@wecodesolutions/shared-react-components-ts 0.2.1 → 0.4.0
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/dist/components/buttons/button/Button.d.ts +10 -0
- package/dist/components/formContainer/FormContainer.d.ts +7 -0
- package/dist/components/inputField/InputField.d.ts +12 -0
- package/dist/components/validationMessage/ValidationMessage.d.ts +7 -0
- package/package.json +1 -1
- package/src/components/buttons/button/Button.tsx +21 -0
- package/src/components/formContainer/FormContainer.tsx +13 -0
- package/src/components/inputField/InputField.tsx +35 -0
- package/src/components/validationMessage/ValidationMessage.tsx +10 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface InputFieldProps {
|
|
3
|
+
label: string;
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const InputField: React.FC<InputFieldProps>;
|
|
12
|
+
export {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ButtonProps {
|
|
4
|
+
label: string;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
type?: 'button' | 'submit' | 'reset';
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Button: React.FC<ButtonProps> = ({
|
|
12
|
+
label,
|
|
13
|
+
onClick,
|
|
14
|
+
type = 'button',
|
|
15
|
+
disabled = false,
|
|
16
|
+
className = '',
|
|
17
|
+
}) => (
|
|
18
|
+
<button type={type} onClick={onClick} disabled={disabled} className={className}>
|
|
19
|
+
{label}
|
|
20
|
+
</button>
|
|
21
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface FormContainerProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
title: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const FormContainer: React.FC<FormContainerProps> = ({ children, title }) => (
|
|
9
|
+
<div className="form-container">
|
|
10
|
+
<h2>{title}</h2>
|
|
11
|
+
{children}
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ValidationMessage } from '../validationMessage/ValidationMessage';
|
|
3
|
+
|
|
4
|
+
interface InputFieldProps {
|
|
5
|
+
label: string;
|
|
6
|
+
type: string;
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const InputField: React.FC<InputFieldProps> = ({
|
|
15
|
+
label,
|
|
16
|
+
type,
|
|
17
|
+
name,
|
|
18
|
+
value,
|
|
19
|
+
onChange,
|
|
20
|
+
placeholder,
|
|
21
|
+
error,
|
|
22
|
+
}) => (
|
|
23
|
+
<div className="input-field">
|
|
24
|
+
<label htmlFor={name}>{label}</label>
|
|
25
|
+
<input
|
|
26
|
+
id={name}
|
|
27
|
+
type={type}
|
|
28
|
+
name={name}
|
|
29
|
+
value={value}
|
|
30
|
+
onChange={onChange}
|
|
31
|
+
placeholder={placeholder}
|
|
32
|
+
/>
|
|
33
|
+
{error && <ValidationMessage message={error} type="error" />}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ValidationMessageProps {
|
|
4
|
+
message: string;
|
|
5
|
+
type: 'error' | 'success' | 'info';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const ValidationMessage: React.FC<ValidationMessageProps> = ({ message, type }) => (
|
|
9
|
+
<span className={`validation-message ${type}`}>{message}</span>
|
|
10
|
+
);
|