techsbcn-storybook 0.15.0 → 0.15.3

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.
@@ -3,6 +3,7 @@ interface UserList {
3
3
  id: number;
4
4
  name: string;
5
5
  image: string;
6
+ imageGuid: string;
6
7
  skills: string[];
7
8
  information: string;
8
9
  email: string;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const usePrevious: (value: any) => undefined;
3
+ export declare const useIsMounted: () => import("react").MutableRefObject<boolean>;
@@ -1,3 +1,4 @@
1
1
  export * from './CheckPermission';
2
2
  export * from './GroupBy';
3
3
  export * from './FileDownloader';
4
+ export * from './hooks';
@@ -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, {
@@ -365,6 +365,50 @@ TextFieldComponent.defaultProps = {
365
365
  type: 'text'
366
366
  };
367
367
 
368
+ var checkPermission = function checkPermission(persmisionAvailable, userRoles) {
369
+ if (persmisionAvailable === null || persmisionAvailable === undefined || persmisionAvailable.length === 0) {
370
+ return true;
371
+ } else {
372
+ if (userRoles === undefined || userRoles === null || userRoles === 0) {
373
+ return false;
374
+ }
375
+ }
376
+
377
+ if (userRoles && Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
378
+ return persmisionAvailable.some(function (r) {
379
+ return userRoles.indexOf(r) >= 0;
380
+ });
381
+ }
382
+
383
+ if (userRoles && !Array.isArray(userRoles) && !Array.isArray(persmisionAvailable)) {
384
+ return userRoles === persmisionAvailable;
385
+ }
386
+
387
+ if (userRoles && !Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
388
+ return persmisionAvailable.indexOf(userRoles) >= 0;
389
+ }
390
+
391
+ return userRoles.indexOf(persmisionAvailable) >= 0;
392
+ };
393
+
394
+ var usePrevious = function usePrevious(value) {
395
+ var ref = React.useRef();
396
+ React.useEffect(function () {
397
+ ref.current = value;
398
+ });
399
+ return ref.current;
400
+ };
401
+ var useIsMounted = function useIsMounted() {
402
+ var isMounted = React.useRef(false);
403
+ React.useEffect(function () {
404
+ isMounted.current = true;
405
+ return function () {
406
+ isMounted.current = false;
407
+ };
408
+ }, []);
409
+ return isMounted;
410
+ };
411
+
368
412
  var ImageTableComponent = function ImageTableComponent(props) {
369
413
  var _useState = React.useState(false),
370
414
  loading = _useState[0],
@@ -374,17 +418,21 @@ var ImageTableComponent = function ImageTableComponent(props) {
374
418
  image = _useState2[0],
375
419
  setImage = _useState2[1];
376
420
 
421
+ var prevGuidState = usePrevious(props.guid);
422
+ var isMounted = useIsMounted();
377
423
  React.useEffect(function () {
378
- if (!image) {
424
+ if (prevGuidState !== props.guid) {
379
425
  setLoading(true);
380
426
  props.readFile(props.guid).then(function (result) {
381
- setImage(props.convertImage ? props.convertImage(result) : result);
382
- setLoading(false);
427
+ if (isMounted.current) {
428
+ setImage(props.convertImage ? props.convertImage(result) : result);
429
+ setLoading(false);
430
+ }
383
431
  })["catch"](function () {
384
432
  return setLoading(false);
385
433
  });
386
434
  }
387
- }, [props, image]);
435
+ }, [props, prevGuidState, isMounted]);
388
436
  return React__default.createElement(material.Box, {
389
437
  className: "images-table-component"
390
438
  }, loading ? React__default.createElement(material.Box, {
@@ -686,7 +734,7 @@ var TableComponent = function TableComponent(props) {
686
734
  className: "table-rows " + rowColor + " " + (props.onClickRow || props.onClickRowData ? 'row-click' : ''),
687
735
  role: "checkbox",
688
736
  tabIndex: -1,
689
- key: row.id || index
737
+ key: index
690
738
  }, props.columns.map(function (column) {
691
739
  var value = ObjectbyString(row, column.id);
692
740
  var isItemSelected = column.isCheck && isSelected(row.id);
@@ -1052,7 +1100,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1052
1100
  }))), props.rows && props.rows.length > 0 ? props.rows.map(function (row, index) {
1053
1101
  var _props$isCheckTable17;
1054
1102
 
1055
- var key = props.rows[index + 1] && props.rows[index + 1].id === row.id ? index : row.id;
1103
+ //const key = props.rows[index + 1] && props.rows[index + 1].id === row.id ? index : row.id;
1056
1104
  var rowColor = props.rowsColorColumn && ObjectbyString(row, props.rowsColorColumn.columnName) === props.rowsColorColumn.columnValue ? "row-color-" + props.rowsColorColumn.columnValue : '';
1057
1105
  var isRowSelected = ((_props$isCheckTable17 = props.isCheckTable) == null ? void 0 : _props$isCheckTable17.rowsChecked) && isSelected(row.id);
1058
1106
  return React__default.createElement(_.TableRow, {
@@ -1061,7 +1109,7 @@ var SimpleTableComponent = function SimpleTableComponent(props) {
1061
1109
  tabIndex: -1,
1062
1110
  selected: isRowSelected,
1063
1111
  "aria-checked": isRowSelected,
1064
- key: key || index
1112
+ key: index
1065
1113
  }, props.columns.map(function (column) {
1066
1114
  if (column.id) {
1067
1115
  var value = ObjectbyString(row, column.id);
@@ -1151,32 +1199,6 @@ var MainLayoutSimple = function MainLayoutSimple(props) {
1151
1199
  }, props.mainComponent))));
1152
1200
  };
1153
1201
 
1154
- var checkPermission = function checkPermission(persmisionAvailable, userRoles) {
1155
- if (persmisionAvailable === null || persmisionAvailable === undefined || persmisionAvailable.length === 0) {
1156
- return true;
1157
- } else {
1158
- if (userRoles === undefined || userRoles === null || userRoles === 0) {
1159
- return false;
1160
- }
1161
- }
1162
-
1163
- if (userRoles && Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
1164
- return persmisionAvailable.some(function (r) {
1165
- return userRoles.indexOf(r) >= 0;
1166
- });
1167
- }
1168
-
1169
- if (userRoles && !Array.isArray(userRoles) && !Array.isArray(persmisionAvailable)) {
1170
- return userRoles === persmisionAvailable;
1171
- }
1172
-
1173
- if (userRoles && !Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
1174
- return persmisionAvailable.indexOf(userRoles) >= 0;
1175
- }
1176
-
1177
- return userRoles.indexOf(persmisionAvailable) >= 0;
1178
- };
1179
-
1180
1202
  var VerticalNavItem = function VerticalNavItem(props) {
1181
1203
  var _useLocation = reactRouterDom.useLocation(),
1182
1204
  pathname = _useLocation.pathname;