ingred-ui 35.0.0 → 36.1.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/README.md CHANGED
@@ -55,7 +55,7 @@ Storybook: https://ingred-ui.netlify.app/
55
55
 
56
56
  ## Development
57
57
 
58
- Node.js 20 以上を推奨します。パッケージ管理は [pnpm](https://pnpm.io/)(`package.json` の `packageManager`)。**ローカル開発では `make` が `pnpm run` のラッパー**(fluct_ms の client と同様)。CI は従来どおり `ci.mk` を使用します。
58
+ Node.js 24 以上が必要です。パッケージ管理は [pnpm](https://pnpm.io/)(`package.json` の `packageManager`)。**ローカル開発では `make` が `pnpm run` のラッパー**(fluct_ms の client と同様)。CI は従来どおり `ci.mk` を使用します。
59
59
 
60
60
  ```bash
61
61
  # 初回・依存更新後
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import { PieChartProps } from "./types";
3
+ declare const PieChart: React.FC<PieChartProps>;
4
+ export default PieChart;
@@ -0,0 +1,2 @@
1
+ export { default as PieChart } from "./PieChart";
2
+ export type { PieChartProps, PieChartVariant, PieSlice, PieSliceLabel, PieSliceLabelStyle, } from "./types";
@@ -0,0 +1,79 @@
1
+ export type PieSlice = {
2
+ /** 表示名。凡例・表示切替の内部キーは index 付きで一意化する */
3
+ label: string;
4
+ /** 0 以下はスライスとして描画しない */
5
+ value: number;
6
+ /** 未指定時は theme.palette.chart の系列色を使う */
7
+ color?: string;
8
+ };
9
+ export type PieChartVariant = "pie" | "donut";
10
+ /** スライス外側ラベルの内容。none は非表示 */
11
+ export type PieSliceLabel = "none" | "value" | "percent" | "both";
12
+ /** スライス外側ラベルの見た目。未指定項目は theme.palette.chart.pie.label */
13
+ export type PieSliceLabelStyle = {
14
+ fontSize?: number;
15
+ color?: string;
16
+ };
17
+ export type PieChartProps = {
18
+ data: PieSlice[];
19
+ /** pie: 円 / donut: 穴あき。デフォルト pie */
20
+ variant?: PieChartVariant;
21
+ /**
22
+ * theme.palette.chart.colorSchemes のキー。
23
+ * 未指定時は palette.chart.series(デフォルト)を使う。
24
+ */
25
+ colorScheme?: string;
26
+ /**
27
+ * 数値の表示。tooltip のほか、外側ラベル・内側ラベル・donut 中央合計にも使う。
28
+ * 未指定時は toLocaleString()
29
+ */
30
+ valueFormatter?: (value: number) => string;
31
+ /**
32
+ * スライス外側のラベル。
33
+ * - none: 出さない(デフォルト)
34
+ * - value: 絶対値
35
+ * - percent: 構成比
36
+ * - both: 絶対値と構成比
37
+ */
38
+ sliceLabel?: PieSliceLabel;
39
+ /**
40
+ * スライス外側ラベルのフォントサイズ・色。
41
+ * 未指定項目は theme.palette.chart.pie.label を使う。
42
+ */
43
+ sliceLabelStyle?: PieSliceLabelStyle;
44
+ /**
45
+ * スライス内側のラベル。
46
+ * - none: 出さない(デフォルト)
47
+ * - value: 絶対値
48
+ * - percent: 構成比
49
+ * - both: 絶対値と構成比
50
+ */
51
+ innerLabel?: PieSliceLabel;
52
+ /**
53
+ * スライス内側ラベルのフォントサイズ・色。
54
+ * 色を省略したときはスライス色とのコントラストで白または theme 色を選ぶ。
55
+ */
56
+ innerLabelStyle?: PieSliceLabelStyle;
57
+ /** スライスが 2 個以上のとき凡例を表示。デフォルト true */
58
+ showLegend?: boolean;
59
+ /**
60
+ * donut の中央に表示中スライスの合計を出す。
61
+ * pie では無視。デフォルト true
62
+ */
63
+ showCenterTotal?: boolean;
64
+ /**
65
+ * donut 中央の合計のフォントサイズ・色。
66
+ * fontSize は数値に適用(「合計」はそれに合わせて小さめ)。
67
+ * 未指定時のサイズは穴の大きさから自動、色は theme.palette.chart.pie.centerTotal。
68
+ */
69
+ centerTotalStyle?: PieSliceLabelStyle;
70
+ /** 凡例クリックでスライスの表示/非表示を切り替え。デフォルト true */
71
+ interactiveLegend?: boolean;
72
+ /** true の間、チャートの代わりにローディング表示 */
73
+ loading?: boolean;
74
+ /** 描画可能なデータがないときのメッセージ。未指定時は「データがありません」 */
75
+ emptyMessage?: string;
76
+ "aria-label": string;
77
+ height?: number;
78
+ className?: string;
79
+ };
@@ -6,6 +6,8 @@ export { AreaChart } from "./AreaChart";
6
6
  export type { AreaChartLayout, AreaChartProps } from "./AreaChart";
7
7
  export { BarLineChart } from "./BarLineChart";
8
8
  export type { BarLineChartProps } from "./BarLineChart";
9
+ export { PieChart } from "./PieChart";
10
+ export type { PieChartProps, PieChartVariant, PieSlice, PieSliceLabel, PieSliceLabelStyle, } from "./PieChart";
9
11
  export type { BarSegment, BarChartOrientation, ChartHoverState, ChartReferenceLine, ChartReferenceLineAxis, ChartSeries, ResolvedChartSeries, } from "./types";
10
12
  export type { LinePoint, LinePathSegment, LineSeriesGeometry, } from "./internal/getLineSeries";
11
13
  export { computeYTicks, computeMaxStackedTotal } from "./internal/utils";
@@ -24,3 +26,5 @@ export { computeAreaChartMaxValue, getAreaSegments, getOverlayAreaPath, getStack
24
26
  export type { AreaPathSegment } from "./internal/getAreaPath";
25
27
  export { hasBarLineChartData } from "./internal/hasBarLineChartData";
26
28
  export { getBarLineChartAxisSeries, getBarLineChartDrawBarSeries, getBarLineChartReferenceLineLegendItems, getBarLineSeriesDisplayLabel, getBarLineSeriesKey, } from "./internal/getBarLineChartSeries";
29
+ export { describeSlicePath, formatPieSliceLabel, getPieCenterTotalValueFontSize, getPieSliceInnerLabelLayout, getPieSliceLabelGutter, getPieSliceLabelLayout, getPieDrawableSeriesLabels, getPieSliceDisplayLabel, getPieSliceKey, getPieSlices, getPieTotal, hasPieChartData, pickContrastingLabelColor, resolvePieCenterTotalStyle, resolvePieSliceLabelStyle, } from "./internal/getPieSlices";
30
+ export type { PieSliceGeometry, PieSliceInnerLabelLayout, PieSliceInput, PieSliceLabelGutterOptions, PieSliceLabelLayout, } from "./internal/getPieSlices";
@@ -0,0 +1,78 @@
1
+ export type PieSliceInput = {
2
+ /** React key / 凡例トグル用。未指定時は label */
3
+ id?: string;
4
+ label: string;
5
+ value: number;
6
+ color: string;
7
+ };
8
+ export type PieSliceGeometry = {
9
+ id: string;
10
+ label: string;
11
+ color: string;
12
+ value: number;
13
+ startAngle: number;
14
+ endAngle: number;
15
+ path: string;
16
+ };
17
+ /** 同名スライスを区別する内部キー */
18
+ export declare function getPieSliceKey(index: number, label: string): string;
19
+ export declare function getPieSliceDisplayLabel(seriesKey: string): string;
20
+ /** 凡例の last-1 ガード用。0 以下は描画しないのでカウントしない */
21
+ export declare function getPieDrawableSeriesLabels(series: readonly {
22
+ label: string;
23
+ data: readonly (number | null)[];
24
+ }[]): string[];
25
+ export declare function describeSlicePath(cx: number, cy: number, outerRadius: number, innerRadius: number, startAngle: number, endAngle: number): string;
26
+ export declare function hasPieChartData(data: readonly Pick<PieSliceInput, "value">[]): boolean;
27
+ /** 正の値だけを合計する(0 以下は無視) */
28
+ export declare function getPieTotal(data: readonly Pick<PieSliceInput, "value">[]): number;
29
+ export type PieSliceLabelGutterOptions = {
30
+ labels?: readonly string[];
31
+ fontSize?: number;
32
+ };
33
+ /** フォーマット済みラベルと fontSize から外側ラベル用の SVG 余白を取る */
34
+ export declare function getPieSliceLabelGutter(mode: "none" | "value" | "percent" | "both", options?: PieSliceLabelGutterOptions): {
35
+ x: number;
36
+ y: number;
37
+ };
38
+ export type PieSliceLabelLayout = {
39
+ midAngle: number;
40
+ lineStartX: number;
41
+ lineStartY: number;
42
+ lineEndX: number;
43
+ lineEndY: number;
44
+ textX: number;
45
+ textY: number;
46
+ textAnchor: "start" | "end";
47
+ percent: number;
48
+ };
49
+ /** スライス色に対してコントラストが高い方のラベル色を返す。解析できない色は darkColor */
50
+ export declare function pickContrastingLabelColor(background: string, lightColor: string, darkColor: string): string;
51
+ export declare function resolvePieSliceLabelStyle(themeStyle: {
52
+ fontSize: number;
53
+ color: string;
54
+ }, override?: {
55
+ fontSize?: number;
56
+ color?: string;
57
+ }): {
58
+ fontSize: number;
59
+ color: string;
60
+ };
61
+ /** donut 中央の数値サイズ。穴とフォーマット済み文字列の幅から 12〜24 に収める */
62
+ export declare function getPieCenterTotalValueFontSize(innerRadius: number, formattedValue?: string): number;
63
+ export declare function resolvePieCenterTotalStyle(themeColor: string, autoFontSize: number, override?: {
64
+ fontSize?: number;
65
+ color?: string;
66
+ }): {
67
+ fontSize: number;
68
+ color: string;
69
+ captionFontSize: number;
70
+ };
71
+ export declare function formatPieSliceLabel(value: number, total: number, mode: "value" | "percent" | "both", valueFormatter: (value: number) => string, percentFormatter: (value: number) => string): string;
72
+ export declare function getPieSliceLabelLayout(startAngle: number, endAngle: number, value: number, total: number, cx: number, cy: number, outerRadius: number): PieSliceLabelLayout | null;
73
+ export type PieSliceInnerLabelLayout = {
74
+ x: number;
75
+ y: number;
76
+ };
77
+ export declare function getPieSliceInnerLabelLayout(startAngle: number, endAngle: number, cx: number, cy: number, outerRadius: number, innerRadius: number): PieSliceInnerLabelLayout | null;
78
+ export declare function getPieSlices(data: readonly PieSliceInput[], cx: number, cy: number, outerRadius: number, innerRadius: number): PieSliceGeometry[];