11export const MAX_PACKAGE_SELECTION = 4
22
33export function usePackageSelection ( ) {
4- // Use 'push' mode and let router handle scroll behavior naturally
54 const selectedPackagesParam = useRouteQuery < string > ( 'selection' , '' , { mode : 'push' } )
65 const showSelectionViewParam = useRouteQuery < string > ( 'view' , '' , { mode : 'push' } )
76
@@ -23,10 +22,8 @@ export function usePackageSelection() {
2322 } ,
2423 } )
2524
26- // Check if max selection is reached
2725 const isMaxSelected = computed ( ( ) => selectedPackages . value . length >= MAX_PACKAGE_SELECTION )
2826
29- // Track whether the SelectionView is open/visible
3027 const showSelectionView = computed < boolean > ( {
3128 get ( ) {
3229 return showSelectionViewParam . value === 'selection'
@@ -36,12 +33,14 @@ export function usePackageSelection() {
3633 } ,
3734 } )
3835
39- /** Check if a package name is selected */
36+ function closeSelectionView ( ) {
37+ showSelectionView . value = false
38+ }
39+
4040 function isPackageSelected ( packageName : string ) : boolean {
4141 return selectedPackages . value . includes ( String ( packageName ) . trim ( ) )
4242 }
4343
44- /** Toggle selection for a package by name */
4544 function togglePackageSelection ( packageName : string ) {
4645 const safeName = String ( packageName ) . trim ( )
4746 if ( ! safeName ) return
@@ -56,17 +55,10 @@ export function usePackageSelection() {
5655 selectedPackages . value = pkgs
5756 }
5857
59- /** Clear all selected packages */
6058 function clearSelectedPackages ( ) {
6159 selectedPackages . value = [ ]
6260 }
6361
64- /** Close the selection view */
65- function closeSelectionView ( ) {
66- showSelectionView . value = false
67- }
68-
69- /** Open the selection view */
7062 function openSelectionView ( ) {
7163 showSelectionView . value = true
7264 }
0 commit comments