@charcoal-ui/react 5.0.0-beta.4 → 5.0.0-beta.6
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/index.cjs.map +1 -1
- package/dist/index.css +31 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/layered.css +31 -10
- package/dist/layered.css.map +1 -1
- package/package.json +5 -5
- package/src/_lib/createDivComponent.tsx +1 -1
- package/src/_lib/index.ts +1 -1
- package/src/components/Button/index.css +4 -1
- package/src/components/Button/index.tsx +2 -2
- package/src/components/Button/styledButtonTypeTest.d.tsx +2 -2
- package/src/components/Checkbox/CheckboxInput/index.css +3 -1
- package/src/components/Checkbox/CheckboxInput/index.tsx +3 -3
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/Clickable/index.tsx +2 -2
- package/src/components/DropdownSelector/DropdownPopover.tsx +1 -1
- package/src/components/DropdownSelector/ListItem/index.tsx +1 -1
- package/src/components/DropdownSelector/MenuItem/index.tsx +2 -2
- package/src/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.tsx +6 -6
- package/src/components/DropdownSelector/MenuList/index.tsx +1 -1
- package/src/components/DropdownSelector/Popover/index.tsx +1 -1
- package/src/components/DropdownSelector/Popover/usePreventScroll.tsx +1 -1
- package/src/components/DropdownSelector/index.css +3 -1
- package/src/components/DropdownSelector/index.story.tsx +1 -1
- package/src/components/DropdownSelector/index.tsx +3 -3
- package/src/components/DropdownSelector/utils/findPreviewRecursive.tsx +2 -2
- package/src/components/FieldLabel/index.css +3 -1
- package/src/components/FieldLabel/index.tsx +2 -2
- package/src/components/Icon/index.tsx +1 -1
- package/src/components/IconButton/index.css +3 -1
- package/src/components/IconButton/index.tsx +4 -4
- package/src/components/LoadingSpinner/index.tsx +4 -4
- package/src/components/Modal/Dialog/index.tsx +1 -1
- package/src/components/Modal/ModalBackgroundContext.tsx +1 -1
- package/src/components/Modal/index.tsx +4 -4
- package/src/components/Modal/useCustomModalOverlay.tsx +4 -4
- package/src/components/MultiSelect/context.ts +1 -1
- package/src/components/MultiSelect/index.css +3 -1
- package/src/components/MultiSelect/index.test.tsx +6 -6
- package/src/components/MultiSelect/index.tsx +5 -5
- package/src/components/Radio/RadioGroup/index.tsx +4 -4
- package/src/components/Radio/RadioGroupContext.ts +1 -1
- package/src/components/Radio/RadioInput/index.css +6 -2
- package/src/components/Radio/RadioInput/index.tsx +2 -2
- package/src/components/Radio/index.test.tsx +3 -1
- package/src/components/Radio/index.tsx +2 -2
- package/src/components/SegmentedControl/index.tsx +6 -6
- package/src/components/Switch/SwitchInput/index.tsx +1 -1
- package/src/components/Switch/index.tsx +1 -1
- package/src/components/TagItem/index.tsx +3 -3
- package/src/components/TextArea/index.css +3 -1
- package/src/components/TextArea/index.tsx +4 -4
- package/src/components/TextField/AssistiveText/index.tsx +1 -1
- package/src/components/TextField/index.css +3 -1
- package/src/components/TextField/index.tsx +3 -3
- package/src/components/TextField/text-field.test.tsx +5 -5
- package/src/components/TextField/useFocusWithClick.tsx +1 -1
- package/src/core/themeHelper.ts +2 -2
|
@@ -17,11 +17,11 @@ const StyledButtonAsButton = styled(Button<'button'>)``
|
|
|
17
17
|
const StyledButtonA = styled(Button<'a'>)``
|
|
18
18
|
const StyledButtonCustom = styled(Button<typeof Custom>)``
|
|
19
19
|
const StyledButtonCustomAsButton = styled(
|
|
20
|
-
Button<typeof Custom
|
|
20
|
+
Button<typeof Custom>,
|
|
21
21
|
)`` as typeof Button
|
|
22
22
|
const StyledButtonCustomGeneric = styled(Button<typeof CustomGeneric>)``
|
|
23
23
|
const StyledButtonCustomGenericFoo = styled(
|
|
24
|
-
Button<typeof CustomGeneric<'foo'
|
|
24
|
+
Button<typeof CustomGeneric<'foo'>>,
|
|
25
25
|
)``
|
|
26
26
|
|
|
27
27
|
// for type test only
|
|
@@ -17,14 +17,14 @@ export type CheckboxInputProps = CharcoalCheckboxInputProps &
|
|
|
17
17
|
const CheckboxInput = forwardRef<HTMLInputElement, CheckboxInputProps>(
|
|
18
18
|
function CheckboxInput(
|
|
19
19
|
{ onChange, checked, invalid, className, rounded, ...props },
|
|
20
|
-
ref
|
|
20
|
+
ref,
|
|
21
21
|
) {
|
|
22
22
|
const handleChange = useCallback(
|
|
23
23
|
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
24
24
|
const el = e.currentTarget
|
|
25
25
|
onChange?.(el.checked)
|
|
26
26
|
},
|
|
27
|
-
[onChange]
|
|
27
|
+
[onChange],
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
const classNames = useClassNames('charcoal-checkbox-input', className)
|
|
@@ -41,7 +41,7 @@ const CheckboxInput = forwardRef<HTMLInputElement, CheckboxInputProps>(
|
|
|
41
41
|
{...props}
|
|
42
42
|
/>
|
|
43
43
|
)
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
45
|
)
|
|
46
46
|
|
|
47
47
|
export default memo(CheckboxInput)
|
|
@@ -13,7 +13,7 @@ export type ClickableProps<T extends React.ElementType = 'button'> = {
|
|
|
13
13
|
|
|
14
14
|
const Clickable = forwardRef(function Clickable<T extends React.ElementType>(
|
|
15
15
|
{ component, ...props }: ClickableProps<T>,
|
|
16
|
-
ref: React.ForwardedRef<HTMLButtonElement
|
|
16
|
+
ref: React.ForwardedRef<HTMLButtonElement>,
|
|
17
17
|
) {
|
|
18
18
|
const className = useClassNames('charcoal-clickable', props.className)
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ const Clickable = forwardRef(function Clickable<T extends React.ElementType>(
|
|
|
21
21
|
|
|
22
22
|
return <Component {...props} ref={ref} className={className} />
|
|
23
23
|
}) as <T extends React.ElementType = 'button'>(
|
|
24
|
-
p: ClickableProps<T
|
|
24
|
+
p: ClickableProps<T>,
|
|
25
25
|
) => JSX.Element
|
|
26
26
|
export default Clickable
|
|
27
27
|
|
|
@@ -25,7 +25,7 @@ export function DropdownPopover({ children, ...props }: DropdownPopoverProps) {
|
|
|
25
25
|
const windowScrollY = window.scrollY
|
|
26
26
|
const windowScrollX = window.scrollX
|
|
27
27
|
const selectedElement = document.querySelector(
|
|
28
|
-
`[data-key="${props.value.toString()}"]
|
|
28
|
+
`[data-key="${props.value.toString()}"]`,
|
|
29
29
|
) as HTMLElement | undefined
|
|
30
30
|
selectedElement?.focus()
|
|
31
31
|
window.scrollTo(windowScrollX, windowScrollY)
|
|
@@ -15,7 +15,7 @@ export type ListItemProps<T extends React.ElementType = 'li'> = {
|
|
|
15
15
|
|
|
16
16
|
const ListItem = forwardRef(function ListItem<T extends React.ElementType>(
|
|
17
17
|
{ as, className, ...props }: ListItemProps<T>,
|
|
18
|
-
ref: ForwardedRef<HTMLLIElement
|
|
18
|
+
ref: ForwardedRef<HTMLLIElement>,
|
|
19
19
|
) {
|
|
20
20
|
const Component = useMemo(() => as ?? 'li', [as])
|
|
21
21
|
const classNames = useClassNames('charcoal-list-item', className)
|
|
@@ -12,10 +12,10 @@ export type MenuItemProps<T extends React.ElementType = 'li'> = {
|
|
|
12
12
|
* 基本的に`<MenuList>`, `<MenuGroup>`と合わせて使用する
|
|
13
13
|
*/
|
|
14
14
|
const MenuItem = forwardRef(function MenuItem<
|
|
15
|
-
T extends React.ElementType = 'li'
|
|
15
|
+
T extends React.ElementType = 'li',
|
|
16
16
|
>(
|
|
17
17
|
{ className: _, value, disabled, ...props }: MenuItemProps<T>,
|
|
18
|
-
ref: ForwardedRef<HTMLLIElement
|
|
18
|
+
ref: ForwardedRef<HTMLLIElement>,
|
|
19
19
|
) {
|
|
20
20
|
const [handleKeyDown, setContextValue] = useMenuItemHandleKeyDown(value)
|
|
21
21
|
return (
|
|
@@ -10,7 +10,7 @@ import { MenuListContext } from '../../MenuList/MenuListContext'
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
export function useMenuItemHandleKeyDown(
|
|
13
|
-
value?: string
|
|
13
|
+
value?: string,
|
|
14
14
|
): [(e: React.KeyboardEvent<HTMLElement>) => void, () => void] {
|
|
15
15
|
const { setValue, root, propsArray } = useContext(MenuListContext)
|
|
16
16
|
const setContextValue = useCallback(() => {
|
|
@@ -39,11 +39,11 @@ export function useMenuItemHandleKeyDown(
|
|
|
39
39
|
? values[0]
|
|
40
40
|
: values[index + 1]
|
|
41
41
|
: // next or first
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
index - 1 < 0
|
|
43
|
+
? values[values.length - 1]
|
|
44
|
+
: values[index - 1]
|
|
45
45
|
const next = root?.current?.querySelector(
|
|
46
|
-
`[data-key='${focusValue}']
|
|
46
|
+
`[data-key='${focusValue}']`,
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
if (next instanceof HTMLElement) {
|
|
@@ -60,7 +60,7 @@ export function useMenuItemHandleKeyDown(
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
[setContextValue, propsArray, value, root]
|
|
63
|
+
[setContextValue, propsArray, value, root],
|
|
64
64
|
)
|
|
65
65
|
return [handleKeyDown, setContextValue]
|
|
66
66
|
}
|
|
@@ -324,7 +324,7 @@ export const InFormTag: StoryObj<typeof DropdownSelector> = {
|
|
|
324
324
|
onSubmit={(e) => {
|
|
325
325
|
const target = e.target as HTMLFormElement
|
|
326
326
|
const select = target.elements.namedItem(
|
|
327
|
-
'exampleOption'
|
|
327
|
+
'exampleOption',
|
|
328
328
|
) as HTMLSelectElement
|
|
329
329
|
alert(`selected value: Option ${select.value}`)
|
|
330
330
|
e.preventDefault()
|
|
@@ -43,7 +43,7 @@ export default function DropdownSelector({
|
|
|
43
43
|
|
|
44
44
|
const isPlaceholder = useMemo(
|
|
45
45
|
() => props.placeholder !== undefined && preview === undefined,
|
|
46
|
-
[preview, props.placeholder]
|
|
46
|
+
[preview, props.placeholder],
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
const propsArray = getValuesRecursive(props.children)
|
|
@@ -54,7 +54,7 @@ export default function DropdownSelector({
|
|
|
54
54
|
(e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
55
55
|
onChange(e.target.value)
|
|
56
56
|
},
|
|
57
|
-
[onChange]
|
|
57
|
+
[onChange],
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
const labelId = useId()
|
|
@@ -62,7 +62,7 @@ export default function DropdownSelector({
|
|
|
62
62
|
|
|
63
63
|
const classNames = useClassNames(
|
|
64
64
|
'charcoal-dropdown-selector-root',
|
|
65
|
-
props.className
|
|
65
|
+
props.className,
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
return (
|
|
@@ -12,7 +12,7 @@ import * as React from 'react'
|
|
|
12
12
|
*/
|
|
13
13
|
export function findPreviewRecursive(
|
|
14
14
|
children: ReactNode,
|
|
15
|
-
value: string
|
|
15
|
+
value: string,
|
|
16
16
|
): ReactNode | undefined {
|
|
17
17
|
const childArray = React.Children.toArray(children)
|
|
18
18
|
for (let i = 0; i < childArray.length; i++) {
|
|
@@ -28,7 +28,7 @@ export function findPreviewRecursive(
|
|
|
28
28
|
if ('children' in child.props) {
|
|
29
29
|
const children = findPreviewRecursive(
|
|
30
30
|
(child.props as { children: ReactNode }).children,
|
|
31
|
-
value
|
|
31
|
+
value,
|
|
32
32
|
)
|
|
33
33
|
if (children !== undefined) {
|
|
34
34
|
return children
|
|
@@ -24,7 +24,7 @@ const FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(
|
|
|
24
24
|
subLabel,
|
|
25
25
|
...labelProps
|
|
26
26
|
},
|
|
27
|
-
ref
|
|
27
|
+
ref,
|
|
28
28
|
) {
|
|
29
29
|
const classNames = useClassNames('charcoal-field-label-root', className)
|
|
30
30
|
return (
|
|
@@ -42,7 +42,7 @@ const FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(
|
|
|
42
42
|
</div>
|
|
43
43
|
</div>
|
|
44
44
|
)
|
|
45
|
-
}
|
|
45
|
+
},
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
export default FieldLabel
|
|
@@ -25,7 +25,7 @@ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
|
25
25
|
component,
|
|
26
26
|
...rest
|
|
27
27
|
}: IconButtonProps<T>,
|
|
28
|
-
ref: ForwardedRef<HTMLButtonElement
|
|
28
|
+
ref: ForwardedRef<HTMLButtonElement>,
|
|
29
29
|
) {
|
|
30
30
|
validateIconSize(size, icon)
|
|
31
31
|
const Component = useMemo(() => component ?? 'button', [component])
|
|
@@ -43,9 +43,9 @@ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
|
43
43
|
<pixiv-icon name={icon} />
|
|
44
44
|
</Component>
|
|
45
45
|
)
|
|
46
|
-
}
|
|
46
|
+
},
|
|
47
47
|
) as <T extends React.ElementType = 'button'>(
|
|
48
|
-
p: IconButtonProps<T
|
|
48
|
+
p: IconButtonProps<T>,
|
|
49
49
|
) => JSX.Element
|
|
50
50
|
|
|
51
51
|
export default IconButton
|
|
@@ -73,7 +73,7 @@ function validateIconSize(size: Size, icon: keyof KnownIconType) {
|
|
|
73
73
|
if (iconSize !== requiredIconSize) {
|
|
74
74
|
// eslint-disable-next-line no-console
|
|
75
75
|
console.warn(
|
|
76
|
-
`IconButton with size "${size}" expect icon size "${requiredIconSize}, but got "${iconSize}"
|
|
76
|
+
`IconButton with size "${size}" expect icon size "${requiredIconSize}, but got "${iconSize}"`,
|
|
77
77
|
)
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -13,11 +13,11 @@ export type LoadingSpinnerProps = {
|
|
|
13
13
|
const LoadingSpinner = forwardRef<HTMLDivElement, LoadingSpinnerProps>(
|
|
14
14
|
function LoadingSpinnerInner(
|
|
15
15
|
{ size = 48, padding = 16, transparent = false, ...props },
|
|
16
|
-
ref
|
|
16
|
+
ref,
|
|
17
17
|
) {
|
|
18
18
|
const classNames = useClassNames(
|
|
19
19
|
'charcoal-loading-spinner',
|
|
20
|
-
props.className
|
|
20
|
+
props.className,
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
return (
|
|
@@ -34,7 +34,7 @@ const LoadingSpinner = forwardRef<HTMLDivElement, LoadingSpinnerProps>(
|
|
|
34
34
|
<LoadingSpinnerIcon />
|
|
35
35
|
</div>
|
|
36
36
|
)
|
|
37
|
-
}
|
|
37
|
+
},
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
export default memo(LoadingSpinner)
|
|
@@ -71,5 +71,5 @@ export const LoadingSpinnerIcon = forwardRef<LoadingSpinnerIconHandler, Props>(
|
|
|
71
71
|
className="charcoal-loading-spinner-icon"
|
|
72
72
|
/>
|
|
73
73
|
)
|
|
74
|
-
}
|
|
74
|
+
},
|
|
75
75
|
)
|
|
@@ -68,7 +68,7 @@ const DEFAULT_Z_INDEX = 10
|
|
|
68
68
|
*/
|
|
69
69
|
const Modal = forwardRef<HTMLDivElement, ModalProps>(function ModalInner(
|
|
70
70
|
{ children, zIndex = DEFAULT_Z_INDEX, portalContainer, ...props },
|
|
71
|
-
external
|
|
71
|
+
external,
|
|
72
72
|
) {
|
|
73
73
|
const {
|
|
74
74
|
title,
|
|
@@ -93,7 +93,7 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(function ModalInner(
|
|
|
93
93
|
onClose,
|
|
94
94
|
isOpen,
|
|
95
95
|
},
|
|
96
|
-
ref
|
|
96
|
+
ref,
|
|
97
97
|
)
|
|
98
98
|
|
|
99
99
|
const isMobile = (useWindowWidth() ?? Infinity) < 744
|
|
@@ -131,7 +131,7 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(function ModalInner(
|
|
|
131
131
|
onClose()
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
|
-
[onClose]
|
|
134
|
+
[onClose],
|
|
135
135
|
)
|
|
136
136
|
|
|
137
137
|
return transition(
|
|
@@ -186,7 +186,7 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(function ModalInner(
|
|
|
186
186
|
</ModalBackgroundContext.Provider>
|
|
187
187
|
</animated.div>
|
|
188
188
|
</Overlay>
|
|
189
|
-
)
|
|
189
|
+
),
|
|
190
190
|
)
|
|
191
191
|
})
|
|
192
192
|
|
|
@@ -19,7 +19,7 @@ export type CharcoalModalOverlayProps = AriaModalOverlayProps & {
|
|
|
19
19
|
export function useCharcoalModalOverlay(
|
|
20
20
|
props: CharcoalModalOverlayProps,
|
|
21
21
|
state: { isOpen: boolean; onClose: () => void },
|
|
22
|
-
ref: React.RefObject<HTMLElement | null
|
|
22
|
+
ref: React.RefObject<HTMLElement | null>,
|
|
23
23
|
): ModalOverlayAria {
|
|
24
24
|
const { overlayProps, underlayProps } = useOverlay(
|
|
25
25
|
{
|
|
@@ -28,13 +28,13 @@ export function useCharcoalModalOverlay(
|
|
|
28
28
|
onClose: state.onClose,
|
|
29
29
|
shouldCloseOnInteractOutside: () => false,
|
|
30
30
|
},
|
|
31
|
-
ref
|
|
31
|
+
ref,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
usePreventScroll(
|
|
35
35
|
typeof document !== 'undefined' ? document.body : null,
|
|
36
36
|
state.isOpen,
|
|
37
|
-
props.overflowClip
|
|
37
|
+
props.overflowClip,
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
useOverlayFocusContain()
|
|
@@ -57,7 +57,7 @@ function isWindowDefined() {
|
|
|
57
57
|
|
|
58
58
|
export function useWindowWidth() {
|
|
59
59
|
const [width, setWidth] = React.useState(
|
|
60
|
-
isWindowDefined() ? window.innerWidth : null
|
|
60
|
+
isWindowDefined() ? window.innerWidth : null,
|
|
61
61
|
)
|
|
62
62
|
React.useEffect(() => {
|
|
63
63
|
const handleResize = () => {
|
|
@@ -17,7 +17,7 @@ export const MultiSelectGroupContext = createContext<MultiSelectGroupContext>({
|
|
|
17
17
|
invalid: false,
|
|
18
18
|
onChange() {
|
|
19
19
|
throw new Error(
|
|
20
|
-
'Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<MultiSelectGroup />` ?'
|
|
20
|
+
'Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<MultiSelectGroup />` ?',
|
|
21
21
|
)
|
|
22
22
|
},
|
|
23
23
|
})
|
|
@@ -45,7 +45,9 @@
|
|
|
45
45
|
margin: 0;
|
|
46
46
|
background-color: var(--charcoal-text3);
|
|
47
47
|
border-radius: 999999px;
|
|
48
|
-
transition:
|
|
48
|
+
transition:
|
|
49
|
+
0.2s background-color,
|
|
50
|
+
0.2s box-shadow;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
.charcoal-multi-select-input[type='checkbox']:checked {
|
|
@@ -19,8 +19,8 @@ describe('MultiSelect', () => {
|
|
|
19
19
|
// eslint-disable-next-line no-console
|
|
20
20
|
expect(console.error).toHaveBeenCalledWith(
|
|
21
21
|
expect.stringMatching(
|
|
22
|
-
/Perhaps you forgot to wrap with <MultiSelectGroup>/u
|
|
23
|
-
)
|
|
22
|
+
/Perhaps you forgot to wrap with <MultiSelectGroup>/u,
|
|
23
|
+
),
|
|
24
24
|
)
|
|
25
25
|
})
|
|
26
26
|
})
|
|
@@ -41,7 +41,7 @@ describe('MultiSelect', () => {
|
|
|
41
41
|
selected={[]}
|
|
42
42
|
childOnChange={childOnChange}
|
|
43
43
|
parentOnChange={parentOnChange}
|
|
44
|
-
|
|
44
|
+
/>,
|
|
45
45
|
)
|
|
46
46
|
|
|
47
47
|
option1 = screen.getByDisplayValue('option1')
|
|
@@ -92,7 +92,7 @@ describe('MultiSelect', () => {
|
|
|
92
92
|
selected={['option2']}
|
|
93
93
|
childOnChange={childOnChange}
|
|
94
94
|
parentOnChange={parentOnChange}
|
|
95
|
-
|
|
95
|
+
/>,
|
|
96
96
|
)
|
|
97
97
|
|
|
98
98
|
option1 = screen.getByDisplayValue('option1')
|
|
@@ -103,7 +103,7 @@ describe('MultiSelect', () => {
|
|
|
103
103
|
it('only option2 is selected', () => {
|
|
104
104
|
expect(option2.checked).toBeTruthy()
|
|
105
105
|
;[option1, option3].forEach((element) =>
|
|
106
|
-
expect(element.checked).toBeFalsy()
|
|
106
|
+
expect(element.checked).toBeFalsy(),
|
|
107
107
|
)
|
|
108
108
|
})
|
|
109
109
|
|
|
@@ -187,7 +187,7 @@ describe('MultiSelect', () => {
|
|
|
187
187
|
|
|
188
188
|
it('all the options have `aria-invalid="true"`', () => {
|
|
189
189
|
allOptions.forEach((element) =>
|
|
190
|
-
expect(element.getAttribute('aria-invalid')).toBeTruthy()
|
|
190
|
+
expect(element.getAttribute('aria-invalid')).toBeTruthy(),
|
|
191
191
|
)
|
|
192
192
|
})
|
|
193
193
|
})
|
|
@@ -25,7 +25,7 @@ const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>(
|
|
|
25
25
|
className,
|
|
26
26
|
children,
|
|
27
27
|
},
|
|
28
|
-
ref
|
|
28
|
+
ref,
|
|
29
29
|
) {
|
|
30
30
|
const {
|
|
31
31
|
name,
|
|
@@ -39,7 +39,7 @@ const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>(
|
|
|
39
39
|
warning(
|
|
40
40
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
41
41
|
name !== undefined,
|
|
42
|
-
`"name" is not Provided for <MultiSelect>. Perhaps you forgot to wrap with <MultiSelectGroup>
|
|
42
|
+
`"name" is not Provided for <MultiSelect>. Perhaps you forgot to wrap with <MultiSelectGroup> ?`,
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
const isSelected = selected.includes(value)
|
|
@@ -53,7 +53,7 @@ const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>(
|
|
|
53
53
|
if (onChange) onChange({ value, selected: event.currentTarget.checked })
|
|
54
54
|
parentOnChange({ value, selected: event.currentTarget.checked })
|
|
55
55
|
},
|
|
56
|
-
[onChange, parentOnChange, value]
|
|
56
|
+
[onChange, parentOnChange, value],
|
|
57
57
|
)
|
|
58
58
|
const classNames = useClassNames('charcoal-multi-select', className)
|
|
59
59
|
return (
|
|
@@ -83,7 +83,7 @@ const MultiSelect = forwardRef<HTMLInputElement, MultiSelectProps>(
|
|
|
83
83
|
)}
|
|
84
84
|
</label>
|
|
85
85
|
)
|
|
86
|
-
}
|
|
86
|
+
},
|
|
87
87
|
)
|
|
88
88
|
|
|
89
89
|
export default memo(MultiSelect)
|
|
@@ -126,7 +126,7 @@ export function MultiSelectGroup({
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
|
-
[onChange, selected]
|
|
129
|
+
[onChange, selected],
|
|
130
130
|
)
|
|
131
131
|
|
|
132
132
|
return (
|
|
@@ -37,7 +37,7 @@ export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps<string>>(
|
|
|
37
37
|
'aria-orientation': ariaOrientation = 'vertical',
|
|
38
38
|
...props
|
|
39
39
|
},
|
|
40
|
-
ref
|
|
40
|
+
ref,
|
|
41
41
|
) {
|
|
42
42
|
const classNames = useClassNames('charcoal-radio-group', props.className)
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps<string>>(
|
|
|
45
45
|
(next: string) => {
|
|
46
46
|
onChange(next)
|
|
47
47
|
},
|
|
48
|
-
[onChange]
|
|
48
|
+
[onChange],
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
const contextValue = useMemo(
|
|
@@ -57,7 +57,7 @@ export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps<string>>(
|
|
|
57
57
|
invalid: invalid ?? false,
|
|
58
58
|
onChange: handleChange,
|
|
59
59
|
}),
|
|
60
|
-
[disabled, handleChange, invalid, name, readonly, value]
|
|
60
|
+
[disabled, handleChange, invalid, name, readonly, value],
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
return (
|
|
@@ -76,5 +76,5 @@ export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps<string>>(
|
|
|
76
76
|
</div>
|
|
77
77
|
</RadioGroupContext.Provider>
|
|
78
78
|
)
|
|
79
|
-
}
|
|
79
|
+
},
|
|
80
80
|
) as <Value extends string>(props: RadioGroupProps<Value>) => JSX.Element
|
|
@@ -17,7 +17,7 @@ export const RadioGroupContext = React.createContext<RadioGroupContext>({
|
|
|
17
17
|
invalid: false,
|
|
18
18
|
onChange() {
|
|
19
19
|
throw new Error(
|
|
20
|
-
'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?'
|
|
20
|
+
'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?',
|
|
21
21
|
)
|
|
22
22
|
},
|
|
23
23
|
})
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
cursor: pointer;
|
|
12
12
|
border-radius: 999999px;
|
|
13
13
|
background-color: var(--charcoal-surface1);
|
|
14
|
-
transition:
|
|
14
|
+
transition:
|
|
15
|
+
0.2s background-color,
|
|
16
|
+
0.2s box-shadow;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
.charcoal-radio-input:checked {
|
|
@@ -26,7 +28,9 @@
|
|
|
26
28
|
pointer-events: none;
|
|
27
29
|
background-color: var(--charcoal-text5);
|
|
28
30
|
border-radius: 999999px;
|
|
29
|
-
transition:
|
|
31
|
+
transition:
|
|
32
|
+
0.2s background-color,
|
|
33
|
+
0.2s box-shadow;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
.charcoal-radio-input:not(:checked) {
|
|
@@ -20,7 +20,7 @@ const RadioInput = forwardRef<HTMLInputElement, RadioInputProps>(
|
|
|
20
20
|
const el = e.currentTarget
|
|
21
21
|
onChange?.(el.value)
|
|
22
22
|
},
|
|
23
|
-
[onChange]
|
|
23
|
+
[onChange],
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
const classNames = useClassNames('charcoal-radio-input', className)
|
|
@@ -36,7 +36,7 @@ const RadioInput = forwardRef<HTMLInputElement, RadioInputProps>(
|
|
|
36
36
|
{...props}
|
|
37
37
|
/>
|
|
38
38
|
)
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
40
|
)
|
|
41
41
|
|
|
42
42
|
export default memo(RadioInput)
|
|
@@ -20,7 +20,9 @@ describe('Radio', () => {
|
|
|
20
20
|
it('console.error()', () => {
|
|
21
21
|
// eslint-disable-next-line no-console
|
|
22
22
|
expect(console.error).toHaveBeenCalledWith(
|
|
23
|
-
expect.stringMatching(
|
|
23
|
+
expect.stringMatching(
|
|
24
|
+
/Perhaps you forgot to wrap with <RadioGroup>/u,
|
|
25
|
+
),
|
|
24
26
|
)
|
|
25
27
|
})
|
|
26
28
|
})
|