11<script setup lang="ts">
22import type { NewOperation } from ' ~/composables/useConnector'
3- import type Modal from ' ~/components/Modal.client.vue'
43import { PackageDeprecateParamsSchema , safeParse } from ' ~~/cli/src/schemas'
5- import { fetchAllPackageVersions } from ' ~/utils/npm/api'
64
75const DEPRECATE_MESSAGE_MAX_LENGTH = 500
86
@@ -12,8 +10,10 @@ const props = withDefaults(
1210 version? : string
1311 /** When true, the package or version is already deprecated; form is hidden and state cannot be changed. */
1412 isAlreadyDeprecated? : boolean
13+ /** Version strings that are already deprecated (computed by parent from pkg.versions). */
14+ deprecatedVersions? : string []
1515 }>(),
16- { version: ' ' , isAlreadyDeprecated: false },
16+ { version: ' ' , isAlreadyDeprecated: false , deprecatedVersions : () => [] },
1717)
1818
1919const { t } = useI18n ()
@@ -28,18 +28,6 @@ const deprecateError = shallowRef<string | null>(null)
2828
2929const connectorModal = useModal (' connector-modal' )
3030
31- /** Full version list (same as "Other versions"); fetched in modal for deprecated check. */
32- const allPackageVersions = shallowRef <Awaited <ReturnType <typeof fetchAllPackageVersions >> | null >(
33- null ,
34- )
35-
36- /** Deprecated version strings from fetched full list (includes Other versions). */
37- const effectiveDeprecatedVersions = computed (() => {
38- const list = allPackageVersions .value
39- if (! list ) return []
40- return list .filter (v => v .deprecated ).map (v => v .version )
41- })
42-
4331const modalTitle = computed (() =>
4432 deprecateVersion .value
4533 ? ` ${t (' package.deprecation.modal.title' )} ${props .packageName }@${deprecateVersion .value } `
@@ -49,24 +37,10 @@ const modalTitle = computed(() =>
4937/** True when the user has entered a version in the form that is already deprecated. */
5038const isSelectedVersionDeprecated = computed (() => {
5139 const v = deprecateVersion .value .trim ()
52- if (! v || ! effectiveDeprecatedVersions . value .length ) return false
53- return effectiveDeprecatedVersions . value .includes (v )
40+ if (! v || ! props . deprecatedVersions .length ) return false
41+ return props . deprecatedVersions .includes (v )
5442})
5543
56- // Load full version list so deprecated check includes "Other versions"
57- watch (
58- () => props .packageName ,
59- async name => {
60- if (! name ) return
61- try {
62- allPackageVersions .value = await fetchAllPackageVersions (name )
63- } catch {
64- allPackageVersions .value = null
65- }
66- },
67- { immediate: true },
68- )
69-
7044async function handleDeprecate() {
7145 if (props .isAlreadyDeprecated || isSelectedVersionDeprecated .value ) return
7246 const message = deprecateMessage .value .trim ()
@@ -137,7 +111,7 @@ async function handleDeprecate() {
137111 }
138112}
139113
140- const dialogRef = ref < InstanceType < typeof Modal > | undefined >( )
114+ const dialogRef = useTemplateRef ( ' dialogRef ' )
141115
142116function open() {
143117 deprecateError .value = null
@@ -226,7 +200,10 @@ defineExpose({ open, close })
226200 </div >
227201 </div >
228202 <div >
229- <label for =" deprecate-message" class =" block text-sm font-medium text-fg mb-1" >
203+ <label
204+ for =" deprecate-message"
205+ class =" block text-xs text-fg-subtle uppercase tracking-wider mb-1.5"
206+ >
230207 {{ $t('package.deprecation.modal.reason') }}
231208 </label >
232209 <textarea
@@ -235,7 +212,7 @@ defineExpose({ open, close })
235212 rows =" 3"
236213 :maxlength =" DEPRECATE_MESSAGE_MAX_LENGTH"
237214 :disabled =" isSelectedVersionDeprecated"
238- class =" w-full px-3 py-2 font-mono text-sm bg-bg border border-border rounded-md text-fg placeholder:text-fg-muted focus: outline-none focus:ring-2 focus:ring-fg/50 disabled:opacity-60 disabled: cursor-not-allowed"
215+ class =" w-full appearance-none bg-bg-subtle border border-border font-mono text-sm leading-none px-3 py-2.5 rounded-lg text-fg placeholder:text-fg-subtle transition-[border-color,outline-color] duration-300 hover:border-fg-subtle outline-2 outline-transparent outline-offset-2 focus:border-accent focus-visible:outline-accent/70 disabled:( opacity-50 cursor-not-allowed) "
239216 :placeholder =" $t('package.deprecation.modal.reason_placeholder')"
240217 :aria-describedby ="
241218 deprecateMessage.length >= DEPRECATE_MESSAGE_MAX_LENGTH
@@ -252,15 +229,20 @@ defineExpose({ open, close })
252229 </p >
253230 </div >
254231 <div >
255- <label for =" deprecate-version" class =" block text-sm font-medium text-fg mb-1" >
232+ <label
233+ for =" deprecate-version"
234+ class =" block text-xs text-fg-subtle uppercase tracking-wider mb-1.5"
235+ >
256236 {{ $t('package.deprecation.modal.version') }}
257237 </label >
258- <input
238+ <InputBase
259239 id =" deprecate-version"
260240 v-model =" deprecateVersion"
261241 type =" text"
242+ name =" deprecate-version"
262243 :disabled =" isSelectedVersionDeprecated"
263- class =" w-full px-3 py-2 font-mono text-sm bg-bg border border-border rounded-md text-fg placeholder:text-fg-muted focus:outline-none focus:ring-2 focus:ring-fg/50 disabled:opacity-60 disabled:cursor-not-allowed"
244+ class =" w-full"
245+ size =" medium"
264246 :placeholder =" $t('package.deprecation.modal.version_placeholder')"
265247 />
266248 </div >
0 commit comments