techsbcn-storybook 0.15.3 → 0.16.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.
@@ -58,6 +58,7 @@ interface ColumnProps {
58
58
  hasColor?: boolean;
59
59
  enumSuffix?: string;
60
60
  };
61
+ rowViewFormat?: (row: any) => any;
61
62
  }
62
63
  interface ActionProps {
63
64
  children: React.ReactNode;
@@ -61,6 +61,7 @@ interface ColumnProps {
61
61
  enumSuffix?: string;
62
62
  };
63
63
  orderBy?: string;
64
+ rowViewFormat?: (row: any) => any;
64
65
  }
65
66
  interface ActionProps {
66
67
  children: React.ReactNode;
@@ -633,6 +633,16 @@ var TableComponent = function TableComponent(props) {
633
633
  return o;
634
634
  };
635
635
 
636
+ var checkFormat = function checkFormat(o, f) {
637
+ try {
638
+ o = f(o);
639
+ } catch (_error) {
640
+ return undefined;
641
+ }
642
+
643
+ return o;
644
+ };
645
+
636
646
  var EditableTableCell = function EditableTableCell(row, value, fieldName, editableCell) {
637
647
  var rowEdit = JSON.parse(JSON.stringify(row));
638
648
 
@@ -736,7 +746,7 @@ var TableComponent = function TableComponent(props) {
736
746
  tabIndex: -1,
737
747
  key: index
738
748
  }, props.columns.map(function (column) {
739
- var value = ObjectbyString(row, column.id);
749
+ var value = column.rowViewFormat ? checkFormat(row, column.rowViewFormat) : ObjectbyString(row, column.id);
740
750
  var isItemSelected = column.isCheck && isSelected(row.id);
741
751
  var guid = Math.random().toString(36).substring(7);
742
752
  return React__default.createElement(_.TableCell, {
@@ -756,7 +766,9 @@ var TableComponent = function TableComponent(props) {
756
766
  }, column.label !== '-' && React__default.createElement(_.Box, {
757
767
  display: "inline-block",
758
768
  className: "label-cell"
759
- }, column.label)), column.action ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
769
+ }, column.label)), column.rowViewFormat ? React__default.createElement(_.Box, {
770
+ className: "format-value"
771
+ }, value) : column.action ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
760
772
  display: "flex",
761
773
  className: "actions"
762
774
  }, column.action && column.action.map(function (action, i) {
@@ -1017,6 +1029,18 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1017
1029
  return o;
1018
1030
  };
1019
1031
 
1032
+ var checkFormat = function checkFormat(o, f) {
1033
+ var result = o;
1034
+
1035
+ try {
1036
+ result = f(o);
1037
+ } catch (_error) {
1038
+ return undefined;
1039
+ }
1040
+
1041
+ return result;
1042
+ };
1043
+
1020
1044
  var EditableTableCell = function EditableTableCell(row, value, fieldName, editableCell) {
1021
1045
  var rowEdit = JSON.parse(JSON.stringify(row));
1022
1046
 
@@ -1100,7 +1124,6 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1100
1124
  }))), props.rows && props.rows.length > 0 ? props.rows.map(function (row, index) {
1101
1125
  var _props$isCheckTable17;
1102
1126
 
1103
- //const key = props.rows[index + 1] && props.rows[index + 1].id === row.id ? index : row.id;
1104
1127
  var rowColor = props.rowsColorColumn && ObjectbyString(row, props.rowsColorColumn.columnName) === props.rowsColorColumn.columnValue ? "row-color-" + props.rowsColorColumn.columnValue : '';
1105
1128
  var isRowSelected = ((_props$isCheckTable17 = props.isCheckTable) == null ? void 0 : _props$isCheckTable17.rowsChecked) && isSelected(row.id);
1106
1129
  return React__default.createElement(_.TableRow, {
@@ -1112,7 +1135,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1112
1135
  key: index
1113
1136
  }, props.columns.map(function (column) {
1114
1137
  if (column.id) {
1115
- var value = ObjectbyString(row, column.id);
1138
+ var value = column.rowViewFormat ? checkFormat(row, column.rowViewFormat) : ObjectbyString(row, column.id);
1116
1139
  var isItemSelected = column.isCheck && isSelected(row.id);
1117
1140
  var guid = Math.random().toString(36).substring(7);
1118
1141
  return React__default.createElement(_.TableCell, {
@@ -1135,7 +1158,9 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1135
1158
  }, column.label)), column.action ? React__default.createElement(_.Box, null, React__default.createElement(_.Box, {
1136
1159
  display: "flex",
1137
1160
  className: "actions"
1138
- }, column.action && column.action.map(function (action, i) {
1161
+ }, column.rowViewFormat ? React__default.createElement(_.Box, {
1162
+ className: "format-value"
1163
+ }, value) : column.action && column.action.map(function (action, i) {
1139
1164
  return React__default.createElement(_.Box, {
1140
1165
  key: i
1141
1166
  }, action.onClick && React__default.createElement(_.Box, {