diff --git a/packages/smarthr-ui/src/components/DatePicker/DatePicker.tsx b/packages/smarthr-ui/src/components/DatePicker/DatePicker.tsx index c2162d8671..e9e85d1dab 100644 --- a/packages/smarthr-ui/src/components/DatePicker/DatePicker.tsx +++ b/packages/smarthr-ui/src/components/DatePicker/DatePicker.tsx @@ -76,6 +76,7 @@ const datePicker = tv({ }, }) +/** @deprecated DatePicker は非推奨です。Input[type=date] を使ってください。 */ export const DatePicker = forwardRef( ( { diff --git a/packages/smarthr-ui/src/components/DatePicker/stories/DatePicker.stories.tsx b/packages/smarthr-ui/src/components/DatePicker/stories/DatePicker.stories.tsx index 859fbdf7e3..3c642b934d 100644 --- a/packages/smarthr-ui/src/components/DatePicker/stories/DatePicker.stories.tsx +++ b/packages/smarthr-ui/src/components/DatePicker/stories/DatePicker.stories.tsx @@ -8,7 +8,7 @@ import { DatePicker } from '../DatePicker' import type { Meta, StoryObj } from '@storybook/react' export default { - title: 'Forms(フォーム)/DatePicker', + title: 'Forms(フォーム)/DatePicker(非推奨)', component: DatePicker, render: (args) => , args: {}, @@ -20,6 +20,7 @@ export default { parameters: { chromatic: { disableSnapshot: true }, }, + tags: ['skip-test-runner'], } satisfies Meta export const Playground: StoryObj = { diff --git a/packages/smarthr-ui/src/components/DatePicker/stories/VRTDatePicker.stories.tsx b/packages/smarthr-ui/src/components/DatePicker/stories/VRTDatePicker.stories.tsx index 6b4be6c551..b860a25e29 100644 --- a/packages/smarthr-ui/src/components/DatePicker/stories/VRTDatePicker.stories.tsx +++ b/packages/smarthr-ui/src/components/DatePicker/stories/VRTDatePicker.stories.tsx @@ -11,7 +11,7 @@ import { DatePicker } from '../DatePicker' import type { Meta, StoryObj } from '@storybook/react' export default { - title: 'Forms(フォーム)/DatePicker/VRT', + title: 'Forms(フォーム)/DatePicker(非推奨)/VRT', component: DatePicker, render: (args) => { const value = '2024/11/06' @@ -55,7 +55,7 @@ export default { parameters: { chromatic: { disableSnapshot: false }, }, - tags: ['!autodocs'], + tags: ['!autodocs', 'skip-test-runner'], } satisfies Meta export const VRT = {} diff --git a/packages/smarthr-ui/src/components/Input/stories/Input.stories.tsx b/packages/smarthr-ui/src/components/Input/stories/Input.stories.tsx index 27dfd73f91..43d3476e78 100644 --- a/packages/smarthr-ui/src/components/Input/stories/Input.stories.tsx +++ b/packages/smarthr-ui/src/components/Input/stories/Input.stories.tsx @@ -49,10 +49,15 @@ export const Type: StoryObj = { name: 'type', render: (args) => ( - {[undefined, 'text', 'number', 'password'].map((type) => ( - // eslint-disable-next-line smarthr/a11y-input-in-form-control - - ))} + {[undefined, 'text', 'number', 'password', 'date', 'datetime-local', 'time', 'month'].map( + (type) => ( + + ), + )} ), } diff --git a/packages/smarthr-ui/src/components/Picker/DatetimeLocalPicker.tsx b/packages/smarthr-ui/src/components/Picker/DatetimeLocalPicker.tsx index 1f723e5394..4e50272382 100644 --- a/packages/smarthr-ui/src/components/Picker/DatetimeLocalPicker.tsx +++ b/packages/smarthr-ui/src/components/Picker/DatetimeLocalPicker.tsx @@ -8,6 +8,7 @@ type Props = { error?: boolean } +/** @deprecated DatetimeLocalPicker は非推奨です。Input[type="datetime-local"] を使ってください。 */ export const DatetimeLocalPicker = forwardRef>( ({ disabled, error, readOnly, className, ...rest }, ref) => { const { wrapperStyle, innerStyle } = useMemo(() => { diff --git a/packages/smarthr-ui/src/components/Picker/MonthPicker.tsx b/packages/smarthr-ui/src/components/Picker/MonthPicker.tsx index eeca0adb4c..37ffa61b11 100644 --- a/packages/smarthr-ui/src/components/Picker/MonthPicker.tsx +++ b/packages/smarthr-ui/src/components/Picker/MonthPicker.tsx @@ -8,6 +8,7 @@ type Props = { error?: boolean } +/** @deprecated MonthPicker は非推奨です。Input[type="month"] を使ってください。 */ export const MonthPicker = forwardRef>( ({ disabled, error, readOnly, className, ...rest }, ref) => { const { wrapperStyle, innerStyle } = useMemo(() => { diff --git a/packages/smarthr-ui/src/components/Picker/TimePicker.tsx b/packages/smarthr-ui/src/components/Picker/TimePicker.tsx index d48618f288..2562882eb1 100644 --- a/packages/smarthr-ui/src/components/Picker/TimePicker.tsx +++ b/packages/smarthr-ui/src/components/Picker/TimePicker.tsx @@ -8,6 +8,7 @@ type Props = { error?: boolean } +/** @deprecated TimePicker は非推奨です。Input[type="time"] を使ってください。 */ export const TimePicker = forwardRef>( ({ disabled, error, readOnly, className, ...rest }, ref) => { const { wrapperStyle, innerStyle } = useMemo(() => { diff --git a/packages/smarthr-ui/src/components/WarekiPicker/WarekiPicker.tsx b/packages/smarthr-ui/src/components/WarekiPicker/WarekiPicker.tsx new file mode 100644 index 0000000000..a42dbe6fae --- /dev/null +++ b/packages/smarthr-ui/src/components/WarekiPicker/WarekiPicker.tsx @@ -0,0 +1,15 @@ +import React, { ComponentProps } from 'react' + +import { DatePicker } from '../DatePicker' + +type Props = Omit, 'showAlternative'> + +const handleShowWareki = (date: Date | null) => + date?.toLocaleDateString('ja-JP-u-ca-japanese', { + dateStyle: 'long', + }) + +export const WarekiPicker: React.FC = (props) => ( + // eslint-disable-next-line smarthr/a11y-input-in-form-control + +) diff --git a/packages/smarthr-ui/src/components/WarekiPicker/index.ts b/packages/smarthr-ui/src/components/WarekiPicker/index.ts new file mode 100644 index 0000000000..7363cdb45e --- /dev/null +++ b/packages/smarthr-ui/src/components/WarekiPicker/index.ts @@ -0,0 +1 @@ +export { WarekiPicker } from './WarekiPicker' diff --git a/packages/smarthr-ui/src/components/WarekiPicker/stories/VRTWarekiPicker.stories.tsx b/packages/smarthr-ui/src/components/WarekiPicker/stories/VRTWarekiPicker.stories.tsx new file mode 100644 index 0000000000..dda5bd4caa --- /dev/null +++ b/packages/smarthr-ui/src/components/WarekiPicker/stories/VRTWarekiPicker.stories.tsx @@ -0,0 +1,104 @@ +/* eslint-disable smarthr/a11y-input-has-name-attribute */ +/* eslint-disable smarthr/a11y-prohibit-input-placeholder */ +/* eslint-disable smarthr/a11y-input-in-form-control */ +import { userEvent, within } from '@storybook/test' +import dayjs from 'dayjs' +import React from 'react' + +import { Cluster } from '../../Layout' +import { WarekiPicker } from '../WarekiPicker' + +import type { Meta, StoryObj } from '@storybook/react' + +export default { + title: 'Forms(フォーム)/WarekiPicker/VRT', + component: WarekiPicker, + render: (args) => { + const value = '2024/11/06' + const placeholder = '日付を入力してください' + const width = '100%' + const formatDate = (date: Date | null) => dayjs(date).format('YYYY年MM月DD') + + const matrics = [ + { error: false, disabled: false }, + { error: false, disabled: true }, + { error: true, disabled: false }, + { error: true, disabled: true }, + ] + + return ( + + {matrics.map((m) => ( + <> + + + + + + + ))} + + ) + }, + parameters: { + chromatic: { disableSnapshot: false }, + }, + tags: ['!autodocs', 'skip-test-runner'], +} satisfies Meta + +export const VRT = {} + +export const VRTForcedColors: StoryObj = { + ...VRT, + parameters: { + chromatic: { forcedColors: 'active' }, + }, +} + +export const VRTExpanded: StoryObj = { + render: (args) => , + args: { + value: '2024/11/06', + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement) + await userEvent.click(canvas.getByRole('textbox')) + }, +} + +export const VRTExpandedForcedColor: StoryObj = { + ...VRTExpanded, + parameters: { + chromatic: { forcedColors: 'active' }, + }, +} + +export const VRTExpandedFromTo: StoryObj = { + ...VRTExpanded, + args: { + value: '2024/11/06', + from: dayjs('2024/11/03').toDate(), + to: dayjs('2024/11/09').toDate(), + }, +} + +export const VRTExpandedFromToForcedColor: StoryObj = { + ...VRTExpandedFromTo, + parameters: { + chromatic: { forcedColors: 'active' }, + }, +} + +export const VRTExpandedBottom: StoryObj = { + ...VRTExpanded, + render: (args) => ( +
+ +
+ ), +} diff --git a/packages/smarthr-ui/src/components/WarekiPicker/stories/WarekiPicker.stories.tsx b/packages/smarthr-ui/src/components/WarekiPicker/stories/WarekiPicker.stories.tsx new file mode 100644 index 0000000000..fe104cb5e8 --- /dev/null +++ b/packages/smarthr-ui/src/components/WarekiPicker/stories/WarekiPicker.stories.tsx @@ -0,0 +1,100 @@ +/* eslint-disable smarthr/a11y-input-in-form-control */ +import { userEvent, within } from '@storybook/test' +import dayjs from 'dayjs' +import React from 'react' + +import { WarekiPicker } from '../WarekiPicker' + +import type { Meta, StoryObj } from '@storybook/react' + +export default { + title: 'Forms(フォーム)/WarekiPicker', + component: WarekiPicker, + render: (args) => , + args: {}, + argTypes: { + value: { + control: 'text', + }, + }, + parameters: { + chromatic: { disableSnapshot: true }, + }, + tags: ['skip-test-runner'], +} satisfies Meta + +export const Playground: StoryObj = { + args: {}, +} + +export const Value: StoryObj = { + name: 'value', + args: { + value: '2024-11-06', + }, +} + +export const Disabled: StoryObj = { + name: 'disabled', + args: { + disabled: true, + }, +} + +export const PlaceHolder: StoryObj = { + name: 'placeholder', + args: { + placeholder: '日付を選択してください', + }, +} + +export const Error: StoryObj = { + name: 'error', + args: { + error: true, + }, +} + +export const Width: StoryObj = { + name: 'width', + args: { + width: '500px', + }, +} + +export const From: StoryObj = { + name: 'from', + args: { + from: dayjs().subtract(3, 'day').toDate(), + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement) + await userEvent.click(canvas.getByRole('textbox')) + }, +} + +export const To: StoryObj = { + name: 'to', + args: { + to: dayjs().add(3, 'day').toDate(), + }, + play: async ({ canvasElement }) => { + const canvas = within(canvasElement) + await userEvent.click(canvas.getByRole('textbox')) + }, +} + +export const ParseInput: StoryObj = { + name: 'parseInput', + args: { + value: '2024年11月06日', + parseInput: (input) => dayjs(input.replace(/年|月/g, '-').replace(/日/g, '')).toDate(), + }, +} + +export const FormatDate: StoryObj = { + name: 'formatDate', + args: { + formatDate: (date) => dayjs(date).format('YYYY年MM月DD日'), + }, +} diff --git a/packages/smarthr-ui/src/index.ts b/packages/smarthr-ui/src/index.ts index b3cd1d4834..3490654c0f 100644 --- a/packages/smarthr-ui/src/index.ts +++ b/packages/smarthr-ui/src/index.ts @@ -91,6 +91,7 @@ export * from './components/Switch' export * from './components/Stepper' export * from './components/Picker' export * from './components/Browser' +export * from './components/WarekiPicker' // layout components export { Center, Cluster, Reel, Stack, Sidebar } from './components/Layout' diff --git a/packages/smarthr-ui/test-runner-jest.config.js b/packages/smarthr-ui/test-runner-jest.config.js index 02e2c726ab..87ac7b79e0 100644 --- a/packages/smarthr-ui/test-runner-jest.config.js +++ b/packages/smarthr-ui/test-runner-jest.config.js @@ -32,11 +32,6 @@ module.exports = { 'ComboBox.stories.tsx', 'FieldSet.stories.tsx', 'Switch.stories.tsx', - /** - * error: "Form elements must have labels" - * error: "Elements must only use allowed ARIA attributes" - */ - 'DatePicker.stories.tsx', 'FormControl.stories.tsx', // DatePicker を含むために除外 /** * error: "ARIA attributes must conform to valid values"