techsbcn-storybook 0.15.3 → 0.17.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.
@@ -40,6 +40,9 @@ interface ColumnProps {
40
40
  };
41
41
  isCheck?: boolean;
42
42
  isPrice?: boolean;
43
+ priceFormat?: {
44
+ currency?: string;
45
+ };
43
46
  isImage?: {
44
47
  isUrl?: boolean;
45
48
  isGuid?: {
@@ -58,6 +61,7 @@ interface ColumnProps {
58
61
  hasColor?: boolean;
59
62
  enumSuffix?: string;
60
63
  };
64
+ rowViewFormat?: (row: any) => any;
61
65
  }
62
66
  interface ActionProps {
63
67
  children: React.ReactNode;
@@ -42,6 +42,9 @@ interface ColumnProps {
42
42
  isCheck?: boolean;
43
43
  noSort?: boolean;
44
44
  isPrice?: boolean;
45
+ priceFormat?: {
46
+ currency?: string;
47
+ };
45
48
  isImage?: {
46
49
  isUrl?: boolean;
47
50
  isGuid?: {
@@ -61,6 +64,7 @@ interface ColumnProps {
61
64
  enumSuffix?: string;
62
65
  };
63
66
  orderBy?: string;
67
+ rowViewFormat?: (row: any) => any;
64
68
  }
65
69
  interface ActionProps {
66
70
  children: React.ReactNode;
@@ -562,7 +562,7 @@ var TableComponent = function TableComponent(props) {
562
562
  }
563
563
 
564
564
  if (column.isDate && value) return new Date(value).toLocaleDateString('es-ES');
565
- if (column.isPrice && value) return Number(value).toFixed(2).replace('.', ',') + " " + props.values.SYMBOL_EURO;
565
+ if (column.isPrice && value) return Number(value).toFixed(2).replace('.', ',').toLocaleString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.') + " " + props.values.SYMBOL_EURO;
566
566
 
567
567
  if (column.isImage && value) {
568
568
  if (column.isImage.isUrl) {
@@ -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
 
@@ -687,7 +697,7 @@ var TableComponent = function TableComponent(props) {
687
697
  }, React__default.createElement(_.Hidden, {
688
698
  smDown: true
689
699
  }, React__default.createElement(_.TableHead, null, React__default.createElement(_.TableRow, null, props.columns.map(function (column) {
690
- var _ref, _props$isCheckTable10, _props$isCheckTable11, _props$isCheckTable12;
700
+ var _props$isCheckTable10, _props$isCheckTable11, _props$isCheckTable12;
691
701
 
692
702
  var guid = Math.random().toString(36).substring(7);
693
703
  return React__default.createElement(_.TableCell, {
@@ -700,7 +710,7 @@ var TableComponent = function TableComponent(props) {
700
710
  }
701
711
  }, column.id !== 'actions' && !column.isCheck && !column.isActiveFunction && !column.noSort ? React__default.createElement(_.TableSortLabel, {
702
712
  className: "table-header-cell",
703
- active: (_ref = filters.orderBy === column.orderBy) != null ? _ref : column.id,
713
+ active: column.orderBy ? filters.orderBy === column.orderBy : filters.orderBy === column.id,
704
714
  direction: filters.orderAsc ? 'asc' : 'desc',
705
715
  onClick: function onClick() {
706
716
  var _column$orderBy;
@@ -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) {
@@ -805,10 +817,10 @@ var TableComponent = function TableComponent(props) {
805
817
  count: props.totalCount,
806
818
  rowsPerPage: props.baseFilters.limit,
807
819
  labelRowsPerPage: props.values.SHOWING,
808
- labelDisplayedRows: function labelDisplayedRows(_ref2) {
809
- var from = _ref2.from,
810
- to = _ref2.to,
811
- count = _ref2.count;
820
+ labelDisplayedRows: function labelDisplayedRows(_ref) {
821
+ var from = _ref.from,
822
+ to = _ref.to,
823
+ count = _ref.count;
812
824
  return props.values.TABLE_LABEL_DISPLAY(from, to, count);
813
825
  },
814
826
  page: props.baseFilters.page - 1,
@@ -946,7 +958,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
946
958
  }
947
959
 
948
960
  if (column.isDate && value) return new Date(value).toLocaleDateString('es-ES');
949
- if (column.isPrice && value) return Number(value).toFixed(2).replace('.', ',') + " " + props.values.SYMBOL_EURO;
961
+ if (column.isPrice && value) return Number(value).toFixed(2).replace('.', ',').toLocaleString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.') + " " + props.values.SYMBOL_EURO;
950
962
 
951
963
  if (column.isImage && value) {
952
964
  if (column.isImage.isUrl) {
@@ -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, {