11import * as React from "react" ;
22import { connect } from "unistore/react" ;
33import * as Types from "./types" ;
4- import * as PointSet from "./point-set" ;
5- import * as PointMap from "./point-map" ;
6- import { getRangeDimensions } from "./util" ;
4+ import { getCopiedRange , getRangeDimensions } from "./util" ;
75import FloatingRect , {
86 Props as FloatingRectProps ,
97 StateProps ,
@@ -12,19 +10,13 @@ import FloatingRect, {
1210type Props = Omit < FloatingRectProps , "variant" > ;
1311
1412const Copied : React . FC < Props > = ( props ) => (
15- < FloatingRect { ...props } variant = "copied" />
13+ < FloatingRect { ...props } variant = "copied" dragging = { false } />
1614) ;
1715
1816export default connect < { } , { } , Types . StoreState , StateProps > ( ( state ) => {
19- const cells = state . hasPasted
20- ? PointSet . from ( [ ] )
21- : PointMap . map ( ( ) => true , state . copied ) ;
22- const hidden = PointSet . size ( cells ) === 0 ;
17+ const range = getCopiedRange ( state . copied , state . hasPasted ) ;
2318 return {
24- dimensions : hidden
25- ? null
26- : getRangeDimensions ( state , PointSet . toRange ( cells ) ) ,
27- hidden,
28- dragging : false ,
19+ dimensions : range && getRangeDimensions ( state , range ) ,
20+ hidden : range === null ,
2921 } ;
3022} ) ( Copied ) ;
0 commit comments