diff --git a/src/components/NeTextInput.vue b/src/components/NeTextInput.vue new file mode 100644 index 0000000..824e567 --- /dev/null +++ b/src/components/NeTextInput.vue @@ -0,0 +1,210 @@ + + + + + diff --git a/src/main.ts b/src/main.ts index 3b269ae..ca703d0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,6 +31,7 @@ export { default as NePaginator } from '@/components/NePaginator.vue' export { default as NeEmptyState } from '@/components/NeEmptyState.vue' export { default as NeTabs } from '@/components/NeTabs.vue' export { default as NeTextArea } from '@/components/NeTextArea.vue' +export { default as NeTextInput } from '@/components/NeTextInput.vue' // types export export type { NeComboboxOption } from '@/components/NeCombobox.vue' diff --git a/stories/NeTextInput.stories.ts b/stories/NeTextInput.stories.ts new file mode 100644 index 0000000..4c8956d --- /dev/null +++ b/stories/NeTextInput.stories.ts @@ -0,0 +1,132 @@ +// Copyright (C) 2024 Nethesis S.r.l. +// SPDX-License-Identifier: GPL-3.0-or-later + +import type { Meta, StoryObj } from '@storybook/vue3' + +import { NeTextInput, NeTooltip } from '../src/main' + +const meta = { + title: 'Control/NeTextInput', + component: NeTextInput, + // default values + args: { + label: 'Label', + modelValue: '', + placeholder: 'Placeholder', + helperText: '', + invalidMessage: '', + optional: false, + disabled: false, + id: '', + isPassword: false, + showPasswordLabel: 'Show password', + hidePasswordLabel: 'Hide password', + optionalLabel: 'Optional' + } +} satisfies Meta + +export default meta +type Story = StoryObj + +const template = '' + +export const Default: Story = { + render: (args) => ({ + components: { NeTextInput }, + setup() { + return { args } + }, + template: template + }), + args: {} +} + +export const HelperText: Story = { + render: (args) => ({ + components: { NeTextInput }, + setup() { + return { args } + }, + template: template + }), + args: { helperText: 'Helper text' } +} + +export const Invalid: Story = { + render: (args) => ({ + components: { NeTextInput }, + setup() { + return { args } + }, + template: template + }), + args: { + invalidMessage: 'Invalid input value' + } +} + +export const Optional: Story = { + render: (args) => ({ + components: { NeTextInput }, + setup() { + return { args } + }, + template: template + }), + args: { optional: true } +} + +export const Disabled: Story = { + render: (args) => ({ + components: { NeTextInput }, + setup() { + return { args } + }, + template: template + }), + args: { disabled: true } +} + +export const Password: Story = { + render: (args) => ({ + components: { NeTextInput }, + setup() { + return { args } + }, + template: template + }), + args: { isPassword: true, label: 'Enter password', placeholder: '' } +} + +const typeNumberTemplate = '' + +export const TypeNumber: Story = { + render: (args) => ({ + components: { NeTextInput }, + setup() { + return { args } + }, + template: typeNumberTemplate + }), + args: {} +} + +const templateWithTooltip = + '\ + \ + ' + +export const WithTooltip: Story = { + render: (args) => ({ + components: { NeTextInput, NeTooltip }, + setup() { + return { args } + }, + template: templateWithTooltip + }), + args: {} +}