File tree Expand file tree Collapse file tree 3 files changed +45
-17
lines changed
Expand file tree Collapse file tree 3 files changed +45
-17
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,12 @@ export default class PgTree extends HTMLElement {
8383 }
8484 item . selected = true ;
8585 this . #selectedIndexes. set ( unproxyItem , indexes ) ;
86- callback ( this . #selectedIndexes. size ) ;
86+ let count = 0 ;
87+ this . #selectedIndexes. forEach ( ( indexes ) => {
88+ const item = this . #getItem( indexes ) ;
89+ count = this . #getDragCount( item , count ) ;
90+ } ) ;
91+ callback ( count ) ;
8792 this . $items . classList . toggle ( 'dragging' , true ) ;
8893 } ) ;
8994 this . $items . addEventListener ( 'itemdragend' , ( e : any ) => {
@@ -92,6 +97,16 @@ export default class PgTree extends HTMLElement {
9297 this . $items . addEventListener ( 'itemdropenter' , this . #handleDropEnter. bind ( this ) ) ;
9398 }
9499
100+ #getDragCount( item , count ) {
101+ count += 1
102+ if ( item . items && item . items . length > 0 ) {
103+ item . items . forEach ( ( itm ) => {
104+ count = this . #getDragCount( itm , count ) ;
105+ } ) ;
106+ }
107+ return count ;
108+ }
109+
95110 #handleDropEnter( e : any ) {
96111 const { indexes, callback } = e . detail ;
97112 const excludes = this . #calculateDragExcludes( ) ;
Original file line number Diff line number Diff line change 181181 padding-left : calc ((var (--x ) * 0.5rem ) + 1.25rem )
182182}
183183
184- [part = item ].dragging {
185- position : relative;
186- }
187- [part = item ].dragging ::after {
188- position : absolute;
189- content : ' ' ;
190- display : flex;
191- top : 0 ;
192- right : 0 ;
193- bottom : 0 ;
194- left : 0 ;
195- border-radius : 0.25rem ;
196- background : rgba (255 , 255 , 255 , 0.5 );
197- user-select : none;
198- }
199-
200184[part = actions ] {
201185 display : flex;
202186 gap : 0.25rem ;
259243 border-radius : 0.25rem ;
260244}
261245
246+ [part = item ].dragging ::after {
247+ content : ' ' ;
248+ display : flex;
249+ grid-column : 1 / 5 ;
250+ grid-row : 1 ;
251+ border-radius : 0.25rem ;
252+ background : rgba (255 , 255 , 255 , 0.5 );
253+ user-select : none;
254+ margin : -0.25rem ;
255+ }
256+ [part = items ].dragging {
257+ --pg-_is-index-dragging : true
258+ }
259+
262260@container style(- - pg- _is - dragging: false) {
263261 [part = dropabove ],
264262 [part = dropon ],
265263 [part = dropbelow ] {
266264 display : none;
267265 }
268266}
267+
268+ @container style(- - pg- _is - index- dragging: true) {
269+ [part = item ]::after {
270+ content : ' ' ;
271+ display : flex;
272+ grid-column : 1 / 5 ;
273+ grid-row : 1 ;
274+ border-radius : 0.25rem ;
275+ background : rgba (255 , 255 , 255 , 0.5 );
276+ user-select : none;
277+ margin : -0.25rem ;
278+ }
279+ }
Original file line number Diff line number Diff line change @@ -347,6 +347,7 @@ export default class PgTreeItem extends HTMLElement {
347347 }
348348 } ) ) ;
349349 this . $item . classList . toggle ( 'dragging' , true ) ;
350+ this . $items . classList . toggle ( 'dragging' , true ) ;
350351 // Generate drag image showing selected item count
351352 const size = window . devicePixelRatio ;
352353 const canvas = document . createElement ( 'canvas' ) ;
@@ -403,6 +404,7 @@ export default class PgTreeItem extends HTMLElement {
403404 detail : { indexes : [ this . index ] }
404405 } ) ) ;
405406 this . $item . classList . toggle ( 'dragging' , false ) ;
407+ this . $items . classList . toggle ( 'dragging' , false ) ;
406408 this . #canvas. remove ( ) ;
407409 }
408410
You can’t perform that action at this time.
0 commit comments