@charcoal-ui/react 6.0.0-rc.1 → 6.0.0-rc.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.
Files changed (50) hide show
  1. package/dist/components/Carousel/CarouselItem.d.ts +10 -0
  2. package/dist/components/Carousel/CarouselItem.d.ts.map +1 -0
  3. package/dist/components/Carousel/carouselStore.d.ts +25 -0
  4. package/dist/components/Carousel/carouselStore.d.ts.map +1 -0
  5. package/dist/components/Carousel/index.d.ts +61 -0
  6. package/dist/components/Carousel/index.d.ts.map +1 -0
  7. package/dist/components/Carousel/intersectionObserver.d.ts +7 -0
  8. package/dist/components/Carousel/intersectionObserver.d.ts.map +1 -0
  9. package/dist/components/Carousel/resizeObserver.d.ts +6 -0
  10. package/dist/components/Carousel/resizeObserver.d.ts.map +1 -0
  11. package/dist/components/Carousel/store.d.ts +7 -0
  12. package/dist/components/Carousel/store.d.ts.map +1 -0
  13. package/dist/components/Carousel/useCarouselScroller.d.ts +18 -0
  14. package/dist/components/Carousel/useCarouselScroller.d.ts.map +1 -0
  15. package/dist/components/Icon/index.d.ts +1 -1
  16. package/dist/components/Icon/index.d.ts.map +1 -1
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.css +319 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +2 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/layered.css +319 -1
  25. package/dist/layered.css.map +1 -1
  26. package/package.json +5 -5
  27. package/src/__tests__/fixtures/legacy-v1-index.css +1836 -0
  28. package/src/__tests__/token-v1-compat.test.ts +118 -0
  29. package/src/__tests__/token-v1-remap.test.ts +133 -0
  30. package/src/components/Carousel/CarouselItem.tsx +56 -0
  31. package/src/components/Carousel/MIGRATION.md +117 -0
  32. package/src/components/Carousel/Migration.mdx +8 -0
  33. package/src/components/Carousel/__snapshots__/index.css.snap +274 -0
  34. package/src/components/Carousel/carouselStore.test.ts +38 -0
  35. package/src/components/Carousel/carouselStore.ts +48 -0
  36. package/src/components/Carousel/index.css +274 -0
  37. package/src/components/Carousel/index.story.tsx +169 -0
  38. package/src/components/Carousel/index.test.tsx +666 -0
  39. package/src/components/Carousel/index.tsx +278 -0
  40. package/src/components/Carousel/intersectionObserver.test.ts +68 -0
  41. package/src/components/Carousel/intersectionObserver.ts +58 -0
  42. package/src/components/Carousel/resizeObserver.test.ts +60 -0
  43. package/src/components/Carousel/resizeObserver.ts +35 -0
  44. package/src/components/Carousel/store.test.ts +25 -0
  45. package/src/components/Carousel/store.ts +27 -0
  46. package/src/components/Carousel/useCarouselScroller.ts +158 -0
  47. package/src/components/Icon/index.tsx +2 -1
  48. package/src/components/Modal/__snapshots__/index.css.snap +1 -1
  49. package/src/components/Modal/index.css +1 -1
  50. package/src/index.ts +12 -0
@@ -0,0 +1,169 @@
1
+ import { Meta, StoryObj } from '@storybook/react-vite'
2
+ import Carousel, { type CarouselItem } from '.'
3
+
4
+ const sampleImage = (
5
+ <img
6
+ src="/carousel-sample.png"
7
+ alt="サンプル画像"
8
+ style={{
9
+ width: '100%',
10
+ height: '100%',
11
+ objectFit: 'cover',
12
+ display: 'block',
13
+ }}
14
+ />
15
+ )
16
+
17
+ const items: CarouselItem[] = Array.from({ length: 6 }, (_, i) => ({
18
+ id: `item-${i + 1}`,
19
+ children: sampleImage,
20
+ }))
21
+
22
+ // 横幅が確定したスロット(defaultScroll の初期位置計算と 0.75 ページ送りを確認するため)
23
+ const numberedItems: CarouselItem[] = Array.from({ length: 20 }, (_, i) => ({
24
+ id: `num-${i + 1}`,
25
+ children: (
26
+ <div
27
+ style={{
28
+ width: 200,
29
+ height: 120,
30
+ display: 'flex',
31
+ alignItems: 'center',
32
+ justifyContent: 'center',
33
+ background: i % 2 === 0 ? '#cfe3ff' : '#ffe3cf',
34
+ borderRadius: 8,
35
+ font: 'bold 32px sans-serif',
36
+ color: '#333',
37
+ }}
38
+ >
39
+ {i + 1}
40
+ </div>
41
+ ),
42
+ }))
43
+
44
+ export default {
45
+ title: 'react/Carousel',
46
+ component: Carousel,
47
+ parameters: {
48
+ layout: 'padded',
49
+ },
50
+ args: {
51
+ items,
52
+ size: 'M',
53
+ hasGradient: false,
54
+ fullWidth: false,
55
+ scrollStep: 0.75,
56
+ },
57
+ argTypes: {
58
+ size: {
59
+ control: { type: 'radio' },
60
+ options: ['S', 'M'],
61
+ },
62
+ hasGradient: { control: 'boolean' },
63
+ fullWidth: { control: 'boolean' },
64
+ navigationButtons: { control: 'boolean' },
65
+ indicator: { control: 'boolean' },
66
+ // react-sandbox 互換コールバックを Actions パネルで確認できるようにする。
67
+ onScroll: { action: 'onScroll' },
68
+ onResize: { action: 'onResize' },
69
+ onScrollStateChange: { action: 'onScrollStateChange' },
70
+ scrollStep: {
71
+ // number は clientWidth に対する比率。関数 (ctx) => px も渡せるが、
72
+ // Controls では数値(比率)のみ操作可能。関数形式は ScrollStepFunction story を参照。
73
+ control: { type: 'range', min: 0.1, max: 1.5, step: 0.05 },
74
+ },
75
+ },
76
+ } satisfies Meta<typeof Carousel>
77
+
78
+ export const SizeM: StoryObj<typeof Carousel> = {
79
+ args: { size: 'M' },
80
+ }
81
+
82
+ export const SizeS: StoryObj<typeof Carousel> = {
83
+ args: { size: 'S' },
84
+ }
85
+
86
+ export const WithGradient: StoryObj<typeof Carousel> = {
87
+ args: { size: 'M', hasGradient: true },
88
+ }
89
+
90
+ export const FullWidth: StoryObj<typeof Carousel> = {
91
+ args: { size: 'M', fullWidth: true },
92
+ }
93
+
94
+ export const NavigationButtonsOnSizeS: StoryObj<typeof Carousel> = {
95
+ args: { size: 'S', navigationButtons: true },
96
+ }
97
+
98
+ export const IndicatorOnSizeM: StoryObj<typeof Carousel> = {
99
+ args: { size: 'M', indicator: true },
100
+ }
101
+
102
+ // 横幅が確定したスロット(番号付き)
103
+ export const DefaultScrollCenter: StoryObj<typeof Carousel> = {
104
+ args: { size: 'M', items: numberedItems, defaultScroll: { align: 'center' } },
105
+ }
106
+
107
+ export const DefaultScrollRight: StoryObj<typeof Carousel> = {
108
+ args: { size: 'M', items: numberedItems, defaultScroll: { align: 'right' } },
109
+ }
110
+
111
+ // 遅延読み込み画像(マウント時に幅が未確定)でも初期位置が効くことの確認
112
+ export const DefaultScrollCenterAsyncImages: StoryObj<typeof Carousel> = {
113
+ args: { size: 'M', items, defaultScroll: { align: 'center' } },
114
+ }
115
+
116
+ // 白フェードが見えることの確認用(暗色コンテンツなら白フェードが明確に出る)
117
+ const darkTiles: CarouselItem[] = Array.from({ length: 10 }, (_, i) => ({
118
+ id: `dark-${i + 1}`,
119
+ children: (
120
+ <div
121
+ style={{
122
+ width: 220,
123
+ height: 140,
124
+ display: 'flex',
125
+ alignItems: 'center',
126
+ justifyContent: 'center',
127
+ background: '#2a3b8f',
128
+ color: '#fff',
129
+ borderRadius: 4,
130
+ font: 'bold 28px sans-serif',
131
+ }}
132
+ >
133
+ {i + 1}
134
+ </div>
135
+ ),
136
+ }))
137
+
138
+ export const GradientOnDarkContent: StoryObj<typeof Carousel> = {
139
+ args: { size: 'M', hasGradient: true, items: darkTiles },
140
+ }
141
+
142
+ // scrollStep に関数を渡してフル制御する例(送り量を clientWidth - 48px に固定)。
143
+ // Controls の数値スライダーでは表現できない使い方の確認用。
144
+ export const ScrollStepFunction: StoryObj<typeof Carousel> = {
145
+ args: {
146
+ size: 'M',
147
+ items: numberedItems,
148
+ scrollStep: ({ clientWidth }) => clientWidth - 48,
149
+ },
150
+ }
151
+
152
+ // scroll-snap を item ごと(mandatory)に。align: start で各アイテムが左端にスナップする。
153
+ export const ScrollSnapPerItem: StoryObj<typeof Carousel> = {
154
+ args: {
155
+ size: 'M',
156
+ items: numberedItems,
157
+ scrollSnap: { type: 'mandatory', align: 'start' },
158
+ },
159
+ }
160
+
161
+ export const AllControls: StoryObj<typeof Carousel> = {
162
+ args: {
163
+ size: 'M',
164
+ hasGradient: true,
165
+ fullWidth: false,
166
+ navigationButtons: true,
167
+ indicator: true,
168
+ },
169
+ }