@xaypay/tui 0.0.111 → 0.0.113
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 +184 -82
- package/dist/index.js +184 -82
- package/package.json +1 -1
- package/src/components/input/index.js +24 -0
- package/src/components/input/input.stories.js +0 -2
- package/src/components/modal/index.js +2 -3
- package/src/components/newAutocomplete/index.js +2 -3
- package/src/components/newFile/fileItem.js +1 -0
- package/src/components/newFile/index.js +84 -12
- package/src/components/newFile/newFile.stories.js +2 -1
- package/src/components/select/index.js +2 -3
- package/src/components/table/index.js +30 -20
- package/src/components/table/table.stories.js +1 -10
- package/src/components/table/td.js +61 -50
- package/src/components/table/th.js +12 -8
- package/src/components/textarea/index.js +4 -6
- package/src/components/typography/index.js +1 -1
- package/src/utils/index.js +4 -0
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classnames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import { compereConfigs } from './../../utils'
|
|
5
|
+
import { compereConfigs, hasOwnerProperty } from './../../utils'
|
|
6
6
|
import styles from './modal.module.css'
|
|
7
7
|
|
|
8
8
|
import SvgNext from './../icon/Next'
|
|
@@ -266,8 +266,7 @@ export const Modal = ({
|
|
|
266
266
|
innerData.length > 0 &&
|
|
267
267
|
innerData.map((item, index) => {
|
|
268
268
|
if (select === index) {
|
|
269
|
-
|
|
270
|
-
if (!item.hasOwnProperty('url')) {
|
|
269
|
+
if (!hasOwnerProperty(item, 'url')) {
|
|
271
270
|
alert('Please add url property in data prop on each element')
|
|
272
271
|
} else {
|
|
273
272
|
return (
|
|
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
4
|
import classnames from 'classnames'
|
|
5
|
-
import { compereConfigs } from './../../utils'
|
|
5
|
+
import { compereConfigs, hasOwnerProperty } from './../../utils'
|
|
6
6
|
|
|
7
7
|
import SvgRequired from './../icon/Required'
|
|
8
8
|
|
|
@@ -351,8 +351,7 @@ export const NewAutocomplete = ({
|
|
|
351
351
|
options &&
|
|
352
352
|
options.length > 0 &&
|
|
353
353
|
options.map((item) => {
|
|
354
|
-
|
|
355
|
-
if (!item.hasOwnProperty(keyNames.name)) {
|
|
354
|
+
if (!hasOwnerProperty(item, keyNames.name)) {
|
|
356
355
|
alert(`Please add ${keyNames.name} property in items of options array`)
|
|
357
356
|
}
|
|
358
357
|
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useRef, useState, useEffect, useMemo } from 'react'
|
|
2
|
-
import ReactDOM from 'react-dom'
|
|
3
2
|
import PropTypes from 'prop-types'
|
|
4
3
|
import { v4 as uuidv4 } from 'uuid'
|
|
5
4
|
|
|
@@ -56,6 +55,7 @@ export const NewFile = ({
|
|
|
56
55
|
listItemPadding,
|
|
57
56
|
progressFontSize,
|
|
58
57
|
borderHoverColor,
|
|
58
|
+
maxCHoosenLength,
|
|
59
59
|
listItemErrorSize,
|
|
60
60
|
progressTrackColor,
|
|
61
61
|
fileAreaImageWidth,
|
|
@@ -66,9 +66,11 @@ export const NewFile = ({
|
|
|
66
66
|
progressSuccessColor,
|
|
67
67
|
progressLoadingColor,
|
|
68
68
|
hiddenBackgroundColor,
|
|
69
|
+
maxCHoosenLengthError,
|
|
69
70
|
extentionsRowMarginTop,
|
|
70
71
|
listItemBackgroundColor,
|
|
71
72
|
listItemBackgroundErrorColor,
|
|
73
|
+
maxCHoosenLengthErrorHideTime,
|
|
72
74
|
}) => {
|
|
73
75
|
const ref = useRef(null)
|
|
74
76
|
const inpRef = useRef(null)
|
|
@@ -77,6 +79,7 @@ export const NewFile = ({
|
|
|
77
79
|
const [error, setError] = useState('')
|
|
78
80
|
const [isHover, setIsHover] = useState(false)
|
|
79
81
|
const [singleFile, setSingleFile] = useState(null)
|
|
82
|
+
const [choosenFileCount, setChoosenFileCount] = useState(0)
|
|
80
83
|
const [image, setImage] = useState(
|
|
81
84
|
!multiple ? (defaultData ? (defaultData.type !== 'application/pdf' ? defaultData.url : 'pdf') : null) : null
|
|
82
85
|
)
|
|
@@ -84,10 +87,6 @@ export const NewFile = ({
|
|
|
84
87
|
const configStyles = compereConfigs()
|
|
85
88
|
|
|
86
89
|
const handleRemoveComponent = () => {
|
|
87
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
88
|
-
const node = ReactDOM.findDOMNode(ref.current)
|
|
89
|
-
const parent = node.parentNode
|
|
90
|
-
parent.removeChild(node)
|
|
91
90
|
if (!multiple) {
|
|
92
91
|
removeFile && removeFile(singleFile)
|
|
93
92
|
} else {
|
|
@@ -101,12 +100,59 @@ export const NewFile = ({
|
|
|
101
100
|
removeFile && removeFile(singleFile)
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
const handleUploadFiles = (file) => {
|
|
104
|
+
if (maxCHoosenLength && choosenFileCount > 0) {
|
|
105
|
+
if (file.length > choosenFileCount || file.length + memoizedItems.length > choosenFileCount) {
|
|
106
|
+
setError(
|
|
107
|
+
maxCHoosenLengthError
|
|
108
|
+
? maxCHoosenLengthError
|
|
109
|
+
: `Դիմումին կարող եք կցել առավելագույնը ${choosenFileCount} ֆայլ`
|
|
110
|
+
)
|
|
111
|
+
const clearFunc = () => {
|
|
112
|
+
clearTimeout(time)
|
|
113
|
+
}
|
|
114
|
+
const time = setTimeout(
|
|
115
|
+
() => {
|
|
116
|
+
setError('')
|
|
117
|
+
clearFunc()
|
|
118
|
+
},
|
|
119
|
+
maxCHoosenLengthErrorHideTime && typeof maxCHoosenLengthErrorHideTime === 'number'
|
|
120
|
+
? Math.round(maxCHoosenLengthErrorHideTime)
|
|
121
|
+
: 3000
|
|
122
|
+
)
|
|
123
|
+
} else {
|
|
124
|
+
for (let ix = 0; ix < file.length; ix++) {
|
|
125
|
+
if (file[ix]) {
|
|
126
|
+
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
127
|
+
if (
|
|
128
|
+
fileExtensions.includes(file[ix].type.split('/')[1]) ||
|
|
129
|
+
(fileExtensions.includes('heic') && file[ix].type.split('/')[1] === 'heif')
|
|
130
|
+
) {
|
|
131
|
+
change({
|
|
132
|
+
id: '',
|
|
133
|
+
check: '',
|
|
134
|
+
status: '',
|
|
135
|
+
file: file[ix],
|
|
136
|
+
uuid: uuidv4(),
|
|
137
|
+
})
|
|
138
|
+
} else {
|
|
139
|
+
change({
|
|
140
|
+
file: file[ix],
|
|
141
|
+
uuid: uuidv4(),
|
|
142
|
+
check: formatError,
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
change({
|
|
147
|
+
file: file[ix],
|
|
148
|
+
uuid: uuidv4(),
|
|
149
|
+
check: maxSizeError,
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
110
156
|
for (let ix = 0; ix < file.length; ix++) {
|
|
111
157
|
if (file[ix]) {
|
|
112
158
|
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
@@ -137,6 +183,17 @@ export const NewFile = ({
|
|
|
137
183
|
}
|
|
138
184
|
}
|
|
139
185
|
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const handleChange = (e) => {
|
|
190
|
+
const file = e.target.files
|
|
191
|
+
|
|
192
|
+
if (multiple) {
|
|
193
|
+
setError('')
|
|
194
|
+
setImage(null)
|
|
195
|
+
handleUploadFiles(file)
|
|
196
|
+
|
|
140
197
|
if (file.length === 0 && memoizedItems.length === 0) {
|
|
141
198
|
setError(noChoosenFile)
|
|
142
199
|
}
|
|
@@ -229,7 +286,19 @@ export const NewFile = ({
|
|
|
229
286
|
if (multiple && !removeFile) {
|
|
230
287
|
alert('Please add removeFile prop on NewFile component, it is a require in multiple mode')
|
|
231
288
|
}
|
|
232
|
-
|
|
289
|
+
|
|
290
|
+
if (maxCHoosenLength) {
|
|
291
|
+
if (typeof maxCHoosenLength !== 'number') {
|
|
292
|
+
alert('maxCHoosenLength prop must be a number, please check it!')
|
|
293
|
+
} else {
|
|
294
|
+
if (maxCHoosenLength <= 0) {
|
|
295
|
+
setChoosenFileCount(1)
|
|
296
|
+
} else {
|
|
297
|
+
setChoosenFileCount(Math.round(maxCHoosenLength))
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}, [multiple, removeFile, filesArray && filesArray.length, defaultData, maxCHoosenLength])
|
|
233
302
|
|
|
234
303
|
useEffect(() => {
|
|
235
304
|
if (deleteComponent && !removeComponent) {
|
|
@@ -556,6 +625,7 @@ NewFile.propTypes = {
|
|
|
556
625
|
backgroundColor: PropTypes.string,
|
|
557
626
|
change: PropTypes.func.isRequired,
|
|
558
627
|
listItemPadding: PropTypes.string,
|
|
628
|
+
maxCHoosenLength: PropTypes.number,
|
|
559
629
|
progressFontSize: PropTypes.string,
|
|
560
630
|
borderHoverColor: PropTypes.string,
|
|
561
631
|
listItemErrorSize: PropTypes.string,
|
|
@@ -568,9 +638,11 @@ NewFile.propTypes = {
|
|
|
568
638
|
progressSuccessColor: PropTypes.string,
|
|
569
639
|
progressLoadingColor: PropTypes.string,
|
|
570
640
|
hiddenBackgroundColor: PropTypes.string,
|
|
641
|
+
maxCHoosenLengthError: PropTypes.string,
|
|
571
642
|
extentionsRowMarginTop: PropTypes.string,
|
|
572
643
|
listItemBackgroundColor: PropTypes.string,
|
|
573
644
|
listItemBackgroundErrorColor: PropTypes.string,
|
|
645
|
+
maxCHoosenLengthErrorHideTime: PropTypes.number,
|
|
574
646
|
filesArray: PropTypes.arrayOf(PropTypes.object),
|
|
575
647
|
fileExtensions: PropTypes.arrayOf(PropTypes.string),
|
|
576
648
|
}
|
|
@@ -25,12 +25,13 @@ const Template = (args) => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const handleRemoveComponent = (componentId) => {
|
|
28
|
-
|
|
28
|
+
alert(`You want to remove component with id, ${componentId}`)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<NewFile
|
|
33
33
|
{...args}
|
|
34
|
+
removeFromDOM
|
|
34
35
|
componentId={2}
|
|
35
36
|
filesArray={files}
|
|
36
37
|
change={handleChange}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classnames from 'classnames'
|
|
4
|
-
import { compereConfigs } from './../../utils'
|
|
4
|
+
import { compereConfigs, hasOwnerProperty } from './../../utils'
|
|
5
5
|
import { SingleCheckbox } from '../singleCheckbox'
|
|
6
6
|
|
|
7
7
|
import ReactArrowIcon from '../icon/Arrow'
|
|
@@ -152,8 +152,7 @@ export const Select = ({
|
|
|
152
152
|
|
|
153
153
|
const isObjectEmpty = (obj) => {
|
|
154
154
|
for (var key in obj) {
|
|
155
|
-
|
|
156
|
-
if (obj.hasOwnProperty(key)) {
|
|
155
|
+
if (hasOwnerProperty(obj, key)) {
|
|
157
156
|
return false
|
|
158
157
|
}
|
|
159
158
|
}
|
|
@@ -7,7 +7,7 @@ import TD from './td'
|
|
|
7
7
|
import SvgUpArrow from './../icon/UpArrow'
|
|
8
8
|
import SvgDownArrow from './../icon/DownArrow'
|
|
9
9
|
|
|
10
|
-
import { compereConfigs } from './../../utils'
|
|
10
|
+
import { compereConfigs, hasOwnerProperty } from './../../utils'
|
|
11
11
|
|
|
12
12
|
export const Table = ({
|
|
13
13
|
getData,
|
|
@@ -48,7 +48,7 @@ export const Table = ({
|
|
|
48
48
|
bodyData.map((item, index) => {
|
|
49
49
|
if (index === data.index) {
|
|
50
50
|
item.map((innerItem, innerIndex) => {
|
|
51
|
-
if (
|
|
51
|
+
if (hasOwnerProperty(innerItem, 'arrowComponent')) {
|
|
52
52
|
removeItemIndex = innerIndex
|
|
53
53
|
}
|
|
54
54
|
})
|
|
@@ -73,7 +73,7 @@ export const Table = ({
|
|
|
73
73
|
let headerWithoutArrow
|
|
74
74
|
|
|
75
75
|
header.map((item, index) => {
|
|
76
|
-
if (
|
|
76
|
+
if (hasOwnerProperty(item, 'arrowComponent')) {
|
|
77
77
|
removeItemIndex = index
|
|
78
78
|
}
|
|
79
79
|
})
|
|
@@ -121,7 +121,7 @@ export const Table = ({
|
|
|
121
121
|
let checkedItems = []
|
|
122
122
|
data.map((item, index) => {
|
|
123
123
|
item.map((innerItem, innerIndex) => {
|
|
124
|
-
if (
|
|
124
|
+
if (hasOwnerProperty(innerItem, 'checkBox')) {
|
|
125
125
|
if (!checkedItems[innerIndex]) {
|
|
126
126
|
checkedItems[innerIndex] = []
|
|
127
127
|
}
|
|
@@ -203,7 +203,7 @@ export const Table = ({
|
|
|
203
203
|
checkableItemBool = !item.checkBox.checked
|
|
204
204
|
item.checkBox.checked = !item.checkBox.checked
|
|
205
205
|
}
|
|
206
|
-
if (
|
|
206
|
+
if (hasOwnerProperty(item, 'arrowComponent')) {
|
|
207
207
|
removeItemIndex = index
|
|
208
208
|
}
|
|
209
209
|
return item
|
|
@@ -255,7 +255,7 @@ export const Table = ({
|
|
|
255
255
|
if (
|
|
256
256
|
innerItem.id === data.id &&
|
|
257
257
|
innerItem.content == data.content &&
|
|
258
|
-
|
|
258
|
+
hasOwnerProperty(innerItem, 'checkBox')
|
|
259
259
|
) {
|
|
260
260
|
innerItem.checkBox.checked = !innerItem.checkBox.checked
|
|
261
261
|
handleHeaderCheckedUpdate({
|
|
@@ -318,7 +318,7 @@ export const Table = ({
|
|
|
318
318
|
const handleCheckArrowAction = (item, rowPosition) => {
|
|
319
319
|
const status = item.status
|
|
320
320
|
const checkedOpenableRow = body[rowPosition].map((innerItem) => {
|
|
321
|
-
if (
|
|
321
|
+
if (hasOwnerProperty(innerItem, 'status')) {
|
|
322
322
|
if (status === 'close') {
|
|
323
323
|
innerItem.status = 'open'
|
|
324
324
|
} else {
|
|
@@ -346,10 +346,7 @@ export const Table = ({
|
|
|
346
346
|
single = item
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
if (
|
|
350
|
-
Object.prototype.hasOwnProperty.call(item, 'status') &&
|
|
351
|
-
!Object.prototype.hasOwnProperty.call(item, 'arrowComponent')
|
|
352
|
-
) {
|
|
349
|
+
if (hasOwnerProperty(item, 'status') && !hasOwnerProperty(item, 'arrowComponent')) {
|
|
353
350
|
allArrows.push(item)
|
|
354
351
|
}
|
|
355
352
|
|
|
@@ -357,7 +354,7 @@ export const Table = ({
|
|
|
357
354
|
})
|
|
358
355
|
|
|
359
356
|
const checkedOpenableRowArrow = checkedOpenableRow.map((item) => {
|
|
360
|
-
if (
|
|
357
|
+
if (hasOwnerProperty(item, 'arrowComponent')) {
|
|
361
358
|
if (single && single.status === 'close') {
|
|
362
359
|
item.status = 'close'
|
|
363
360
|
} else if (single && single.status === 'open') {
|
|
@@ -390,7 +387,7 @@ export const Table = ({
|
|
|
390
387
|
|
|
391
388
|
const checkedOpenableAllRowsBody = body.map((innerItem) => {
|
|
392
389
|
return innerItem.map((iElem) => {
|
|
393
|
-
if (
|
|
390
|
+
if (hasOwnerProperty(iElem, 'status')) {
|
|
394
391
|
if (item.status === 'open') {
|
|
395
392
|
iElem.status = 'open'
|
|
396
393
|
} else {
|
|
@@ -408,7 +405,7 @@ export const Table = ({
|
|
|
408
405
|
e.stopPropagation()
|
|
409
406
|
const checkBodyMore = body.map((elemItem, elemIndex) => {
|
|
410
407
|
return elemItem.map((elemInnerItem, elemInnerIndex) => {
|
|
411
|
-
if (elemIndex === index &&
|
|
408
|
+
if (elemIndex === index && hasOwnerProperty(elemInnerItem, 'dots')) {
|
|
412
409
|
if (elemInnerIndex === innerIndex) {
|
|
413
410
|
if (item.dotsStatus === 'deActive') {
|
|
414
411
|
elemInnerItem.dotsStatus = 'active'
|
|
@@ -416,7 +413,7 @@ export const Table = ({
|
|
|
416
413
|
elemInnerItem.dotsStatus = 'deActive'
|
|
417
414
|
}
|
|
418
415
|
}
|
|
419
|
-
} else if (elemIndex !== index &&
|
|
416
|
+
} else if (elemIndex !== index && hasOwnerProperty(elemInnerItem, 'dots')) {
|
|
420
417
|
if (elemInnerIndex === innerIndex) {
|
|
421
418
|
elemInnerItem.dotsStatus = 'deActive'
|
|
422
419
|
}
|
|
@@ -432,7 +429,7 @@ export const Table = ({
|
|
|
432
429
|
if (disableArr && disableArr.length > 0) {
|
|
433
430
|
headerWithDisabled = arr.map((item, index) => {
|
|
434
431
|
if (disableArr[index]) {
|
|
435
|
-
if (
|
|
432
|
+
if (hasOwnerProperty(item, 'checkBox')) {
|
|
436
433
|
item.checkBox.disabled = true
|
|
437
434
|
}
|
|
438
435
|
}
|
|
@@ -484,6 +481,18 @@ export const Table = ({
|
|
|
484
481
|
getData(moreData)
|
|
485
482
|
}
|
|
486
483
|
|
|
484
|
+
const handleTableClick = () => {
|
|
485
|
+
const checkBodyMore = body.map((elemItem) => {
|
|
486
|
+
return elemItem.map((elemInnerItem) => {
|
|
487
|
+
if (hasOwnerProperty(elemInnerItem, 'dots')) {
|
|
488
|
+
elemInnerItem.dotsStatus = 'deActive'
|
|
489
|
+
}
|
|
490
|
+
return elemInnerItem
|
|
491
|
+
})
|
|
492
|
+
})
|
|
493
|
+
setBody(() => checkBodyMore)
|
|
494
|
+
}
|
|
495
|
+
|
|
487
496
|
useEffect(() => {
|
|
488
497
|
let checkedItems = []
|
|
489
498
|
const disabledArray = []
|
|
@@ -499,8 +508,8 @@ export const Table = ({
|
|
|
499
508
|
)
|
|
500
509
|
const insert = checkForInsertArrow.map((item, index) => {
|
|
501
510
|
item.map((innerItem, innerIndex) => {
|
|
502
|
-
if (
|
|
503
|
-
if (
|
|
511
|
+
if (hasOwnerProperty(innerItem, 'checkBox')) {
|
|
512
|
+
if (hasOwnerProperty(innerItem.checkBox, 'disabled')) {
|
|
504
513
|
if (innerItem.checkBox.disabled === true) {
|
|
505
514
|
if (!disabledArray[innerIndex]) {
|
|
506
515
|
disabledArray[innerIndex] = { rowIndex: index, columnIndex: innerIndex }
|
|
@@ -516,8 +525,8 @@ export const Table = ({
|
|
|
516
525
|
} else {
|
|
517
526
|
const insert = checkBodyForChackedItems.map((item, index) => {
|
|
518
527
|
item.map((innerItem, innerIndex) => {
|
|
519
|
-
if (
|
|
520
|
-
if (
|
|
528
|
+
if (hasOwnerProperty(innerItem, 'checkBox')) {
|
|
529
|
+
if (hasOwnerProperty(innerItem.checkBox, 'disabled')) {
|
|
521
530
|
if (innerItem.checkBox.disabled === true) {
|
|
522
531
|
if (!disabledArray[innerIndex]) {
|
|
523
532
|
disabledArray[innerIndex] = { rowIndex: index, columnIndex: innerIndex }
|
|
@@ -560,6 +569,7 @@ export const Table = ({
|
|
|
560
569
|
width: '100%',
|
|
561
570
|
borderCollapse: 'collapse',
|
|
562
571
|
}}
|
|
572
|
+
onClick={handleTableClick}
|
|
563
573
|
>
|
|
564
574
|
{header && header.length > 0 && (
|
|
565
575
|
<thead>
|
|
@@ -435,16 +435,7 @@ const Template = (args) => {
|
|
|
435
435
|
console.log(tData, ' data from table click action, with getData props')
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
return
|
|
439
|
-
<Table
|
|
440
|
-
{...args}
|
|
441
|
-
arrowShow
|
|
442
|
-
arrowColumn={3}
|
|
443
|
-
dataBody={bodyData}
|
|
444
|
-
dataHeader={headerData}
|
|
445
|
-
getData={handleGetData}
|
|
446
|
-
/>
|
|
447
|
-
)
|
|
438
|
+
return <Table {...args} dataBody={bodyData} dataHeader={headerData} getData={handleGetData} />
|
|
448
439
|
}
|
|
449
440
|
|
|
450
441
|
export const Default = Template.bind({})
|