ProtoItemPanel Variants

Specialized panel components for extending a collection item's detail view — text template generation, time-series snapshots, and URL input.

ProtoItemPanel Variants

The ProtoItemPanel* family provides specialized UI panels you can embed inside a collection item's detail or modal view. Each panel receives the current item as a prop and emits an update event containing only the fields that changed, which you pass directly to a useProtoList update call.

All three panels share the same visual chrome: a top border, a muted background, and consistent padding. They are designed to slot below ProtoForm sections inside a ProtoCrudModal or any custom item layout.

ProtoItemPanelTextTemplate

ProtoItemPanelTextTemplate generates text content from template functions and presents each section in an editable textarea. It is well-suited for AI-style prompt scaffolding, copy generation, and structured document exports.

Features

  • Renders one textarea per section, sized to content (2–8 rows, auto-resizing)
  • Each section shows an optional character counter that turns red when the limit is exceeded
  • A copy button writes the current content to the clipboard
  • The Regenerate button resets all local edits back to the template output
  • An optional global tip and per-section tips provide contextual guidance

Props

PropTypeDescription
panelDefTextTemplatePanelDefPanel configuration including sections and optional tip
itemRecord<string, any>The current collection item
collectionsRecord<string, any[]>Collection arrays passed as context to template functions

TextTemplatePanelDef

interface TextTemplatePanelDef {
  type: 'text-template'
  id: string
  label: string
  icon?: string
  sections: Array<{
    id: string
    label: string
    template: (item: Record<string, any>, ctx: { collections: Record<string, any[]> }) => string
    tip?: string      // shown as italic helper text above the textarea
    hint?: string     // shown as muted text below the textarea
    charLimit?: number
  }>
  tip?: string | ((item: Record<string, any>, ctx: { collections: Record<string, any[]> }) => string | undefined)
  showWhen?: (item: Record<string, any>) => boolean
}

Example

<ProtoItemPanelTextTemplate
  :panel-def="{
    type: 'text-template',
    id: 'copy-gen',
    label: 'Copy Generator',
    icon: 'i-lucide-file-pen',
    tip: 'These drafts are generated from your item data. Edit freely before copying.',
    sections: [
      {
        id: 'headline',
        label: 'Headline',
        charLimit: 80,
        hint: 'Keep it under 80 characters for best display.',
        template: (item) => `${item.name} — ${item.tagline}`,
      },
      {
        id: 'summary',
        label: 'Summary',
        template: (item, ctx) => {
          const related = ctx.collections.features?.filter(f => f.itemId === item._id) ?? []
          return related.map(f => `• ${f.title}`).join('\n')
        },
      },
    ],
  }"
  :item="currentItem"
  :collections="collections"
/>

ProtoItemPanelTimeSeries

ProtoItemPanelTimeSeries lets you record dated metric snapshots for a collection item. It is useful for tracking progress over time — keyword rankings, revenue figures, follower counts, or any numeric KPI that changes week to week.

Features

  • A date picker (defaults to today) and one numeric input per metric
  • Save Snapshot writes the values to both the item's top-level fields and to the history array
  • If a snapshot for the selected date already exists, it is replaced in place
  • The history table shows the last seven snapshots, sorted newest first
  • Individual metrics can be hidden with a showWhen predicate

Props

PropTypeDescription
panelDefTimeSeriesPanelDefPanel configuration with metric definitions and the history key
itemRecord<string, any>The current collection item
collectionsRecord<string, any[]>Passed for API consistency; not used internally

Emits

EventPayloadDescription
updatePartial<Record<string, any>>Patch containing the updated metric fields and the new history array

TimeSeriesPanelDef

interface TimeSeriesPanelDef {
  type: 'time-series'
  id: string
  label: string
  icon?: string
  historyKey: string               // field on the item that holds the snapshots array
  metrics: Array<{
    key: string                    // field key on the item
    label: string
    showWhen?: (item: Record<string, any>) => boolean
  }>
  showWhen?: (item: Record<string, any>) => boolean
}

Example

<ProtoItemPanelTimeSeries
  :panel-def="{
    type: 'time-series',
    id: 'rank-history',
    label: 'Rank History',
    icon: 'i-lucide-chart-line',
    historyKey: 'rankHistory',
    metrics: [
      { key: 'rank',        label: 'Rank' },
      { key: 'impressions', label: 'Impressions' },
      { key: 'clicks',      label: 'Clicks' },
      {
        key: 'ctr',
        label: 'CTR %',
        showWhen: (item) => item.trackCtr === true,
      },
    ],
  }"
  :item="currentItem"
  :collections="collections"
  @update="(patch) => updateItem(currentItem._id, patch)"
/>

The history array stores objects of the form { date: 'YYYY-MM-DD', rank: 12, impressions: 4300, ... }. You can reference rankHistory in derived or visualizations to render a trend line.


ProtoItemPanelUrlInput

ProtoItemPanelUrlInput presents a single URL field with a Save button and save-on-Enter support. It is suited for attaching external links to a collection item — a Figma file, a Notion doc, a staging URL, or any other resource.

Features

  • Initializes from item[panelDef.field] and syncs when the item changes
  • Saves on Enter keypress or button click
  • An optional onConfirm function lets you transform the URL into a richer patch before emitting (for example, to also update a display label or parse a domain)

Props

PropTypeDescription
panelDefUrlInputPanelDefPanel configuration — field name, placeholder, and optional transform
itemRecord<string, any>The current collection item

Emits

EventPayloadDescription
updatePartial<Record<string, any>>Patch produced by onConfirm or { [field]: url }

UrlInputPanelDef

interface UrlInputPanelDef {
  type: 'url-input'
  id: string
  label: string
  icon?: string
  field: string
  placeholder?: string
  onConfirm?: (url: string, item: Record<string, any>) => Partial<Record<string, any>>
  showWhen?: (item: Record<string, any>) => boolean
}

Example

<ProtoItemPanelUrlInput
  :panel-def="{
    type: 'url-input',
    id: 'figma-url',
    label: 'Figma File',
    icon: 'i-lucide-link',
    field: 'figmaUrl',
    placeholder: 'Paste Figma file URL…',
    onConfirm: (url, item) => ({
      figmaUrl: url,
      figmaDomain: new URL(url).hostname,
    }),
  }"
  :item="currentItem"
  @update="(patch) => updateItem(currentItem._id, patch)"
/>

Wiring panels into a detail view

Item panels work best in a master–detail layout: a clickable list on the left and a detail column on the right. The detail column stacks the panels below any summary header for the selected item.

<script setup lang="ts">
const { items, update } = useProtoCollection(schema)

const selectedIndex = ref<number | null>(null)
const selectedItem = computed(() =>
  selectedIndex.value !== null ? items.value[selectedIndex.value] ?? null : null
)

function handlePanelUpdate(patch: Partial<Record<string, any>>) {
  if (selectedIndex.value === null) return
  update(selectedIndex.value, { ...selectedItem.value, ...patch })
}
</script>

<template>
  <div class="flex h-full">
    <!-- List column -->
    <div class="w-72 border-r overflow-y-auto">
      <button
        v-for="(item, index) in items"
        :key="index"
        class="w-full text-left px-4 py-3 border-b hover:bg-muted/40"
        :class="{ 'bg-primary/5': selectedIndex === index }"
        @click="selectedIndex = index"
      >
        {{ item.title }}
      </button>
    </div>

    <!-- Detail column -->
    <div
      v-if="selectedItem"
      class="flex-1 overflow-y-auto divide-y divide-default"
    >
      <ProtoItemPanelUrlInput
        :panel-def="urlPanel"
        :item="selectedItem"
        @update="handlePanelUpdate"
      />
      <ProtoItemPanelTimeSeries
        :panel-def="metricsPanel"
        :item="selectedItem"
        :collections="{}"
        @update="handlePanelUpdate"
      />
      <ProtoItemPanelTextTemplate
        :panel-def="templatePanel"
        :item="selectedItem"
        :collections="{}"
      />
    </div>
  </div>
</template>

The handlePanelUpdate function merges the incoming patch with the current item and forwards it to useProtoCollection's update. Each panel only emits the fields it owns, so updates from different panels do not overwrite each other.

Need a Landing Page?

Modern landing pages with optional modules (blog, docs, forms, i18n). Let's discuss your project.

Build Your MVP

Full-stack SaaS development. Expert in database design, multi-tenancy, and scalable architecture.

Deployment Help

Dockerize your backend, set up CI/CD pipelines, deploy to Cloudflare or Hetzner. Early-stage setup.

Suggest a SaaS Tool

Missing a calculator or tool? Suggest what you'd like to see on our site.