lucentia-ui 1.2.0 → 1.4.0
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/components/Calendar/ArrowLeftIcon.d.ts +8 -0
- package/dist/components/Calendar/ArrowLeftIcon.js +5 -0
- package/dist/components/Calendar/ArrowRightIcon.d.ts +8 -0
- package/dist/components/Calendar/ArrowRightIcon.js +5 -0
- package/dist/components/Calendar/Calendar.d.ts +6 -0
- package/dist/components/Calendar/Calendar.js +48 -0
- package/dist/components/Calendar/Calendar.module.css +75 -0
- package/dist/components/Calendar/index.d.ts +2 -0
- package/dist/components/Calendar/index.js +1 -0
- package/dist/components/Calendar/types.d.ts +6 -0
- package/dist/components/Calendar/types.js +1 -0
- package/dist/components/Chart/BarChart/Bar.d.ts +11 -0
- package/dist/components/Chart/BarChart/Bar.js +4 -0
- package/dist/components/Chart/BarChart/Bar.module.css +0 -0
- package/dist/components/Chart/BarChart/BarChart.d.ts +2 -0
- package/dist/components/Chart/BarChart/BarChart.js +22 -0
- package/dist/components/Chart/BarChart/BarSeries.d.ts +10 -0
- package/dist/components/Chart/BarChart/BarSeries.js +27 -0
- package/dist/components/Chart/BarChart/types.d.ts +10 -0
- package/dist/components/Chart/BarChart/types.js +1 -0
- package/dist/components/Chart/BarChart/utils.d.ts +3 -0
- package/dist/components/Chart/BarChart/utils.js +26 -0
- package/dist/components/Chart/ChartAxis.d.ts +6 -0
- package/dist/components/Chart/ChartAxis.js +6 -0
- package/dist/components/Chart/ChartContainer.d.ts +11 -0
- package/dist/components/Chart/ChartContainer.js +22 -0
- package/dist/components/Chart/ChartContainer.module.css +51 -0
- package/dist/components/Chart/ChartContext.d.ts +7 -0
- package/dist/components/Chart/ChartContext.js +9 -0
- package/dist/components/Chart/ChartGrid.d.ts +6 -0
- package/dist/components/Chart/ChartGrid.js +19 -0
- package/dist/components/Chart/ChartLegend.d.ts +9 -0
- package/dist/components/Chart/ChartLegend.js +19 -0
- package/dist/components/Chart/ChartTooltip.d.ts +8 -0
- package/dist/components/Chart/ChartTooltip.js +35 -0
- package/dist/components/Chart/ChartXAxis.d.ts +5 -0
- package/dist/components/Chart/ChartXAxis.js +16 -0
- package/dist/components/Chart/ChartYAxis.d.ts +6 -0
- package/dist/components/Chart/ChartYAxis.js +11 -0
- package/dist/components/Chart/LineChart/LineChart.d.ts +2 -0
- package/dist/components/Chart/LineChart/LineChart.js +27 -0
- package/dist/components/Chart/LineChart/LinePath.d.ts +9 -0
- package/dist/components/Chart/LineChart/LinePath.js +7 -0
- package/dist/components/Chart/LineChart/LinePoint.d.ts +9 -0
- package/dist/components/Chart/LineChart/LinePoint.js +4 -0
- package/dist/components/Chart/LineChart/LineSeries.d.ts +9 -0
- package/dist/components/Chart/LineChart/LineSeries.js +24 -0
- package/dist/components/Chart/LineChart/types.d.ts +9 -0
- package/dist/components/Chart/LineChart/types.js +1 -0
- package/dist/components/Chart/PieChart/PieChart.d.ts +2 -0
- package/dist/components/Chart/PieChart/PieChart.js +9 -0
- package/dist/components/Chart/PieChart/PieSeries.d.ts +2 -0
- package/dist/components/Chart/PieChart/PieSeries.js +40 -0
- package/dist/components/Chart/PieChart/PieSlice.d.ts +12 -0
- package/dist/components/Chart/PieChart/PieSlice.js +8 -0
- package/dist/components/Chart/PieChart/types.d.ts +18 -0
- package/dist/components/Chart/PieChart/types.js +1 -0
- package/dist/components/Chart/PieChart/utils.d.ts +5 -0
- package/dist/components/Chart/PieChart/utils.js +27 -0
- package/dist/components/Chart/RadarChart/RadarAxis.d.ts +4 -0
- package/dist/components/Chart/RadarChart/RadarAxis.js +16 -0
- package/dist/components/Chart/RadarChart/RadarChart.d.ts +2 -0
- package/dist/components/Chart/RadarChart/RadarChart.js +11 -0
- package/dist/components/Chart/RadarChart/RadarGrid.d.ts +5 -0
- package/dist/components/Chart/RadarChart/RadarGrid.js +20 -0
- package/dist/components/Chart/RadarChart/RadarSeries.d.ts +2 -0
- package/dist/components/Chart/RadarChart/RadarSeries.js +33 -0
- package/dist/components/Chart/RadarChart/types.d.ts +22 -0
- package/dist/components/Chart/RadarChart/types.js +1 -0
- package/dist/components/Chart/RadarChart/utils.d.ts +5 -0
- package/dist/components/Chart/RadarChart/utils.js +16 -0
- package/dist/components/Chart/index.d.ts +15 -0
- package/dist/components/Chart/index.js +18 -0
- package/dist/components/Chart/utils/getNiceTicks.d.ts +1 -0
- package/dist/components/Chart/utils/getNiceTicks.js +20 -0
- package/dist/components/DatePicker/CalendarIcon.d.ts +8 -0
- package/dist/components/DatePicker/CalendarIcon.js +5 -0
- package/dist/components/DatePicker/DatePicker.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.js +32 -0
- package/dist/components/DatePicker/DatePicker.module.css +52 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/DatePicker/index.js +1 -0
- package/dist/components/DatePicker/types.d.ts +6 -0
- package/dist/components/DatePicker/types.js +1 -0
- package/dist/components/Feedback/Modal/Modal.module.css +1 -1
- package/dist/components/Feedback/Popover/Popover.d.ts +3 -0
- package/dist/components/Feedback/Popover/Popover.js +22 -0
- package/dist/components/Feedback/Popover/PopoverContent.d.ts +2 -0
- package/dist/components/Feedback/Popover/PopoverContent.js +62 -0
- package/dist/components/Feedback/Popover/PopoverTrigger.d.ts +2 -0
- package/dist/components/Feedback/Popover/PopoverTrigger.js +21 -0
- package/dist/components/Feedback/Popover/popover.module.css +14 -0
- package/dist/components/Feedback/Popover/types.d.ts +19 -0
- package/dist/components/Feedback/Popover/types.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/styles/tokens.css +28 -4
- package/dist/utils/date/generateCalendar.d.ts +5 -0
- package/dist/utils/date/generateCalendar.js +36 -0
- package/package.json +5 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const LinePath = ({ points, color }) => {
|
|
3
|
+
const d = points
|
|
4
|
+
.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`)
|
|
5
|
+
.join(" ");
|
|
6
|
+
return _jsx("path", { d: d, fill: "none", stroke: color, strokeWidth: 3 });
|
|
7
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
cx: number;
|
|
3
|
+
cy: number;
|
|
4
|
+
color: string;
|
|
5
|
+
onMouseEnter?: () => void;
|
|
6
|
+
onMouseLeave?: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const LinePoint: ({ cx, cy, color, onMouseEnter, onMouseLeave, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const LinePoint = ({ cx, cy, color, onMouseEnter, onMouseLeave, }) => {
|
|
3
|
+
return (_jsx("circle", { cx: cx, cy: cy, r: 5, fill: color, stroke: "var(--color-surface)", strokeWidth: 2, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }));
|
|
4
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
data: any[];
|
|
3
|
+
keys: string[];
|
|
4
|
+
max: number;
|
|
5
|
+
onHover?: (label: string, key: string, value: number) => void;
|
|
6
|
+
onLeave?: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const LineSeries: ({ data, keys, max, onHover, onLeave }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useChart } from "../ChartContext";
|
|
3
|
+
import { scaleValue } from "../BarChart/utils";
|
|
4
|
+
import { LinePath } from "./LinePath";
|
|
5
|
+
import { LinePoint } from "./LinePoint";
|
|
6
|
+
export const LineSeries = ({ data, keys, max, onHover, onLeave }) => {
|
|
7
|
+
const { width, height, padding } = useChart();
|
|
8
|
+
const innerWidth = width - padding * 2;
|
|
9
|
+
const innerHeight = height - padding * 2;
|
|
10
|
+
// XAxisと同じ中央配置ロジック
|
|
11
|
+
const groupWidth = innerWidth / data.length;
|
|
12
|
+
return (_jsx("g", { children: keys.map((key, kIndex) => {
|
|
13
|
+
const points = data.map((d, i) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const value = Number((_a = d[key]) !== null && _a !== void 0 ? _a : 0);
|
|
16
|
+
const x = padding + groupWidth * (i + 0.5);
|
|
17
|
+
const y = height -
|
|
18
|
+
padding -
|
|
19
|
+
scaleValue(value, max, innerHeight);
|
|
20
|
+
return { x, y, value, label: d.label };
|
|
21
|
+
});
|
|
22
|
+
return (_jsxs("g", { children: [_jsx(LinePath, { points: points, color: `var(--color-primary)` }), points.map((p, i) => (_jsx(LinePoint, { cx: p.x, cy: p.y, color: `var(--color-primary)`, onMouseEnter: () => onHover === null || onHover === void 0 ? void 0 : onHover(p.label, key, p.value), onMouseLeave: onLeave }, i)))] }, key));
|
|
23
|
+
}) }));
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { ChartContainer } from "../ChartContainer";
|
|
4
|
+
import { ChartTooltip } from "../ChartTooltip";
|
|
5
|
+
import { PieSeries } from "./PieSeries";
|
|
6
|
+
export const PieChart = ({ data, width = 300, height = 300, radius, innerRadius = 0, }) => {
|
|
7
|
+
const [tooltip, setTooltip] = useState(null);
|
|
8
|
+
return (_jsxs(ChartContainer, { width: width, height: height, children: [_jsx(PieSeries, { data: data, radius: radius, innerRadius: innerRadius, onHover: (label, value, x, y) => setTooltip({ label, value, x, y }), onLeave: () => setTooltip(null) }), tooltip && (_jsxs(ChartTooltip, { x: tooltip.x + 10, y: tooltip.y - 10, children: [_jsx("div", { children: tooltip.label }), _jsx("div", { style: { fontWeight: "var(--font-weight-bold)" }, children: tooltip.value })] }))] }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useChart } from "../ChartContext";
|
|
4
|
+
import { PieSlice } from "./PieSlice";
|
|
5
|
+
import { describeArc } from "./utils";
|
|
6
|
+
export const PieSeries = ({ data, radius, innerRadius = 0, onHover, onLeave, }) => {
|
|
7
|
+
const { width, height } = useChart();
|
|
8
|
+
const [hoverIndex, setHoverIndex] = useState(null);
|
|
9
|
+
const cx = width / 2;
|
|
10
|
+
const cy = height / 2;
|
|
11
|
+
const r = radius !== null && radius !== void 0 ? radius : Math.min(width, height) / 2;
|
|
12
|
+
const total = data.reduce((sum, d) => sum + d.value, 0);
|
|
13
|
+
let startAngle = 0;
|
|
14
|
+
const getSVGPoint = (e) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const svg = e.currentTarget.ownerSVGElement;
|
|
17
|
+
if (!svg)
|
|
18
|
+
return { x: 0, y: 0 };
|
|
19
|
+
const pt = svg.createSVGPoint();
|
|
20
|
+
pt.x = e.clientX;
|
|
21
|
+
pt.y = e.clientY;
|
|
22
|
+
const cursorpt = pt.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
|
|
23
|
+
return { x: cursorpt.x, y: cursorpt.y };
|
|
24
|
+
};
|
|
25
|
+
return (_jsx("g", { children: data.map((d, i) => {
|
|
26
|
+
const angle = (d.value / total) * 360;
|
|
27
|
+
const endAngle = startAngle + angle;
|
|
28
|
+
const path = describeArc(cx, cy, r, startAngle, endAngle, innerRadius);
|
|
29
|
+
startAngle = endAngle;
|
|
30
|
+
const scale = hoverIndex === i ? 1.04 : 1;
|
|
31
|
+
return (_jsx(PieSlice, { d: path, color: `var(--chart-color-${i + 1})`, cx: cx, cy: cy, scale: scale, onMouseMove: (e) => {
|
|
32
|
+
setHoverIndex(i);
|
|
33
|
+
const { x, y } = getSVGPoint(e);
|
|
34
|
+
onHover === null || onHover === void 0 ? void 0 : onHover(d.label, d.value, x, y);
|
|
35
|
+
}, onMouseLeave: () => {
|
|
36
|
+
setHoverIndex(null);
|
|
37
|
+
onLeave === null || onLeave === void 0 ? void 0 : onLeave();
|
|
38
|
+
} }, i));
|
|
39
|
+
}) }));
|
|
40
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MouseEvent } from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
d: string;
|
|
4
|
+
color: string;
|
|
5
|
+
cx: number;
|
|
6
|
+
cy: number;
|
|
7
|
+
scale?: number;
|
|
8
|
+
onMouseMove?: (e: MouseEvent<SVGPathElement>) => void;
|
|
9
|
+
onMouseLeave?: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const PieSlice: ({ d, color, cx, cy, scale, onMouseMove, onMouseLeave, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const PieSlice = ({ d, color, cx, cy, scale = 1, onMouseMove, onMouseLeave, }) => {
|
|
3
|
+
return (_jsx("path", { d: d, fill: color, transform: `scale(${scale})`, style: {
|
|
4
|
+
cursor: "default",
|
|
5
|
+
transformOrigin: `${cx}px ${cy}px`,
|
|
6
|
+
transition: "transform 120ms ease",
|
|
7
|
+
}, onMouseMove: onMouseMove, onMouseLeave: onMouseLeave }));
|
|
8
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type PieDatum = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: number;
|
|
4
|
+
};
|
|
5
|
+
export type PieChartProps = {
|
|
6
|
+
data: PieDatum[];
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
radius?: number;
|
|
10
|
+
innerRadius?: number;
|
|
11
|
+
};
|
|
12
|
+
export type PieSeriesProps = {
|
|
13
|
+
data: PieDatum[];
|
|
14
|
+
radius?: number;
|
|
15
|
+
innerRadius?: number;
|
|
16
|
+
onHover?: (label: string, value: number, x: number, y: number) => void;
|
|
17
|
+
onLeave?: () => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const polarToCartesian = (cx, cy, r, angle) => {
|
|
2
|
+
const rad = (angle - 90) * (Math.PI / 180);
|
|
3
|
+
return {
|
|
4
|
+
x: cx + r * Math.cos(rad),
|
|
5
|
+
y: cy + r * Math.sin(rad),
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export const describeArc = (cx, cy, r, startAngle, endAngle, innerRadius = 0) => {
|
|
9
|
+
const outerStart = polarToCartesian(cx, cy, r, endAngle);
|
|
10
|
+
const outerEnd = polarToCartesian(cx, cy, r, startAngle);
|
|
11
|
+
const largeArcFlag = endAngle - startAngle > 180 ? 1 : 0;
|
|
12
|
+
if (innerRadius === 0) {
|
|
13
|
+
return ` M ${outerStart.x} ${outerStart.y}
|
|
14
|
+
A ${r} ${r} 0 ${largeArcFlag} 0 ${outerEnd.x} ${outerEnd.y}
|
|
15
|
+
L ${cx} ${cy}
|
|
16
|
+
Z
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
const innerStart = polarToCartesian(cx, cy, innerRadius, endAngle);
|
|
20
|
+
const innerEnd = polarToCartesian(cx, cy, innerRadius, startAngle);
|
|
21
|
+
return ` M ${outerStart.x} ${outerStart.y}
|
|
22
|
+
A ${r} ${r} 0 ${largeArcFlag} 0 ${outerEnd.x} ${outerEnd.y}
|
|
23
|
+
L ${innerEnd.x} ${innerEnd.y}
|
|
24
|
+
A ${innerRadius} ${innerRadius} 0 ${largeArcFlag} 1 ${innerStart.x} ${innerStart.y}
|
|
25
|
+
Z
|
|
26
|
+
`;
|
|
27
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useChart } from "../ChartContext";
|
|
3
|
+
import { polarToCartesian } from "./utils";
|
|
4
|
+
export const RadarAxis = ({ data, }) => {
|
|
5
|
+
const { width, height } = useChart();
|
|
6
|
+
const cx = width / 2;
|
|
7
|
+
const cy = height / 2;
|
|
8
|
+
const radius = Math.min(width, height) / 2 - 24;
|
|
9
|
+
const step = (Math.PI * 2) / data.length;
|
|
10
|
+
return (_jsx("g", { fontSize: 14, textAnchor: "middle", fill: "var(--color-on-surface)", children: data.map((d, i) => {
|
|
11
|
+
const angle = i * step - Math.PI / 2;
|
|
12
|
+
const lineEnd = polarToCartesian(cx, cy, radius, angle);
|
|
13
|
+
const labelPos = polarToCartesian(cx, cy, radius + 16, angle);
|
|
14
|
+
return (_jsxs("g", { children: [_jsx("line", { x1: cx, y1: cy, x2: lineEnd.x, y2: lineEnd.y, stroke: "var(--chart-grid)" }), _jsx("text", { x: labelPos.x, y: labelPos.y, children: d.label })] }, i));
|
|
15
|
+
}) }));
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { ChartContainer } from "../ChartContainer";
|
|
4
|
+
import { ChartTooltip } from "../ChartTooltip";
|
|
5
|
+
import { RadarGrid } from "./RadarGrid";
|
|
6
|
+
import { RadarAxis } from "./RadarAxis";
|
|
7
|
+
import { RadarSeries } from "./RadarSeries";
|
|
8
|
+
export const RadarChart = ({ data, width = 320, height = 320, levels = 5, }) => {
|
|
9
|
+
const [tooltip, setTooltip] = useState(null);
|
|
10
|
+
return (_jsxs(ChartContainer, { width: width, height: height, children: [" ", _jsx(RadarGrid, { data: data, levels: levels }), _jsx(RadarAxis, { data: data }), _jsx(RadarSeries, { data: data, onHover: (label, value, x, y) => setTooltip({ label, value, x, y }), onLeave: () => setTooltip(null) }), tooltip && (_jsxs(ChartTooltip, { x: tooltip.x + 10, y: tooltip.y - 10, children: [_jsx("div", { children: tooltip.label }), _jsx("div", { children: tooltip.value })] }))] }));
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useChart } from "../ChartContext";
|
|
3
|
+
import { polarToCartesian } from "./utils";
|
|
4
|
+
export const RadarGrid = ({ data, levels = 5, }) => {
|
|
5
|
+
const { width, height } = useChart();
|
|
6
|
+
const axes = data.length;
|
|
7
|
+
const cx = width / 2;
|
|
8
|
+
const cy = height / 2;
|
|
9
|
+
const radius = Math.min(width, height) / 2 - 24;
|
|
10
|
+
const step = (Math.PI * 2) / axes;
|
|
11
|
+
return (_jsx("g", { stroke: "var(--chart-grid)", fill: "none", children: [...Array(levels)].map((_, level) => {
|
|
12
|
+
const r = (radius / levels) * (level + 1);
|
|
13
|
+
const points = [...Array(axes)].map((_, i) => {
|
|
14
|
+
const angle = i * step - Math.PI / 2;
|
|
15
|
+
const p = polarToCartesian(cx, cy, r, angle);
|
|
16
|
+
return `${p.x},${p.y}`;
|
|
17
|
+
});
|
|
18
|
+
return (_jsx("polygon", { points: points.join(" ") }, level));
|
|
19
|
+
}) }));
|
|
20
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useChart } from "../ChartContext";
|
|
3
|
+
import { createRadarPath, polarToCartesian, } from "./utils";
|
|
4
|
+
export const RadarSeries = ({ data, onHover, onLeave, }) => {
|
|
5
|
+
const { width, height } = useChart();
|
|
6
|
+
const cx = width / 2;
|
|
7
|
+
const cy = height / 2;
|
|
8
|
+
const radius = Math.min(width, height) / 2 - 24;
|
|
9
|
+
const values = data.map((d) => d.value);
|
|
10
|
+
const max = Math.max(...values);
|
|
11
|
+
const path = createRadarPath(cx, cy, radius, values, max);
|
|
12
|
+
const step = (Math.PI * 2) / data.length;
|
|
13
|
+
const getSVGPoint = (e) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const svg = e.currentTarget.ownerSVGElement;
|
|
16
|
+
if (!svg)
|
|
17
|
+
return { x: 0, y: 0 };
|
|
18
|
+
const pt = svg.createSVGPoint();
|
|
19
|
+
pt.x = e.clientX;
|
|
20
|
+
pt.y = e.clientY;
|
|
21
|
+
const cursorpt = pt.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
|
|
22
|
+
return { x: cursorpt.x, y: cursorpt.y };
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs("g", { children: [" ", _jsx("path", { d: path, fill: "var(--chart-color-1)", fillOpacity: 0.25, stroke: "var(--chart-color-1)", strokeWidth: 2 }), data.map((d, i) => {
|
|
25
|
+
const r = (d.value / max) * radius;
|
|
26
|
+
const angle = i * step - Math.PI / 2;
|
|
27
|
+
const p = polarToCartesian(cx, cy, r, angle);
|
|
28
|
+
return (_jsx("circle", { cx: p.x, cy: p.y, r: 12, fillOpacity: 0, style: { cursor: "default" }, onMouseMove: (e) => {
|
|
29
|
+
const { x, y } = getSVGPoint(e);
|
|
30
|
+
onHover === null || onHover === void 0 ? void 0 : onHover(d.label, d.value, x, y);
|
|
31
|
+
}, onMouseLeave: onLeave }, i));
|
|
32
|
+
})] }));
|
|
33
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type RadarDatum = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: number;
|
|
4
|
+
};
|
|
5
|
+
export type RadarChartProps = {
|
|
6
|
+
data: RadarDatum[];
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
levels?: number;
|
|
10
|
+
};
|
|
11
|
+
export type RadarSeriesProps = {
|
|
12
|
+
data: RadarDatum[];
|
|
13
|
+
onHover?: (label: string, value: number, x: number, y: number) => void;
|
|
14
|
+
onLeave?: () => void;
|
|
15
|
+
};
|
|
16
|
+
export type RadarGridProps = {
|
|
17
|
+
data: RadarDatum[];
|
|
18
|
+
levels?: number;
|
|
19
|
+
};
|
|
20
|
+
export type RadarAxisProps = {
|
|
21
|
+
data: RadarDatum[];
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const polarToCartesian = (cx, cy, r, angle) => {
|
|
2
|
+
return {
|
|
3
|
+
x: cx + r * Math.cos(angle),
|
|
4
|
+
y: cy + r * Math.sin(angle),
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export const createRadarPath = (cx, cy, radius, values, max) => {
|
|
8
|
+
const step = (Math.PI * 2) / values.length;
|
|
9
|
+
const points = values.map((v, i) => {
|
|
10
|
+
const r = (v / max) * radius;
|
|
11
|
+
const angle = i * step - Math.PI / 2;
|
|
12
|
+
const p = polarToCartesian(cx, cy, r, angle);
|
|
13
|
+
return `${p.x} ${p.y}`;
|
|
14
|
+
});
|
|
15
|
+
return `M ${points.join(" L ")} Z`;
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { ChartContainer } from "./ChartContainer";
|
|
2
|
+
export { ChartTooltip } from "./ChartTooltip";
|
|
3
|
+
export { ChartLegend } from "./ChartLegend";
|
|
4
|
+
export { ChartAxis } from "./ChartAxis";
|
|
5
|
+
export { ChartXAxis } from "./ChartXAxis";
|
|
6
|
+
export { ChartYAxis } from "./ChartYAxis";
|
|
7
|
+
export { ChartGrid } from "./ChartGrid";
|
|
8
|
+
export { BarChart } from "./BarChart/BarChart";
|
|
9
|
+
export type { BarChartProps } from "./BarChart/types";
|
|
10
|
+
export { LineChart } from "./LineChart/LineChart";
|
|
11
|
+
export type { LineChartProps } from "./LineChart/types";
|
|
12
|
+
export { PieChart } from "./PieChart/PieChart";
|
|
13
|
+
export type { PieChartProps, PieDatum } from "./PieChart/types";
|
|
14
|
+
export { RadarChart } from "./RadarChart/RadarChart";
|
|
15
|
+
export type { RadarChartProps, RadarDatum } from "./RadarChart/types";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// =========================
|
|
2
|
+
// Core
|
|
3
|
+
// =========================
|
|
4
|
+
export { ChartContainer } from "./ChartContainer";
|
|
5
|
+
export { ChartTooltip } from "./ChartTooltip";
|
|
6
|
+
export { ChartLegend } from "./ChartLegend";
|
|
7
|
+
// Axis / Grid
|
|
8
|
+
export { ChartAxis } from "./ChartAxis";
|
|
9
|
+
export { ChartXAxis } from "./ChartXAxis";
|
|
10
|
+
export { ChartYAxis } from "./ChartYAxis";
|
|
11
|
+
export { ChartGrid } from "./ChartGrid";
|
|
12
|
+
// =========================
|
|
13
|
+
// Charts
|
|
14
|
+
// =========================
|
|
15
|
+
export { BarChart } from "./BarChart/BarChart";
|
|
16
|
+
export { LineChart } from "./LineChart/LineChart";
|
|
17
|
+
export { PieChart } from "./PieChart/PieChart";
|
|
18
|
+
export { RadarChart } from "./RadarChart/RadarChart";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getNiceTicks: (max: number, tickCount?: number) => number[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const getNiceTicks = (max, tickCount = 5) => {
|
|
2
|
+
if (max === 0)
|
|
3
|
+
return [0];
|
|
4
|
+
const roughStep = max / (tickCount - 1);
|
|
5
|
+
const magnitude = Math.pow(10, Math.floor(Math.log10(roughStep)));
|
|
6
|
+
const residual = roughStep / magnitude;
|
|
7
|
+
let niceStep = magnitude;
|
|
8
|
+
if (residual > 5)
|
|
9
|
+
niceStep = 10 * magnitude;
|
|
10
|
+
else if (residual > 2)
|
|
11
|
+
niceStep = 5 * magnitude;
|
|
12
|
+
else if (residual > 1)
|
|
13
|
+
niceStep = 2 * magnitude;
|
|
14
|
+
const niceMax = Math.ceil(max / niceStep) * niceStep;
|
|
15
|
+
const ticks = [];
|
|
16
|
+
for (let v = 0; v <= niceMax; v += niceStep) {
|
|
17
|
+
ticks.push(v);
|
|
18
|
+
}
|
|
19
|
+
return ticks;
|
|
20
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const CalendarIcon = ({ size = 24, color = "tranparent", className = "", }) => {
|
|
3
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", className: className, children: _jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M21 19C21 20.1046 20.1046 21 19 21H5C3.89543 21 3 20.1046 3 19V9H21V19ZM5.5 16C5.22386 16 5 16.2239 5 16.5V17.5C5 17.7761 5.22386 18 5.5 18H6.5C6.77614 18 7 17.7761 7 17.5V16.5C7 16.2239 6.77614 16 6.5 16H5.5ZM9.5 16C9.22386 16 9 16.2239 9 16.5V17.5C9 17.7761 9.22386 18 9.5 18H10.5C10.7761 18 11 17.7761 11 17.5V16.5C11 16.2239 10.7761 16 10.5 16H9.5ZM13.5 16C13.2239 16 13 16.2239 13 16.5V17.5C13 17.7761 13.2239 18 13.5 18H14.5C14.7761 18 15 17.7761 15 17.5V16.5C15 16.2239 14.7761 16 14.5 16H13.5ZM17.5 16C17.2239 16 17 16.2239 17 16.5V17.5C17 17.7761 17.2239 18 17.5 18H18.5C18.7761 18 19 17.7761 19 17.5V16.5C19 16.2239 18.7761 16 18.5 16H17.5ZM5.5 12C5.22386 12 5 12.2239 5 12.5V13.5C5 13.7761 5.22386 14 5.5 14H6.5C6.77614 14 7 13.7761 7 13.5V12.5C7 12.2239 6.77614 12 6.5 12H5.5ZM9.5 12C9.22386 12 9 12.2239 9 12.5V13.5C9 13.7761 9.22386 14 9.5 14H10.5C10.7761 14 11 13.7761 11 13.5V12.5C11 12.2239 10.7761 12 10.5 12H9.5ZM13.5 12C13.2239 12 13 12.2239 13 12.5V13.5C13 13.7761 13.2239 14 13.5 14H14.5C14.7761 14 15 13.7761 15 13.5V12.5C15 12.2239 14.7761 12 14.5 12H13.5ZM17.5 12C17.2239 12 17 12.2239 17 12.5V13.5C17 13.7761 17.2239 14 17.5 14H18.5C18.7761 14 19 13.7761 19 13.5V12.5C19 12.2239 18.7761 12 18.5 12H17.5Z", fill: "currentColor" }), _jsx("path", { d: "M7.5 3C7.77614 3 8 3.22386 8 3.5V5H16V3.5C16 3.22386 16.2239 3 16.5 3H17.5C17.7761 3 18 3.22386 18 3.5V5H19C20.1046 5 21 5.89543 21 7V8H3V7C3 5.89543 3.89543 5 5 5H6V3.5C6 3.22386 6.22386 3 6.5 3H7.5Z", fill: "currentColor" })] }) }));
|
|
4
|
+
};
|
|
5
|
+
export default CalendarIcon;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Popover } from "../Feedback/Popover/Popover";
|
|
5
|
+
import { PopoverTrigger } from "../Feedback/Popover/PopoverTrigger";
|
|
6
|
+
import { PopoverContent } from "../Feedback/Popover/PopoverContent";
|
|
7
|
+
import { Calendar } from "../Calendar/Calendar";
|
|
8
|
+
import { CalendarIcon } from "./CalendarIcon";
|
|
9
|
+
import styeles from "./DatePicker.module.css";
|
|
10
|
+
export const DatePicker = ({ value: valueProp, defaultValue, onChange, placeholder = "YYYY/MM/DD", }) => {
|
|
11
|
+
// --- value制御 ---
|
|
12
|
+
const isControlled = valueProp !== undefined;
|
|
13
|
+
const [internalValue, setInternalValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : null);
|
|
14
|
+
const value = isControlled ? valueProp : internalValue;
|
|
15
|
+
const setValue = (date) => {
|
|
16
|
+
if (!isControlled) {
|
|
17
|
+
setInternalValue(date);
|
|
18
|
+
}
|
|
19
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(date);
|
|
20
|
+
};
|
|
21
|
+
// --- Popover制御(追加) ---
|
|
22
|
+
const [open, setOpen] = useState(false);
|
|
23
|
+
const formatDate = (date) => {
|
|
24
|
+
if (!date)
|
|
25
|
+
return "";
|
|
26
|
+
return date.toLocaleDateString();
|
|
27
|
+
};
|
|
28
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("div", { className: styeles.inputWrapper, children: [_jsx("input", { readOnly: true, className: styeles.dateInput, value: formatDate(value), placeholder: placeholder }), _jsx(CalendarIcon, { className: styeles.calendarIcon })] }) }), _jsx(PopoverContent, { children: _jsx(Calendar, { value: value, onChange: (date) => {
|
|
29
|
+
setValue(date);
|
|
30
|
+
setOpen(false);
|
|
31
|
+
} }) })] }));
|
|
32
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
.inputWrapper {
|
|
3
|
+
position: relative;
|
|
4
|
+
width: 100%; /* 必要に応じて調整 */
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
.calendarIcon{
|
|
9
|
+
color: var(--color-on-surface-variant);
|
|
10
|
+
position: absolute;
|
|
11
|
+
top: 50%;
|
|
12
|
+
transform: translateY(-50%);
|
|
13
|
+
right: 16px;
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.dateInput{
|
|
18
|
+
font-family: var(--font);
|
|
19
|
+
border-radius: var(--radius-sm);
|
|
20
|
+
border: 2px solid var(--color-background);
|
|
21
|
+
outline: none;
|
|
22
|
+
background: var(--color-surface-container);
|
|
23
|
+
color: var(--color-on-surface);
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
transition:
|
|
26
|
+
border-color 0.2s ease,
|
|
27
|
+
box-shadow 0.2s ease;
|
|
28
|
+
|
|
29
|
+
font-size: var(--font-size-16);
|
|
30
|
+
padding: var(--space-md) var(--space-lg);
|
|
31
|
+
box-shadow: var(--shadow-md-in);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/* ===== Focus ===== */
|
|
37
|
+
.dateInput:focus {
|
|
38
|
+
outline: none;
|
|
39
|
+
border: 2px solid var(--color-primary);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* ===== Error ===== */
|
|
43
|
+
.error {
|
|
44
|
+
border: 2px solid var(--color-error);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* ===== Disabled ===== */
|
|
48
|
+
.dateInput:disabled {
|
|
49
|
+
opacity: 0.5;
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
}
|
|
52
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DatePicker } from "./DatePicker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PopoverProps, PopoverContextType } from "./types";
|
|
2
|
+
export declare const PopoverContext: import("react").Context<PopoverContextType | null>;
|
|
3
|
+
export declare const Popover: ({ children, open: openProp, defaultOpen, onOpenChange, }: PopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useRef, useState } from "react";
|
|
4
|
+
import styles from "./popover.module.css";
|
|
5
|
+
export const PopoverContext = createContext(null);
|
|
6
|
+
export const Popover = ({ children, open: openProp, defaultOpen = false, onOpenChange, }) => {
|
|
7
|
+
const isControlled = openProp !== undefined;
|
|
8
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
9
|
+
const open = isControlled ? openProp : internalOpen;
|
|
10
|
+
const setOpen = (next) => {
|
|
11
|
+
if (!isControlled) {
|
|
12
|
+
setInternalOpen(next);
|
|
13
|
+
}
|
|
14
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(next);
|
|
15
|
+
};
|
|
16
|
+
const referenceRef = useRef(null);
|
|
17
|
+
return (_jsx(PopoverContext.Provider, { value: {
|
|
18
|
+
open,
|
|
19
|
+
setOpen,
|
|
20
|
+
referenceRef,
|
|
21
|
+
}, children: _jsx("div", { className: styles.root, children: children }) }));
|
|
22
|
+
};
|