@charcoal-ui/react 3.10.1 → 3.11.0
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/Checkbox/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts +1 -2
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +4 -4
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/CharcoalProvider.d.ts +1 -1
- package/dist/core/CharcoalProvider.d.ts.map +1 -1
- package/dist/index.cjs.js +120 -348
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +82 -310
- package/dist/index.esm.js.map +1 -1
- package/package.json +13 -17
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +560 -154
- package/src/components/Checkbox/index.story.tsx +46 -74
- package/src/components/Checkbox/index.tsx +1 -0
- package/src/components/DropdownSelector/Popover/index.tsx +1 -2
- package/src/components/IconButton/__snapshots__/index.story.storyshot +6 -8
- package/src/components/IconButton/index.story.tsx +14 -37
- package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +139 -1
- package/src/components/LoadingSpinner/index.story.tsx +18 -7
- package/src/components/Modal/index.tsx +1 -1
- package/src/components/Modal/useCustomModalOverlay.tsx +5 -4
- package/src/components/MultiSelect/__snapshots__/index.story.storyshot +32 -44
- package/src/components/MultiSelect/index.story.tsx +88 -192
- package/src/components/MultiSelect/index.tsx +2 -1
- package/src/components/Radio/__snapshots__/index.story.storyshot +1 -1
- package/src/components/Radio/index.story.tsx +20 -21
- package/src/components/Radio/index.tsx +14 -13
- package/src/components/Switch/__snapshots__/index.story.storyshot +8 -9
- package/src/components/Switch/index.story.tsx +10 -18
- package/src/components/TagItem/__snapshots__/index.story.storyshot +791 -665
- package/src/components/TagItem/index.story.tsx +44 -161
- package/src/components/TextArea/TextArea.story.tsx +62 -24
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +1858 -472
- package/src/components/TextArea/index.tsx +2 -0
- package/src/components/TextField/TextField.story.tsx +77 -67
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +2004 -786
- package/src/components/TextField/index.tsx +2 -0
- package/src/components/a11y.test.tsx +1 -1
- package/src/core/CharcoalProvider.tsx +1 -1
- package/dist/components/Button/index.story.d.ts +0 -14
- package/dist/components/Button/index.story.d.ts.map +0 -1
- package/dist/components/Checkbox/index.story.d.ts +0 -8
- package/dist/components/Checkbox/index.story.d.ts.map +0 -1
- package/dist/components/Clickable/index.story.d.ts +0 -6
- package/dist/components/Clickable/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/ListItem/index.story.d.ts +0 -9
- package/dist/components/DropdownSelector/ListItem/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/MenuList/index.story.d.ts +0 -8
- package/dist/components/DropdownSelector/MenuList/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/Popover/index.story.d.ts +0 -5
- package/dist/components/DropdownSelector/Popover/index.story.d.ts.map +0 -1
- package/dist/components/DropdownSelector/index.story.d.ts +0 -19
- package/dist/components/DropdownSelector/index.story.d.ts.map +0 -1
- package/dist/components/Icon/index.story.d.ts +0 -6
- package/dist/components/Icon/index.story.d.ts.map +0 -1
- package/dist/components/IconButton/index.story.d.ts +0 -9
- package/dist/components/IconButton/index.story.d.ts.map +0 -1
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts +0 -8
- package/dist/components/LoadingSpinner/LoadingSpinnerIcon.story.d.ts.map +0 -1
- package/dist/components/LoadingSpinner/index.story.d.ts +0 -6
- package/dist/components/LoadingSpinner/index.story.d.ts.map +0 -1
- package/dist/components/Modal/index.story.d.ts +0 -21
- package/dist/components/Modal/index.story.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.story.d.ts +0 -82
- package/dist/components/MultiSelect/index.story.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.test.d.ts +0 -2
- package/dist/components/MultiSelect/index.test.d.ts.map +0 -1
- package/dist/components/Radio/index.story.d.ts +0 -26
- package/dist/components/Radio/index.story.d.ts.map +0 -1
- package/dist/components/Radio/index.test.d.ts +0 -2
- package/dist/components/Radio/index.test.d.ts.map +0 -1
- package/dist/components/SegmentedControl/index.story.d.ts +0 -7
- package/dist/components/SegmentedControl/index.story.d.ts.map +0 -1
- package/dist/components/Switch/index.story.d.ts +0 -9
- package/dist/components/Switch/index.story.d.ts.map +0 -1
- package/dist/components/TagItem/index.story.d.ts +0 -16
- package/dist/components/TagItem/index.story.d.ts.map +0 -1
- package/dist/components/TextArea/TextArea.story.d.ts +0 -9
- package/dist/components/TextArea/TextArea.story.d.ts.map +0 -1
- package/dist/components/TextField/TextField.story.d.ts +0 -22
- package/dist/components/TextField/TextField.story.d.ts.map +0 -1
- package/dist/components/a11y.test.d.ts +0 -2
- package/dist/components/a11y.test.d.ts.map +0 -1
- package/src/components/LoadingSpinner/LoadingSpinnerIcon.story.tsx +0 -13
|
@@ -7,10 +7,6 @@ import { useState } from 'react'
|
|
|
7
7
|
export default {
|
|
8
8
|
title: 'Radio',
|
|
9
9
|
component: Radio,
|
|
10
|
-
args: {
|
|
11
|
-
name: 'name',
|
|
12
|
-
label: 'label',
|
|
13
|
-
},
|
|
14
10
|
parameters: {
|
|
15
11
|
layout: 'centered',
|
|
16
12
|
},
|
|
@@ -21,16 +17,19 @@ const LayoutDiv = styled.div`
|
|
|
21
17
|
flex-direction: column;
|
|
22
18
|
gap: ${({ theme }) => px(theme.spacing[24])};
|
|
23
19
|
`
|
|
20
|
+
const options = ['1', '2', '3'] as const
|
|
21
|
+
type Option = (typeof options)[number]
|
|
22
|
+
|
|
23
|
+
export const Default: StoryObj<typeof Radio> = {
|
|
24
|
+
render: function Render(args) {
|
|
25
|
+
const [value, setValue] = useState<Option>(options[0])
|
|
24
26
|
|
|
25
|
-
export const Basic: StoryObj<typeof Radio> = {
|
|
26
|
-
render: function Render() {
|
|
27
|
-
const options = ['1', '2', '3']
|
|
28
|
-
const [value, setValue] = useState(options[0])
|
|
29
27
|
return (
|
|
30
28
|
<LayoutDiv>
|
|
31
|
-
<RadioGroup
|
|
29
|
+
<RadioGroup<Option>
|
|
32
30
|
label={'label'}
|
|
33
31
|
name={'name'}
|
|
32
|
+
{...args}
|
|
34
33
|
value={value}
|
|
35
34
|
onChange={setValue}
|
|
36
35
|
>
|
|
@@ -47,11 +46,11 @@ export const Basic: StoryObj<typeof Radio> = {
|
|
|
47
46
|
|
|
48
47
|
export const Disabled: StoryObj<typeof Radio> = {
|
|
49
48
|
render: function Render() {
|
|
50
|
-
const
|
|
51
|
-
|
|
49
|
+
const [value, setValue] = useState<Option>(options[0])
|
|
50
|
+
|
|
52
51
|
return (
|
|
53
52
|
<LayoutDiv>
|
|
54
|
-
<RadioGroup
|
|
53
|
+
<RadioGroup<Option>
|
|
55
54
|
label={'label'}
|
|
56
55
|
name={'name'}
|
|
57
56
|
value={value}
|
|
@@ -71,11 +70,11 @@ export const Disabled: StoryObj<typeof Radio> = {
|
|
|
71
70
|
|
|
72
71
|
export const PartialDisabled: StoryObj<typeof Radio> = {
|
|
73
72
|
render: function Render() {
|
|
74
|
-
const
|
|
75
|
-
|
|
73
|
+
const [value, setValue] = useState<Option>(options[0])
|
|
74
|
+
|
|
76
75
|
return (
|
|
77
76
|
<LayoutDiv>
|
|
78
|
-
<RadioGroup
|
|
77
|
+
<RadioGroup<Option>
|
|
79
78
|
label={'label'}
|
|
80
79
|
name={'name'}
|
|
81
80
|
value={value}
|
|
@@ -94,11 +93,11 @@ export const PartialDisabled: StoryObj<typeof Radio> = {
|
|
|
94
93
|
|
|
95
94
|
export const Readonly: StoryObj<typeof Radio> = {
|
|
96
95
|
render: function Render() {
|
|
97
|
-
const
|
|
98
|
-
|
|
96
|
+
const [value, setValue] = useState<Option>(options[0])
|
|
97
|
+
|
|
99
98
|
return (
|
|
100
99
|
<LayoutDiv>
|
|
101
|
-
<RadioGroup
|
|
100
|
+
<RadioGroup<Option>
|
|
102
101
|
label={'label'}
|
|
103
102
|
name={'name'}
|
|
104
103
|
value={value}
|
|
@@ -118,11 +117,11 @@ export const Readonly: StoryObj<typeof Radio> = {
|
|
|
118
117
|
|
|
119
118
|
export const Invalid: StoryObj<typeof Radio> = {
|
|
120
119
|
render: function Render() {
|
|
121
|
-
const
|
|
122
|
-
|
|
120
|
+
const [value, setValue] = useState<Option>(options[0])
|
|
121
|
+
|
|
123
122
|
return (
|
|
124
123
|
<LayoutDiv>
|
|
125
|
-
<RadioGroup
|
|
124
|
+
<RadioGroup<Option>
|
|
126
125
|
label={'label'}
|
|
127
126
|
name={'name'}
|
|
128
127
|
value={value}
|
|
@@ -169,16 +169,17 @@ const RadioLabel = styled.div`
|
|
|
169
169
|
}
|
|
170
170
|
`
|
|
171
171
|
|
|
172
|
-
export type RadioGroupProps =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
172
|
+
export type RadioGroupProps<Value extends string = string> =
|
|
173
|
+
React.PropsWithChildren<{
|
|
174
|
+
className?: string
|
|
175
|
+
value?: Value
|
|
176
|
+
label: string
|
|
177
|
+
name: string
|
|
178
|
+
onChange(next: Value): void
|
|
179
|
+
disabled?: boolean
|
|
180
|
+
readonly?: boolean
|
|
181
|
+
invalid?: boolean
|
|
182
|
+
}>
|
|
182
183
|
|
|
183
184
|
// TODO: use (or polyfill) flex gap
|
|
184
185
|
const StyledRadioGroup = styled.div`
|
|
@@ -209,7 +210,7 @@ const RadioGroupContext = React.createContext<RadioGroupContext>({
|
|
|
209
210
|
},
|
|
210
211
|
})
|
|
211
212
|
|
|
212
|
-
export function RadioGroup({
|
|
213
|
+
export function RadioGroup<Value extends string = string>({
|
|
213
214
|
className,
|
|
214
215
|
value,
|
|
215
216
|
label,
|
|
@@ -219,10 +220,10 @@ export function RadioGroup({
|
|
|
219
220
|
readonly,
|
|
220
221
|
invalid,
|
|
221
222
|
children,
|
|
222
|
-
}: RadioGroupProps) {
|
|
223
|
+
}: RadioGroupProps<Value>) {
|
|
223
224
|
const handleChange = useCallback(
|
|
224
225
|
(next: string) => {
|
|
225
|
-
onChange(next)
|
|
226
|
+
onChange(next as Value)
|
|
226
227
|
},
|
|
227
228
|
[onChange]
|
|
228
229
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Storybook Tests Switch
|
|
3
|
+
exports[`Storybook Tests Switch Checked 1`] = `
|
|
4
4
|
.c0 {
|
|
5
5
|
display: inline-grid;
|
|
6
6
|
grid-template-columns: auto 1fr;
|
|
@@ -118,8 +118,8 @@ exports[`Storybook Tests Switch Basic 1`] = `
|
|
|
118
118
|
className="c0"
|
|
119
119
|
>
|
|
120
120
|
<input
|
|
121
|
-
aria-label="
|
|
122
|
-
checked={
|
|
121
|
+
aria-label="checked"
|
|
122
|
+
checked={true}
|
|
123
123
|
className="c1"
|
|
124
124
|
disabled={false}
|
|
125
125
|
name="name"
|
|
@@ -144,7 +144,7 @@ exports[`Storybook Tests Switch Basic 1`] = `
|
|
|
144
144
|
</div>
|
|
145
145
|
`;
|
|
146
146
|
|
|
147
|
-
exports[`Storybook Tests Switch
|
|
147
|
+
exports[`Storybook Tests Switch Default 1`] = `
|
|
148
148
|
.c0 {
|
|
149
149
|
display: inline-grid;
|
|
150
150
|
grid-template-columns: auto 1fr;
|
|
@@ -262,8 +262,7 @@ exports[`Storybook Tests Switch Checked 1`] = `
|
|
|
262
262
|
className="c0"
|
|
263
263
|
>
|
|
264
264
|
<input
|
|
265
|
-
|
|
266
|
-
checked={true}
|
|
265
|
+
checked={false}
|
|
267
266
|
className="c1"
|
|
268
267
|
disabled={false}
|
|
269
268
|
name="name"
|
|
@@ -417,7 +416,7 @@ exports[`Storybook Tests Switch Disabled 1`] = `
|
|
|
417
416
|
checked={false}
|
|
418
417
|
className="c1"
|
|
419
418
|
disabled={true}
|
|
420
|
-
name="
|
|
419
|
+
name="disabled"
|
|
421
420
|
onChange={[Function]}
|
|
422
421
|
onClick={[Function]}
|
|
423
422
|
onDragStart={[Function]}
|
|
@@ -444,7 +443,7 @@ exports[`Storybook Tests Switch Disabled 1`] = `
|
|
|
444
443
|
</div>
|
|
445
444
|
`;
|
|
446
445
|
|
|
447
|
-
exports[`Storybook Tests Switch
|
|
446
|
+
exports[`Storybook Tests Switch Label 1`] = `
|
|
448
447
|
.c0 {
|
|
449
448
|
display: inline-grid;
|
|
450
449
|
grid-template-columns: auto 1fr;
|
|
@@ -572,7 +571,7 @@ exports[`Storybook Tests Switch Labelled 1`] = `
|
|
|
572
571
|
checked={false}
|
|
573
572
|
className="c1"
|
|
574
573
|
disabled={false}
|
|
575
|
-
name="
|
|
574
|
+
name="label"
|
|
576
575
|
onChange={[Function]}
|
|
577
576
|
onClick={[Function]}
|
|
578
577
|
onDragStart={[Function]}
|
|
@@ -5,16 +5,12 @@ import { Meta, StoryObj } from '@storybook/react'
|
|
|
5
5
|
export default {
|
|
6
6
|
title: 'Switch',
|
|
7
7
|
component: Switch,
|
|
8
|
-
args: {
|
|
9
|
-
name: 'name',
|
|
10
|
-
label: 'label',
|
|
11
|
-
},
|
|
12
8
|
parameters: {
|
|
13
9
|
layout: 'centered',
|
|
14
10
|
},
|
|
15
11
|
} as Meta<typeof Switch>
|
|
16
12
|
|
|
17
|
-
export const
|
|
13
|
+
export const Default: StoryObj<typeof Switch> = {
|
|
18
14
|
render: function Render(args) {
|
|
19
15
|
const [checked, setChecked] = useState(false)
|
|
20
16
|
return (
|
|
@@ -33,33 +29,29 @@ export const Basic: StoryObj<typeof Switch> = {
|
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
export const Checked: StoryObj<typeof Switch> = {
|
|
36
|
-
render: function Render(
|
|
32
|
+
render: function Render() {
|
|
37
33
|
const [checked, setChecked] = useState(true)
|
|
38
34
|
return (
|
|
39
35
|
<div>
|
|
40
36
|
<Switch
|
|
41
|
-
{...args}
|
|
42
37
|
name="name"
|
|
38
|
+
label="checked"
|
|
43
39
|
onChange={(v) => {
|
|
44
40
|
setChecked(v)
|
|
45
41
|
}}
|
|
46
|
-
checked={
|
|
42
|
+
checked={checked}
|
|
47
43
|
/>
|
|
48
44
|
</div>
|
|
49
45
|
)
|
|
50
46
|
},
|
|
51
47
|
}
|
|
52
48
|
|
|
53
|
-
export const
|
|
54
|
-
render: function Render(
|
|
49
|
+
export const Label: StoryObj<typeof Switch> = {
|
|
50
|
+
render: function Render() {
|
|
55
51
|
const [checked, setChecked] = useState(false)
|
|
56
52
|
return (
|
|
57
53
|
<div>
|
|
58
|
-
<Switch
|
|
59
|
-
{...args}
|
|
60
|
-
checked={args.checked ?? checked}
|
|
61
|
-
onChange={setChecked}
|
|
62
|
-
>
|
|
54
|
+
<Switch name="label" checked={checked} onChange={setChecked}>
|
|
63
55
|
Label
|
|
64
56
|
</Switch>
|
|
65
57
|
</div>
|
|
@@ -68,13 +60,13 @@ export const Labelled: StoryObj<typeof Switch> = {
|
|
|
68
60
|
}
|
|
69
61
|
|
|
70
62
|
export const Disabled: StoryObj<typeof Switch> = {
|
|
71
|
-
render: function Render(
|
|
63
|
+
render: function Render() {
|
|
72
64
|
const [checked, setChecked] = useState(false)
|
|
73
65
|
return (
|
|
74
66
|
<div>
|
|
75
67
|
<Switch
|
|
76
|
-
|
|
77
|
-
checked={
|
|
68
|
+
name="disabled"
|
|
69
|
+
checked={checked}
|
|
78
70
|
onChange={setChecked}
|
|
79
71
|
disabled
|
|
80
72
|
>
|