@xaypay/tui 0.0.75 → 0.0.77

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,125 +1,191 @@
1
- import React, { useEffect, useState } from "react";
2
- import PropTypes from "prop-types";
3
- import classnames from "classnames";
4
- import styles from "./table.module.css";
5
- import { Checkbox } from "../checkbox";
6
-
7
- export const Table = ({
8
- className,
9
- onChange,
10
- config,
11
- jsonData,
12
- hearderData,
13
- keyNames,
14
- actions,
15
- ...props
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import { compereConfigs } from './../../utils';
5
+
6
+ const Table = ({
7
+ tableHeadItems,
8
+ tableBodyItems,
9
+
10
+ tHeadColor,
11
+ tHeadFamily,
12
+ tHeadPadding,
13
+ tHeadFontWeight,
14
+ tHeadBorderRadius,
15
+ tHeadBackgroundColor,
16
+
17
+ tBodyColor,
18
+ tBodyPadding,
19
+ tBodyFontSize,
20
+ tBodyTextAlign,
21
+ tBodyFontWeight,
22
+ tBodyFontFamily,
23
+
24
+ tBodyRowBorder,
25
+ tBodyMarginTop,
16
26
  }) => {
17
- const classProps = classnames(className);
18
- let tbodyData = jsonData.length ? JSON.parse(jsonData) : [];
19
-
20
- useEffect(()=>{
21
- tbodyData = jsonData.length ? JSON.parse(jsonData) : [];
22
- },[jsonData])
23
-
24
- const [checked,setChecked] = useState(config.isCheckbox && config.isCheckbox.checked ? config.isCheckbox.checked : []);
25
-
26
-
27
- config.isCheckbox && config.isCheckbox.showCheckbox == undefined
28
- ? (config.isCheckbox.showCheckbox = () => {
29
- return true;
30
- })
31
- : "";
32
-
33
- return (
34
- <div className={`${styles["table-wrap"]} table-wrap-rem`}>
35
- {config.isHeader &&
36
- hearderData.map((header, key) => {
37
- return (
38
- <div className={`${styles["table-top"]} table-top-rem`} key={key}>
39
- <div className={`${styles["table-items"]} table-items-rem`}>
40
- {header}
41
- </div>
42
- </div>
43
- );
44
- })}
45
- <div className={`${styles["table-bottom"]} table-bottom-rem`}>
46
- {tbodyData.map((item, key) => {
47
- return (
48
- <div className={`${styles["table-bottom-inner"]} table-bottom-inner-rem`} key={key}>
49
- {keyNames.map((keyName, keyNameKey) => {
50
- return (
51
- <div
52
- className={`${styles["table-items"]} table-items-rem`}
53
- key={keyNameKey}
54
- >
55
- {config.isCheckbox &&
56
- config.isCheckbox.showCheckbox &&
57
- config.isCheckbox.showCheckbox(
58
- item
59
- ) &&
60
- keyNameKey == 0 && (
61
- <Checkbox
62
- onClick={(e) => {
63
- const id = e.target.id;
64
- const checkedValue = e.target.checked;
65
- let ch = [...checked]
66
- checkedValue ? ch.push(Number(id)) : ch.splice(ch.indexOf(id), 1);
67
- setChecked(ch);
68
- config.isCheckbox.onChange(ch);
69
- }}
70
- jsonData={`[{"value":"", "name":"", "label":"", "id":${item.id}, "checked":${checked.indexOf(item.id) > -1 ? true : false }}]`}
71
- />
72
- )}
73
- {typeof keyName === "string" ? (
74
- item[keyName]
75
- ) : (
76
- <>
77
- <i className={keyName.icon} />
78
- {item[keyName.name]}
79
- </>
80
- )}
81
- </div>
82
- );
83
- })}
84
-
85
- {actions && (
86
- <div className={`${styles["table-items"]} table-items-rem`}>
87
- {actions.filter(a => a.show && a.show(item) || a.show === undefined).map((action, key) => {
88
- return (<div key={key}>
89
- <i className={action.icon} onClick={action.click? action.click : ()=>{}}>
90
- {action.icon}
91
- </i>
92
- </div>)
93
- })}
94
- </div>
95
- )}
96
- </div>
97
- );
98
- })}
99
- </div>
100
- </div>
101
- );
27
+
28
+ const configStyles = compereConfigs();
29
+
30
+ return (
31
+ <>
32
+ <table
33
+ style={{
34
+ borderCollapse: 'collapse'
35
+ }}
36
+ >
37
+
38
+ {
39
+ tableHeadItems && tableHeadItems.length > 0 && <thead>
40
+ <tr
41
+ style={{
42
+ color: tHeadColor ? tHeadColor : configStyles.TABLE.tHeadColor,
43
+ backgroundColor: tHeadBackgroundColor ? tHeadBackgroundColor : configStyles.TABLE.tHeadBackgroundColor
44
+ }}
45
+ >
46
+ {
47
+ tableHeadItems.map((item, index) => {
48
+ return (
49
+ <th
50
+ key={`${item}_${index}`}
51
+ style={{
52
+ padding: tHeadPadding ? tHeadPadding : configStyles.TABLE.tHeadPadding,
53
+ fontFamily: tHeadFamily ? tHeadFamily : configStyles.TABLE.tHeadFamily,
54
+ fontWeight: tHeadFontWeight ? tHeadFontWeight : configStyles.TABLE.tHeadFontWeight,
55
+ borderTopLeftRadius: index === 0 ? tHeadBorderRadius ? tHeadBorderRadius : configStyles.TABLE.tHeadBorderRadius : '0px',
56
+ borderTopRightRadius: index === tableHeadItems.length - 1 ? tHeadBorderRadius ? tHeadBorderRadius : configStyles.TABLE.tHeadBorderRadius : '0px'
57
+ }}
58
+ >
59
+ {item}
60
+ </th>
61
+ )
62
+ })
63
+ }
64
+ </tr>
65
+ </thead>
66
+ }
67
+
68
+ {
69
+ tableBodyItems && tableBodyItems.length > 0 && <tbody
70
+ style={{
71
+ boxShadow: '0px 10px 30px rgba(0, 35, 106, 0.06)'
72
+ }}
73
+ >
74
+
75
+ {
76
+
77
+ tableBodyItems.map((item, index) => {
78
+ return (
79
+ <>
80
+ {
81
+ tBodyMarginTop ? tBodyMarginTop : configStyles.TABLE.tBodyMarginTop && index === 0 && <tr>
82
+ <td
83
+ style={{
84
+ height: tBodyMarginTop ? tBodyMarginTop : configStyles.TABLE.tBodyMarginTop
85
+ }}
86
+ >
87
+ </td>
88
+ </tr>
89
+ }
90
+
91
+ <tr
92
+ key={`${item.id}_${index}`}
93
+ style={{
94
+ borderBottom: index === tableBodyItems.length - 1 ? 'none' : tBodyRowBorder ? tBodyRowBorder : configStyles.TABLE.tBodyRowBorder
95
+ }}
96
+ >
97
+ {
98
+ Object.values(item).map((innerItem, innerIndex) => {
99
+ if (innerIndex > 0) { // TODO:
100
+ return (
101
+ <td
102
+ key={`${innerItem}_${innerIndex}`}
103
+ style={{
104
+ color: tBodyColor ? tBodyColor : configStyles.TABLE.tBodyColor,
105
+ padding: tBodyPadding ? tBodyPadding : configStyles.TABLE.tBodyPadding,
106
+ fontSize: tBodyFontSize ? tBodyFontSize : configStyles.TABLE.tBodyFontSize,
107
+ textAlign: tBodyTextAlign ? tBodyTextAlign : configStyles.TABLE.tBodyTextAlign,
108
+ fontFamily: tBodyFontFamily ? tBodyFontFamily : configStyles.TABLE.tBodyFontFamily,
109
+ fontWeight: tBodyFontWeight ? tBodyFontWeight : configStyles.TABLE.tBodyFontWeight,
110
+ borderRight: innerIndex === Object.values(item).length - 1 ? 'none' : configStyles.TABLE.tBodyRowBorder
111
+ }}
112
+ >
113
+ {
114
+ Array.isArray(innerItem)
115
+ ? innerItem.length > 0
116
+ ? innerItem.map((newItem, newIndex) => {
117
+ if (newItem && !Array.isArray(newItem) && typeof newItem === 'object') {
118
+ return Object.values(newItem).map((actionItem, actionIndex) => {
119
+ return (
120
+ <span
121
+ key={`${actionItem}_${actionIndex}`}
122
+ style={{
123
+ cursor: 'pointer'
124
+ }}
125
+ >
126
+ { actionItem }
127
+ </span>
128
+ )
129
+ })
130
+ } else {
131
+ return <span
132
+ key={`${newItem}_${newIndex}`}
133
+ >
134
+ {newItem}
135
+ </span>
136
+ }
137
+ })
138
+ : ''
139
+ : innerItem
140
+ }
141
+ </td>
142
+ )
143
+ }
144
+ })
145
+ }
146
+ </tr>
147
+ </>
148
+ )
149
+ })
150
+ }
151
+ </tbody>
152
+ }
153
+
154
+
155
+
156
+
157
+ <tfoot
158
+ style={{
159
+
160
+ }}
161
+ >
162
+
163
+ </tfoot>
164
+ </table>
165
+ </>
166
+ );
102
167
  };
103
168
 
104
169
  Table.propTypes = {
105
- className: PropTypes.string,
106
- onChange: PropTypes.func,
107
- config: PropTypes.object,
108
- actions: PropTypes.arrayOf(PropTypes.object),
109
- jsonData: PropTypes.string,
110
- keyNames: PropTypes.arrayOf(
111
- PropTypes.oneOf([PropTypes.string, PropTypes.object])
112
- ),
113
- hearderData: PropTypes.array,
114
- };
170
+ tableHeadItems: PropTypes.array,
171
+ tableBodyItems: PropTypes.array,
172
+
173
+ tHeadColor: PropTypes.string,
174
+ tHeadFamily: PropTypes.string,
175
+ tHeadPadding: PropTypes.string,
176
+ tHeadFontWeight: PropTypes.number,
177
+ tHeadBorderRadius: PropTypes.string,
178
+ tHeadBackgroundColor: PropTypes.string,
115
179
 
116
- Table.defaultProps = {
117
- className: "",
118
- onChange: undefined,
119
- errorMessage: "",
120
- config: { isHeader: true, isCheckbox: {checked:[]} },
121
- actions: [],
122
- jsonData: "",
123
- keyNames: [],
124
- hearderData: [],
180
+ tBodyColor: PropTypes.string,
181
+ tBodyPadding: PropTypes.string,
182
+ tBodyFontSize: PropTypes.string,
183
+ tBodyTextAlign: PropTypes.string,
184
+ tBodyFontWeight: PropTypes.string,
185
+ tBodyFontFamily: PropTypes.string,
186
+
187
+ tBodyRowBorder: PropTypes.string,
188
+ tBodyMarginTop: PropTypes.string
125
189
  };
190
+
191
+ export default Table;
@@ -1,36 +1,39 @@
1
- import React from "react";
2
- import { Table } from "./index";
1
+ import React from 'react';
2
+ import Table from './index';
3
3
 
4
4
  export default {
5
- component: Table,
6
- title: "Components/Table",
5
+ component: Table,
6
+ title: 'Components/Table'
7
7
  };
8
8
 
9
- const Template = (args) => <Table {...args} />;
9
+ const Template = (args) => {
10
+ const tableHeadItems = [
11
+ 'Հ/Հ',
12
+ 'ՀՎՀՀ',
13
+ 'Վարչ․ շրջան',
14
+ 'Վճար',
15
+ 'Ամսաթիվ',
16
+ 'Մուտքի ամիս',
17
+ 'Հավելյալ ինֆորմացիա',
18
+ 'Ստեղծված',
19
+ 'Գործողություն',
20
+ ];
21
+
22
+ const tableBodyItems = [
23
+ { 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'] },
24
+ { id: 3, hh: 22641, hvhh: 12095524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: 'text' },
25
+ { id: 4, hh: 25005, hvhh: 15495524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
26
+ { id: 7, hh: 31576, hvhh: 16895524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
27
+ { id: 45, hh: 32586, hvhh: 17495524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
28
+ { id: 78, hh: 32754, hvhh: 20095524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
29
+ { id: 99, hh: 41411, hvhh: 20595524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
30
+ { id: 541, hh: 44547, hvhh: 26595524, shrjan: 'Շենգավիթ', pay: 7000, date: '27.05.2022', enterDate: '27.05.2022', info: 'Այլ արտաքին գովազդի տեղադրելու վճար / ԱՁ', create: '27.05.2022', actions: [] },
31
+ ];
32
+
33
+ return <Table tableHeadItems={tableHeadItems} tableBodyItems={tableBodyItems} {...args} />;
34
+ };
10
35
 
11
36
  export const Default = Template.bind({});
12
-
13
- const showCheckbox = (item) => {
14
- return true;
15
- // return item.id === 2;
16
- }
17
-
18
- const onChange = (checked) => {
19
- console.log("project",checked);
20
- }
21
-
22
- const show = () => {
23
- return true
24
- }
25
-
26
- const action = (id) => {
27
- console.log('action from project',id);
28
- }
29
-
30
37
  Default.args = {
31
- config: {isHeader: true, isCheckbox: {showCheckbox: showCheckbox, checked: [], onChange: onChange }},
32
- jsonData: JSON.stringify([{id:1,name:'Item 1',name2:'Item 1'},{id:2, name:'Item 2',name2:'Item 2'}]),
33
- actions: [{icon: 'icon-1',show: show, click: action},{icon: 'icon-2'},{icon: 'icon-3'},{icon: 'icon-4'}],
34
- keyNames: ['name',{name: 'name2', icon: 'icon-temp'}],
35
- hearderData: ['first Name', 'Last Name','asdas',]
36
- };
38
+
39
+ };
@@ -17,6 +17,7 @@ import selectImage from './static/select-usage.png';
17
17
  import toastImage from './static/toaster-usage.png';
18
18
  import tooltipImage from './static/tooltip-usage.png';
19
19
  import textareaImage from './static/textarea-usage.png';
20
+ import buttonImageIcon from './static/button-usage-icon.png';
20
21
  import fileSingleImage from './static/file-single-usage.png';
21
22
  import toasterImage from './static/toaster-container-usage.png';
22
23
  import autocompleteImage from './static/autocomplete-usage.png';
@@ -136,6 +137,9 @@ import autocompleteImage from './static/autocomplete-usage.png';
136
137
  ### Button
137
138
  <img src={buttonImage} alt="button image" />
138
139
 
140
+ #### Button with icon prop
141
+ <img src={buttonImageIcon} alt="button image" />
142
+
139
143
  ### Input
140
144
  <img src={inputImage} alt="input image" />
141
145
 
@@ -2,24 +2,11 @@ const _ = require('lodash');
2
2
 
3
3
  export const compereConfigs = () => {
4
4
  let projectConfig = {};
5
- let packageConfig = {};
5
+ let packageConfig = require(process.env.STORYBOOK_PATH);
6
6
 
7
7
  try {
8
- packageConfig = require('../tui.config.js');
9
- } catch (e){
10
- try {
11
- packageConfig = require('../../tui.config.js');
12
- } catch (err) {
13
- packageConfig = {};
14
- }
15
- }
16
-
17
- try {
18
- projectConfig = require('../../../../tui.config.js');
19
- } catch (error) {
20
- projectConfig = {};
21
- // console.log(error, 'Project: if you want to use custom styles, create tui.config.js file in your project root');
22
- }
8
+ projectConfig = require(`${process.env.STORYBOOK_CONFIG_PATH}`);
9
+ } catch(e) {}
23
10
 
24
11
  return _.merge(packageConfig, projectConfig);
25
12
  };
package/tui.config.js CHANGED
@@ -50,12 +50,15 @@ module.exports = {
50
50
  labelLineHeight: '22px', // for label line height
51
51
  errorLineHeight: '19px', // for error message line height
52
52
  boxSizing: 'border-box', // for box sizing
53
+ borderRight: '2px solid', // for type tel right border
53
54
  backgroundColor: 'white', // for input and also (if there exist left or right icons) icons block background color
54
55
  color: 'rgb(60, 57, 62)', // for input color
55
56
  labelMarginBottom: '6px', // for label margin bottom
56
57
  phoneAlignItems: 'center', // for phone extention inside item, work when input type is tel
57
58
  errorPosition: 'absolute', // for error message position (maybe you want to show error message in custom place)
58
59
  transform: 'scale3d(0,0,0)', // for transform (when have error message and errorAnimation prop is true)
60
+ borderRightColor: '#d1d1d1', // for type tel right border
61
+ borderRightColorHover: '#3c393e', // for type tel right border color when hover is active
59
62
  phoneJustifyContent: 'center', // for phone extention inside item, work when input type is tel
60
63
  boxShadow: '0 0 0 2px #d1d1d1', // for border size and color
61
64
  errorAnimationDuration: '240ms', // for animation duration (when have error message and errorAnimation prop is true)
@@ -194,9 +197,7 @@ module.exports = {
194
197
  selectedFontWeight: '500', // for selected font weight
195
198
  selectedLineHeight: '22px', // for selected line height
196
199
  selectedPadding: '0px 15px', // for selected padding
197
- selectedBorder: '2px solid', // for selected border
198
200
  selectedHoverColor: '#373538', // for selected color ( when hover )
199
- selectedBorderColor: '#D1D1D1', // for selected border color
200
201
  selectedBoxSizing: 'border-box', // for selected box sizing
201
202
  selectedTransition: 'border-color 240ms', // for selected transition
202
203
 
@@ -216,6 +217,9 @@ module.exports = {
216
217
  optionItemBoxSizing: 'border-box', // for option box sizing
217
218
  optionItemBackgroudColor: '#ffffff', // for option background color
218
219
  optionItemBackgroudColorHover: 'unset', // for option background color ( when hover )
220
+
221
+ boxShadow: '0 0 0 2px #d1d1d1',
222
+ boxShadowHover: '0 0 0 2px #3c393e'
219
223
  },
220
224
  // default properties for <Textarea /> component
221
225
  TEXTAREA: {
@@ -374,5 +378,24 @@ module.exports = {
374
378
  backgroundColor: 'white', // for modal background color
375
379
  padding: '10px 20px 20px', // for modal padding
376
380
  layerBackgroundColor: 'rgba(0,0,0,0.4)', // for modal parent layer background color
381
+ },
382
+ // default properties for <Table /> component
383
+ TABLE: {
384
+ tHeadFontWeight: 600,
385
+ tHeadColor: '#FBFBFB',
386
+ tHeadPadding: '11px 20px',
387
+ tHeadBorderRadius: '14px',
388
+ tHeadBackgroundColor: '#00236A',
389
+ tHeadFamily: 'Noto Sans Armenia',
390
+
391
+ tBodyColor: '#3C393E',
392
+ tBodyFontSize: '16px',
393
+ tBodyFontWeight: 500,
394
+ tBodyTextAlign: 'center',
395
+ tBodyPadding: '11px 20px',
396
+ tBodyFontFamily: 'Noto Sans Armenia',
397
+
398
+ tBodyRowBorder: '1px solid #eeeeee',
399
+ tBodyMarginTop: '20px',
377
400
  }
378
401
  };
@@ -1,80 +0,0 @@
1
- .table-wrap {
2
- width: 100%;
3
- background: #fff;
4
- box-shadow: 0 10px 30px rgba(0,35,106,.06);
5
- border-radius: 14px 14px 0 0;
6
- overflow: hidden
7
- }
8
-
9
- .table-wrap:not(:first-child) {
10
- margin-top: 30px
11
- }
12
-
13
- .table-bottom-inner .table-items:first-child,.table-top .table-items:first-child {
14
- flex: 0 0 auto;
15
- width: 60px
16
- }
17
-
18
- .table-bottom-inner .table-items:nth-child(2),.table-top .table-items:nth-child(2) {
19
- flex: 0 0 auto;
20
- width: 120px
21
- }
22
-
23
- .table-bottom-inner .table-items:nth-child(3),.table-top .table-items:nth-child(3) {
24
- flex: 0 0 auto;
25
- width: 170px
26
- }
27
-
28
- .table-bottom-inner .table-items:nth-child(4),.table-top .table-items:nth-child(4) {
29
- flex: 0 0 auto;
30
- width: 126px
31
- }
32
-
33
- .table-bottom-inner .table-items:nth-child(5),.table-bottom-inner .table-items:nth-child(6),.table-bottom-inner .table-items:nth-child(8),.table-top .table-items:nth-child(5),.table-top .table-items:nth-child(6),.table-top .table-items:nth-child(8) {
34
- flex: 0 0 auto;
35
- width: 100px
36
- }
37
-
38
- .table-bottom-inner .table-items:last-child,.table-top .table-items:last-child {
39
- flex: 0 0 auto;
40
- width: 104px
41
- }
42
-
43
- .table-top {
44
- width: 100%;
45
- height: 44px;
46
- background: #00236a
47
- }
48
-
49
- .table-top .table-items {
50
- flex: 1 1;
51
- display: flex;
52
- align-items: center;
53
- justify-content: center;
54
- text-align: center;
55
- color: #fff;
56
- font-size: 15px;
57
- line-height: 17px
58
- }
59
-
60
- .table-bottom-inner {
61
- width: 100%;
62
- min-height: 40px;
63
- background: #fff
64
- }
65
-
66
- .table-bottom-inner .table-items {
67
- flex: 1 1;
68
- display: flex;
69
- align-items: center;
70
- justify-content: center;
71
- text-align: center;
72
- font-size: 14px;
73
- line-height: 16px;
74
- border-bottom: 1px solid #eee;
75
- padding: 4px
76
- }
77
-
78
- .table-bottom-inner .table-items:not(:last-child) {
79
- border-right: 1px solid #eee
80
- }