@xaypay/tui 0.0.22 → 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 +227 -112
- package/dist/index.js +227 -111
- package/package.json +1 -1
- package/src/components/autocomplate/autocomplate.stories.js +12 -2
- package/src/components/autocomplate/index.js +60 -54
- 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
|
@@ -11,13 +11,23 @@ const Template = (args) => <Autocomplate {...args} />;
|
|
|
11
11
|
export const Default = Template.bind({});
|
|
12
12
|
Default.args = {
|
|
13
13
|
jsonOptionsData: '[{"bbb":"0", "value":"asd"}, {"bbb":"2", "value":"bas"}]',
|
|
14
|
-
|
|
14
|
+
jsonSelectedOptionsData: '{"bbb":"0", "value":"gasdfgdsfgdsg"}',
|
|
15
15
|
label: 'label',
|
|
16
16
|
keyNames: { name: 'value', id: 'bbb' },
|
|
17
17
|
searchCount: 2,
|
|
18
18
|
onChange: (aa)=> {
|
|
19
19
|
console.log(aa);
|
|
20
|
-
|
|
20
|
+
fetch(`http://dev2.govazd-api.yerevan.am/api/v1/companies/autocomplete?slug=${aa.name? aa.name : 'a'}`, {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIwMjE0NzEyYTllNzQwZWMyMjNhYzE2MGQyNGVkY2UzNyIsImp0aSI6Ijk2Mjk0MjJkNTY1ZTQ3MGM3MjFkZjY5NDgzMzE3ZThm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
-
import React, { useState } from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import classnames from "classnames";
|
|
4
4
|
import styles from "./autocomplate.module.css";
|
|
@@ -13,79 +13,81 @@ export const Autocomplate = ({
|
|
|
13
13
|
onChange,
|
|
14
14
|
value,
|
|
15
15
|
searchCount,
|
|
16
|
+
placeHolder,
|
|
16
17
|
keyNames,
|
|
18
|
+
errorMesage,
|
|
17
19
|
...props
|
|
18
20
|
}) => {
|
|
19
21
|
const classProps = classnames(styles.searchBox, className);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
+
const parseSelectedOptionsData =
|
|
23
|
+
jsonSelectedOptionsData ? JSON.parse(jsonSelectedOptionsData) : { name: '', id: '' };
|
|
24
|
+
const [inputValue, setInputValue] = useState(parseSelectedOptionsData[keyNames.name]);
|
|
25
|
+
const [inputId, setInputId] = useState(parseSelectedOptionsData[keyNames.id]);
|
|
22
26
|
const [activeOption, setActiveOption] = useState(0);
|
|
23
|
-
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
24
27
|
const [showOptions, setShowOptions] = useState(false);
|
|
25
28
|
const parseOptionsData =
|
|
26
|
-
jsonOptionsData? JSON.parse(jsonOptionsData)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
jsonOptionsData ? JSON.parse(jsonOptionsData) : [];
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setInputValue(JSON.parse(jsonSelectedOptionsData)[keyNames.name])
|
|
32
|
+
setInputId(JSON.parse(jsonSelectedOptionsData)[keyNames.id])
|
|
33
|
+
}, [jsonSelectedOptionsData])
|
|
34
|
+
|
|
30
35
|
const handleChange = (e) => {
|
|
31
36
|
const currentInputValue = e.currentTarget.value;
|
|
32
37
|
setInputId(null)
|
|
33
|
-
const filteredOptions = parseOptionsData.filter(
|
|
34
|
-
(optionName) =>
|
|
35
|
-
optionName[keyNames.name].toLowerCase().indexOf(currentInputValue.toLowerCase()) > -1
|
|
36
|
-
);
|
|
37
38
|
setInputValue(currentInputValue);
|
|
39
|
+
setInputId('')
|
|
38
40
|
setActiveOption(0);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
setShowOptions(true);
|
|
42
|
+
onChange({ name: currentInputValue, id: e.target.id });
|
|
41
43
|
};
|
|
42
44
|
const handleClick = (e) => {
|
|
43
|
-
setInputValue(e.currentTarget.innerText);
|
|
44
|
-
setInputId(e.target.id)
|
|
45
45
|
setActiveOption(0);
|
|
46
|
-
setFilteredOptions([]);
|
|
47
46
|
setShowOptions(false);
|
|
48
|
-
|
|
47
|
+
setInputValue(e.target.innerText);
|
|
48
|
+
setInputId(e.target.id)
|
|
49
|
+
|
|
50
|
+
onChange({ name: e.target.innerText, id: e.target.id });
|
|
49
51
|
|
|
50
52
|
};
|
|
51
53
|
let optionList;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
})}
|
|
72
|
-
</div>
|
|
54
|
+
if (showOptions && inputValue) {
|
|
55
|
+
if (parseOptionsData.length && inputValue.length >= searchCount) {
|
|
56
|
+
optionList = (
|
|
57
|
+
<div className={styles['autocomplate-content-bottom']}>
|
|
58
|
+
<div className={styles['autocomplate-content-bottom-inner']}>
|
|
59
|
+
{parseOptionsData.map((optionName, index) => {
|
|
60
|
+
let className;
|
|
61
|
+
if (index === activeOption) {
|
|
62
|
+
className = "option-active";
|
|
63
|
+
}
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
className={styles[className]}
|
|
67
|
+
key={optionName[keyNames.id]}
|
|
68
|
+
onClick={handleClick}
|
|
69
|
+
>
|
|
70
|
+
<div id={optionName[keyNames.id]} className={styles['autocomplate-content-bottom-row']}>{optionName[keyNames.name]}</div>
|
|
73
71
|
</div>
|
|
72
|
+
);
|
|
73
|
+
})}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
74
76
|
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
78
|
+
);
|
|
79
|
+
} else {
|
|
80
|
+
optionList = (
|
|
81
|
+
<div className={styles['autocomplate-content-bottom']}>
|
|
82
|
+
<div className={styles['autocomplate-content-bottom-inner']}>
|
|
83
|
+
<div className={styles['autocomplate-content-bottom-row']}>
|
|
84
|
+
<div className={styles['no-option']}>No Option!</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
88
89
|
}
|
|
90
|
+
}
|
|
89
91
|
|
|
90
92
|
return (
|
|
91
93
|
<>
|
|
@@ -98,10 +100,12 @@ export const Autocomplate = ({
|
|
|
98
100
|
required={required}
|
|
99
101
|
disabled={disabled}
|
|
100
102
|
onChange={handleChange}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
onClick={() => { setShowOptions(!showOptions) }}
|
|
104
|
+
value={inputValue}
|
|
105
|
+
placeholder={placeHolder}
|
|
103
106
|
{...props}
|
|
104
|
-
|
|
107
|
+
/>
|
|
108
|
+
{errorMesage ? <span className={styles.errorMessage}>{errorMesage}</span> : null}
|
|
105
109
|
{optionList}
|
|
106
110
|
</div>
|
|
107
111
|
</>
|
|
@@ -111,6 +115,7 @@ export const Autocomplate = ({
|
|
|
111
115
|
Autocomplate.propTypes = {
|
|
112
116
|
className: PropTypes.string,
|
|
113
117
|
label: PropTypes.string,
|
|
118
|
+
placeHolder: PropTypes.string,
|
|
114
119
|
required: PropTypes.bool,
|
|
115
120
|
disabled: PropTypes.bool,
|
|
116
121
|
jsonOptionsData: PropTypes.string,
|
|
@@ -119,6 +124,7 @@ Autocomplate.propTypes = {
|
|
|
119
124
|
value: PropTypes.string,
|
|
120
125
|
searchCount: PropTypes.number,
|
|
121
126
|
keyNames: PropTypes.object,
|
|
127
|
+
errorMesage: PropTypes.string,
|
|
122
128
|
};
|
|
123
129
|
|
|
124
130
|
|
|
@@ -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';
|