techsbcn-storybook 0.25.1 → 0.26.0

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.
@@ -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: string;
30
- label: string;
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())];
@@ -725,17 +725,18 @@ var TableComponent = function TableComponent(props) {
725
725
  key: column.isUnique ? guid : column.id,
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, {
@@ -771,69 +772,71 @@ var TableComponent = function TableComponent(props) {
771
772
  tabIndex: -1,
772
773
  key: index
773
774
  }, props.columns.map(function (column) {
774
- var value = column.rowViewFormat ? checkFormat(row, column.rowViewFormat) : ObjectbyString(row, column.id);
775
- var isItemSelected = column.isCheck && isSelected(row.id);
776
- var guid = Math.random().toString(36).substring(7);
777
- return React__default.createElement(_.TableCell, {
778
- className: "table-cell",
779
- key: column.isUnique ? guid : column.id,
780
- sx: {
781
- textAlign: {
782
- xs: 'left',
783
- md: column.alignCell ? column.alignCell : column.align ? column.align : 'center'
784
- }
785
- },
786
- onClick: function onClick() {
787
- return !column.action && !column.isCheck && !column.isActiveFunction ? handleRowClick(row) : '';
788
- }
789
- }, React__default.createElement(_.Hidden, {
790
- mdUp: true
791
- }, column.label !== '-' && React__default.createElement(_.Box, {
792
- display: "inline-block",
793
- className: "label-cell"
794
- }, column.label)), column.rowViewFormat ? React__default.createElement(_.Box, {
795
- className: "format-value"
796
- }, value) : column.action ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
797
- display: "flex",
798
- className: "actions"
799
- }, column.action && column.action.map(function (action, i) {
800
- return React__default.createElement(_.Box, {
801
- key: i
802
- }, action.onClick && React__default.createElement(_.Box, {
803
- className: "btn-action main-color-hover",
775
+ if (column.id) {
776
+ var value = column.rowViewFormat ? checkFormat(row, column.rowViewFormat) : ObjectbyString(row, column.id);
777
+ var isItemSelected = column.isCheck && isSelected(row.id);
778
+ var guid = Math.random().toString(36).substring(7);
779
+ return React__default.createElement(_.TableCell, {
780
+ className: "table-cell " + (column.cellClassName ? column.cellClassName(row) : ''),
781
+ key: column.isUnique ? guid : column.id,
782
+ sx: {
783
+ textAlign: {
784
+ xs: 'left',
785
+ md: column.alignCell ? column.alignCell : column.align ? column.align : 'center'
786
+ }
787
+ },
804
788
  onClick: function onClick() {
805
- return action.onClick && action.onClick(row);
789
+ return !column.action && !column.isCheck && !column.isActiveFunction ? handleRowClick(row) : '';
806
790
  }
807
- }, action.children), action.onClickId && React__default.createElement(_.Box, {
791
+ }, React__default.createElement(_.Hidden, {
792
+ mdUp: true
793
+ }, column.label !== '-' && React__default.createElement(_.Box, {
794
+ display: "inline-block",
795
+ className: "label-cell"
796
+ }, column.label)), column.rowViewFormat ? React__default.createElement(_.Box, {
797
+ className: "format-value"
798
+ }, value) : column.action && row.length > 0 ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
799
+ display: "flex",
800
+ className: "actions"
801
+ }, column.action && column.action.map(function (action, i) {
802
+ return React__default.createElement(_.Box, {
803
+ key: i
804
+ }, action.onClick && React__default.createElement(_.Box, {
805
+ className: "btn-action main-color-hover",
806
+ onClick: function onClick() {
807
+ return action.onClick && action.onClick(row);
808
+ }
809
+ }, action.children), action.onClickId && React__default.createElement(_.Box, {
810
+ className: "btn-action main-color-hover",
811
+ onClick: function onClick() {
812
+ return action.onClickId && action.onClickId(row.id);
813
+ }
814
+ }, action.children), !action.onClick && !action.onClickId && React__default.createElement(_.Box, {
815
+ className: "btn-action"
816
+ }, action.children));
817
+ }))) : column.isActiveFunction && row.length > 0 ? React__default.createElement(_.Box, {
808
818
  className: "btn-action main-color-hover",
809
819
  onClick: function onClick() {
810
- return action.onClickId && action.onClickId(row.id);
820
+ return column.isActiveFunction && column.isActiveFunction.onClickId(row.id);
811
821
  }
812
- }, action.children), !action.onClick && !action.onClickId && React__default.createElement(_.Box, {
813
- className: "btn-action"
814
- }, action.children));
815
- }))) : column.isActiveFunction ? React__default.createElement(_.Box, {
816
- className: "btn-action main-color-hover",
817
- onClick: function onClick() {
818
- return column.isActiveFunction && column.isActiveFunction.onClickId(row.id);
819
- }
820
- }, value ? column.isActiveFunction.activeIcon : column.isActiveFunction.disabledIcon) : column.isCheck ? React__default.createElement(_.Box, {
821
- className: "checkbox-cell"
822
- }, React__default.createElement(_.Checkbox, {
823
- checked: isItemSelected,
824
- inputProps: {
825
- 'aria-labelledby': row.id
826
- },
827
- onChange: function onChange(event) {
828
- return onCheckAction(event, row.id);
829
- }
830
- })) : column.isEditableTableCell ? EditableTableCell(row, value, column.id, column.isEditableTableCell) : column.enumColumn ? React__default.createElement(_.Box, {
831
- 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, {
833
- className: (column.isBoolean.hasColor ? (column.isBoolean.enumSuffix ? value.toString().toLowerCase() + "-" + column.isBoolean.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-boolean-color" : '') + " format-value"
834
- }, formatValue(value, column)) : React__default.createElement(_.Box, {
835
- className: "" + (column.isImage ? '' : 'format-value')
836
- }, formatValue(value, column)));
822
+ }, value ? column.isActiveFunction.activeIcon : column.isActiveFunction.disabledIcon) : column.isCheck && row.length > 0 ? React__default.createElement(_.Box, {
823
+ className: "checkbox-cell"
824
+ }, React__default.createElement(_.Checkbox, {
825
+ checked: isItemSelected,
826
+ inputProps: {
827
+ 'aria-labelledby': row.id
828
+ },
829
+ onChange: function onChange(event) {
830
+ return onCheckAction(event, row.id);
831
+ }
832
+ })) : column.isEditableTableCell && row.length > 0 ? EditableTableCell(row, value, column.id, column.isEditableTableCell) : column.enumColumn && row.length > 0 ? React__default.createElement(_.Box, {
833
+ className: (column.enumColumn.hasColor ? (column.enumColumn.enumSuffix ? value.toLowerCase() + "-" + column.enumColumn.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-type-color" : '') + " format-value"
834
+ }, formatValue(value, column)) : column.isBoolean && row.length > 0 ? React__default.createElement(_.Box, {
835
+ className: (column.isBoolean.hasColor ? (column.isBoolean.enumSuffix ? value.toString().toLowerCase() + "-" + column.isBoolean.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-boolean-color" : '') + " format-value"
836
+ }, formatValue(value, column)) : React__default.createElement(_.Box, {
837
+ className: "" + (column.isImage ? '' : 'format-value')
838
+ }, formatValue(value, column)));
839
+ } else return null;
837
840
  }));
838
841
  }) : !props.loading ? React__default.createElement(_.TableRow, null, React__default.createElement(_.TableCell, {
839
842
  colSpan: props.columns.length
@@ -842,10 +845,10 @@ var TableComponent = function TableComponent(props) {
842
845
  count: props.totalCount,
843
846
  rowsPerPage: props.baseFilters.limit,
844
847
  labelRowsPerPage: props.values.SHOWING,
845
- labelDisplayedRows: function labelDisplayedRows(_ref) {
846
- var from = _ref.from,
847
- to = _ref.to,
848
- count = _ref.count;
848
+ labelDisplayedRows: function labelDisplayedRows(_ref2) {
849
+ var from = _ref2.from,
850
+ to = _ref2.to,
851
+ count = _ref2.count;
849
852
  return props.values.TABLE_LABEL_DISPLAY(from, to, count);
850
853
  },
851
854
  page: props.baseFilters.page - 1,
@@ -1012,9 +1015,9 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1012
1015
  }
1013
1016
 
1014
1017
  if (column.isBoolean) {
1015
- var booleanStr = value ? 'true' : 'false';
1018
+ var booleanStr = value ? value ? 'true' : 'false' : '';
1016
1019
 
1017
- if (column.isBoolean.enumType) {
1020
+ if (column.isBoolean.enumType && booleanStr) {
1018
1021
  var _column$isBoolean3;
1019
1022
 
1020
1023
  if (column.isBoolean.enumSuffix) {
@@ -1022,7 +1025,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1022
1025
 
1023
1026
  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
1027
  } else return props.values[(_column$isBoolean3 = column.isBoolean) == null ? void 0 : _column$isBoolean3.enumType[booleanStr].toUpperCase()];
1025
- } else if (column.isBoolean.enumSuffix) {
1028
+ } else if (column.isBoolean.enumSuffix && booleanStr) {
1026
1029
  var _column$isBoolean4;
1027
1030
 
1028
1031
  return props.values[booleanStr.toUpperCase() + "_" + ((_column$isBoolean4 = column.isBoolean) == null ? void 0 : _column$isBoolean4.enumSuffix.toUpperCase())];
@@ -1128,6 +1131,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1128
1131
  key: column.isUnique ? guid : column.id,
1129
1132
  align: column.align ? column.align : 'center',
1130
1133
  style: {
1134
+ width: column.width,
1131
1135
  minWidth: column.minWidth,
1132
1136
  maxWidth: column.maxWidth
1133
1137
  }
@@ -1170,7 +1174,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1170
1174
  var isItemSelected = column.isCheck && isSelected(row.id);
1171
1175
  var guid = Math.random().toString(36).substring(7);
1172
1176
  return React__default.createElement(_.TableCell, {
1173
- className: "table-cell",
1177
+ className: "table-cell " + (column.cellClassName ? column.cellClassName(row) : ''),
1174
1178
  key: column.isUnique ? guid : column.id,
1175
1179
  sx: {
1176
1180
  textAlign: {
@@ -1186,7 +1190,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1186
1190
  }, column.label !== '-' && React__default.createElement(_.Box, {
1187
1191
  display: "inline-block",
1188
1192
  className: "label-cell"
1189
- }, column.label)), column.action ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
1193
+ }, column.label)), column.action && row.length > 0 ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
1190
1194
  display: "flex",
1191
1195
  className: "actions"
1192
1196
  }, column.rowViewFormat ? React__default.createElement(_.Box, {
@@ -1207,12 +1211,12 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1207
1211
  }, action.children), !action.onClick && !action.onClickId && React__default.createElement(_.Box, {
1208
1212
  className: "btn-action"
1209
1213
  }, action.children));
1210
- }))) : column.isActiveFunction ? React__default.createElement(_.Box, {
1214
+ }))) : column.isActiveFunction && row.length > 0 ? React__default.createElement(_.Box, {
1211
1215
  className: "btn-action main-color-hover",
1212
1216
  onClick: function onClick() {
1213
1217
  return column.isActiveFunction && column.isActiveFunction.onClickId(row.id);
1214
1218
  }
1215
- }, value ? column.isActiveFunction.activeIcon : column.isActiveFunction.disabledIcon) : column.isCheck ? React__default.createElement(_.Box, {
1219
+ }, value ? column.isActiveFunction.activeIcon : column.isActiveFunction.disabledIcon) : column.isCheck && row.length > 0 ? React__default.createElement(_.Box, {
1216
1220
  className: "checkbox-cell"
1217
1221
  }, React__default.createElement(_.Checkbox, {
1218
1222
  checked: isItemSelected,
@@ -1224,9 +1228,9 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1224
1228
 
1225
1229
  return (_props$isCheckTable18 = props.isCheckTable) != null && _props$isCheckTable18.onCheckedAction ? onCheckAction(event, row.id) : onCheckSingleAction(event, row.id);
1226
1230
  }
1227
- })) : column.isEditableTableCell ? EditableTableCell(row, value, column.id, column.isEditableTableCell) : column.enumColumn ? React__default.createElement(_.Box, {
1231
+ })) : column.isEditableTableCell && row.length > 0 ? EditableTableCell(row, value, column.id, column.isEditableTableCell) : column.enumColumn && row.length > 0 ? React__default.createElement(_.Box, {
1228
1232
  className: (column.enumColumn.hasColor ? (column.enumColumn.enumSuffix ? value.toLowerCase() + "-" + column.enumColumn.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-type-color" : '') + " format-value"
1229
- }, formatValue(value, column)) : column.isBoolean ? React__default.createElement(_.Box, {
1233
+ }, formatValue(value, column)) : column.isBoolean && row.length > 0 ? React__default.createElement(_.Box, {
1230
1234
  className: (column.isBoolean.hasColor ? (column.isBoolean.enumSuffix ? value.toString().toLowerCase() + "-" + column.isBoolean.enumSuffix.toLowerCase() : value.toString().toLowerCase()) + "-boolean-color" : '') + " format-value"
1231
1235
  }, formatValue(value, column)) : React__default.createElement(_.Box, {
1232
1236
  className: "" + (column.isImage ? '' : 'format-value')