@charcoal-ui/react 4.0.0-beta.7 → 4.0.0-beta.8
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/DropdownSelector/Divider/index.d.ts +3 -0
- package/dist/components/DropdownSelector/Divider/index.d.ts.map +1 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts +8 -0
- package/dist/components/DropdownSelector/DropdownMenuItem/index.d.ts.map +1 -0
- package/dist/components/DropdownSelector/DropdownPopover.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts +5 -13
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.d.ts +10 -3
- package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.d.ts +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index.d.ts +1 -3
- package/dist/components/DropdownSelector/MenuItemGroup/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index.d.ts +1 -4
- package/dist/components/DropdownSelector/MenuList/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts +1 -0
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts +3 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/Radio/RadioGroup/index.d.ts +20 -0
- package/dist/components/Radio/RadioGroup/index.d.ts.map +1 -0
- package/dist/components/Radio/RadioGroupContext.d.ts +11 -0
- package/dist/components/Radio/RadioGroupContext.d.ts.map +1 -0
- package/dist/components/Radio/RadioInput/index.d.ts +10 -0
- package/dist/components/Radio/RadioInput/index.d.ts.map +1 -0
- package/dist/components/Radio/index.d.ts +1 -12
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/index.cjs.js +285 -294
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +174 -22
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +230 -239
- package/dist/index.esm.js.map +1 -1
- package/package.json +8 -8
- package/src/components/DropdownSelector/Divider/index.css +11 -0
- package/src/components/DropdownSelector/Divider/index.tsx +5 -0
- package/src/components/DropdownSelector/DropdownMenuItem/index.css +20 -0
- package/src/components/DropdownSelector/DropdownMenuItem/index.tsx +34 -0
- package/src/components/DropdownSelector/DropdownPopover.tsx +16 -9
- package/src/components/DropdownSelector/ListItem/__snapshots__/index.story.storyshot +35 -94
- package/src/components/DropdownSelector/ListItem/index.css +24 -0
- package/src/components/DropdownSelector/ListItem/index.tsx +14 -53
- package/src/components/DropdownSelector/MenuItem/index.tsx +17 -12
- package/src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx +2 -2
- package/src/components/DropdownSelector/MenuItemGroup/index.css +19 -0
- package/src/components/DropdownSelector/MenuItemGroup/index.tsx +6 -28
- package/src/components/DropdownSelector/MenuList/__snapshots__/index.story.storyshot +159 -413
- package/src/components/DropdownSelector/MenuList/index.css +4 -0
- package/src/components/DropdownSelector/MenuList/index.tsx +4 -12
- package/src/components/DropdownSelector/Popover/index.css +11 -0
- package/src/components/DropdownSelector/Popover/index.tsx +6 -15
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +389 -1167
- package/src/components/DropdownSelector/index.css +84 -0
- package/src/components/DropdownSelector/index.story.tsx +0 -4
- package/src/components/DropdownSelector/index.tsx +40 -102
- package/src/components/Modal/__snapshots__/index.story.storyshot +16 -176
- package/src/components/Radio/RadioGroup/index.css +5 -0
- package/src/components/Radio/RadioGroup/index.tsx +80 -0
- package/src/components/Radio/RadioGroupContext.ts +23 -0
- package/src/components/Radio/RadioInput/index.css +82 -0
- package/src/components/Radio/RadioInput/index.tsx +41 -0
- package/src/components/Radio/__snapshots__/index.story.storyshot +36 -30
- package/src/components/Radio/index.css +2 -81
- package/src/components/Radio/index.story.tsx +16 -6
- package/src/components/Radio/index.test.tsx +2 -1
- package/src/components/Radio/index.tsx +7 -89
- package/src/index.ts +2 -6
- package/dist/components/DropdownSelector/Divider.d.ts +0 -7
- package/dist/components/DropdownSelector/Divider.d.ts.map +0 -1
- package/dist/components/DropdownSelector/DropdownMenuItem.d.ts +0 -7
- package/dist/components/DropdownSelector/DropdownMenuItem.d.ts.map +0 -1
- package/src/components/DropdownSelector/Divider.tsx +0 -16
- package/src/components/DropdownSelector/DropdownMenuItem.tsx +0 -43
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
.charcoal-radio-input {
|
|
2
|
+
appearance: none;
|
|
3
|
+
display: block;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: 6px;
|
|
8
|
+
|
|
9
|
+
width: 20px;
|
|
10
|
+
height: 20px;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
border-radius: 999999px;
|
|
13
|
+
background-color: var(--charcoal-surface1);
|
|
14
|
+
transition: 0.2s background-color, 0.2s box-shadow;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.charcoal-radio-input:checked {
|
|
18
|
+
background-color: var(--charcoal-brand);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.charcoal-radio-input:checked::after {
|
|
22
|
+
content: '';
|
|
23
|
+
display: block;
|
|
24
|
+
width: 8px;
|
|
25
|
+
height: 8px;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
background-color: var(--charcoal-text5);
|
|
28
|
+
border-radius: 999999px;
|
|
29
|
+
transition: 0.2s background-color, 0.2s box-shadow;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.charcoal-radio-input:not(:checked) {
|
|
33
|
+
border-width: 2px;
|
|
34
|
+
border-style: solid;
|
|
35
|
+
border-color: var(--charcoal-text3);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.charcoal-radio-input:disabled {
|
|
39
|
+
cursor: default;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.charcoal-radio-input:not(:disabled):hover {
|
|
43
|
+
background-color: var(--charcoal-surface1-hover);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.charcoal-radio-input:not(:disabled):active {
|
|
47
|
+
background-color: var(--charcoal-surface1-press);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.charcoal-radio-input:not(:disabled):focus {
|
|
51
|
+
outline: none;
|
|
52
|
+
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.charcoal-radio-input:not(:disabled):focus-visible {
|
|
56
|
+
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.charcoal-radio-input:not(:disabled):focus:not(:focus-visible) {
|
|
60
|
+
box-shadow: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.charcoal-radio-input:not(:disabled)[aria-invalid='true'],
|
|
64
|
+
.charcoal-radio-input:not(:disabled)[aria-invalid='true']:focus {
|
|
65
|
+
box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.charcoal-radio-input:checked:not(:disabled):hover {
|
|
69
|
+
background-color: var(--charcoal-brand-hover);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.charcoal-radio-input:checked:not(:disabled):hover::after {
|
|
73
|
+
background-color: var(--charcoal-text5-hover);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.charcoal-radio-input:checked:not(:disabled):active {
|
|
77
|
+
background-color: var(--charcoal-brand-press);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.charcoal-radio-input:checked:not(:disabled):active::after {
|
|
81
|
+
background-color: var(--charcoal-text5-press);
|
|
82
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import './index.css'
|
|
2
|
+
|
|
3
|
+
import { forwardRef, memo, useCallback } from 'react'
|
|
4
|
+
import { useClassNames } from '../../../_lib/useClassNames'
|
|
5
|
+
|
|
6
|
+
type CharcoalRadioInputProps = {
|
|
7
|
+
invalid?: boolean
|
|
8
|
+
onChange?: (value: string) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type InputProps = React.HTMLProps<HTMLInputElement>
|
|
12
|
+
|
|
13
|
+
export type RadioInputProps = CharcoalRadioInputProps &
|
|
14
|
+
Omit<InputProps, keyof CharcoalRadioInputProps | 'ref'>
|
|
15
|
+
|
|
16
|
+
const RadioInput = forwardRef<HTMLInputElement, RadioInputProps>(
|
|
17
|
+
function RadioInput({ onChange, invalid, className, ...props }, ref) {
|
|
18
|
+
const handleChange = useCallback(
|
|
19
|
+
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
20
|
+
const el = e.currentTarget
|
|
21
|
+
onChange?.(el.value)
|
|
22
|
+
},
|
|
23
|
+
[onChange]
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const classNames = useClassNames('charcoal-radio-input', className)
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<input
|
|
30
|
+
className={classNames}
|
|
31
|
+
ref={ref}
|
|
32
|
+
type="radio"
|
|
33
|
+
onChange={handleChange}
|
|
34
|
+
aria-invalid={invalid}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
export default memo(RadioInput)
|
|
@@ -19,6 +19,7 @@ exports[`Storybook Tests react/Radio Default 1`] = `
|
|
|
19
19
|
className="c0"
|
|
20
20
|
>
|
|
21
21
|
<div
|
|
22
|
+
aria-label="default story"
|
|
22
23
|
aria-orientation="vertical"
|
|
23
24
|
className="charcoal-radio-group"
|
|
24
25
|
role="radiogroup"
|
|
@@ -30,9 +31,9 @@ exports[`Storybook Tests react/Radio Default 1`] = `
|
|
|
30
31
|
<input
|
|
31
32
|
aria-invalid={false}
|
|
32
33
|
checked={true}
|
|
33
|
-
className="charcoal-
|
|
34
|
+
className="charcoal-radio-input"
|
|
34
35
|
disabled={false}
|
|
35
|
-
name="
|
|
36
|
+
name="default_story"
|
|
36
37
|
onChange={[Function]}
|
|
37
38
|
type="radio"
|
|
38
39
|
value="1"
|
|
@@ -51,9 +52,9 @@ exports[`Storybook Tests react/Radio Default 1`] = `
|
|
|
51
52
|
<input
|
|
52
53
|
aria-invalid={false}
|
|
53
54
|
checked={false}
|
|
54
|
-
className="charcoal-
|
|
55
|
+
className="charcoal-radio-input"
|
|
55
56
|
disabled={false}
|
|
56
|
-
name="
|
|
57
|
+
name="default_story"
|
|
57
58
|
onChange={[Function]}
|
|
58
59
|
type="radio"
|
|
59
60
|
value="2"
|
|
@@ -72,9 +73,9 @@ exports[`Storybook Tests react/Radio Default 1`] = `
|
|
|
72
73
|
<input
|
|
73
74
|
aria-invalid={false}
|
|
74
75
|
checked={false}
|
|
75
|
-
className="charcoal-
|
|
76
|
+
className="charcoal-radio-input"
|
|
76
77
|
disabled={false}
|
|
77
|
-
name="
|
|
78
|
+
name="default_story"
|
|
78
79
|
onChange={[Function]}
|
|
79
80
|
type="radio"
|
|
80
81
|
value="3"
|
|
@@ -110,6 +111,8 @@ exports[`Storybook Tests react/Radio Disabled 1`] = `
|
|
|
110
111
|
className="c0"
|
|
111
112
|
>
|
|
112
113
|
<div
|
|
114
|
+
aria-disabled={true}
|
|
115
|
+
aria-label="disabled_stroy"
|
|
113
116
|
aria-orientation="vertical"
|
|
114
117
|
className="charcoal-radio-group"
|
|
115
118
|
role="radiogroup"
|
|
@@ -121,9 +124,9 @@ exports[`Storybook Tests react/Radio Disabled 1`] = `
|
|
|
121
124
|
<input
|
|
122
125
|
aria-invalid={false}
|
|
123
126
|
checked={true}
|
|
124
|
-
className="charcoal-
|
|
127
|
+
className="charcoal-radio-input"
|
|
125
128
|
disabled={true}
|
|
126
|
-
name="
|
|
129
|
+
name="disabled story"
|
|
127
130
|
onChange={[Function]}
|
|
128
131
|
type="radio"
|
|
129
132
|
value="1"
|
|
@@ -142,9 +145,9 @@ exports[`Storybook Tests react/Radio Disabled 1`] = `
|
|
|
142
145
|
<input
|
|
143
146
|
aria-invalid={false}
|
|
144
147
|
checked={false}
|
|
145
|
-
className="charcoal-
|
|
148
|
+
className="charcoal-radio-input"
|
|
146
149
|
disabled={true}
|
|
147
|
-
name="
|
|
150
|
+
name="disabled story"
|
|
148
151
|
onChange={[Function]}
|
|
149
152
|
type="radio"
|
|
150
153
|
value="2"
|
|
@@ -163,9 +166,9 @@ exports[`Storybook Tests react/Radio Disabled 1`] = `
|
|
|
163
166
|
<input
|
|
164
167
|
aria-invalid={false}
|
|
165
168
|
checked={false}
|
|
166
|
-
className="charcoal-
|
|
169
|
+
className="charcoal-radio-input"
|
|
167
170
|
disabled={true}
|
|
168
|
-
name="
|
|
171
|
+
name="disabled story"
|
|
169
172
|
onChange={[Function]}
|
|
170
173
|
type="radio"
|
|
171
174
|
value="3"
|
|
@@ -202,6 +205,7 @@ exports[`Storybook Tests react/Radio Invalid 1`] = `
|
|
|
202
205
|
>
|
|
203
206
|
<div
|
|
204
207
|
aria-invalid={true}
|
|
208
|
+
aria-label="invalid story"
|
|
205
209
|
aria-orientation="vertical"
|
|
206
210
|
className="charcoal-radio-group"
|
|
207
211
|
role="radiogroup"
|
|
@@ -213,9 +217,9 @@ exports[`Storybook Tests react/Radio Invalid 1`] = `
|
|
|
213
217
|
<input
|
|
214
218
|
aria-invalid={true}
|
|
215
219
|
checked={true}
|
|
216
|
-
className="charcoal-
|
|
220
|
+
className="charcoal-radio-input"
|
|
217
221
|
disabled={false}
|
|
218
|
-
name="
|
|
222
|
+
name="invalid_story"
|
|
219
223
|
onChange={[Function]}
|
|
220
224
|
type="radio"
|
|
221
225
|
value="1"
|
|
@@ -234,9 +238,9 @@ exports[`Storybook Tests react/Radio Invalid 1`] = `
|
|
|
234
238
|
<input
|
|
235
239
|
aria-invalid={true}
|
|
236
240
|
checked={false}
|
|
237
|
-
className="charcoal-
|
|
241
|
+
className="charcoal-radio-input"
|
|
238
242
|
disabled={false}
|
|
239
|
-
name="
|
|
243
|
+
name="invalid_story"
|
|
240
244
|
onChange={[Function]}
|
|
241
245
|
type="radio"
|
|
242
246
|
value="2"
|
|
@@ -255,9 +259,9 @@ exports[`Storybook Tests react/Radio Invalid 1`] = `
|
|
|
255
259
|
<input
|
|
256
260
|
aria-invalid={true}
|
|
257
261
|
checked={false}
|
|
258
|
-
className="charcoal-
|
|
262
|
+
className="charcoal-radio-input"
|
|
259
263
|
disabled={false}
|
|
260
|
-
name="
|
|
264
|
+
name="invalid_story"
|
|
261
265
|
onChange={[Function]}
|
|
262
266
|
type="radio"
|
|
263
267
|
value="3"
|
|
@@ -293,6 +297,7 @@ exports[`Storybook Tests react/Radio PartialDisabled 1`] = `
|
|
|
293
297
|
className="c0"
|
|
294
298
|
>
|
|
295
299
|
<div
|
|
300
|
+
aria-label="partial disabled story"
|
|
296
301
|
aria-orientation="vertical"
|
|
297
302
|
className="charcoal-radio-group"
|
|
298
303
|
role="radiogroup"
|
|
@@ -304,9 +309,9 @@ exports[`Storybook Tests react/Radio PartialDisabled 1`] = `
|
|
|
304
309
|
<input
|
|
305
310
|
aria-invalid={false}
|
|
306
311
|
checked={true}
|
|
307
|
-
className="charcoal-
|
|
312
|
+
className="charcoal-radio-input"
|
|
308
313
|
disabled={false}
|
|
309
|
-
name="
|
|
314
|
+
name="partial_disabled_story"
|
|
310
315
|
onChange={[Function]}
|
|
311
316
|
type="radio"
|
|
312
317
|
value="1"
|
|
@@ -325,9 +330,9 @@ exports[`Storybook Tests react/Radio PartialDisabled 1`] = `
|
|
|
325
330
|
<input
|
|
326
331
|
aria-invalid={false}
|
|
327
332
|
checked={false}
|
|
328
|
-
className="charcoal-
|
|
333
|
+
className="charcoal-radio-input"
|
|
329
334
|
disabled={true}
|
|
330
|
-
name="
|
|
335
|
+
name="partial_disabled_story"
|
|
331
336
|
onChange={[Function]}
|
|
332
337
|
type="radio"
|
|
333
338
|
value="2"
|
|
@@ -346,9 +351,9 @@ exports[`Storybook Tests react/Radio PartialDisabled 1`] = `
|
|
|
346
351
|
<input
|
|
347
352
|
aria-invalid={false}
|
|
348
353
|
checked={false}
|
|
349
|
-
className="charcoal-
|
|
354
|
+
className="charcoal-radio-input"
|
|
350
355
|
disabled={false}
|
|
351
|
-
name="
|
|
356
|
+
name="partial_disabled_story"
|
|
352
357
|
onChange={[Function]}
|
|
353
358
|
type="radio"
|
|
354
359
|
value="3"
|
|
@@ -384,6 +389,7 @@ exports[`Storybook Tests react/Radio Readonly 1`] = `
|
|
|
384
389
|
className="c0"
|
|
385
390
|
>
|
|
386
391
|
<div
|
|
392
|
+
aria-label="readonly story"
|
|
387
393
|
aria-orientation="vertical"
|
|
388
394
|
className="charcoal-radio-group"
|
|
389
395
|
role="radiogroup"
|
|
@@ -395,9 +401,9 @@ exports[`Storybook Tests react/Radio Readonly 1`] = `
|
|
|
395
401
|
<input
|
|
396
402
|
aria-invalid={false}
|
|
397
403
|
checked={true}
|
|
398
|
-
className="charcoal-
|
|
404
|
+
className="charcoal-radio-input"
|
|
399
405
|
disabled={false}
|
|
400
|
-
name="
|
|
406
|
+
name="readonly_story"
|
|
401
407
|
onChange={[Function]}
|
|
402
408
|
type="radio"
|
|
403
409
|
value="1"
|
|
@@ -416,9 +422,9 @@ exports[`Storybook Tests react/Radio Readonly 1`] = `
|
|
|
416
422
|
<input
|
|
417
423
|
aria-invalid={false}
|
|
418
424
|
checked={false}
|
|
419
|
-
className="charcoal-
|
|
425
|
+
className="charcoal-radio-input"
|
|
420
426
|
disabled={true}
|
|
421
|
-
name="
|
|
427
|
+
name="readonly_story"
|
|
422
428
|
onChange={[Function]}
|
|
423
429
|
type="radio"
|
|
424
430
|
value="2"
|
|
@@ -437,9 +443,9 @@ exports[`Storybook Tests react/Radio Readonly 1`] = `
|
|
|
437
443
|
<input
|
|
438
444
|
aria-invalid={false}
|
|
439
445
|
checked={false}
|
|
440
|
-
className="charcoal-
|
|
446
|
+
className="charcoal-radio-input"
|
|
441
447
|
disabled={true}
|
|
442
|
-
name="
|
|
448
|
+
name="readonly_story"
|
|
443
449
|
onChange={[Function]}
|
|
444
450
|
type="radio"
|
|
445
451
|
value="3"
|
|
@@ -5,93 +5,14 @@
|
|
|
5
5
|
align-items: center;
|
|
6
6
|
cursor: pointer;
|
|
7
7
|
}
|
|
8
|
-
.charcoal-radio[aria-disabled]:not([aria-disabled='false']) {
|
|
9
|
-
opacity: 0.32;
|
|
10
|
-
cursor: default;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.charcoal-radio__input {
|
|
14
|
-
appearance: none;
|
|
15
|
-
display: block;
|
|
16
|
-
box-sizing: border-box;
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
width: 20px;
|
|
22
|
-
height: 20px;
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
border-radius: 999999px;
|
|
25
|
-
background-color: var(--charcoal-surface1);
|
|
26
|
-
transition: 0.2s background-color, 0.2s box-shadow;
|
|
27
|
-
}
|
|
28
|
-
.charcoal-radio__input:checked {
|
|
29
|
-
background-color: var(--charcoal-brand);
|
|
30
|
-
}
|
|
31
|
-
.charcoal-radio__input:checked::after {
|
|
32
|
-
content: '';
|
|
33
|
-
display: block;
|
|
34
|
-
width: 8px;
|
|
35
|
-
height: 8px;
|
|
36
|
-
pointer-events: none;
|
|
37
|
-
background-color: var(--charcoal-text5);
|
|
38
|
-
border-radius: 999999px;
|
|
39
|
-
transition: 0.2s background-color, 0.2s box-shadow;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.charcoal-radio__input:not(:checked) {
|
|
43
|
-
border-width: 2px;
|
|
44
|
-
border-style: solid;
|
|
45
|
-
border-color: var(--charcoal-text3);
|
|
46
|
-
}
|
|
47
|
-
.charcoal-radio__input:disabled {
|
|
9
|
+
.charcoal-radio__label[aria-disabled]:not([aria-disabled='false']) {
|
|
10
|
+
opacity: 0.32;
|
|
48
11
|
cursor: default;
|
|
49
12
|
}
|
|
50
13
|
|
|
51
|
-
.charcoal-radio__input:not(:disabled):hover {
|
|
52
|
-
background-color: var(--charcoal-surface1-hover);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.charcoal-radio__input:not(:disabled):active {
|
|
56
|
-
background-color: var(--charcoal-surface1-press);
|
|
57
|
-
}
|
|
58
|
-
.charcoal-radio__input:not(:disabled):focus {
|
|
59
|
-
outline: none;
|
|
60
|
-
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
61
|
-
}
|
|
62
|
-
.charcoal-radio__input:not(:disabled):focus-visible {
|
|
63
|
-
box-shadow: 0 0 0 4px rgba(0, 150, 250, 0.32);
|
|
64
|
-
}
|
|
65
|
-
.charcoal-radio__input:not(:disabled):focus:not(:focus-visible) {
|
|
66
|
-
box-shadow: none;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.charcoal-radio__input:not(:disabled)[aria-invalid='true'],
|
|
70
|
-
.charcoal-radio__input:not(:disabled)[aria-invalid='true']:focus {
|
|
71
|
-
box-shadow: 0 0 0 4px rgba(255, 43, 0, 0.32);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.charcoal-radio__input:checked:not(:disabled):hover {
|
|
75
|
-
background-color: var(--charcoal-brand-hover);
|
|
76
|
-
}
|
|
77
|
-
.charcoal-radio__input:checked:not(:disabled):hover::after {
|
|
78
|
-
background-color: var(--charcoal-text5-hover);
|
|
79
|
-
}
|
|
80
|
-
.charcoal-radio__input:checked:not(:disabled):active {
|
|
81
|
-
background-color: var(--charcoal-brand-press);
|
|
82
|
-
}
|
|
83
|
-
.charcoal-radio__input:checked:not(:disabled):active::after {
|
|
84
|
-
background-color: var(--charcoal-text5-press);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
14
|
.charcoal-radio__label_div {
|
|
88
15
|
font-size: 14px;
|
|
89
16
|
line-height: 22px;
|
|
90
17
|
color: var(--charcoal-text2);
|
|
91
18
|
}
|
|
92
|
-
|
|
93
|
-
.charcoal-radio-group {
|
|
94
|
-
display: grid;
|
|
95
|
-
grid-template-columns: 1fr;
|
|
96
|
-
grid-gap: 8px;
|
|
97
|
-
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components'
|
|
2
|
-
import Radio
|
|
2
|
+
import Radio from '.'
|
|
3
|
+
import { RadioGroup } from './RadioGroup'
|
|
3
4
|
import { px } from '@charcoal-ui/utils'
|
|
4
5
|
import { StoryObj } from '@storybook/react'
|
|
5
6
|
import { useState } from 'react'
|
|
@@ -27,7 +28,8 @@ export const Default: StoryObj<typeof Radio> = {
|
|
|
27
28
|
return (
|
|
28
29
|
<LayoutDiv>
|
|
29
30
|
<RadioGroup<Option>
|
|
30
|
-
name=
|
|
31
|
+
name="default_story"
|
|
32
|
+
label="default story"
|
|
31
33
|
{...args}
|
|
32
34
|
value={value}
|
|
33
35
|
onChange={setValue}
|
|
@@ -50,7 +52,8 @@ export const Disabled: StoryObj<typeof Radio> = {
|
|
|
50
52
|
return (
|
|
51
53
|
<LayoutDiv>
|
|
52
54
|
<RadioGroup<Option>
|
|
53
|
-
|
|
55
|
+
label="disabled_stroy"
|
|
56
|
+
name="disabled story"
|
|
54
57
|
value={value}
|
|
55
58
|
onChange={setValue}
|
|
56
59
|
disabled
|
|
@@ -72,7 +75,12 @@ export const PartialDisabled: StoryObj<typeof Radio> = {
|
|
|
72
75
|
|
|
73
76
|
return (
|
|
74
77
|
<LayoutDiv>
|
|
75
|
-
<RadioGroup<Option>
|
|
78
|
+
<RadioGroup<Option>
|
|
79
|
+
name={'partial_disabled_story'}
|
|
80
|
+
label={'partial disabled story'}
|
|
81
|
+
value={value}
|
|
82
|
+
onChange={setValue}
|
|
83
|
+
>
|
|
76
84
|
{options.map((option) => (
|
|
77
85
|
<Radio key={option} value={option} disabled={option === '2'}>
|
|
78
86
|
Value {option}
|
|
@@ -91,7 +99,8 @@ export const Readonly: StoryObj<typeof Radio> = {
|
|
|
91
99
|
return (
|
|
92
100
|
<LayoutDiv>
|
|
93
101
|
<RadioGroup<Option>
|
|
94
|
-
name=
|
|
102
|
+
name="readonly_story"
|
|
103
|
+
label="readonly story"
|
|
95
104
|
value={value}
|
|
96
105
|
onChange={setValue}
|
|
97
106
|
readonly
|
|
@@ -114,7 +123,8 @@ export const Invalid: StoryObj<typeof Radio> = {
|
|
|
114
123
|
return (
|
|
115
124
|
<LayoutDiv>
|
|
116
125
|
<RadioGroup<Option>
|
|
117
|
-
name=
|
|
126
|
+
name="invalid_story"
|
|
127
|
+
label="invalid story"
|
|
118
128
|
value={value}
|
|
119
129
|
onChange={setValue}
|
|
120
130
|
invalid
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fireEvent, render, screen } from '@testing-library/react'
|
|
2
2
|
import { ThemeProvider } from 'styled-components'
|
|
3
|
-
import Radio
|
|
3
|
+
import Radio from '.'
|
|
4
|
+
import { RadioGroup } from './RadioGroup'
|
|
4
5
|
import { light } from '@charcoal-ui/theme'
|
|
5
6
|
|
|
6
7
|
describe('Radio', () => {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './index.css'
|
|
2
|
+
|
|
3
|
+
import { memo, forwardRef, useContext } from 'react'
|
|
2
4
|
import * as React from 'react'
|
|
3
5
|
import warning from 'warning'
|
|
4
6
|
import { useClassNames } from '../../_lib/useClassNames'
|
|
5
7
|
|
|
6
|
-
import './
|
|
8
|
+
import { RadioGroupContext } from './RadioGroupContext'
|
|
9
|
+
import RadioInput from './RadioInput'
|
|
7
10
|
|
|
8
11
|
export type RadioProps = React.PropsWithChildren<{
|
|
9
12
|
value: string
|
|
@@ -36,23 +39,14 @@ const Radio = forwardRef<HTMLInputElement, RadioProps>(function RadioInner(
|
|
|
36
39
|
const isDisabled = disabled || isParentDisabled
|
|
37
40
|
const isReadonly = readonly && !isSelected
|
|
38
41
|
|
|
39
|
-
const handleChange = useCallback(
|
|
40
|
-
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
41
|
-
onChange(e.currentTarget.value)
|
|
42
|
-
},
|
|
43
|
-
[onChange]
|
|
44
|
-
)
|
|
45
|
-
|
|
46
42
|
return (
|
|
47
43
|
<label aria-disabled={isDisabled || isReadonly} className={classNames}>
|
|
48
|
-
<
|
|
49
|
-
type="radio"
|
|
50
|
-
className="charcoal-radio__input"
|
|
44
|
+
<RadioInput
|
|
51
45
|
name={name}
|
|
52
46
|
value={value}
|
|
53
47
|
checked={isSelected}
|
|
54
48
|
aria-invalid={invalid}
|
|
55
|
-
onChange={
|
|
49
|
+
onChange={onChange}
|
|
56
50
|
disabled={isDisabled || isReadonly}
|
|
57
51
|
ref={ref}
|
|
58
52
|
/>
|
|
@@ -64,79 +58,3 @@ const Radio = forwardRef<HTMLInputElement, RadioProps>(function RadioInner(
|
|
|
64
58
|
})
|
|
65
59
|
|
|
66
60
|
export default memo(Radio)
|
|
67
|
-
|
|
68
|
-
export type RadioGroupProps<Value extends string = string> =
|
|
69
|
-
React.PropsWithChildren<{
|
|
70
|
-
className?: string
|
|
71
|
-
value?: Value
|
|
72
|
-
name: string
|
|
73
|
-
onChange(next: Value): void
|
|
74
|
-
disabled?: boolean
|
|
75
|
-
readonly?: boolean
|
|
76
|
-
invalid?: boolean
|
|
77
|
-
ref?: React.Ref<HTMLDivElement>
|
|
78
|
-
}>
|
|
79
|
-
|
|
80
|
-
interface RadioGroupContext {
|
|
81
|
-
name: string
|
|
82
|
-
selected?: string
|
|
83
|
-
disabled: boolean
|
|
84
|
-
readonly: boolean
|
|
85
|
-
invalid: boolean
|
|
86
|
-
onChange: (next: string) => void
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const RadioGroupContext = React.createContext<RadioGroupContext>({
|
|
90
|
-
name: undefined as never,
|
|
91
|
-
selected: undefined,
|
|
92
|
-
disabled: false,
|
|
93
|
-
readonly: false,
|
|
94
|
-
invalid: false,
|
|
95
|
-
onChange() {
|
|
96
|
-
throw new Error(
|
|
97
|
-
'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?'
|
|
98
|
-
)
|
|
99
|
-
},
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps<string>>(
|
|
103
|
-
function RadioGroupInner(
|
|
104
|
-
{ value, name, onChange, disabled, readonly, invalid, children, ...props },
|
|
105
|
-
ref
|
|
106
|
-
) {
|
|
107
|
-
const classNames = useClassNames('charcoal-radio-group', props.className)
|
|
108
|
-
|
|
109
|
-
const handleChange = useCallback(
|
|
110
|
-
(next: string) => {
|
|
111
|
-
onChange(next)
|
|
112
|
-
},
|
|
113
|
-
[onChange]
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
const contextValue = useMemo(
|
|
117
|
-
() => ({
|
|
118
|
-
name,
|
|
119
|
-
selected: value,
|
|
120
|
-
disabled: disabled ?? false,
|
|
121
|
-
readonly: readonly ?? false,
|
|
122
|
-
invalid: invalid ?? false,
|
|
123
|
-
onChange: handleChange,
|
|
124
|
-
}),
|
|
125
|
-
[disabled, handleChange, invalid, name, readonly, value]
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
return (
|
|
129
|
-
<RadioGroupContext.Provider value={contextValue}>
|
|
130
|
-
<div
|
|
131
|
-
role="radiogroup"
|
|
132
|
-
aria-orientation="vertical"
|
|
133
|
-
aria-invalid={invalid}
|
|
134
|
-
className={classNames}
|
|
135
|
-
ref={ref}
|
|
136
|
-
>
|
|
137
|
-
{children}
|
|
138
|
-
</div>
|
|
139
|
-
</RadioGroupContext.Provider>
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
) as <Value extends string>(props: RadioGroupProps<Value>) => JSX.Element
|
package/src/index.ts
CHANGED
|
@@ -18,12 +18,8 @@ export {
|
|
|
18
18
|
default as IconButton,
|
|
19
19
|
type IconButtonProps,
|
|
20
20
|
} from './components/IconButton'
|
|
21
|
-
export {
|
|
22
|
-
|
|
23
|
-
type RadioProps,
|
|
24
|
-
RadioGroup,
|
|
25
|
-
type RadioGroupProps,
|
|
26
|
-
} from './components/Radio'
|
|
21
|
+
export { default as Radio, type RadioProps } from './components/Radio'
|
|
22
|
+
export { RadioGroup, type RadioGroupProps } from './components/Radio/RadioGroup'
|
|
27
23
|
export { default as Switch, type SwitchProps } from './components/Switch'
|
|
28
24
|
export {
|
|
29
25
|
default as TextField,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Divider.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/Divider.tsx"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO;;UAUnB,CAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { MenuItemProps } from './MenuItem';
|
|
2
|
-
export type DropdownMenuItemProps = Omit<MenuItemProps<'div'>, 'as'>;
|
|
3
|
-
/**
|
|
4
|
-
* DropdownSelectorの選択肢として使うMenuItem
|
|
5
|
-
*/
|
|
6
|
-
export default function DropdownMenuItem(props: DropdownMenuItemProps): JSX.Element;
|
|
7
|
-
//# sourceMappingURL=DropdownMenuItem.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuItem.d.ts","sourceRoot":"","sources":["../../../src/components/DropdownSelector/DropdownMenuItem.tsx"],"names":[],"mappings":"AACA,OAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAKpD,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;AAEpE;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eAWpE"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 水平方向の直線
|
|
5
|
-
*/
|
|
6
|
-
export const Divider = styled.div.attrs({ role: 'separator' })`
|
|
7
|
-
display: flex;
|
|
8
|
-
|
|
9
|
-
&:before {
|
|
10
|
-
content: '';
|
|
11
|
-
display: block;
|
|
12
|
-
width: 100%;
|
|
13
|
-
height: 1px;
|
|
14
|
-
background: #00000014;
|
|
15
|
-
}
|
|
16
|
-
`
|