@xaypay/tui 0.0.80 → 0.0.82

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 (57) hide show
  1. package/dist/index.es.js +220 -146
  2. package/dist/index.js +220 -146
  3. package/package.json +1 -1
  4. package/src/assets/attach.svg +4 -0
  5. package/src/assets/delete.svg +4 -0
  6. package/src/assets/down-arrow.svg +4 -0
  7. package/src/assets/minus.svg +4 -0
  8. package/src/assets/plus.svg +4 -0
  9. package/src/assets/up-arrow.svg +4 -0
  10. package/src/components/icon/Arrow.js +2 -2
  11. package/src/components/icon/CaptchaArrowDown.js +2 -2
  12. package/src/components/icon/CaptchaArrowUp.js +2 -2
  13. package/src/components/icon/CheckboxChecked.js +2 -2
  14. package/src/components/icon/CheckboxUnchecked.js +2 -2
  15. package/src/components/icon/Close.js +2 -2
  16. package/src/components/icon/CloseIcon.js +2 -2
  17. package/src/components/icon/CloseSlide.js +2 -2
  18. package/src/components/icon/DeleteComponent.js +2 -2
  19. package/src/components/icon/Dots.js +2 -2
  20. package/src/components/icon/HeartFilled.js +2 -2
  21. package/src/components/icon/HeartOutline.js +2 -2
  22. package/src/components/icon/ListItemDelete.js +2 -2
  23. package/src/components/icon/ListItemJpeg.js +2 -2
  24. package/src/components/icon/ListItemJpg.js +2 -2
  25. package/src/components/icon/ListItemPdf.js +2 -2
  26. package/src/components/icon/ListItemPng.js +2 -2
  27. package/src/components/icon/Next.js +2 -2
  28. package/src/components/icon/Nextarrow.js +2 -2
  29. package/src/components/icon/PDF.js +2 -2
  30. package/src/components/icon/Prev.js +2 -2
  31. package/src/components/icon/RangeArrowDefault.js +2 -2
  32. package/src/components/icon/RangeArrowError.js +2 -2
  33. package/src/components/icon/RangeArrowSuccess.js +2 -2
  34. package/src/components/icon/RemoveFile.js +2 -2
  35. package/src/components/icon/ToasterClose.js +2 -2
  36. package/src/components/icon/ToasterError.js +2 -2
  37. package/src/components/icon/ToasterInfo.js +2 -2
  38. package/src/components/icon/ToasterSuccess.js +2 -2
  39. package/src/components/icon/ToasterWarning.js +2 -2
  40. package/src/components/icon/Tooltip.js +2 -2
  41. package/src/components/icon/Upload.js +2 -2
  42. package/src/components/input/index.js +11 -21
  43. package/src/components/modal/index.js +28 -20
  44. package/src/components/modal/modal.stories.js +1 -1
  45. package/src/components/newAutocomplete/index.js +9 -5
  46. package/src/components/newFile/index.js +4 -3
  47. package/src/components/select/index.js +9 -2
  48. package/src/components/singleCheckbox/index.js +27 -5
  49. package/src/components/table/index.js +70 -97
  50. package/src/components/table/table.module.css +28 -0
  51. package/src/components/table/table.stories.js +391 -172
  52. package/src/components/table/td.js +133 -0
  53. package/src/components/table/th.js +55 -0
  54. package/src/components/textarea/index.js +21 -15
  55. package/src/components/textarea/textarea.stories.js +4 -0
  56. package/src/stories/configuration.stories.mdx +17 -5
  57. package/tui.config.js +18 -7
@@ -1,205 +1,424 @@
1
- import React from 'react';
2
- import Table from './index';
1
+ import React, { useState, useEffect } from 'react';
2
+ import Table from '.';
3
3
 
4
- import { ReactComponent as ReactSVG } from './../../assets/table-settings-icon.svg';
4
+ import { ReactComponent as ReactSVGPlus } from './../../assets/plus.svg';
5
+ import { ReactComponent as ReactSVGMinus } from './../../assets/minus.svg';
6
+ import { ReactComponent as ReactSVGDelete } from './../../assets/delete.svg';
7
+ import { ReactComponent as ReactSVGAttach } from './../../assets/attach.svg';
8
+ import { ReactComponent as ReactSVGArrowUp } from './../../assets/up-arrow.svg';
9
+ import { ReactComponent as ReactSVGArrowDown } from './../../assets/down-arrow.svg';
10
+ import { ReactComponent as ReactSVG } from './../../assets/table-settings-icon.svg';
5
11
 
6
12
  export default {
7
13
  component: Table,
8
14
  title: 'Components/Table'
9
15
  };
10
16
 
11
- const Template = (args) => {
12
- const tableDataInfo = {
13
- header: [
14
- {
15
- type: 'show',
16
- content: 'Հ/Հ'
17
- },
18
- {
19
- type: 'show',
20
- content: 'ՀՎՀՀ'
21
- },
17
+ const headerData = [
18
+ {
19
+ type: 'show',
20
+ content: 'Հ/Հ',
21
+ checkBox: {
22
+ checked: false,
23
+ checkedColor: 'orange',
24
+ unCheckedColor: 'orange'
25
+ },
26
+ sortingArrows: true
27
+ },
28
+ {
29
+ type: 'show',
30
+ content: 'ՀՎՀՀ',
31
+ sortingArrows: true
32
+ },
33
+ {
34
+ type: 'show',
35
+ content: 'Վարչ․շրջան',
36
+ sortingArrows: true
37
+ },
38
+ {
39
+ type: 'show',
40
+ content: 'Վճար',
41
+ checkBox: {
42
+ checked: false,
43
+ checkedColor: 'orange',
44
+ unCheckedColor: 'orange'
45
+ },
46
+ sortingArrows: true
47
+ },
48
+ {
49
+ type: 'show',
50
+ content: 'Ամսաթիվ',
51
+ sortingArrows: true
52
+ },
53
+ {
54
+ type: 'show',
55
+ content: 'Մուտքի ամս․',
56
+ sortingArrows: true
57
+ },
58
+ {
59
+ type: 'show',
60
+ content: 'Հավելյալ ինֆորմացիա',
61
+ sortingArrows: true
62
+ },
63
+ {
64
+ type: 'show',
65
+ content: 'Ստեղծված',
66
+ sortingArrows: true
67
+ },
68
+ {
69
+ type: 'show',
70
+ content: 'Գործողություն',
71
+ sortingArrows: true
72
+ },
73
+ {
74
+ type: 'show',
75
+ content: <ReactSVG />,
76
+ sortingArrows: false,
77
+ }
78
+ ];
79
+
80
+ const bodyData = [
81
+ {
82
+ hh: {
83
+ id: 19854,
84
+ content: 19854,
85
+ checkBox: {
86
+ checked: false,
87
+ checkedColor: 'green',
88
+ unCheckedColor: 'green'
89
+ }
90
+ },
91
+ hvhh: {
92
+ content: 10195524
93
+ },
94
+ shrjan: {
95
+ content: 'Շենգավիթ'
96
+ },
97
+ pay: {
98
+ id: 19854,
99
+ content: 7000,
100
+ checkBox: {
101
+ checked: false,
102
+ checkedColor: 'green',
103
+ unCheckedColor: 'green'
104
+ }
105
+ },
106
+ startDate: {
107
+ content: '27.05.2022'
108
+ },
109
+ enterDate: {
110
+ content: '27.05.2022'
111
+ },
112
+ info: {
113
+ openArrow: <ReactSVGArrowUp />,
114
+ closeArrow: <ReactSVGArrowDown />,
115
+ content: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ',
116
+ contentList: [
117
+ 'Ակտիվ է => Այո',
118
+ 'Lorem just => ipsum',
119
+ 'Dolor sit => amet',
120
+ 'text for => test',
121
+ ]
122
+ },
123
+ create: {
124
+ content: '27.05.2022'
125
+ },
126
+ actions: [
22
127
  {
23
- type: 'show',
24
- content: 'Վարչ․շրջան'
128
+ id: 19854,
129
+ type: 'attach',
130
+ content: <ReactSVGAttach />
25
131
  },
26
132
  {
27
- type: 'show',
28
- content: 'Վճար'
29
- },
133
+ id: 19854,
134
+ type: 'plus',
135
+ content: <ReactSVGPlus />
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ hh: {
141
+ id: 19954,
142
+ content: 19954,
143
+ checkBox: {
144
+ checked: false,
145
+ checkedColor: 'green',
146
+ unCheckedColor: 'green'
147
+ }
148
+ },
149
+ hvhh: {
150
+ content: 14595524
151
+ },
152
+ shrjan: {
153
+ content: 'Կենտրոն'
154
+ },
155
+ pay: {
156
+ id: 19954,
157
+ content: 7840,
158
+ checkBox: {
159
+ checked: false,
160
+ checkedColor: 'green',
161
+ unCheckedColor: 'green'
162
+ }
163
+ },
164
+ startDate: {
165
+ content: '27.05.2022'
166
+ },
167
+ enterDate: {
168
+ content: '27.05.2022'
169
+ },
170
+ info: {
171
+ openArrow: <ReactSVGArrowUp />,
172
+ closeArrow: <ReactSVGArrowDown />,
173
+ content: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ',
174
+ contentList: [
175
+ 'Ակտիվ է => Այո',
176
+ 'Lorem just => ipsum',
177
+ 'Dolor sit => amet',
178
+ 'text for => test',
179
+ ]
180
+ },
181
+ create: {
182
+ content: '27.05.2022'
183
+ },
184
+ actions: [
30
185
  {
31
- type: 'show',
32
- content: 'Ամսաթիվ'
186
+ id: 19954,
187
+ type: 'minus',
188
+ content: <ReactSVGMinus />
33
189
  },
34
190
  {
35
- type: 'show',
36
- content: 'Մուտքի ամս․'
37
- },
191
+ id: 19954,
192
+ type: 'delete',
193
+ content: <ReactSVGDelete />
194
+ }
195
+ ]
196
+ },
197
+ {
198
+ hh: {
199
+ id: 20037,
200
+ content: 20037,
201
+ checkBox: {
202
+ checked: false,
203
+ checkedColor: 'green',
204
+ unCheckedColor: 'green'
205
+ }
206
+ },
207
+ hvhh: {
208
+ content: 14595524
209
+ },
210
+ shrjan: {
211
+ content: 'Շենգավիթ'
212
+ },
213
+ pay: {
214
+ id: 20037,
215
+ content: 6541,
216
+ checkBox: {
217
+ checked: false,
218
+ checkedColor: 'green',
219
+ unCheckedColor: 'green'
220
+ }
221
+ },
222
+ startDate: {
223
+ content: '27.05.2022'
224
+ },
225
+ enterDate: {
226
+ content: '27.05.2022'
227
+ },
228
+ info: {
229
+ openArrow: <ReactSVGArrowUp />,
230
+ closeArrow: <ReactSVGArrowDown />,
231
+ content: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ',
232
+ contentList: [
233
+ 'Ակտիվ է => Այո',
234
+ 'Lorem just => ipsum',
235
+ 'Dolor sit => amet',
236
+ 'text for => test',
237
+ ]
238
+ },
239
+ create: {
240
+ content: '27.05.2022'
241
+ },
242
+ actions: [
38
243
  {
39
- type: 'show',
40
- content: 'Հավելյալ ինֆորմացիա'
244
+ id: 20037,
245
+ type: 'attach',
246
+ content: <ReactSVGAttach />
41
247
  },
42
248
  {
43
- type: 'show',
44
- content: 'Ստեղծված'
45
- },
249
+ id: 20037,
250
+ type: 'plus',
251
+ content: <ReactSVGPlus />
252
+ }
253
+ ]
254
+ },
255
+ {
256
+ hh: {
257
+ id: 21031,
258
+ content: 21031,
259
+ checkBox: {
260
+ checked: false,
261
+ checkedColor: 'green',
262
+ unCheckedColor: 'green'
263
+ }
264
+ },
265
+ hvhh: {
266
+ content: 14595524
267
+ },
268
+ shrjan: {
269
+ content: 'Կենտրոն'
270
+ },
271
+ pay: {
272
+ id: 21031,
273
+ content: 9845,
274
+ checkBox: {
275
+ checked: false,
276
+ checkedColor: 'green',
277
+ unCheckedColor: 'green'
278
+ }
279
+ },
280
+ startDate: {
281
+ content: '27.05.2022'
282
+ },
283
+ enterDate: {
284
+ content: '27.05.2022'
285
+ },
286
+ info: {
287
+ openArrow: <ReactSVGArrowUp />,
288
+ closeArrow: <ReactSVGArrowDown />,
289
+ content: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ',
290
+ contentList: [
291
+ 'Ակտիվ է => Այո',
292
+ 'Lorem just => ipsum',
293
+ 'Dolor sit => amet',
294
+ 'text for => test',
295
+ ]
296
+ },
297
+ create: {
298
+ content: '27.05.2022'
299
+ },
300
+ actions: [
46
301
  {
47
- type: 'show',
48
- content: 'Գործողություն'
302
+ id: 21031,
303
+ type: 'minus',
304
+ content: <ReactSVGMinus />
49
305
  },
50
306
  {
51
- type: 'show',
52
- content: <ReactSVG />
307
+ id: 21031,
308
+ type: 'delete',
309
+ content: <ReactSVGDelete />
53
310
  }
54
- ],
55
- body: [
56
-
57
311
  ]
58
- };
312
+ }
313
+ ];
59
314
 
60
- const tableBodyItems = [
61
- { id: 1, hh: 19854, hvhh: 10195524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: ['item', 'just'] },
62
- { id: 3, hh: 22641, hvhh: 12095524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: 'text' },
63
- { id: 4, hh: 25005, hvhh: 15495524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
64
- { id: 7, hh: 31576, hvhh: 16895524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
65
- { id: 45, hh: 32586, hvhh: 17495524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
66
- { id: 78, hh: 32754, hvhh: 20095524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
67
- { id: 99, hh: 41411, hvhh: 20595524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
68
- { id: 541, hh: 44547, hvhh: 26595524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
69
- ];
70
-
71
- return <Table tableHeadItems={tableDataInfo.header} tableBodyItems={tableBodyItems} {...args} />;
72
- };
73
-
74
- export const Default = Template.bind({});
75
- Default.args = {};
315
+ const Template = (args) => {
316
+ const [tableDataHeader, setTableDataHeader] = useState(headerData);
317
+ const [tableDataBody, setTableDataBody] = useState(bodyData);
76
318
 
319
+ const [checkedFirstCount, setCheckedFirstCount] = useState(0);
320
+ const [checkedSecondCount, setCheckedSecondCount] = useState(0);
77
321
 
322
+ const handleHeaderItemClick = (e) => {
323
+ e.stopPropagation();
324
+ console.log(e.target.innerText);
325
+ };
326
+
327
+ const handleBodyActionClick = (e) => {
328
+ console.log(e.target.id, 'e.target.id - - - - id');
329
+ console.log(e.target.getAttribute('type'), 'e.target.type - - - - type');
330
+ };
78
331
 
332
+ const handleCheckedHeader = (e, content) => {
333
+ e.stopPropagation();
334
+ let checkableItemIndex;
335
+ let checkableItemBool;
336
+ const updatedHeader = tableDataHeader.slice();
337
+ const updatedBody = tableDataBody.slice().map(item => Object.values(item));
338
+ const newData = updatedHeader.map((item, index) => {
339
+ if (item.content === content) {
340
+ checkableItemIndex = index;
341
+ checkableItemBool = !item.checkBox.checked;
342
+ item.checkBox.checked = !item.checkBox.checked;
343
+ }
344
+ return item;
345
+ });
346
+
347
+ const newUpdatedBody = updatedBody.map(item => {
348
+ return item.map((innerItem, innerIndex) => {
349
+ if (checkableItemIndex === innerIndex) {
350
+ innerItem.checkBox.checked = checkableItemBool;
351
+ }
352
+ return innerItem;
353
+ });
354
+ });
355
+ setTableDataHeader(newData);
356
+ setTableDataBody(newUpdatedBody);
357
+ };
79
358
 
359
+ const handleCheckedBody = (e, content, id) => {
360
+ e.stopPropagation();
80
361
 
362
+ const updatedBody = tableDataBody.slice().map(item => Object.values(item));
363
+ const newData = updatedBody.map(item => {
364
+ return item.map((innerItem, innerIndex) => {
365
+ if (innerItem.id === id && innerItem.content === content) {
366
+ if (innerIndex === 0) {
367
+ if (innerItem.checkBox.checked === false) {
368
+ setCheckedFirstCount(prev => prev + 1);
369
+ } else {
370
+ setCheckedFirstCount(prev => prev - 1);
371
+ }
372
+ } else if (innerIndex === 3) {
373
+ if (innerItem.checkBox.checked === false) {
374
+ setCheckedSecondCount(prev => prev + 1);
375
+ } else {
376
+ setCheckedSecondCount(prev => prev - 1);
377
+ }
378
+ }
379
+ innerItem.checkBox.checked = !innerItem.checkBox.checked;
380
+ }
381
+ return innerItem;
382
+ });
383
+ });
384
+ setTableDataBody(newData);
385
+ };
81
386
 
387
+ const handleHeaderCheckedUpdate = () => {
388
+ const updatedHeader = tableDataHeader.slice();
82
389
 
390
+ const newData = updatedHeader.map((item, index) => {
391
+ if (checkedFirstCount === tableDataBody.length && index === 0) {
392
+ item.checkBox.checked = true;
393
+ } else if (checkedFirstCount !== tableDataBody.length && index === 0) {
394
+ item.checkBox.checked = false;
395
+ }
83
396
 
397
+ if (checkedSecondCount === tableDataBody.length && index === 3) {
398
+ item.checkBox.checked = true;
399
+ } else if (checkedSecondCount !== tableDataBody.length && index === 3) {
400
+ item.checkBox.checked = false;
401
+ }
402
+ return item;
403
+ });
404
+ setTableDataHeader(newData);
405
+ };
84
406
 
407
+ useEffect(() => {
408
+ handleHeaderCheckedUpdate();
409
+ }, [checkedFirstCount, checkedSecondCount]);
410
+
85
411
 
86
- // {
87
- // header: [
88
- // "Hello" | <component></component>,
89
- // "Title 2",
90
- // {
91
- // type: 'hide',
92
- // icon: svg
93
- // }
94
- // ]
95
-
96
- // body: [
97
- // {
98
- // color: 'red',
99
- // colorStatus: 'left' | "row" | "right",
100
- // data: [
101
- // "jkashdkjha",
102
- // "jkashdkjha 1",
103
- // "jkashdkjha 2",
104
- // {
105
- // type: "image",
106
- // svg: <SVG></SVG>,
107
- // click: onclick()
108
- // },
109
- // {
110
- // type: "action",
111
- // data: [
112
- // {
113
- // icon: svg,
114
- // title?: 'sadas',
115
- // click: onclick()
116
- // },
117
- // {
118
- // icon: svg,
119
- // group: [
120
- // {
121
- // icon: svg,
122
- // title?: 'sadas',
123
- // click: onclick()
124
- // },
125
- // {
126
- // icon: svg,
127
- // title?: 'sadas',
128
- // click: onclick()
129
- // }
130
- // ]
131
- // }
132
- // ]
133
- // },
134
- // {
135
- // type: "action",
136
- // data: [
137
- // [
138
- // {
139
- // icon: svg,
140
- // title?: 'sadas',
141
- // click: onclick()
142
- // },
143
- // {
144
- // icon: svg,
145
- // group: [
146
- // {
147
- // icon: svg,
148
- // title?: 'sadas',
149
- // click: onclick()
150
- // },
151
- // {
152
- // icon: svg,
153
- // title?: 'sadas',
154
- // click: onclick()
155
- // }
156
- // ]
157
- // }
158
- // ],
159
- // [
160
- // {
161
- // icon: svg,
162
- // title?: 'sadas',
163
- // click: onclick()
164
- // },
165
- // {
166
- // icon: svg,
167
- // group: [
168
- // {
169
- // icon: svg,
170
- // title?: 'sadas',
171
- // click: onclick()
172
- // },
173
- // {
174
- // icon: svg,
175
- // title?: 'sadas',
176
- // click: onclick()
177
- // }
178
- // ]
179
- // }
180
- // ]
181
- // ]
182
- // },
183
- // {
184
- // type: "accordion",
185
- // title: 'asdasdsa',
186
- // openKeys: [
187
- // 't1',
188
- // 't2',
189
- // 't3'
190
- // ]
191
- // },
192
- // {
193
- // type: "text",
194
- // accourdionData: [
195
- // 'asdasd',
196
- // <Component></Component>,
197
- // 'asdasd',
198
- // 'asdasd'
199
- // ]
200
- // }
201
- // ]
202
- // }
203
- // ]
204
- // }
412
+ return <Table
413
+ {...args}
414
+ dataBody={tableDataBody}
415
+ dataHeader={tableDataHeader}
416
+ handleCheckedBody={handleCheckedBody}
417
+ handleCheckedHeader={handleCheckedHeader}
418
+ handleBodyActionClick={handleBodyActionClick}
419
+ handleHeaderItemClick={handleHeaderItemClick}
420
+ />;
421
+ };
205
422
 
423
+ export const Default = Template.bind({});
424
+ Default.args = {};