techsbcn-storybook 0.15.2 → 0.17.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.
@@ -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;
@@ -135,14 +135,14 @@ var SearchComponent = function SearchComponent(props) {
135
135
  alignItems: "center"
136
136
  }, React__default.createElement(material.Grid, {
137
137
  item: true,
138
- xs: props.actions ? 6 : 12,
138
+ xs: props.actions ? 8 : 12,
139
139
  md: props.searchBar ? 4 : props.actions ? 6 : 12
140
140
  }, React__default.createElement(material.Box, {
141
141
  px: 1,
142
142
  className: (props.enableAfter ? 'main-background-color-after' : '') + " title"
143
143
  }, props.title)), props.actions && React__default.createElement(material.Grid, {
144
144
  item: true,
145
- xs: props.title ? 6 : 12,
145
+ xs: props.title ? 4 : 12,
146
146
  sx: {
147
147
  display: {
148
148
  xs: 'block',
@@ -153,14 +153,14 @@ var SearchComponent = function SearchComponent(props) {
153
153
  sx: {
154
154
  display: {
155
155
  xs: 'none',
156
- sm: 'flex'
156
+ md: 'flex'
157
157
  }
158
158
  }
159
159
  }, ActionsList(props.actions)), React__default.createElement(material.Box, {
160
160
  sx: {
161
161
  display: {
162
162
  xs: 'flex',
163
- sm: 'none'
163
+ md: 'none'
164
164
  }
165
165
  }
166
166
  }, props.actions.length > 1 ? React__default.createElement(material.Box, {
@@ -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
 
@@ -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) {
@@ -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, {