Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: eslintのwarningを解消する #5117

Merged
merged 34 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a0cdb7c
fix: react-hooks/exhaustive-deps: Tooltip
AtsushiM Nov 18, 2024
7fbe6c7
fix: react-hooks/exhaustive-deps: Textarea
AtsushiM Nov 18, 2024
0eee887
fix: react/jsx-pascal-case: VRTStepper
AtsushiM Nov 18, 2024
b20318e
chore: Stepper.stories.tsxを修正
AtsushiM Nov 18, 2024
5eb3551
chore: TimePicker.stories.tsxを修正
AtsushiM Nov 18, 2024
5797c6f
chore: MonthPicker.stories.tsxを修正
AtsushiM Nov 18, 2024
b8b4347
fix: react-hooks/exhaustive-deps: Input
AtsushiM Nov 18, 2024
bfe22a4
fix: react-hooks/exhaustive-deps: generateIcon
AtsushiM Nov 18, 2024
9d0566f
chore: VRTFormControl.stories.tsxを修正
AtsushiM Nov 18, 2024
4eb7a70
chore: FormControl.stories.tsxを修正
AtsushiM Nov 18, 2024
a427514
fix: react-hooks/exhaustive-deps: FormControl
AtsushiM Nov 18, 2024
ef0e6d0
chore: VRTFieldset.stories.tsxを修正
AtsushiM Nov 18, 2024
2aeb0ad
chore: Fieldset.stories.tsxを修正
AtsushiM Nov 18, 2024
b7797df
fix: react-hooks/exhaustive-deps: Dropdown
AtsushiM Nov 18, 2024
b134110
fix: react-hooks/exhaustive-deps: ModelessDialog.tsx
AtsushiM Nov 18, 2024
41cc645
chore: ModelessDialog.stories.tsxを修正
AtsushiM Nov 18, 2024
744f3d5
chore: Dialog.test.tsxを修正
AtsushiM Nov 18, 2024
461b6b2
chore: Dialog.stories.tsxを修正
AtsushiM Nov 18, 2024
a0a23d2
fix: react-hooks/exhaustive-deps: DatePicker.tsx
AtsushiM Nov 18, 2024
96de446
chore: DatePicker.test.tsxを修正
AtsushiM Nov 18, 2024
56a64a6
fix: react-hooks/exhaustive-deps: ComboBox/useListBox.tsx
AtsushiM Nov 18, 2024
201a97f
chore: SingleCombobox.test.tsxを修正
AtsushiM Nov 18, 2024
4d5b5e3
chore: SingleCombobox.stories.tsxを修正
AtsushiM Nov 18, 2024
7dbaa96
fix: react-hooks/exhaustive-deps: SingleComboBox.tsx
AtsushiM Nov 18, 2024
ba956b0
chore: MultiCombobox.stories.tsxを修正
AtsushiM Nov 18, 2024
0676f49
fix: react-hooks/exhaustive-deps: MultiComboBox.tsx
AtsushiM Nov 18, 2024
75c0459
chore: MultiComboBox.test.tsxを修正
AtsushiM Nov 18, 2024
1979b0d
Merge branch 'master' of https://github.com/kufu/smarthr-ui into fix-…
AtsushiM Nov 19, 2024
7d59090
chore: pnpm audit --fix
AtsushiM Nov 19, 2024
2770e16
Merge branch 'update-cross-spawn' into fix-eslint
AtsushiM Nov 19, 2024
59bbae3
Merge branch 'master' of https://github.com/kufu/smarthr-ui into fix-…
AtsushiM Nov 19, 2024
693261d
fix: FormDialogのマークアップを調整し、form内にheadingが入りこまないように修正
AtsushiM Nov 20, 2024
c98ac10
fix: SortDropdownをformでマークアップする
AtsushiM Nov 20, 2024
0d9d7bf
chore: storybookを調整
AtsushiM Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/smarthr-ui/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
esm
lib
*.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ describe('SingleComboBox', () => {
const deleteButtons = () => screen.getAllByRole('button', { name: '削除' })

const template = (args: Partial<ComponentProps<typeof MultiComboBox>>) => (
<FormControl title="コンボボックス">
<MultiComboBox
name="default"
items={[
{ label: 'option 1', value: 'value-1' },
{ label: 'option 2', value: 'value-2' },
{ label: 'option 3', value: 'value-3' },
{ label: 'option 4', value: 'value-4' },
{ label: 'option 5', value: 'value-5' },
]}
selectedItems={[{ label: 'option 1', value: 'value-1' }]}
// eslint-disable-next-line smarthr/jsx-start-with-spread-attributes
{...args}
/>
</FormControl>
<form>
<FormControl title="コンボボックス">
<MultiComboBox
name="default"
items={[
{ label: 'option 1', value: 'value-1' },
{ label: 'option 2', value: 'value-2' },
{ label: 'option 3', value: 'value-3' },
{ label: 'option 4', value: 'value-4' },
{ label: 'option 5', value: 'value-5' },
]}
selectedItems={[{ label: 'option 1', value: 'value-1' }]}
// eslint-disable-next-line smarthr/jsx-start-with-spread-attributes
{...args}
/>
</FormControl>
</form>
)

it('アイテムを選択できること', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const ActualMultiComboBox = <T,>(
if (isFocused) return textColor.black
if (disabled) return textColor.disabled
return textColor.grey
}, [disabled, isFocused, textColor.black, textColor.disabled, textColor.grey])
}, [disabled, isFocused])

useOuterClick([outerRef, listBoxRef], blur)

Expand Down Expand Up @@ -335,6 +335,10 @@ const ActualMultiComboBox = <T,>(
isComposing,
isFocused,
resetDeletionButtonFocus,
handleDelete,
inputValue,
selectedItems,
setInputValueIfUncontrolled,
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ const ActualSingleComboBox = <T,>(
if (isFocused) return textColor.black
if (disabled) return textColor.disabled
return textColor.grey
}, [disabled, isFocused, textColor.black, textColor.disabled, textColor.grey])
}, [disabled, isFocused])

useClick(
[outerRef, listBoxRef, clearButtonRef],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ describe('SingleComboBox', () => {
const clearButton = () => screen.getByRole('button', { name: '削除' })

const template = (args: Partial<ComponentProps<typeof SingleComboBox>>) => (
<FormControl title="コンボボックス">
<SingleComboBox
name="default"
items={[
{ label: 'option 1', value: 'value-1' },
{ label: 'option 2', value: 'value-2' },
{ label: 'option 3', value: 'value-3' },
{ label: 'option 4', value: 'value-4' },
{ label: 'option 5', value: 'value-5' },
]}
selectedItem={{ label: 'option 1', value: 'value-1' }}
// eslint-disable-next-line smarthr/jsx-start-with-spread-attributes
{...args}
/>
</FormControl>
<form>
<FormControl title="コンボボックス">
<SingleComboBox
name="default"
items={[
{ label: 'option 1', value: 'value-1' },
{ label: 'option 2', value: 'value-2' },
{ label: 'option 3', value: 'value-3' },
{ label: 'option 4', value: 'value-4' },
{ label: 'option 5', value: 'value-5' },
]}
selectedItem={{ label: 'option 1', value: 'value-1' }}
// eslint-disable-next-line smarthr/jsx-start-with-spread-attributes
{...args}
/>
</FormControl>
</form>
)

it('アイテムを選択できること', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const useListBox = <T,>({
const rect = triggerRef.current.getBoundingClientRect()

setTriggerWidth(rect.width)
}, [triggerRef.current, isExpanded])
}, [isExpanded, triggerRef])

const calculateRect = useCallback(() => {
if (!listBoxRef.current || !triggerRef.current) {
Expand Down Expand Up @@ -278,7 +278,6 @@ export const useListBox = <T,>({
triggerWidth,
loaderWrapper,
noItems,
spacing,
wrapper,
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ describe('DatePicker', () => {

it('カレンダーから日付を選択することができる', async () => {
render(
<FormControl title="DatePicker">
<DatePicker value="2024-09-25" name="date" onChangeDate={vi.fn()} />
</FormControl>,
<form>
<FormControl title="DatePicker">
<DatePicker value="2024-09-25" name="date" onChangeDate={vi.fn()} />
</FormControl>
</form>,
)
const textbox = screen.getByRole('textbox', { name: 'DatePicker' })

Expand All @@ -40,9 +42,11 @@ describe('DatePicker', () => {

it('フォーカスを失うときにテキストボックスの内容がフォーマットされること', async () => {
render(
<FormControl title="DatePicker">
<DatePicker name="date" onChangeDate={vi.fn()} />
</FormControl>,
<form>
<FormControl title="DatePicker">
<DatePicker name="date" onChangeDate={vi.fn()} />
</FormControl>
</form>,
)
const textbox = screen.getByRole('textbox', { name: 'DatePicker' })
await act(() => userEvent.type(textbox, '平成4年5月29日{tab}'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,7 @@ export const DatePicker = forwardRef<HTMLInputElement, Props & InputAttributes>(
if (isInputFocused || isCalendarShown) return textColor.black
if (disabled) return textColor.disabled
return textColor.grey
}, [
isInputFocused,
isCalendarShown,
textColor.black,
textColor.disabled,
textColor.grey,
disabled,
])
}, [isInputFocused, isCalendarShown, disabled])

return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ export const Default: StoryFn = () => {
ariaLabel="Dialog"
data-test="dialog-content"
>
<Section>
<Heading>Dialog</Heading>
<Fieldset title="Dialog" titleType="sectionTitle">
<p>The value of isOpen must be managed by you, but you can customize content freely.</p>
<DatePicker
name="dialog_datepicker"
Expand Down Expand Up @@ -115,7 +114,7 @@ export const Default: StoryFn = () => {
</li>
</RadioListCluster>
</Fieldset>
</Section>
</Fieldset>
{/* eslint-disable-next-line smarthr/best-practice-for-layouts */}
<FooterCluster>
<Button onClick={onClickClose} data-test="dialog-closer">
Expand Down
73 changes: 38 additions & 35 deletions packages/smarthr-ui/src/components/Dialog/Dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import { Button } from '../Button'
import { DatePicker } from '../DatePicker'
import { Fieldset } from '../Fieldset'
import { FormControl } from '../FormControl'
import { Heading } from '../Heading'
import { Input } from '../Input'
import { Cluster } from '../Layout'
import { RadioButton } from '../RadioButton'
import { Section } from '../SectioningContent'

import { Dialog } from './Dialog'

Expand All @@ -21,34 +19,37 @@ describe('Dialog', () => {
<>
<Button onClick={() => setIsOpen(true)}>Dialog</Button>
<Dialog isOpen={isOpen} ariaLabel="Dialog">
<Section>
<Heading>Dialog</Heading>
<p>The value of isOpen must be managed by you, but you can customize content freely.</p>
<DatePicker
name="dialog_datepicker"
value={'2021-01-01'}
formatDate={(_date) => (_date ? _date.toDateString() : '')}
title="dialog_datepicker"
/>
<Fieldset title="Fruits">
<Cluster as="ul">
<li>
<RadioButton name="Apple" checked>
Apple
</RadioButton>
</li>
<li>
<RadioButton name="Orange">Orange</RadioButton>
</li>
<li>
<RadioButton name="Grape">Grape</RadioButton>
</li>
</Cluster>
<form>
<Fieldset title="Dialog" titleType="sectionTitle">
<p>
The value of isOpen must be managed by you, but you can customize content freely.
</p>
<DatePicker
name="dialog_datepicker"
value={'2021-01-01'}
formatDate={(_date) => (_date ? _date.toDateString() : '')}
title="dialog_datepicker"
/>
<Fieldset title="Fruits">
<Cluster as="ul">
<li>
<RadioButton name="Apple" checked>
Apple
</RadioButton>
</li>
<li>
<RadioButton name="Orange">Orange</RadioButton>
</li>
<li>
<RadioButton name="Grape">Grape</RadioButton>
</li>
</Cluster>
</Fieldset>
</Fieldset>
</Section>
<div>
<Button onClick={() => setIsOpen(false)}>close</Button>
</div>
<div>
<Button onClick={() => setIsOpen(false)}>close</Button>
</div>
</form>
</Dialog>
</>
)
Expand Down Expand Up @@ -122,12 +123,14 @@ describe('Dialog', () => {
firstFocusTarget={inputRef}
ariaLabel="特定の要素をフォーカスするダイアログ"
>
<FormControl title="特定の要素をフォーカスするダイアログのInput">
<Input ref={inputRef} name="input_focus_target" />
</FormControl>
<div>
<Button onClick={() => setIsOpen(false)}>close</Button>
</div>
<form>
<FormControl title="特定の要素をフォーカスするダイアログのInput">
<Input ref={inputRef} name="input_focus_target" />
</FormControl>
<div>
<Button onClick={() => setIsOpen(false)}>close</Button>
</div>
</form>
</Dialog>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ export const FormDialogContentInner: FC<FormDialogContentInnerProps> = ({
const { wrapper, actionArea, buttonArea, message } = dialogContentInner()

return (
// eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content
// eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content, smarthr/a11y-prohibit-sectioning-content-in-form
<Section>
<DialogHeader title={title} subtitle={subtitle} titleTag={titleTag} titleId={titleId} />
<form onSubmit={handleSubmitAction}>
{/* eslint-disable-next-line smarthr/best-practice-for-layouts */}
<Stack gap={0} className={wrapper()}>
<DialogHeader title={title} subtitle={subtitle} titleTag={titleTag} titleId={titleId} />
<div className={wrapper()}>
<DialogBody contentPadding={contentPadding} contentBgColor={contentBgColor}>
{children}
</DialogBody>
Expand Down Expand Up @@ -118,7 +117,7 @@ export const FormDialogContentInner: FC<FormDialogContentInnerProps> = ({
</div>
)}
</Stack>
</Stack>
</div>
</form>
</Section>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const ModelessDialog: FC<Props & BaseElementProps & VariantProps<typeof m
className: wrapperStyle,
style,
}
}, [wrapperStyle, left, right, spacing, width])
}, [wrapperStyle, left, right, width])

const wrapperRef = useRef<HTMLDivElement>(null)
const focusTargetRef = useRef<HTMLDivElement>(null)
Expand Down
2 changes: 1 addition & 1 deletion packages/smarthr-ui/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const Dropdown: FC<PropsWithChildren<Props>> = ({ onOpen, onClose, childr
if (!active) return null
return createPortal(props.children)
},
[active, createPortal, isPortalRootMounted],
[active, createPortal],
)

useEffect(() => {
Expand Down
Loading