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

chore: decoratorsに対する処理を共通化できるよう、useDecoratorsを定義する #5326

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion packages/smarthr-ui/src/components/Browser/Browser.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC, KeyboardEventHandler, useCallback, useMemo } from 'react'
import { tv } from 'tailwind-variants'

import { DecoratorsType } from '../../types'
import { type DecoratorsType } from '../../hooks/useDecorators'
import { Text } from '../Text'

import { BrowserColumn } from './BrowserColumn'
Expand Down
2 changes: 1 addition & 1 deletion packages/smarthr-ui/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React, { ButtonHTMLAttributes, forwardRef, useMemo } from 'react'
import { tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../hooks/useDecorators'
import { usePortal } from '../../hooks/usePortal'
import { DecoratorsType } from '../../types'
import { Loader } from '../Loader'
import { VisuallyHiddenText } from '../VisuallyHiddenText'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useId } from 'react'
import innerText from 'react-innertext'
import { tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { useOuterClick } from '../../../hooks/useOuterClick'
import { genericsForwardRef } from '../../../libs/util'
import { textColor } from '../../../themes'
Expand All @@ -26,7 +27,6 @@ import { useOptions } from '../useOptions'
import { MultiSelectedItem } from './MultiSelectedItem'
import { hasParentElementByClassName } from './multiComboBoxHelper'

import type { DecoratorsType } from '../../../types'
import type { BaseProps, ComboBoxItem } from '../types'

type Props<T> = BaseProps<T> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import innerText from 'react-innertext'
import { tv } from 'tailwind-variants'

import { useClick } from '../../../hooks/useClick'
import { type DecoratorsType } from '../../../hooks/useDecorators'
import { genericsForwardRef } from '../../../libs/util'
import { textColor } from '../../../themes'
import { UnstyledButton } from '../../Button'
Expand All @@ -25,7 +26,6 @@ import { Input } from '../../Input'
import { useListBox } from '../useListBox'
import { useOptions } from '../useOptions'

import type { DecoratorsType } from '../../../types'
import type { BaseProps, ComboBoxItem } from '../types'

type Props<T> = BaseProps<T> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import React, {
} from 'react'
import { tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../hooks/useDecorators'
import { useEnhancedEffect } from '../../hooks/useEnhancedEffect'
import { usePortal } from '../../hooks/usePortal'
import { spacing } from '../../themes'
Expand All @@ -23,8 +24,6 @@ import { ComboBoxItem, ComboBoxOption } from './types'
import { useActiveOption } from './useActiveOption'
import { usePartialRendering } from './usePartialRendering'

import type { DecoratorsType } from '../../types'

type Props<T> = {
options: Array<ComboBoxOption<T>>
dropdownHelpMessage?: ReactNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import React, { type FC, type PropsWithChildren, type ReactNode, useCallback } from 'react'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { Button } from '../../Button'
import { Cluster, Stack } from '../../Layout'
import { ResponseMessage } from '../../ResponseMessage'
import { DialogBody, type Props as DialogBodyProps } from '../DialogBody'
import { DialogHeader, type Props as DialogHeaderProps } from '../DialogHeader'
import { dialogContentInner } from '../dialogInnerStyle'

import type { DecoratorsType, ResponseMessageType } from '../../../types'
import type { ResponseMessageType } from '../../../types'

export type BaseProps = PropsWithChildren<
DialogHeaderProps &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, {
} from 'react'
import { tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { Button } from '../../Button'
import { Cluster, Stack } from '../../Layout'
import { ResponseMessage } from '../../ResponseMessage'
Expand All @@ -16,7 +17,7 @@ import { DialogBody, Props as DialogBodyProps } from '../DialogBody'
import { DialogHeader, type Props as DialogHeaderProps } from '../DialogHeader'
import { dialogContentInner } from '../dialogInnerStyle'

import type { DecoratorsType, ResponseMessageType } from '../../../types'
import type { ResponseMessageType } from '../../../types'

export type BaseProps = PropsWithChildren<
DialogHeaderProps &
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { type FC, useMemo } from 'react'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { Button } from '../../Button'
import { Cluster } from '../../Layout'
import { Section } from '../../SectioningContent'
import { DialogBody, Props as DialogBodyProps } from '../DialogBody'
import { DialogHeader, Props as DialogHeaderProps } from '../DialogHeader'
import { dialogContentInner } from '../dialogInnerStyle'

import type { DecoratorsType } from '../../../types'

export type BaseProps = DialogHeaderProps &
DialogBodyProps & {
/** ダイアログの説明 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import React, {
import Draggable from 'react-draggable'
import { VariantProps, tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../hooks/useDecorators'
import { useHandleEscape } from '../../hooks/useHandleEscape'
import { Base, BaseElementProps } from '../Base'
import { Button } from '../Button'
Expand All @@ -26,8 +27,6 @@ import { DialogBody, type Props as DialogBodyProps } from './DialogBody'
import { DialogOverlap } from './DialogOverlap'
import { useDialogPortal } from './useDialogPortal'

import type { DecoratorsType } from '../../types'

type Props = PropsWithChildren<{
/**
* ダイアログのヘッダ部分の内容
Expand Down
3 changes: 1 addition & 2 deletions packages/smarthr-ui/src/components/DropZone/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import React, {
} from 'react'
import { tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../hooks/useDecorators'
import { Button } from '../Button'
import { FaFolderOpenIcon } from '../Icon'

import type { DecoratorsType } from '../../types'

const dropZone = tv({
slots: {
wrapper: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { ComponentProps, FC, ReactNode, useMemo } from 'react'
import innerText from 'react-innertext'
import { tv } from 'tailwind-variants'

import { type DecoratorType, type DecoratorsType } from '../../../hooks/useDecorators'
import { Button, BaseProps as ButtonProps } from '../../Button'
import { FaCircleCheckIcon, FaFilterIcon, FaRotateLeftIcon } from '../../Icon'
import { Cluster, Stack } from '../../Layout'
Expand All @@ -13,7 +14,7 @@ import { DropdownCloser } from '../DropdownCloser'
import { DropdownContent } from '../DropdownContent'
import { DropdownTrigger } from '../DropdownTrigger'

import type { DecoratorType, DecoratorsType, ResponseMessageType } from '../../../types'
import type { ResponseMessageType } from '../../../types'

type Props = {
isFiltered?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React, { ComponentPropsWithRef } from 'react'
import { type FC, type MouseEventHandler } from 'react'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { Button } from '../../Button'
import { Fieldset } from '../../Fieldset'
import { FormControl } from '../../FormControl'
Expand All @@ -16,8 +17,6 @@ import { DropdownTrigger } from '../DropdownTrigger'

import { useSortDropdown } from './useSortDropdown'

import type { DecoratorsType } from '../../../types'

type SortFieldType = {
value: string
} & Omit<React.OptionHTMLAttributes<HTMLOptionElement>, 'value'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React, { HTMLAttributes, ReactNode, useMemo } from 'react'
import { VariantProps, tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { Button } from '../../Button'
import { Dropdown, DropdownContent, DropdownTrigger } from '../../Dropdown'
import { Heading } from '../../Heading'
import { FaCaretDownIcon, FaToolboxIcon } from '../../Icon'
import { Cluster, Stack } from '../../Layout'
import { TextLink } from '../../TextLink'

import type { DecoratorsType } from '../../../types'

type Category = {
type?: string
heading: ReactNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import React, { HTMLAttributes, ReactNode, useCallback, useMemo } from 'react'
import { VariantProps, tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { tabbable } from '../../../libs/tabbable'
import { Button } from '../../Button'
import { Dropdown, DropdownContent, DropdownTrigger } from '../../Dropdown'
import { FaCaretDownIcon, FaCheckIcon, FaGlobeIcon, LanguageIcon } from '../../Icon'

import type { DecoratorsType, LocaleMap } from '../../../types'
import type { LocaleMap } from '../../../types'

export type Props = {
narrow?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import React, {
} from 'react'
import { VariantProps, tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../hooks/useDecorators'
import { Base, BaseElementProps } from '../Base'
import { Button } from '../Button'
import { Heading, HeadingTagTypes } from '../Heading'
import { FaCaretDownIcon, FaCaretUpIcon } from '../Icon'
import { Cluster } from '../Layout'
import { ResponseMessage } from '../ResponseMessage'

import type { DecoratorsType } from '../../types'

type AbstractProps = PropsWithChildren<{
/** パネルのタイトル */
title: React.ReactNode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { ComponentProps, forwardRef, useMemo } from 'react'
import { tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { FaMagnifyingGlassIcon } from '../../Icon'
import { InputWithTooltip } from '../InputWithTooltip'

import type { DecoratorsType } from '../../../types'

type Props = Omit<ComponentProps<typeof InputWithTooltip>, 'tooltipMessage' | 'prefix'> & {
/** 入力欄の説明を紐付けるツールチップに表示するメッセージ */
tooltipMessage: React.ReactNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import React, {
} from 'react'
import { VariantProps, tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../hooks/useDecorators'
import { BaseColumn } from '../Base'
import { Button } from '../Button'
import { FaFolderOpenIcon, FaTrashCanIcon } from '../Icon'
import { Stack } from '../Layout'

import type { DecoratorsType } from '../../types'

const inputFile = tv({
slots: {
wrapper: 'smarthr-ui-InputFile shr-block',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { ComponentPropsWithoutRef, useMemo } from 'react'
import { tv } from 'tailwind-variants'

import { type DecoratorType, type DecoratorsType } from '../../hooks/useDecorators'
import { Cluster } from '../Layout'
import { RangeSeparator, Text } from '../Text'

import type { DecoratorType, DecoratorsType } from '../../types'

type Props = {
start: number
end: number
Expand Down
3 changes: 1 addition & 2 deletions packages/smarthr-ui/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import React, {
} from 'react'
import { tv } from 'tailwind-variants'

import { type DecoratorType, type DecoratorsType } from '../../hooks/useDecorators'
import { isIOS, isMobileSafari } from '../../libs/ua'
import { genericsForwardRef } from '../../libs/util'
import { FaSortIcon } from '../Icon'

import type { DecoratorType, DecoratorsType } from '../../types'

type Option<T extends string> = {
value: T
} & Omit<React.OptionHTMLAttributes<HTMLOptionElement>, 'value'>
Expand Down
3 changes: 1 addition & 2 deletions packages/smarthr-ui/src/components/Table/ThCheckbox.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { ComponentProps, forwardRef, useMemo } from 'react'
import { tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../hooks/useDecorators'
import { Balloon } from '../Balloon'
import { CheckBox, Props as CheckBoxProps } from '../CheckBox'

import { Th } from './Th'

import type { DecoratorsType } from '../../types'

type Props = {
decorators?: DecoratorsType<'checkAllInvisibleLabel'> & {
checkColumnName?: (text: string) => string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { useMemo } from 'react'

import { type DecoratorType, type DecoratorsType } from '../../hooks/useDecorators'
import { VisuallyHiddenText } from '../VisuallyHiddenText'

import type { DecoratorType, DecoratorsType } from '../../types'

type Props = {
decorators?: DecoratorsType<'text' | 'visuallyHiddenText'>
}
Expand Down
Loading