@charcoal-ui/react 3.10.1-beta.0 → 3.10.1
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/Button/index.story.d.ts +4 -9
- package/dist/components/Button/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/index.cjs.js +9 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +13 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -7
- package/src/components/Button/__snapshots__/index.story.storyshot +91 -939
- package/src/components/Button/index.story.tsx +14 -161
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +15 -0
- package/src/components/DropdownSelector/index.tsx +19 -4
- package/src/components/Modal/__snapshots__/index.story.storyshot +2 -0
|
@@ -1,190 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ClickableElement } from '../Clickable'
|
|
3
|
-
import Button, { ButtonProps } from '.'
|
|
1
|
+
import Button from '.'
|
|
4
2
|
import { Meta, StoryObj } from '@storybook/react'
|
|
5
3
|
|
|
6
4
|
export default {
|
|
7
5
|
title: 'Button',
|
|
8
6
|
component: Button,
|
|
9
|
-
argTypes: {
|
|
10
|
-
variant: {
|
|
11
|
-
control: {
|
|
12
|
-
type: 'inline-radio',
|
|
13
|
-
options: ['Primary', 'Default', 'Overlay', 'Danger', 'Navigation'],
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
size: {
|
|
17
|
-
control: {
|
|
18
|
-
type: 'inline-radio',
|
|
19
|
-
options: ['S', 'M'],
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
render: (args) => <Button {...args}>Button</Button>,
|
|
24
7
|
} as Meta<typeof Button>
|
|
25
8
|
|
|
26
|
-
export const Default: StoryObj<typeof Button> = {
|
|
9
|
+
export const Default: StoryObj<typeof Button> = {
|
|
10
|
+
render: (args) => <Button {...args}>Button</Button>,
|
|
11
|
+
}
|
|
27
12
|
|
|
28
13
|
export const Primary: StoryObj<typeof Button> = {
|
|
29
|
-
|
|
30
|
-
variant: 'Primary',
|
|
31
|
-
},
|
|
14
|
+
render: () => <Button variant="Primary">Primary</Button>,
|
|
32
15
|
}
|
|
33
16
|
|
|
34
17
|
export const Navigation: StoryObj<typeof Button> = {
|
|
35
|
-
|
|
36
|
-
variant: 'Navigation',
|
|
37
|
-
},
|
|
18
|
+
render: () => <Button variant="Navigation">Navigation</Button>,
|
|
38
19
|
}
|
|
39
20
|
|
|
40
21
|
export const Overlay: StoryObj<typeof Button> = {
|
|
41
|
-
|
|
42
|
-
variant: 'Overlay',
|
|
43
|
-
},
|
|
22
|
+
render: () => <Button variant="Overlay">Overlay</Button>,
|
|
44
23
|
}
|
|
45
24
|
|
|
46
25
|
export const Danger: StoryObj<typeof Button> = {
|
|
47
|
-
|
|
48
|
-
variant: 'Danger',
|
|
49
|
-
},
|
|
26
|
+
render: () => <Button variant="Danger">Danger</Button>,
|
|
50
27
|
}
|
|
51
28
|
|
|
52
29
|
export const Small: StoryObj<typeof Button> = {
|
|
53
|
-
|
|
54
|
-
size: 'S',
|
|
55
|
-
},
|
|
30
|
+
render: () => <Button size="S">Small</Button>,
|
|
56
31
|
}
|
|
57
32
|
|
|
58
|
-
export const
|
|
59
|
-
|
|
60
|
-
fullWidth: true,
|
|
61
|
-
},
|
|
33
|
+
export const FullWidth: StoryObj<typeof Button> = {
|
|
34
|
+
render: () => <Button fullWidth>Full width</Button>,
|
|
62
35
|
}
|
|
63
36
|
|
|
64
37
|
export const Disabled: StoryObj<typeof Button> = {
|
|
65
|
-
|
|
66
|
-
disabled: true,
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const Active: StoryObj<typeof Button> = {
|
|
71
|
-
args: {
|
|
72
|
-
isActive: true,
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export const Link: StoryObj<typeof Button> = {
|
|
77
|
-
args: {
|
|
78
|
-
to: '#',
|
|
79
|
-
},
|
|
38
|
+
render: () => <Button disabled>Disabled</Button>,
|
|
80
39
|
}
|
|
81
40
|
|
|
82
|
-
export const
|
|
83
|
-
render: (
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const Focus: StoryObj<typeof Button> = {
|
|
87
|
-
render: function Render(args) {
|
|
88
|
-
const ref = useRef<ClickableElement>(null)
|
|
89
|
-
const focus = () => ref.current?.focus()
|
|
90
|
-
return (
|
|
91
|
-
<Button {...args} onMouseOver={focus} ref={ref}>
|
|
92
|
-
Mouse over to focus
|
|
93
|
-
</Button>
|
|
94
|
-
)
|
|
95
|
-
},
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const LayoutExample: StoryObj<typeof Button> = {
|
|
99
|
-
render: (args: ButtonProps) => (
|
|
100
|
-
<div
|
|
101
|
-
css={`
|
|
102
|
-
display: grid;
|
|
103
|
-
gap: 24px;
|
|
104
|
-
`}
|
|
105
|
-
>
|
|
106
|
-
<div
|
|
107
|
-
css={`
|
|
108
|
-
display: grid;
|
|
109
|
-
grid: auto / auto-flow min-content;
|
|
110
|
-
gap: 8px;
|
|
111
|
-
`}
|
|
112
|
-
>
|
|
113
|
-
<Button {...args}>Grid</Button>
|
|
114
|
-
<Button {...args} variant="Navigation">
|
|
115
|
-
Layout
|
|
116
|
-
</Button>
|
|
117
|
-
<Button {...args} variant="Danger">
|
|
118
|
-
Sample
|
|
119
|
-
</Button>
|
|
120
|
-
</div>
|
|
121
|
-
<div
|
|
122
|
-
css={`
|
|
123
|
-
display: grid;
|
|
124
|
-
grid: auto-flow auto / 392px;
|
|
125
|
-
gap: 8px;
|
|
126
|
-
`}
|
|
127
|
-
>
|
|
128
|
-
<Button {...args} variant="Primary" fullWidth>
|
|
129
|
-
Submit
|
|
130
|
-
</Button>
|
|
131
|
-
<Button {...args} variant="Default" fullWidth>
|
|
132
|
-
Cancel
|
|
133
|
-
</Button>
|
|
134
|
-
</div>
|
|
135
|
-
<div
|
|
136
|
-
css={`
|
|
137
|
-
display: flex;
|
|
138
|
-
|
|
139
|
-
& > * + * {
|
|
140
|
-
margin-left: 8px;
|
|
141
|
-
}
|
|
142
|
-
`}
|
|
143
|
-
>
|
|
144
|
-
<Button {...args}>Flex</Button>
|
|
145
|
-
<Button {...args} variant="Navigation">
|
|
146
|
-
Layout
|
|
147
|
-
</Button>
|
|
148
|
-
<Button {...args} variant="Danger">
|
|
149
|
-
Sample
|
|
150
|
-
</Button>
|
|
151
|
-
</div>
|
|
152
|
-
<div
|
|
153
|
-
css={`
|
|
154
|
-
display: flex;
|
|
155
|
-
flex-direction: column;
|
|
156
|
-
width: 392px;
|
|
157
|
-
|
|
158
|
-
& > * + * {
|
|
159
|
-
margin-top: 8px;
|
|
160
|
-
}
|
|
161
|
-
`}
|
|
162
|
-
>
|
|
163
|
-
<Button {...args} variant="Primary" fullWidth>
|
|
164
|
-
Submit
|
|
165
|
-
</Button>
|
|
166
|
-
<Button {...args} variant="Default" fullWidth>
|
|
167
|
-
Cancel
|
|
168
|
-
</Button>
|
|
169
|
-
</div>
|
|
170
|
-
<div
|
|
171
|
-
css={`
|
|
172
|
-
display: flex;
|
|
173
|
-
flex-direction: column;
|
|
174
|
-
width: 392px;
|
|
175
|
-
|
|
176
|
-
& > * + * {
|
|
177
|
-
margin-top: 8px;
|
|
178
|
-
}
|
|
179
|
-
`}
|
|
180
|
-
>
|
|
181
|
-
<Button {...args} variant="Primary" fullWidth>
|
|
182
|
-
すべて見る
|
|
183
|
-
</Button>
|
|
184
|
-
<Button {...args} variant="Default">
|
|
185
|
-
作品を投稿
|
|
186
|
-
</Button>
|
|
187
|
-
</div>
|
|
188
|
-
</div>
|
|
189
|
-
),
|
|
41
|
+
export const IsActive: StoryObj<typeof Button> = {
|
|
42
|
+
render: () => <Button isActive>Active</Button>,
|
|
190
43
|
}
|
|
@@ -140,6 +140,7 @@ exports[`Storybook Tests DropdownSelector AssistiveText 1`] = `
|
|
|
140
140
|
}
|
|
141
141
|
>
|
|
142
142
|
<select
|
|
143
|
+
onChange={[Function]}
|
|
143
144
|
tabIndex={-1}
|
|
144
145
|
value="1"
|
|
145
146
|
>
|
|
@@ -301,6 +302,7 @@ exports[`Storybook Tests DropdownSelector CustomChildren 1`] = `
|
|
|
301
302
|
}
|
|
302
303
|
>
|
|
303
304
|
<select
|
|
305
|
+
onChange={[Function]}
|
|
304
306
|
tabIndex={-1}
|
|
305
307
|
value="bold"
|
|
306
308
|
>
|
|
@@ -465,6 +467,7 @@ exports[`Storybook Tests DropdownSelector Default 1`] = `
|
|
|
465
467
|
}
|
|
466
468
|
>
|
|
467
469
|
<select
|
|
470
|
+
onChange={[Function]}
|
|
468
471
|
tabIndex={-1}
|
|
469
472
|
value=""
|
|
470
473
|
>
|
|
@@ -622,6 +625,7 @@ exports[`Storybook Tests DropdownSelector Disabled 1`] = `
|
|
|
622
625
|
}
|
|
623
626
|
>
|
|
624
627
|
<select
|
|
628
|
+
onChange={[Function]}
|
|
625
629
|
tabIndex={-1}
|
|
626
630
|
value="1"
|
|
627
631
|
>
|
|
@@ -779,6 +783,7 @@ exports[`Storybook Tests DropdownSelector DisabledItem 1`] = `
|
|
|
779
783
|
}
|
|
780
784
|
>
|
|
781
785
|
<select
|
|
786
|
+
onChange={[Function]}
|
|
782
787
|
tabIndex={-1}
|
|
783
788
|
value="2"
|
|
784
789
|
>
|
|
@@ -1052,6 +1057,7 @@ exports[`Storybook Tests DropdownSelector InFormTag 1`] = `
|
|
|
1052
1057
|
>
|
|
1053
1058
|
<select
|
|
1054
1059
|
name="exampleOption"
|
|
1060
|
+
onChange={[Function]}
|
|
1055
1061
|
tabIndex={-1}
|
|
1056
1062
|
value="1"
|
|
1057
1063
|
>
|
|
@@ -1811,6 +1817,7 @@ exports[`Storybook Tests DropdownSelector InModal 1`] = `
|
|
|
1811
1817
|
}
|
|
1812
1818
|
>
|
|
1813
1819
|
<select
|
|
1820
|
+
onChange={[Function]}
|
|
1814
1821
|
tabIndex={-1}
|
|
1815
1822
|
value="1"
|
|
1816
1823
|
>
|
|
@@ -1987,6 +1994,7 @@ exports[`Storybook Tests DropdownSelector InModal 1`] = `
|
|
|
1987
1994
|
}
|
|
1988
1995
|
>
|
|
1989
1996
|
<select
|
|
1997
|
+
onChange={[Function]}
|
|
1990
1998
|
tabIndex={-1}
|
|
1991
1999
|
value="2"
|
|
1992
2000
|
>
|
|
@@ -2165,6 +2173,7 @@ exports[`Storybook Tests DropdownSelector Invalid 1`] = `
|
|
|
2165
2173
|
}
|
|
2166
2174
|
>
|
|
2167
2175
|
<select
|
|
2176
|
+
onChange={[Function]}
|
|
2168
2177
|
tabIndex={-1}
|
|
2169
2178
|
value="1"
|
|
2170
2179
|
>
|
|
@@ -2351,6 +2360,7 @@ exports[`Storybook Tests DropdownSelector InvalidAssistiveText 1`] = `
|
|
|
2351
2360
|
}
|
|
2352
2361
|
>
|
|
2353
2362
|
<select
|
|
2363
|
+
onChange={[Function]}
|
|
2354
2364
|
tabIndex={-1}
|
|
2355
2365
|
value="1"
|
|
2356
2366
|
>
|
|
@@ -2615,6 +2625,7 @@ exports[`Storybook Tests DropdownSelector Label 1`] = `
|
|
|
2615
2625
|
}
|
|
2616
2626
|
>
|
|
2617
2627
|
<select
|
|
2628
|
+
onChange={[Function]}
|
|
2618
2629
|
tabIndex={-1}
|
|
2619
2630
|
value="1"
|
|
2620
2631
|
>
|
|
@@ -2771,6 +2782,7 @@ exports[`Storybook Tests DropdownSelector LongNames 1`] = `
|
|
|
2771
2782
|
}
|
|
2772
2783
|
>
|
|
2773
2784
|
<select
|
|
2785
|
+
onChange={[Function]}
|
|
2774
2786
|
tabIndex={-1}
|
|
2775
2787
|
value="1"
|
|
2776
2788
|
>
|
|
@@ -3067,6 +3079,7 @@ exports[`Storybook Tests DropdownSelector RequiredText 1`] = `
|
|
|
3067
3079
|
}
|
|
3068
3080
|
>
|
|
3069
3081
|
<select
|
|
3082
|
+
onChange={[Function]}
|
|
3070
3083
|
tabIndex={-1}
|
|
3071
3084
|
value="1"
|
|
3072
3085
|
>
|
|
@@ -3223,6 +3236,7 @@ exports[`Storybook Tests DropdownSelector Section 1`] = `
|
|
|
3223
3236
|
}
|
|
3224
3237
|
>
|
|
3225
3238
|
<select
|
|
3239
|
+
onChange={[Function]}
|
|
3226
3240
|
tabIndex={-1}
|
|
3227
3241
|
value="banana"
|
|
3228
3242
|
>
|
|
@@ -3504,6 +3518,7 @@ exports[`Storybook Tests DropdownSelector SubLabel 1`] = `
|
|
|
3504
3518
|
}
|
|
3505
3519
|
>
|
|
3506
3520
|
<select
|
|
3521
|
+
onChange={[Function]}
|
|
3507
3522
|
tabIndex={-1}
|
|
3508
3523
|
value="1"
|
|
3509
3524
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, useState, useRef, useMemo } from 'react'
|
|
1
|
+
import React, { ReactNode, useState, useRef, useMemo, useCallback } from 'react'
|
|
2
2
|
import styled, { css } from 'styled-components'
|
|
3
3
|
import { disabledSelector } from '@charcoal-ui/utils'
|
|
4
4
|
import Icon from '../Icon'
|
|
@@ -31,7 +31,10 @@ export type DropdownSelectorProps = {
|
|
|
31
31
|
|
|
32
32
|
const defaultRequiredText = '*必須'
|
|
33
33
|
|
|
34
|
-
export default function DropdownSelector(
|
|
34
|
+
export default function DropdownSelector({
|
|
35
|
+
onChange,
|
|
36
|
+
...props
|
|
37
|
+
}: DropdownSelectorProps) {
|
|
35
38
|
const triggerRef = useRef<HTMLButtonElement>(null)
|
|
36
39
|
const [isOpen, setIsOpen] = useState(false)
|
|
37
40
|
const preview = findPreviewRecursive(props.children, props.value)
|
|
@@ -45,6 +48,13 @@ export default function DropdownSelector(props: DropdownSelectorProps) {
|
|
|
45
48
|
|
|
46
49
|
const { visuallyHiddenProps } = useVisuallyHidden()
|
|
47
50
|
|
|
51
|
+
const handleChange = useCallback(
|
|
52
|
+
(e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
53
|
+
onChange(e.target.value)
|
|
54
|
+
},
|
|
55
|
+
[onChange]
|
|
56
|
+
)
|
|
57
|
+
|
|
48
58
|
return (
|
|
49
59
|
<DropdownSelectorRoot aria-disabled={props.disabled}>
|
|
50
60
|
{props.showLabel === true && (
|
|
@@ -56,7 +66,12 @@ export default function DropdownSelector(props: DropdownSelectorProps) {
|
|
|
56
66
|
/>
|
|
57
67
|
)}
|
|
58
68
|
<div {...visuallyHiddenProps} aria-hidden="true">
|
|
59
|
-
<select
|
|
69
|
+
<select
|
|
70
|
+
name={props.name}
|
|
71
|
+
value={props.value}
|
|
72
|
+
onChange={handleChange}
|
|
73
|
+
tabIndex={-1}
|
|
74
|
+
>
|
|
60
75
|
{propsArray.map((itemProps) => {
|
|
61
76
|
return (
|
|
62
77
|
<option
|
|
@@ -96,7 +111,7 @@ export default function DropdownSelector(props: DropdownSelectorProps) {
|
|
|
96
111
|
<MenuList
|
|
97
112
|
value={props.value}
|
|
98
113
|
onChange={(v) => {
|
|
99
|
-
|
|
114
|
+
onChange(v)
|
|
100
115
|
setIsOpen(false)
|
|
101
116
|
}}
|
|
102
117
|
>
|
|
@@ -881,6 +881,7 @@ exports[`Storybook Tests Modal BackgroundScroll 1`] = `
|
|
|
881
881
|
}
|
|
882
882
|
>
|
|
883
883
|
<select
|
|
884
|
+
onChange={[Function]}
|
|
884
885
|
tabIndex={-1}
|
|
885
886
|
value="10"
|
|
886
887
|
>
|
|
@@ -2305,6 +2306,7 @@ exports[`Storybook Tests Modal Default 1`] = `
|
|
|
2305
2306
|
}
|
|
2306
2307
|
>
|
|
2307
2308
|
<select
|
|
2309
|
+
onChange={[Function]}
|
|
2308
2310
|
tabIndex={-1}
|
|
2309
2311
|
value="10"
|
|
2310
2312
|
>
|