@@ -6,7 +6,6 @@ const props = defineProps<{
66 packageName: string
77}>()
88
9- const claimPackageModal = useModal (' claim-package-modal' )
109const {
1110 isConnected,
1211 state,
@@ -72,14 +71,14 @@ async function handleClaim() {
7271 } else if (completedOp ?.status === ' failed' ) {
7372 if (completedOp .result ?.requiresOtp ) {
7473 // OTP is needed - open connector panel to handle it
75- claimPackageModal . close ()
74+ close ()
7675 connectorModal .open ()
7776 } else {
7877 publishError .value = completedOp .result ?.stderr || ' Failed to publish package'
7978 }
8079 } else {
8180 // Still pending/approved/running - open connector panel to show progress
82- claimPackageModal . close ()
81+ close ()
8382 connectorModal .open ()
8483 }
8584 } catch (err ) {
@@ -89,14 +88,23 @@ async function handleClaim() {
8988 }
9089}
9190
92- // Reset state when modal opens
93- function handleModalOpen() {
91+ const dialogRef = ref <HTMLDialogElement >()
92+
93+ function open() {
94+ // Reset state and check availability each time modal is opened
9495 checkResult .value = null
9596 publishError .value = null
9697 publishSuccess .value = false
9798 checkAvailability ()
99+ dialogRef .value ?.showModal ()
100+ }
101+
102+ function close() {
103+ dialogRef .value ?.close ()
98104}
99105
106+ defineExpose ({ open , close })
107+
100108// Computed for similar packages with warnings
101109const hasDangerousSimilarPackages = computed (() => {
102110 if (! checkResult .value ?.similarPackages ) return false
@@ -127,7 +135,12 @@ const previewPackageJson = computed(() => {
127135
128136<template >
129137 <!-- Modal -->
130- <Modal :modalTitle =" $t('claim.modal.title')" id =" claim-package-modal" @open =" handleModalOpen" >
138+ <Modal
139+ ref =" dialogRef"
140+ :modalTitle =" $t('claim.modal.title')"
141+ id =" claim-package-modal"
142+ class =" max-w-md"
143+ >
131144 <!-- Loading state -->
132145 <div v-if =" isChecking" class =" py-8 text-center" >
133146 <LoadingSpinner :text =" $t('claim.modal.checking')" />
@@ -155,14 +168,14 @@ const previewPackageJson = computed(() => {
155168 <NuxtLink
156169 :to =" `/package/${packageName}`"
157170 class =" flex-1 px-4 py-2 font-mono text-sm text-center text-bg bg-fg rounded-md transition-colors duration-200 hover:bg-fg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
158- @click =" claimPackageModal. close"
171+ @click =" close"
159172 >
160173 {{ $t('claim.modal.view_package') }}
161174 </NuxtLink >
162175 <button
163176 type =" button"
164177 class =" flex-1 px-4 py-2 font-mono text-sm text-fg-muted bg-bg-subtle border border-border rounded-md transition-colors duration-200 hover:text-fg hover:border-border-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
165- @click =" claimPackageModal. close"
178+ @click =" close"
166179 >
167180 {{ $t('common.close') }}
168181 </button >
@@ -349,7 +362,7 @@ const previewPackageJson = computed(() => {
349362 v-if =" !checkResult.available || !checkResult.valid"
350363 type =" button"
351364 class =" w-full px-4 py-2 font-mono text-sm text-fg-muted bg-bg-subtle border border-border rounded-md transition-colors duration-200 hover:text-fg hover:border-border-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fg/50"
352- @click =" claimPackageModal. close"
365+ @click =" close"
353366 >
354367 {{ $t('common.close') }}
355368 </button >
0 commit comments