@charcoal-ui/react 4.0.0-beta.7 → 4.0.0-rc.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/_lib/compat.d.ts +0 -12
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/_lib/createDivComponent.d.ts +2 -2
- package/dist/_lib/createDivComponent.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +2 -6
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Clickable/index.d.ts +4 -7
- package/dist/components/Clickable/index.d.ts.map +1 -1
- 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/IconButton/index.d.ts +1 -2
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/Modal/Dialog/index.d.ts +1 -1
- package/dist/components/Modal/Dialog/index.d.ts.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +6 -6
- package/dist/components/Modal/ModalPlumbing.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.d.ts +1 -0
- package/dist/components/Modal/useCustomModalOverlay.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/TagItem/index.d.ts +2 -6
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +2 -2
- package/dist/components/TextField/AssistiveText/index.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts +3 -3
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/CharcoalProvider.d.ts +4 -11
- package/dist/core/CharcoalProvider.d.ts.map +1 -1
- package/dist/index.cjs.js +356 -399
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +176 -27
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +322 -363
- package/dist/index.esm.js.map +1 -1
- package/dist/layered.css +1214 -0
- package/dist/layered.css.map +1 -0
- package/package.json +17 -13
- package/src/README.mdx +68 -0
- package/src/SSR.mdx +67 -0
- package/src/_lib/compat.ts +0 -11
- package/src/_lib/index.ts +1 -1
- package/src/components/Button/__snapshots__/index.story.storyshot +9 -9
- package/src/components/Button/index.tsx +4 -10
- package/src/components/Checkbox/CheckboxInput/__snapshots__/index.story.storyshot +5 -5
- package/src/components/Checkbox/CheckboxInput/index.css +4 -5
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +6 -6
- package/src/components/Clickable/__snapshots__/index.story.storyshot +2 -2
- package/src/components/Clickable/index.story.tsx +1 -1
- package/src/components/Clickable/index.tsx +7 -12
- 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 +41 -99
- package/src/components/DropdownSelector/ListItem/index.css +24 -0
- package/src/components/DropdownSelector/ListItem/index.story.tsx +11 -5
- 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 +162 -416
- package/src/components/DropdownSelector/MenuList/index.css +4 -0
- package/src/components/DropdownSelector/MenuList/index.tsx +4 -12
- package/src/components/DropdownSelector/Popover/__snapshots__/index.story.storyshot +1 -1
- 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 +403 -1181
- 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/Icon/__snapshots__/index.story.storyshot +1 -1
- package/src/components/IconButton/__snapshots__/index.story.storyshot +3 -3
- package/src/components/IconButton/index.tsx +3 -6
- package/src/components/LoadingSpinner/__snapshots__/index.story.storyshot +4 -4
- package/src/components/Modal/Dialog/index.tsx +2 -1
- package/src/components/Modal/__snapshots__/index.story.storyshot +118 -437
- package/src/components/Modal/index.story.tsx +26 -11
- package/src/components/Modal/index.tsx +5 -6
- package/src/components/Modal/useCustomModalOverlay.tsx +20 -0
- 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 +76 -95
- package/src/components/Radio/index.css +2 -81
- package/src/components/Radio/index.story.tsx +30 -13
- package/src/components/Radio/index.test.tsx +22 -28
- package/src/components/Radio/index.tsx +7 -89
- package/src/components/SegmentedControl/__snapshots__/index.story.storyshot +2 -2
- package/src/components/Switch/__snapshots__/index.story.storyshot +4 -4
- package/src/components/TagItem/__snapshots__/index.story.storyshot +8 -8
- package/src/components/TagItem/index.tsx +4 -8
- package/src/components/TextArea/__snapshots__/TextArea.story.storyshot +11 -11
- package/src/components/TextField/TextField.story.tsx +8 -9
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +20 -26
- package/src/components/TextField/index.tsx +2 -2
- package/src/core/CharcoalProvider.tsx +5 -29
- package/src/index.ts +2 -11
- package/src/type.d.ts +2 -13
- 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/dist/components/Modal/__stories__/InternalScrollStory.d.ts +0 -4
- package/dist/components/Modal/__stories__/InternalScrollStory.d.ts.map +0 -1
- package/dist/core/ComponentAbstraction.d.ts +0 -24
- package/dist/core/ComponentAbstraction.d.ts.map +0 -1
- package/dist/styled.d.ts +0 -95
- package/dist/styled.d.ts.map +0 -1
- package/src/components/Button/__snapshots__/index.test.tsx.snap +0 -11
- package/src/components/Button/index.test.tsx +0 -32
- package/src/components/DropdownSelector/Divider.tsx +0 -16
- package/src/components/DropdownSelector/DropdownMenuItem.tsx +0 -43
- package/src/components/Modal/__stories__/InternalScrollStory.tsx +0 -75
- package/src/components/a11y.test.tsx +0 -99
- package/src/core/ComponentAbstraction.tsx +0 -48
- package/src/styled.ts +0 -3
|
@@ -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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Storybook Tests react/SegmentedControl ObjectSegments 1`] = `
|
|
3
|
+
exports[`Storybook Tests > react/SegmentedControl > ObjectSegments 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
data-dark={false}
|
|
6
6
|
>
|
|
@@ -140,7 +140,7 @@ exports[`Storybook Tests react/SegmentedControl ObjectSegments 1`] = `
|
|
|
140
140
|
</div>
|
|
141
141
|
`;
|
|
142
142
|
|
|
143
|
-
exports[`Storybook Tests react/SegmentedControl StringSegments 1`] = `
|
|
143
|
+
exports[`Storybook Tests > react/SegmentedControl > StringSegments 1`] = `
|
|
144
144
|
<div
|
|
145
145
|
data-dark={false}
|
|
146
146
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Storybook Tests react/Switch Checked 1`] = `
|
|
3
|
+
exports[`Storybook Tests > react/Switch > Checked 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
data-dark={false}
|
|
6
6
|
>
|
|
@@ -19,7 +19,7 @@ exports[`Storybook Tests react/Switch Checked 1`] = `
|
|
|
19
19
|
</div>
|
|
20
20
|
`;
|
|
21
21
|
|
|
22
|
-
exports[`Storybook Tests react/Switch Default 1`] = `
|
|
22
|
+
exports[`Storybook Tests > react/Switch > Default 1`] = `
|
|
23
23
|
<div
|
|
24
24
|
data-dark={false}
|
|
25
25
|
>
|
|
@@ -37,7 +37,7 @@ exports[`Storybook Tests react/Switch Default 1`] = `
|
|
|
37
37
|
</div>
|
|
38
38
|
`;
|
|
39
39
|
|
|
40
|
-
exports[`Storybook Tests react/Switch Disabled 1`] = `
|
|
40
|
+
exports[`Storybook Tests > react/Switch > Disabled 1`] = `
|
|
41
41
|
<div
|
|
42
42
|
data-dark={false}
|
|
43
43
|
>
|
|
@@ -67,7 +67,7 @@ exports[`Storybook Tests react/Switch Disabled 1`] = `
|
|
|
67
67
|
</div>
|
|
68
68
|
`;
|
|
69
69
|
|
|
70
|
-
exports[`Storybook Tests react/Switch Label 1`] = `
|
|
70
|
+
exports[`Storybook Tests > react/Switch > Label 1`] = `
|
|
71
71
|
<div
|
|
72
72
|
data-dark={false}
|
|
73
73
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Storybook Tests react/TagItem Active 1`] = `
|
|
3
|
+
exports[`Storybook Tests > react/TagItem > Active 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
data-dark={false}
|
|
6
6
|
>
|
|
@@ -33,7 +33,7 @@ exports[`Storybook Tests react/TagItem Active 1`] = `
|
|
|
33
33
|
</div>
|
|
34
34
|
`;
|
|
35
35
|
|
|
36
|
-
exports[`Storybook Tests react/TagItem BGColor 1`] = `
|
|
36
|
+
exports[`Storybook Tests > react/TagItem > BGColor 1`] = `
|
|
37
37
|
<div
|
|
38
38
|
data-dark={false}
|
|
39
39
|
>
|
|
@@ -63,7 +63,7 @@ exports[`Storybook Tests react/TagItem BGColor 1`] = `
|
|
|
63
63
|
</div>
|
|
64
64
|
`;
|
|
65
65
|
|
|
66
|
-
exports[`Storybook Tests react/TagItem BGImage 1`] = `
|
|
66
|
+
exports[`Storybook Tests > react/TagItem > BGImage 1`] = `
|
|
67
67
|
<div
|
|
68
68
|
data-dark={false}
|
|
69
69
|
>
|
|
@@ -93,7 +93,7 @@ exports[`Storybook Tests react/TagItem BGImage 1`] = `
|
|
|
93
93
|
</div>
|
|
94
94
|
`;
|
|
95
95
|
|
|
96
|
-
exports[`Storybook Tests react/TagItem Default 1`] = `
|
|
96
|
+
exports[`Storybook Tests > react/TagItem > Default 1`] = `
|
|
97
97
|
<div
|
|
98
98
|
data-dark={false}
|
|
99
99
|
>
|
|
@@ -123,7 +123,7 @@ exports[`Storybook Tests react/TagItem Default 1`] = `
|
|
|
123
123
|
</div>
|
|
124
124
|
`;
|
|
125
125
|
|
|
126
|
-
exports[`Storybook Tests react/TagItem Disabled 1`] = `
|
|
126
|
+
exports[`Storybook Tests > react/TagItem > Disabled 1`] = `
|
|
127
127
|
<div
|
|
128
128
|
data-dark={false}
|
|
129
129
|
>
|
|
@@ -154,7 +154,7 @@ exports[`Storybook Tests react/TagItem Disabled 1`] = `
|
|
|
154
154
|
</div>
|
|
155
155
|
`;
|
|
156
156
|
|
|
157
|
-
exports[`Storybook Tests react/TagItem InActive 1`] = `
|
|
157
|
+
exports[`Storybook Tests > react/TagItem > InActive 1`] = `
|
|
158
158
|
<div
|
|
159
159
|
data-dark={false}
|
|
160
160
|
>
|
|
@@ -184,7 +184,7 @@ exports[`Storybook Tests react/TagItem InActive 1`] = `
|
|
|
184
184
|
</div>
|
|
185
185
|
`;
|
|
186
186
|
|
|
187
|
-
exports[`Storybook Tests react/TagItem Small 1`] = `
|
|
187
|
+
exports[`Storybook Tests > react/TagItem > Small 1`] = `
|
|
188
188
|
<div
|
|
189
189
|
data-dark={false}
|
|
190
190
|
>
|
|
@@ -214,7 +214,7 @@ exports[`Storybook Tests react/TagItem Small 1`] = `
|
|
|
214
214
|
</div>
|
|
215
215
|
`;
|
|
216
216
|
|
|
217
|
-
exports[`Storybook Tests react/TagItem TranslatedLabel 1`] = `
|
|
217
|
+
exports[`Storybook Tests > react/TagItem > TranslatedLabel 1`] = `
|
|
218
218
|
<div
|
|
219
219
|
data-dark={false}
|
|
220
220
|
>
|
|
@@ -21,16 +21,12 @@ export type TagItemProps<T extends React.ElementType = 'button'> = {
|
|
|
21
21
|
* The component used for root element.
|
|
22
22
|
* @type T extends React.ElementType = 'button'
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* The as property of the component specified by the Button component's as attribute.
|
|
27
|
-
*/
|
|
28
|
-
componentAs?: React.ComponentPropsWithRef<T>['as']
|
|
29
|
-
} & Omit<React.ComponentPropsWithRef<T>, 'children' | 'as'>
|
|
24
|
+
component?: T
|
|
25
|
+
} & Omit<React.ComponentPropsWithRef<T>, 'children'>
|
|
30
26
|
|
|
31
27
|
const TagItem = forwardRef(function TagItemInner<T extends React.ElementType>(
|
|
32
28
|
{
|
|
33
|
-
|
|
29
|
+
component,
|
|
34
30
|
label,
|
|
35
31
|
translatedLabel,
|
|
36
32
|
bgColor = '#7ACCB1',
|
|
@@ -55,7 +51,7 @@ const TagItem = forwardRef(function TagItemInner<T extends React.ElementType>(
|
|
|
55
51
|
bgImage !== undefined && bgImage.length > 0 ? 'image' : 'color'
|
|
56
52
|
const bg = bgVariant === 'color' ? bgColor : `url(${bgImage ?? ''})`
|
|
57
53
|
|
|
58
|
-
const Component = useMemo(() =>
|
|
54
|
+
const Component = useMemo(() => component ?? 'button', [component])
|
|
59
55
|
|
|
60
56
|
return (
|
|
61
57
|
<Component
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Storybook Tests react/TextArea AssistiveText 1`] = `
|
|
3
|
+
exports[`Storybook Tests > react/TextArea > AssistiveText 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
data-dark={false}
|
|
6
6
|
>
|
|
@@ -69,7 +69,7 @@ exports[`Storybook Tests react/TextArea AssistiveText 1`] = `
|
|
|
69
69
|
</div>
|
|
70
70
|
`;
|
|
71
71
|
|
|
72
|
-
exports[`Storybook Tests react/TextArea AutoHeight 1`] = `
|
|
72
|
+
exports[`Storybook Tests > react/TextArea > AutoHeight 1`] = `
|
|
73
73
|
<div
|
|
74
74
|
data-dark={false}
|
|
75
75
|
>
|
|
@@ -130,7 +130,7 @@ exports[`Storybook Tests react/TextArea AutoHeight 1`] = `
|
|
|
130
130
|
</div>
|
|
131
131
|
`;
|
|
132
132
|
|
|
133
|
-
exports[`Storybook Tests react/TextArea Default 1`] = `
|
|
133
|
+
exports[`Storybook Tests > react/TextArea > Default 1`] = `
|
|
134
134
|
<div
|
|
135
135
|
data-dark={false}
|
|
136
136
|
>
|
|
@@ -201,7 +201,7 @@ exports[`Storybook Tests react/TextArea Default 1`] = `
|
|
|
201
201
|
</div>
|
|
202
202
|
`;
|
|
203
203
|
|
|
204
|
-
exports[`Storybook Tests react/TextArea Disabled 1`] = `
|
|
204
|
+
exports[`Storybook Tests > react/TextArea > Disabled 1`] = `
|
|
205
205
|
<div
|
|
206
206
|
data-dark={false}
|
|
207
207
|
>
|
|
@@ -263,7 +263,7 @@ exports[`Storybook Tests react/TextArea Disabled 1`] = `
|
|
|
263
263
|
</div>
|
|
264
264
|
`;
|
|
265
265
|
|
|
266
|
-
exports[`Storybook Tests react/TextArea Invalid 1`] = `
|
|
266
|
+
exports[`Storybook Tests > react/TextArea > Invalid 1`] = `
|
|
267
267
|
<div
|
|
268
268
|
data-dark={false}
|
|
269
269
|
>
|
|
@@ -333,7 +333,7 @@ exports[`Storybook Tests react/TextArea Invalid 1`] = `
|
|
|
333
333
|
</div>
|
|
334
334
|
`;
|
|
335
335
|
|
|
336
|
-
exports[`Storybook Tests react/TextArea Label 1`] = `
|
|
336
|
+
exports[`Storybook Tests > react/TextArea > Label 1`] = `
|
|
337
337
|
<div
|
|
338
338
|
data-dark={false}
|
|
339
339
|
>
|
|
@@ -380,7 +380,7 @@ exports[`Storybook Tests react/TextArea Label 1`] = `
|
|
|
380
380
|
</div>
|
|
381
381
|
`;
|
|
382
382
|
|
|
383
|
-
exports[`Storybook Tests react/TextArea Placeholder 1`] = `
|
|
383
|
+
exports[`Storybook Tests > react/TextArea > Placeholder 1`] = `
|
|
384
384
|
<div
|
|
385
385
|
data-dark={false}
|
|
386
386
|
>
|
|
@@ -442,7 +442,7 @@ exports[`Storybook Tests react/TextArea Placeholder 1`] = `
|
|
|
442
442
|
</div>
|
|
443
443
|
`;
|
|
444
444
|
|
|
445
|
-
exports[`Storybook Tests react/TextArea ReadOnly 1`] = `
|
|
445
|
+
exports[`Storybook Tests > react/TextArea > ReadOnly 1`] = `
|
|
446
446
|
<div
|
|
447
447
|
data-dark={false}
|
|
448
448
|
>
|
|
@@ -505,7 +505,7 @@ exports[`Storybook Tests react/TextArea ReadOnly 1`] = `
|
|
|
505
505
|
</div>
|
|
506
506
|
`;
|
|
507
507
|
|
|
508
|
-
exports[`Storybook Tests react/TextArea Required 1`] = `
|
|
508
|
+
exports[`Storybook Tests > react/TextArea > Required 1`] = `
|
|
509
509
|
<div
|
|
510
510
|
data-dark={false}
|
|
511
511
|
>
|
|
@@ -571,7 +571,7 @@ exports[`Storybook Tests react/TextArea Required 1`] = `
|
|
|
571
571
|
</div>
|
|
572
572
|
`;
|
|
573
573
|
|
|
574
|
-
exports[`Storybook Tests react/TextArea ShowCount 1`] = `
|
|
574
|
+
exports[`Storybook Tests > react/TextArea > ShowCount 1`] = `
|
|
575
575
|
<div
|
|
576
576
|
data-dark={false}
|
|
577
577
|
>
|
|
@@ -638,7 +638,7 @@ exports[`Storybook Tests react/TextArea ShowCount 1`] = `
|
|
|
638
638
|
</div>
|
|
639
639
|
`;
|
|
640
640
|
|
|
641
|
-
exports[`Storybook Tests react/TextArea SubLabel 1`] = `
|
|
641
|
+
exports[`Storybook Tests > react/TextArea > SubLabel 1`] = `
|
|
642
642
|
<div
|
|
643
643
|
data-dark={false}
|
|
644
644
|
>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
1
|
import Clickable from '../Clickable'
|
|
3
2
|
import TextField from '.'
|
|
4
3
|
import { useState } from 'react'
|
|
@@ -92,21 +91,21 @@ export const Affix: StoryObj<typeof TextField> = {
|
|
|
92
91
|
},
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
const PrefixIconWrap = styled.div`
|
|
96
|
-
display: flex;
|
|
97
|
-
align-items: center;
|
|
98
|
-
color: ${({ theme }) => theme.color.text3};
|
|
99
|
-
`
|
|
100
|
-
|
|
101
94
|
export const Prefix: StoryObj<typeof TextField> = {
|
|
102
95
|
render() {
|
|
103
96
|
return (
|
|
104
97
|
<TextField
|
|
105
98
|
label="Label"
|
|
106
99
|
prefix={
|
|
107
|
-
<
|
|
100
|
+
<div
|
|
101
|
+
style={{
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
color: 'var(--charcoal-text3)',
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
108
107
|
<pixiv-icon name="16/Search" />
|
|
109
|
-
</
|
|
108
|
+
</div>
|
|
110
109
|
}
|
|
111
110
|
/>
|
|
112
111
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Storybook Tests react/TextField Affix 1`] = `
|
|
3
|
+
exports[`Storybook Tests > react/TextField > Affix 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
data-dark={false}
|
|
6
6
|
>
|
|
@@ -66,7 +66,7 @@ exports[`Storybook Tests react/TextField Affix 1`] = `
|
|
|
66
66
|
</div>
|
|
67
67
|
`;
|
|
68
68
|
|
|
69
|
-
exports[`Storybook Tests react/TextField AssistiveText 1`] = `
|
|
69
|
+
exports[`Storybook Tests > react/TextField > AssistiveText 1`] = `
|
|
70
70
|
<div
|
|
71
71
|
data-dark={false}
|
|
72
72
|
>
|
|
@@ -130,7 +130,7 @@ exports[`Storybook Tests react/TextField AssistiveText 1`] = `
|
|
|
130
130
|
</div>
|
|
131
131
|
`;
|
|
132
132
|
|
|
133
|
-
exports[`Storybook Tests react/TextField Default 1`] = `
|
|
133
|
+
exports[`Storybook Tests > react/TextField > Default 1`] = `
|
|
134
134
|
<div
|
|
135
135
|
data-dark={false}
|
|
136
136
|
>
|
|
@@ -195,7 +195,7 @@ exports[`Storybook Tests react/TextField Default 1`] = `
|
|
|
195
195
|
</div>
|
|
196
196
|
`;
|
|
197
197
|
|
|
198
|
-
exports[`Storybook Tests react/TextField Disabled 1`] = `
|
|
198
|
+
exports[`Storybook Tests > react/TextField > Disabled 1`] = `
|
|
199
199
|
<div
|
|
200
200
|
data-dark={false}
|
|
201
201
|
>
|
|
@@ -252,7 +252,7 @@ exports[`Storybook Tests react/TextField Disabled 1`] = `
|
|
|
252
252
|
</div>
|
|
253
253
|
`;
|
|
254
254
|
|
|
255
|
-
exports[`Storybook Tests react/TextField Invalid 1`] = `
|
|
255
|
+
exports[`Storybook Tests > react/TextField > Invalid 1`] = `
|
|
256
256
|
<div
|
|
257
257
|
data-dark={false}
|
|
258
258
|
>
|
|
@@ -317,7 +317,7 @@ exports[`Storybook Tests react/TextField Invalid 1`] = `
|
|
|
317
317
|
</div>
|
|
318
318
|
`;
|
|
319
319
|
|
|
320
|
-
exports[`Storybook Tests react/TextField Label 1`] = `
|
|
320
|
+
exports[`Storybook Tests > react/TextField > Label 1`] = `
|
|
321
321
|
<div
|
|
322
322
|
data-dark={false}
|
|
323
323
|
>
|
|
@@ -359,7 +359,7 @@ exports[`Storybook Tests react/TextField Label 1`] = `
|
|
|
359
359
|
</div>
|
|
360
360
|
`;
|
|
361
361
|
|
|
362
|
-
exports[`Storybook Tests react/TextField Number 1`] = `
|
|
362
|
+
exports[`Storybook Tests > react/TextField > Number 1`] = `
|
|
363
363
|
<div
|
|
364
364
|
data-dark={false}
|
|
365
365
|
>
|
|
@@ -417,7 +417,7 @@ exports[`Storybook Tests react/TextField Number 1`] = `
|
|
|
417
417
|
</div>
|
|
418
418
|
`;
|
|
419
419
|
|
|
420
|
-
exports[`Storybook Tests react/TextField Placeholder 1`] = `
|
|
420
|
+
exports[`Storybook Tests > react/TextField > Placeholder 1`] = `
|
|
421
421
|
<div
|
|
422
422
|
data-dark={false}
|
|
423
423
|
>
|
|
@@ -474,19 +474,7 @@ exports[`Storybook Tests react/TextField Placeholder 1`] = `
|
|
|
474
474
|
</div>
|
|
475
475
|
`;
|
|
476
476
|
|
|
477
|
-
exports[`Storybook Tests react/TextField Prefix 1`] = `
|
|
478
|
-
.c0 {
|
|
479
|
-
display: -webkit-box;
|
|
480
|
-
display: -webkit-flex;
|
|
481
|
-
display: -ms-flexbox;
|
|
482
|
-
display: flex;
|
|
483
|
-
-webkit-align-items: center;
|
|
484
|
-
-webkit-box-align: center;
|
|
485
|
-
-ms-flex-align: center;
|
|
486
|
-
align-items: center;
|
|
487
|
-
color: #858585;
|
|
488
|
-
}
|
|
489
|
-
|
|
477
|
+
exports[`Storybook Tests > react/TextField > Prefix 1`] = `
|
|
490
478
|
<div
|
|
491
479
|
data-dark={false}
|
|
492
480
|
>
|
|
@@ -532,7 +520,13 @@ exports[`Storybook Tests react/TextField Prefix 1`] = `
|
|
|
532
520
|
className="charcoal-text-field-prefix"
|
|
533
521
|
>
|
|
534
522
|
<div
|
|
535
|
-
|
|
523
|
+
style={
|
|
524
|
+
Object {
|
|
525
|
+
"alignItems": "center",
|
|
526
|
+
"color": "var(--charcoal-text3)",
|
|
527
|
+
"display": "flex",
|
|
528
|
+
}
|
|
529
|
+
}
|
|
536
530
|
>
|
|
537
531
|
<pixiv-icon
|
|
538
532
|
name="16/Search"
|
|
@@ -553,7 +547,7 @@ exports[`Storybook Tests react/TextField Prefix 1`] = `
|
|
|
553
547
|
</div>
|
|
554
548
|
`;
|
|
555
549
|
|
|
556
|
-
exports[`Storybook Tests react/TextField ReadOnly 1`] = `
|
|
550
|
+
exports[`Storybook Tests > react/TextField > ReadOnly 1`] = `
|
|
557
551
|
<div
|
|
558
552
|
data-dark={false}
|
|
559
553
|
>
|
|
@@ -611,7 +605,7 @@ exports[`Storybook Tests react/TextField ReadOnly 1`] = `
|
|
|
611
605
|
</div>
|
|
612
606
|
`;
|
|
613
607
|
|
|
614
|
-
exports[`Storybook Tests react/TextField RequiredText 1`] = `
|
|
608
|
+
exports[`Storybook Tests > react/TextField > RequiredText 1`] = `
|
|
615
609
|
<div
|
|
616
610
|
data-dark={false}
|
|
617
611
|
>
|
|
@@ -658,7 +652,7 @@ exports[`Storybook Tests react/TextField RequiredText 1`] = `
|
|
|
658
652
|
</div>
|
|
659
653
|
`;
|
|
660
654
|
|
|
661
|
-
exports[`Storybook Tests react/TextField ShowCount 1`] = `
|
|
655
|
+
exports[`Storybook Tests > react/TextField > ShowCount 1`] = `
|
|
662
656
|
<div
|
|
663
657
|
data-dark={false}
|
|
664
658
|
>
|
|
@@ -724,7 +718,7 @@ exports[`Storybook Tests react/TextField ShowCount 1`] = `
|
|
|
724
718
|
</div>
|
|
725
719
|
`;
|
|
726
720
|
|
|
727
|
-
exports[`Storybook Tests react/TextField SubLabel 1`] = `
|
|
721
|
+
exports[`Storybook Tests > react/TextField > SubLabel 1`] = `
|
|
728
722
|
<div
|
|
729
723
|
data-dark={false}
|
|
730
724
|
>
|
|
@@ -26,7 +26,7 @@ export type TextFieldProps = {
|
|
|
26
26
|
requiredText?: string
|
|
27
27
|
disabled?: boolean
|
|
28
28
|
subLabel?: React.ReactNode
|
|
29
|
-
|
|
29
|
+
rdfaPrefix?: string
|
|
30
30
|
|
|
31
31
|
getCount?: (value: string) => number
|
|
32
32
|
} & Omit<React.ComponentPropsWithoutRef<'input'>, 'prefix' | 'onChange'>
|
|
@@ -89,7 +89,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
89
89
|
const showAssistiveText =
|
|
90
90
|
assistiveText != null && assistiveText.length !== 0
|
|
91
91
|
|
|
92
|
-
const classNames = useClassNames('charcoal-text-field-root')
|
|
92
|
+
const classNames = useClassNames('charcoal-text-field-root', className)
|
|
93
93
|
|
|
94
94
|
return (
|
|
95
95
|
<div className={classNames} aria-disabled={disabled}>
|
|
@@ -1,39 +1,15 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { ThemeProvider } from 'styled-components'
|
|
3
|
-
import ComponentAbstraction, { Components } from './ComponentAbstraction'
|
|
4
|
-
import { TokenInjector } from '@charcoal-ui/styled'
|
|
5
|
-
import type { ThemeMap } from '@charcoal-ui/styled/src/TokenInjector'
|
|
6
|
-
import { CharcoalTheme, ThemeColor } from '@charcoal-ui/theme'
|
|
7
|
-
|
|
8
2
|
import { OverlayProvider } from './OverlayProvider'
|
|
9
3
|
import { SSRProvider } from './SSRProvider'
|
|
10
4
|
|
|
11
|
-
export type CharcoalProviderProps =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
injectTokens?: boolean
|
|
15
|
-
components?: Partial<Components>
|
|
16
|
-
background?: keyof ThemeColor
|
|
17
|
-
}>
|
|
5
|
+
export type CharcoalProviderProps = {
|
|
6
|
+
children: React.ReactNode
|
|
7
|
+
}
|
|
18
8
|
|
|
19
|
-
export function CharcoalProvider({
|
|
20
|
-
themeMap,
|
|
21
|
-
defaultTheme = themeMap[':root'],
|
|
22
|
-
components = {},
|
|
23
|
-
injectTokens = true,
|
|
24
|
-
children,
|
|
25
|
-
background,
|
|
26
|
-
}: CharcoalProviderProps) {
|
|
9
|
+
export function CharcoalProvider({ children }: CharcoalProviderProps) {
|
|
27
10
|
return (
|
|
28
11
|
<SSRProvider>
|
|
29
|
-
<
|
|
30
|
-
{injectTokens && (
|
|
31
|
-
<TokenInjector theme={themeMap} background={background} />
|
|
32
|
-
)}
|
|
33
|
-
<ComponentAbstraction components={components}>
|
|
34
|
-
<OverlayProvider>{children}</OverlayProvider>
|
|
35
|
-
</ComponentAbstraction>
|
|
36
|
-
</ThemeProvider>
|
|
12
|
+
<OverlayProvider>{children}</OverlayProvider>
|
|
37
13
|
</SSRProvider>
|
|
38
14
|
)
|
|
39
15
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
default as ComponentAbstraction,
|
|
3
|
-
useComponentAbstraction,
|
|
4
|
-
type LinkProps,
|
|
5
|
-
} from './core/ComponentAbstraction'
|
|
6
1
|
export { SSRProvider } from './core/SSRProvider'
|
|
7
2
|
export { OverlayProvider } from './core/OverlayProvider'
|
|
8
3
|
export {
|
|
@@ -18,12 +13,8 @@ export {
|
|
|
18
13
|
default as IconButton,
|
|
19
14
|
type IconButtonProps,
|
|
20
15
|
} from './components/IconButton'
|
|
21
|
-
export {
|
|
22
|
-
|
|
23
|
-
type RadioProps,
|
|
24
|
-
RadioGroup,
|
|
25
|
-
type RadioGroupProps,
|
|
26
|
-
} from './components/Radio'
|
|
16
|
+
export { default as Radio, type RadioProps } from './components/Radio'
|
|
17
|
+
export { RadioGroup, type RadioGroupProps } from './components/Radio/RadioGroup'
|
|
27
18
|
export { default as Switch, type SwitchProps } from './components/Switch'
|
|
28
19
|
export {
|
|
29
20
|
default as TextField,
|
package/src/type.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CharcoalTheme as Theme } from '@charcoal-ui/theme'
|
|
3
|
-
|
|
4
|
-
declare module 'styled-components' {
|
|
5
|
-
export interface DefaultTheme extends Theme {}
|
|
6
|
-
}
|
|
1
|
+
import 'react'
|
|
7
2
|
|
|
8
3
|
declare module 'react' {
|
|
9
4
|
interface CSSProperties {
|
|
10
|
-
[key: `--${string}`]: string |
|
|
11
|
-
}
|
|
12
|
-
interface Attributes {
|
|
13
|
-
css?: CSSProp<DefaultTheme>
|
|
14
|
-
}
|
|
15
|
-
interface CSSProperties {
|
|
16
|
-
[key: `--${string}`]: string | undefined
|
|
5
|
+
[key: `--${string}`]: string | number
|
|
17
6
|
}
|
|
18
7
|
}
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InternalScrollStory.d.ts","sourceRoot":"","sources":["../../../../src/components/Modal/__stories__/InternalScrollStory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAc,EAAe,UAAU,EAAE,MAAM,IAAI,CAAA;AAQnD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,UAAU,CA0BjD,CAAA"}
|