@xaypay/tui 0.0.81 → 0.0.83

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