Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/components/Input/VuInput.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Meta, StoryObj } from '@storybook/vue3-vite';
import VuInput from './VuInput.vue';

const meta = {
title: 'Viribus Unitis/VuInput',
component: VuInput,
tags: ['autodocs'],
args: {
message: 'Номер группы',
variant: 'outlined',
},
} satisfies Meta<typeof VuInput>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {};

export const WithPlaceholder: Story = {
args: {
placeholder: "Введите номер группы",
autofocus: true
},
};

export const Validate: Story = {
args: {
rules: [(value: string) => !!value || 'Обязательное поле']
},
};
45 changes: 45 additions & 0 deletions src/components/Input/VuInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { PropType } from 'vue';

type VariantType = "outlined"
Copy link
Contributor

Choose a reason for hiding this comment

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

Этот тип не нужен

type Rule = (value: string) => string | boolean;

defineProps({
message: {
type: String,
default: ""
},
variant: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Вроде просил убрать -- ты только в типе заменил. Убери этот проп вообще, и впиши сразу в компонент значение

type: String as PropType<VariantType>,
default: "outlined"
},
placeholder: {
type: String,
default: ""
},
autofocus: {
type: Boolean,
default: false
},
rules: {
type: Array as PropType<Rule[]>,
default: () => []
}
});

defineEmits(['update:modelValue']);
</script>

<template>
<v-text-field
max-width="348px"
type="input"
:label="message"
color="primary"
:variant="variant"
:placeholder="placeholder"
:autofocus="autofocus"
:rules="rules"
>
</v-text-field>
</template>