refactor(webui): migrate remaining shadcn components to perfect-design

Move AuthGate, ConfigWarningsBanner, ToastViewport, SnippetBlock,
PageLoadError, LabeledSelect and the helper forms to perfect-design
Button, Input, Card, Callout, NativeSelect and ToastItem. Number fields
use a small native input because the library input rewrites typed text.

Delete components/ui, the unused ModelChip, CompactNumber, AliasBadge and
lib/utils, and the shadcn config. Remove shadcn-vue, tw-animate-css,
class-variance-authority and clsx. Give FaIcon an optional title and drop
role from decorative icons. Refresh stale comments and the README.
This commit is contained in:
2026-11-25 11:52:38 +00:00
parent e1f1a60d4d
commit 6bc144cc12
49 changed files with 224 additions and 5584 deletions
-7
View File
@@ -1,7 +0,0 @@
<script setup lang="ts">
import { Badge } from '@/components/ui/badge'
</script>
<template>
<Badge as="span" variant="outline" class="shrink-0 px-1.5 py-0 text-[10px] font-medium uppercase tracking-wide" title="Model alias defined in the gateway config">alias</Badge>
</template>
+3 -10
View File
@@ -1,11 +1,8 @@
<script setup lang="ts">
import { faCheck, faEye, faEyeSlash, faKey } from '@fortawesome/free-solid-svg-icons'
import { Button, Callout, Card, CardContent, CardDescription, CardHeader, CardTitle, Input } from '@perfect-design/ui'
import { computed, nextTick, onMounted, ref, watch } from 'vue'
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Input } from '@/components/ui/input'
import { useAuthStore } from '@/stores/auth'
import { useDashboardStore } from '@/stores/dashboard'
@@ -119,10 +116,7 @@ watch(() => auth.error, (err) => {
Continue
</Button>
</form>
<Alert v-if="auth.error" id="authgate-error" variant="destructive">
<AlertTitle>Authentication failed</AlertTitle>
<AlertDescription>{{ auth.error }}</AlertDescription>
</Alert>
<Callout v-if="auth.error" id="authgate-error" type="danger" role="alert" title="Authentication failed">{{ auth.error }}</Callout>
</CardContent>
</Card>
</div>
@@ -134,8 +128,7 @@ watch(() => auth.error, (err) => {
* needs one yet (grep confirms) but nothing in the Vite/@vitejs/plugin-vue
* pipeline forbids it, and the alternative (Tailwind-only) has no shake
* keyframe to compose from: Tailwind v4 core ships only pulse/bounce/spin/
* ping (node_modules/tailwindcss/theme.css), and tw-animate-css adds
* accordion/collapsible/enter/exit/caret-blink, none of which reads as
* ping (node_modules/tailwindcss/theme.css), none of which reads as
* "rejected". Contained to this file per the task's file-scope constraint.
*
* Applied only while auth.error is set (a failed submit), not on every
-40
View File
@@ -1,40 +0,0 @@
<script setup lang="ts">
import { computed } from 'vue'
import { formatCompactCount, formatExactInt } from '@/lib/format'
/**
* CompactNumber renders a large raw token/request count in its compact
* SI-style form ("1.23M") while carrying the exact value via `title`
* (mouse hover) and a visually-hidden sibling span (keyboard/screen-
* reader parity). Used anywhere a usage count renders: DataTable numeric
* columns (usage-columns.ts, target-columns.ts, via
* `h(CompactNumber, { value })`), the Consumers page's Total row, and a
* group accordion's trigger/detail stat grid (ConsumerDirectory.vue).
*
* Review fix (folded minor, ARIA): `aria-label` on a plain `<span>` is
* an axe `aria-prohibited-attr` violation — a `<span>`'s implicit ARIA
* role ("generic") does not support name computation at all, so
* `aria-label`/`aria-labelledby` there is simply invalid, not merely
* discouraged. The visible, compact text is marked `aria-hidden="true"`
* so assistive tech skips the abbreviated form, and a `sr-only` sibling
* span (visually hidden, still in the accessibility tree) carries the
* exact value instead — the same visible-abbreviation-plus-hidden-full-
* text pattern ProviderRateBadge.vue now applies too.
*
* Cost figures are NOT this component's concern — formatCost already
* shows full 4-decimal precision, so there is nothing to compact or
* disambiguate with a title there; only token/request COUNTS use this.
*/
const props = defineProps<{ value: number }>()
const compact = computed(() => formatCompactCount(props.value))
const exact = computed(() => formatExactInt(props.value))
</script>
<template>
<span :title="exact">
<span aria-hidden="true">{{ compact }}</span>
<span class="sr-only">{{ exact }}</span>
</span>
</template>
+16 -25
View File
@@ -1,10 +1,7 @@
<script setup lang="ts">
import { faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
import { Button, Callout } from '@perfect-design/ui'
import { ref } from 'vue'
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
import { Button } from '@/components/ui/button'
/**
* ConfigWarningsBanner surfaces GET /admin/api/overview's `warnings`/
* `warningsDropped` (F10, dashboard-plan.md — promoted warnf calls
@@ -30,19 +27,19 @@ function toggleExpanded(): void {
</script>
<template>
<Alert v-if="props.warnings.length > 0" variant="warn">
<FontAwesomeIcon :icon="faTriangleExclamation" class="size-4" aria-hidden="true" />
<AlertTitle class="flex items-center justify-between gap-2">
<span>{{ props.warnings.length }} configuration {{ props.warnings.length === 1 ? 'warning' : 'warnings' }}</span>
<!--
P11 review fix (WCAG 2.5.3 Label in Name): the aria-label used to
be the fixed text "Toggle configuration warning details", which
shares NO words with the visible "Show"/"Hide" label a sighted
reader sees — a speech-input user saying "click show" would not
match this control's accessible name at all. The aria-label now
STARTS WITH the same word the button visibly displays, so the
accessible name always contains the visible label.
-->
<Callout
v-if="props.warnings.length > 0"
type="warning"
:title="`${props.warnings.length} configuration ${props.warnings.length === 1 ? 'warning' : 'warnings'}`"
>
<template v-if="expanded">
<ul class="mt-1 list-disc space-y-0.5 pl-4 font-mono text-xs">
<li v-for="(warning, i) in props.warnings" :key="i">{{ warning }}</li>
</ul>
<p v-if="props.warningsDropped" class="mt-1 text-xs">and {{ props.warningsDropped }} more were not kept</p>
</template>
<template #actions>
<!-- The aria-label starts with the visible word (WCAG 2.5.3 Label in Name). -->
<Button
type="button"
variant="ghost"
@@ -53,12 +50,6 @@ function toggleExpanded(): void {
>
{{ expanded ? 'Hide' : 'Show' }}
</Button>
</AlertTitle>
<AlertDescription v-if="expanded">
<ul class="mt-1 list-disc space-y-0.5 pl-4 font-mono text-xs">
<li v-for="(warning, i) in props.warnings" :key="i">{{ warning }}</li>
</ul>
<p v-if="props.warningsDropped" class="mt-1 text-xs">and {{ props.warningsDropped }} more were not kept</p>
</AlertDescription>
</Alert>
</template>
</Callout>
</template>
+8 -3
View File
@@ -2,7 +2,11 @@
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
import { computed } from 'vue'
const props = defineProps<{ icon: IconDefinition }>()
const props = defineProps<{
icon: IconDefinition
/** Accessible name; leave unset for a decorative icon. */
title?: string
}>()
const view = computed(() => {
const [width, height, , , path] = props.icon.icon
@@ -15,11 +19,12 @@ const view = computed(() => {
:class="['svg-inline--fa', `fa-${icon.iconName}`]"
:data-prefix="icon.prefix"
:data-icon="icon.iconName"
role="img"
aria-hidden="true"
:role="title ? 'img' : undefined"
:aria-hidden="title ? undefined : 'true'"
focusable="false"
:viewBox="view.box"
>
<title v-if="title">{{ title }}</title>
<path fill="currentColor" :d="view.path" />
</svg>
</template>
+15 -34
View File
@@ -1,26 +1,16 @@
<script setup lang="ts">
import { NativeSelect } from '@perfect-design/ui'
import { computed, useId } from 'vue'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
export interface LabeledSelectOption {
value: string
label: string
}
/**
* LabeledSelect (reuse-audit.md F11) is the ONE "label above a Select,
* wired via aria-labelledby" block this panel used to hand-roll at every
* filter/target picker (GlobalFilterBar's Range, CostAvoidedCard's
* reference model, SpendPage's Metric, ReliabilityPage's Provider,
* UserForm's Primary group). `allLabel`, when set, injects an "All X"
* option and maps it to/from `modelValue === ''` internally — Radix/
* reka-ui Select items cannot hold an empty-string value themselves
* (EventsView.vue's/ReliabilityPage.vue's own identical ALL_KINDS/
* ALL_PROVIDERS_OPTION doc comments), so every "All" filter used to
* re-implement this same sentinel swap at its own template boundary.
* Omit `allLabel` for a plain required-selection picker with no "All"
* concept (UserForm's Primary group, CostAvoidedCard's reference model).
* LabeledSelect is the one "label above a native select" block the panel's pickers share.
* `allLabel`, when set, adds an "All X" option whose value is '' (modelValue === '');
* omit it for a required-selection picker with no "All" concept.
*/
const props = withDefaults(
defineProps<{
@@ -36,30 +26,21 @@ const props = withDefaults(
const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
/** ALL_SENTINEL is LabeledSelect's own internal Select-only stand-in for modelValue === '' — never exposed to a caller, which only ever sees '' itself via v-model. */
const ALL_SENTINEL = '__all__'
const selectId = `labeled-select-${useId()}`
const labelId = `labeled-select-${useId()}`
const selectValue = computed(() => (props.modelValue === '' && props.allLabel !== undefined ? ALL_SENTINEL : props.modelValue))
function onUpdate(value: unknown): void {
if (typeof value !== 'string') return
emit('update:modelValue', value === ALL_SENTINEL ? '' : value)
}
const allOptions = computed(() => (props.allLabel === undefined ? props.options : [{ value: '', label: props.allLabel }, ...props.options]))
</script>
<template>
<div class="flex flex-col gap-1">
<label :id="labelId" class="text-xs font-medium text-muted-foreground">{{ label }}</label>
<Select :model-value="selectValue" @update:model-value="onUpdate">
<SelectTrigger :aria-labelledby="labelId" :class="triggerClass">
<SelectValue :placeholder="placeholder" />
</SelectTrigger>
<SelectContent>
<SelectItem v-if="allLabel !== undefined" :value="ALL_SENTINEL">{{ allLabel }}</SelectItem>
<SelectItem v-for="opt in options" :key="opt.value" :value="opt.value">{{ opt.label }}</SelectItem>
</SelectContent>
</Select>
<label :for="selectId" class="text-xs font-medium text-muted-foreground">{{ label }}</label>
<NativeSelect
:id="selectId"
:model-value="modelValue"
:options="allOptions"
:placeholder="allLabel === undefined ? placeholder : undefined"
:class="triggerClass"
@update:model-value="emit('update:modelValue', $event)"
/>
</div>
</template>
-134
View File
@@ -1,134 +0,0 @@
<script setup lang="ts">
import { faCheck, faCopy, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
import { computed, useTemplateRef } from 'vue'
import AliasBadge from '@/components/AliasBadge.vue'
import { Badge } from '@/components/ui/badge'
import { useAliasNames } from '@/composables/useAliasNames'
import { useCopyFeedback } from '@/composables/useCopyFeedback'
import { copyText } from '@/lib/clipboard'
import { formatContextWindow, formatModelCostHover } from '@/lib/format'
import { useToastsStore } from '@/stores/toasts'
/**
* ModelChip is one clickable, copyable model-id chip, used anywhere a
* resolvable model or alias id renders: a provider's expanded model list
* and the model-alias table (both ProviderHealthPanel.vue's accordion),
* the Models page's own catalog table (lib/model-table-columns.ts, WITH
* metadata props — see contextTokens/inputPerMTokUsd/outputPerMTokUsd
* below), and a group's own allowed-models list (ConsumerDirectory.vue —
* passed with no metadata props there for a raw glob entry, since it has
* no resolvable provider/model pair to look metadata up against). id is
* the full routable id (lib/format.ts's routableModelId) or an alias
* name — what actually gets copied, so a pasted value works straight
* into a `model: "..."` request field.
*
* contextTokens/inputPerMTokUsd/outputPerMTokUsd are this model's
* resolved metadata (feature v0.23, hover-detail refinement:
* admin.go's adminModelMetaView / adminAliasView.ModelMeta) — all
* optional and independently omittable, exactly mirroring
* AdminModelMetaView's own "undefined means unknown" convention. When
* known, they render as an appended hover-detail phrase (metaDetail
* below) on top of whichever copy-state message title already carries;
* when nothing is known at all, the hover is unchanged from before this
* feature existed. A caller resolving an ALIAS's chip passes the
* alias's own INHERITED metadata (its target's resolved values, unless
* the alias itself has a modelMeta override) — the same values GET
* /v1/models and the admin API already resolve that way.
*
* The label span (labelRef below) is copyText's select-text fallback
* target — not a rare edge case here: navigator.clipboard is undefined
* outright on any plain-HTTP admin deployment (the Clipboard API
* requires a secure context — https, or localhost), so the fallback is
* the ONLY path a click ever takes there, not a backstop for an unlikely
* failure. labelRef is a template ref on an element this component
* always renders (below), so it is populated by the time onClick can
* ever run — a click handler cannot fire before mount.
*/
const props = defineProps<{
id: string
contextTokens?: number
inputPerMTokUsd?: number
outputPerMTokUsd?: number
}>()
const { isAlias } = useAliasNames()
const labelRef = useTemplateRef<HTMLElement>('label')
const { state, set: setCopyFeedback } = useCopyFeedback()
const toasts = useToastsStore()
async function onClick(): Promise<void> {
const result = await copyText(props.id, labelRef.value ?? undefined)
// 'failed' (neither the Clipboard API nor the selection fallback
// worked) gets its own visible state rather than a silent no-op — a
// click that visibly does nothing reads as a broken button, not as
// "nothing to report". Only a FAILURE also gets a toast (states-plan.md
// item 3) — 'copied'/'selected' already have clear, accessible inline
// feedback right at the click target (the icon swap plus this same
// title/aria-label text), so a success toast on top would double-notify
// for something the reader is already looking straight at.
setCopyFeedback(result)
if (result === 'failed') toasts.push({ kind: 'error', message: `Could not copy ${props.id}.` })
}
const icon = {
idle: faCopy,
copied: faCheck,
selected: faCheck,
failed: faTriangleExclamation,
}
const baseTitle = computed<Record<typeof state.value, string>>(() => ({
idle: `Copy ${props.id}`,
copied: 'Copied',
selected: 'Selected — press Ctrl/Cmd+C',
failed: 'Copy failed',
}))
/**
* metaDetail is the resolved-metadata hover phrase (feature v0.23):
* cost first ("in $0.19 / out $0.51 per MTok", or "free"), then context
* ("256k context"), joined with " · " — either half is independently
* omitted when its props are undefined, and the whole phrase is empty
* (never appended to title below) when nothing at all is known, per
* this feature's "fully-unknown models get no metadata hover" rule.
*/
const metaDetail = computed(() => {
const parts: string[] = []
if (props.inputPerMTokUsd !== undefined && props.outputPerMTokUsd !== undefined) {
parts.push(formatModelCostHover(props.inputPerMTokUsd, props.outputPerMTokUsd))
}
if (props.contextTokens !== undefined) {
parts.push(`${formatContextWindow(props.contextTokens)} context`)
}
return parts.join(' · ')
})
/**
* title carries BOTH the copy-state message (unchanged behavior) and,
* when known, the resolved-metadata detail appended after " · " — bound
* to both the mouse-only `title` attribute and `aria-label` (same
* mouse-vs-keyboard/screen-reader parity fix ProviderRateBadge.vue's
* own `detail` computed already applies).
*/
const title = computed(() => {
const base = baseTitle.value[state.value]
return metaDetail.value ? `${base} · ${metaDetail.value}` : base
})
</script>
<template>
<Badge
as="button"
type="button"
variant="secondary"
class="max-w-full cursor-pointer gap-1 truncate font-mono text-xs font-normal transition-colors hover:bg-accent hover:text-accent-foreground"
:class="state === 'failed' ? 'text-destructive' : ''"
:title="title"
:aria-label="title"
@click="onClick"
>
<span ref="label" class="min-w-0 truncate select-text">{{ id }}</span>
<AliasBadge v-if="isAlias(id)" />
<FontAwesomeIcon :icon="icon[state]" class="size-2.5 shrink-0" aria-hidden="true" />
</Badge>
</template>
+16
View File
@@ -0,0 +1,16 @@
<script setup lang="ts">
import { inputVariants } from '@perfect-design/ui'
// pd's Input emits a Number for type="number", which rewrites what the user typed ("0.50" -> "0.5"); the helper forms validate the raw string, so this keeps a native number input.
defineProps<{ modelValue: string }>()
const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
const classes = inputVariants()
function onInput(event: Event): void {
emit('update:modelValue', (event.target as HTMLInputElement).value)
}
</script>
<template>
<input type="number" :value="modelValue" :class="classes" @input="onInput" />
</template>
+1 -1
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { faArrowRotateRight, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
import { Button } from '@/components/ui/button'
import { Button } from '@perfect-design/ui'
function reload(): void {
window.location.reload()
+1 -1
View File
@@ -1,8 +1,8 @@
<script setup lang="ts">
import { faCheck, faCopy, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
import { Button } from '@perfect-design/ui'
import { useTemplateRef } from 'vue'
import { Button } from '@/components/ui/button'
import { useCopyFeedback } from '@/composables/useCopyFeedback'
import { copyText } from '@/lib/clipboard'
import { useToastsStore } from '@/stores/toasts'
+21 -47
View File
@@ -1,9 +1,7 @@
<script setup lang="ts">
import { faCheck, faCircleInfo, faTriangleExclamation, faXmark } from '@fortawesome/free-solid-svg-icons'
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
import { ToastItem } from '@perfect-design/ui'
import { computed } from 'vue'
import { Button } from '@/components/ui/button'
import type { Toast, ToastKind } from '@/stores/toasts'
import { useToastsStore } from '@/stores/toasts'
@@ -32,16 +30,10 @@ import { useToastsStore } from '@/stores/toasts'
*/
const toasts = useToastsStore()
const ICON: Record<ToastKind, IconDefinition> = {
success: faCheck,
error: faTriangleExclamation,
info: faCircleInfo,
}
const ICON_CLASS: Record<ToastKind, string> = {
success: 'text-chart-requests',
error: 'text-destructive',
info: 'text-muted-foreground',
const VARIANT: Record<ToastKind, 'success' | 'danger' | 'info'> = {
success: 'success',
error: 'danger',
info: 'info',
}
/** politeToasts/assertiveToasts split the store's single ordered list by kind — success/info are politely announced, error assertively, matching each region's own aria-live level. */
@@ -66,23 +58,14 @@ function onDismiss(toast: Toast): void {
leave-active-class="transition duration-150 ease-in motion-reduce:transition-none"
leave-to-class="opacity-0"
>
<div
v-for="toast in assertiveToasts"
:key="toast.id"
class="pointer-events-auto flex items-start gap-2 rounded-lg border bg-popover px-3 py-2.5 text-popover-foreground shadow-lg"
>
<FontAwesomeIcon :icon="ICON[toast.kind]" class="mt-0.5 size-3.5 shrink-0" :class="ICON_CLASS[toast.kind]" aria-hidden="true" />
<p class="min-w-0 flex-1 text-sm">{{ toast.message }}</p>
<Button
type="button"
variant="ghost"
size="icon"
class="-mt-1 -mr-1 size-6 shrink-0 text-muted-foreground hover:text-foreground"
:aria-label="`Dismiss: ${toast.message}`"
@click="onDismiss(toast)"
>
<FontAwesomeIcon :icon="faXmark" class="size-3" aria-hidden="true" />
</Button>
<div v-for="toast in assertiveToasts" :key="toast.id" class="pointer-events-auto">
<ToastItem
:title="toast.message"
:variant="VARIANT[toast.kind]"
:announce="false"
:dismiss-label="`Dismiss: ${toast.message}`"
@dismiss="onDismiss(toast)"
/>
</div>
</TransitionGroup>
</div>
@@ -95,23 +78,14 @@ function onDismiss(toast: Toast): void {
leave-active-class="transition duration-150 ease-in motion-reduce:transition-none"
leave-to-class="opacity-0"
>
<div
v-for="toast in politeToasts"
:key="toast.id"
class="pointer-events-auto flex items-start gap-2 rounded-lg border bg-popover px-3 py-2.5 text-popover-foreground shadow-lg"
>
<FontAwesomeIcon :icon="ICON[toast.kind]" class="mt-0.5 size-3.5 shrink-0" :class="ICON_CLASS[toast.kind]" aria-hidden="true" />
<p class="min-w-0 flex-1 text-sm">{{ toast.message }}</p>
<Button
type="button"
variant="ghost"
size="icon"
class="-mt-1 -mr-1 size-6 shrink-0 text-muted-foreground hover:text-foreground"
:aria-label="`Dismiss: ${toast.message}`"
@click="onDismiss(toast)"
>
<FontAwesomeIcon :icon="faXmark" class="size-3" aria-hidden="true" />
</Button>
<div v-for="toast in politeToasts" :key="toast.id" class="pointer-events-auto">
<ToastItem
:title="toast.message"
:variant="VARIANT[toast.kind]"
:announce="false"
:dismiss-label="`Dismiss: ${toast.message}`"
@dismiss="onDismiss(toast)"
/>
</div>
</TransitionGroup>
</div>
+3 -6
View File
@@ -1,10 +1,9 @@
<script setup lang="ts">
import { Callout, Input } from '@perfect-design/ui'
import { computed, ref } from 'vue'
import TargetPicker from '@/components/forms/TargetPicker.vue'
import SnippetBlock from '@/components/SnippetBlock.vue'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Input } from '@/components/ui/input'
import { useTargetPicker } from '@/composables/useTargetPicker'
import { groupGrantSnippet, parseList, userGrantJsonFragment, validatePersonalGrant } from '@/lib/snippets'
@@ -16,7 +15,7 @@ import { groupGrantSnippet, parseList, userGrantJsonFragment, validatePersonalGr
* as a bare JSON fragment for an existing users.json entry.
*
* Every list field is a comma-separated text Input rather than a proper
* multi-select (no such shadcn-vue primitive is installed in this panel) —
* multi-select (a multi-select is not worth the weight here) —
* parsed, trimmed, and de-duplicated below.
*/
const props = defineProps<{
@@ -103,9 +102,7 @@ const snippet = computed<string | null>(() => {
</template>
</div>
<Alert v-if="grantError" id="grant-error" variant="destructive">
<AlertDescription>{{ grantError }}</AlertDescription>
</Alert>
<Callout v-if="grantError" id="grant-error" type="danger" role="alert" size="sm">{{ grantError }}</Callout>
<SnippetBlock v-if="snippet" :label="snippetLabel" :text="snippet" />
<p v-else class="text-sm text-muted-foreground">Pick a target and at least one list to build a snippet.</p>
+5 -8
View File
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { Callout } from '@perfect-design/ui'
import { computed, reactive, ref } from 'vue'
import TargetPicker from '@/components/forms/TargetPicker.vue'
import NumberField from '@/components/NumberField.vue'
import SnippetBlock from '@/components/SnippetBlock.vue'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Input } from '@/components/ui/input'
import { useTargetPicker } from '@/composables/useTargetPicker'
import { groupLimitsSnippet, groupMemberLimitsSnippet, isValidNonNegative, isValidNonNegativeInt, userLimitsJsonFragment } from '@/lib/snippets'
import type { LimitKey, LimitsConfig } from '@/types/api'
@@ -120,10 +120,9 @@ const snippet = computed<string | null>(() => {
<div class="grid grid-cols-1 gap-3 sm:grid-cols-3">
<div v-for="field in FIELDS" :key="field.key" class="flex flex-col gap-1">
<label :for="`limits-${field.key}`" class="text-xs font-medium text-muted-foreground">{{ field.label }}</label>
<Input
<NumberField
:id="`limits-${field.key}`"
v-model="raw[field.key]"
type="number"
min="0"
:step="INTEGER_FIELDS.has(field.key) ? '1' : 'any'"
placeholder="unset"
@@ -133,12 +132,10 @@ const snippet = computed<string | null>(() => {
</div>
</div>
<Alert v-if="invalidFields.length" id="limits-errors" variant="destructive">
<AlertDescription>
<Callout v-if="invalidFields.length" id="limits-errors" type="danger" role="alert" size="sm">
<p v-if="invalidIntegerFields.length">Enter a non-negative whole number for: {{ invalidIntegerFields.join(', ') }}.</p>
<p v-if="invalidDecimalFields.length">Enter a non-negative number for: {{ invalidDecimalFields.join(', ') }}.</p>
</AlertDescription>
</Alert>
</Callout>
<SnippetBlock v-if="snippet" :label="snippetLabel" :text="snippet" />
<p v-else class="text-sm text-muted-foreground">Pick a target and at least one limit to build a snippet.</p>
+4 -7
View File
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { Callout, Input } from '@perfect-design/ui'
import { computed, ref } from 'vue'
import NumberField from '@/components/NumberField.vue'
import SnippetBlock from '@/components/SnippetBlock.vue'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Input } from '@/components/ui/input'
import { isValidNonNegativeInt, modelMetaSnippet } from '@/lib/snippets'
/**
@@ -48,10 +48,9 @@ const snippet = computed<string | null>(() => {
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:items-end">
<div class="flex flex-col gap-1">
<label for="modelmeta-context" class="text-xs font-medium text-muted-foreground">Context window (tokens)</label>
<Input
<NumberField
id="modelmeta-context"
v-model="contextRaw"
type="number"
min="1"
step="1"
placeholder="131072"
@@ -65,9 +64,7 @@ const snippet = computed<string | null>(() => {
</label>
</div>
<Alert v-if="contextEntered && !contextValid" id="modelmeta-context-error" variant="destructive">
<AlertDescription>Context window must be a positive whole number of tokens.</AlertDescription>
</Alert>
<Callout v-if="contextEntered && !contextValid" id="modelmeta-context-error" type="danger" role="alert" size="sm">Context window must be a positive whole number of tokens.</Callout>
<SnippetBlock v-if="snippet" label="Paste into middleware.yaml" :text="snippet" />
<p v-else class="text-sm text-muted-foreground">Enter a model id and set a context window and/or free to build a snippet.</p>
+6 -10
View File
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { Callout, Input } from '@perfect-design/ui'
import { computed, ref } from 'vue'
import NumberField from '@/components/NumberField.vue'
import SnippetBlock from '@/components/SnippetBlock.vue'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Input } from '@/components/ui/input'
import { isValidNonNegative, pricingSnippet } from '@/lib/snippets'
/**
@@ -56,10 +56,9 @@ const snippet = computed<string | null>(() => {
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
<div class="flex flex-col gap-1">
<label for="pricing-input" class="text-xs font-medium text-muted-foreground">Input price / MTok (USD)</label>
<Input
<NumberField
id="pricing-input"
v-model="inputRaw"
type="number"
min="0"
step="any"
placeholder="0.50"
@@ -69,10 +68,9 @@ const snippet = computed<string | null>(() => {
</div>
<div class="flex flex-col gap-1">
<label for="pricing-output" class="text-xs font-medium text-muted-foreground">Output price / MTok (USD)</label>
<Input
<NumberField
id="pricing-output"
v-model="outputRaw"
type="number"
min="0"
step="any"
placeholder="1.50"
@@ -82,11 +80,9 @@ const snippet = computed<string | null>(() => {
</div>
</div>
<Alert v-if="errors.length" id="pricing-errors" variant="destructive">
<AlertDescription>
<Callout v-if="errors.length" id="pricing-errors" type="danger" role="alert" size="sm">
<p v-for="(error, index) in errors" :key="index">{{ error }}</p>
</AlertDescription>
</Alert>
</Callout>
<SnippetBlock v-if="snippet" label="Paste into middleware.yaml" :text="snippet" />
<p v-else class="text-sm text-muted-foreground">Enter a model id and both prices to build a snippet.</p>
+6 -8
View File
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { Callout, Input } from '@perfect-design/ui'
import { computed, ref } from 'vue'
import NumberField from '@/components/NumberField.vue'
import SnippetBlock from '@/components/SnippetBlock.vue'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Input } from '@/components/ui/input'
import { isValidName, parseList, routerSnippet, validateRouter } from '@/lib/snippets'
import type { RouterInput } from '@/lib/snippets'
@@ -75,7 +75,7 @@ const snippet = computed<string | null>(() => {
</div>
<div class="flex flex-col gap-1">
<label :for="`router-tier-score-${index}`" class="text-xs font-medium text-muted-foreground">Min score (0-1000)</label>
<Input :id="`router-tier-score-${index}`" v-model="row.minScore" type="number" min="0" max="1000" step="1" />
<NumberField :id="`router-tier-score-${index}`" v-model="row.minScore" min="0" max="1000" step="1" />
</div>
<div class="flex flex-col gap-1">
<label :for="`router-tier-models-${index}`" class="text-xs font-medium text-muted-foreground">Models (comma-separated)</label>
@@ -104,7 +104,7 @@ const snippet = computed<string | null>(() => {
</div>
<div class="flex flex-col gap-1">
<label for="router-max-attempts" class="text-xs font-medium text-muted-foreground">Max attempts (blank = 4)</label>
<Input id="router-max-attempts" v-model="maxAttemptsRaw" type="number" min="0" step="1" placeholder="4" />
<NumberField id="router-max-attempts" v-model="maxAttemptsRaw" min="0" step="1" placeholder="4" />
</div>
<div class="flex items-center gap-2">
<input id="router-context-escalation" v-model="contextEscalation" type="checkbox" class="size-4 rounded border-input" />
@@ -112,11 +112,9 @@ const snippet = computed<string | null>(() => {
</div>
</div>
<Alert v-if="errors.length" id="router-errors" variant="destructive">
<AlertDescription>
<Callout v-if="errors.length" id="router-errors" type="danger" role="alert" size="sm">
<p v-for="(error, index) in errors" :key="index">{{ error }}</p>
</AlertDescription>
</Alert>
</Callout>
<SnippetBlock v-if="snippet" label="Paste into middleware.yaml" :text="snippet" />
<p v-else class="text-sm text-muted-foreground">Enter a router name and at least one tier with models to build a snippet.</p>
+14 -19
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useId } from 'vue'
import { NativeSelect } from '@perfect-design/ui'
import { computed, useId } from 'vue'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
import type { GrantTargetKind } from '@/composables/useTargetPicker'
/**
@@ -26,8 +26,14 @@ const emit = defineEmits<{
'update:targetName': [value: string]
}>()
const kindLabelId = `target-picker-kind-${useId()}`
const nameLabelId = `target-picker-name-${useId()}`
const kindId = `target-picker-kind-${useId()}`
const nameId = `target-picker-name-${useId()}`
const kindOptions = computed(() => [
{ value: 'group', label: 'Group' },
{ value: 'user', label: props.userOptionLabel },
])
const nameOptions = computed(() => props.targetNames.map((name) => ({ value: name, label: name })))
function onKindUpdate(value: unknown): void {
if (value === 'group' || value === 'user') emit('update:targetKind', value)
@@ -40,23 +46,12 @@ function onNameUpdate(value: unknown): void {
<template>
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
<div class="flex flex-col gap-1">
<label :id="kindLabelId" class="text-xs font-medium text-muted-foreground">Target</label>
<Select :model-value="targetKind" @update:model-value="onKindUpdate">
<SelectTrigger :aria-labelledby="kindLabelId"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="group">Group</SelectItem>
<SelectItem value="user">{{ props.userOptionLabel }}</SelectItem>
</SelectContent>
</Select>
<label :for="kindId" class="text-xs font-medium text-muted-foreground">Target</label>
<NativeSelect :id="kindId" :model-value="targetKind" :options="kindOptions" @update:model-value="onKindUpdate" />
</div>
<div class="flex flex-col gap-1">
<label :id="nameLabelId" class="text-xs font-medium text-muted-foreground">{{ targetKind === 'group' ? 'Group name' : 'User name' }}</label>
<Select :model-value="targetName" @update:model-value="onNameUpdate">
<SelectTrigger :aria-labelledby="nameLabelId"><SelectValue placeholder="Select…" /></SelectTrigger>
<SelectContent>
<SelectItem v-for="name in targetNames" :key="name" :value="name">{{ name }}</SelectItem>
</SelectContent>
</Select>
<label :for="nameId" class="text-xs font-medium text-muted-foreground">{{ targetKind === 'group' ? 'Group name' : 'User name' }}</label>
<NativeSelect :id="nameId" :model-value="targetName" :options="nameOptions" placeholder="Select…" @update:model-value="onNameUpdate" />
<p v-if="targetNames.length === 0" class="text-xs text-muted-foreground">No {{ targetKind === 'group' ? 'groups' : 'users' }} loaded yet.</p>
</div>
</div>
+2 -6
View File
@@ -1,11 +1,9 @@
<script setup lang="ts">
import { Button, Callout, Input } from '@perfect-design/ui'
import { computed, ref } from 'vue'
import LabeledSelect from '@/components/LabeledSelect.vue'
import SnippetBlock from '@/components/SnippetBlock.vue'
import { Alert, AlertDescription } from '@/components/ui/alert'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { API_KEY_PLACEHOLDER, generateApiKey, isValidUserName, parseList, userJsonLine, validatePersonalGrant } from '@/lib/snippets'
import { useToastsStore } from '@/stores/toasts'
@@ -123,9 +121,7 @@ const snippet = computed<string | null>(() => {
Admin (full access to /admin/api/*)
</label>
<Alert v-if="grantError" variant="destructive">
<AlertDescription>{{ grantError }}</AlertDescription>
</Alert>
<Callout v-if="grantError" type="danger" role="alert" size="sm">{{ grantError }}</Callout>
<SnippetBlock v-if="snippet" label="Add as a new line in users.json" :text="snippet" />
<p v-else class="text-sm text-muted-foreground">Fill in a name, group, and a real (generated) API key to build a snippet.</p>
-21
View File
@@ -1,21 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import type { AlertVariants } from '.'
import { cn } from '@/lib/utils'
import { alertVariants } from '.'
const props = defineProps<{
class?: HTMLAttributes['class']
variant?: AlertVariants['variant']
}>()
</script>
<template>
<div
data-slot="alert"
:class="cn(alertVariants({ variant }), props.class)"
role="alert"
>
<slot />
</div>
</template>
@@ -1,17 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>
<template>
<div
data-slot="alert-description"
:class="cn('text-muted-foreground text-sm text-balance md:text-pretty [&_p:not(:last-child)]:mb-4 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground', props.class)"
>
<slot />
</div>
</template>
@@ -1,17 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>
<template>
<div
data-slot="alert-title"
:class="cn('font-medium group-has-[>svg]/alert:col-start-2 font-heading [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground', props.class)"
>
<slot />
</div>
</template>
-29
View File
@@ -1,29 +0,0 @@
import type { VariantProps } from 'class-variance-authority'
import { cva } from 'class-variance-authority'
export { default as Alert } from './Alert.vue'
export { default as AlertDescription } from './AlertDescription.vue'
export { default as AlertTitle } from './AlertTitle.vue'
export const alertVariants = cva('grid gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*=size-])]:size-4 group/alert relative w-full', {
variants: {
variant: {
default: 'bg-card text-card-foreground',
destructive: 'text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current',
/**
* warn: a non-destructive "worth a look, not broken" tier —
* reuses the panel's shared --status-warn token (main.css,
* already the Providers tab's degraded badge and the usage-bar
* amber threshold) instead of `destructive`'s red, which implies
* a hard failure. Same structure as `destructive` above, only the
* color changes.
*/
warn: 'text-status-warn bg-card *:data-[slot=alert-description]:text-status-warn/90 *:[svg]:text-current',
},
},
defaultVariants: {
variant: 'default',
},
})
export type AlertVariants = VariantProps<typeof alertVariants>
-27
View File
@@ -1,27 +0,0 @@
<script setup lang="ts">
import type { PrimitiveProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import type { BadgeVariants } from '.'
import { reactiveOmit } from '@vueuse/core'
import { Primitive } from 'reka-ui'
import { cn } from '@/lib/utils'
import { badgeVariants } from '.'
const props = defineProps<PrimitiveProps & {
variant?: BadgeVariants['variant']
class?: HTMLAttributes['class']
}>()
const delegatedProps = reactiveOmit(props, 'class')
</script>
<template>
<Primitive
data-slot="badge"
:data-variant="variant"
:class="cn(badgeVariants({ variant }), props.class)"
v-bind="delegatedProps"
>
<slot />
</Primitive>
</template>
-24
View File
@@ -1,24 +0,0 @@
import type { VariantProps } from 'class-variance-authority'
import { cva } from 'class-variance-authority'
export { default as Badge } from './Badge.vue'
export const badgeVariants = cva(
'h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none',
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
secondary: 'bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80',
destructive: 'bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20',
outline: 'border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground',
ghost: 'hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50',
link: 'text-primary underline-offset-4 hover:underline',
},
},
defaultVariants: {
variant: 'default',
},
},
)
export type BadgeVariants = VariantProps<typeof badgeVariants>
-31
View File
@@ -1,31 +0,0 @@
<script setup lang="ts">
import type { PrimitiveProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import type { ButtonVariants } from '.'
import { Primitive } from 'reka-ui'
import { cn } from '@/lib/utils'
import { buttonVariants } from '.'
interface Props extends PrimitiveProps {
variant?: ButtonVariants['variant']
size?: ButtonVariants['size']
class?: HTMLAttributes['class']
}
const props = withDefaults(defineProps<Props>(), {
as: 'button',
})
</script>
<template>
<Primitive
data-slot="button"
:data-variant="variant"
:data-size="size"
:as="as"
:as-child="asChild"
:class="cn(buttonVariants({ variant, size }), props.class)"
>
<slot />
</Primitive>
</template>
-35
View File
@@ -1,35 +0,0 @@
import type { VariantProps } from 'class-variance-authority'
import { cva } from 'class-variance-authority'
export { default as Button } from './Button.vue'
export const buttonVariants = cva(
'focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-3 aria-invalid:ring-3 active:not-aria-[haspopup]:translate-y-px [&_svg:not([class*=size-])]:size-4 group/button inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-all outline-none select-none disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
outline: 'border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',
ghost: 'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',
destructive: 'bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
'default': 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
'xs': 'h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*=size-])]:size-3',
'sm': 'h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*=size-])]:size-3.5',
'lg': 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
'icon': 'size-8',
'icon-xs': 'size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*=size-])]:size-3',
'icon-sm': 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
'icon-lg': 'size-9',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
},
)
export type ButtonVariants = VariantProps<typeof buttonVariants>
-21
View File
@@ -1,21 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = withDefaults(defineProps<{
class?: HTMLAttributes['class']
size?: 'default' | 'sm'
}>(), {
size: 'default',
})
</script>
<template>
<div
data-slot="card"
:data-size="size"
:class="cn('ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-xl py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col', props.class)"
>
<slot />
</div>
</template>
@@ -1,17 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>
<template>
<div
data-slot="card-content"
:class="cn('px-4 group-data-[size=sm]/card:px-3', props.class)"
>
<slot />
</div>
</template>
@@ -1,17 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>
<template>
<div
data-slot="card-description"
:class="cn('text-muted-foreground text-sm', props.class)"
>
<slot />
</div>
</template>
@@ -1,17 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>
<template>
<div
data-slot="card-header"
:class="cn('gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]', props.class)"
>
<slot />
</div>
</template>
@@ -1,17 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>
<template>
<div
data-slot="card-title"
:class="cn('text-base leading-snug font-medium group-data-[size=sm]/card:text-sm font-heading', props.class)"
>
<slot />
</div>
</template>
-5
View File
@@ -1,5 +0,0 @@
export { default as Card } from './Card.vue'
export { default as CardContent } from './CardContent.vue'
export { default as CardDescription } from './CardDescription.vue'
export { default as CardHeader } from './CardHeader.vue'
export { default as CardTitle } from './CardTitle.vue'
-31
View File
@@ -1,31 +0,0 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { useVModel } from '@vueuse/core'
import { cn } from '@/lib/utils'
const props = defineProps<{
defaultValue?: string | number
modelValue?: string | number
class?: HTMLAttributes['class']
}>()
const emits = defineEmits<{
(e: 'update:modelValue', payload: string | number): void
}>()
const modelValue = useVModel(props, 'modelValue', emits, {
passive: true,
defaultValue: props.defaultValue,
})
</script>
<template>
<input
v-model="modelValue"
data-slot="input"
:class="cn(
'dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 md:text-sm w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
props.class,
)"
>
</template>
-1
View File
@@ -1 +0,0 @@
export { default as Input } from './Input.vue'
-19
View File
@@ -1,19 +0,0 @@
<script setup lang="ts">
import type { SelectRootEmits, SelectRootProps } from 'reka-ui'
import { SelectRoot, useForwardPropsEmits } from 'reka-ui'
const props = defineProps<SelectRootProps>()
const emits = defineEmits<SelectRootEmits>()
const forwarded = useForwardPropsEmits(props, emits)
</script>
<template>
<SelectRoot
v-slot="slotProps"
data-slot="select"
v-bind="forwarded"
>
<slot v-bind="slotProps" />
</SelectRoot>
</template>
@@ -1,58 +0,0 @@
<script setup lang="ts">
import type { SelectContentEmits, SelectContentProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import { reactiveOmit } from '@vueuse/core'
import {
SelectContent,
SelectPortal,
SelectViewport,
useForwardPropsEmits,
} from 'reka-ui'
import { cn } from '@/lib/utils'
import { SelectScrollDownButton, SelectScrollUpButton } from '.'
defineOptions({
inheritAttrs: false,
})
const props = withDefaults(
defineProps<SelectContentProps & { class?: HTMLAttributes['class'] }>(),
{
position: 'item-aligned',
align: 'center',
},
)
const emits = defineEmits<SelectContentEmits>()
const delegatedProps = reactiveOmit(props, 'class')
const forwarded = useForwardPropsEmits(delegatedProps, emits)
</script>
<template>
<SelectPortal>
<SelectContent
data-slot="select-content"
:data-align-trigger="position === 'item-aligned'"
v-bind="{ ...$attrs, ...forwarded }"
:class="cn(
'bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 min-w-36 rounded-lg shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 cn-menu-translucent relative z-50 max-h-(--reka-select-content-available-height) origin-(--reka-select-content-transform-origin) overflow-x-hidden overflow-y-auto data-[align-trigger=true]:animate-none',
position === 'popper'
&& 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
props.class,
)
"
>
<SelectScrollUpButton />
<SelectViewport
:data-position="position"
:class="cn(
'data-[position=popper]:h-(--reka-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--reka-select-trigger-width)',
)"
>
<slot />
</SelectViewport>
<SelectScrollDownButton />
</SelectContent>
</SelectPortal>
</template>
@@ -1,46 +0,0 @@
<script setup lang="ts">
import type { SelectItemProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import { faCheck } from '@fortawesome/free-solid-svg-icons'
import FontAwesomeIcon from '@/components/FaIcon.vue'
import { reactiveOmit } from '@vueuse/core'
import {
SelectItem,
SelectItemIndicator,
SelectItemText,
useForwardProps,
} from 'reka-ui'
import { cn } from '@/lib/utils'
const props = defineProps<SelectItemProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = reactiveOmit(props, 'class')
const forwardedProps = useForwardProps(delegatedProps)
</script>
<template>
<SelectItem
data-slot="select-item"
v-bind="forwardedProps"
:class="
cn(
'focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm [&_svg:not([class*=size-])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
props.class,
)
"
>
<span class="pointer-events-none absolute right-2 flex size-4 items-center justify-center">
<SelectItemIndicator>
<slot name="indicator-icon">
<FontAwesomeIcon :icon="faCheck" class="pointer-events-none size-3.5" />
</slot>
</SelectItemIndicator>
</span>
<SelectItemText>
<slot />
</SelectItemText>
</SelectItem>
</template>
@@ -1,28 +0,0 @@
<script setup lang="ts">
import type { SelectScrollDownButtonProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'
import FontAwesomeIcon from '@/components/FaIcon.vue'
import { reactiveOmit } from '@vueuse/core'
import { SelectScrollDownButton, useForwardProps } from 'reka-ui'
import { cn } from '@/lib/utils'
const props = defineProps<SelectScrollDownButtonProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = reactiveOmit(props, 'class')
const forwardedProps = useForwardProps(delegatedProps)
</script>
<template>
<SelectScrollDownButton
data-slot="select-scroll-down-button"
v-bind="forwardedProps"
:class="cn('bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*=size-])]:size-4', props.class)"
>
<slot>
<FontAwesomeIcon :icon="faChevronDown" class="size-4" />
</slot>
</SelectScrollDownButton>
</template>
@@ -1,28 +0,0 @@
<script setup lang="ts">
import type { SelectScrollUpButtonProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import { faChevronUp } from '@fortawesome/free-solid-svg-icons'
import FontAwesomeIcon from '@/components/FaIcon.vue'
import { reactiveOmit } from '@vueuse/core'
import { SelectScrollUpButton, useForwardProps } from 'reka-ui'
import { cn } from '@/lib/utils'
const props = defineProps<SelectScrollUpButtonProps & { class?: HTMLAttributes['class'] }>()
const delegatedProps = reactiveOmit(props, 'class')
const forwardedProps = useForwardProps(delegatedProps)
</script>
<template>
<SelectScrollUpButton
data-slot="select-scroll-up-button"
v-bind="forwardedProps"
:class="cn('bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*=size-])]:size-4', props.class)"
>
<slot>
<FontAwesomeIcon :icon="faChevronUp" class="size-4" />
</slot>
</SelectScrollUpButton>
</template>
@@ -1,35 +0,0 @@
<script setup lang="ts">
import type { SelectTriggerProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'
import FontAwesomeIcon from '@/components/FaIcon.vue'
import { reactiveOmit } from '@vueuse/core'
import { SelectIcon, SelectTrigger, useForwardProps } from 'reka-ui'
import { cn } from '@/lib/utils'
const props = withDefaults(
defineProps<SelectTriggerProps & { class?: HTMLAttributes['class'], size?: 'sm' | 'default' }>(),
{ size: 'default' },
)
const delegatedProps = reactiveOmit(props, 'class', 'size')
const forwardedProps = useForwardProps(delegatedProps)
</script>
<template>
<SelectTrigger
data-slot="select-trigger"
:data-size="size"
v-bind="forwardedProps"
:class="cn(
'border-input data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-lg border bg-transparent py-2 pr-2 pl-2.5 text-sm transition-colors select-none focus-visible:ring-3 aria-invalid:ring-3 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*=size-])]:size-4 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0',
props.class,
)"
>
<slot />
<SelectIcon as-child>
<FontAwesomeIcon :icon="faChevronDown" class="text-muted-foreground size-4 pointer-events-none" />
</SelectIcon>
</SelectTrigger>
</template>
@@ -1,15 +0,0 @@
<script setup lang="ts">
import type { SelectValueProps } from 'reka-ui'
import { SelectValue } from 'reka-ui'
const props = defineProps<SelectValueProps>()
</script>
<template>
<SelectValue
data-slot="select-value"
v-bind="props"
>
<slot />
</SelectValue>
</template>
-7
View File
@@ -1,7 +0,0 @@
export { default as Select } from './Select.vue'
export { default as SelectContent } from './SelectContent.vue'
export { default as SelectItem } from './SelectItem.vue'
export { default as SelectScrollDownButton } from './SelectScrollDownButton.vue'
export { default as SelectScrollUpButton } from './SelectScrollUpButton.vue'
export { default as SelectTrigger } from './SelectTrigger.vue'
export { default as SelectValue } from './SelectValue.vue'