@imposium-hub/components 1.33.3 → 1.34.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.
package/Util.ts CHANGED
@@ -250,7 +250,7 @@ export const formatDateDefault = (unix : number) => {
250
250
  let hr = date.getHours();
251
251
  const meridian = hr >= 12 ? 'PM' : 'AM';
252
252
  if (hr > 12) { hr = hr - 12; }
253
-
253
+ if (hr === 0) { hr = 12; }
254
254
  let min : any = date.getMinutes();
255
255
  if (min < 10) {
256
256
  min = `0${min}`;
@@ -6,7 +6,7 @@ interface IAssetsTableDateCell {
6
6
  }
7
7
 
8
8
  const AssetsTableDateCell : React.FC<IAssetsTableDateCell> = (p : IAssetsTableDateCell) => (
9
- <>{formatDateDefault(p.cell.row.values.date_created)}</>
9
+ <div>{formatDateDefault(p.cell.row.values.date_created)}</div>
10
10
  );
11
11
 
12
12
  const AssetsTableDateCellMemoized = React.memo(AssetsTableDateCell);
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import {useEffect, useState} from 'react';
2
3
  import TextField from '../text-field/TextField';
3
4
  import { updateAssetName } from '../../redux/actions/asset-list';
4
5
  import { connect } from 'react-redux';
@@ -8,22 +9,38 @@ import { IImposiumAPI } from '../../services/API';
8
9
  interface IAssetsTableNameCell {
9
10
  cell : any;
10
11
  api : IImposiumAPI;
11
- updateAssetName : (api : any, id : string, name : string) => any;
12
+ updateAssetName : (api : any, id : string, name : string, delay? : boolean) => any;
12
13
  }
13
14
 
15
+ let updateTimeout : any;
14
16
  const AssetsTableNameCell : React.FC<IAssetsTableNameCell> = (props : IAssetsTableNameCell) => {
15
17
 
16
18
  const {cell: {row: {original: {name, id}}}} = props;
19
+ const [ localName, setLocalName ] = useState('');
20
+
21
+ const onUpdate = (n) => {
22
+ setLocalName(n);
23
+ clearTimeout(updateTimeout);
24
+ updateTimeout = setTimeout(() => setName(n), 1000);
25
+ };
26
+
27
+ const setName = (n) => {
28
+ props.updateAssetName(props.api, id, n);
29
+ };
30
+
31
+ useEffect(() => {
32
+ setLocalName(name);
33
+ return () => {
34
+ clearTimeout(updateTimeout);
35
+ };
36
+ }, [name]);
17
37
 
18
38
  return (
19
- <div>
20
- <TextField
21
- controlled = {true}
22
- value ={name}
23
- width = {'100%'}
24
- onSubmit = {(t) => props.updateAssetName(props.api, id, t)}
25
- />
26
- </div>
39
+ <TextField
40
+ value ={localName}
41
+ width = {'100%'}
42
+ onChange = {(n) => onUpdate(n)}
43
+ />
27
44
  );
28
45
  };
29
46
 
@@ -35,14 +35,12 @@ class AssetsTableSelectCell extends React.PureComponent<IAssetsTableSelectCell,
35
35
  };
36
36
 
37
37
  return (
38
- <div className = 'select-cell'>
39
- <CheckboxField
40
- label = ''
41
- width = 'auto'
42
- value = {isSelected}
43
- onChange = {(v, e) => selectionHandler(v, e)}
44
- />
45
- </div>
38
+ <CheckboxField
39
+ label = ''
40
+ width = 'auto'
41
+ value = {isSelected}
42
+ onChange = {(v, e) => selectionHandler(v, e)}
43
+ />
46
44
  );
47
45
  }
48
46
  }
@@ -50,6 +50,7 @@ interface IDataTableProps {
50
50
  freezeWhenExpanded? : boolean;
51
51
  customPaginator? : boolean;
52
52
  pages ? : number;
53
+ tightRows : boolean;
53
54
  dndType : string;
54
55
  dndName : string;
55
56
  dnd : boolean;
@@ -179,6 +180,7 @@ const DataTable : React.FC<IDataTableProps> = (props : IDataTableProps) => {
179
180
  const horizontalScrollClass : string = (wrapperRef.current && totalColumnsWidth > wrapperRef.current.clientWidth)
180
181
  ? 'horizontal-scroll'
181
182
  : '';
183
+ const rowClass = (props.tightRows) ? 'tight-rows' : '';
182
184
 
183
185
  // Set component mounted state
184
186
  React.useEffect(() => setDidMount(true), []);
@@ -254,7 +256,7 @@ const DataTable : React.FC<IDataTableProps> = (props : IDataTableProps) => {
254
256
 
255
257
  <table
256
258
  {...getTableProps()}
257
- className = {`ip-table ${horizontalScrollClass} ${hidePaginatorClass}`}
259
+ className = {`ip-table ${horizontalScrollClass} ${hidePaginatorClass} ${rowClass}`}
258
260
  >
259
261
  <thead className = 'ip-table-head'>
260
262
  {headerGroups.map((headerGroup) => {