@xaypay/tui 0.0.70 → 0.0.72

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.
Files changed (71) hide show
  1. package/dist/index.es.js +1009 -121
  2. package/dist/index.js +1009 -120
  3. package/package.json +3 -2
  4. package/src/components/autocomplate/autocomplate.stories.js +1 -1
  5. package/src/components/captcha/captcha.module.css +3 -3
  6. package/src/components/captcha/index.js +10 -7
  7. package/src/components/file/index.js +2 -3
  8. package/src/components/icon/Arrow.js +2 -2
  9. package/src/components/icon/CheckboxChecked.js +2 -2
  10. package/src/components/icon/CheckboxUnchecked.js +2 -2
  11. package/src/components/icon/CloseIcon.js +2 -2
  12. package/src/components/icon/DeleteComponent.js +20 -0
  13. package/src/components/icon/Dots.js +6 -6
  14. package/src/components/icon/ListItemDelete.js +19 -0
  15. package/src/components/icon/ListItemJpeg.js +21 -0
  16. package/src/components/icon/ListItemJpg.js +21 -0
  17. package/src/components/icon/ListItemPdf.js +21 -0
  18. package/src/components/icon/ListItemPng.js +21 -0
  19. package/src/components/icon/Nextarrow.js +19 -0
  20. package/src/components/icon/RangeArrowDefault.js +54 -0
  21. package/src/components/icon/RangeArrowError.js +54 -0
  22. package/src/components/icon/RangeArrowSuccess.js +54 -0
  23. package/src/components/icon/RemoveFile.js +20 -0
  24. package/src/components/icon/ToasterClose.js +2 -2
  25. package/src/components/icon/ToasterError.js +2 -2
  26. package/src/components/icon/ToasterInfo.js +2 -2
  27. package/src/components/icon/ToasterSuccess.js +2 -2
  28. package/src/components/icon/ToasterWarning.js +2 -2
  29. package/src/components/icon/Tooltip.js +2 -2
  30. package/src/components/icon/Upload.js +25 -0
  31. package/src/components/icon/index.js +2 -15
  32. package/src/components/input/index.js +49 -37
  33. package/src/components/input/input.stories.js +11 -5
  34. package/src/components/newAutocomplete/NewAutocomplete.stories.js +26 -26
  35. package/src/components/newAutocomplete/index.js +113 -92
  36. package/src/components/newFile/fileItem.js +213 -0
  37. package/src/components/newFile/index.js +488 -0
  38. package/src/components/newFile/newFile.stories.js +44 -0
  39. package/src/components/pagination/index.js +5 -5
  40. package/src/components/textarea/index.js +93 -28
  41. package/src/components/textarea/textarea.stories.js +3 -3
  42. package/src/components/toaster/Toast.js +1 -1
  43. package/src/components/tooltip/index.js +2 -2
  44. package/src/index.js +1 -0
  45. package/src/stories/configuration.stories.mdx +43 -0
  46. package/src/stories/static/autocomplete-usage.png +0 -0
  47. package/src/stories/static/file-single-usage.png +0 -0
  48. package/src/stories/static/file-usage.png +0 -0
  49. package/src/stories/static/input-usage.png +0 -0
  50. package/src/stories/static/tooltip-usage.png +0 -0
  51. package/src/stories/usage.stories.mdx +17 -8
  52. package/tui.config.js +41 -0
  53. package/src/assets/icons/arrow.svg +0 -3
  54. package/src/assets/icons/checkbox-checked.svg +0 -3
  55. package/src/assets/icons/checkbox-unchecked.svg +0 -3
  56. package/src/assets/icons/close-icon.svg +0 -3
  57. package/src/assets/icons/dots.svg +0 -3
  58. package/src/assets/icons/nextarrow.svg +0 -3
  59. package/src/assets/icons/toaster-close.svg +0 -3
  60. package/src/assets/icons/toaster-error.svg +0 -3
  61. package/src/assets/icons/toaster-info.svg +0 -3
  62. package/src/assets/icons/toaster-success.svg +0 -3
  63. package/src/assets/icons/toaster-warning.svg +0 -3
  64. package/src/assets/icons/tooltip.svg +0 -3
  65. package/src/assets/upload.svg +0 -4
  66. package/src/components/icon/NextArrow.js +0 -19
  67. package/src/stories/static/input-tooltip-usage.png +0 -0
  68. package/src/stories/static/new-autocomplete-usage.png +0 -0
  69. /package/src/assets/{icons/range-arrow-default.svg → range-arrow-default.svg} +0 -0
  70. /package/src/assets/{icons/range-arrow-error.svg → range-arrow-error.svg} +0 -0
  71. /package/src/assets/{icons/range-arrow-success.svg → range-arrow-success.svg} +0 -0
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ const SvgUpload = ({ title, titleId, ...props }) => (
3
+ <svg
4
+ width="51"
5
+ height="35"
6
+ viewBox="0 0 51 35"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ aria-labelledby={titleId}
10
+ {...props}
11
+ >
12
+ {title ? <title id={titleId}>{title}</title> : null}
13
+ <path
14
+ d="M41.54 11.842h-.017c-.23-3.225-2.902-5.772-6.167-5.772-1.08 0-2.095.28-2.979.77C30.267 2.774 26.041 0 21.167 0 14.318 0 8.742 5.483 8.534 12.326 3.758 12.708 0 16.726 0 21.63c0 5.155 4.153 9.334 9.277 9.334h22.625a10.987 10.987 0 0 1-.888-4.334c0-6.059 4.899-10.987 10.918-10.987 3.773 0 7.106 1.938 9.068 4.875-.444-4.864-4.508-8.675-9.46-8.675ZM15.654 6.975c-.072.06-.144.12-.211.185-.266.259-.512.53-.705.849-.741 1.218-.882 2.523-.72 3.927.156 1.35-1.942 1.334-2.095 0-.289-2.493.504-5.307 2.664-6.775 1.12-.763 2.164 1.052 1.067 1.814Zm-.022.015c-.047.035-.111.093 0 0Z"
15
+ fill="#D1D1D1"
16
+ />
17
+ <path
18
+ fillRule="evenodd"
19
+ clipRule="evenodd"
20
+ d="M41.822 17.245c-4.864 0-8.822 3.982-8.822 8.878C33 31.018 36.958 35 41.822 35c4.864 0 8.822-3.982 8.822-8.877 0-4.896-3.959-8.878-8.822-8.878Zm-.536 13.005v-6.689l-3.067 3.22a.69.69 0 0 1-1.01 0 .777.777 0 0 1 0-1.06l4.286-4.5A.71.71 0 0 1 42 21a.684.684 0 0 1 .505.22l4.286 4.5a.777.777 0 0 1 0 1.06.69.69 0 0 1-1.01 0l-3.067-3.22v6.69c0 .414-.32.75-.714.75-.395 0-.714-.336-.714-.75Z"
21
+ fill="#0DA574"
22
+ />
23
+ </svg>
24
+ );
25
+ export default SvgUpload;
@@ -1,15 +1,2 @@
1
- export { default as Pdf } from './PDF';
2
- export { default as Dots } from './Dots';
3
- export { default as Arrow } from './Arrow';
4
- export { default as Tooltip } from './Tooltip';
5
- export { default as NextArrow } from './NextArrow';
6
- export { default as CloseIcon } from './CloseIcon';
7
- export { default as HeartFilled } from './HeartFilled';
8
- export { default as ToasterInfo } from './ToasterInfo';
9
- export { default as HeartOutline } from './HeartOutline';
10
- export { default as ToasterClose } from './ToasterClose';
11
- export { default as ToasterError } from './ToasterError';
12
- export { default as ToasterSuccess } from './ToasterSuccess';
13
- export { default as ToasterWarning } from './ToasterWarning';
14
- export { default as CheckboxChecked } from './CheckboxChecked';
15
- export { default as CheckboxUnchecked } from './CheckboxUnchecked';
1
+ export { default as Jpeg } from "./Jpeg";
2
+ export { default as Png } from "./Png";
@@ -12,6 +12,10 @@ export const InputTypes = {
12
12
  PASSWORD: "password",
13
13
  };
14
14
 
15
+ const P = styled.p`
16
+ animation: ${props => props.errorAnimation ? props.animation : 'none'};
17
+ `;
18
+
15
19
  export const Input = ({
16
20
  type,
17
21
  size,
@@ -23,12 +27,12 @@ export const Input = ({
23
27
  regexp,
24
28
  height,
25
29
  radius,
30
+ change,
26
31
  padding,
27
32
  tooltip,
28
33
  leftIcon,
29
34
  required,
30
35
  disabled,
31
- onChange,
32
36
  transform,
33
37
  iconWidth,
34
38
  rightIcon,
@@ -64,7 +68,7 @@ export const Input = ({
64
68
  errorAnimationDuration,
65
69
  ...props
66
70
  }) => {
67
- const phoneNumberRegex = /^\d{8}$/;
71
+ const phoneNumberRegex = /^\d+$/;
68
72
  const [show, setShow] = useState(false);
69
73
  const [isHover, setIsHover] = useState(false);
70
74
  const [innerValue, setInnerValue] = useState('');
@@ -91,42 +95,45 @@ export const Input = ({
91
95
  ${errorShow} ${errorAnimationDuration ? errorAnimationDuration : configStyles.INPUT.errorAnimationDuration} forwards
92
96
  `;
93
97
 
94
- const P = styled.p`
95
- animation: ${errorAnimation ? animation : 'none'};
96
- `;
97
-
98
98
  const handleChange = (event) => {
99
99
  const currentValue = event.target.value;
100
100
 
101
101
  setInnerValue(currentValue);
102
+ if (change) {
103
+ change(currentValue);
104
+ }
105
+
102
106
  if (type === 'tel') {
103
- if (currentValue.length > 8) {
104
- setInnerValue(currentValue.substr(0, 8));
105
- }
106
-
107
- if (!phoneNumberRegex.test(currentValue) && telErrorMessage) {
108
- setInnerErrorMessage(telErrorMessage);
107
+ if (!phoneNumberRegex.test(currentValue)) {
108
+ telErrorMessage && setInnerErrorMessage(telErrorMessage);
109
+ setInnerValue('');
109
110
  } else {
110
111
  setInnerErrorMessage('');
112
+ if (currentValue.length > 8) {
113
+ setInnerValue(currentValue.substr(0, 8));
114
+ if (change) {
115
+ change(currentValue.substr(0, 8));
116
+ }
117
+ } else {
118
+ setInnerValue(currentValue);
119
+ if (change) {
120
+ change(currentValue);
121
+ }
122
+ }
111
123
  }
112
124
  }
113
125
 
114
126
  if (maxLength && currentValue.length > maxLength && type !== 'tel') {
115
127
  setInnerValue(currentValue.substr(0, maxLength));
128
+ if (change) {
129
+ change(currentValue.substr(0, maxLength));
130
+ }
116
131
  }
117
132
 
118
133
  if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
119
- !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('')
120
- }
121
-
122
- if (onChange) {
123
- onChange(currentValue);
124
- if (type === 'tel' && currentValue.length > 8) {
125
- onChange(currentValue.substr(0, 8));
126
- }
127
-
128
- if (maxLength && currentValue.length > maxLength && type !== 'tel') {
129
- onChange(currentValue.substr(0, maxLength));
134
+ !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
135
+ if (change) {
136
+ change(currentValue);
130
137
  }
131
138
  }
132
139
  };
@@ -140,19 +147,27 @@ export const Input = ({
140
147
  };
141
148
 
142
149
  useEffect(() => {
150
+ if (errorMessage) {
151
+ setInnerErrorMessage(errorMessage);
152
+ } else {
153
+ setInnerErrorMessage('');
154
+ }
155
+
143
156
  if (value !== undefined && value !== null) {
144
157
  setInnerValue(value);
145
158
  if (type === 'tel') {
146
- if (value.length > 8) {
147
- setInnerValue(value.substr(0, 8));
148
- }
149
-
150
- if (!phoneNumberRegex.test(value) && telErrorMessage) {
151
- setInnerErrorMessage(telErrorMessage);
159
+ if (!phoneNumberRegex.test(value)) {
160
+ telErrorMessage && setInnerErrorMessage(telErrorMessage);
161
+ setInnerValue('');
152
162
  } else {
153
163
  setInnerErrorMessage('');
164
+ if (value.length > 8) {
165
+ setInnerValue(value.substr(0, 8));
166
+ } else {
167
+ setInnerValue(value);
168
+ }
154
169
  }
155
- }
170
+ }
156
171
 
157
172
  if (maxLength && value.length > maxLength && type !== 'tel') {
158
173
  setInnerValue(value.substr(0, maxLength));
@@ -162,12 +177,6 @@ export const Input = ({
162
177
  !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('')
163
178
  }
164
179
  }
165
-
166
- if (errorMessage) {
167
- setInnerErrorMessage(errorMessage);
168
- } else {
169
- setInnerErrorMessage('');
170
- }
171
180
  }, [type, value, regexp, maxLength, errorMessage, regexpErrorMessage]);
172
181
 
173
182
  return (
@@ -291,7 +300,10 @@ export const Input = ({
291
300
  {
292
301
  innerErrorMessage ?
293
302
  <P
303
+ errorAnimation={errorAnimation}
304
+ animation={animation}
294
305
  style={{
306
+ margin: '0px',
295
307
  left: errorLeft ? errorLeft : configStyles.INPUT.errorLeft,
296
308
  color: errorColor ? errorColor : configStyles.INPUT.errorColor,
297
309
  fontSize: errorSize ? errorSize : configStyles.INPUT.errorSize,
@@ -313,11 +325,11 @@ export const Input = ({
313
325
 
314
326
  Input.propTypes = {
315
327
  name: PropTypes.string,
328
+ change: PropTypes.func,
316
329
  color: PropTypes.string,
317
330
  value: PropTypes.string,
318
331
  width: PropTypes.string,
319
332
  label: PropTypes.string,
320
- onChange: PropTypes.func,
321
333
  required: PropTypes.bool,
322
334
  disabled: PropTypes.bool,
323
335
  height: PropTypes.string,
@@ -1,21 +1,27 @@
1
- import React from "react";
1
+ import React, { useState } from "react";
2
2
  import { Input, InputTypes } from "./index";
3
3
 
4
4
  export default {
5
5
  component: Input,
6
6
  title: "Components/Input",
7
7
  argsType: {
8
- onChange: {
8
+ change: {
9
9
  control: { type: 'function' }
10
10
  }
11
11
  }
12
12
  };
13
13
 
14
- const Template = (args) => <Input {...args} />;
14
+ const Template = (args) => {
15
+ const [newVal, setNewVal] = useState('');
16
+ const handleChange = (val) => {
17
+ setNewVal(val);
18
+ console.log(val);
19
+ };
20
+ return <Input value={newVal} change={handleChange} {...args} />;
21
+ }
15
22
 
16
23
  export const Default = Template.bind({});
17
24
  Default.args = {
18
- type: InputTypes.TEXT,
19
- onChange: (val) => {}
25
+ type: InputTypes.TEXT
20
26
  };
21
27
 
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { NewAutocomplete } from './index';
3
3
 
4
4
  export default {
@@ -10,41 +10,41 @@ export default {
10
10
  },
11
11
  getItem: {
12
12
  control: 'function'
13
+ },
14
+ change: {
15
+ control: 'function'
13
16
  }
14
17
  }
15
18
  };
16
19
 
17
20
  const Template = (args) => {
21
+ const [newOptions, setNewOptions] = useState([]);
18
22
  const handleClick = (selected) => {
19
23
  console.log(selected, 'selected');
20
24
  };
21
25
 
22
- return <NewAutocomplete {...args} getItem={handleClick} />
26
+ const handleChange = (value) => {
27
+ fetch(`http://dev2.govazd-api.yerevan.am/api/v1/companies/autocomplete?slug=${value}`, {
28
+ method: 'GET',
29
+ headers: {
30
+ 'Content-Type': 'application/json',
31
+ 'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIwMjE0NzEyYTllNzQwZWMyMjNhYzE2MGQyNGVkY2UzNyIsImp0aSI6ImY2N2FjNmNiYjI2YWM3NTRhMDhhOTgxOTZkOTZjNjFjNWI3YTA1NzUyN2U4MGE3NzM0ZDJlOGFlZjNkMjY0ZmRiMGZkN2QwZjllZjA1MmE4IiwiaWF0IjoxNjgwNzYzMzU3LjUyMzI5OCwibmJmIjoxNjgwNzYzMzU3LjUyMzMwNSwiZXhwIjoxNjgwNzg4NTU3LjQ5NjQzLCJzdWIiOiJtaW5hc0BtYWlsLnJ1Iiwic2NvcGVzIjpbImVtYWlsIl19.XLp4N1C9XYnX8EITknJs-j684GkppCVrREA5ttTAEyloxCftJUEo6KQGp-2grZDZvWvwvsgD9NF5lecdPOIYuSEgp7NPgbAQ34-hRn0u6TGoC5LQI6Vjc_PijH9YoH2a2V9q58jAJrxSbwNjKsMixiHmAsahIKl_XRL1ZoDxpKDE23avnndCZZ9Fw_oe8ypkEscfgrpK9iT9EhxWXZWC9MJ-iAxHox6b6XWsVHkJg5oN5MApJt1h9h-oZQmrKNn_274z3evPChlrvSjTyqLzGWy3zlVUMgGQWBE5RsKiuUh1O3TsF4PYvANKp0a_urOFtU9Q-umyfFNlWfgoLsTtKIQE0xmlLi8Kr5OutSna-a0Eu2hzgTM47_x-cJb7ImokTxdgoh1DDODmLDKkfTTXhEQ-KNTQ4J5T8UDn6a11E6EzBEfJYOIv9eXz5bQBf5H14x4mzXEkHNeC10EAsUFH7b9JT8DPJISwazeAA5zloj39dVFVDLoJS2TvZAxMRLQuyoMSs7eEXp4i7TTWPyrDhMLJ-YUgxmbAhWfwQ9J1ULkLyzFCrmvUz4xPmeRp9gnUNCXOo52jjSVD8x5q3cokFhCEUuWP6fE_DSgChe18j5w75Xi7BjGAIHRJjYtyvJQHy0DIQf2qd6YbbKkyP4iW_PvLfJah9JTlOU1_QGhUWqc',
32
+ },
33
+ }).then((res)=> {
34
+ return res.json()
35
+ }).then((data)=> {
36
+ if (data.data.success === false) {
37
+ setNewOptions([]);
38
+ } else {
39
+ setNewOptions(data.data.companies);
40
+ }
41
+ console.log(data, 'data')
42
+ });
43
+ };
44
+
45
+ return <NewAutocomplete {...args} getItem={handleClick} options={newOptions} change={handleChange} />
23
46
  };
24
47
  export const Default = Template.bind({});
25
48
  Default.args = {
26
- searchCount: 3,
27
- options: [
28
- {"bbb":"0", "value":"dfsag"},
29
- {"bbb":"1", "value":"asdfgh"},
30
- {"bbb":"2", "value":"ghjjjh"},
31
- {"bbb":"3", "value":"qwembm"},
32
- {"bbb":"4", "value":"ertmbn"},
33
- {"bbb":"5", "value":"tyuvxvc"},
34
- {"bbb":"6", "value":"uiozcvx"},
35
- {"bbb":"7", "value":"jkljhdfg"},
36
- {"bbb":"8", "value":"asdfghcxvbcb"},
37
- {"bbb":"9", "value":"asdfghcxvkbcb"},
38
- {"bbb":"10", "value":"asdfghcxkkvbcb"},
39
- {"bbb":"11", "value":"asdfghcxvmmmbcb"},
40
- {"bbb":"12", "value":"asdfghcxkhjvbcb"},
41
- {"bbb":"13", "value":"asdfghcxhjkvbcsb"},
42
- {"bbb":"14", "value":"asdfghcxvbzxccxzcb"},
43
- {"bbb":"15", "value":"asdfghcxjklljklvbcb"},
44
- {"bbb":"16", "value":"asdfghcxvbljkljkljkcb"},
45
- {"bbb":"17", "value":"asdfghcxljkljkljkljvbcb"},
46
- {"bbb":"18", "value":"asdfghcxiouiouiouiouovbcb"},
47
- {"bbb":"19", "value":"asdfghcuoiouiouiouiouxvbcb"},
48
- {"bbb":"20", "value":"asdfghcuiouiouioiouiouixvbcb"}
49
- ]
49
+ searchCount: 3
50
50
  }
@@ -7,6 +7,7 @@ import { compereConfigs } from './../../utils';
7
7
 
8
8
  export const NewAutocomplete = ({
9
9
  label,
10
+ change,
10
11
  options,
11
12
  getItem,
12
13
  required,
@@ -80,6 +81,7 @@ export const NewAutocomplete = ({
80
81
  const [isHover, setIsHover] = useState(false);
81
82
  const [isFocus, setIsFocus] = useState(false);
82
83
  const [innerValue, setInnerValue] = useState('');
84
+ const [innerOptions, setInnerOptions] = useState([]);
83
85
  const configStyles = compereConfigs();
84
86
 
85
87
  const showOption = keyframes`
@@ -122,124 +124,137 @@ export const NewAutocomplete = ({
122
124
  const value = e.target.value;
123
125
  value.length > 0 ? setShow(true) : setShow(false);
124
126
  setInnerValue(value);
127
+ if (value.length >= searchCount) {
128
+ change(value);
129
+ } else {
130
+ change('');
131
+ }
125
132
  };
126
133
 
127
134
  const handleClick = (selectedValue) => {
128
135
  setShow(false);
129
136
  getItem(selectedValue);
130
- setInnerValue(selectedValue.value);
137
+ setInnerValue(selectedValue.name);
131
138
  };
132
139
 
133
140
  const optionList = (
134
141
  <>
135
142
  {
136
- show && options && options.length > 0 && <div
137
- style={{
138
- left: contentBottomLeft ? contentBottomLeft : configStyles.NEWAUTOCOMPLETE.contentBottomLeft,
139
- width: contentBottomWidth ? contentBottomWidth : configStyles.NEWAUTOCOMPLETE.contentBottomWidth,
140
- zIndex: contentBottomZindex ? contentBottomZindex : configStyles.NEWAUTOCOMPLETE.contentBottomZindex,
141
- borderRadius: contentBottomRadius ? contentBottomRadius : configStyles.NEWAUTOCOMPLETE.contentBottomRadius,
142
- maxWidth: contentBottomMaxWidth ? contentBottomMaxWidth : configStyles.NEWAUTOCOMPLETE.contentBottomMaxWidth,
143
- overflow: contentBottomOverflow ? contentBottomOverflow : configStyles.NEWAUTOCOMPLETE.contentBottomOverflow,
144
- position: contentBottomPosition ? contentBottomPosition : configStyles.NEWAUTOCOMPLETE.contentBottomPosition,
145
- minHeight: contentBottomMinHeight ? contentBottomMinHeight : configStyles.NEWAUTOCOMPLETE.contentBottomMinHeight,
146
- boxShadow: contentBottomBoxShadow ? contentBottomBoxShadow : configStyles.NEWAUTOCOMPLETE.contentBottomBoxShadow,
147
- backgroundColor: contentBottomBackgroundColor ? contentBottomBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomBackgroundColor,
148
- top: contentTopHeight ?
149
- contentTopHeight.includes('rem') ?
150
- parseFloat(contentTopHeight.substr(0, contentTopHeight.length - 3)) + 0.6 + 'rem' :
151
- parseFloat(contentTopHeight.substr(0, contentTopHeight.length - 2)) + 6 + 'px'
152
- : configStyles.NEWAUTOCOMPLETE.contentTopHeight.includes('rem') ?
153
- parseFloat(configStyles.NEWAUTOCOMPLETE.contentTopHeight.substr(0, configStyles.NEWAUTOCOMPLETE.contentTopHeight.length - 3)) + 0.6 + 'rem' :
154
- parseFloat(configStyles.NEWAUTOCOMPLETE.contentTopHeight.substr(0, configStyles.NEWAUTOCOMPLETE.contentTopHeight.length - 2)) + 6 + 'px',
155
- animation
156
- }}
157
- >
158
- <div
159
- style={{
160
- display: contentBottomInnerDisplay ? contentBottomInnerDisplay : configStyles.NEWAUTOCOMPLETE.contentBottomInnerDisplay,
161
- overflowY: contentBottomInnerOverflowY ? contentBottomInnerOverflowY : configStyles.NEWAUTOCOMPLETE.contentBottomInnerOverflowY,
162
- overflowX: contentBottomInnerOverflowX ? contentBottomInnerOverflowX : configStyles.NEWAUTOCOMPLETE.contentBottomInnerOverflowX,
163
- maxHeight: contentBottomInnerMaxHeight ? contentBottomInnerMaxHeight : configStyles.NEWAUTOCOMPLETE.contentBottomInnerMaxHeight,
164
- flexDirection: contentBottomInnerDirection ? contentBottomInnerDirection : configStyles.NEWAUTOCOMPLETE.contentBottomInnerDirection
165
- }}
166
- >
167
- {
168
- innerValue.length >= searchCount ?
169
- options.filter(item => item.value.includes(innerValue)).length > 0 ?
170
- options.filter(item => item.value.includes(innerValue)).map((item, index) => {
171
- return (
172
- <p
173
- key={`${item}_${index}`}
174
- onMouseEnter={handleRowMouseEnter}
175
- onMouseLeave={handleRowMouseLeave}
176
- onClick={() => handleClick(item)}
177
- style={{
178
- flexShrink: 0,
179
- color: contentBottomRowColor ? contentBottomRowColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowColor,
180
- height: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
181
- cursor: contentBottomRowCursor ? contentBottomRowCursor : configStyles.NEWAUTOCOMPLETE.contentBottomRowCursor,
182
- display: contentBottomRowDisplay ? contentBottomRowDisplay : configStyles.NEWAUTOCOMPLETE.contentBottomRowDisplay,
183
- padding: contentBottomRowPadding ? contentBottomRowPadding : configStyles.NEWAUTOCOMPLETE.contentBottomRowPadding,
184
- fontSize: contentBottomRowFontSize ? contentBottomRowFontSize : configStyles.NEWAUTOCOMPLETE.contentBottomRowFontSize,
185
- boxSizing: contentBottomRowBoxSizing ? contentBottomRowBoxSizing : configStyles.NEWAUTOCOMPLETE.contentBottomRowBoxSizing,
186
- fontWeight: contentBottomRowFontWeight ? contentBottomRowFontWeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowFontWeight,
187
- lineHeight: contentBottomRowLineHeight ? contentBottomRowLineHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowLineHeight,
188
- alignItems: contentBottomRowAlignItems ? contentBottomRowAlignItems : configStyles.NEWAUTOCOMPLETE.contentBottomRowAlignItems,
189
- transition: contentBottomRowTransition ? contentBottomRowTransition : configStyles.NEWAUTOCOMPLETE.contentBottomRowTransition,
190
- marginBottom: contentBottomRowMarginBottom ? contentBottomRowMarginBottom : configStyles.NEWAUTOCOMPLETE.contentBottomRowMarginBottom,
191
- backgroundColor: contentBottomRowBackgroundColor ? contentBottomRowBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowBackgroundColor
192
- }}
193
- >
194
- {item.value}
195
- </p>
196
- )
197
- }) : <p
198
- style={{
199
- color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
200
- fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
201
- height: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
202
- padding: contentBottomRowPadding ? contentBottomRowPadding : configStyles.NEWAUTOCOMPLETE.contentBottomRowPadding,
203
- lineHeight: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight
204
- }}
205
- >Նման տվյալ առկա չէ</p>
206
- : <p
143
+ show && innerOptions
144
+ ?
145
+ innerOptions.length > 0
146
+ ?
147
+ <div
148
+ style={{
149
+ left: contentBottomLeft ? contentBottomLeft : configStyles.NEWAUTOCOMPLETE.contentBottomLeft,
150
+ width: contentBottomWidth ? contentBottomWidth : configStyles.NEWAUTOCOMPLETE.contentBottomWidth,
151
+ zIndex: contentBottomZindex ? contentBottomZindex : configStyles.NEWAUTOCOMPLETE.contentBottomZindex,
152
+ borderRadius: contentBottomRadius ? contentBottomRadius : configStyles.NEWAUTOCOMPLETE.contentBottomRadius,
153
+ maxWidth: contentBottomMaxWidth ? contentBottomMaxWidth : configStyles.NEWAUTOCOMPLETE.contentBottomMaxWidth,
154
+ overflow: contentBottomOverflow ? contentBottomOverflow : configStyles.NEWAUTOCOMPLETE.contentBottomOverflow,
155
+ position: contentBottomPosition ? contentBottomPosition : configStyles.NEWAUTOCOMPLETE.contentBottomPosition,
156
+ minHeight: contentBottomMinHeight ? contentBottomMinHeight : configStyles.NEWAUTOCOMPLETE.contentBottomMinHeight,
157
+ boxShadow: contentBottomBoxShadow ? contentBottomBoxShadow : configStyles.NEWAUTOCOMPLETE.contentBottomBoxShadow,
158
+ backgroundColor: contentBottomBackgroundColor ? contentBottomBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomBackgroundColor,
159
+ top: contentTopHeight ?
160
+ contentTopHeight.includes('rem') ?
161
+ parseFloat(contentTopHeight.substr(0, contentTopHeight.length - 3)) + 0.6 + 'rem' :
162
+ parseFloat(contentTopHeight.substr(0, contentTopHeight.length - 2)) + 6 + 'px'
163
+ : configStyles.NEWAUTOCOMPLETE.contentTopHeight.includes('rem') ?
164
+ parseFloat(configStyles.NEWAUTOCOMPLETE.contentTopHeight.substr(0, configStyles.NEWAUTOCOMPLETE.contentTopHeight.length - 3)) + 0.6 + 'rem' :
165
+ parseFloat(configStyles.NEWAUTOCOMPLETE.contentTopHeight.substr(0, configStyles.NEWAUTOCOMPLETE.contentTopHeight.length - 2)) + 6 + 'px',
166
+ animation
167
+ }}
168
+ >
169
+ <div
170
+ style={{
171
+ display: contentBottomInnerDisplay ? contentBottomInnerDisplay : configStyles.NEWAUTOCOMPLETE.contentBottomInnerDisplay,
172
+ overflowY: contentBottomInnerOverflowY ? contentBottomInnerOverflowY : configStyles.NEWAUTOCOMPLETE.contentBottomInnerOverflowY,
173
+ overflowX: contentBottomInnerOverflowX ? contentBottomInnerOverflowX : configStyles.NEWAUTOCOMPLETE.contentBottomInnerOverflowX,
174
+ maxHeight: contentBottomInnerMaxHeight ? contentBottomInnerMaxHeight : configStyles.NEWAUTOCOMPLETE.contentBottomInnerMaxHeight,
175
+ flexDirection: contentBottomInnerDirection ? contentBottomInnerDirection : configStyles.NEWAUTOCOMPLETE.contentBottomInnerDirection
176
+ }}
177
+ >
178
+ {
179
+ innerOptions.map(item => {
180
+ return (
181
+ <p
182
+ key={item.id}
183
+ onMouseEnter={handleRowMouseEnter}
184
+ onMouseLeave={handleRowMouseLeave}
185
+ onClick={() => handleClick(item)}
186
+ style={{
187
+ flexShrink: 0,
188
+ color: contentBottomRowColor ? contentBottomRowColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowColor,
189
+ height: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
190
+ cursor: contentBottomRowCursor ? contentBottomRowCursor : configStyles.NEWAUTOCOMPLETE.contentBottomRowCursor,
191
+ display: contentBottomRowDisplay ? contentBottomRowDisplay : configStyles.NEWAUTOCOMPLETE.contentBottomRowDisplay,
192
+ padding: contentBottomRowPadding ? contentBottomRowPadding : configStyles.NEWAUTOCOMPLETE.contentBottomRowPadding,
193
+ fontSize: contentBottomRowFontSize ? contentBottomRowFontSize : configStyles.NEWAUTOCOMPLETE.contentBottomRowFontSize,
194
+ boxSizing: contentBottomRowBoxSizing ? contentBottomRowBoxSizing : configStyles.NEWAUTOCOMPLETE.contentBottomRowBoxSizing,
195
+ fontWeight: contentBottomRowFontWeight ? contentBottomRowFontWeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowFontWeight,
196
+ lineHeight: contentBottomRowLineHeight ? contentBottomRowLineHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowLineHeight,
197
+ alignItems: contentBottomRowAlignItems ? contentBottomRowAlignItems : configStyles.NEWAUTOCOMPLETE.contentBottomRowAlignItems,
198
+ transition: contentBottomRowTransition ? contentBottomRowTransition : configStyles.NEWAUTOCOMPLETE.contentBottomRowTransition,
199
+ marginBottom: contentBottomRowMarginBottom ? contentBottomRowMarginBottom : configStyles.NEWAUTOCOMPLETE.contentBottomRowMarginBottom,
200
+ backgroundColor: contentBottomRowBackgroundColor ? contentBottomRowBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowBackgroundColor
201
+ }}
202
+ >
203
+ {item.name}
204
+ </p>
205
+ )
206
+ })
207
+ }
208
+ </div>
209
+ </div>
210
+ : innerOptions.length <= 0
211
+ ?
212
+ <p
207
213
  style={{
214
+ margin: '0px',
208
215
  color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
209
216
  fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
210
217
  height: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
211
218
  padding: contentBottomRowPadding ? contentBottomRowPadding : configStyles.NEWAUTOCOMPLETE.contentBottomRowPadding,
212
- lineHeight: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight
219
+ lineHeight: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
220
+ backgroundColor: contentBottomBackgroundColor ? contentBottomBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomBackgroundColor,
213
221
  }}
214
222
  >
215
- {innerValue.length < searchCount && `Լրացնել առնվազն ${searchCount} նիշ`}
223
+ {
224
+ innerValue.length >= searchCount
225
+ ? 'Նման տվյալ առկա չէ'
226
+ : `Լրացնել առնվազն ${searchCount} նիշ`
227
+ }
216
228
  </p>
217
- }
218
- </div>
219
- </div>
229
+ : ''
230
+ : ''
220
231
  }
221
232
  </>
222
233
  );
223
234
 
224
235
  useEffect(() => {
225
- if (!options) {
226
- alert('Please add array of options');
227
- }
228
-
229
- if (options.length === 0) {
230
- alert('Please fill options array');
236
+ if (options === undefined) {
237
+ alert('Please add options prop');
231
238
  }
232
239
 
233
240
  options && options.length > 0 && options.map(item => {
234
- if (!item.hasOwnProperty('value')) {
235
- alert('Please add value property in items of options array');
241
+ if (!item.hasOwnProperty('name')) {
242
+ alert('Please add name property in items of options array');
236
243
  }
237
244
  });
238
245
 
239
246
  if (!getItem) {
240
247
  alert('Please add getItem function for get choosen item from autocomplete');
241
248
  }
242
- }, [options, getItem]);
249
+
250
+ options && setInnerOptions(options);
251
+ }, [options, options.length, getItem]);
252
+
253
+ useEffect(() => {
254
+ if (!change) {
255
+ alert('Please add change prop on New Autocomplete component');
256
+ }
257
+ }, [change]);
243
258
 
244
259
  return (
245
260
  <>
@@ -252,8 +267,9 @@ export const NewAutocomplete = ({
252
267
  display: labelDisplay ? labelDisplay : configStyles.NEWAUTOCOMPLETE.labelDisplay,
253
268
  fontWeight: labelWeight ? labelWeight : configStyles.NEWAUTOCOMPLETE.labelWeight,
254
269
  lineHeight: labelLineHeight ? labelLineHeight : configStyles.NEWAUTOCOMPLETE.labelLineHeight,
270
+ maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
255
271
  marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.NEWAUTOCOMPLETE.labelMarginBottom,
256
- textTransform: labelTextTransform ? labelTextTransform : configStyles.NEWAUTOCOMPLETE.labelTextTransform
272
+ textTransform: labelTextTransform ? labelTextTransform : configStyles.NEWAUTOCOMPLETE.labelTextTransform,
257
273
  }}
258
274
  >
259
275
  {label}
@@ -271,7 +287,8 @@ export const NewAutocomplete = ({
271
287
  style={{
272
288
  display: contentDisplay ? contentDisplay : configStyles.NEWAUTOCOMPLETE.contentDisplay,
273
289
  position: contentPosition ? contentPosition : configStyles.NEWAUTOCOMPLETE.contentPosition,
274
- flexDirection: contentDirection ? contentDirection : configStyles.NEWAUTOCOMPLETE.contentDirection
290
+ flexDirection: contentDirection ? contentDirection : configStyles.NEWAUTOCOMPLETE.contentDirection,
291
+ maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth
275
292
  }}
276
293
  >
277
294
  <input
@@ -281,11 +298,12 @@ export const NewAutocomplete = ({
281
298
  onBlur={handleBlur}
282
299
  onFocus={handleFocus}
283
300
  onInput={handleChange}
284
- placeholder={placeHolder ? placeHolder : ''}
285
- autoComplete={autoComplete ? autoComplete : configStyles.NEWAUTOCOMPLETE.autoComplete}
286
301
  onMouseEnter={handleMouseEnter}
287
302
  onMouseLeave={handleMouseLeave}
303
+ placeholder={placeHolder ? placeHolder : ''}
304
+ autoComplete={autoComplete ? autoComplete : configStyles.NEWAUTOCOMPLETE.autoComplete}
288
305
  style={{
306
+ maxWidth: '100%',
289
307
  transition: 'all 240ms',
290
308
  cursor: disabled ? 'not-allowed' : 'auto',
291
309
  color: contentTopColor ? contentTopColor : configStyles.NEWAUTOCOMPLETE.contentTopColor,
@@ -296,7 +314,6 @@ export const NewAutocomplete = ({
296
314
  display: contentTopDisplay ? contentTopDisplay : configStyles.NEWAUTOCOMPLETE.contentTopDisplay,
297
315
  fontWeight: contentTopWeight ? contentTopWeight : configStyles.NEWAUTOCOMPLETE.contentTopWeight,
298
316
  borderRadius: contentTopRadius ? contentTopRadius : configStyles.NEWAUTOCOMPLETE.contentTopRadius,
299
- maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
300
317
  boxSizing: contentTopBoxSizing ? contentTopBoxSizing : configStyles.NEWAUTOCOMPLETE.contentTopBoxSizing,
301
318
  lineHeight: contentTopLineHeight ? contentTopLineHeight : configStyles.NEWAUTOCOMPLETE.contentTopLineHeight,
302
319
  flexDirection: contentTopDirection ? contentTopDirection : configStyles.NEWAUTOCOMPLETE.contentTopDirection,
@@ -313,8 +330,11 @@ export const NewAutocomplete = ({
313
330
  errorMessage
314
331
  ? <span
315
332
  style={{
333
+ margin: '0px',
334
+ display: 'inline-block',
316
335
  color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
317
- fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize
336
+ fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
337
+ maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
318
338
  }}
319
339
  >
320
340
  {errorMessage}
@@ -349,6 +369,7 @@ NewAutocomplete.propTypes = {
349
369
  contentPosition: PropTypes.string,
350
370
  labelLineHeight: PropTypes.string,
351
371
  contentTopColor: PropTypes.string,
372
+ change: PropTypes.func.isRequired,
352
373
  contentDirection: PropTypes.string,
353
374
  contentTopWeight: PropTypes.number,
354
375
  contentTopRadius: PropTypes.string,