import type { Meta, StoryObj } from '@storybook/vue3-vite' import VvInputText from '@/components/VvInputText/VvInputText.vue' import { Position } from '@/constants' import { argTypes, defaultArgs } from './InputText.settings' import { checkNullTest, checkUndefinedTest, defaultTest } from './InputText.test' const meta: Meta = { title: 'Components/InputText', component: VvInputText, args: defaultArgs, argTypes, tags: ['autodocs'], } export default meta type Story = StoryObj export const Default: Story = { args: { ...defaultArgs, }, render: args => ({ components: { VvInputText }, setup() { return { args } }, data: () => ({ inputValue: undefined, maskedInputValue: undefined }), template: /* html */ `
Value: {{ inputValue }}
Masked Value: {{ maskedInputValue }}
`, }), play: defaultTest, } export const Null: Story = { args: { ...defaultArgs, }, render: args => ({ components: { VvInputText }, setup() { return { args } }, data: () => ({ inputValue: null, maskedInputValue: undefined }), template: /* html */ `
Value: {{ JSON.stringify(inputValue) }}
`, }), play: checkNullTest, } export const Undefined: Story = { args: { ...defaultArgs, }, render: args => ({ components: { VvInputText }, setup() { return { args } }, data: () => ({ inputValue: undefined, maskedInputValue: undefined }), template: /* html */ `
Value: {{ inputValue === undefined ? 'undefined' : inputValue }}
`, }), play: checkUndefinedTest, } export const Disabled: Story = { ...Default, args: { ...defaultArgs, disabled: true, }, } export const Readonly: Story = { ...Default, args: { ...defaultArgs, readonly: true, }, } export const Valid: Story = { ...Default, args: { ...defaultArgs, valid: true, validLabel: 'The field is valid.', icon: 'check', iconPosition: Position.after, }, } export const Invalid: Story = { ...Default, args: { ...defaultArgs, invalid: true, invalidLabel: 'The field is required.', icon: 'error-2', iconPosition: Position.after, }, } export const Hint: Story = { ...Default, args: { ...defaultArgs, hintLabel: 'Please enter your name.', }, } export const Loading: Story = { ...Default, args: { ...defaultArgs, loading: true, loadingLabel: 'Loading...', }, } export const Floating: Story = { ...Default, args: { ...defaultArgs, floating: true, }, } export const Unit: Story = { ...Default, args: { ...defaultArgs, unit: 'km', autoWidth: true, type: 'number', }, }