@xaypay/tui 0.0.115 → 0.0.117

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 (32) hide show
  1. package/dist/index.es.js +361 -256
  2. package/dist/index.js +361 -256
  3. package/package.json +1 -1
  4. package/src/components/button/index.js +3 -2
  5. package/src/components/captcha/index.js +5 -5
  6. package/src/components/checkbox/checkbox.module.css +0 -59
  7. package/src/components/checkbox/checkbox.stories.js +70 -4
  8. package/src/components/checkbox/index.js +103 -70
  9. package/src/components/input/index.js +6 -4
  10. package/src/components/modal/index.js +15 -3
  11. package/src/components/newAutocomplete/index.js +7 -5
  12. package/src/components/newFile/index.js +45 -42
  13. package/src/components/pagination/index.js +9 -2
  14. package/src/components/select/index.js +7 -2
  15. package/src/components/singleCheckbox/Checkbox.js +30 -19
  16. package/src/components/singleCheckbox/index.js +15 -9
  17. package/src/components/stepper/index.js +9 -2
  18. package/src/components/table/index.js +45 -4
  19. package/src/components/table/table.stories.js +1 -10
  20. package/src/components/table/td.js +41 -6
  21. package/src/components/table/th.js +12 -2
  22. package/src/components/textarea/index.js +8 -1
  23. package/src/components/toaster/index.js +7 -2
  24. package/src/components/tooltip/index.js +3 -3
  25. package/src/components/typography/index.js +1 -1
  26. package/src/index.js +0 -1
  27. package/src/stories/configuration.stories.mdx +45 -4
  28. package/src/stories/static/checkbox-group-usage-2.png +0 -0
  29. package/src/stories/static/checkbox-group-usage.png +0 -0
  30. package/src/stories/static/single-checkbox-usage.png +0 -0
  31. package/src/stories/usage.stories.mdx +11 -1
  32. package/tui.config.js +42 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.0.115",
3
+ "version": "0.0.117",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -5,7 +5,6 @@ import { compereConfigs } from './../../utils'
5
5
 
6
6
  export const Button = ({
7
7
  icon,
8
- hoverIcon,
9
8
  size,
10
9
  type,
11
10
  font,
@@ -23,6 +22,7 @@ export const Button = ({
23
22
  disabled,
24
23
  className,
25
24
  boxSizing,
25
+ hoverIcon,
26
26
  hoverColor,
27
27
  transition,
28
28
  contentWidth,
@@ -44,7 +44,7 @@ export const Button = ({
44
44
  }, [])
45
45
 
46
46
  const configStyles = compereConfigs()
47
- const classProps = classnames(className)
47
+ const classProps = classnames(className ? className : configStyles.BUTTON.className)
48
48
 
49
49
  const handleMouseEnter = () => {
50
50
  setIsHover(true)
@@ -58,6 +58,7 @@ export const Button = ({
58
58
  <button
59
59
  style={{
60
60
  display: 'flex',
61
+ outline: 'none',
61
62
  alignItems: 'center',
62
63
  justifyContent: 'center',
63
64
  fontSize: size ? size : configStyles.BUTTON.size,
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import PropTypes from 'prop-types'
3
-
3
+ import classnames from 'classnames'
4
4
  import { compereConfigs } from './../../utils'
5
5
 
6
6
  import SvgCaptchaArrowUp from './../icon/CaptchaArrowUp'
@@ -8,11 +8,11 @@ import SvgCaptchaArrowDown from './../icon/CaptchaArrowDown'
8
8
 
9
9
  import styles from './captcha.module.css'
10
10
 
11
- export const Captcha = ({ size, color, range, label, getRange }) => {
11
+ export const Captcha = ({ size, color, range, label, className, getRange }) => {
12
12
  const [rangeNumber, setRangeNumber] = useState(0)
13
13
  const [rangeProgress, setRangeProgress] = useState(0)
14
-
15
14
  const configStyles = compereConfigs()
15
+ const classProps = classnames(className ? className : configStyles.CAPTCHA.className)
16
16
 
17
17
  const handleRange = (e) => {
18
18
  const value = e.target.value
@@ -38,7 +38,7 @@ export const Captcha = ({ size, color, range, label, getRange }) => {
38
38
  }, [range, getRange])
39
39
 
40
40
  return (
41
- <>
41
+ <div className={classProps}>
42
42
  {label && (
43
43
  <p
44
44
  style={{
@@ -147,7 +147,7 @@ export const Captcha = ({ size, color, range, label, getRange }) => {
147
147
  <SvgCaptchaArrowUp />
148
148
  </div>
149
149
  </div>
150
- </>
150
+ </div>
151
151
  )
152
152
  }
153
153
 
@@ -1,59 +0,0 @@
1
- .checkbox-wrap {
2
- position: relative;
3
- display: inline-flex;
4
- flex-direction: row;
5
- flex-wrap: nowrap;
6
- align-items: center;
7
- margin: 0 6px;
8
- padding-left: 24px;
9
- cursor: pointer;
10
- }
11
- .checkbox-wrap > input {
12
- position: absolute;
13
- opacity: 0;
14
- height: 0;
15
- width: 0;
16
- }
17
-
18
- .checkbox-wrap .checkmark {
19
- position: absolute;
20
- top: 0;
21
- left: 0;
22
- bottom: 0;
23
- margin: auto;
24
- display: inline-block;
25
- vertical-align: top;
26
- width: 14px;
27
- height: 14px;
28
- border: 1px solid #d9d9d9;
29
- border-radius: 3px;
30
- margin-right: 4px;
31
- transition: border-color 240ms;
32
- }
33
-
34
- .checkbox-wrap > .checkmark:after {
35
- position: absolute;
36
- content: '';
37
- display: block;
38
- left: 4px;
39
- top: 1px;
40
- width: 4px;
41
- height: 8px;
42
- border: solid #1890ff;
43
- border-width: 0 2px 2px 0;
44
- transform: rotate(45deg);
45
- opacity: 0;
46
- transition: opacity 240ms;
47
- }
48
-
49
- .checkbox-wrap input:checked ~ .checkmark:after {
50
- opacity: 1;
51
- }
52
-
53
- .checkbox-wrap input:checked ~ .checkmark {
54
- border-color: #1890ff;
55
- }
56
-
57
- .checkbox-wrap:hover input ~ .checkmark {
58
- border-color: #1890ff;
59
- }
@@ -1,10 +1,76 @@
1
- import React from 'react'
2
- import { Checkbox } from '.'
1
+ import React, { useState } from 'react'
2
+ import { Checkbox, DirectionMode } from '.'
3
+ import SvgCancel from './../icon/Cancel'
4
+ import SvgDone from './../icon/Done'
3
5
  export default {
4
6
  component: Checkbox,
5
7
  title: 'Components/Checkbox',
8
+ argsType: {
9
+ direction: {
10
+ options: Object.values(DirectionMode),
11
+ },
12
+ },
6
13
  }
7
14
 
8
- const Template = (args) => <Checkbox {...args} />
15
+ const checkBoxData = [
16
+ {
17
+ id: 1,
18
+ label: '1 checkbox',
19
+ checked: true,
20
+ disabled: true,
21
+ ignoreDisabledForChecked: true,
22
+ },
23
+ {
24
+ id: 2,
25
+ label: '2 checkbox',
26
+ checked: true,
27
+ },
28
+ {
29
+ id: 3,
30
+ label: '3 checkbox',
31
+ checked: true,
32
+ },
33
+ {
34
+ id: 4,
35
+ label: '4 checkbox',
36
+ checked: true,
37
+ },
38
+ {
39
+ id: 5,
40
+ label: '5 checkbox',
41
+ checked: true,
42
+ },
43
+ {
44
+ id: 6,
45
+ label: '6 checkbox',
46
+ checked: true,
47
+ },
48
+ ];
9
49
 
10
- export const CheckboxButton = Template.bind({})
50
+ const Template = (args) => {
51
+ const [innerData, setInnerData] = useState(checkBoxData)
52
+
53
+ const handleGetData = (data) => {
54
+ console.log(data, 'data - - -')
55
+ setInnerData(data.checkboxArr)
56
+ }
57
+
58
+ return (
59
+ <Checkbox
60
+ {...args}
61
+ data={innerData}
62
+ getData={handleGetData}
63
+ checkedIcon={<SvgCancel />}
64
+ unCheckedIcon={<SvgDone />}
65
+ keyNames={{
66
+ id: 'id',
67
+ label: 'label',
68
+ checked: 'checked',
69
+ disabled: 'disabled',
70
+ ignoreDisabledForChecked: 'ignoreDisabledForChecked',
71
+ }}
72
+ />
73
+ )
74
+ }
75
+
76
+ export const Default = Template.bind({})
@@ -1,87 +1,120 @@
1
- import React, { useState } from 'react'
1
+ import React, { useState, useEffect } from 'react'
2
2
  import PropTypes from 'prop-types'
3
- import classNames from 'classnames'
4
- import styles from './checkbox.module.css'
5
- import { useEffect } from 'react'
3
+ import classnames from 'classnames'
4
+ import { SingleCheckbox } from './../singleCheckbox'
5
+ import { compereConfigs } from './../../utils'
6
6
 
7
- export const Checkbox = ({ disabled, required, className, jsonData, onChange, keyNames, onClick, ...props }) => {
8
- const classProps = classNames(styles.checkbox, className, 'checkbox-input-rem')
9
- const parseData = jsonData.length !== 0 ? JSON.parse(jsonData) : []
10
- const [data, setData] = useState(parseData)
11
-
12
- useEffect(() => {
13
- const parseData = jsonData.length !== 0 ? JSON.parse(jsonData) : []
14
- setData(parseData)
15
- }, [jsonData])
16
- useEffect(() => {
17
- onChange ? onChange(data.filter((d) => d.checked)) : ''
18
- }, [data])
7
+ export const DirectionMode = {
8
+ VERTICAL: 'vertical',
9
+ HORINZONTAL: 'horizontal',
10
+ }
19
11
 
20
- const handleChange = (e) => {
21
- let id
22
- data.forEach((value, key) => {
23
- if (value[keyNames.value] === e.target.value) {
24
- id = key
25
- }
26
- })
12
+ export const Checkbox = ({
13
+ data,
14
+ getData,
15
+ keyNames,
16
+ className,
17
+ direction,
18
+ checkedIcon,
19
+ unCheckedIcon,
20
+ labelMarginLeft,
21
+ checkBoxMarginBottom,
22
+ }) => {
23
+ const configStyles = compereConfigs()
24
+ const [innerData, setInnerData] = useState([])
25
+ const classProps = classnames(className ? className : configStyles.CHECKBOX.className)
27
26
 
28
- let items = [...data]
29
- let item = { ...items[id] }
30
- item.checked = !item.checked
31
- items[id] = item
32
- setData(items)
27
+ const handleSendData = (_, e, index) => {
28
+ const dataForSend = {}
29
+ setInnerData((prev) =>
30
+ prev.map((innerItem, innerIndex) => {
31
+ if (innerIndex === index) {
32
+ innerItem[keyNames.checked] = !innerItem[keyNames.checked]
33
+ dataForSend.item = innerItem
34
+ dataForSend.itemIndex = innerIndex
35
+ dataForSend.itemId = innerItem[keyNames.id]
36
+ }
37
+ return innerItem
38
+ })
39
+ )
40
+ dataForSend.checkboxArr = innerData
41
+ getData && getData(dataForSend)
33
42
  }
34
43
 
35
- !keyNames ? (keyNames = { id: 'id', name: 'name', value: 'value', label: 'label' }) : ''
44
+ useEffect(() => {
45
+ if (Array.isArray(data)) {
46
+ setInnerData(data)
47
+ } else {
48
+ setInnerData([data])
49
+ }
50
+ }, [data])
36
51
 
37
52
  return (
38
- <>
39
- {data.map((element) => {
40
- return (
41
- <label className={`${styles['checkbox-wrap']} checkbox-wrap-rem`} key={element.value}>
42
- <input
43
- type="checkbox"
44
- className={classProps}
45
- disabled={disabled}
46
- required={required}
47
- value={keyNames.value ? element[keyNames.value] : ''}
48
- name={keyNames.name ? element[keyNames.name] : ''}
49
- id={keyNames.id ? element[keyNames.id] : ''}
50
- onChange={handleChange}
51
- onClick={onClick ? onClick : () => {}}
52
- defaultChecked={element.checked}
53
- {...props}
54
- />
55
- <span className={`${styles['checkmark']} checkmark-rem`} />
56
- {element[keyNames.label] ? (
57
- <label className={styles.labelCheckbox} htmlFor={element[keyNames.id]}>
58
- {element[keyNames.label]}
59
- </label>
60
- ) : (
61
- ''
62
- )}
63
- </label>
64
- )
65
- })}
66
- </>
53
+ <div
54
+ style={{
55
+ width: '100%',
56
+ display: 'flex',
57
+ flexDirection: direction === 'vertical' ? 'column' : 'row',
58
+ }}
59
+ className={classProps}
60
+ >
61
+ {innerData &&
62
+ innerData.length > 0 &&
63
+ innerData.map((item, index) => {
64
+ return (
65
+ <div
66
+ key={`TUI_${index}_checkbox`}
67
+ style={{
68
+ width: 'fit-content',
69
+ marginBottom:
70
+ direction === 'vertical'
71
+ ? checkBoxMarginBottom
72
+ ? checkBoxMarginBottom
73
+ : configStyles.CHECKBOX.checkBoxMarginBottom
74
+ : '0px',
75
+ }}
76
+ >
77
+ <SingleCheckbox
78
+ data={item}
79
+ index={index}
80
+ checkedColor="#00236A"
81
+ unCheckedColor="#D1D1D1"
82
+ checkedIcon={checkedIcon}
83
+ label={item[keyNames.label]}
84
+ unCheckedIcon={unCheckedIcon}
85
+ handleChecked={handleSendData}
86
+ checked={item[keyNames.checked]}
87
+ disabled={item[keyNames.disabled]}
88
+ ignoreDisabledForChecked={item[keyNames.ignoreDisabledForChecked]}
89
+ labelMarginLeft={
90
+ labelMarginLeft ? labelMarginLeft : configStyles.CHECKBOX.labelMarginLeft
91
+ }
92
+ />
93
+ </div>
94
+ )
95
+ })}
96
+ </div>
67
97
  )
68
98
  }
69
99
 
70
100
  Checkbox.propTypes = {
71
- className: PropTypes.string,
72
- onChange: PropTypes.func,
73
- onClick: PropTypes.func,
74
- required: PropTypes.bool,
75
- disabled: PropTypes.bool,
76
- name: PropTypes.string,
77
- value: PropTypes.string,
78
- jsonData: PropTypes.string,
79
- label: PropTypes.string,
101
+ getData: PropTypes.func,
80
102
  keyNames: PropTypes.object,
103
+ checkedIcon: PropTypes.element,
104
+ unCheckedIcon: PropTypes.element,
105
+ labelMarginLeft: PropTypes.string,
106
+ checkBoxMarginBottom: PropTypes.string,
107
+ direction: PropTypes.oneOf(Object.values(DirectionMode)),
108
+ data: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]),
81
109
  }
82
110
 
83
111
  Checkbox.defaultProps = {
84
- onChange: undefined,
85
- jsonData:
86
- '[{"value":"email", "name":"contact1", "label":"Email", "id":"contactChoice1"}, {"value":"phone", "name":"contact2", "label":"Phone", "id":"contactChoice2"}]',
112
+ direction: 'vertical',
113
+ keyNames: {
114
+ id: 'id',
115
+ label: 'label',
116
+ checked: 'checked',
117
+ disabled: 'disabled',
118
+ ignoreDisabledForChecked: 'ignoreDisabledForChecked',
119
+ },
87
120
  }
@@ -64,6 +64,7 @@ export const Input = ({
64
64
  boxShadowHover,
65
65
  errorClassName,
66
66
  errorAnimation,
67
+ labelFontFamily,
67
68
  phoneAlignItems,
68
69
  errorLineHeight,
69
70
  labelLineHeight,
@@ -88,7 +89,8 @@ export const Input = ({
88
89
  const configStyles = compereConfigs()
89
90
  const classProps = classnames(
90
91
  className ? className : configStyles.INPUT.className,
91
- type === 'number' ? styles['inp-num'] : ''
92
+ type === 'number' ? styles['inp-num'] : '',
93
+ styles['input-wrap']
92
94
  )
93
95
 
94
96
  const errorShow = keyframes`
@@ -420,10 +422,9 @@ export const Input = ({
420
422
  ])
421
423
 
422
424
  return (
423
- <div className={`${styles['input-wrap']}`}>
425
+ <div className={classProps}>
424
426
  {label ? (
425
427
  <label
426
- className={`${styles['input-title']}`}
427
428
  style={{
428
429
  color: labelColor ? labelColor : configStyles.INPUT.labelColor,
429
430
  fontSize: labelSize ? labelSize : configStyles.INPUT.labelSize,
@@ -431,6 +432,7 @@ export const Input = ({
431
432
  fontWeight: labelWeight ? labelWeight : configStyles.INPUT.labelWeight,
432
433
  lineHeight: labelLineHeight ? labelLineHeight : configStyles.INPUT.labelLineHeight,
433
434
  marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.INPUT.labelMarginBottom,
435
+ fontFamily: labelFontFamily ? labelFontFamily : configStyles.INPUT.labelFontFamily,
434
436
  }}
435
437
  >
436
438
  {label}
@@ -533,7 +535,6 @@ export const Input = ({
533
535
  <input
534
536
  {...props}
535
537
  value={innerValue}
536
- className={classProps}
537
538
  onInput={handleChange}
538
539
  disabled={disabled ? disabled : ''}
539
540
  name={name ? name : `tui_${random}_tui`}
@@ -662,6 +663,7 @@ Input.propTypes = {
662
663
  errorPosition: PropTypes.string,
663
664
  boxShadowHover: PropTypes.string,
664
665
  errorClassName: PropTypes.string,
666
+ labelFontFamily: PropTypes.string,
665
667
  telErrorMessage: PropTypes.string,
666
668
  backgroundColor: PropTypes.string,
667
669
  phoneAlignItems: PropTypes.string,
@@ -50,10 +50,11 @@ export const Modal = ({
50
50
  layerBackgroundColor,
51
51
  }) => {
52
52
  const [select, setSelect] = useState(0)
53
+ const [isHover, setIsHover] = useState(false)
53
54
  const [innerData, setInnerData] = useState([])
54
55
 
55
56
  const configStyles = compereConfigs()
56
- const classProps = classnames(className)
57
+ const classProps = classnames(className ? className : configStyles.MODAL.className)
57
58
 
58
59
  const handleCloseModal = () => {
59
60
  setShow(false)
@@ -91,6 +92,14 @@ export const Modal = ({
91
92
  imageLink.click()
92
93
  }
93
94
 
95
+ const handleMouseEnter = () => {
96
+ setIsHover(true)
97
+ }
98
+
99
+ const handleMouseLeave = () => {
100
+ setIsHover(false)
101
+ }
102
+
94
103
  useEffect(() => {
95
104
  if (type === 'images') {
96
105
  if (data) {
@@ -128,6 +137,7 @@ export const Modal = ({
128
137
 
129
138
  return (
130
139
  <div
140
+ className={classProps}
131
141
  onClick={outsideClose || configStyles.MODAL.outsideClose ? handleCloseModal : (_) => _}
132
142
  style={{
133
143
  top: '0px',
@@ -150,7 +160,7 @@ export const Modal = ({
150
160
  }}
151
161
  >
152
162
  <div
153
- className={`${classProps} ${styles['animation__modal']}`}
163
+ className={`${styles['animation__modal']}`}
154
164
  onClick={handleStopClosing}
155
165
  style={{
156
166
  position: 'relative',
@@ -225,6 +235,8 @@ export const Modal = ({
225
235
  borderStyle: borderStyle ? borderStyle : configStyles.MODAL.borderStyle,
226
236
  borderColor: borderColor ? borderColor : configStyles.MODAL.borderColor,
227
237
  }}
238
+ onMouseEnter={handleMouseEnter}
239
+ onMouseLeave={handleMouseLeave}
228
240
  >
229
241
  {type === 'content' ? (
230
242
  children ? (
@@ -303,7 +315,7 @@ export const Modal = ({
303
315
  }}
304
316
  src={item.url}
305
317
  />
306
- {showZoomIcon ? (
318
+ {isHover && showZoomIcon ? (
307
319
  <div
308
320
  style={{
309
321
  top: '0px',
@@ -35,6 +35,7 @@ export const NewAutocomplete = ({
35
35
  contentPosition,
36
36
  contentTopColor,
37
37
  labelLineHeight,
38
+ labelFontFamily,
38
39
  contentDirection,
39
40
  contentTopWeight,
40
41
  contentTopRadius,
@@ -166,7 +167,7 @@ export const NewAutocomplete = ({
166
167
  }
167
168
 
168
169
  const optionList = (
169
- <>
170
+ <div>
170
171
  {show && innerOptions && !disabled ? (
171
172
  innerOptions.length > 0 ? (
172
173
  <div
@@ -340,7 +341,7 @@ export const NewAutocomplete = ({
340
341
  ) : (
341
342
  ''
342
343
  )}
343
- </>
344
+ </div>
344
345
  )
345
346
 
346
347
  useEffect(() => {
@@ -384,7 +385,7 @@ export const NewAutocomplete = ({
384
385
  }, [errorMessage])
385
386
 
386
387
  return (
387
- <>
388
+ <div className={classProps}>
388
389
  {label ? (
389
390
  <label
390
391
  style={{
@@ -392,6 +393,7 @@ export const NewAutocomplete = ({
392
393
  fontSize: labelSize ? labelSize : configStyles.NEWAUTOCOMPLETE.labelSize,
393
394
  display: labelDisplay ? labelDisplay : configStyles.NEWAUTOCOMPLETE.labelDisplay,
394
395
  fontWeight: labelWeight ? labelWeight : configStyles.NEWAUTOCOMPLETE.labelWeight,
396
+ fontFamily: labelFontFamily ? labelFontFamily : configStyles.NEWAUTOCOMPLETE.labelFontFamily,
395
397
  lineHeight: labelLineHeight ? labelLineHeight : configStyles.NEWAUTOCOMPLETE.labelLineHeight,
396
398
  maxWidth: contentTopMaxWidth
397
399
  ? contentTopMaxWidth
@@ -432,7 +434,6 @@ export const NewAutocomplete = ({
432
434
  onInput={handleChange}
433
435
  onMouseEnter={handleMouseEnter}
434
436
  onMouseLeave={handleMouseLeave}
435
- className={classProps}
436
437
  placeholder={placeHolder ? placeHolder : ''}
437
438
  autoComplete={autoComplete ? autoComplete : configStyles.NEWAUTOCOMPLETE.autoComplete}
438
439
  style={{
@@ -503,7 +504,7 @@ export const NewAutocomplete = ({
503
504
 
504
505
  {optionList}
505
506
  </div>
506
- </>
507
+ </div>
507
508
  )
508
509
  }
509
510
 
@@ -531,6 +532,7 @@ NewAutocomplete.propTypes = {
531
532
  labelLineHeight: PropTypes.string,
532
533
  contentTopColor: PropTypes.string,
533
534
  change: PropTypes.func.isRequired,
535
+ labelFontFamily: PropTypes.string,
534
536
  contentDirection: PropTypes.string,
535
537
  contentTopWeight: PropTypes.number,
536
538
  contentTopRadius: PropTypes.string,