techsbcn-storybook 0.25.1 → 0.26.1
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/components/tables/SimpleTableComponent/SimpleTableComponent.d.ts +2 -0
- package/dist/components/tables/TableComponent/TableComponent.d.ts +4 -2
- package/dist/techsbcn-storybook.cjs.development.js +91 -86
- package/dist/techsbcn-storybook.cjs.development.js.map +1 -1
- package/dist/techsbcn-storybook.cjs.production.min.js +1 -1
- package/dist/techsbcn-storybook.cjs.production.min.js.map +1 -1
- package/dist/techsbcn-storybook.esm.js +91 -86
- package/dist/techsbcn-storybook.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/tables/SimpleTableComponent/SimpleTableComponent.tsx +122 -122
- package/src/components/tables/TableComponent/TableComponent.tsx +26 -19
- package/src/stories/Tables/TableComponent.stories.tsx +3 -2
|
@@ -29,6 +29,7 @@ interface ColumnProps {
|
|
|
29
29
|
label?: string;
|
|
30
30
|
minWidth?: number;
|
|
31
31
|
maxWidth?: number;
|
|
32
|
+
width?: number;
|
|
32
33
|
align?: 'inherit' | 'left' | 'center' | 'right' | 'justify';
|
|
33
34
|
alignCell?: 'inherit' | 'left' | 'center' | 'right' | 'justify';
|
|
34
35
|
action?: ActionProps[];
|
|
@@ -65,6 +66,7 @@ interface ColumnProps {
|
|
|
65
66
|
enumSuffix?: string;
|
|
66
67
|
};
|
|
67
68
|
rowViewFormat?: (row: any) => any;
|
|
69
|
+
cellClassName?: (row: any) => string;
|
|
68
70
|
}
|
|
69
71
|
interface ActionProps {
|
|
70
72
|
children: React.ReactNode;
|
|
@@ -26,10 +26,11 @@ interface TableComponentProps {
|
|
|
26
26
|
isBordered?: boolean;
|
|
27
27
|
}
|
|
28
28
|
interface ColumnProps {
|
|
29
|
-
id
|
|
30
|
-
label
|
|
29
|
+
id?: string;
|
|
30
|
+
label?: string;
|
|
31
31
|
minWidth?: number;
|
|
32
32
|
maxWidth?: number;
|
|
33
|
+
width?: number;
|
|
33
34
|
align?: 'inherit' | 'left' | 'center' | 'right' | 'justify';
|
|
34
35
|
alignCell?: 'inherit' | 'left' | 'center' | 'right' | 'justify';
|
|
35
36
|
action?: ActionProps[];
|
|
@@ -68,6 +69,7 @@ interface ColumnProps {
|
|
|
68
69
|
};
|
|
69
70
|
orderBy?: string;
|
|
70
71
|
rowViewFormat?: (row: any) => any;
|
|
72
|
+
cellClassName?: (row: any) => string;
|
|
71
73
|
}
|
|
72
74
|
interface ActionProps {
|
|
73
75
|
children: React.ReactNode;
|
|
@@ -605,9 +605,9 @@ var TableComponent = function TableComponent(props) {
|
|
|
605
605
|
}
|
|
606
606
|
|
|
607
607
|
if (column.isBoolean) {
|
|
608
|
-
var booleanStr = value ? 'true' : 'false';
|
|
608
|
+
var booleanStr = value ? value ? 'true' : 'false' : '';
|
|
609
609
|
|
|
610
|
-
if (column.isBoolean.enumType) {
|
|
610
|
+
if (column.isBoolean.enumType && booleanStr) {
|
|
611
611
|
var _column$isBoolean3;
|
|
612
612
|
|
|
613
613
|
if (column.isBoolean.enumSuffix) {
|
|
@@ -615,7 +615,7 @@ var TableComponent = function TableComponent(props) {
|
|
|
615
615
|
|
|
616
616
|
return props.values[((_column$isBoolean = column.isBoolean) == null ? void 0 : _column$isBoolean.enumType[booleanStr].toUpperCase()) + "_" + ((_column$isBoolean2 = column.isBoolean) == null ? void 0 : _column$isBoolean2.enumSuffix.toUpperCase())];
|
|
617
617
|
} else return props.values[(_column$isBoolean3 = column.isBoolean) == null ? void 0 : _column$isBoolean3.enumType[booleanStr].toUpperCase()];
|
|
618
|
-
} else if (column.isBoolean.enumSuffix) {
|
|
618
|
+
} else if (column.isBoolean.enumSuffix && booleanStr) {
|
|
619
619
|
var _column$isBoolean4;
|
|
620
620
|
|
|
621
621
|
return props.values[booleanStr.toUpperCase() + "_" + ((_column$isBoolean4 = column.isBoolean) == null ? void 0 : _column$isBoolean4.enumSuffix.toUpperCase())];
|
|
@@ -722,20 +722,21 @@ var TableComponent = function TableComponent(props) {
|
|
|
722
722
|
var guid = Math.random().toString(36).substring(7);
|
|
723
723
|
return React__default.createElement(_.TableCell, {
|
|
724
724
|
className: "table-column",
|
|
725
|
-
key: column.isUnique ? guid : column.id,
|
|
725
|
+
key: column.isUnique ? guid : column.id ? guid + '-' + column.id : guid,
|
|
726
726
|
align: column.align ? column.align : 'center',
|
|
727
727
|
style: {
|
|
728
|
+
width: column.width,
|
|
728
729
|
minWidth: column.minWidth,
|
|
729
730
|
maxWidth: column.maxWidth
|
|
730
731
|
}
|
|
731
|
-
}, column.id !== 'actions' && !column.isCheck && !column.isActiveFunction && !column.noSort ? React__default.createElement(_.TableSortLabel, {
|
|
732
|
+
}, (column.orderBy || column.id) && column.id !== 'actions' && !column.isCheck && !column.isActiveFunction && !column.noSort ? React__default.createElement(_.TableSortLabel, {
|
|
732
733
|
className: "table-header-cell",
|
|
733
734
|
active: column.orderBy ? filters.orderBy === column.orderBy : filters.orderBy === column.id,
|
|
734
735
|
direction: filters.orderAsc ? 'asc' : 'desc',
|
|
735
736
|
onClick: function onClick() {
|
|
736
|
-
var _column$orderBy;
|
|
737
|
+
var _ref, _column$orderBy;
|
|
737
738
|
|
|
738
|
-
return createSortHandler((_column$orderBy = column.orderBy) != null ? _column$orderBy : column.id);
|
|
739
|
+
return createSortHandler((_ref = (_column$orderBy = column.orderBy) != null ? _column$orderBy : column.id) != null ? _ref : '');
|
|
739
740
|
},
|
|
740
741
|
hideSortIcon: true
|
|
741
742
|
}, column.label) : column.isCheck ? React__default.createElement(_.Box, {
|
|
@@ -763,20 +764,23 @@ var TableComponent = function TableComponent(props) {
|
|
|
763
764
|
|
|
764
765
|
var rowColor = props.rowsColorColumn && ObjectbyString(row, props.rowsColorColumn.columnName) === props.rowsColorColumn.columnValue ? "row-color-" + props.rowsColorColumn.columnValue : props.isStriped && props.rows.length > 1 && index % 2 == 0 ? 'main-background-color table-striped' : '';
|
|
765
766
|
var isRowSelected = ((_props$isCheckTable13 = props.isCheckTable) == null ? void 0 : _props$isCheckTable13.rowsChecked) && isSelected(row.id);
|
|
767
|
+
var guidRow = Math.random().toString(36).substring(7);
|
|
766
768
|
return React__default.createElement(_.TableRow, {
|
|
767
769
|
className: "table-rows " + rowColor + " " + (props.onClickRow || props.onClickRowData ? 'row-click' : ''),
|
|
768
770
|
role: "checkbox",
|
|
769
771
|
selected: isRowSelected,
|
|
770
772
|
"aria-checked": isRowSelected,
|
|
771
773
|
tabIndex: -1,
|
|
772
|
-
key: index
|
|
774
|
+
key: index + '-' + guidRow
|
|
773
775
|
}, props.columns.map(function (column) {
|
|
774
|
-
var
|
|
776
|
+
var _column$id;
|
|
777
|
+
|
|
778
|
+
var value = column.rowViewFormat ? checkFormat(row, column.rowViewFormat) : ObjectbyString(row, (_column$id = column.id) != null ? _column$id : '');
|
|
775
779
|
var isItemSelected = column.isCheck && isSelected(row.id);
|
|
776
780
|
var guid = Math.random().toString(36).substring(7);
|
|
777
781
|
return React__default.createElement(_.TableCell, {
|
|
778
|
-
className: "table-cell",
|
|
779
|
-
key: column.isUnique ? guid : column.id,
|
|
782
|
+
className: "table-cell " + (column.cellClassName ? column.cellClassName(row) : ''),
|
|
783
|
+
key: column.isUnique ? guid : column.id ? guid + '-' + column.id : guid,
|
|
780
784
|
sx: {
|
|
781
785
|
textAlign: {
|
|
782
786
|
xs: 'left',
|
|
@@ -793,7 +797,7 @@ var TableComponent = function TableComponent(props) {
|
|
|
793
797
|
className: "label-cell"
|
|
794
798
|
}, column.label)), column.rowViewFormat ? React__default.createElement(_.Box, {
|
|
795
799
|
className: "format-value"
|
|
796
|
-
}, value) : column.action ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
|
|
800
|
+
}, value) : column.action && row.length > 0 ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
|
|
797
801
|
display: "flex",
|
|
798
802
|
className: "actions"
|
|
799
803
|
}, column.action && column.action.map(function (action, i) {
|
|
@@ -812,12 +816,12 @@ var TableComponent = function TableComponent(props) {
|
|
|
812
816
|
}, action.children), !action.onClick && !action.onClickId && React__default.createElement(_.Box, {
|
|
813
817
|
className: "btn-action"
|
|
814
818
|
}, action.children));
|
|
815
|
-
}))) : column.isActiveFunction ? React__default.createElement(_.Box, {
|
|
819
|
+
}))) : column.isActiveFunction && row.length > 0 ? React__default.createElement(_.Box, {
|
|
816
820
|
className: "btn-action main-color-hover",
|
|
817
821
|
onClick: function onClick() {
|
|
818
822
|
return column.isActiveFunction && column.isActiveFunction.onClickId(row.id);
|
|
819
823
|
}
|
|
820
|
-
}, value ? column.isActiveFunction.activeIcon : column.isActiveFunction.disabledIcon) : column.isCheck ? React__default.createElement(_.Box, {
|
|
824
|
+
}, value ? column.isActiveFunction.activeIcon : column.isActiveFunction.disabledIcon) : column.isCheck && row.length > 0 ? React__default.createElement(_.Box, {
|
|
821
825
|
className: "checkbox-cell"
|
|
822
826
|
}, React__default.createElement(_.Checkbox, {
|
|
823
827
|
checked: isItemSelected,
|
|
@@ -827,9 +831,9 @@ var TableComponent = function TableComponent(props) {
|
|
|
827
831
|
onChange: function onChange(event) {
|
|
828
832
|
return onCheckAction(event, row.id);
|
|
829
833
|
}
|
|
830
|
-
})) : column.isEditableTableCell ? EditableTableCell(row, value, column.id, column.isEditableTableCell) : column.enumColumn ? React__default.createElement(_.Box, {
|
|
834
|
+
})) : column.isEditableTableCell && row.length > 0 ? EditableTableCell(row, value, column.id, column.isEditableTableCell) : column.enumColumn && row.length > 0 ? React__default.createElement(_.Box, {
|
|
831
835
|
className: (column.enumColumn.hasColor ? (column.enumColumn.enumSuffix ? value.toLowerCase() + "-" + column.enumColumn.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-type-color" : '') + " format-value"
|
|
832
|
-
}, formatValue(value, column)) : column.isBoolean ? React__default.createElement(_.Box, {
|
|
836
|
+
}, formatValue(value, column)) : column.isBoolean && row.length > 0 ? React__default.createElement(_.Box, {
|
|
833
837
|
className: (column.isBoolean.hasColor ? (column.isBoolean.enumSuffix ? value.toString().toLowerCase() + "-" + column.isBoolean.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-boolean-color" : '') + " format-value"
|
|
834
838
|
}, formatValue(value, column)) : React__default.createElement(_.Box, {
|
|
835
839
|
className: "" + (column.isImage ? '' : 'format-value')
|
|
@@ -842,10 +846,10 @@ var TableComponent = function TableComponent(props) {
|
|
|
842
846
|
count: props.totalCount,
|
|
843
847
|
rowsPerPage: props.baseFilters.limit,
|
|
844
848
|
labelRowsPerPage: props.values.SHOWING,
|
|
845
|
-
labelDisplayedRows: function labelDisplayedRows(
|
|
846
|
-
var from =
|
|
847
|
-
to =
|
|
848
|
-
count =
|
|
849
|
+
labelDisplayedRows: function labelDisplayedRows(_ref2) {
|
|
850
|
+
var from = _ref2.from,
|
|
851
|
+
to = _ref2.to,
|
|
852
|
+
count = _ref2.count;
|
|
849
853
|
return props.values.TABLE_LABEL_DISPLAY(from, to, count);
|
|
850
854
|
},
|
|
851
855
|
page: props.baseFilters.page - 1,
|
|
@@ -1012,9 +1016,9 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
|
|
|
1012
1016
|
}
|
|
1013
1017
|
|
|
1014
1018
|
if (column.isBoolean) {
|
|
1015
|
-
var booleanStr = value ? 'true' : 'false';
|
|
1019
|
+
var booleanStr = value ? value ? 'true' : 'false' : '';
|
|
1016
1020
|
|
|
1017
|
-
if (column.isBoolean.enumType) {
|
|
1021
|
+
if (column.isBoolean.enumType && booleanStr) {
|
|
1018
1022
|
var _column$isBoolean3;
|
|
1019
1023
|
|
|
1020
1024
|
if (column.isBoolean.enumSuffix) {
|
|
@@ -1022,7 +1026,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
|
|
|
1022
1026
|
|
|
1023
1027
|
return props.values[((_column$isBoolean = column.isBoolean) == null ? void 0 : _column$isBoolean.enumType[booleanStr].toUpperCase()) + "_" + ((_column$isBoolean2 = column.isBoolean) == null ? void 0 : _column$isBoolean2.enumSuffix.toUpperCase())];
|
|
1024
1028
|
} else return props.values[(_column$isBoolean3 = column.isBoolean) == null ? void 0 : _column$isBoolean3.enumType[booleanStr].toUpperCase()];
|
|
1025
|
-
} else if (column.isBoolean.enumSuffix) {
|
|
1029
|
+
} else if (column.isBoolean.enumSuffix && booleanStr) {
|
|
1026
1030
|
var _column$isBoolean4;
|
|
1027
1031
|
|
|
1028
1032
|
return props.values[booleanStr.toUpperCase() + "_" + ((_column$isBoolean4 = column.isBoolean) == null ? void 0 : _column$isBoolean4.enumSuffix.toUpperCase())];
|
|
@@ -1125,9 +1129,10 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
|
|
|
1125
1129
|
var guid = Math.random().toString(36).substring(7);
|
|
1126
1130
|
return React__default.createElement(_.TableCell, {
|
|
1127
1131
|
className: "table-column",
|
|
1128
|
-
key: column.isUnique ? guid : column.id,
|
|
1132
|
+
key: column.isUnique ? guid : column.id ? guid + '-' + column.id : guid,
|
|
1129
1133
|
align: column.align ? column.align : 'center',
|
|
1130
1134
|
style: {
|
|
1135
|
+
width: column.width,
|
|
1131
1136
|
minWidth: column.minWidth,
|
|
1132
1137
|
maxWidth: column.maxWidth
|
|
1133
1138
|
}
|
|
@@ -1165,73 +1170,73 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
|
|
|
1165
1170
|
"aria-checked": isRowSelected,
|
|
1166
1171
|
key: index
|
|
1167
1172
|
}, props.columns.map(function (column) {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
},
|
|
1181
|
-
onClick: function onClick() {
|
|
1182
|
-
return !column.action && !column.isCheck && !column.isActiveFunction ? handleRowClick(row) : '';
|
|
1173
|
+
var _column$id;
|
|
1174
|
+
|
|
1175
|
+
var value = column.rowViewFormat ? checkFormat(row, column.rowViewFormat) : ObjectbyString(row, (_column$id = column.id) != null ? _column$id : '');
|
|
1176
|
+
var isItemSelected = column.isCheck && isSelected(row.id);
|
|
1177
|
+
var guid = Math.random().toString(36).substring(7);
|
|
1178
|
+
return React__default.createElement(_.TableCell, {
|
|
1179
|
+
className: "table-cell " + (column.cellClassName ? column.cellClassName(row) : ''),
|
|
1180
|
+
key: column.isUnique ? guid : column.id ? guid + '-' + column.id : guid,
|
|
1181
|
+
sx: {
|
|
1182
|
+
textAlign: {
|
|
1183
|
+
xs: 'left',
|
|
1184
|
+
md: column.alignCell ? column.alignCell : column.align ? column.align : 'center'
|
|
1183
1185
|
}
|
|
1184
|
-
},
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
}, action.children), action.onClickId && React__default.createElement(_.Box, {
|
|
1203
|
-
className: "btn-action main-color-hover",
|
|
1204
|
-
onClick: function onClick() {
|
|
1205
|
-
return action.onClickId && action.onClickId(row.id);
|
|
1206
|
-
}
|
|
1207
|
-
}, action.children), !action.onClick && !action.onClickId && React__default.createElement(_.Box, {
|
|
1208
|
-
className: "btn-action"
|
|
1209
|
-
}, action.children));
|
|
1210
|
-
}))) : column.isActiveFunction ? React__default.createElement(_.Box, {
|
|
1186
|
+
},
|
|
1187
|
+
onClick: function onClick() {
|
|
1188
|
+
return !column.action && !column.isCheck && !column.isActiveFunction ? handleRowClick(row) : '';
|
|
1189
|
+
}
|
|
1190
|
+
}, React__default.createElement(_.Hidden, {
|
|
1191
|
+
mdUp: true
|
|
1192
|
+
}, column.label !== '-' && React__default.createElement(_.Box, {
|
|
1193
|
+
display: "inline-block",
|
|
1194
|
+
className: "label-cell"
|
|
1195
|
+
}, column.label)), column.action && row.length > 0 ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
|
|
1196
|
+
display: "flex",
|
|
1197
|
+
className: "actions"
|
|
1198
|
+
}, column.rowViewFormat ? React__default.createElement(_.Box, {
|
|
1199
|
+
className: "format-value"
|
|
1200
|
+
}, value) : column.action && column.action.map(function (action, i) {
|
|
1201
|
+
return React__default.createElement(_.Box, {
|
|
1202
|
+
key: i
|
|
1203
|
+
}, action.onClick && React__default.createElement(_.Box, {
|
|
1211
1204
|
className: "btn-action main-color-hover",
|
|
1212
1205
|
onClick: function onClick() {
|
|
1213
|
-
return
|
|
1206
|
+
return action.onClick && action.onClick(row);
|
|
1214
1207
|
}
|
|
1215
|
-
},
|
|
1216
|
-
className: "
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
inputProps: {
|
|
1220
|
-
'aria-labelledby': row.id
|
|
1221
|
-
},
|
|
1222
|
-
onChange: function onChange(event) {
|
|
1223
|
-
var _props$isCheckTable18;
|
|
1224
|
-
|
|
1225
|
-
return (_props$isCheckTable18 = props.isCheckTable) != null && _props$isCheckTable18.onCheckedAction ? onCheckAction(event, row.id) : onCheckSingleAction(event, row.id);
|
|
1208
|
+
}, action.children), action.onClickId && React__default.createElement(_.Box, {
|
|
1209
|
+
className: "btn-action main-color-hover",
|
|
1210
|
+
onClick: function onClick() {
|
|
1211
|
+
return action.onClickId && action.onClickId(row.id);
|
|
1226
1212
|
}
|
|
1227
|
-
}
|
|
1228
|
-
className:
|
|
1229
|
-
},
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1213
|
+
}, action.children), !action.onClick && !action.onClickId && React__default.createElement(_.Box, {
|
|
1214
|
+
className: "btn-action"
|
|
1215
|
+
}, action.children));
|
|
1216
|
+
}))) : column.isActiveFunction && row.length > 0 ? React__default.createElement(_.Box, {
|
|
1217
|
+
className: "btn-action main-color-hover",
|
|
1218
|
+
onClick: function onClick() {
|
|
1219
|
+
return column.isActiveFunction && column.isActiveFunction.onClickId(row.id);
|
|
1220
|
+
}
|
|
1221
|
+
}, value ? column.isActiveFunction.activeIcon : column.isActiveFunction.disabledIcon) : column.isCheck && row.length > 0 ? React__default.createElement(_.Box, {
|
|
1222
|
+
className: "checkbox-cell"
|
|
1223
|
+
}, React__default.createElement(_.Checkbox, {
|
|
1224
|
+
checked: isItemSelected,
|
|
1225
|
+
inputProps: {
|
|
1226
|
+
'aria-labelledby': row.id
|
|
1227
|
+
},
|
|
1228
|
+
onChange: function onChange(event) {
|
|
1229
|
+
var _props$isCheckTable18;
|
|
1230
|
+
|
|
1231
|
+
return (_props$isCheckTable18 = props.isCheckTable) != null && _props$isCheckTable18.onCheckedAction ? onCheckAction(event, row.id) : onCheckSingleAction(event, row.id);
|
|
1232
|
+
}
|
|
1233
|
+
})) : column.isEditableTableCell && row.length > 0 ? EditableTableCell(row, value, column.id, column.isEditableTableCell) : column.enumColumn && row.length > 0 ? React__default.createElement(_.Box, {
|
|
1234
|
+
className: (column.enumColumn.hasColor ? (column.enumColumn.enumSuffix ? value.toLowerCase() + "-" + column.enumColumn.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-type-color" : '') + " format-value"
|
|
1235
|
+
}, formatValue(value, column)) : column.isBoolean && row.length > 0 ? React__default.createElement(_.Box, {
|
|
1236
|
+
className: (column.isBoolean.hasColor ? (column.isBoolean.enumSuffix ? value.toString().toLowerCase() + "-" + column.isBoolean.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-boolean-color" : '') + " format-value"
|
|
1237
|
+
}, formatValue(value, column)) : React__default.createElement(_.Box, {
|
|
1238
|
+
className: "" + (column.isImage ? '' : 'format-value')
|
|
1239
|
+
}, formatValue(value, column)));
|
|
1235
1240
|
}));
|
|
1236
1241
|
}) : !props.loading ? React__default.createElement(_.TableRow, null, React__default.createElement(_.TableCell, {
|
|
1237
1242
|
colSpan: props.columns.length
|