@xaypay/tui 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -11,13 +11,23 @@ const Template = (args) => <Autocomplate {...args} />;
11
11
  export const Default = Template.bind({});
12
12
  Default.args = {
13
13
  jsonOptionsData: '[{"bbb":"0", "value":"asd"}, {"bbb":"2", "value":"bas"}]',
14
- // jsonSelectedOptionsData: '{"bbb":"0", "value":"asd"}',
14
+ jsonSelectedOptionsData: '{"bbb":"0", "value":"gasdfgdsfgdsg"}',
15
15
  label: 'label',
16
16
  keyNames: { name: 'value', id: 'bbb' },
17
17
  searchCount: 2,
18
18
  onChange: (aa)=> {
19
19
  console.log(aa);
20
- // console.log(aa.id);
20
+ fetch(`http://dev2.govazd-api.yerevan.am/api/v1/companies/autocomplete?slug=${aa.name? aa.name : 'a'}`, {
21
+ method: 'GET',
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ 'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIwMjE0NzEyYTllNzQwZWMyMjNhYzE2MGQyNGVkY2UzNyIsImp0aSI6Ijk2Mjk0MjJkNTY1ZTQ3MGM3MjFkZjY5NDgzMzE3ZThmYjdlMDJmMjI4YjY5MzZhYzdiM2EzMWM4ODZkMWQwZDk2YjIzNzYwMmJhMWE0MTE0IiwiaWF0IjoxNjY5MTgyOTI5LjczMjIwOCwibmJmIjoxNjY5MTgyOTI5LjczMjIzLCJleHAiOjE2NjkyMDgxMjkuNzEyNDczLCJzdWIiOiJtaW5hcyIsInNjb3BlcyI6WyJlbWFpbCJdfQ.NsFsqDHOBYzgReUtW9iumbEvYCB8O7yCIJ2UTz0-AeVEjdUxE-htZMBYF8pP3m-lM1IQ3iN2ude7AZhTzVLMAhTt-5tKJr8YAxhX28yCBLYsFHE-e0k7-FLKBkkZxt9yrvX_Rz8aSQ39-3HrkyB-BYHzV5-GnMgAhnrWKYlTmrVFi9SWu0WBYPHvblMTEh3Vkkd1ESn7fUhy8gf8qma0ChRAMbkozLffbVVYfnWlU0eySD2PUWrZ26JtKAX6k-q7TiMd6HMjOEFUi80JH7aoKDI1vdg8kKlPqcjYTEJK3hzIJrtOHTTUoW4m1-k5x9Le3ULdT4Hctr0bh--ERShnTTg-DBJh0zIoBol4hFHZnA35_FEqKBkDAJ3EOt9DusBTJ9Iad-JzrxJqb-4uhzWjTg8f3F_IedPgG3pwqGkSw2U2dVqzwdqy3yaElp7SGWpicNxJWJsr5Vfa8gLhMkmDMooOHNBUNkS-4Z8Cn6dPc-1mg2JZxrBuSMElkp8-DQr9Xe9VBf8wCUEdHDvQmb-6LIEL8njS2XGL82m827uO-BOVVOIiZO-BVGn_VjIwdhywrjmudPWBy2CVUxHEft64Bz3VkS2FnFoSN7_zsaCE6dpXWTRJKv-4IeBv8pn4-lYw67jMINza7Om9_6BOlnk1VvjixmulPyTobgEO7PQ6FeE',
25
+ },
26
+ }).then((res)=> {
27
+ return res.json()
28
+ }).then((data)=> {
29
+ console.log(data)
30
+ })
21
31
  }
22
32
 
23
33
  };
@@ -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 "./autocomplate.module.css";
@@ -13,79 +13,81 @@ export const Autocomplate = ({
13
13
  onChange,
14
14
  value,
15
15
  searchCount,
16
+ placeHolder,
16
17
  keyNames,
18
+ errorMesage,
17
19
  ...props
18
20
  }) => {
19
21
  const classProps = classnames(styles.searchBox, className);
20
- const [inputValue, setInputValue] = useState(null);
21
- const [inputId, setInputId] = useState(null);
22
+ const parseSelectedOptionsData =
23
+ jsonSelectedOptionsData ? JSON.parse(jsonSelectedOptionsData) : { name: '', id: '' };
24
+ const [inputValue, setInputValue] = useState(parseSelectedOptionsData[keyNames.name]);
25
+ const [inputId, setInputId] = useState(parseSelectedOptionsData[keyNames.id]);
22
26
  const [activeOption, setActiveOption] = useState(0);
23
- const [filteredOptions, setFilteredOptions] = useState([]);
24
27
  const [showOptions, setShowOptions] = useState(false);
25
28
  const parseOptionsData =
26
- jsonOptionsData? JSON.parse(jsonOptionsData).sort() : [];
27
- const parseSelectedOptionsData =
28
- jsonSelectedOptionsData ? JSON.parse(jsonSelectedOptionsData) : {};
29
-
29
+ jsonOptionsData ? JSON.parse(jsonOptionsData) : [];
30
+ useEffect(() => {
31
+ setInputValue(JSON.parse(jsonSelectedOptionsData)[keyNames.name])
32
+ setInputId(JSON.parse(jsonSelectedOptionsData)[keyNames.id])
33
+ }, [jsonSelectedOptionsData])
34
+
30
35
  const handleChange = (e) => {
31
36
  const currentInputValue = e.currentTarget.value;
32
37
  setInputId(null)
33
- const filteredOptions = parseOptionsData.filter(
34
- (optionName) =>
35
- optionName[keyNames.name].toLowerCase().indexOf(currentInputValue.toLowerCase()) > -1
36
- );
37
38
  setInputValue(currentInputValue);
39
+ setInputId('')
38
40
  setActiveOption(0);
39
- setFilteredOptions(filteredOptions);
40
- setShowOptions(true);
41
+ setShowOptions(true);
42
+ onChange({ name: currentInputValue, id: e.target.id });
41
43
  };
42
44
  const handleClick = (e) => {
43
- setInputValue(e.currentTarget.innerText);
44
- setInputId(e.target.id)
45
45
  setActiveOption(0);
46
- setFilteredOptions([]);
47
46
  setShowOptions(false);
48
- onChange({name: e.currentTarget.innerText, id: e.target.id});
47
+ setInputValue(e.target.innerText);
48
+ setInputId(e.target.id)
49
+
50
+ onChange({ name: e.target.innerText, id: e.target.id });
49
51
 
50
52
  };
51
53
  let optionList;
52
- if (showOptions && inputValue) {
53
- if (filteredOptions.length && inputValue.length >= searchCount) {
54
- optionList = (
55
- <div className={styles['autocomplate-content-bottom']}>
56
- <div className={styles['autocomplate-content-bottom-inner']}>
57
- {filteredOptions.map((optionName, index) => {
58
- let className;
59
- if (index === activeOption) {
60
- className = "option-active";
61
- }
62
- return (
63
- <div
64
- className={styles[className]}
65
- key={optionName[keyNames.id]}
66
- onClick={handleClick}
67
- >
68
- <div id={optionName[keyNames.id]} className={styles['autocomplate-content-bottom-row']}>{optionName[keyNames.name]}</div>
69
- </div>
70
- );
71
- })}
72
- </div>
54
+ if (showOptions && inputValue) {
55
+ if (parseOptionsData.length && inputValue.length >= searchCount) {
56
+ optionList = (
57
+ <div className={styles['autocomplate-content-bottom']}>
58
+ <div className={styles['autocomplate-content-bottom-inner']}>
59
+ {parseOptionsData.map((optionName, index) => {
60
+ let className;
61
+ if (index === activeOption) {
62
+ className = "option-active";
63
+ }
64
+ return (
65
+ <div
66
+ className={styles[className]}
67
+ key={optionName[keyNames.id]}
68
+ onClick={handleClick}
69
+ >
70
+ <div id={optionName[keyNames.id]} className={styles['autocomplate-content-bottom-row']}>{optionName[keyNames.name]}</div>
73
71
  </div>
72
+ );
73
+ })}
74
+ </div>
75
+ </div>
74
76
 
75
77
 
76
- );
77
- } else {
78
- optionList = (
79
- <div className={styles['autocomplate-content-bottom']}>
80
- <div className={styles['autocomplate-content-bottom-inner']}>
81
- <div className={styles['autocomplate-content-bottom-row']}>
82
- <div className={styles['no-option']}>No Option!</div>
83
- </div>
84
- </div>
85
- </div>
86
- );
87
- }
78
+ );
79
+ } else {
80
+ optionList = (
81
+ <div className={styles['autocomplate-content-bottom']}>
82
+ <div className={styles['autocomplate-content-bottom-inner']}>
83
+ <div className={styles['autocomplate-content-bottom-row']}>
84
+ <div className={styles['no-option']}>No Option!</div>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ );
88
89
  }
90
+ }
89
91
 
90
92
  return (
91
93
  <>
@@ -98,10 +100,12 @@ export const Autocomplate = ({
98
100
  required={required}
99
101
  disabled={disabled}
100
102
  onChange={handleChange}
101
- value={inputValue != null ? inputValue : parseSelectedOptionsData[keyNames.name]}
102
- placeholder= {!parseSelectedOptionsData[keyNames.name] ?" Write..." : ''}
103
+ onClick={() => { setShowOptions(!showOptions) }}
104
+ value={inputValue}
105
+ placeholder={placeHolder}
103
106
  {...props}
104
- />
107
+ />
108
+ {errorMesage ? <span className={styles.errorMessage}>{errorMesage}</span> : null}
105
109
  {optionList}
106
110
  </div>
107
111
  </>
@@ -111,6 +115,7 @@ export const Autocomplate = ({
111
115
  Autocomplate.propTypes = {
112
116
  className: PropTypes.string,
113
117
  label: PropTypes.string,
118
+ placeHolder: PropTypes.string,
114
119
  required: PropTypes.bool,
115
120
  disabled: PropTypes.bool,
116
121
  jsonOptionsData: PropTypes.string,
@@ -119,6 +124,7 @@ Autocomplate.propTypes = {
119
124
  value: PropTypes.string,
120
125
  searchCount: PropTypes.number,
121
126
  keyNames: PropTypes.object,
127
+ errorMesage: PropTypes.string,
122
128
  };
123
129
 
124
130
 
@@ -1,5 +1,5 @@
1
1
  .btn {
2
- text-transform: capitalize;
2
+ text-transform: none;
3
3
  font-size: 16px;
4
4
  line-height: 20px;
5
5
  padding: 12px 20px;
@@ -0,0 +1,11 @@
1
+ .file-Form{
2
+ display: flex;
3
+ flex-direction: column;
4
+ justify-content: center;
5
+ align-items: center;
6
+ border: 3px dashed rgb(161, 160, 160);
7
+ width: 300px;
8
+ height: 200px;
9
+ cursor: pointer;
10
+ border-radius: 5px;
11
+ }
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import { File } from "./index";
3
+
4
+ export default {
5
+ component: File,
6
+ title: "Components/File",
7
+ };
8
+
9
+ const Template = (args) => <File {...args} />;
10
+
11
+ export const Default = Template.bind({});
12
+ Default.args = {
13
+ label: 'ssa',
14
+ onChange: (aa) => {
15
+ console.log('barev', aa);
16
+
17
+ },
18
+ defaultData: {
19
+ url: 'https://images.pexels.com/photos/753626/pexels-photo-753626.jpeg?auto=compress&cs=tinysrgb&w=1600',
20
+ type: "image/png",
21
+ },
22
+ name: 'sss'
23
+
24
+ };
@@ -0,0 +1,117 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import PropTypes from "prop-types";
3
+ import classnames from "classnames";
4
+ import styles from "./file.module.css";
5
+
6
+ export const File = ({
7
+ className,
8
+ label,
9
+ required,
10
+ disabled,
11
+ onChange,
12
+ defaultData,
13
+ errorMesage,
14
+ name,
15
+ ...props
16
+ }) => {
17
+ const pdfImageName = 'https://play-lh.googleusercontent.com/kIwlXqs28otssKK_9AKwdkB6gouex_U2WmtLshTACnwIJuvOqVvJEzewpzuYBXwXQQ'
18
+ const [image, setImage] = useState(defaultData ?
19
+ defaultData.type != 'application/pdf' ?
20
+ defaultData.url : pdfImageName : null);
21
+ const [error, setError] = useState(errorMesage);
22
+ const [fileName, setFileName] = useState('no selected file');
23
+ function fileType(file) {
24
+ if (file.size <= 5000000) {
25
+ if (file.type === 'image/jpeg' || file.type === 'image/png') {
26
+ setImage(URL.createObjectURL(file))
27
+ setError('')
28
+
29
+ }
30
+ else if (file.type === 'application/pdf') {
31
+ setImage(pdfImageName)
32
+ setError('')
33
+
34
+ }
35
+ else {
36
+ setImage(null)
37
+ setFileName('no selected file');
38
+ setError('ֆայլի սխալ ֆորմատ')
39
+ }
40
+ }
41
+ else {
42
+ setImage(null)
43
+ setFileName('no selected file');
44
+ setError('առավելագույն ծավալ')
45
+ }
46
+ }
47
+
48
+ return (
49
+ <>
50
+ <label>{label}</label>
51
+ <div>
52
+ <div
53
+ className={styles['file-Form']}
54
+ onChange={(e) => { console.log(e) }}
55
+ style={error ? { borderColor: 'red' } : {}}
56
+ onClick={() => {
57
+ document.querySelector(`.${name}`).click()
58
+ }}
59
+ >
60
+ <input type='file' className={name} hidden disabled={disabled}
61
+ onChange={({ target: { files } }) => {
62
+ onChange({ target: { files } })
63
+ files[0] && setFileName(files[0].name)
64
+ if (files[0]) {
65
+ fileType(files[0])
66
+ }
67
+ }}
68
+ />
69
+ {
70
+ image ?
71
+ <div>
72
+ <div
73
+ onClick={() => {
74
+ setFileName('no selected file');
75
+ setImage(null)
76
+ }}
77
+ >
78
+ x
79
+ </div>
80
+ <img
81
+ src={image}
82
+ height={120}
83
+ alt={fileName}
84
+ />
85
+ </div> :
86
+ <div>
87
+ <div>
88
+ <img src='https://uxwing.com/wp-content/themes/uxwing/download/web-app-development/cloud-upload-icon.png' width={100} />
89
+ </div>
90
+ <div>
91
+ <span>Տեղադրել ֆայլը այստեղ կամ Բեռնել</span>
92
+ </div>
93
+ <div>
94
+ <span>Առավելագույնը 5ՄԲ ( jpg, jpeg, png, pdf)</span>
95
+ </div>
96
+ </div>
97
+ }
98
+ </div>
99
+ </div>
100
+ {
101
+ error ? <span style={{ color: 'red' }}>{error}</span> : null
102
+ }
103
+ </>
104
+ );
105
+ };
106
+
107
+ File.propTypes = {
108
+ className: PropTypes.string,
109
+ label: PropTypes.string,
110
+ required: PropTypes.bool,
111
+ disabled: PropTypes.bool,
112
+ onChange: PropTypes.func,
113
+ errorMesage: PropTypes.string,
114
+ defaultData: PropTypes.object
115
+ };
116
+
117
+
@@ -16,7 +16,7 @@
16
16
  position: relative;
17
17
  }
18
18
  .input {
19
- text-transform: capitalize;
19
+ text-transform: none;
20
20
  font-size: 16px;
21
21
  line-height: 20px;
22
22
  border-radius: 6px;
@@ -3,7 +3,7 @@
3
3
  }
4
4
  .multi-select-title {
5
5
  display: block;
6
- text-transform: capitalize;
6
+ text-transform: none;
7
7
  font-size: 16px;
8
8
  color: #3C393E;
9
9
  line-height: 22px;
@@ -48,7 +48,7 @@ export const PaginationRange = ({
48
48
  }
49
49
 
50
50
  if (shouldShowLeftDots && !shouldShowRightDots) {
51
- let rightItemCount =
51
+ let rightItemCount = 0;
52
52
  currentPageNumber === lastPageIndex - 3 && lastPageIndex > 7
53
53
  ? (rightItemCount = 4 + siblingCountNumber)
54
54
  : (rightItemCount = 3 + siblingCountNumber);
@@ -1,6 +1,6 @@
1
1
  .select-title {
2
2
  display: block;
3
- text-transform: capitalize;
3
+ text-transform: none;
4
4
  font-size: 16px;
5
5
  color: #3C393E;
6
6
  line-height: 22px;
@@ -34,21 +34,21 @@ h5 {
34
34
  }
35
35
 
36
36
  h5 {
37
- text-transform: capitalize;
37
+ text-transform: none;
38
38
  font-size: 16px;
39
39
  line-height: 22px;
40
40
  font-weight: 600;
41
41
  }
42
42
 
43
43
  p {
44
- text-transform: capitalize;
44
+ text-transform: none;
45
45
  font-size: 14px;
46
46
  line-height: 20px;
47
47
  font-weight: 600;
48
48
  }
49
49
 
50
50
  span {
51
- text-transform: capitalize;
51
+ text-transform: none;
52
52
  font-size: 12px;
53
53
  line-height: 16px;
54
54
  font-weight: 500;
package/src/index.js CHANGED
@@ -8,4 +8,5 @@ export * from './components/pagination';
8
8
  export * from './components/radio';
9
9
  export * from './components/captcha';
10
10
  export * from './components/stepper';
11
- export * from './components/select';
11
+ export * from './components/select';
12
+ export * from './components/file';