@@ -2,7 +2,7 @@ import styled from 'styled-components';
2
2
3
3
import IndeterminateCheckbox from './IndeterminateCheckbox' ;
4
4
5
- import React , { useEffect , useRef , useState } from 'react' ;
5
+ import React , { useEffect , useState } from 'react' ;
6
6
7
7
import {
8
8
useTable ,
@@ -23,7 +23,6 @@ import { Dropdown, Input, Menu, Tooltip, Button, Empty } from 'antd';
23
23
24
24
import { debounce } from '../services/util/debounce' ;
25
25
import { getConditionalSelectHeaderCheckboxProps } from '../services/GetConditionalSelectHeaderCheckboxProps' ;
26
- import { useIsOverflow } from '../hooks/useIsOverflow' ;
27
26
28
27
//TODO: Move all of the styled components to another file.
29
28
@@ -44,7 +43,7 @@ const CellActionContainer = styled.div`
44
43
width: fit-content;
45
44
` ;
46
45
47
- const SearchContainer = styled . div < { reloadDisabled : boolean , loading : boolean } > `
46
+ const SearchContainer = styled . div < { reloadDisabled : number , loading : number } > `
48
47
display: flex;
49
48
border-bottom: 1px solid #f0f0f0;
50
49
background-color: #fafafa;
@@ -258,9 +257,9 @@ const FilterDropdownButton = styled.span<{ isFiltered: boolean; }>`
258
257
const FilterDropdown = styled . div `
259
258
position: absolute;
260
259
261
- right: 1rem ;
260
+ right: 1em ;
262
261
263
- top: 3rem ;
262
+ top: 3em ;
264
263
265
264
background-color: #fff;
266
265
@@ -273,7 +272,7 @@ const FilterDropdown = styled.div`
273
272
box-shadow: 0 3px 6px -4px #0000001f, 0 6px 16px #00000014,
274
273
0 9px 28px 8px #0000000d;
275
274
276
- min-width: 20rem ;
275
+ min-width: 20em ;
277
276
278
277
cursor: default;
279
278
` ;
@@ -312,6 +311,10 @@ const CellInputContainer = styled.div<{ validationError?: IValidationError | nul
312
311
box-shadow: ${ ( { validationError, columnId } ) => ( validationError && ( validationError . name || validationError . isUnique ) && columnId === 'name' ) || ( validationError && validationError . value && columnId === 'value' ) ? '0px 0px 0px 2px rgb(255 77 79 / 20%)' : '0 0 0 2px rgb(24 144 255 / 20%);' } ;
313
312
}
314
313
314
+ input::selection {
315
+ background-color: #1a98ff;
316
+ }
317
+
315
318
input {
316
319
padding: 0;
317
320
border: none;
@@ -341,25 +344,10 @@ const CellInputSuffixContainer = styled.span<{ validationError?: IValidationErro
341
344
}
342
345
` ;
343
346
344
- const CellValue = styled . div < { hasOverflow : boolean | undefined } > `
345
- overflow-x: auto;
347
+ const CellValue = styled . div `
348
+ text-overflow: ellipsis;
349
+ overflow-x: hidden;
346
350
overflow-wrap: normal;
347
-
348
- margin-bottom: ${ ( { hasOverflow } ) => hasOverflow ? '-10px' : '' } ;
349
-
350
- ::-webkit-scrollbar {
351
- height: 10px;
352
- }
353
-
354
- ::-webkit-scrollbar-track {
355
- background: #f1f1f1;
356
- border-radius: 2px;
357
- }
358
-
359
- ::-webkit-scrollbar-thumb {
360
- background: #888;
361
- border-radius: 2px;
362
- }
363
351
` ;
364
352
365
353
const NoData = styled . div `
@@ -392,10 +380,6 @@ const EditableCell = ({
392
380
393
381
const [ errorMessage , setErrorMessage ] = useState < string > ( '' ) ;
394
382
395
- const ref = useRef ( null ) ;
396
-
397
- const hasOverflow = useIsOverflow ( ref , editableRowIndex ) ;
398
-
399
383
async function validateInput ( value :string ) {
400
384
const nameIsNotUnique : string = 'Name is not unique' ;
401
385
const nameIsTooShort : string = 'Name is too short' ;
@@ -541,7 +525,9 @@ const EditableCell = ({
541
525
</ CellInputSuffixContainer >
542
526
</ CellInputContainer >
543
527
) : (
544
- < CellValue hasOverflow = { hasOverflow } ref = { ref } > { value } </ CellValue >
528
+ < CellValue >
529
+ { value }
530
+ </ CellValue >
545
531
) ;
546
532
} ;
547
533
@@ -575,7 +561,7 @@ function GlobalFilter({
575
561
} , 200 ) ;
576
562
577
563
return (
578
- < SearchContainer loading = { loading } reloadDisabled = { editableRowIndex !== null } >
564
+ < SearchContainer loading = { loading ? 1 : 0 } reloadDisabled = { editableRowIndex !== null ? 1 : 0 } >
579
565
< Button disabled = { editableRowIndex !== null } loading = { loading } onClick = { ( ) => loadVariables ( ) } > Reload</ Button >
580
566
< HeaderSeparator />
581
567
< SearchLabel > Search:{ ' ' } </ SearchLabel >
@@ -734,7 +720,7 @@ export function Table(tableProps: React.PropsWithChildren<ITableProps>) {
734
720
Header ( props ) {
735
721
const [ indeterminateCheckboxProps , setIndeterminateCheckboxProps ] = useState ( getConditionalSelectHeaderCheckboxProps ( {
736
722
headerProps : props ,
737
- checkIfRowIsSelectable : ( row : Row ) => row . cells [ 5 ] . value !== true ,
723
+ checkIfRowIsSelectable : ( row : Row ) => row . cells [ 5 ] . value !== 1 ,
738
724
shouldSelectPage : true
739
725
} ) ) ;
740
726
@@ -765,7 +751,7 @@ export function Table(tableProps: React.PropsWithChildren<ITableProps>) {
765
751
case 'unlocked' :
766
752
newProps = {
767
753
headerProps : props ,
768
- checkIfRowIsSelectable : ( row : Row ) => row . cells [ 5 ] . value !== true ,
754
+ checkIfRowIsSelectable : ( row : Row ) => row . cells [ 5 ] . value !== 1 ,
769
755
shouldSelectPage : true
770
756
} ;
771
757
setIndeterminateCheckboxProps ( getConditionalSelectHeaderCheckboxProps ( { ...newProps } ) ) ;
@@ -774,7 +760,7 @@ export function Table(tableProps: React.PropsWithChildren<ITableProps>) {
774
760
case 'locked' :
775
761
newProps = {
776
762
headerProps : props ,
777
- checkIfRowIsSelectable : ( row : Row ) => row . cells [ 5 ] . value === true ,
763
+ checkIfRowIsSelectable : ( row : Row ) => row . cells [ 5 ] . value === 1 ,
778
764
shouldSelectPage : true
779
765
} ;
780
766
setIndeterminateCheckboxProps ( getConditionalSelectHeaderCheckboxProps ( { ...newProps } ) ) ;
@@ -814,8 +800,8 @@ export function Table(tableProps: React.PropsWithChildren<ITableProps>) {
814
800
Header : 'Actions' ,
815
801
disableFilters : true ,
816
802
disableSortBy : true ,
817
- width : 320 ,
818
- minWidth : 320 ,
803
+ width : 338 ,
804
+ minWidth : 338 ,
819
805
maxWidth : undefined ,
820
806
Cell : ( { row, setEditableRowIndex, editableRowIndex, validationError, rowIndexToKey, editVariable, deleteVariable, initialRowData, setInitialRowData, modifyTableData } ) => (
821
807
< CellActionContainer >
@@ -826,7 +812,7 @@ export function Table(tableProps: React.PropsWithChildren<ITableProps>) {
826
812
const updatedRow = row . values ;
827
813
editVariable ( id . toString ( ) , updatedRow . name , updatedRow . value , ! updatedRow . preventDeletion ) ;
828
814
} }
829
- style = { { minWidth : 96.69 } }
815
+ style = { { minWidth : 104 } }
830
816
>
831
817
{ row . values . preventDeletion ? 'Unlock' : 'Lock' }
832
818
</ ActionButton >
@@ -847,13 +833,13 @@ export function Table(tableProps: React.PropsWithChildren<ITableProps>) {
847
833
setInitialRowData ( null ) ;
848
834
}
849
835
} }
850
- style = { { minWidth : 82.71 } }
836
+ style = { { minWidth : 89 } }
851
837
>
852
838
{ editableRowIndex !== row . index ? 'Edit' : 'Save' }
853
839
</ ActionButton >
854
840
< ActionButton
855
841
danger = { true }
856
- disabled = { ( validationError && validationError . row !== row . index ) || ( editableRowIndex !== null && editableRowIndex !== row . index ) || ( row . values . preventDeletion === true && editableRowIndex !== row . index ) }
842
+ disabled = { ( validationError && validationError . row !== row . index ) || ( editableRowIndex !== null && editableRowIndex !== row . index ) || ( row . values . preventDeletion === 1 && editableRowIndex !== row . index ) }
857
843
onClick = { ( ) => {
858
844
const currentIndex = row . index ;
859
845
if ( editableRowIndex !== currentIndex ) {
@@ -872,7 +858,7 @@ export function Table(tableProps: React.PropsWithChildren<ITableProps>) {
872
858
loadVariables ( ) ;
873
859
}
874
860
} }
875
- style = { { minWidth : 96 } }
861
+ style = { { minWidth : 103 } }
876
862
>
877
863
{ editableRowIndex !== row . index ? 'Delete' : 'Cancel' }
878
864
</ ActionButton >
@@ -993,7 +979,7 @@ export function Table(tableProps: React.PropsWithChildren<ITableProps>) {
993
979
title : undefined ,
994
980
style : {
995
981
width : column . width !== undefined ? column . width : '' ,
996
- minWidth : column . minWidth !== undefined ? column . width : '' ,
982
+ minWidth : column . minWidth !== undefined ? column . minWidth : '' ,
997
983
maxWidth : column . maxWidth !== undefined ? column . maxWidth : '' ,
998
984
} ,
999
985
} )
0 commit comments