@xaypay/tui 0.0.20 → 0.0.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.es.js +29 -14
- package/dist/index.js +29 -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/checkbox/index.js +8 -2
- package/src/components/multiselect/index.js +33 -28
package/dist/index.es.js
CHANGED
|
@@ -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(e.target.id);
|
|
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}";
|
|
@@ -291,11 +301,15 @@ const Checkbox = ({
|
|
|
291
301
|
onChange,
|
|
292
302
|
label,
|
|
293
303
|
keyNames,
|
|
304
|
+
onClick,
|
|
294
305
|
...props
|
|
295
306
|
}) => {
|
|
296
307
|
const classProps = classnames(styles$6.checkbox, className);
|
|
297
308
|
const parseData = jsonData.length !== 0 ? JSON.parse(jsonData) : [];
|
|
298
309
|
const [data, setData] = useState(parseData);
|
|
310
|
+
const handleClick = e => {
|
|
311
|
+
onClick(e);
|
|
312
|
+
};
|
|
299
313
|
const handleChange = e => {
|
|
300
314
|
if (e.target.checked) {
|
|
301
315
|
data.forEach(item => {
|
|
@@ -324,7 +338,8 @@ const Checkbox = ({
|
|
|
324
338
|
required: required,
|
|
325
339
|
value: value ? value : element.value,
|
|
326
340
|
name: name ? name : element.name,
|
|
327
|
-
onChange: handleChange
|
|
341
|
+
onChange: handleChange,
|
|
342
|
+
onClick: handleClick
|
|
328
343
|
}, props)), /*#__PURE__*/React.createElement("span", {
|
|
329
344
|
className: styles$6["checkmark"]
|
|
330
345
|
}), element.label ? /*#__PURE__*/React.createElement("span", {
|
|
@@ -341,7 +356,7 @@ Checkbox.propTypes = {
|
|
|
341
356
|
value: PropTypes.string,
|
|
342
357
|
jsonData: PropTypes.string,
|
|
343
358
|
label: PropTypes.string,
|
|
344
|
-
|
|
359
|
+
onClick: PropTypes.func,
|
|
345
360
|
keyNames: PropTypes.object
|
|
346
361
|
};
|
|
347
362
|
Checkbox.defaultProps = {
|
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(e.target.id);
|
|
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}";
|
|
@@ -302,11 +312,15 @@ const Checkbox = ({
|
|
|
302
312
|
onChange,
|
|
303
313
|
label,
|
|
304
314
|
keyNames,
|
|
315
|
+
onClick,
|
|
305
316
|
...props
|
|
306
317
|
}) => {
|
|
307
318
|
const classProps = classnames__default["default"](styles$6.checkbox, className);
|
|
308
319
|
const parseData = jsonData.length !== 0 ? JSON.parse(jsonData) : [];
|
|
309
320
|
const [data, setData] = React.useState(parseData);
|
|
321
|
+
const handleClick = e => {
|
|
322
|
+
onClick(e);
|
|
323
|
+
};
|
|
310
324
|
const handleChange = e => {
|
|
311
325
|
if (e.target.checked) {
|
|
312
326
|
data.forEach(item => {
|
|
@@ -335,7 +349,8 @@ const Checkbox = ({
|
|
|
335
349
|
required: required,
|
|
336
350
|
value: value ? value : element.value,
|
|
337
351
|
name: name ? name : element.name,
|
|
338
|
-
onChange: handleChange
|
|
352
|
+
onChange: handleChange,
|
|
353
|
+
onClick: handleClick
|
|
339
354
|
}, props)), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
340
355
|
className: styles$6["checkmark"]
|
|
341
356
|
}), element.label ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -352,7 +367,7 @@ Checkbox.propTypes = {
|
|
|
352
367
|
value: PropTypes__default["default"].string,
|
|
353
368
|
jsonData: PropTypes__default["default"].string,
|
|
354
369
|
label: PropTypes__default["default"].string,
|
|
355
|
-
|
|
370
|
+
onClick: PropTypes__default["default"].func,
|
|
356
371
|
keyNames: PropTypes__default["default"].object
|
|
357
372
|
};
|
|
358
373
|
Checkbox.defaultProps = {
|
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(e.target.id)
|
|
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
|
+
|
|
@@ -13,12 +13,17 @@ export const Checkbox = ({
|
|
|
13
13
|
onChange,
|
|
14
14
|
label,
|
|
15
15
|
keyNames,
|
|
16
|
+
onClick,
|
|
16
17
|
...props
|
|
17
18
|
}) => {
|
|
18
19
|
const classProps = classNames(styles.checkbox, className);
|
|
19
20
|
const parseData = jsonData.length !== 0 ? JSON.parse(jsonData) : [];
|
|
20
21
|
const [data, setData] = useState(parseData);
|
|
21
22
|
|
|
23
|
+
const handleClick = (e) => {
|
|
24
|
+
onClick(e)
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
const handleChange = (e) => {
|
|
23
28
|
if (e.target.checked) {
|
|
24
29
|
data.forEach((item) => {
|
|
@@ -50,9 +55,10 @@ export const Checkbox = ({
|
|
|
50
55
|
value={value ? value : element.value}
|
|
51
56
|
name={name ? name : element.name}
|
|
52
57
|
onChange={handleChange}
|
|
58
|
+
onClick={handleClick}
|
|
53
59
|
{...props}
|
|
54
60
|
/>
|
|
55
|
-
<span className={styles["checkmark"]}/>
|
|
61
|
+
<span className={styles["checkmark"]} />
|
|
56
62
|
{element.label ? (
|
|
57
63
|
<span className={styles.labelRadio}>
|
|
58
64
|
{label ? label : element.label}
|
|
@@ -76,7 +82,7 @@ Checkbox.propTypes = {
|
|
|
76
82
|
value: PropTypes.string,
|
|
77
83
|
jsonData: PropTypes.string,
|
|
78
84
|
label: PropTypes.string,
|
|
79
|
-
|
|
85
|
+
onClick: PropTypes.func,
|
|
80
86
|
keyNames: PropTypes.object,
|
|
81
87
|
};
|
|
82
88
|
|
|
@@ -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
|
}
|