import * as React from 'react' import type { StoryObj, StoryFn, Meta } from '@storybook/react-webpack5' import type { InputTimeProps } from '.' import { InputTime } from '.' export default { title: 'pv-form/Components/InputTime', tags: ['autodocs'], component: InputTime, argTypes: { defaultValue: { control: { type: 'text' }, }, value: { control: { type: 'text' }, }, limit: { options: [ 'none', 'number', 'always visible counter', 'no truncation', ], mapping: { none: undefined, number: 20, 'always visible counter': { value: 20, show: 'always', } satisfies InputTimeProps['limit'], 'no truncation': { value: 20, truncate: false, } satisfies InputTimeProps['limit'], }, control: { type: 'radio', }, table: { type: { summary: 'number | LimitConfig', }, }, }, }, parameters: { badges: ['intl'], }, } satisfies Meta const Template: StoryFn = (args) => export const Default = Template.bind({}) Default.args = { label: 'Sample label', placeholder: 'Enter value', } export const WithAsterisk = Template.bind({}) WithAsterisk.args = { label: 'Field is required', withAsterisk: true, } export const WithAsteriskAndIcon = Template.bind({}) WithAsteriskAndIcon.args = { label: { text: 'Field is required with icon', required: true, requiredTooltip: 'This is required', iconTooltip: 'You may want to provide additional information using this mechanism', }, } export const LongLabelWithAsteriskAndIcon: StoryFn = ( args ) => (
) LongLabelWithAsteriskAndIcon.args = { label: { text: 'Field is required with icon that has such a long label that it wraps to three lines', required: true, requiredTooltip: 'This is required', iconTooltip: 'You may want to provide additional information using this mechanism', }, } export const Disabled = Template.bind({}) Disabled.args = { label: 'Sample label', disabled: true, value: '10:10', } export const Error = Template.bind({}) Error.args = { label: 'Sample label', error: 'This is an error message', value: '10:10', } export const Warning = Template.bind({}) Warning.args = { label: 'Sample label', warning: 'This is an warning message', value: '10:10', } export const ReadOnly = Template.bind({}) ReadOnly.args = { label: 'Sample label', readOnly: true, value: '10:10', } /** * Passing an array of strings into the `value` prop activates * a bulk editing mode that will display the count of unique values * and give a means of clearing all values at once with the clear button. * * If all values in the array are identical, then bulk editing mode will * not activate and the input will display that single value. * * Bulk editing is not supported with `defaultValue`. * * Bulk editing is localized internally and requires the component to be * a descendant of an `IntlProvider` from react-intl. See * [our localization page](/docs/localization--docs) for more information. */ export const BulkEditing: StoryObj = { args: { label: 'Sample label', }, argTypes: { value: { control: false, }, }, render: function BulkEditing(args) { const [value, setValue] = React.useState([ '1:00', '2:00', '3:00', ]) return ( { setValue(cbargs[0]) args?.onChange?.(...cbargs) }} /> ) }, }