@charcoal-ui/react 4.0.0-beta.6 → 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/_lib/createDivComponent.d.ts +4 -0
- package/dist/_lib/createDivComponent.d.ts.map +1 -0
- 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/Modal/ModalPlumbing.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/components/TextArea/index.d.ts +1 -0
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +5 -0
- package/dist/components/TextField/AssistiveText/index.d.ts.map +1 -0
- package/dist/components/TextField/index.d.ts +1 -3
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/index.cjs.js +308 -347
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +330 -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 +257 -296
- package/dist/index.esm.js.map +1 -1
- package/package.json +8 -8
- package/src/_lib/createDivComponent.tsx +11 -0
- 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 +397 -1187
- package/src/components/DropdownSelector/index.css +84 -0
- package/src/components/DropdownSelector/index.story.tsx +0 -4
- package/src/components/DropdownSelector/index.tsx +41 -103
- package/src/components/Modal/ModalPlumbing.tsx +2 -11
- package/src/components/Modal/__snapshots__/index.story.storyshot +58 -410
- 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/components/TextArea/__snapshots__/TextArea.story.storyshot +141 -813
- package/src/components/TextArea/index.css +78 -0
- package/src/components/TextArea/index.tsx +26 -96
- package/src/components/TextField/AssistiveText/index.css +10 -0
- package/src/components/TextField/AssistiveText/index.tsx +6 -0
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +109 -1059
- package/src/components/TextField/index.css +87 -0
- package/src/components/TextField/index.tsx +24 -117
- 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,80 @@
|
|
|
1
|
+
import './index.css'
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useCallback, useMemo } from 'react'
|
|
4
|
+
import * as React from 'react'
|
|
5
|
+
import { useClassNames } from '../../../_lib/useClassNames'
|
|
6
|
+
import { RadioGroupContext } from '../RadioGroupContext'
|
|
7
|
+
|
|
8
|
+
export type RadioGroupProps<Value extends string = string> =
|
|
9
|
+
React.PropsWithChildren<{
|
|
10
|
+
className?: string
|
|
11
|
+
value?: Value
|
|
12
|
+
/**
|
|
13
|
+
* aria-label of RadioGroup
|
|
14
|
+
*/
|
|
15
|
+
label?: string
|
|
16
|
+
name: string
|
|
17
|
+
onChange(next: Value): void
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
readonly?: boolean
|
|
20
|
+
invalid?: boolean
|
|
21
|
+
ref?: React.Ref<HTMLDivElement>
|
|
22
|
+
'aria-labelledby'?: React.ComponentProps<'div'>['aria-labelledby']
|
|
23
|
+
'aria-orientation'?: React.ComponentProps<'div'>['aria-orientation']
|
|
24
|
+
}>
|
|
25
|
+
|
|
26
|
+
export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps<string>>(
|
|
27
|
+
function RadioGroupInner(
|
|
28
|
+
{
|
|
29
|
+
value,
|
|
30
|
+
label,
|
|
31
|
+
name,
|
|
32
|
+
onChange,
|
|
33
|
+
disabled,
|
|
34
|
+
readonly,
|
|
35
|
+
invalid,
|
|
36
|
+
children,
|
|
37
|
+
'aria-orientation': ariaOrientation = 'vertical',
|
|
38
|
+
...props
|
|
39
|
+
},
|
|
40
|
+
ref
|
|
41
|
+
) {
|
|
42
|
+
const classNames = useClassNames('charcoal-radio-group', props.className)
|
|
43
|
+
|
|
44
|
+
const handleChange = useCallback(
|
|
45
|
+
(next: string) => {
|
|
46
|
+
onChange(next)
|
|
47
|
+
},
|
|
48
|
+
[onChange]
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
const contextValue = useMemo(
|
|
52
|
+
() => ({
|
|
53
|
+
name,
|
|
54
|
+
selected: value,
|
|
55
|
+
disabled: disabled ?? false,
|
|
56
|
+
readonly: readonly ?? false,
|
|
57
|
+
invalid: invalid ?? false,
|
|
58
|
+
onChange: handleChange,
|
|
59
|
+
}),
|
|
60
|
+
[disabled, handleChange, invalid, name, readonly, value]
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<RadioGroupContext.Provider value={contextValue}>
|
|
65
|
+
<div
|
|
66
|
+
role="radiogroup"
|
|
67
|
+
aria-disabled={disabled}
|
|
68
|
+
aria-invalid={invalid}
|
|
69
|
+
aria-label={label}
|
|
70
|
+
aria-labelledby={props['aria-labelledby']}
|
|
71
|
+
aria-orientation={ariaOrientation}
|
|
72
|
+
className={classNames}
|
|
73
|
+
ref={ref}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</div>
|
|
77
|
+
</RadioGroupContext.Provider>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
) as <Value extends string>(props: RadioGroupProps<Value>) => JSX.Element
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
export interface RadioGroupContext {
|
|
4
|
+
name: string
|
|
5
|
+
selected?: string
|
|
6
|
+
disabled: boolean
|
|
7
|
+
readonly: boolean
|
|
8
|
+
invalid: boolean
|
|
9
|
+
onChange: (next: string) => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const RadioGroupContext = React.createContext<RadioGroupContext>({
|
|
13
|
+
name: undefined as never,
|
|
14
|
+
selected: undefined,
|
|
15
|
+
disabled: false,
|
|
16
|
+
readonly: false,
|
|
17
|
+
invalid: false,
|
|
18
|
+
onChange() {
|
|
19
|
+
throw new Error(
|
|
20
|
+
'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?'
|
|
21
|
+
)
|
|
22
|
+
},
|
|
23
|
+
})
|
|
@@ -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', () => {
|