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!: ResponseMessageをResponseStatusに名称変更 #5399

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
20 changes: 20 additions & 0 deletions packages/smarthr-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,26 @@
},
"main": "lib/index.js",
"module": "esm/index.js",
"exports": {
".": {
"types": "./lib/index.d.ts",
"import": "./esm/index.js",
"require": "./lib/index.js"
},
"./types": {
"types": "./lib/types/index.d.ts",
"import": "./esm/types/index.js",
"require": "./lib/types/index.js"
},
"./lib/*": {
"types": "./lib/*.d.ts",
"require": "./lib/*.js"
},
"./esm/*": {
"types": "./lib/*.d.ts",
"import": "./esm/*.js"
}
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export const AccordionPanel: React.FC<Props & ElementProps> = ({
parentRef,
}}
>
{}
<div {...props} ref={parentRef} role="presentation" className={actualClassName} />
</AccordionPanelContext.Provider>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Stack } from '../../../Layout'
import { Text } from '../../../Text'
import { MultiComboBox } from '../MultiComboBox'

// eslint-disable-next-line storybook/prefer-pascal-case
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: 不要そう?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そもそもstorybookってlintの対象外になってませんか?
対象になっていた時代の名残なような気がします

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

おっ、そうなんですね? 対象外であれば消しで問題ないです!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ですね!ここは消して良さそうだったので消しました

export const defaultItems = {
'option 1': {
label: 'option 1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ export default {

export const Action_Dialog: StoryFn = () => {
const [openedDialog, setOpenedDialog] = useState<'normal' | 'opened' | null>(null)
const [responseMessage, setResponseMessage] =
useState<ComponentProps<typeof ActionDialog>['responseMessage']>()
const [responseStatus, setResponseStatus] =
useState<ComponentProps<typeof ActionDialog>['responseStatus']>()
const openedFocusRef = useRef<HTMLInputElement>(null)
const onClickClose = () => {
setOpenedDialog(null)
setResponseMessage(undefined)
setResponseStatus(undefined)
}

return (
Expand All @@ -65,11 +65,11 @@ export const Action_Dialog: StoryFn = () => {
decorators={{ closeButtonLabel: (txt) => `cancel.(${txt})` }}
onClickAction={(closeDialog) => {
action('executed')()
setResponseMessage(undefined)
setResponseStatus(undefined)
closeDialog()
}}
onClickClose={onClickClose}
responseMessage={responseMessage}
responseStatus={responseStatus}
id="dialog-action"
data-test="dialog-content"
width="40em"
Expand All @@ -80,7 +80,7 @@ export const Action_Dialog: StoryFn = () => {
<Cluster>
<Button
onClick={() =>
setResponseMessage({
setResponseStatus({
status: 'success',
text: '保存しました。',
})
Expand All @@ -90,7 +90,7 @@ export const Action_Dialog: StoryFn = () => {
</Button>
<Button
onClick={() =>
setResponseMessage({
setResponseStatus({
status: 'error',
text: '何らかのエラーが発生しました。',
})
Expand All @@ -100,7 +100,7 @@ export const Action_Dialog: StoryFn = () => {
</Button>
<Button
onClick={() =>
setResponseMessage({
setResponseStatus({
status: 'processing',
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ActionDialog: React.FC<Props & ElementProps> = ({
onClickAction,
onClickClose,
onPressEscape = onClickClose,
responseMessage,
responseStatus,
actionDisabled,
closeDisabled,
subActionArea,
Expand Down Expand Up @@ -69,7 +69,7 @@ export const ActionDialog: React.FC<Props & ElementProps> = ({
onClickClose={handleClickClose}
onClickAction={handleClickAction}
subActionArea={subActionArea}
responseMessage={responseMessage}
responseStatus={responseStatus}
decorators={decorators}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { type FC, type PropsWithChildren, type ReactNode, useCallback, useMemo } from 'react'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { type ResponseMessageType, useResponseMessage } from '../../../hooks/useResponseMessage'
import { type ResponseStatus, useResponseStatus } from '../../../hooks/useResponseStatus'
import { Button } from '../../Button'
import { Cluster, Stack } from '../../Layout'
import { ResponseMessage } from '../../ResponseMessage'
Expand Down Expand Up @@ -37,7 +37,7 @@ export type BaseProps = PropsWithChildren<

export type ActionDialogContentInnerProps = BaseProps & {
onClickClose: () => void
responseMessage?: ResponseMessageType
responseStatus?: ResponseStatus
}

const CLOSE_BUTTON_LABEL = 'キャンセル'
Expand All @@ -55,13 +55,13 @@ export const ActionDialogContentInner: FC<ActionDialogContentInnerProps> = ({
actionTheme,
onClickAction,
onClickClose,
responseMessage,
responseStatus,
actionDisabled,
closeDisabled,
subActionArea,
decorators,
}) => {
const calcedResponseStatus = useResponseMessage(responseMessage)
const calcedResponseStatus = useResponseStatus(responseStatus)

const styles = useMemo(() => {
const { wrapper, actionArea, buttonArea, message } = dialogContentInner()
Expand Down
16 changes: 8 additions & 8 deletions packages/smarthr-ui/src/components/Dialog/Dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ const dummyText = (
export const Form_Dialog: StoryFn = () => {
const [openedDialog, setOpenedDialog] = useState<'normal' | 'opened' | null>(null)
const [value, setValue] = React.useState('Apple')
const [responseMessage, setResponseMessage] =
useState<ComponentProps<typeof ActionDialog>['responseMessage']>()
const [responseStatus, setResponseStatus] =
useState<ComponentProps<typeof ActionDialog>['responseStatus']>()
const openedFocusRef = useRef<HTMLInputElement>(null)
const onClickClose = () => {
setOpenedDialog(null)
setResponseMessage(undefined)
setResponseStatus(undefined)
}
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => setValue(e.currentTarget.name)

Expand All @@ -203,11 +203,11 @@ export const Form_Dialog: StoryFn = () => {
onSubmit={(closeDialog, e) => {
action('executed')()
console.log('event', e)
setResponseMessage(undefined)
setResponseStatus(undefined)
closeDialog()
}}
onClickClose={onClickClose}
responseMessage={responseMessage}
responseStatus={responseStatus}
id="dialog-form"
data-test="form-dialog-content"
width="40em"
Expand Down Expand Up @@ -237,7 +237,7 @@ export const Form_Dialog: StoryFn = () => {
<p>切り替えボタン:</p>
<Button
onClick={() =>
setResponseMessage({
setResponseStatus({
status: 'success',
text: '保存しました。',
})
Expand All @@ -247,7 +247,7 @@ export const Form_Dialog: StoryFn = () => {
</Button>
<Button
onClick={() =>
setResponseMessage({
setResponseStatus({
status: 'error',
text: '何らかのエラーが発生しました。',
})
Expand All @@ -257,7 +257,7 @@ export const Form_Dialog: StoryFn = () => {
</Button>
<Button
onClick={() =>
setResponseMessage({
setResponseStatus({
status: 'processing',
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const FormDialog: React.FC<Props & ElementProps> = ({
onSubmit,
onClickClose,
onPressEscape = onClickClose,
responseMessage,
responseStatus,
actionDisabled,
closeDisabled,
subActionArea,
Expand Down Expand Up @@ -73,7 +73,7 @@ export const FormDialog: React.FC<Props & ElementProps> = ({
subActionArea={subActionArea}
onClickClose={handleClickClose}
onSubmit={handleSubmitAction}
responseMessage={responseMessage}
responseStatus={responseStatus}
decorators={decorators}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, {
import { tv } from 'tailwind-variants'

import { type DecoratorsType } from '../../../hooks/useDecorators'
import { type ResponseMessageType, useResponseMessage } from '../../../hooks/useResponseMessage'
import { type ResponseStatus, useResponseStatus } from '../../../hooks/useResponseStatus'
import { Button } from '../../Button'
import { Cluster, Stack } from '../../Layout'
import { ResponseMessage } from '../../ResponseMessage'
Expand Down Expand Up @@ -43,7 +43,7 @@ export type BaseProps = PropsWithChildren<

export type FormDialogContentInnerProps = BaseProps & {
onClickClose: () => void
responseMessage?: ResponseMessageType
responseStatus?: ResponseStatus
}

const CLOSE_BUTTON_LABEL = 'キャンセル'
Expand All @@ -68,7 +68,7 @@ export const FormDialogContentInner: FC<FormDialogContentInnerProps> = ({
actionTheme,
onSubmit,
onClickClose,
responseMessage,
responseStatus,
actionDisabled,
closeDisabled,
subActionArea,
Expand All @@ -85,7 +85,7 @@ export const FormDialogContentInner: FC<FormDialogContentInnerProps> = ({
[onSubmit, onClickClose],
)

const calculatedResponseStatus = useResponseMessage(responseMessage)
const calculatedResponseStatus = useResponseStatus(responseStatus)

const styles = useMemo(() => {
const { form, wrapper, actionArea, buttonArea, message } = formDialogContentInner()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const radioButtonListWrapper = tv({
export const Default: StoryFn = () => {
const [openedDialog, setOpenedDialog] = useState<'normal' | 'opened' | null>(null)
const [value, setValue] = React.useState('Apple')
const [responseMessage, setResponseMessage] =
useState<ComponentProps<typeof ActionDialog>['responseMessage']>()
const [responseStatus, setResponseStatus] =
useState<ComponentProps<typeof ActionDialog>['responseStatus']>()
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => setValue(e.currentTarget.name)
const stepOrder = [
{ id: 'a', stepNumber: 1 },
Expand Down Expand Up @@ -73,7 +73,7 @@ export const Default: StoryFn = () => {
firstStep={stepOrder[0]}
onSubmit={(closeDialog, e, currentStep) => {
action('onSubmit')()
setResponseMessage(undefined)
setResponseStatus(undefined)
if (currentStep.id === stepOrder[2].id) {
closeDialog()
}
Expand All @@ -89,13 +89,13 @@ export const Default: StoryFn = () => {
onClickClose={() => {
action('closed')()
setOpenedDialog(null)
setResponseMessage(undefined)
setResponseStatus(undefined)
}}
onClickBack={() => {
action('back')()
}}
stepLength={3}
responseMessage={responseMessage}
responseStatus={responseStatus}
id="dialog-form"
data-test="form-dialog-content"
width="40em"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const StepFormDialog: React.FC<Props & ElementProps> = ({
onClickClose,
onClickBack,
onPressEscape = onClickClose,
responseMessage,
responseStatus,
actionDisabled = false,
closeDisabled,
className,
Expand Down Expand Up @@ -100,7 +100,7 @@ export const StepFormDialog: React.FC<Props & ElementProps> = ({
onClickClose={handleClickClose}
onSubmit={handleSubmitAction}
onClickBack={handleBackSteps}
responseMessage={responseMessage}
responseStatus={responseStatus}
decorators={decorators}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, {
} from 'react'

import { type DecoratorsType, useDecorators } from '../../../hooks/useDecorators'
import { type ResponseMessageType, useResponseMessage } from '../../../hooks/useResponseMessage'
import { type ResponseStatus, useResponseStatus } from '../../../hooks/useResponseStatus'
import { Button } from '../../Button'
import { Cluster, Stack } from '../../Layout'
import { ResponseMessage } from '../../ResponseMessage'
Expand Down Expand Up @@ -50,7 +50,7 @@ export type BaseProps = PropsWithChildren<
export type StepFormDialogContentInnerProps = BaseProps & {
firstStep: StepItem
onClickClose: () => void
responseMessage?: ResponseMessageType
responseStatus?: ResponseStatus
stepLength: number
onClickBack?: () => void
}
Expand Down Expand Up @@ -80,7 +80,7 @@ export const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = (
firstStep,
onSubmit,
onClickClose,
responseMessage,
responseStatus,
actionDisabled,
closeDisabled,
decorators,
Expand Down Expand Up @@ -135,7 +135,7 @@ export const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = (
const decorated = useDecorators<DecoratorKeyTypes>(DECORATOR_DEFAULT_TEXTS, decorators)
const actionText = activeStep === stepLength ? submitLabel : decorated.nextButtonLabel

const responseStatus = useResponseMessage(responseMessage)
const calcedResponseStatus = useResponseStatus(responseStatus)

return (
// eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content, smarthr/a11y-prohibit-sectioning-content-in-form
Expand All @@ -155,7 +155,7 @@ export const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = (
{activeStep > 1 && (
<Button
onClick={handleBackAction}
disabled={responseStatus.isProcessing}
disabled={calcedResponseStatus.isProcessing}
className="smarthr-ui-Dialog-backButton"
>
{decorated.backButtonLabel}
Expand All @@ -164,7 +164,7 @@ export const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = (
<Cluster gap={BUTTON_COLUMN_GAP} className={classNames.buttonArea}>
<Button
onClick={handleCloseAction}
disabled={closeDisabled || responseStatus.isProcessing}
disabled={closeDisabled || calcedResponseStatus.isProcessing}
className="smarthr-ui-Dialog-closeButton"
>
{decorated.closeButtonLabel}
Expand All @@ -173,17 +173,17 @@ export const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = (
type="submit"
variant={actionTheme}
disabled={actionDisabled}
loading={responseStatus.isProcessing}
loading={calcedResponseStatus.isProcessing}
className="smarthr-ui-Dialog-actionButton"
>
{actionText}
</Button>
</Cluster>
</Cluster>
{responseStatus.message && (
{calcedResponseStatus.message && (
<div className={classNames.message}>
<ResponseMessage type={responseStatus.status} role="alert">
{responseStatus.message}
<ResponseMessage type={calcedResponseStatus.status} role="alert">
{calcedResponseStatus.message}
</ResponseMessage>
</div>
)}
Expand Down
Loading