@@ -19,7 +19,7 @@ export class SelectAllController implements ReactiveController {
19
19
private readonly query : QueryController ;
20
20
private abortController ?: AbortController ;
21
21
private locked = false ;
22
- readonly pageSize : number = 100 ;
22
+ readonly pageSize : number = 500 ;
23
23
private readonly emitter = new EventTarget ( ) ;
24
24
25
25
constructor ( host : ReactiveControllerHost , spec : SelectAllControllerSpec ) {
@@ -30,7 +30,6 @@ export class SelectAllController implements ReactiveController {
30
30
type PrivateMembers = "setIsLocked" | "locked" ;
31
31
makeObservable < this, PrivateMembers > ( this , {
32
32
setIsLocked : action ,
33
- selection : computed ,
34
33
canExecute : computed ,
35
34
isExecuting : computed ,
36
35
locked : observable ,
@@ -52,13 +51,18 @@ export class SelectAllController implements ReactiveController {
52
51
this . emitter . removeEventListener ( type , listener ) ;
53
52
}
54
53
55
- get selection ( ) : SelectionMultiValue | undefined {
54
+ /**
55
+ * @throws if selection is undefined or single
56
+ */
57
+ selection ( ) : SelectionMultiValue {
56
58
const selection = this . gate . props . itemSelection ;
57
- return selection ?. type === "Multi" ? selection : undefined ;
59
+ if ( selection === undefined ) throw new Error ( "SelectAllController: selection is undefined." ) ;
60
+ if ( selection . type === "Single" ) throw new Error ( "SelectAllController: single selection is not supported." ) ;
61
+ return selection ;
58
62
}
59
63
60
64
get canExecute ( ) : boolean {
61
- return this . selection ?. type === "Multi" && ! this . locked ;
65
+ return this . gate . props . itemSelection ?. type === "Multi" && ! this . locked ;
62
66
}
63
67
64
68
get isExecuting ( ) : boolean {
@@ -96,7 +100,7 @@ export class SelectAllController implements ReactiveController {
96
100
this . setIsLocked ( true ) ;
97
101
98
102
const { offset : initOffset , limit : initLimit } = this . query ;
99
- const initSelection = this . selection ? .selection ;
103
+ const initSelection = this . selection ( ) . selection ;
100
104
const hasTotal = typeof this . query . totalCount === "number" ;
101
105
const totalCount = this . query . totalCount ?? 0 ;
102
106
let loaded = 0 ;
@@ -125,13 +129,13 @@ export class SelectAllController implements ReactiveController {
125
129
loading = ! signal . aborted && this . query . hasMoreItems ;
126
130
}
127
131
// Set allItems on success
128
- this . selection ? .setSelection ( allItems ) ;
132
+ this . selection ( ) . setSelection ( allItems ) ;
129
133
} catch ( error ) {
130
134
if ( ! signal . aborted ) {
131
135
throw error ;
132
136
}
133
137
// Restore selection on abort
134
- this . selection ? .setSelection ( initSelection ?? [ ] ) ;
138
+ this . selection ( ) . setSelection ( initSelection ) ;
135
139
} finally {
136
140
this . query . setOffset ( initOffset ) ;
137
141
this . query . setLimit ( initLimit ) ;
@@ -146,7 +150,7 @@ export class SelectAllController implements ReactiveController {
146
150
console . debug ( "SelectAllController: can't clear selection while executing." ) ;
147
151
return ;
148
152
}
149
- this . selection ? .setSelection ( [ ] ) ;
153
+ this . selection ( ) . setSelection ( [ ] ) ;
150
154
}
151
155
152
156
abort ( ) : void {
0 commit comments