Skip to content

Commit 9d4ab27

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix/build-foundation/cjs-migrate-to-rollup
2 parents cfc3f81 + 6fb78d1 commit 9d4ab27

87 files changed

Lines changed: 1959 additions & 1172 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ reg_storybook
7878
smarthr-ui.css
7979

8080
.idea
81-
.vscode
81+
.vscode
82+
packages/smarthr-ui/metadata.json

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"devDependencies": {
77
"@commitlint/cli": "^20.3.1",
88
"@commitlint/config-conventional": "^20.3.1",
9-
"eslint": "^9.32.0",
10-
"eslint-config-smarthr": "^12.0.0",
9+
"eslint": "^9.39.2",
10+
"eslint-config-smarthr": "^13.3.0",
1111
"eslint-plugin-storybook": "^9.0.18",
1212
"husky": "^9.1.7",
1313
"lint-staged": "^16.2.7",
@@ -21,26 +21,26 @@
2121
"stylelint-config-styled-components": "^0.1.1",
2222
"ts-node": "^10.9.2",
2323
"tsx": "^4.20.6",
24-
"typescript": "^5.8.3"
24+
"typescript": "^5.9.3"
2525
},
2626
"scripts": {
2727
"ui": "pnpm -F smarthr-ui",
2828
"charts": "pnpm -F @smarthr/smarthr-ui-charts",
2929
"commitmsg": "commitlint -e $GIT_PARAMS",
3030
"prepare": "husky"
3131
},
32-
"packageManager": "pnpm@10.28.2",
32+
"packageManager": "pnpm@10.29.3",
3333
"pnpm": {
3434
"overrides": {
3535
"@babel/helper-compilation-targets": "^7.28.6",
36-
"@types/react": "^18.3.27",
36+
"@types/react": "^18.3.28",
3737
"minimist": "1.2.8",
3838
"react": "^19.2.4",
3939
"react-dom": "^19.2.4",
4040
"micromatch@<4.0.8": ">=4.0.8",
4141
"cross-spawn@<7.0.5": ">=7.0.6",
4242
"nanoid": "3.3.11",
43-
"esbuild@<=0.24.2": ">=0.27.2",
43+
"esbuild@<=0.24.2": ">=0.27.3",
4444
"@babel/runtime@<7.26.10": ">=7.28.6",
4545
"@babel/helpers@<7.26.10": ">=7.28.6",
4646
"brace-expansion@<1.1.12": "^4.0.1",
@@ -49,7 +49,7 @@
4949
"tmp@<=0.2.3": ">=0.2.5",
5050
"vite@>=6.0.0 <=6.4.0": ">=6.4.1",
5151
"js-yaml@>=4.0.0 <4.1.1": ">=4.1.1",
52-
"glob@>=11.0.0 <11.1.0": ">=11.1.0",
52+
"glob@>=11.0.0 <11.1.0": ">=13.0.1",
5353
"diff@<8.0.3": ">=8.0.3",
5454
"lodash@>=4.0.0 <=4.17.22": ">=4.17.23"
5555
}

packages/charts/package.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,21 @@
3232
"release": "standard-version -a",
3333
"release:dryrun": "standard-version --dry-run",
3434
"storybook": "storybook dev -p 6007",
35+
"test": "vitest",
3536
"watch:css": "tailwindcss -i ./src/styles/index.css -o ./lib/styles.css --watch"
3637
},
3738
"peerDependencies": {
3839
"react": "^19.0.3",
3940
"react-dom": "^19.0.3",
40-
"react-intl": "^7.0.4",
41+
"react-intl": "^7.0.4 || ^8.0.0",
4142
"smarthr-ui": "^74.0.0",
4243
"styled-components": "^5.0.1"
4344
},
4445
"dependencies": {
45-
"chart.js": "^4.5.1",
4646
"@smarthr/patternomaly": "^2.0.0",
47+
"chart.js": "^4.5.1",
48+
"chartjs-plugin-datalabels": "^2.2.0",
49+
"deepmerge": "^4.3.1",
4750
"react-chartjs-2": "^5.3.1"
4851
},
4952
"devDependencies": {
@@ -56,25 +59,27 @@
5659
"@storybook/cli": "9.0.18",
5760
"@storybook/react": "9.0.18",
5861
"@storybook/react-vite": "9.0.18",
59-
"@types/node": "^20.19.30",
60-
"@types/react": "^18.3.27",
62+
"@types/node": "^20.19.33",
63+
"@types/react": "^18.3.28",
6164
"@types/react-dom": "^19.2.3",
6265
"@types/styled-components": "^5.1.36",
63-
"autoprefixer": "^10.4.23",
64-
"glob": "11.0.3",
66+
"autoprefixer": "^10.4.24",
67+
"glob": "13.0.3",
68+
"jsdom": "^26.1.0",
6569
"npm-run-all2": "^8.0.4",
6670
"postcss": "^8.5.6",
67-
"react": "^19.1.5",
68-
"react-dom": "^19.1.5",
69-
"react-intl": "^7.1.14",
71+
"react": "^19.2.4",
72+
"react-dom": "^19.2.4",
73+
"react-intl": "^8.1.3",
7074
"rimraf": "^6.0.1",
7175
"rollup": "^4.44.2",
7276
"standard-version": "^9.5.0",
7377
"storybook": "9.0.18",
7478
"styled-components": "^5.3.11",
7579
"tailwind-variants": "^0.3.1",
7680
"tailwindcss": "^3.4.19",
77-
"typescript": "^5.8.3"
81+
"typescript": "^5.9.3",
82+
"vitest": "^4.0.18"
7883
},
7984
"keywords": [
8085
"react",

packages/charts/src/components/BarChart/BarChart.stories.tsx

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,106 @@ export const MultipleDatasets: Story = {
5555
title: '複数データの棒グラフ',
5656
},
5757
}
58+
59+
export const WithCustomOptions: Story = {
60+
args: {
61+
data: {
62+
labels: [
63+
'レベル1',
64+
'レベル2',
65+
'レベル3',
66+
'レベル3',
67+
'レベル3',
68+
'レベル3',
69+
'レベル3',
70+
'レベル3',
71+
'レベル3',
72+
'レベル4',
73+
'レベル5',
74+
],
75+
datasets: [
76+
{
77+
label: '人数',
78+
data: [95, 48, 138, 138, 138, 138, 138, 138, 138, 88, 42],
79+
},
80+
],
81+
},
82+
title: 'レベル分布',
83+
options: {
84+
plugins: {
85+
datalabels: {
86+
display: true,
87+
anchor: 'end',
88+
align: 'end',
89+
color: '#333',
90+
font: {
91+
weight: 'bold',
92+
size: 12,
93+
},
94+
},
95+
},
96+
scales: {
97+
y: {
98+
ticks: {
99+
stepSize: 50,
100+
},
101+
suggestedMax: 150,
102+
},
103+
},
104+
datasets: {
105+
bar: {
106+
barPercentage: 0.8,
107+
categoryPercentage: 0.9,
108+
},
109+
},
110+
},
111+
},
112+
}
113+
114+
export const WithDataLabels: Story = {
115+
args: {
116+
data: sampleData,
117+
title: 'データラベル付き棒グラフ',
118+
options: {
119+
plugins: {
120+
datalabels: {
121+
display: true,
122+
anchor: 'end',
123+
align: 'end',
124+
color: '#333',
125+
font: {
126+
weight: 'bold',
127+
size: 12,
128+
},
129+
},
130+
},
131+
},
132+
},
133+
}
134+
135+
export const WithoutTitle: Story = {
136+
args: {
137+
data: sampleData,
138+
},
139+
}
140+
141+
export const WithOverriddenTooltipAttempt: Story = {
142+
name: 'Tooltip上書き試行(内部設定が保護される)',
143+
args: {
144+
data: sampleData,
145+
title: 'Tooltip上書きテスト',
146+
options: {
147+
plugins: {
148+
tooltip: {
149+
// これらの設定は無視され、内部のスタイルが使われる
150+
backgroundColor: '#ff0000',
151+
titleColor: '#00ff00',
152+
bodyColor: '#0000ff',
153+
borderColor: '#ff00ff',
154+
borderWidth: 10,
155+
cornerRadius: 20,
156+
},
157+
},
158+
},
159+
},
160+
}

packages/charts/src/components/BarChart/BarChart.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ type Props = {
1616
// 色などはpropsで渡せないようにする
1717
// TODO:もっと簡単なデータの型を作る
1818
data: ChartData<'bar'>
19-
title: string
19+
title?: string
20+
options?: Partial<ChartOptions<'bar'>>
2021
}
2122

22-
export const BarChart: React.FC<Props> = ({ data, title }) => {
23+
export const BarChart: React.FC<Props> = ({ data, title, options: externalOptions }) => {
2324
const chartId = useId()
2425
const chartRef = useRef<Chart<'bar'>>(null)
2526
const chartColors = useMemo(() => getChartColors(data.datasets.length), [data.datasets.length])
2627

2728
const ariaLabel = useMemo(() => {
2829
const datasetCount = data.datasets.length
2930
const barCount = data.datasets[0].data.length
30-
return `${title} 棒グラフ ${datasetCount}個のデータ ${barCount}本の棒`
31+
const prefix = title ? `${title} ` : ''
32+
return `${prefix}棒グラフ ${datasetCount}個のデータ ${barCount}本の棒`
3133
}, [title, data])
3234

3335
const enhancedData: ChartData<'bar'> = useMemo(
@@ -44,21 +46,27 @@ export const BarChart: React.FC<Props> = ({ data, title }) => {
4446
const chartOptions: ChartOptions<'bar'> = useMemo(
4547
() =>
4648
createBarChartOptions({
49+
...externalOptions,
4750
plugins: {
48-
title: {
49-
display: true,
50-
text: title,
51-
},
51+
...externalOptions?.plugins,
52+
title: title
53+
? {
54+
display: true,
55+
text: title,
56+
}
57+
: {
58+
display: false,
59+
},
5260
keyboardNavigation: {
5361
liveRegionId: chartId,
5462
},
5563
},
5664
}),
57-
[title, chartId],
65+
[title, chartId, externalOptions],
5866
)
5967

6068
return (
61-
<div className="shr-relative">
69+
<div className="shr-relative shr-h-full shr-w-full">
6270
<VisuallyHiddenText aria-live="polite" id={chartId}></VisuallyHiddenText>
6371
<Bar
6472
tabIndex={0}

packages/charts/src/components/Chart/Chart.stories.tsx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,81 @@ export const ManyDatasetsLine: Story = {
173173
},
174174
},
175175
}
176+
177+
export const BarChartWithDataLabels: Story = {
178+
args: {
179+
type: 'bar',
180+
title: 'データラベル付き棒グラフ',
181+
data: {
182+
labels: ['1月', '2月', '3月', '4月', '5月'],
183+
datasets: [
184+
{
185+
label: '売上',
186+
data: [65, 59, 80, 81, 56],
187+
},
188+
],
189+
},
190+
options: {
191+
plugins: {
192+
datalabels: {
193+
display: true,
194+
anchor: 'end',
195+
align: 'end',
196+
color: '#333',
197+
font: {
198+
weight: 'bold',
199+
size: 12,
200+
},
201+
},
202+
},
203+
},
204+
},
205+
}
206+
207+
export const LineChartWithDataLabels: Story = {
208+
args: {
209+
type: 'line',
210+
title: 'データラベル付き線グラフ',
211+
data: {
212+
labels: ['1月', '2月', '3月', '4月', '5月'],
213+
datasets: [
214+
{
215+
label: '売上',
216+
data: [65, 59, 80, 81, 56],
217+
},
218+
],
219+
},
220+
options: {
221+
plugins: {
222+
datalabels: {
223+
display: true,
224+
backgroundColor: '#fff',
225+
borderColor: '#333',
226+
borderWidth: 1,
227+
borderRadius: 4,
228+
color: '#333',
229+
font: {
230+
weight: 'bold',
231+
size: 12,
232+
},
233+
padding: 4,
234+
},
235+
},
236+
},
237+
},
238+
}
239+
240+
export const BarChartWithoutTitle: Story = {
241+
args: {
242+
type: 'bar',
243+
data: {
244+
labels: ['1月', '2月', '3月', '4月', '5月'],
245+
datasets: [
246+
{
247+
label: '売上',
248+
data: [65, 59, 80, 81, 56],
249+
},
250+
],
251+
},
252+
},
253+
}

0 commit comments

Comments
 (0)