Package Info

Display dependency information and version changes.

The PackageInfo component displays package dependency information including version changes and change type badges.

Install using CLI

AI Elements Vue
shadcn-vue CLI
npx ai-elements-vue@latest add package-info

Install Manually

Copy and paste the following files into the same folder.

PackageInfo.vue
PackageInfoHeader.vue
PackageInfoName.vue
PackageInfoChangeType.vue
PackageInfoVersion.vue
PackageInfoDescription.vue
PackageInfoContent.vue
PackageInfoDependencies.vue
PackageInfoDependency.vue
context.ts
index.ts
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import type { ChangeType } from './context'
import { cn } from '@repo/shadcn-vue/lib/utils'
import { provide } from 'vue'
import { PackageInfoKey } from './context'
import PackageInfoChangeType from './PackageInfoChangeType.vue'
import PackageInfoHeader from './PackageInfoHeader.vue'
import PackageInfoName from './PackageInfoName.vue'
import PackageInfoVersion from './PackageInfoVersion.vue'

interface Props extends /* @vue-ignore */ HTMLAttributes {
  name: string
  currentVersion?: string
  newVersion?: string
  changeType?: ChangeType
  class?: HTMLAttributes['class']
}

const props = defineProps<Props>()

provide(PackageInfoKey, {
  name: props.name,
  currentVersion: props.currentVersion,
  newVersion: props.newVersion,
  changeType: props.changeType,
})
</script>

<template>
  <div
    :class="cn('rounded-lg border bg-background p-4', props.class)"
    v-bind="$attrs"
  >
    <slot>
      <PackageInfoHeader>
        <PackageInfoName />
        <PackageInfoChangeType v-if="changeType" />
      </PackageInfoHeader>
      <PackageInfoVersion v-if="currentVersion || newVersion" />
    </slot>
  </div>
</template>

Features

  • Version change display (current → new)
  • Color-coded change type badges
  • Dependencies list
  • Description support

Change Types

TypeColorUse Case
majorRedBreaking changes
minorYellowNew features
patchGreenBug fixes
addedBlueNew dependency
removedGrayRemoved dependency

Props

<PackageInfo />

namerequiredstring
Package name.
currentVersionstring
Current installed version.
newVersionstring
New version being installed.
changeType"major" | "minor" | "patch" | "added" | "removed"
Type of version change.
...propsHTMLAttributes
Spread to the container div.

<PackageInfoHeader />

...propsHTMLAttributes
Spread to the header div.

<PackageInfoName />

defaultSlot
Custom name content. Defaults to the name from context.
...propsHTMLAttributes
Spread to the container div.

<PackageInfoChangeType />

defaultSlot
Custom change type label. Defaults to the changeType from context.
...propsBadgeProps
Spread to the Badge component.

<PackageInfoVersion />

defaultSlot
Custom version content. Defaults to version transition display.
...propsHTMLAttributes
Spread to the container div.

<PackageInfoDescription />

...propsHTMLAttributes
Spread to the p element.

<PackageInfoContent />

...propsHTMLAttributes
Spread to the container div.

<PackageInfoDependencies />

...propsHTMLAttributes
Spread to the container div.

<PackageInfoDependency />

namerequiredstring
Dependency name.
versionstring
Dependency version.
...propsHTMLAttributes
Spread to the row div.