@capyx/components-library 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -5
- package/dist/addons/CharacterCountInput.d.ts +73 -0
- package/dist/addons/CharacterCountInput.d.ts.map +1 -0
- package/dist/addons/CharacterCountInput.js +130 -0
- package/{lib/addons/index.ts → dist/addons/index.d.ts} +1 -0
- package/dist/addons/index.d.ts.map +1 -0
- package/dist/addons/index.js +1 -0
- package/dist/components/CheckInput.d.ts +49 -0
- package/dist/components/CheckInput.d.ts.map +1 -0
- package/dist/components/CheckInput.js +58 -0
- package/dist/components/DateInput.d.ts +63 -0
- package/dist/components/DateInput.d.ts.map +1 -0
- package/dist/components/DateInput.js +86 -0
- package/dist/components/FileInput.d.ts +102 -0
- package/dist/components/FileInput.d.ts.map +1 -0
- package/dist/components/FileInput.js +164 -0
- package/dist/components/RichTextInput.d.ts +34 -0
- package/dist/components/RichTextInput.d.ts.map +1 -0
- package/dist/components/RichTextInput.js +57 -0
- package/dist/components/SelectInput.d.ts +54 -0
- package/dist/components/SelectInput.d.ts.map +1 -0
- package/dist/components/SelectInput.js +64 -0
- package/dist/components/SwitchInput.d.ts +46 -0
- package/dist/components/SwitchInput.d.ts.map +1 -0
- package/dist/components/SwitchInput.js +53 -0
- package/dist/components/TagsInput.d.ts +35 -0
- package/dist/components/TagsInput.d.ts.map +1 -0
- package/dist/components/TagsInput.js +67 -0
- package/dist/components/TextAreaInput.d.ts +71 -0
- package/dist/components/TextAreaInput.d.ts.map +1 -0
- package/dist/components/TextAreaInput.js +113 -0
- package/dist/components/TextInput.d.ts +89 -0
- package/dist/components/TextInput.d.ts.map +1 -0
- package/dist/components/TextInput.js +177 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/package.json +85 -70
- package/.storybook/main.ts +0 -33
- package/.storybook/preview.ts +0 -36
- package/.storybook/vitest.setup.ts +0 -7
- package/biome.json +0 -37
- package/lib/addons/CharacterCountInput.tsx +0 -204
- package/lib/components/CheckInput.tsx +0 -126
- package/lib/components/DateInput.tsx +0 -179
- package/lib/components/FileInput.tsx +0 -353
- package/lib/components/RichTextInput.tsx +0 -112
- package/lib/components/SelectInput.tsx +0 -144
- package/lib/components/SwitchInput.tsx +0 -116
- package/lib/components/TagsInput.tsx +0 -118
- package/lib/components/TextAreaInput.tsx +0 -211
- package/lib/components/TextInput.tsx +0 -381
- package/stories/CharacterCountInput.stories.tsx +0 -104
- package/stories/CheckInput.stories.tsx +0 -80
- package/stories/DateInput.stories.tsx +0 -137
- package/stories/FileInput.stories.tsx +0 -125
- package/stories/RichTextInput.stories.tsx +0 -77
- package/stories/SelectInput.stories.tsx +0 -131
- package/stories/SwitchInput.stories.tsx +0 -80
- package/stories/TagsInput.stories.tsx +0 -69
- package/stories/TextAreaInput.stories.tsx +0 -117
- package/stories/TextInput.stories.tsx +0 -167
- package/vitest.config.ts +0 -37
- package/vitest.shims.d.ts +0 -1
- /package/{lib/components/index.ts → dist/components/index.js} +0 -0
- /package/{lib/index.ts → dist/index.js} +0 -0
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
4
|
-
import { FileInput } from '../lib/components/FileInput';
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Components/FileInput',
|
|
8
|
-
component: FileInput,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: 'centered',
|
|
11
|
-
},
|
|
12
|
-
tags: ['autodocs'],
|
|
13
|
-
} satisfies Meta<typeof FileInput>;
|
|
14
|
-
|
|
15
|
-
export default meta;
|
|
16
|
-
type Story = StoryObj<typeof meta>;
|
|
17
|
-
|
|
18
|
-
const FormWrapper = ({ children }: { children: React.ReactNode }) => {
|
|
19
|
-
const methods = useForm({
|
|
20
|
-
defaultValues: {
|
|
21
|
-
profilePicture: null,
|
|
22
|
-
documents: null,
|
|
23
|
-
resume: null,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return <FormProvider {...methods}>{children}</FormProvider>;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const Basic: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
name: 'profilePicture',
|
|
33
|
-
label: 'Profile Picture',
|
|
34
|
-
},
|
|
35
|
-
render: (args) => (
|
|
36
|
-
<FormWrapper>
|
|
37
|
-
<FileInput {...args} />
|
|
38
|
-
</FormWrapper>
|
|
39
|
-
),
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const ImageOnly: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
name: 'profilePicture',
|
|
45
|
-
label: 'Profile Picture',
|
|
46
|
-
accept: 'image/*',
|
|
47
|
-
},
|
|
48
|
-
render: (args) => (
|
|
49
|
-
<FormWrapper>
|
|
50
|
-
<FileInput {...args} />
|
|
51
|
-
</FormWrapper>
|
|
52
|
-
),
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const MultipleFiles: Story = {
|
|
56
|
-
args: {
|
|
57
|
-
name: 'documents',
|
|
58
|
-
label: 'Upload Documents',
|
|
59
|
-
multiple: true,
|
|
60
|
-
accept: '.pdf,.doc,.docx',
|
|
61
|
-
},
|
|
62
|
-
render: (args) => (
|
|
63
|
-
<FormWrapper>
|
|
64
|
-
<FileInput {...args} />
|
|
65
|
-
</FormWrapper>
|
|
66
|
-
),
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const WithMaxSize: Story = {
|
|
70
|
-
args: {
|
|
71
|
-
name: 'resume',
|
|
72
|
-
label: 'Upload Resume',
|
|
73
|
-
accept: '.pdf',
|
|
74
|
-
maxSize: 5 * 1024 * 1024, // 5MB
|
|
75
|
-
},
|
|
76
|
-
render: (args) => (
|
|
77
|
-
<FormWrapper>
|
|
78
|
-
<FileInput {...args} />
|
|
79
|
-
</FormWrapper>
|
|
80
|
-
),
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const Required: Story = {
|
|
84
|
-
args: {
|
|
85
|
-
name: 'profilePicture',
|
|
86
|
-
label: 'Profile Picture',
|
|
87
|
-
required: true,
|
|
88
|
-
},
|
|
89
|
-
render: (args) => (
|
|
90
|
-
<FormWrapper>
|
|
91
|
-
<FileInput {...args} />
|
|
92
|
-
</FormWrapper>
|
|
93
|
-
),
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const Disabled: Story = {
|
|
97
|
-
args: {
|
|
98
|
-
name: 'documents',
|
|
99
|
-
label: 'Documents',
|
|
100
|
-
disabled: true,
|
|
101
|
-
},
|
|
102
|
-
render: (args) => (
|
|
103
|
-
<FormWrapper>
|
|
104
|
-
<FileInput {...args} />
|
|
105
|
-
</FormWrapper>
|
|
106
|
-
),
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const CustomValidation: Story = {
|
|
110
|
-
args: {
|
|
111
|
-
name: 'document',
|
|
112
|
-
label: 'Upload PDF Only',
|
|
113
|
-
validateFile: (file: File) => {
|
|
114
|
-
if (!file.name.endsWith('.pdf')) {
|
|
115
|
-
return { valid: false, error: 'Only PDF files are allowed' };
|
|
116
|
-
}
|
|
117
|
-
return { valid: true };
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
render: (args) => (
|
|
121
|
-
<FormWrapper>
|
|
122
|
-
<FileInput {...args} />
|
|
123
|
-
</FormWrapper>
|
|
124
|
-
),
|
|
125
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import { RichTextInput } from '../lib/components/RichTextInput';
|
|
4
|
-
|
|
5
|
-
const meta = {
|
|
6
|
-
title: 'Components/RichTextInput',
|
|
7
|
-
component: RichTextInput,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: 'centered',
|
|
10
|
-
},
|
|
11
|
-
tags: ['autodocs'],
|
|
12
|
-
} satisfies Meta<typeof RichTextInput>;
|
|
13
|
-
|
|
14
|
-
export default meta;
|
|
15
|
-
type Story = StoryObj<typeof meta>;
|
|
16
|
-
|
|
17
|
-
export const Basic: Story = {
|
|
18
|
-
render: () => {
|
|
19
|
-
const [content, setContent] = useState('');
|
|
20
|
-
return (
|
|
21
|
-
<div style={{ width: '600px' }}>
|
|
22
|
-
<RichTextInput value={content} onChange={setContent} />
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const WithMaxLength: Story = {
|
|
29
|
-
render: () => {
|
|
30
|
-
const [content, setContent] = useState('');
|
|
31
|
-
return (
|
|
32
|
-
<div style={{ width: '600px' }}>
|
|
33
|
-
<RichTextInput value={content} onChange={setContent} maxLength={1000} />
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const WithInitialContent: Story = {
|
|
40
|
-
render: () => {
|
|
41
|
-
const [content, setContent] = useState('<p><strong>Bold text</strong> and <em>italic text</em></p>');
|
|
42
|
-
return (
|
|
43
|
-
<div style={{ width: '600px' }}>
|
|
44
|
-
<RichTextInput value={content} onChange={setContent} />
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const ReadOnly: Story = {
|
|
51
|
-
render: () => {
|
|
52
|
-
const content = '<h2>Read-only Content</h2><p>This editor is in read-only mode.</p>';
|
|
53
|
-
return (
|
|
54
|
-
<div style={{ width: '600px' }}>
|
|
55
|
-
<RichTextInput value={content} readonly />
|
|
56
|
-
</div>
|
|
57
|
-
);
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const WithValidationError: Story = {
|
|
62
|
-
render: () => {
|
|
63
|
-
const [content, setContent] = useState('');
|
|
64
|
-
return (
|
|
65
|
-
<div style={{ width: '600px' }}>
|
|
66
|
-
<RichTextInput
|
|
67
|
-
value={content}
|
|
68
|
-
onChange={setContent}
|
|
69
|
-
isInvalid={true}
|
|
70
|
-
/>
|
|
71
|
-
<div style={{ color: 'red', fontSize: '14px', marginTop: '5px' }}>
|
|
72
|
-
This field is required
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
},
|
|
77
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
4
|
-
import { SelectInput } from '../lib/components/SelectInput';
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Components/SelectInput',
|
|
8
|
-
component: SelectInput,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: 'centered',
|
|
11
|
-
},
|
|
12
|
-
tags: ['autodocs'],
|
|
13
|
-
argTypes: {
|
|
14
|
-
controlSize: {
|
|
15
|
-
control: 'select',
|
|
16
|
-
options: ['sm', 'lg', undefined],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
} satisfies Meta<typeof SelectInput>;
|
|
20
|
-
|
|
21
|
-
export default meta;
|
|
22
|
-
type Story = StoryObj<typeof meta>;
|
|
23
|
-
|
|
24
|
-
const FormWrapper = ({ children }: { children: React.ReactNode }) => {
|
|
25
|
-
const methods = useForm({
|
|
26
|
-
defaultValues: {
|
|
27
|
-
country: '',
|
|
28
|
-
role: '',
|
|
29
|
-
priority: '',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return <FormProvider {...methods}>{children}</FormProvider>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const Basic: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
name: 'country',
|
|
39
|
-
label: 'Country',
|
|
40
|
-
options: ['USA', 'Canada', 'UK', 'France', 'Germany', 'Spain', 'Italy'],
|
|
41
|
-
},
|
|
42
|
-
render: (args) => (
|
|
43
|
-
<FormWrapper>
|
|
44
|
-
<SelectInput {...args} />
|
|
45
|
-
</FormWrapper>
|
|
46
|
-
),
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const Required: Story = {
|
|
50
|
-
args: {
|
|
51
|
-
name: 'role',
|
|
52
|
-
label: 'User Role',
|
|
53
|
-
options: ['Admin', 'Editor', 'Viewer', 'Guest'],
|
|
54
|
-
required: true,
|
|
55
|
-
},
|
|
56
|
-
render: (args) => (
|
|
57
|
-
<FormWrapper>
|
|
58
|
-
<SelectInput {...args} />
|
|
59
|
-
</FormWrapper>
|
|
60
|
-
),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const WithHighlightedValues: Story = {
|
|
64
|
-
args: {
|
|
65
|
-
name: 'priority',
|
|
66
|
-
label: 'Priority',
|
|
67
|
-
options: ['Critical', 'High', 'Medium', 'Low'],
|
|
68
|
-
highlightValues: ['Critical', 'High'],
|
|
69
|
-
},
|
|
70
|
-
render: (args) => (
|
|
71
|
-
<FormWrapper>
|
|
72
|
-
<SelectInput {...args} />
|
|
73
|
-
</FormWrapper>
|
|
74
|
-
),
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const CustomPlaceholder: Story = {
|
|
78
|
-
args: {
|
|
79
|
-
name: 'country',
|
|
80
|
-
label: 'Select your country',
|
|
81
|
-
options: ['USA', 'Canada', 'UK', 'France', 'Germany'],
|
|
82
|
-
helpText: 'Choose a country...',
|
|
83
|
-
},
|
|
84
|
-
render: (args) => (
|
|
85
|
-
<FormWrapper>
|
|
86
|
-
<SelectInput {...args} />
|
|
87
|
-
</FormWrapper>
|
|
88
|
-
),
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const Disabled: Story = {
|
|
92
|
-
args: {
|
|
93
|
-
name: 'role',
|
|
94
|
-
label: 'User Role',
|
|
95
|
-
options: ['Admin', 'Editor', 'Viewer'],
|
|
96
|
-
disabled: true,
|
|
97
|
-
},
|
|
98
|
-
render: (args) => (
|
|
99
|
-
<FormWrapper>
|
|
100
|
-
<SelectInput {...args} />
|
|
101
|
-
</FormWrapper>
|
|
102
|
-
),
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const SmallSize: Story = {
|
|
106
|
-
args: {
|
|
107
|
-
name: 'country',
|
|
108
|
-
label: 'Country (Small)',
|
|
109
|
-
options: ['USA', 'Canada', 'UK'],
|
|
110
|
-
controlSize: 'sm',
|
|
111
|
-
},
|
|
112
|
-
render: (args) => (
|
|
113
|
-
<FormWrapper>
|
|
114
|
-
<SelectInput {...args} />
|
|
115
|
-
</FormWrapper>
|
|
116
|
-
),
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const LargeSize: Story = {
|
|
120
|
-
args: {
|
|
121
|
-
name: 'country',
|
|
122
|
-
label: 'Country (Large)',
|
|
123
|
-
options: ['USA', 'Canada', 'UK'],
|
|
124
|
-
controlSize: 'lg',
|
|
125
|
-
},
|
|
126
|
-
render: (args) => (
|
|
127
|
-
<FormWrapper>
|
|
128
|
-
<SelectInput {...args} />
|
|
129
|
-
</FormWrapper>
|
|
130
|
-
),
|
|
131
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
4
|
-
import { SwitchInput } from '../lib/components/SwitchInput';
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Components/SwitchInput',
|
|
8
|
-
component: SwitchInput,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: 'centered',
|
|
11
|
-
},
|
|
12
|
-
tags: ['autodocs'],
|
|
13
|
-
} satisfies Meta<typeof SwitchInput>;
|
|
14
|
-
|
|
15
|
-
export default meta;
|
|
16
|
-
type Story = StoryObj<typeof meta>;
|
|
17
|
-
|
|
18
|
-
const FormWrapper = ({ children }: { children: React.ReactNode }) => {
|
|
19
|
-
const methods = useForm({
|
|
20
|
-
defaultValues: {
|
|
21
|
-
notifications: false,
|
|
22
|
-
darkMode: false,
|
|
23
|
-
autoSave: false,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return <FormProvider {...methods}>{children}</FormProvider>;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const Basic: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
name: 'notifications',
|
|
33
|
-
label: 'Enable notifications',
|
|
34
|
-
},
|
|
35
|
-
render: (args) => (
|
|
36
|
-
<FormWrapper>
|
|
37
|
-
<SwitchInput {...args} />
|
|
38
|
-
</FormWrapper>
|
|
39
|
-
),
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const Required: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
name: 'autoSave',
|
|
45
|
-
label: 'Enable auto-save',
|
|
46
|
-
required: true,
|
|
47
|
-
},
|
|
48
|
-
render: (args) => (
|
|
49
|
-
<FormWrapper>
|
|
50
|
-
<SwitchInput {...args} />
|
|
51
|
-
</FormWrapper>
|
|
52
|
-
),
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const Disabled: Story = {
|
|
56
|
-
args: {
|
|
57
|
-
name: 'darkMode',
|
|
58
|
-
label: 'Dark mode',
|
|
59
|
-
disabled: true,
|
|
60
|
-
},
|
|
61
|
-
render: (args) => (
|
|
62
|
-
<FormWrapper>
|
|
63
|
-
<SwitchInput {...args} />
|
|
64
|
-
</FormWrapper>
|
|
65
|
-
),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const DisabledOn: Story = {
|
|
69
|
-
args: {
|
|
70
|
-
name: 'darkMode',
|
|
71
|
-
label: 'Dark mode (enabled & disabled)',
|
|
72
|
-
disabled: true,
|
|
73
|
-
value: true,
|
|
74
|
-
},
|
|
75
|
-
render: (args) => (
|
|
76
|
-
<FormWrapper>
|
|
77
|
-
<SwitchInput {...args} />
|
|
78
|
-
</FormWrapper>
|
|
79
|
-
),
|
|
80
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import { TagsInput } from '../lib/components/TagsInput';
|
|
4
|
-
|
|
5
|
-
const meta = {
|
|
6
|
-
title: 'Components/TagsInput',
|
|
7
|
-
component: TagsInput,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: 'centered',
|
|
10
|
-
},
|
|
11
|
-
tags: ['autodocs'],
|
|
12
|
-
} satisfies Meta<typeof TagsInput>;
|
|
13
|
-
|
|
14
|
-
export default meta;
|
|
15
|
-
type Story = StoryObj<typeof meta>;
|
|
16
|
-
|
|
17
|
-
export const Basic: Story = {
|
|
18
|
-
render: () => {
|
|
19
|
-
const [tags, setTags] = useState<string[]>([]);
|
|
20
|
-
return (
|
|
21
|
-
<div style={{ width: '400px' }}>
|
|
22
|
-
<TagsInput name="skills" value={tags} onChange={setTags} />
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const WithInitialValues: Story = {
|
|
29
|
-
render: () => {
|
|
30
|
-
const [tags, setTags] = useState<string[]>(['JavaScript', 'TypeScript', 'React']);
|
|
31
|
-
return (
|
|
32
|
-
<div style={{ width: '400px' }}>
|
|
33
|
-
<TagsInput
|
|
34
|
-
name="skills"
|
|
35
|
-
value={tags}
|
|
36
|
-
onChange={setTags}
|
|
37
|
-
placeholder="Add more skills..."
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const CustomPlaceholder: Story = {
|
|
45
|
-
render: () => {
|
|
46
|
-
const [tags, setTags] = useState<string[]>([]);
|
|
47
|
-
return (
|
|
48
|
-
<div style={{ width: '400px' }}>
|
|
49
|
-
<TagsInput
|
|
50
|
-
name="interests"
|
|
51
|
-
value={tags}
|
|
52
|
-
onChange={setTags}
|
|
53
|
-
placeholder="Enter your interests..."
|
|
54
|
-
/>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const Disabled: Story = {
|
|
61
|
-
render: () => {
|
|
62
|
-
const [tags] = useState<string[]>(['Tag 1', 'Tag 2', 'Tag 3']);
|
|
63
|
-
return (
|
|
64
|
-
<div style={{ width: '400px' }}>
|
|
65
|
-
<TagsInput name="skills" value={tags} onChange={() => {}} disabled />
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
},
|
|
69
|
-
};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
4
|
-
import { TextAreaInput } from '../lib/components/TextAreaInput';
|
|
5
|
-
|
|
6
|
-
const meta = {
|
|
7
|
-
title: 'Components/TextAreaInput',
|
|
8
|
-
component: TextAreaInput,
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: 'centered',
|
|
11
|
-
},
|
|
12
|
-
tags: ['autodocs'],
|
|
13
|
-
argTypes: {
|
|
14
|
-
controlSize: {
|
|
15
|
-
control: 'select',
|
|
16
|
-
options: ['sm', 'lg', undefined],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
} satisfies Meta<typeof TextAreaInput>;
|
|
20
|
-
|
|
21
|
-
export default meta;
|
|
22
|
-
type Story = StoryObj<typeof meta>;
|
|
23
|
-
|
|
24
|
-
const FormWrapper = ({ children }: { children: React.ReactNode }) => {
|
|
25
|
-
const methods = useForm({
|
|
26
|
-
defaultValues: {
|
|
27
|
-
bio: '',
|
|
28
|
-
description: '',
|
|
29
|
-
comments: '',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return <FormProvider {...methods}>{children}</FormProvider>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const Basic: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
name: 'bio',
|
|
39
|
-
label: 'Biography',
|
|
40
|
-
placeholder: 'Tell us about yourself...',
|
|
41
|
-
},
|
|
42
|
-
render: (args) => (
|
|
43
|
-
<FormWrapper>
|
|
44
|
-
<TextAreaInput {...args} />
|
|
45
|
-
</FormWrapper>
|
|
46
|
-
),
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const Required: Story = {
|
|
50
|
-
args: {
|
|
51
|
-
name: 'description',
|
|
52
|
-
label: 'Description',
|
|
53
|
-
placeholder: 'Enter description...',
|
|
54
|
-
required: true,
|
|
55
|
-
},
|
|
56
|
-
render: (args) => (
|
|
57
|
-
<FormWrapper>
|
|
58
|
-
<TextAreaInput {...args} />
|
|
59
|
-
</FormWrapper>
|
|
60
|
-
),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const WithMaxLength: Story = {
|
|
64
|
-
args: {
|
|
65
|
-
name: 'bio',
|
|
66
|
-
label: 'Biography',
|
|
67
|
-
maxLength: 500,
|
|
68
|
-
placeholder: 'Max 500 characters',
|
|
69
|
-
},
|
|
70
|
-
render: (args) => (
|
|
71
|
-
<FormWrapper>
|
|
72
|
-
<TextAreaInput {...args} />
|
|
73
|
-
</FormWrapper>
|
|
74
|
-
),
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const WithDebounce: Story = {
|
|
78
|
-
args: {
|
|
79
|
-
name: 'comments',
|
|
80
|
-
label: 'Comments',
|
|
81
|
-
placeholder: 'Type with 500ms debounce...',
|
|
82
|
-
debounceMs: 500,
|
|
83
|
-
},
|
|
84
|
-
render: (args) => (
|
|
85
|
-
<FormWrapper>
|
|
86
|
-
<TextAreaInput {...args} />
|
|
87
|
-
</FormWrapper>
|
|
88
|
-
),
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const Disabled: Story = {
|
|
92
|
-
args: {
|
|
93
|
-
name: 'bio',
|
|
94
|
-
label: 'Biography',
|
|
95
|
-
placeholder: 'This field is disabled',
|
|
96
|
-
disabled: true,
|
|
97
|
-
},
|
|
98
|
-
render: (args) => (
|
|
99
|
-
<FormWrapper>
|
|
100
|
-
<TextAreaInput {...args} />
|
|
101
|
-
</FormWrapper>
|
|
102
|
-
),
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const ReadOnly: Story = {
|
|
106
|
-
args: {
|
|
107
|
-
name: 'bio',
|
|
108
|
-
label: 'Biography',
|
|
109
|
-
value: 'This is a read-only biography text.',
|
|
110
|
-
isReadOnly: true,
|
|
111
|
-
},
|
|
112
|
-
render: (args) => (
|
|
113
|
-
<FormWrapper>
|
|
114
|
-
<TextAreaInput {...args} />
|
|
115
|
-
</FormWrapper>
|
|
116
|
-
),
|
|
117
|
-
};
|