@xaypay/tui 0.0.16 → 0.0.18

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.
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styles from './captcha.module.css';
4
-
4
+ import Icon from '../icon/Icon';
5
5
 
6
6
  export const Captcha = ({ onclick, rangeCount }) => {
7
7
  const [data, setData] = useState("");
@@ -10,7 +10,7 @@ export const Captcha = ({ onclick, rangeCount }) => {
10
10
  let rangeElement = document.getElementsByClassName(styles.range);
11
11
  useEffect(() => {
12
12
  for (let element of rangeElement) {
13
- element.style.marginLeft = `${range - 3}%`;
13
+ element.style.marginLeft = `${range + 60}%`;
14
14
  element.style.color = data;
15
15
  }
16
16
  }, [range, data])
@@ -25,10 +25,10 @@ export const Captcha = ({ onclick, rangeCount }) => {
25
25
  progressBar[0].style.width = event.target.value + '%';
26
26
 
27
27
  if (rangeCount == event.target.value) {
28
- selectBtn[0].style.backgroundImage = "url('https://i.ibb.co/b1HDRtd/green.png')";
28
+ selectBtn[0].style.background = "pink";
29
29
  }
30
30
  else {
31
- selectBtn[0].style.backgroundImage = "url('https://i.ibb.co/QvXjjLM/red.png')";
31
+ selectBtn[0].style.background = "red";
32
32
  }
33
33
  }
34
34
 
@@ -39,13 +39,17 @@ export const Captcha = ({ onclick, rangeCount }) => {
39
39
  return (
40
40
  <>
41
41
  <div className={styles.main}>
42
- <div className={styles.range}>▼</div>
42
+ <div className={styles.range}>
43
+ <Icon className='icon-vector-down'/>
44
+ </div>
43
45
  <input type='range' className={styles.slider} onClick={right ? onclick : null} onInput={sliderInput} onMouseUp={sliderChange} />
44
46
  <div className={styles.selector} >
45
47
  <div className={styles.selectBtn}></div>
46
48
  </div>
47
49
  <div className={styles.progressBar}></div>
48
- <div className={styles.range} >▲</div>
50
+ <div className={styles.range} >
51
+ <Icon className='icon-vector-up'/>
52
+ </div>
49
53
  </div>
50
54
 
51
55
  </>
@@ -2,17 +2,21 @@ import React from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import classnames from "classnames";
4
4
  import styles from "./modal.module.css";
5
+ import Icon from '../icon/Icon';
5
6
 
6
7
  export const Modal = ({ setShow, headerText, className }) => {
7
8
  const classProps = classnames(styles.modal, className);
8
9
  return (
9
- <div className={classProps}>
10
- <div className={styles["modal_header"]}>
11
- <h5 className={styles.heading}>{headerText}</h5>
12
- </div>
13
- <button className={styles["close_btn"]} onClick={() => setShow(false)}>
14
- X
15
- </button>
10
+ <div className={styles["modal-wrap"]}>
11
+ <div className={styles["modal-content"]}>
12
+ <div className={styles["modal-top"]}>
13
+ <div className={styles['modal-title']}>Title</div>
14
+ <div className={styles["close-btn"]} onClick={() => setShow(false)}>
15
+ <Icon className="icon-close"/>
16
+ </div>
17
+ </div>
18
+ <div className={styles["modal-section"]}/>
19
+ </div>
16
20
  </div>
17
21
  );
18
22
  };
@@ -1,35 +1,71 @@
1
- .modal {
2
- width: 250px;
3
- height: 170px;
4
- background: white;
5
- color: white;
6
- z-index: 10;
7
- border-radius: 16px;
8
- box-shadow: 0 5px 20px 0 rgba(0, 0, 0, 0.04);
9
- position: relative
10
- }
11
-
12
- .modal_header {
13
- height: 50px;
14
- background: white;
1
+ .modal-wrap {
2
+ position: fixed;
3
+ width: 100%;
4
+ height: 100%;
5
+ top: 0;
6
+ left: 0;
7
+ z-index: 9;
8
+ background: rgba(0,0,0,0.4);
9
+ }
10
+ .modal-top {
11
+ display: flex;
12
+ flex-direction: row;
13
+ width: 100%;
14
+ height: 30px;
15
+ padding-left: 24px;
16
+ box-sizing: border-box;
17
+ box-shadow: 0 1px 0 0 rgba(0,0,0,0.08);
15
18
  }
16
-
17
- .heading {
18
- color: #2c3e50;
19
+ .modal-title {
20
+ flex: 1 1;
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ font-size: 20px;
25
+ line-height: 24px;
19
26
  font-weight: 500;
20
- font-size: 18px;
21
- text-align: center;
27
+ color: #3C393E;
22
28
  }
23
-
24
- .close_btn {
29
+ .close-btn {
30
+ flex: 0 0 auto;
31
+ width: 24px;
32
+ height: 100%;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
25
36
  cursor: pointer;
26
- font-weight: 500;
27
- padding: 4px 8px;
28
- border: none;
29
- font-size: 18px;
30
- color: #2c3e50;
31
- background: white;
37
+ }
38
+ .modal-section {
39
+ flex: 1 1;
40
+ width: 100%;
41
+ height: 100%;
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ }
46
+ .modal-content {
32
47
  position: absolute;
48
+ width: 100%;
49
+ max-width: 300px;
50
+ min-height: 130px;
51
+ top: 110px;
52
+ left: 0;
33
53
  right: 0;
34
- top: 0;
35
- }
54
+ margin: auto;
55
+ display: flex;
56
+ align-items: center;
57
+ flex-direction: column;
58
+ height: auto;
59
+ background: rgba(255,255,255,1);
60
+ border-radius: 8px;
61
+ animation: show-popup 240ms;
62
+ }
63
+ @keyframes show-popup {
64
+ 0% {
65
+ transform: translate3d(0, -30%, 0);
66
+ }
67
+ 100% {
68
+ transform: translate3d(0, 0, 0);
69
+ opacity: 1;
70
+ }
71
+ }
@@ -9,6 +9,7 @@ export const Multiselect = ({
9
9
  jsonOptionsData,
10
10
  jsonSelectedOptionsData,
11
11
  onchange,
12
+ keyNames,
12
13
  value
13
14
  }) => {
14
15
  const [searchedOptions, setSearchedOptions] = useState(jsonOptionsData.length ? JSON.parse(jsonOptionsData) : []);
@@ -21,8 +22,8 @@ export const Multiselect = ({
21
22
  <div className={styles['multi-select-content-top']} onClick={()=>{setOpened(!opened)}}>
22
23
  {
23
24
  options.map((option, i) => {
24
- return (<div className={styles['multi-select-content-bottom-row']} >
25
- <div id={option.id}>{option.name}</div>
25
+ return (<div className={styles['multi-select-content-bottom-row']} key={option[keyNames.id]}>
26
+ <div id={option[keyNames.id]}>{option[keyNames.name]}</div>
26
27
  <Icon className='icon-close' onClick={() => {
27
28
  options.splice(i, 1);
28
29
  setOptions(options);
@@ -33,28 +34,37 @@ export const Multiselect = ({
33
34
  </div>)
34
35
  })
35
36
  }
36
- {/*<div onChange={(e) => {*/}
37
- {/*setValues(e.target.value ? searchedOptions.filter((option) => {*/}
38
- {/*return option.name.toLowerCase().includes(e.target.value.toLowerCase())*/}
39
- {/*}) : searchedOptions)*/}
40
37
 
41
- {/*}} className={styles.input} type='text' />*/}
38
+ <input onChange={(e) => {
39
+ setValues(e.target.value ? searchedOptions.filter((option) => {
40
+ return option[keyNames.name].toLowerCase().includes(e.target.value.toLowerCase())
41
+ }) : searchedOptions)
42
+
43
+
44
+ }} className={styles.input} type='text' />
42
45
  <div className={styles['select-content-top-icon']}>
43
46
  <Icon className={opened ? 'icon-arrow-up' : 'icon-arrow-down'}/>
44
47
  </div>
45
48
  </div>
46
49
  {
50
+
47
51
  opened ? <div className={styles['multi-select-content-bottom']} onClick={onchange}>
48
52
  <div className={styles['multi-select-content-bottom-inner']}>
49
53
  {
50
54
  values.length ?
51
55
  values.map((value, i) => {
52
- return (<div className={styles['multi-select-content-bottom-row']} id={value.id} onClick={(e) => {
53
- setOptions([...options, { 'name': value.name, 'id': value.id }])
54
- values.splice(i, 1);
55
- setValues(values);
56
- setSearchedOptions(values);
57
- }}>{value.name}</div>)
56
+ return (<div
57
+ className={styles['multi-select-content-bottom-row']}
58
+ key={value[keyNames.id]}
59
+ id={value.id}
60
+ onClick={(e) => {
61
+ setOptions([...options, { [keyNames.name] : value[keyNames.name], [keyNames.id] : value[keyNames.id] }])
62
+ values.splice(i, 1);
63
+ setValues(values);
64
+ setSearchedOptions(values);
65
+ }}>
66
+ {value.name}
67
+ </div>)
58
68
  }) :
59
69
  <div className={styles['no-elements']}>No Elements!</div>
60
70
  }
@@ -72,5 +82,6 @@ Multiselect.propTypes = {
72
82
  jsonOptionsData: PropTypes.string,
73
83
  jsonSelectedOptionsData: PropTypes.string,
74
84
  onchange: PropTypes.func,
85
+ keyNames: PropTypes.object,
75
86
  };
76
87
 
@@ -2,17 +2,19 @@ import React from "react";
2
2
  import { Multiselect } from "./index";
3
3
 
4
4
  export default {
5
- component: Multiselect,
6
- title: "Components/Multiselect",
5
+ component: Multiselect,
6
+ title: "Components/Multiselect",
7
7
  };
8
8
 
9
9
  const Template = (args) => <Multiselect {...args} />;
10
10
 
11
11
  export const Default = Template.bind({});
12
12
  Default.args = {
13
- jsonOptionsData: '[{"id":"1", "name":"Կենտրոն"}]',
14
- jsonSelectedOptionsData: '[{"id":"0", "name":"Արաբկիր"}, {"id":"2", "name":"Մալաթիա"}]',
13
+ jsonOptionsData: '[{"bbb":"1", "value":"Կենտրոն"}]',
14
+ jsonSelectedOptionsData: '[{"bbb":"0", "value":"Արաբկիր"}, {"bbb":"2", "value":"Մալաթիա"}]',
15
15
  label: 'label',
16
- onchange: (newValue)=> {
17
- }
16
+ onchange: (newValue) => {
17
+ console.log(newValue);
18
+ },
19
+ keyNames: { name: 'value', id: 'bbb' }
18
20
  };
@@ -13,9 +13,9 @@ export const Pagination = ({
13
13
  offset,
14
14
  className,
15
15
  }) => {
16
- const [siblingCountNumber, setSibilingCountNumber] = useState(2);
17
- const [currentPageNumber, setCurrentPage] = useState(1);
18
- const [currentTotalCount, setcurrentTotalCount] = useState(10);
16
+ const [siblingCountNumber, setSibilingCountNumber] = useState(siblingCount);
17
+ const [currentPageNumber, setCurrentPage] = useState(currentPage);
18
+ const [currentTotalCount, setcurrentTotalCount] = useState(totalCount);
19
19
  useEffect(() => {
20
20
  setcurrentTotalCount(totalCount);
21
21
  }, [totalCount]);
@@ -31,7 +31,7 @@ export const Pagination = ({
31
31
  };
32
32
  useEffect(() => {
33
33
  onChange(currentPageNumber);
34
- }, []);
34
+ }, [currentPageNumber]);
35
35
  const paginationRange = PaginationRange({
36
36
  currentPageNumber,
37
37
  currentTotalCount,
@@ -87,14 +87,7 @@ export const Pagination = ({
87
87
  <li
88
88
  onClick={() => onPageChange(pageNumber)}
89
89
  key={id}
90
- className={classnames(
91
- `${
92
- pageNumber === currentPageNumber
93
- ? styles.selected
94
- : styles.listItem
95
- }`, styles['pagination-item']
96
- )}
97
- >
90
+ className={classnames(`${pageNumber === currentPageNumber ? styles.selected : styles.listItem}`, styles['pagination-item'])}>
98
91
  {pageNumber}
99
92
  </li>
100
93
  );
@@ -22,21 +22,24 @@ export const SelectSize = {
22
22
  };
23
23
 
24
24
  export const Select = ({
25
- theme,
26
- size,
27
- className,
28
- disabled,
29
- label,
30
- jsonData,
31
- eMessage,
32
- required,
33
- defaultOption,
34
- onChange,
35
- selected
36
- }) => {
37
- const options = jsonData.length ? JSON.parse(jsonData) : []
25
+ theme,
26
+ size,
27
+ className,
28
+ disabled,
29
+ label,
30
+ jsonData,
31
+ eMessage,
32
+ required,
33
+ defaultOption,
34
+ onChange,
35
+ keyNames,
36
+ selected
37
+ }) => {
38
+ const options = jsonData.length ? JSON.parse(jsonData) : [];
39
+ const parseSelectedData =
40
+ selected.length !== 0 ? JSON.parse(selected) : {};
38
41
  let [opened, setOpened] = useState(false)
39
- let [newSelected, setNewSelected] = useState(selected)
42
+ let [newSelected, setNewSelected] = useState(parseSelectedData)
40
43
  const classProps = classnames(
41
44
  styles[theme],
42
45
  styles[size],
@@ -58,7 +61,7 @@ export const Select = ({
58
61
  setOpened(!opened)
59
62
  }}
60
63
  >
61
- <div className={styles['select-content-top-text']}>{newSelected && newSelected.name ? newSelected.name : defaultOption}</div>
64
+ <div className={styles['select-content-top-text']}>{newSelected && newSelected[keyNames.name] ? newSelected[keyNames.name] : defaultOption}</div>
62
65
  <div className={styles['select-content-top-icon']}>
63
66
  <Icon className={opened ? 'icon-arrow-up' : 'icon-arrow-down'}/>
64
67
  </div>
@@ -93,9 +96,9 @@ export const Select = ({
93
96
  setOpened(!opened);
94
97
  }
95
98
  }
96
- defaultValue={option.id}
99
+ defaultValue={option[keyNames.id]}
97
100
  >
98
- {option.name}
101
+ {option[keyNames.name]}
99
102
  </div>
100
103
  })
101
104
  }
@@ -122,8 +125,9 @@ Select.propTypes = {
122
125
  required: PropTypes.bool,
123
126
  disabled: PropTypes.bool,
124
127
  className: PropTypes.string,
125
- selected: PropTypes.object,
126
- jsonData: PropTypes.string
128
+ selected: PropTypes.string,
129
+ jsonData: PropTypes.string,
130
+ keyNames: PropTypes.object,
127
131
  };
128
132
 
129
133
  Select.defaultProps = {
@@ -11,10 +11,11 @@ export const Default = Template.bind({});
11
11
  Default.args = {
12
12
  theme: SelectTheme.DEFAULT,
13
13
  label: 'վարչական շրջան',
14
- jsonData: '[{"id":"0", "name":"Արաբկիր"}, {"id":"1", "name":"Կենտրոն"}, {"id":"2", "name":"Մալաթիա"}]',
14
+ jsonData: '[{"bbb":"0", "value":"Արաբկիր"}, {"bbb":"1", "value":"Կենտրոն"}, {"bbb":"2", "value":"Մալաթիա"}]',
15
15
  onChange: (newValue)=> {
16
16
  },
17
17
  defaultOption: 'ընտրել',
18
- selected: {"id":"2", "name":"Մալաթիա"}
18
+ selected: '{"bbb":"2", "value":"Մալաթիա"}',
19
+ keyNames: {name: 'value', id : 'bbb'}
19
20
  };
20
21
 
@@ -6,34 +6,22 @@ import styles from "./stepper.module.css";
6
6
  export const Stepper = ({ className, onChange, stepLength, activeSteps }) => {
7
7
  const classProps = classNames(className);
8
8
  return (
9
- <>
9
+ <div className={styles['stepper-container']}>
10
10
  {(() => {
11
11
  let steppers = [];
12
12
  for (let step = 1; step <= stepLength; step++) {
13
13
  steppers.push(
14
- <div
15
- className={classNames(
16
- `${step <= activeSteps ? styles.activeRing : styles.bigRing}`
17
- )}
18
- key={step}
19
- >
20
- <div
21
- className={classNames(
22
- `${
23
- step <= activeSteps
24
- ? styles.smallActiveRing
25
- : styles.smallRing
26
- }`
27
- )}
28
- >
29
- {step <= activeSteps ? step : ""}
14
+ <div className={classNames(`${step <= activeSteps ? styles.activeRing : styles.bigRing}`)} key={step}>
15
+ <div
16
+ className={classNames(`${step <= activeSteps ? styles.smallActiveRing : styles.smallRing}`)}>
17
+ {step <= activeSteps ? step : ""}
18
+ </div>
30
19
  </div>
31
- </div>
32
20
  );
33
21
  }
34
22
  return steppers;
35
23
  })()}
36
- </>
24
+ </div>
37
25
  );
38
26
  };
39
27
 
@@ -1,48 +1,58 @@
1
+ .stepper-container > div:last-child:before {
2
+ display: none;
3
+ }
4
+ .bigRing, .activeRing {
5
+ position: relative;
6
+ width: 36px;
7
+ height: 36px;
8
+ border-radius: 50%;
9
+ margin-bottom: 36px;
10
+ cursor:pointer;
11
+ }
1
12
  .bigRing {
2
- width: 30px;
3
- height: 30px;
4
- border: 1px solid gray;
5
- border-radius: 50%;
6
- position: relative;
7
- margin: 10px;
8
- cursor:pointer;
9
- }
10
-
11
- .smallRing {
12
- position: absolute;
13
- width: 50%;
14
- height: 50%;
15
- border-radius: 50%;
16
- background-color: gray;
17
- top: 50%;
18
- left: 50%;
19
- transform: translate(-50%, -50%);
20
- font-size: 12px;
21
- color: white;
22
- text-align: center;
23
- }
24
-
25
-
26
- .activeRing {
27
- width: 30px;
28
- height: 30px;
29
- border: 1px solid blue;
30
- border-radius: 50%;
31
- position: relative;
32
- margin: 10px;
33
- cursor:pointer;
34
- }
35
-
36
- .smallActiveRing {
37
- position: absolute;
38
- width: 50%;
39
- height: 50%;
40
- border-radius: 50%;
41
- background-color: blue;
42
- top: 50%;
43
- left: 50%;
44
- transform: translate(-50%, -50%);
45
- font-size: 12px;
46
- color: white;
47
- text-align: center;
48
- }
13
+ box-shadow: 0 0 0 2px #D1D1D1;
14
+ }
15
+ .bigRing:before {
16
+ background: #D1D1D1;
17
+ }
18
+ .activeRing {
19
+ box-shadow: 0 0 0 2px #00236A;
20
+ }
21
+ .activeRing:before {
22
+ background: #00236A;
23
+ }
24
+ .bigRing:before, .activeRing:before {
25
+ position: absolute;
26
+ content: '';
27
+ width: 2px;
28
+ height: 28px;
29
+ bottom: -32px;
30
+ left: 0;
31
+ right: 0;
32
+ margin: auto;
33
+ border-radius: 20px;
34
+ overflow: hidden;
35
+ }
36
+ .smallRing, .smallActiveRing {
37
+ border-radius: 50%;
38
+ position: absolute;
39
+ top: 0;
40
+ left: 0;
41
+ right: 0;
42
+ bottom: 0;
43
+ margin: auto;
44
+ }
45
+ .smallRing {
46
+ width: 14px;
47
+ height: 14px;
48
+ background-color: #D1D1D1;
49
+ }
50
+ .smallActiveRing {
51
+ display: flex;
52
+ align-items: center;
53
+ justify-content: center;
54
+ width: 28px;
55
+ height: 28px;
56
+ background-color: #00236A;
57
+ color: #ffffff;
58
+ }