react-artasys-ui 0.1.20 → 0.1.22
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 +2 -2
- package/dist/index.js.map +1 -1
- package/lib/Button/Button.d.ts +12 -10
- package/lib/Button/index.d.ts +3 -2
- package/lib/Checkbox/Checkbox.d.ts +7 -7
- package/lib/Components/Arrow/Arrow.d.ts +6 -6
- package/lib/Dropdown/Dropdown.d.ts +18 -16
- package/lib/Dropdown/Item.d.ts +11 -11
- package/lib/Dropdown/Items.d.ts +6 -6
- package/lib/File/File.d.ts +18 -17
- package/lib/FileInput/FileInput.d.ts +13 -0
- package/lib/FileInput/index.d.ts +3 -0
- package/lib/Form/Element/Element.d.ts +16 -15
- package/lib/Form/Form.d.ts +10 -11
- package/lib/Input/Input.d.ts +11 -8
- package/lib/Loading/Loading.d.ts +6 -0
- package/lib/Loading/index.d.ts +3 -0
- package/lib/Progress/Progress.d.ts +7 -7
- package/lib/Provider/Provider.d.ts +7 -0
- package/lib/Provider/ProviderContext.d.ts +1 -0
- package/lib/Provider/index.d.ts +2 -0
- package/lib/Select/Optgroup.d.ts +7 -8
- package/lib/Select/Option.d.ts +8 -8
- package/lib/Select/Select.d.ts +18 -18
- package/lib/Spinner/Spinner.d.ts +8 -7
- package/lib/Spinner/index.d.ts +3 -3
- package/lib/TextArea/TextArea.d.ts +10 -7
- package/lib/UploadImages/Image.d.ts +16 -16
- package/lib/UploadImages/UploadImages.d.ts +9 -9
- package/lib/index.d.ts +19 -16
- package/lib/src/Button/Button.d.ts +12 -0
- package/lib/src/Button/index.d.ts +3 -0
- package/lib/src/Checkbox/Checkbox.d.ts +7 -0
- package/{src/Checkbox/index.tsx → lib/src/Checkbox/index.d.ts} +2 -2
- package/lib/src/Components/Arrow/Arrow.d.ts +6 -0
- package/{src/Components/Arrow/index.tsx → lib/src/Components/Arrow/index.d.ts} +2 -3
- package/lib/src/Dropdown/Dropdown.d.ts +18 -0
- package/lib/src/Dropdown/Item.d.ts +11 -0
- package/lib/src/Dropdown/Items.d.ts +6 -0
- package/lib/src/Dropdown/index.d.ts +9 -0
- package/lib/src/File/File.d.ts +18 -0
- package/lib/src/File/index.d.ts +3 -0
- package/lib/src/FileInput/FileInput.d.ts +14 -0
- package/lib/src/FileInput/index.d.ts +3 -0
- package/lib/src/Form/Element/Element.d.ts +16 -0
- package/lib/src/Form/Element/index.d.ts +3 -0
- package/lib/src/Form/Form.d.ts +10 -0
- package/{src/Form/index.tsx → lib/src/Form/index.d.ts} +5 -8
- package/{src/Form/types.ts → lib/src/Form/types.d.ts} +11 -17
- package/lib/src/Form/useForm.d.ts +17 -0
- package/lib/src/Input/Input.d.ts +11 -0
- package/{src/Input/index.tsx → lib/src/Input/index.d.ts} +2 -3
- package/lib/src/Loading/Loading.d.ts +6 -0
- package/lib/src/Loading/index.d.ts +3 -0
- package/lib/src/Progress/Progress.d.ts +7 -0
- package/{src/Progress/index.tsx → lib/src/Progress/index.d.ts} +2 -3
- package/lib/src/Provider/Provider.d.ts +7 -0
- package/lib/src/Provider/ProviderContext.d.ts +1 -0
- package/lib/src/Provider/index.d.ts +2 -0
- package/lib/src/Select/Optgroup.d.ts +7 -0
- package/lib/src/Select/Option.d.ts +8 -0
- package/lib/src/Select/Select.d.ts +18 -0
- package/lib/src/Select/index.d.ts +11 -0
- package/lib/src/Spinner/Spinner.d.ts +8 -0
- package/lib/src/Spinner/index.d.ts +3 -0
- package/lib/src/TextArea/TextArea.d.ts +9 -0
- package/{src/TextArea/index.tsx → lib/src/TextArea/index.d.ts} +2 -3
- package/lib/src/UploadImages/Image.d.ts +16 -0
- package/lib/src/UploadImages/UploadImages.d.ts +9 -0
- package/lib/src/UploadImages/index.d.ts +5 -0
- package/lib/src/index.d.ts +19 -0
- package/lib/src/ui-types.d.ts +3 -0
- package/lib/stories/Button.stories.d.ts +6 -0
- package/lib/stories/Checkbox.stories.d.ts +6 -0
- package/lib/stories/Dropdown/Dropdown.stories.d.ts +6 -0
- package/lib/stories/Dropdown/Item.stories.d.ts +6 -0
- package/lib/stories/Dropdown/Items.stories.d.ts +6 -0
- package/lib/stories/File.stories.d.ts +6 -0
- package/lib/stories/FileInput.stories.d.ts +9 -0
- package/lib/stories/Form/Element/Element.stories.d.ts +6 -0
- package/lib/stories/Form/Form.stories.d.ts +6 -0
- package/lib/stories/Input.stories.d.ts +6 -0
- package/lib/stories/Loading.stories.d.ts +6 -0
- package/lib/stories/Progress.stories.d.ts +6 -0
- package/lib/stories/Select/Select.stories.d.ts +6 -0
- package/lib/stories/Spinner.stories.d.ts +6 -0
- package/lib/stories/TextArea.stories.d.ts +6 -0
- package/lib/ui-types.d.ts +3 -0
- package/package.json +26 -5
- package/__tests__/static.test.js +0 -0
- package/babel.config.json +0 -3
- package/src/Button/Button.tsx +0 -29
- package/src/Button/index.tsx +0 -3
- package/src/Button/style.module.css +0 -45
- package/src/Checkbox/Checkbox.tsx +0 -22
- package/src/Checkbox/style.module.css +0 -74
- package/src/Components/Arrow/Arrow.tsx +0 -18
- package/src/Components/Arrow/style.module.css +0 -40
- package/src/Dropdown/Dropdown.tsx +0 -113
- package/src/Dropdown/Item.tsx +0 -42
- package/src/Dropdown/Items.tsx +0 -38
- package/src/Dropdown/index.tsx +0 -28
- package/src/Dropdown/style.module.css +0 -89
- package/src/File/File.tsx +0 -85
- package/src/File/index.tsx +0 -9
- package/src/Form/Element/Element.tsx +0 -54
- package/src/Form/Element/index.tsx +0 -7
- package/src/Form/Element/style.module.css +0 -119
- package/src/Form/Form.tsx +0 -40
- package/src/Form/style.module.css +0 -30
- package/src/Form/useForm.tsx +0 -76
- package/src/Input/Input.tsx +0 -49
- package/src/Input/style.module.css +0 -16
- package/src/Progress/Progress.tsx +0 -28
- package/src/Progress/style.module.css +0 -72
- package/src/Select/Optgroup.tsx +0 -19
- package/src/Select/Option.tsx +0 -47
- package/src/Select/Select.tsx +0 -143
- package/src/Select/index.tsx +0 -33
- package/src/Select/style.module.css +0 -117
- package/src/Spinner/Spinner.tsx +0 -21
- package/src/Spinner/index.tsx +0 -8
- package/src/Spinner/style.module.css +0 -65
- package/src/TextArea/TextArea.tsx +0 -57
- package/src/UploadImages/Image.tsx +0 -86
- package/src/UploadImages/UploadImages.tsx +0 -57
- package/src/UploadImages/index.tsx +0 -13
- package/src/UploadImages/style.module.css +0 -108
- package/src/index.ts +0 -62
- package/tsconfig.json +0 -118
- package/types.d.ts +0 -1
- package/webpack.config.js +0 -59
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/* Select */
|
|
2
|
-
|
|
3
|
-
.container-element {
|
|
4
|
-
z-index: 1;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.container {
|
|
8
|
-
position: relative;
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
min-height: 25px;
|
|
13
|
-
outline: none;
|
|
14
|
-
cursor: pointer;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.select {
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: row;
|
|
20
|
-
align-items: center;
|
|
21
|
-
min-height: 45px;
|
|
22
|
-
box-sizing: border-box;
|
|
23
|
-
padding: 10px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.container-element:has(input[type="hidden"]:disabled) .arrow::after {
|
|
27
|
-
border-top-color: #CCCCCC;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.container.opened > .select > .arrow::after {
|
|
31
|
-
rotate: 180deg;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.select-list {
|
|
35
|
-
position: absolute;
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-direction: column;
|
|
38
|
-
min-width: 100%;
|
|
39
|
-
max-height: 40vh;
|
|
40
|
-
max-height: 40dvh;
|
|
41
|
-
top: calc(100% - 1px);
|
|
42
|
-
right: -1px;
|
|
43
|
-
margin: 0;
|
|
44
|
-
padding: 0;
|
|
45
|
-
list-style-type: none;
|
|
46
|
-
background-color: #FFFFFF;
|
|
47
|
-
box-shadow: 0px 4px 5px 0px rgb(0 0 0 / 10%);
|
|
48
|
-
border: 1px solid #CCCCCC;
|
|
49
|
-
overflow: auto;
|
|
50
|
-
opacity: 0;
|
|
51
|
-
visibility: hidden;
|
|
52
|
-
transform: translateY(-10%);
|
|
53
|
-
transition: transform 0.3s ease-in-out, opacity 0.3s, visibility 0.3s;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.container.left > .select-list {
|
|
57
|
-
left: -1px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.container.right > .select-list {
|
|
61
|
-
right: -1px;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.container.hidden > .select-list {
|
|
65
|
-
display: none;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.container.opened > .select-list {
|
|
69
|
-
opacity: 1;
|
|
70
|
-
transform: translateY(0);
|
|
71
|
-
visibility: visible;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.optgpoup {
|
|
75
|
-
padding: 0;
|
|
76
|
-
margin: 0;
|
|
77
|
-
list-style-type: none;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.optgpoup > li.label {
|
|
81
|
-
padding: 10px;
|
|
82
|
-
font-weight: bold;
|
|
83
|
-
cursor: default;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.optgpoup > li.option {
|
|
87
|
-
padding-left: 5% !important;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.title, .select-list li {
|
|
91
|
-
font-size: 20px;
|
|
92
|
-
color: #1D1D1B;
|
|
93
|
-
user-select: none;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.title {
|
|
97
|
-
flex: 1;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.select-list li.option {
|
|
101
|
-
display: flex;
|
|
102
|
-
justify-content: flex-start;
|
|
103
|
-
align-items: center;
|
|
104
|
-
min-height: 25px;
|
|
105
|
-
padding: 5px;
|
|
106
|
-
cursor: pointer;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.select-list li.option:hover, .select-list li.option.active {
|
|
110
|
-
background-color: #BED4DB;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.select-list li.option.disabled {
|
|
114
|
-
background-color: #EFEFEF;
|
|
115
|
-
color: #CCCCCC;
|
|
116
|
-
cursor: default;
|
|
117
|
-
}
|
package/src/Spinner/Spinner.tsx
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AllHTMLAttributes } from "react";
|
|
2
|
-
import styles from "./style.module.css";
|
|
3
|
-
|
|
4
|
-
export type TSpinner = Omit<AllHTMLAttributes<HTMLDivElement>, 'size' | 'color'> & {
|
|
5
|
-
size?: 'small' | 'middle' | 'large';
|
|
6
|
-
color?: 'contrast' | 'orange';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const Spinner = ({size, color, ...props}: TSpinner) => {
|
|
10
|
-
|
|
11
|
-
const classes = ['ui-spinner'];
|
|
12
|
-
|
|
13
|
-
classes.push(styles['spinner']);
|
|
14
|
-
if (size) classes.push(styles[size], 'ui-spinner-' + size);
|
|
15
|
-
if (color) classes.push(styles[color], 'ui-spinner-' + color);
|
|
16
|
-
if (props.className) classes.push(props.className);
|
|
17
|
-
|
|
18
|
-
return(<div {...props} className={classes.join(' ')}></div>);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default Spinner;
|
package/src/Spinner/index.tsx
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/* Spinner */
|
|
2
|
-
|
|
3
|
-
.spinner {
|
|
4
|
-
--color-rgb: 94, 190, 214;
|
|
5
|
-
display: flex;
|
|
6
|
-
justify-content: center;
|
|
7
|
-
align-items: center;
|
|
8
|
-
width: 100%;
|
|
9
|
-
height: 100%;
|
|
10
|
-
max-width: 100px;
|
|
11
|
-
max-height: 100px;
|
|
12
|
-
aspect-ratio: 1/1;
|
|
13
|
-
padding-left: calc(-0.5rem / 2);
|
|
14
|
-
padding-right: calc(-0.5rem / 2);
|
|
15
|
-
overflow: hidden;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.spinner::before {
|
|
19
|
-
content: "";
|
|
20
|
-
display: inline-block;
|
|
21
|
-
width: 100%;
|
|
22
|
-
max-width: 90%;
|
|
23
|
-
max-height: 90%;
|
|
24
|
-
--border-width: clamp(0.2em, 10%, 0.5em);
|
|
25
|
-
border-radius: 50%;
|
|
26
|
-
aspect-ratio: 1/1;
|
|
27
|
-
--mask: radial-gradient(
|
|
28
|
-
farthest-side,
|
|
29
|
-
transparent calc(100% - var(--border-width) - 0.5px),
|
|
30
|
-
#000 calc(100% - var(--border-width) + 0.5px)
|
|
31
|
-
);
|
|
32
|
-
mask: var(--mask);
|
|
33
|
-
background: linear-gradient(to top, rgba(var(--color-rgb), 1), rgba(var(--color-rgb), 0.5)) 100% 0/50% 100% no-repeat,
|
|
34
|
-
linear-gradient(rgba(var(--color-rgb), 0.5) 50%, transparent 95%) 0 0/50% 100% no-repeat;
|
|
35
|
-
animation: button-spinner-border .85s linear infinite;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.spinner.contrast {
|
|
39
|
-
--color-rgb: 255, 255, 255;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.spinner.orange {
|
|
43
|
-
--color-rgb: 251, 163, 29;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.spinner.small {
|
|
47
|
-
width: 1rem;
|
|
48
|
-
height: 1rem;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.spinner.middle {
|
|
52
|
-
width: 4rem;
|
|
53
|
-
height: 4rem;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.spinner.large {
|
|
57
|
-
width: 8rem;
|
|
58
|
-
height: 8rem;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@keyframes button-spinner-border {
|
|
62
|
-
to{
|
|
63
|
-
transform:rotate(360deg)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useRef,
|
|
4
|
-
useEffect,
|
|
5
|
-
useState,
|
|
6
|
-
ChangeEvent,
|
|
7
|
-
useImperativeHandle
|
|
8
|
-
} from "react";
|
|
9
|
-
import Element,{
|
|
10
|
-
IElement
|
|
11
|
-
} from "../Form/Element";
|
|
12
|
-
|
|
13
|
-
interface ITextArea extends IElement<HTMLTextAreaElement> {
|
|
14
|
-
onChangeText?: (text: string) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const TextArea = forwardRef<HTMLTextAreaElement, ITextArea>(({onChange, onInput, onChangeText, formValue, ...props}, ref) => {
|
|
18
|
-
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
19
|
-
const [currentValue, setCurrentValue] = useState(props.value);
|
|
20
|
-
|
|
21
|
-
const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
|
22
|
-
if (typeof onChange === 'function') {
|
|
23
|
-
onChange(e);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (typeof onChangeText === 'function') {
|
|
27
|
-
onChangeText(e.target.value);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const handleInput = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
|
32
|
-
if (typeof onInput === 'function') {
|
|
33
|
-
onInput(e);
|
|
34
|
-
}
|
|
35
|
-
setCurrentValue(e.target.value);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (!textareaRef.current) return;
|
|
40
|
-
|
|
41
|
-
textareaRef.current.style.height = '0';
|
|
42
|
-
const height = textareaRef.current.scrollHeight;
|
|
43
|
-
textareaRef.current.style.height = height + 'px';
|
|
44
|
-
},[currentValue]);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
setCurrentValue(props.value ?? formValue);
|
|
48
|
-
}, [props.value, formValue]);
|
|
49
|
-
|
|
50
|
-
useImperativeHandle(ref, () => textareaRef.current as HTMLTextAreaElement);
|
|
51
|
-
|
|
52
|
-
return(<Element {...props}>
|
|
53
|
-
{ (props) => <textarea {...props} placeholder="" value={currentValue} onChange={handleChange} onInput={handleInput} ref={textareaRef}/> }
|
|
54
|
-
</Element>);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export default TextArea;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import Spinner from "../Spinner";
|
|
3
|
-
import type { TFileData } from "../File";
|
|
4
|
-
import styles from "./style.module.css";
|
|
5
|
-
|
|
6
|
-
export type TImageData = TFileData & {
|
|
7
|
-
id?: string | number;
|
|
8
|
-
setWait: (status: boolean) => void;
|
|
9
|
-
setId: (id: string | number) => void;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface IImage extends TFileData {
|
|
13
|
-
onChange?: (data: TImageData) => void;
|
|
14
|
-
onId?: (id: string | number) => void;
|
|
15
|
-
onRemove?: () => void;
|
|
16
|
-
onClick?: (data: TImageData) => void;
|
|
17
|
-
id?: string | number;
|
|
18
|
-
src?: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const Image = ({onChange, onClick, onId, onRemove, ...props}: IImage) => {
|
|
22
|
-
const { base64, src } = props;
|
|
23
|
-
const [wait, setWait] = useState(true);
|
|
24
|
-
const confirmRemove = useRef(false);
|
|
25
|
-
const currentId = useRef<string | number | undefined>();
|
|
26
|
-
const setId = (id: string | number) => {
|
|
27
|
-
currentId.current = id;
|
|
28
|
-
if (typeof onId !== 'function') return;
|
|
29
|
-
onId(id);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const handleClick = () => {
|
|
33
|
-
if (typeof onClick === 'function') {
|
|
34
|
-
onClick({
|
|
35
|
-
...props,
|
|
36
|
-
setWait,
|
|
37
|
-
setId,
|
|
38
|
-
id: currentId.current
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const handleLoad = () => {
|
|
44
|
-
setWait(false);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const handleRemove = (e: React.MouseEvent<HTMLSpanElement>) => {
|
|
48
|
-
if (!e.target) return;
|
|
49
|
-
const element = (e.target as HTMLSpanElement);
|
|
50
|
-
|
|
51
|
-
const remove = () => {
|
|
52
|
-
if (!confirmRemove.current) return;
|
|
53
|
-
confirmRemove.current = false;
|
|
54
|
-
element.blur();
|
|
55
|
-
if (typeof onRemove === 'function') {
|
|
56
|
-
onRemove();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
remove();
|
|
60
|
-
confirmRemove.current = true;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const handleCancelRemove = () => {
|
|
64
|
-
confirmRemove.current = false;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
if (typeof onChange !== 'function' || src) return;
|
|
69
|
-
onChange({
|
|
70
|
-
...props,
|
|
71
|
-
setWait,
|
|
72
|
-
setId,
|
|
73
|
-
id: currentId.current
|
|
74
|
-
});
|
|
75
|
-
}, []);
|
|
76
|
-
|
|
77
|
-
return(<span className={styles['image']} onClick={handleClick}>
|
|
78
|
-
<span className={styles['close']} onClick={handleRemove} onBlur={handleCancelRemove} tabIndex={1}/>
|
|
79
|
-
<img src={src ?? base64?.toString()} onLoad={handleLoad}/>
|
|
80
|
-
{wait && <span className={styles['wait']}>
|
|
81
|
-
<Spinner/>
|
|
82
|
-
</span>}
|
|
83
|
-
</span>);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export default Image;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import File,{
|
|
3
|
-
TFileData
|
|
4
|
-
} from "../File";
|
|
5
|
-
import styles from "./style.module.css";
|
|
6
|
-
|
|
7
|
-
import Image,{
|
|
8
|
-
TImageData,
|
|
9
|
-
IImage
|
|
10
|
-
} from "./Image";
|
|
11
|
-
|
|
12
|
-
export interface IUploadImages {
|
|
13
|
-
onChange?: (data: TImageData) => void;
|
|
14
|
-
onChangeArray?: (data: IImage[]) => void;
|
|
15
|
-
onClick?: (data: TImageData) => void;
|
|
16
|
-
imagesArray?: TImageData[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const UploadImages = ({imagesArray, onChange, onChangeArray, onClick}: IUploadImages) => {
|
|
20
|
-
const [images, setImages] = useState<IImage[]>([]);
|
|
21
|
-
|
|
22
|
-
const handleChange = (image: TFileData) => {
|
|
23
|
-
setImages((images) => [...images, {...image}]);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const handleChangeId = (image: IImage) => {
|
|
27
|
-
return (id: string | number) => {
|
|
28
|
-
setImages((images) => images.map((currentImage) => {
|
|
29
|
-
if (image === currentImage) {
|
|
30
|
-
currentImage.id = id;
|
|
31
|
-
}
|
|
32
|
-
return currentImage;
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const handleRemove = (image: IImage) => {
|
|
38
|
-
return () => setImages((images) => images.filter((currentImage) => currentImage !== image));
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (typeof onChangeArray !== 'function') return;
|
|
43
|
-
onChangeArray(images);
|
|
44
|
-
}, [images]);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (!imagesArray) return;
|
|
48
|
-
setImages(imagesArray);
|
|
49
|
-
}, [imagesArray]);
|
|
50
|
-
|
|
51
|
-
return(<div className={styles['container']}>
|
|
52
|
-
{images.map((image, index) => <Image key={(image.name + index)} {...image} onChange={onChange} onClick={onClick} onRemove={handleRemove(image)} onId={handleChangeId(image)}/>)}
|
|
53
|
-
<File onChange={handleChange} accept={['image/png']} className={styles['new']} multiple/>
|
|
54
|
-
</div>);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export default UploadImages;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/* UploadImages */
|
|
2
|
-
|
|
3
|
-
.container {
|
|
4
|
-
display: flex;
|
|
5
|
-
flex-direction: row;
|
|
6
|
-
justify-content: flex-start;
|
|
7
|
-
flex-wrap: wrap;
|
|
8
|
-
width: 100%;
|
|
9
|
-
gap: 10px;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.image, .new {
|
|
13
|
-
position: relative;
|
|
14
|
-
display: flex;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
align-items: center;
|
|
17
|
-
width: 80px;
|
|
18
|
-
height: 80px;
|
|
19
|
-
border: 1px solid #b1b0b0;
|
|
20
|
-
background-color: #BED4DB;
|
|
21
|
-
border-radius: 3px;
|
|
22
|
-
cursor: pointer;
|
|
23
|
-
transition: scale 0.3s, box-shadow 0.3s;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.image:hover, .new:hover {
|
|
27
|
-
scale: 1.03;
|
|
28
|
-
box-shadow: 0px 0px 6px 2px rgb(0 0 0 / 10%);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.image:active, .new:active {
|
|
32
|
-
scale: 0.99;
|
|
33
|
-
box-shadow: unset
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.image > img {
|
|
37
|
-
width: 100%;
|
|
38
|
-
object-fit: cover;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/* Close */
|
|
42
|
-
.image .close {
|
|
43
|
-
display: flex;
|
|
44
|
-
position: absolute;
|
|
45
|
-
top: 0;
|
|
46
|
-
right: 0;
|
|
47
|
-
justify-content: center;
|
|
48
|
-
align-items: center;
|
|
49
|
-
width: 20px;
|
|
50
|
-
height: 20px;
|
|
51
|
-
cursor: pointer;
|
|
52
|
-
opacity: 0.7;
|
|
53
|
-
transition: transform 0.3s, opacity 0.3s;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.image .close::before, .image .close::after {
|
|
57
|
-
content: "";
|
|
58
|
-
display: block;
|
|
59
|
-
position: absolute;
|
|
60
|
-
width: 100%;
|
|
61
|
-
height: 3px;
|
|
62
|
-
background-color: #1D1D1B;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.image .close::before {
|
|
66
|
-
transform: rotate(45deg);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.image .close::after {
|
|
70
|
-
transform: rotate(-45deg);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.image .close:focus {
|
|
74
|
-
background-color: red;
|
|
75
|
-
width: 100%;
|
|
76
|
-
height: 100%;
|
|
77
|
-
transition: width 0.1s, height 0.3s;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.image .close:focus::before, .image .close:focus::after {
|
|
81
|
-
background-color: #FFFFFF;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.new {
|
|
85
|
-
display: flex;
|
|
86
|
-
justify-content: center;
|
|
87
|
-
align-items: center;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.new::after {
|
|
91
|
-
content: "+";
|
|
92
|
-
font-size: 1.9em;
|
|
93
|
-
color: #777777;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.wait {
|
|
97
|
-
display: flex;
|
|
98
|
-
position: absolute;
|
|
99
|
-
justify-content: center;
|
|
100
|
-
align-items: center;
|
|
101
|
-
width: 100%;
|
|
102
|
-
height: 100%;
|
|
103
|
-
top: 0;
|
|
104
|
-
left: 0;
|
|
105
|
-
backdrop-filter: blur(2px);
|
|
106
|
-
background-color: #BED4DB9F;
|
|
107
|
-
z-index: 1;
|
|
108
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import Form,{
|
|
2
|
-
useForm,
|
|
3
|
-
FormElement
|
|
4
|
-
} from "./Form";
|
|
5
|
-
import Element,{
|
|
6
|
-
IElement
|
|
7
|
-
} from "./Form/Element";
|
|
8
|
-
import Input from "./Input";
|
|
9
|
-
import TextArea from "./TextArea";
|
|
10
|
-
import Spinner from "./Spinner";
|
|
11
|
-
import File,{
|
|
12
|
-
TFileData,
|
|
13
|
-
TFileMime
|
|
14
|
-
} from "./File";
|
|
15
|
-
import Button from "./Button";
|
|
16
|
-
import UploadImages,{
|
|
17
|
-
IUploadImages,
|
|
18
|
-
TImageData,
|
|
19
|
-
IImage
|
|
20
|
-
} from "./UploadImages";
|
|
21
|
-
import Checkbox from "./Checkbox";
|
|
22
|
-
import Progress from "./Progress";
|
|
23
|
-
import Select,{
|
|
24
|
-
SelectOption,
|
|
25
|
-
SelectOptgroup
|
|
26
|
-
} from "./Select";
|
|
27
|
-
import Dropdown,{
|
|
28
|
-
DropdownItem
|
|
29
|
-
} from "./Dropdown";
|
|
30
|
-
|
|
31
|
-
const UI = {
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
Form,
|
|
37
|
-
FormElement,
|
|
38
|
-
Element,
|
|
39
|
-
useForm,
|
|
40
|
-
Input,
|
|
41
|
-
TextArea,
|
|
42
|
-
Spinner,
|
|
43
|
-
File,
|
|
44
|
-
Button,
|
|
45
|
-
UploadImages,
|
|
46
|
-
Checkbox,
|
|
47
|
-
Progress,
|
|
48
|
-
Select,
|
|
49
|
-
SelectOption,
|
|
50
|
-
SelectOptgroup,
|
|
51
|
-
Dropdown,
|
|
52
|
-
DropdownItem
|
|
53
|
-
};
|
|
54
|
-
export type {
|
|
55
|
-
TFileData,
|
|
56
|
-
TFileMime,
|
|
57
|
-
IUploadImages,
|
|
58
|
-
IImage,
|
|
59
|
-
TImageData,
|
|
60
|
-
IElement
|
|
61
|
-
};
|
|
62
|
-
export default UI;
|