@xaypay/tui 0.0.23 → 0.0.24
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.es.js +194 -96
- package/dist/index.js +194 -95
- package/package.json +1 -1
- package/src/components/button/button.module.css +1 -1
- package/src/components/file/file.module.css +11 -0
- package/src/components/file/file.stories.js +24 -0
- package/src/components/file/index.js +117 -0
- package/src/components/input/input.module.css +1 -1
- package/src/components/multiselect/multiselect.module.css +1 -1
- package/src/components/pagination/paginationRange.js +1 -1
- package/src/components/select/select.module.css +1 -1
- package/src/components/typography/typography.module.css +3 -3
- package/src/index.js +2 -1
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { File } from "./index";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
component: File,
|
|
6
|
+
title: "Components/File",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Template = (args) => <File {...args} />;
|
|
10
|
+
|
|
11
|
+
export const Default = Template.bind({});
|
|
12
|
+
Default.args = {
|
|
13
|
+
label: 'ssa',
|
|
14
|
+
onChange: (aa) => {
|
|
15
|
+
console.log('barev', aa);
|
|
16
|
+
|
|
17
|
+
},
|
|
18
|
+
defaultData: {
|
|
19
|
+
url: 'https://images.pexels.com/photos/753626/pexels-photo-753626.jpeg?auto=compress&cs=tinysrgb&w=1600',
|
|
20
|
+
type: "image/png",
|
|
21
|
+
},
|
|
22
|
+
name: 'sss'
|
|
23
|
+
|
|
24
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import styles from "./file.module.css";
|
|
5
|
+
|
|
6
|
+
export const File = ({
|
|
7
|
+
className,
|
|
8
|
+
label,
|
|
9
|
+
required,
|
|
10
|
+
disabled,
|
|
11
|
+
onChange,
|
|
12
|
+
defaultData,
|
|
13
|
+
errorMesage,
|
|
14
|
+
name,
|
|
15
|
+
...props
|
|
16
|
+
}) => {
|
|
17
|
+
const pdfImageName = 'https://play-lh.googleusercontent.com/kIwlXqs28otssKK_9AKwdkB6gouex_U2WmtLshTACnwIJuvOqVvJEzewpzuYBXwXQQ'
|
|
18
|
+
const [image, setImage] = useState(defaultData ?
|
|
19
|
+
defaultData.type != 'application/pdf' ?
|
|
20
|
+
defaultData.url : pdfImageName : null);
|
|
21
|
+
const [error, setError] = useState(errorMesage);
|
|
22
|
+
const [fileName, setFileName] = useState('no selected file');
|
|
23
|
+
function fileType(file) {
|
|
24
|
+
if (file.size <= 5000000) {
|
|
25
|
+
if (file.type === 'image/jpeg' || file.type === 'image/png') {
|
|
26
|
+
setImage(URL.createObjectURL(file))
|
|
27
|
+
setError('')
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
else if (file.type === 'application/pdf') {
|
|
31
|
+
setImage(pdfImageName)
|
|
32
|
+
setError('')
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
setImage(null)
|
|
37
|
+
setFileName('no selected file');
|
|
38
|
+
setError('ֆայլի սխալ ֆորմատ')
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
setImage(null)
|
|
43
|
+
setFileName('no selected file');
|
|
44
|
+
setError('առավելագույն ծավալ')
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
<label>{label}</label>
|
|
51
|
+
<div>
|
|
52
|
+
<div
|
|
53
|
+
className={styles['file-Form']}
|
|
54
|
+
onChange={(e) => { console.log(e) }}
|
|
55
|
+
style={error ? { borderColor: 'red' } : {}}
|
|
56
|
+
onClick={() => {
|
|
57
|
+
document.querySelector(`.${name}`).click()
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<input type='file' className={name} hidden disabled={disabled}
|
|
61
|
+
onChange={({ target: { files } }) => {
|
|
62
|
+
onChange({ target: { files } })
|
|
63
|
+
files[0] && setFileName(files[0].name)
|
|
64
|
+
if (files[0]) {
|
|
65
|
+
fileType(files[0])
|
|
66
|
+
}
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
{
|
|
70
|
+
image ?
|
|
71
|
+
<div>
|
|
72
|
+
<div
|
|
73
|
+
onClick={() => {
|
|
74
|
+
setFileName('no selected file');
|
|
75
|
+
setImage(null)
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
x
|
|
79
|
+
</div>
|
|
80
|
+
<img
|
|
81
|
+
src={image}
|
|
82
|
+
height={120}
|
|
83
|
+
alt={fileName}
|
|
84
|
+
/>
|
|
85
|
+
</div> :
|
|
86
|
+
<div>
|
|
87
|
+
<div>
|
|
88
|
+
<img src='https://uxwing.com/wp-content/themes/uxwing/download/web-app-development/cloud-upload-icon.png' width={100} />
|
|
89
|
+
</div>
|
|
90
|
+
<div>
|
|
91
|
+
<span>Տեղադրել ֆայլը այստեղ կամ Բեռնել</span>
|
|
92
|
+
</div>
|
|
93
|
+
<div>
|
|
94
|
+
<span>Առավելագույնը 5ՄԲ ( jpg, jpeg, png, pdf)</span>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
{
|
|
101
|
+
error ? <span style={{ color: 'red' }}>{error}</span> : null
|
|
102
|
+
}
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
File.propTypes = {
|
|
108
|
+
className: PropTypes.string,
|
|
109
|
+
label: PropTypes.string,
|
|
110
|
+
required: PropTypes.bool,
|
|
111
|
+
disabled: PropTypes.bool,
|
|
112
|
+
onChange: PropTypes.func,
|
|
113
|
+
errorMesage: PropTypes.string,
|
|
114
|
+
defaultData: PropTypes.object
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
|
|
@@ -48,7 +48,7 @@ export const PaginationRange = ({
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
51
|
-
let rightItemCount =
|
|
51
|
+
let rightItemCount = 0;
|
|
52
52
|
currentPageNumber === lastPageIndex - 3 && lastPageIndex > 7
|
|
53
53
|
? (rightItemCount = 4 + siblingCountNumber)
|
|
54
54
|
: (rightItemCount = 3 + siblingCountNumber);
|
|
@@ -34,21 +34,21 @@ h5 {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
h5 {
|
|
37
|
-
text-transform:
|
|
37
|
+
text-transform: none;
|
|
38
38
|
font-size: 16px;
|
|
39
39
|
line-height: 22px;
|
|
40
40
|
font-weight: 600;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
p {
|
|
44
|
-
text-transform:
|
|
44
|
+
text-transform: none;
|
|
45
45
|
font-size: 14px;
|
|
46
46
|
line-height: 20px;
|
|
47
47
|
font-weight: 600;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
span {
|
|
51
|
-
text-transform:
|
|
51
|
+
text-transform: none;
|
|
52
52
|
font-size: 12px;
|
|
53
53
|
line-height: 16px;
|
|
54
54
|
font-weight: 500;
|
package/src/index.js
CHANGED
|
@@ -8,4 +8,5 @@ export * from './components/pagination';
|
|
|
8
8
|
export * from './components/radio';
|
|
9
9
|
export * from './components/captcha';
|
|
10
10
|
export * from './components/stepper';
|
|
11
|
-
export * from './components/select';
|
|
11
|
+
export * from './components/select';
|
|
12
|
+
export * from './components/file';
|