react-artasys-ui 0.0.4 → 0.0.6
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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/lib/Button/Button.d.ts +3 -1
- package/lib/Checkbox/Checkbox.d.ts +8 -0
- package/lib/Checkbox/index.d.ts +2 -0
- package/lib/Form/Element/Element.d.ts +2 -1
- package/lib/Spinner/Spinner.d.ts +1 -1
- package/lib/Spinner/index.d.ts +2 -1
- package/lib/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/Button/Button.tsx +6 -3
- package/src/Button/style.module.css +2 -2
- package/src/Checkbox/Checkbox.tsx +23 -0
- package/src/Checkbox/index.tsx +2 -0
- package/src/Checkbox/style.module.css +74 -0
- package/src/Form/Element/Element.tsx +11 -3
- package/src/Form/Element/style.module.css +4 -0
- package/src/Spinner/Spinner.tsx +1 -1
- package/src/Spinner/index.tsx +6 -1
- package/src/index.ts +3 -1
package/lib/Button/Button.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { TSpinner } from "../Spinner";
|
|
2
3
|
interface IButton extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
4
|
wait?: boolean;
|
|
4
5
|
classNameContainer?: string;
|
|
5
6
|
styleContainer?: React.HTMLAttributes<HTMLDivElement>['style'];
|
|
7
|
+
spinnerColor?: TSpinner['color'];
|
|
6
8
|
}
|
|
7
|
-
declare const Button: ({ children, className, classNameContainer, styleContainer, wait, ...props }: IButton) => JSX.Element;
|
|
9
|
+
declare const Button: ({ children, className, classNameContainer, styleContainer, spinnerColor, wait, ...props }: IButton) => JSX.Element;
|
|
8
10
|
export default Button;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IElement } from "../Form/Element";
|
|
3
|
+
interface ICheckbox extends IElement<HTMLInputElement> {
|
|
4
|
+
onChangeText?: (text: string) => void;
|
|
5
|
+
type?: 'checkbox' | 'radio';
|
|
6
|
+
}
|
|
7
|
+
declare const Checkbox: import("react").ForwardRefExoticComponent<ICheckbox & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
+
export default Checkbox;
|
|
@@ -8,6 +8,7 @@ export interface IElement<T = any> extends Omit<AllHTMLAttributes<T>, 'children'
|
|
|
8
8
|
classNameContainer?: string;
|
|
9
9
|
beforeElement?: React.ReactElement;
|
|
10
10
|
afterElement?: React.ReactElement;
|
|
11
|
+
hiddenContainer?: boolean;
|
|
11
12
|
}
|
|
12
|
-
declare const Element: ({ children, beforeElement, afterElement, error, placeholder, disabled, styleContainer, classNameContainer, ...props }: IElement) => JSX.Element;
|
|
13
|
+
declare const Element: ({ children, beforeElement, afterElement, error, placeholder, disabled, styleContainer, classNameContainer, hiddenContainer, ...props }: IElement) => JSX.Element;
|
|
13
14
|
export default Element;
|
package/lib/Spinner/Spinner.d.ts
CHANGED
package/lib/Spinner/index.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ import Spinner from "./Spinner";
|
|
|
6
6
|
import File, { TFileData, TFileMime } from "./File";
|
|
7
7
|
import Button from "./Button";
|
|
8
8
|
import UploadImages, { IUploadImages, TImageData, IImage } from "./UploadImages";
|
|
9
|
+
import Checkbox from "./Checkbox";
|
|
9
10
|
declare const UI: {};
|
|
10
|
-
export { Form, FormElement, Element, useForm, Input, TextArea, Spinner, File, Button, UploadImages };
|
|
11
|
+
export { Form, FormElement, Element, useForm, Input, TextArea, Spinner, File, Button, UploadImages, Checkbox };
|
|
11
12
|
export type { TFileData, TFileMime, IUploadImages, IImage, TImageData, IElement };
|
|
12
13
|
export default UI;
|
package/package.json
CHANGED
package/src/Button/Button.tsx
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import styles from "./style.module.css";
|
|
3
|
-
import Spinner
|
|
3
|
+
import Spinner,{
|
|
4
|
+
TSpinner
|
|
5
|
+
} from "../Spinner";
|
|
4
6
|
|
|
5
7
|
interface IButton extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
8
|
wait?: boolean;
|
|
7
9
|
classNameContainer?: string;
|
|
8
10
|
styleContainer?: React.HTMLAttributes<HTMLDivElement>['style'];
|
|
11
|
+
spinnerColor?: TSpinner['color'];
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
const Button = ({children, className, classNameContainer, styleContainer, wait = false, ...props}: IButton) => {
|
|
14
|
+
const Button = ({children, className, classNameContainer, styleContainer, spinnerColor = 'contrast', wait = false, ...props}: IButton) => {
|
|
12
15
|
|
|
13
16
|
return(<div className={styles['container'] + (classNameContainer ? ' ' + classNameContainer : '')} style={styleContainer}>
|
|
14
17
|
<button {...props} className={className}>{children}</button>
|
|
15
18
|
<div className={styles['wait-indicator'] + (wait ? ' ' + styles['active'] : '')}>
|
|
16
|
-
<Spinner size="small" color=
|
|
19
|
+
<Spinner size="small" color={spinnerColor}/>
|
|
17
20
|
</div>
|
|
18
21
|
</div>)
|
|
19
22
|
};
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
.container {
|
|
4
4
|
position: relative;
|
|
5
5
|
border: 1px solid #5EBED6;
|
|
6
|
+
background-color: #BED4DB;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
.container button {
|
|
9
10
|
display: block;
|
|
10
11
|
width: 100%;
|
|
11
12
|
height: 100%;
|
|
12
|
-
background-color: #BED4DB;
|
|
13
13
|
border: 0;
|
|
14
14
|
padding: 5px 8px;
|
|
15
15
|
font-size: 1.1em;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
height: 100%;
|
|
34
34
|
justify-content: center;
|
|
35
35
|
align-items: center;
|
|
36
|
-
background-color:
|
|
36
|
+
background-color: inherit;
|
|
37
37
|
z-index: -1;
|
|
38
38
|
opacity: 0;
|
|
39
39
|
transition: opacity 0.3s;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import Element,{
|
|
3
|
+
IElement
|
|
4
|
+
} from "../Form/Element";
|
|
5
|
+
import styles from "./style.module.css";
|
|
6
|
+
|
|
7
|
+
interface ICheckbox extends IElement<HTMLInputElement> {
|
|
8
|
+
onChangeText?: (text: string) => void;
|
|
9
|
+
type?: 'checkbox' | 'radio';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Checkbox = forwardRef<HTMLInputElement, ICheckbox>(({type = 'checkbox', hiddenContainer = true, placeholder, ...props}: ICheckbox) => {
|
|
13
|
+
|
|
14
|
+
return(<Element {...props} hiddenContainer={hiddenContainer}>
|
|
15
|
+
{(props) => <div className={styles['container']}>
|
|
16
|
+
<input {...props} type={type}/>
|
|
17
|
+
<span className={styles['indicator']}/>
|
|
18
|
+
<span className={styles['text']}>{placeholder}</span>
|
|
19
|
+
</div>}
|
|
20
|
+
</Element>);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export default Checkbox;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* Checkbox */
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: row;
|
|
6
|
+
justify-content: flex-start;
|
|
7
|
+
align-items: center;
|
|
8
|
+
height: 100%;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
user-select: none;
|
|
11
|
+
gap: 10px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.container > input {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.text {
|
|
19
|
+
color: #1D1D1B;
|
|
20
|
+
font-size: 1.1em;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.indicator {
|
|
24
|
+
display: flex;
|
|
25
|
+
position: relative;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
border: 1px solid #5EBED6;
|
|
29
|
+
background-color: #BED4DB;
|
|
30
|
+
width: 20px;
|
|
31
|
+
height: 20px;
|
|
32
|
+
aspect-ratio: 1/1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.container > input[type="radio"] ~ .indicator {
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.container:hover > .indicator {
|
|
40
|
+
background-color: #5EBED65F;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.indicator::before {
|
|
44
|
+
content: "";
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: 0;
|
|
47
|
+
width: 35%;
|
|
48
|
+
height: 70%;
|
|
49
|
+
border: solid #1D1D1B;
|
|
50
|
+
border-width: 0 2px 2px 0;
|
|
51
|
+
transform: rotate( 45deg);
|
|
52
|
+
scale: 0;
|
|
53
|
+
opacity: 0;
|
|
54
|
+
transition: scale 0.1s, opacity 0.1s;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.container > input[type="radio"] ~ .indicator::before {
|
|
58
|
+
border-width: 0;
|
|
59
|
+
border-radius: inherit;
|
|
60
|
+
top: unset;
|
|
61
|
+
transform: unset;
|
|
62
|
+
width: 70%;
|
|
63
|
+
height: 70%;
|
|
64
|
+
background-color: #1D1D1B;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.container > input:checked ~ .indicator {
|
|
68
|
+
background-color: #5EBED65F;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.container > input:checked ~ .indicator::before {
|
|
72
|
+
scale: 1;
|
|
73
|
+
opacity: 1;
|
|
74
|
+
}
|
|
@@ -15,19 +15,27 @@ export interface IElement<T = any> extends Omit<AllHTMLAttributes<T>, 'children'
|
|
|
15
15
|
classNameContainer?: string;
|
|
16
16
|
beforeElement?: React.ReactElement;
|
|
17
17
|
afterElement?: React.ReactElement;
|
|
18
|
+
hiddenContainer?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
const Element = ({children, beforeElement, afterElement, error, placeholder, disabled, styleContainer, classNameContainer, ...props}: IElement) => {
|
|
21
|
+
const Element = ({children, beforeElement, afterElement, error, placeholder, disabled, styleContainer, classNameContainer, hiddenContainer, ...props}: IElement) => {
|
|
21
22
|
const [currentError, setCurrentError] = useState('');
|
|
22
23
|
|
|
23
24
|
useEffect(() => {
|
|
24
25
|
setCurrentError(error ?? '');
|
|
25
26
|
},[error]);
|
|
26
27
|
|
|
28
|
+
const classes = [];
|
|
29
|
+
|
|
30
|
+
classes.push(styles['container']);
|
|
31
|
+
if (currentError) classes.push(styles['error']);
|
|
32
|
+
if (disabled) classes.push(styles['disabled']);
|
|
33
|
+
if (hiddenContainer) classes.push(styles['hidden']);
|
|
34
|
+
if (classNameContainer) classes.push(classNameContainer);
|
|
35
|
+
|
|
27
36
|
return(<>
|
|
28
37
|
<label
|
|
29
|
-
className={
|
|
30
|
-
styles['container'] + (currentError ? ' ' + styles['error'] : '') + (disabled ? ' ' + styles['disabled'] : '') + (classNameContainer ? ' ' + classNameContainer : '')}
|
|
38
|
+
className={classes.join(' ')}
|
|
31
39
|
style={styleContainer}
|
|
32
40
|
>
|
|
33
41
|
{beforeElement}
|
package/src/Spinner/Spinner.tsx
CHANGED
package/src/Spinner/index.tsx
CHANGED
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import UploadImages,{
|
|
|
18
18
|
TImageData,
|
|
19
19
|
IImage
|
|
20
20
|
} from "./UploadImages";
|
|
21
|
+
import Checkbox from "./Checkbox";
|
|
21
22
|
|
|
22
23
|
const UI = {
|
|
23
24
|
|
|
@@ -33,7 +34,8 @@ export {
|
|
|
33
34
|
Spinner,
|
|
34
35
|
File,
|
|
35
36
|
Button,
|
|
36
|
-
UploadImages
|
|
37
|
+
UploadImages,
|
|
38
|
+
Checkbox
|
|
37
39
|
};
|
|
38
40
|
export type {
|
|
39
41
|
TFileData,
|