@xaypay/tui 0.0.19 → 0.0.21
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 +31 -15
- package/dist/index.js +30 -14
- package/package.json +1 -1
- package/src/components/autocomplate/autocomplate.stories.js +12 -0
- package/src/components/autocomplate/index.js +22 -15
- package/src/components/input/index.js +5 -1
- package/src/components/multiselect/index.js +33 -28
- package/src/components/select/index.js +11 -3
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState,
|
|
1
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import styled from 'styled-components';
|
|
@@ -191,20 +191,25 @@ const Autocomplate = ({
|
|
|
191
191
|
required,
|
|
192
192
|
disabled,
|
|
193
193
|
jsonOptionsData,
|
|
194
|
+
jsonSelectedOptionsData,
|
|
194
195
|
onChange,
|
|
195
196
|
value,
|
|
196
197
|
searchCount,
|
|
198
|
+
keyNames,
|
|
197
199
|
...props
|
|
198
200
|
}) => {
|
|
199
201
|
classnames(styles$7.searchBox, className);
|
|
200
|
-
const [inputValue, setInputValue] = useState(
|
|
202
|
+
const [inputValue, setInputValue] = useState(null);
|
|
203
|
+
const [inputId, setInputId] = useState(null);
|
|
201
204
|
const [activeOption, setActiveOption] = useState(0);
|
|
202
205
|
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
203
206
|
const [showOptions, setShowOptions] = useState(false);
|
|
204
|
-
const parseOptionsData = jsonOptionsData
|
|
207
|
+
const parseOptionsData = jsonOptionsData ? JSON.parse(jsonOptionsData).sort() : [];
|
|
208
|
+
const parseSelectedOptionsData = jsonSelectedOptionsData ? JSON.parse(jsonSelectedOptionsData) : {};
|
|
205
209
|
const handleChange = e => {
|
|
206
210
|
const currentInputValue = e.currentTarget.value;
|
|
207
|
-
|
|
211
|
+
setInputId(null);
|
|
212
|
+
const filteredOptions = parseOptionsData.filter(optionName => optionName[keyNames.name].toLowerCase().indexOf(currentInputValue.toLowerCase()) > -1);
|
|
208
213
|
setInputValue(currentInputValue);
|
|
209
214
|
setActiveOption(0);
|
|
210
215
|
setFilteredOptions(filteredOptions);
|
|
@@ -212,9 +217,14 @@ const Autocomplate = ({
|
|
|
212
217
|
};
|
|
213
218
|
const handleClick = e => {
|
|
214
219
|
setInputValue(e.currentTarget.innerText);
|
|
220
|
+
setInputId();
|
|
215
221
|
setActiveOption(0);
|
|
216
222
|
setFilteredOptions([]);
|
|
217
223
|
setShowOptions(false);
|
|
224
|
+
onChange({
|
|
225
|
+
name: e.currentTarget.innerText,
|
|
226
|
+
id: e.target.id
|
|
227
|
+
});
|
|
218
228
|
};
|
|
219
229
|
let optionList;
|
|
220
230
|
if (showOptions && inputValue) {
|
|
@@ -230,11 +240,12 @@ const Autocomplate = ({
|
|
|
230
240
|
}
|
|
231
241
|
return /*#__PURE__*/React.createElement("div", {
|
|
232
242
|
className: styles$7[className],
|
|
233
|
-
key: optionName,
|
|
243
|
+
key: optionName[keyNames.id],
|
|
234
244
|
onClick: handleClick
|
|
235
245
|
}, /*#__PURE__*/React.createElement("div", {
|
|
246
|
+
id: optionName[keyNames.id],
|
|
236
247
|
className: styles$7['autocomplate-content-bottom-row']
|
|
237
|
-
}, optionName));
|
|
248
|
+
}, optionName[keyNames.name]));
|
|
238
249
|
})));
|
|
239
250
|
} else {
|
|
240
251
|
optionList = /*#__PURE__*/React.createElement("div", {
|
|
@@ -253,13 +264,14 @@ const Autocomplate = ({
|
|
|
253
264
|
}, label) : "", /*#__PURE__*/React.createElement("div", {
|
|
254
265
|
className: styles$7['autocomplate-content']
|
|
255
266
|
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
267
|
+
id: inputId,
|
|
256
268
|
type: "text",
|
|
257
269
|
className: styles$7['autocomplate-content-top'],
|
|
258
270
|
required: required,
|
|
259
271
|
disabled: disabled,
|
|
260
272
|
onChange: handleChange,
|
|
261
|
-
value: inputValue,
|
|
262
|
-
placeholder: "Write..."
|
|
273
|
+
value: inputValue != null ? inputValue : parseSelectedOptionsData[keyNames.name],
|
|
274
|
+
placeholder: !parseSelectedOptionsData[keyNames.name] ? " Write..." : ''
|
|
263
275
|
}, props)), optionList));
|
|
264
276
|
};
|
|
265
277
|
Autocomplate.propTypes = {
|
|
@@ -268,13 +280,11 @@ Autocomplate.propTypes = {
|
|
|
268
280
|
required: PropTypes.bool,
|
|
269
281
|
disabled: PropTypes.bool,
|
|
270
282
|
jsonOptionsData: PropTypes.string,
|
|
283
|
+
jsonSelectedOptionsData: PropTypes.string,
|
|
271
284
|
onChange: PropTypes.func,
|
|
272
285
|
value: PropTypes.string,
|
|
273
|
-
searchCount: PropTypes.number
|
|
274
|
-
|
|
275
|
-
Autocomplate.defaultProps = {
|
|
276
|
-
jsonOptionsData: '["Tigran", "Tigran Aleksanyan", "Tigarn Aleksanyan Yerevan"]',
|
|
277
|
-
searchCount: 2
|
|
286
|
+
searchCount: PropTypes.number,
|
|
287
|
+
keyNames: PropTypes.object
|
|
278
288
|
};
|
|
279
289
|
|
|
280
290
|
var css_248z$7 = ".checkbox-module_checkbox-wrap__Xrg-m{align-items:center;cursor:pointer;display:inline-flex;flex-direction:row;flex-wrap:nowrap;margin:0 6px;padding-left:24px;position:relative}.checkbox-module_checkbox-wrap__Xrg-m>input{height:0;opacity:0;position:absolute;width:0}.checkbox-module_checkbox-wrap__Xrg-m .checkbox-module_checkmark__M8DY6{border:1px solid #d9d9d9;border-radius:3px;display:inline-block;height:14px;left:0;margin-right:4px;position:absolute;top:0;transition:border-color .24s;vertical-align:top;width:14px}.checkbox-module_checkbox-wrap__Xrg-m>.checkbox-module_checkmark__M8DY6:after{border:solid #1890ff;border-width:0 2px 2px 0;content:\"\";display:block;height:8px;left:4px;opacity:0;position:absolute;top:1px;transform:rotate(45deg);transition:opacity .24s;width:4px}.checkbox-module_checkbox-wrap__Xrg-m input:checked~.checkbox-module_checkmark__M8DY6:after{opacity:1}.checkbox-module_checkbox-wrap__Xrg-m input:checked~.checkbox-module_checkmark__M8DY6,.checkbox-module_checkbox-wrap__Xrg-m:hover input~.checkbox-module_checkmark__M8DY6{border-color:#1890ff}";
|
|
@@ -397,6 +407,9 @@ const Input = ({
|
|
|
397
407
|
setInputValue(event.target.value);
|
|
398
408
|
onChange ? onChange(event.target.value) : '';
|
|
399
409
|
};
|
|
410
|
+
useEffect(() => {
|
|
411
|
+
setInputValue(value);
|
|
412
|
+
}, [value]);
|
|
400
413
|
let eMessage = "";
|
|
401
414
|
if (errorMesage) {
|
|
402
415
|
eMessage = errorMesage;
|
|
@@ -783,9 +796,12 @@ const Select = ({
|
|
|
783
796
|
selected
|
|
784
797
|
}) => {
|
|
785
798
|
const options = jsonData.length ? JSON.parse(jsonData) : [];
|
|
786
|
-
const parseSelectedData = selected.length !== 0 ? JSON.parse(selected) : {};
|
|
787
799
|
let [opened, setOpened] = useState(false);
|
|
788
|
-
let [newSelected, setNewSelected] = useState(
|
|
800
|
+
let [newSelected, setNewSelected] = useState({});
|
|
801
|
+
useEffect(() => {
|
|
802
|
+
const parseSelectedData = selected.length !== 0 ? JSON.parse(selected) : {};
|
|
803
|
+
setNewSelected(parseSelectedData);
|
|
804
|
+
}, [selected]);
|
|
789
805
|
classnames(styles[theme], styles[size], {
|
|
790
806
|
[styles.disabled]: disabled,
|
|
791
807
|
[styles.required]: required
|
package/dist/index.js
CHANGED
|
@@ -202,20 +202,25 @@ const Autocomplate = ({
|
|
|
202
202
|
required,
|
|
203
203
|
disabled,
|
|
204
204
|
jsonOptionsData,
|
|
205
|
+
jsonSelectedOptionsData,
|
|
205
206
|
onChange,
|
|
206
207
|
value,
|
|
207
208
|
searchCount,
|
|
209
|
+
keyNames,
|
|
208
210
|
...props
|
|
209
211
|
}) => {
|
|
210
212
|
classnames__default["default"](styles$7.searchBox, className);
|
|
211
|
-
const [inputValue, setInputValue] = React.useState(
|
|
213
|
+
const [inputValue, setInputValue] = React.useState(null);
|
|
214
|
+
const [inputId, setInputId] = React.useState(null);
|
|
212
215
|
const [activeOption, setActiveOption] = React.useState(0);
|
|
213
216
|
const [filteredOptions, setFilteredOptions] = React.useState([]);
|
|
214
217
|
const [showOptions, setShowOptions] = React.useState(false);
|
|
215
|
-
const parseOptionsData = jsonOptionsData
|
|
218
|
+
const parseOptionsData = jsonOptionsData ? JSON.parse(jsonOptionsData).sort() : [];
|
|
219
|
+
const parseSelectedOptionsData = jsonSelectedOptionsData ? JSON.parse(jsonSelectedOptionsData) : {};
|
|
216
220
|
const handleChange = e => {
|
|
217
221
|
const currentInputValue = e.currentTarget.value;
|
|
218
|
-
|
|
222
|
+
setInputId(null);
|
|
223
|
+
const filteredOptions = parseOptionsData.filter(optionName => optionName[keyNames.name].toLowerCase().indexOf(currentInputValue.toLowerCase()) > -1);
|
|
219
224
|
setInputValue(currentInputValue);
|
|
220
225
|
setActiveOption(0);
|
|
221
226
|
setFilteredOptions(filteredOptions);
|
|
@@ -223,9 +228,14 @@ const Autocomplate = ({
|
|
|
223
228
|
};
|
|
224
229
|
const handleClick = e => {
|
|
225
230
|
setInputValue(e.currentTarget.innerText);
|
|
231
|
+
setInputId();
|
|
226
232
|
setActiveOption(0);
|
|
227
233
|
setFilteredOptions([]);
|
|
228
234
|
setShowOptions(false);
|
|
235
|
+
onChange({
|
|
236
|
+
name: e.currentTarget.innerText,
|
|
237
|
+
id: e.target.id
|
|
238
|
+
});
|
|
229
239
|
};
|
|
230
240
|
let optionList;
|
|
231
241
|
if (showOptions && inputValue) {
|
|
@@ -241,11 +251,12 @@ const Autocomplate = ({
|
|
|
241
251
|
}
|
|
242
252
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
243
253
|
className: styles$7[className],
|
|
244
|
-
key: optionName,
|
|
254
|
+
key: optionName[keyNames.id],
|
|
245
255
|
onClick: handleClick
|
|
246
256
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
257
|
+
id: optionName[keyNames.id],
|
|
247
258
|
className: styles$7['autocomplate-content-bottom-row']
|
|
248
|
-
}, optionName));
|
|
259
|
+
}, optionName[keyNames.name]));
|
|
249
260
|
})));
|
|
250
261
|
} else {
|
|
251
262
|
optionList = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -264,13 +275,14 @@ const Autocomplate = ({
|
|
|
264
275
|
}, label) : "", /*#__PURE__*/React__default["default"].createElement("div", {
|
|
265
276
|
className: styles$7['autocomplate-content']
|
|
266
277
|
}, /*#__PURE__*/React__default["default"].createElement("input", _extends({
|
|
278
|
+
id: inputId,
|
|
267
279
|
type: "text",
|
|
268
280
|
className: styles$7['autocomplate-content-top'],
|
|
269
281
|
required: required,
|
|
270
282
|
disabled: disabled,
|
|
271
283
|
onChange: handleChange,
|
|
272
|
-
value: inputValue,
|
|
273
|
-
placeholder: "Write..."
|
|
284
|
+
value: inputValue != null ? inputValue : parseSelectedOptionsData[keyNames.name],
|
|
285
|
+
placeholder: !parseSelectedOptionsData[keyNames.name] ? " Write..." : ''
|
|
274
286
|
}, props)), optionList));
|
|
275
287
|
};
|
|
276
288
|
Autocomplate.propTypes = {
|
|
@@ -279,13 +291,11 @@ Autocomplate.propTypes = {
|
|
|
279
291
|
required: PropTypes__default["default"].bool,
|
|
280
292
|
disabled: PropTypes__default["default"].bool,
|
|
281
293
|
jsonOptionsData: PropTypes__default["default"].string,
|
|
294
|
+
jsonSelectedOptionsData: PropTypes__default["default"].string,
|
|
282
295
|
onChange: PropTypes__default["default"].func,
|
|
283
296
|
value: PropTypes__default["default"].string,
|
|
284
|
-
searchCount: PropTypes__default["default"].number
|
|
285
|
-
|
|
286
|
-
Autocomplate.defaultProps = {
|
|
287
|
-
jsonOptionsData: '["Tigran", "Tigran Aleksanyan", "Tigarn Aleksanyan Yerevan"]',
|
|
288
|
-
searchCount: 2
|
|
297
|
+
searchCount: PropTypes__default["default"].number,
|
|
298
|
+
keyNames: PropTypes__default["default"].object
|
|
289
299
|
};
|
|
290
300
|
|
|
291
301
|
var css_248z$7 = ".checkbox-module_checkbox-wrap__Xrg-m{align-items:center;cursor:pointer;display:inline-flex;flex-direction:row;flex-wrap:nowrap;margin:0 6px;padding-left:24px;position:relative}.checkbox-module_checkbox-wrap__Xrg-m>input{height:0;opacity:0;position:absolute;width:0}.checkbox-module_checkbox-wrap__Xrg-m .checkbox-module_checkmark__M8DY6{border:1px solid #d9d9d9;border-radius:3px;display:inline-block;height:14px;left:0;margin-right:4px;position:absolute;top:0;transition:border-color .24s;vertical-align:top;width:14px}.checkbox-module_checkbox-wrap__Xrg-m>.checkbox-module_checkmark__M8DY6:after{border:solid #1890ff;border-width:0 2px 2px 0;content:\"\";display:block;height:8px;left:4px;opacity:0;position:absolute;top:1px;transform:rotate(45deg);transition:opacity .24s;width:4px}.checkbox-module_checkbox-wrap__Xrg-m input:checked~.checkbox-module_checkmark__M8DY6:after{opacity:1}.checkbox-module_checkbox-wrap__Xrg-m input:checked~.checkbox-module_checkmark__M8DY6,.checkbox-module_checkbox-wrap__Xrg-m:hover input~.checkbox-module_checkmark__M8DY6{border-color:#1890ff}";
|
|
@@ -408,6 +418,9 @@ const Input = ({
|
|
|
408
418
|
setInputValue(event.target.value);
|
|
409
419
|
onChange ? onChange(event.target.value) : '';
|
|
410
420
|
};
|
|
421
|
+
React.useEffect(() => {
|
|
422
|
+
setInputValue(value);
|
|
423
|
+
}, [value]);
|
|
411
424
|
let eMessage = "";
|
|
412
425
|
if (errorMesage) {
|
|
413
426
|
eMessage = errorMesage;
|
|
@@ -794,9 +807,12 @@ const Select = ({
|
|
|
794
807
|
selected
|
|
795
808
|
}) => {
|
|
796
809
|
const options = jsonData.length ? JSON.parse(jsonData) : [];
|
|
797
|
-
const parseSelectedData = selected.length !== 0 ? JSON.parse(selected) : {};
|
|
798
810
|
let [opened, setOpened] = React.useState(false);
|
|
799
|
-
let [newSelected, setNewSelected] = React.useState(
|
|
811
|
+
let [newSelected, setNewSelected] = React.useState({});
|
|
812
|
+
React.useEffect(() => {
|
|
813
|
+
const parseSelectedData = selected.length !== 0 ? JSON.parse(selected) : {};
|
|
814
|
+
setNewSelected(parseSelectedData);
|
|
815
|
+
}, [selected]);
|
|
800
816
|
classnames__default["default"](styles[theme], styles[size], {
|
|
801
817
|
[styles.disabled]: disabled,
|
|
802
818
|
[styles.required]: required
|
package/package.json
CHANGED
|
@@ -9,3 +9,15 @@ export default {
|
|
|
9
9
|
const Template = (args) => <Autocomplate {...args} />;
|
|
10
10
|
|
|
11
11
|
export const Default = Template.bind({});
|
|
12
|
+
Default.args = {
|
|
13
|
+
jsonOptionsData: '[{"bbb":"0", "value":"asd"}, {"bbb":"2", "value":"bas"}]',
|
|
14
|
+
// jsonSelectedOptionsData: '{"bbb":"0", "value":"asd"}',
|
|
15
|
+
label: 'label',
|
|
16
|
+
keyNames: { name: 'value', id: 'bbb' },
|
|
17
|
+
searchCount: 2,
|
|
18
|
+
onChange(aa){
|
|
19
|
+
console.log(aa);
|
|
20
|
+
// console.log(aa.id);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
};
|
|
@@ -9,37 +9,44 @@ export const Autocomplate = ({
|
|
|
9
9
|
required,
|
|
10
10
|
disabled,
|
|
11
11
|
jsonOptionsData,
|
|
12
|
+
jsonSelectedOptionsData,
|
|
12
13
|
onChange,
|
|
13
14
|
value,
|
|
14
15
|
searchCount,
|
|
16
|
+
keyNames,
|
|
15
17
|
...props
|
|
16
18
|
}) => {
|
|
17
19
|
const classProps = classnames(styles.searchBox, className);
|
|
18
|
-
const [inputValue, setInputValue] = useState(
|
|
20
|
+
const [inputValue, setInputValue] = useState(null);
|
|
21
|
+
const [inputId, setInputId] = useState(null);
|
|
19
22
|
const [activeOption, setActiveOption] = useState(0);
|
|
20
23
|
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
21
24
|
const [showOptions, setShowOptions] = useState(false);
|
|
22
|
-
|
|
23
25
|
const parseOptionsData =
|
|
24
|
-
jsonOptionsData
|
|
26
|
+
jsonOptionsData? JSON.parse(jsonOptionsData).sort() : [];
|
|
27
|
+
const parseSelectedOptionsData =
|
|
28
|
+
jsonSelectedOptionsData ? JSON.parse(jsonSelectedOptionsData) : {};
|
|
29
|
+
|
|
25
30
|
const handleChange = (e) => {
|
|
26
31
|
const currentInputValue = e.currentTarget.value;
|
|
27
|
-
|
|
32
|
+
setInputId(null)
|
|
28
33
|
const filteredOptions = parseOptionsData.filter(
|
|
29
34
|
(optionName) =>
|
|
30
|
-
optionName.toLowerCase().indexOf(currentInputValue.toLowerCase()) > -1
|
|
35
|
+
optionName[keyNames.name].toLowerCase().indexOf(currentInputValue.toLowerCase()) > -1
|
|
31
36
|
);
|
|
32
|
-
|
|
33
37
|
setInputValue(currentInputValue);
|
|
34
38
|
setActiveOption(0);
|
|
35
39
|
setFilteredOptions(filteredOptions);
|
|
36
|
-
setShowOptions(true);
|
|
40
|
+
setShowOptions(true);
|
|
37
41
|
};
|
|
38
42
|
const handleClick = (e) => {
|
|
39
43
|
setInputValue(e.currentTarget.innerText);
|
|
44
|
+
setInputId()
|
|
40
45
|
setActiveOption(0);
|
|
41
46
|
setFilteredOptions([]);
|
|
42
47
|
setShowOptions(false);
|
|
48
|
+
onChange({name: e.currentTarget.innerText, id: e.target.id});
|
|
49
|
+
|
|
43
50
|
};
|
|
44
51
|
let optionList;
|
|
45
52
|
if (showOptions && inputValue) {
|
|
@@ -55,10 +62,10 @@ export const Autocomplate = ({
|
|
|
55
62
|
return (
|
|
56
63
|
<div
|
|
57
64
|
className={styles[className]}
|
|
58
|
-
key={optionName}
|
|
65
|
+
key={optionName[keyNames.id]}
|
|
59
66
|
onClick={handleClick}
|
|
60
67
|
>
|
|
61
|
-
<div className={styles['autocomplate-content-bottom-row']}>{optionName}</div>
|
|
68
|
+
<div id={optionName[keyNames.id]} className={styles['autocomplate-content-bottom-row']}>{optionName[keyNames.name]}</div>
|
|
62
69
|
</div>
|
|
63
70
|
);
|
|
64
71
|
})}
|
|
@@ -85,13 +92,14 @@ export const Autocomplate = ({
|
|
|
85
92
|
{label ? <label className={styles.labelInput}>{label}</label> : ""}
|
|
86
93
|
<div className={styles['autocomplate-content']}>
|
|
87
94
|
<input
|
|
95
|
+
id={inputId}
|
|
88
96
|
type="text"
|
|
89
97
|
className={styles['autocomplate-content-top']}
|
|
90
98
|
required={required}
|
|
91
99
|
disabled={disabled}
|
|
92
100
|
onChange={handleChange}
|
|
93
|
-
value={inputValue}
|
|
94
|
-
placeholder="Write..."
|
|
101
|
+
value={inputValue != null ? inputValue : parseSelectedOptionsData[keyNames.name]}
|
|
102
|
+
placeholder= {!parseSelectedOptionsData[keyNames.name] ?" Write..." : ''}
|
|
95
103
|
{...props}
|
|
96
104
|
/>
|
|
97
105
|
{optionList}
|
|
@@ -106,12 +114,11 @@ Autocomplate.propTypes = {
|
|
|
106
114
|
required: PropTypes.bool,
|
|
107
115
|
disabled: PropTypes.bool,
|
|
108
116
|
jsonOptionsData: PropTypes.string,
|
|
117
|
+
jsonSelectedOptionsData: PropTypes.string,
|
|
109
118
|
onChange: PropTypes.func,
|
|
110
119
|
value: PropTypes.string,
|
|
111
120
|
searchCount: PropTypes.number,
|
|
121
|
+
keyNames: PropTypes.object,
|
|
112
122
|
};
|
|
113
123
|
|
|
114
|
-
|
|
115
|
-
jsonOptionsData: '["Tigran", "Tigran Aleksanyan", "Tigarn Aleksanyan Yerevan"]',
|
|
116
|
-
searchCount: 2,
|
|
117
|
-
};
|
|
124
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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 "./input.module.css";
|
|
@@ -38,6 +38,10 @@ export const Input = ({
|
|
|
38
38
|
onChange ? onChange(event.target.value) : '';
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
useEffect(()=>{
|
|
42
|
+
setInputValue(value)
|
|
43
|
+
},[value])
|
|
44
|
+
|
|
41
45
|
let eMessage = "";
|
|
42
46
|
if (errorMesage) {
|
|
43
47
|
eMessage = errorMesage;
|
|
@@ -19,18 +19,23 @@ export const Multiselect = ({
|
|
|
19
19
|
return (
|
|
20
20
|
<div className={styles.main}>
|
|
21
21
|
{label ? <label className={styles['multi-select-title']}>վարչական շրջան <span>*</span></label> : ""}
|
|
22
|
-
<div className={styles['multi-select-content-top']} onClick={()=>{setOpened(!opened)}}>
|
|
22
|
+
<div className={styles['multi-select-content-top']} onClick={() => { setOpened(!opened) }}>
|
|
23
23
|
{
|
|
24
24
|
options.map((option, i) => {
|
|
25
25
|
return (<div className={styles['multi-select-content-bottom-row']} key={option[keyNames.id]}>
|
|
26
26
|
<div id={option[keyNames.id]}>{option[keyNames.name]}</div>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
<div
|
|
28
|
+
onClick={() => {
|
|
29
|
+
options.splice(i, 1);
|
|
30
|
+
setOptions(options);
|
|
31
|
+
setValues([...values, option]);
|
|
32
|
+
setSearchedOptions([...values, option]);
|
|
33
|
+
setOpened(true);
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<Icon className='icon-close' />
|
|
37
|
+
</div>
|
|
38
|
+
|
|
34
39
|
</div>)
|
|
35
40
|
})
|
|
36
41
|
}
|
|
@@ -41,33 +46,33 @@ export const Multiselect = ({
|
|
|
41
46
|
}) : searchedOptions)
|
|
42
47
|
|
|
43
48
|
|
|
44
|
-
}}
|
|
49
|
+
}} className={styles.input} type='text' />
|
|
45
50
|
<div className={styles['select-content-top-icon']}>
|
|
46
|
-
<Icon className={opened ? 'icon-arrow-up' : 'icon-arrow-down'}/>
|
|
51
|
+
<Icon className={opened ? 'icon-arrow-up' : 'icon-arrow-down'} />
|
|
47
52
|
</div>
|
|
48
53
|
</div>
|
|
49
54
|
{
|
|
50
55
|
|
|
51
56
|
opened ? <div className={styles['multi-select-content-bottom']} onClick={onchange}>
|
|
52
57
|
<div className={styles['multi-select-content-bottom-inner']}>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
{
|
|
59
|
+
values.length ?
|
|
60
|
+
values.map((value, i) => {
|
|
61
|
+
return (<div
|
|
62
|
+
className={styles['multi-select-content-bottom-row']}
|
|
63
|
+
key={value[keyNames.id]}
|
|
64
|
+
id={value.id}
|
|
65
|
+
onClick={(e) => {
|
|
66
|
+
setOptions([...options, { [keyNames.name]: value[keyNames.name], [keyNames.id]: value[keyNames.id] }])
|
|
67
|
+
values.splice(i, 1);
|
|
68
|
+
setValues(values);
|
|
69
|
+
setSearchedOptions(values);
|
|
70
|
+
}}>
|
|
71
|
+
{value[keyNames.name]}
|
|
72
|
+
</div>)
|
|
73
|
+
}) :
|
|
74
|
+
<div className={styles['no-elements']}>No Elements!</div>
|
|
75
|
+
}
|
|
71
76
|
</div>
|
|
72
77
|
</div> : null
|
|
73
78
|
}
|
|
@@ -36,10 +36,18 @@ export const Select = ({
|
|
|
36
36
|
selected
|
|
37
37
|
}) => {
|
|
38
38
|
const options = jsonData.length ? JSON.parse(jsonData) : [];
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
41
42
|
let [opened, setOpened] = useState(false)
|
|
42
|
-
let [newSelected, setNewSelected] = useState(
|
|
43
|
+
let [newSelected, setNewSelected] = useState({})
|
|
44
|
+
|
|
45
|
+
useEffect(()=>{
|
|
46
|
+
const parseSelectedData =
|
|
47
|
+
selected.length !== 0 ? JSON.parse(selected) : {};
|
|
48
|
+
setNewSelected(parseSelectedData);
|
|
49
|
+
},[selected])
|
|
50
|
+
|
|
43
51
|
const classProps = classnames(
|
|
44
52
|
styles[theme],
|
|
45
53
|
styles[size],
|