@xaypay/tui 0.0.15 → 0.0.17
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 +252 -182
- package/dist/index.js +230 -157
- package/package.json +1 -1
- package/src/components/button/index.js +0 -3
- package/src/components/captcha/captcha.stories.js +0 -1
- package/src/components/icon/Icon.js +9 -2
- package/src/components/input/index.js +4 -1
- package/src/components/input/input.stories.js +1 -1
- package/src/components/multiselect/index.js +24 -13
- package/src/components/multiselect/multiselect.stories.js +7 -6
- package/src/components/pagination/index.js +7 -5
- package/src/components/select/index.js +72 -67
- package/src/components/select/select.stories.js +3 -3
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -31,8 +31,6 @@ export const ButtonSize = {
|
|
|
31
31
|
|
|
32
32
|
export const Button = ({ primary, backgroundColor, theme, size, className, disabled, label, outline, ...props }) => {
|
|
33
33
|
|
|
34
|
-
console.log(styles);
|
|
35
|
-
console.log(backgroundColor);
|
|
36
34
|
const classProps = classnames(
|
|
37
35
|
styles.btn,
|
|
38
36
|
styles[theme],
|
|
@@ -41,7 +39,6 @@ export const Button = ({ primary, backgroundColor, theme, size, className, disab
|
|
|
41
39
|
className
|
|
42
40
|
);
|
|
43
41
|
// className='btn type-outline size-default'
|
|
44
|
-
console.log(classProps);
|
|
45
42
|
return (
|
|
46
43
|
<button
|
|
47
44
|
type="button"
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Created by aleksanyan.tigran on 10/7/2022.
|
|
3
3
|
*/
|
|
4
|
+
import React from "react";
|
|
4
5
|
import style from '../../assets_old/icons/style.css'
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
const Icon = (props) => {
|
|
8
|
+
return (
|
|
9
|
+
<i className={style[props.className]} />
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default Icon;
|
|
@@ -29,9 +29,10 @@ export const Input = ({
|
|
|
29
29
|
disabled,
|
|
30
30
|
type,
|
|
31
31
|
onChange,
|
|
32
|
+
value,
|
|
32
33
|
...props
|
|
33
34
|
}) => {
|
|
34
|
-
const [inputValue, setInputValue] = useState(
|
|
35
|
+
const [inputValue, setInputValue] = useState(value);
|
|
35
36
|
const handleChange = (event) => {
|
|
36
37
|
setInputValue(event.target.value);
|
|
37
38
|
onChange ? onChange(event.target.value) : '';
|
|
@@ -79,6 +80,7 @@ Input.propTypes = {
|
|
|
79
80
|
regexpError: PropTypes.string,
|
|
80
81
|
label: PropTypes.string.isRequired,
|
|
81
82
|
disabled: PropTypes.bool,
|
|
83
|
+
value: PropTypes.string
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
Input.defaultProps = {
|
|
@@ -89,4 +91,5 @@ Input.defaultProps = {
|
|
|
89
91
|
required: true,
|
|
90
92
|
errorMesage: "",
|
|
91
93
|
type: "text",
|
|
94
|
+
value: ""
|
|
92
95
|
};
|
|
@@ -9,6 +9,7 @@ export const Multiselect = ({
|
|
|
9
9
|
jsonOptionsData,
|
|
10
10
|
jsonSelectedOptionsData,
|
|
11
11
|
onchange,
|
|
12
|
+
keyNames,
|
|
12
13
|
value
|
|
13
14
|
}) => {
|
|
14
15
|
const [searchedOptions, setSearchedOptions] = useState(jsonOptionsData.length ? JSON.parse(jsonOptionsData) : []);
|
|
@@ -21,8 +22,8 @@ export const Multiselect = ({
|
|
|
21
22
|
<div className={styles['multi-select-content-top']} onClick={()=>{setOpened(!opened)}}>
|
|
22
23
|
{
|
|
23
24
|
options.map((option, i) => {
|
|
24
|
-
return (<div className={styles['multi-select-content-bottom-row']} >
|
|
25
|
-
<div id={option.id}>{option.name}</div>
|
|
25
|
+
return (<div className={styles['multi-select-content-bottom-row']} key={option[keyNames.id]}>
|
|
26
|
+
<div id={option[keyNames.id]}>{option[keyNames.name]}</div>
|
|
26
27
|
<Icon className='icon-close' onClick={() => {
|
|
27
28
|
options.splice(i, 1);
|
|
28
29
|
setOptions(options);
|
|
@@ -33,28 +34,37 @@ export const Multiselect = ({
|
|
|
33
34
|
</div>)
|
|
34
35
|
})
|
|
35
36
|
}
|
|
36
|
-
{/*<div onChange={(e) => {*/}
|
|
37
|
-
{/*setValues(e.target.value ? searchedOptions.filter((option) => {*/}
|
|
38
|
-
{/*return option.name.toLowerCase().includes(e.target.value.toLowerCase())*/}
|
|
39
|
-
{/*}) : searchedOptions)*/}
|
|
40
37
|
|
|
41
|
-
|
|
38
|
+
<input onChange={(e) => {
|
|
39
|
+
setValues(e.target.value ? searchedOptions.filter((option) => {
|
|
40
|
+
return option[keyNames.name].toLowerCase().includes(e.target.value.toLowerCase())
|
|
41
|
+
}) : searchedOptions)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
}} className={styles.input} type='text' />
|
|
42
45
|
<div className={styles['select-content-top-icon']}>
|
|
43
46
|
<Icon className={opened ? 'icon-arrow-up' : 'icon-arrow-down'}/>
|
|
44
47
|
</div>
|
|
45
48
|
</div>
|
|
46
49
|
{
|
|
50
|
+
|
|
47
51
|
opened ? <div className={styles['multi-select-content-bottom']} onClick={onchange}>
|
|
48
52
|
<div className={styles['multi-select-content-bottom-inner']}>
|
|
49
53
|
{
|
|
50
54
|
values.length ?
|
|
51
55
|
values.map((value, i) => {
|
|
52
|
-
return (<div
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
return (<div
|
|
57
|
+
className={styles['multi-select-content-bottom-row']}
|
|
58
|
+
key={value[keyNames.id]}
|
|
59
|
+
id={value.id}
|
|
60
|
+
onClick={(e) => {
|
|
61
|
+
setOptions([...options, { [keyNames.name] : value[keyNames.name], [keyNames.id] : value[keyNames.id] }])
|
|
62
|
+
values.splice(i, 1);
|
|
63
|
+
setValues(values);
|
|
64
|
+
setSearchedOptions(values);
|
|
65
|
+
}}>
|
|
66
|
+
{value.name}
|
|
67
|
+
</div>)
|
|
58
68
|
}) :
|
|
59
69
|
<div className={styles['no-elements']}>No Elements!</div>
|
|
60
70
|
}
|
|
@@ -72,5 +82,6 @@ Multiselect.propTypes = {
|
|
|
72
82
|
jsonOptionsData: PropTypes.string,
|
|
73
83
|
jsonSelectedOptionsData: PropTypes.string,
|
|
74
84
|
onchange: PropTypes.func,
|
|
85
|
+
keyNames: PropTypes.object,
|
|
75
86
|
};
|
|
76
87
|
|
|
@@ -2,18 +2,19 @@ import React from "react";
|
|
|
2
2
|
import { Multiselect } from "./index";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
component: Multiselect,
|
|
6
|
+
title: "Components/Multiselect",
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
const Template = (args) => <Multiselect {...args} />;
|
|
10
10
|
|
|
11
11
|
export const Default = Template.bind({});
|
|
12
12
|
Default.args = {
|
|
13
|
-
jsonOptionsData: '[{"
|
|
14
|
-
jsonSelectedOptionsData: '[{"
|
|
13
|
+
jsonOptionsData: '[{"bbb":"1", "value":"Կենտրոն"}]',
|
|
14
|
+
jsonSelectedOptionsData: '[{"bbb":"0", "value":"Արաբկիր"}, {"bbb":"2", "value":"Մալաթիա"}]',
|
|
15
15
|
label: 'label',
|
|
16
|
-
onchange: (newValue)=> {
|
|
16
|
+
onchange: (newValue) => {
|
|
17
17
|
console.log(newValue);
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
|
+
keyNames: { name: 'value', id: 'bbb' }
|
|
19
20
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useState, useEffect } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import classnames from "classnames";
|
|
4
4
|
import styles from "./pagination.module.css";
|
|
@@ -13,9 +13,9 @@ export const Pagination = ({
|
|
|
13
13
|
offset,
|
|
14
14
|
className,
|
|
15
15
|
}) => {
|
|
16
|
-
const [siblingCountNumber, setSibilingCountNumber] = useState(
|
|
17
|
-
const [currentPageNumber, setCurrentPage] = useState(
|
|
18
|
-
const [currentTotalCount, setcurrentTotalCount] = useState(
|
|
16
|
+
const [siblingCountNumber, setSibilingCountNumber] = useState(siblingCount);
|
|
17
|
+
const [currentPageNumber, setCurrentPage] = useState(currentPage);
|
|
18
|
+
const [currentTotalCount, setcurrentTotalCount] = useState(totalCount);
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
setcurrentTotalCount(totalCount);
|
|
21
21
|
}, [totalCount]);
|
|
@@ -29,7 +29,9 @@ export const Pagination = ({
|
|
|
29
29
|
const onPageChange = (page) => {
|
|
30
30
|
setCurrentPage(page);
|
|
31
31
|
};
|
|
32
|
-
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
onChange(currentPageNumber);
|
|
34
|
+
}, [currentPageNumber]);
|
|
33
35
|
const paginationRange = PaginationRange({
|
|
34
36
|
currentPageNumber,
|
|
35
37
|
currentTotalCount,
|
|
@@ -22,21 +22,24 @@ export const SelectSize = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const Select = ({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
theme,
|
|
26
|
+
size,
|
|
27
|
+
className,
|
|
28
|
+
disabled,
|
|
29
|
+
label,
|
|
30
|
+
jsonData,
|
|
31
|
+
eMessage,
|
|
32
|
+
required,
|
|
33
|
+
defaultOption,
|
|
34
|
+
onChange,
|
|
35
|
+
keyNames,
|
|
36
|
+
selected
|
|
37
|
+
}) => {
|
|
38
|
+
const options = jsonData.length ? JSON.parse(jsonData) : [];
|
|
39
|
+
const parseSelectedData =
|
|
40
|
+
selected.length !== 0 ? JSON.parse(selected) : {};
|
|
38
41
|
let [opened, setOpened] = useState(false)
|
|
39
|
-
let [newSelected, setNewSelected] = useState(
|
|
42
|
+
let [newSelected, setNewSelected] = useState(parseSelectedData)
|
|
40
43
|
const classProps = classnames(
|
|
41
44
|
styles[theme],
|
|
42
45
|
styles[size],
|
|
@@ -48,66 +51,67 @@ export const Select = ({
|
|
|
48
51
|
);
|
|
49
52
|
|
|
50
53
|
return (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
<div>
|
|
55
|
+
{label ? <label className={styles['select-title']}>{label}</label> : ""}
|
|
56
|
+
<div className={styles['select-wrap']}>
|
|
57
|
+
<div className={styles['select-content']} id={styles.selector}>
|
|
58
|
+
<div
|
|
59
|
+
className={styles['select-content-top']}
|
|
60
|
+
onClick={() => {
|
|
61
|
+
setOpened(!opened)
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<div className={styles['select-content-top-text']}>{newSelected && newSelected[keyNames.name] ? newSelected[keyNames.name] : defaultOption}</div>
|
|
65
|
+
<div className={styles['select-content-top-icon']}>
|
|
66
|
+
<Icon className={opened ? 'icon-arrow-up' : 'icon-arrow-down'}/>
|
|
67
|
+
</div>
|
|
64
68
|
</div>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
opened && !disabled ?
|
|
69
|
+
{
|
|
70
|
+
opened && !disabled ?
|
|
68
71
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
<div className={styles['select-content-bottom']}>
|
|
73
|
+
<div className={styles['select-content-bottom-inner']}>
|
|
74
|
+
<div
|
|
75
|
+
className={styles['select-content-bottom-row']}
|
|
76
|
+
onClick={() => {
|
|
77
|
+
if (!required && !selected) {
|
|
78
|
+
setNewSelected(defaultOption)
|
|
79
|
+
onChange(defaultOption)
|
|
80
|
+
setOpened(!opened)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
78
83
|
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
>
|
|
82
|
-
{defaultOption}
|
|
83
|
-
</div>
|
|
84
|
-
{
|
|
85
|
-
options ?.map((option, i) => {
|
|
86
|
-
return <div
|
|
87
|
-
className={styles['select-content-bottom-row']}
|
|
88
|
-
disabled={true}
|
|
89
|
-
onClick={() => {
|
|
90
|
-
setNewSelected(option);
|
|
91
|
-
onChange(option);
|
|
92
|
-
setOpened(!opened);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
defaultValue={option.id}
|
|
96
84
|
>
|
|
97
|
-
|
|
85
|
+
{defaultOption}
|
|
98
86
|
</div>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
87
|
+
{
|
|
88
|
+
options.map((option, i) => {
|
|
89
|
+
return <div
|
|
90
|
+
key={i}
|
|
91
|
+
className={styles['select-content-bottom-row']}
|
|
92
|
+
disabled={true}
|
|
93
|
+
onClick={() => {
|
|
94
|
+
setNewSelected(option);
|
|
95
|
+
onChange(option);
|
|
96
|
+
setOpened(!opened);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
defaultValue={option[keyNames.id]}
|
|
100
|
+
>
|
|
101
|
+
{option[keyNames.name]}
|
|
102
|
+
</div>
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
</div>
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
</div>
|
|
108
|
+
: null
|
|
109
|
+
}
|
|
106
110
|
|
|
111
|
+
</div>
|
|
107
112
|
</div>
|
|
113
|
+
{eMessage ? <span className={styles.eMessage}>{eMessage}</span> : null}
|
|
108
114
|
</div>
|
|
109
|
-
{eMessage ? <span className={styles.eMessage}>{eMessage}</span> : null}
|
|
110
|
-
</>
|
|
111
115
|
);
|
|
112
116
|
};
|
|
113
117
|
|
|
@@ -121,8 +125,9 @@ Select.propTypes = {
|
|
|
121
125
|
required: PropTypes.bool,
|
|
122
126
|
disabled: PropTypes.bool,
|
|
123
127
|
className: PropTypes.string,
|
|
124
|
-
selected: PropTypes.
|
|
125
|
-
jsonData: PropTypes.string
|
|
128
|
+
selected: PropTypes.string,
|
|
129
|
+
jsonData: PropTypes.string,
|
|
130
|
+
keyNames: PropTypes.object,
|
|
126
131
|
};
|
|
127
132
|
|
|
128
133
|
Select.defaultProps = {
|
|
@@ -11,11 +11,11 @@ export const Default = Template.bind({});
|
|
|
11
11
|
Default.args = {
|
|
12
12
|
theme: SelectTheme.DEFAULT,
|
|
13
13
|
label: 'վարչական շրջան',
|
|
14
|
-
jsonData: '[{"
|
|
14
|
+
jsonData: '[{"bbb":"0", "value":"Արաբկիր"}, {"bbb":"1", "value":"Կենտրոն"}, {"bbb":"2", "value":"Մալաթիա"}]',
|
|
15
15
|
onChange: (newValue)=> {
|
|
16
|
-
console.log(newValue);
|
|
17
16
|
},
|
|
18
17
|
defaultOption: 'ընտրել',
|
|
19
|
-
selected: {"
|
|
18
|
+
selected: '{"bbb":"2", "value":"Մալաթիա"}',
|
|
19
|
+
keyNames: {name: 'value', id : 'bbb'}
|
|
20
20
|
};
|
|
21
21
|
|
package/src/index.js
CHANGED