mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
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:
+11
-78
@@ -1,7 +1,7 @@
|
|||||||
# Admin panel (webui)
|
# Admin panel (webui)
|
||||||
|
|
||||||
Source for the traefik-llmgateway read-only admin dashboard: Vue 3 +
|
Source for the traefik-llmgateway read-only admin dashboard: Vue 3 +
|
||||||
TypeScript + Pinia + Tailwind v4 + shadcn-vue + Chart.js, built with Vite.
|
TypeScript + Pinia + Tailwind v4 + `@perfect-design/ui`, built with Vite.
|
||||||
|
|
||||||
See the repo root [README.md's Admin section](../README.md#admin) for what
|
See the repo root [README.md's Admin section](../README.md#admin) for what
|
||||||
the dashboard shows and how its API/auth works, and the
|
the dashboard shows and how its API/auth works, and the
|
||||||
@@ -10,50 +10,6 @@ only way this directory's output (`../admin_assets_gen.go`) is meant to be
|
|||||||
regenerated. Nothing here runs at request time: the plugin serves the
|
regenerated. Nothing here runs at request time: the plugin serves the
|
||||||
built, baked-in output, never `webui/` itself.
|
built, baked-in output, never `webui/` itself.
|
||||||
|
|
||||||
## Warning: `shadcn-vue add`/`init` regressions
|
|
||||||
|
|
||||||
`components.json` has no `iconLibrary` or `font` key. **Do not add them
|
|
||||||
back.** Their omission is the fix, not an oversight — read on before you
|
|
||||||
"helpfully" restore either one.
|
|
||||||
|
|
||||||
Earlier revisions of this file set `"iconLibrary": "lucide"` and
|
|
||||||
`"font": "inter"`, both wrong for this project (FontAwesome only, per
|
|
||||||
the `vue-web-development` house skill; no external font at all). Both
|
|
||||||
`npx shadcn-vue init` and `npx shadcn-vue add <component>` read those two
|
|
||||||
fields and, when set, rewrite `src/assets/main.css` — hit twice in this
|
|
||||||
project's own history, `init` then a later `add`, both re-adding a
|
|
||||||
`@import url('https://fonts.googleapis.com/...')` line and switching the
|
|
||||||
dark-mode `@custom-variant` back to a `.dark`-class toggle.
|
|
||||||
|
|
||||||
The actual shadcn-vue config schema
|
|
||||||
(`node_modules/shadcn-vue/dist/schema/index.js`'s `rawConfigSchema`)
|
|
||||||
declares both fields as `z.string().optional()` — not an enum, contrary
|
|
||||||
to an earlier, incorrect claim in this project's own review notes that
|
|
||||||
the CLI schema forced one of five fixed values. The CLI's `init --font`/
|
|
||||||
`--icon-library` flags do offer five fixed choices each, but that is a
|
|
||||||
flag-parsing constraint, not a `components.json` schema constraint.
|
|
||||||
Deleting both keys leaves them `undefined` after parse, a valid state:
|
|
||||||
verified empirically, running `npx shadcn-vue add badge -o -y` against a
|
|
||||||
`components.json` with both keys removed left `src/assets/main.css`
|
|
||||||
byte-for-byte unchanged.
|
|
||||||
|
|
||||||
That verification also surfaced a narrower, remaining trap: the same run
|
|
||||||
still added `@lucide/vue` back to `package.json`'s dependencies (Badge
|
|
||||||
itself does not use it — some components' registry entries list an icon
|
|
||||||
package regardless of `iconLibrary`). So after any future `shadcn-vue
|
|
||||||
add`/`init` call:
|
|
||||||
|
|
||||||
1. **Check `git diff webui/package.json`** for a re-added
|
|
||||||
`lucide-vue-next`/`@lucide/vue` dependency, and remove it
|
|
||||||
(`npm uninstall`) if nothing in `src/` imports from it.
|
|
||||||
2. **Check the new component's own file** for a
|
|
||||||
`lucide-vue-next`/`@lucide/vue` import and swap it for the
|
|
||||||
FontAwesome equivalent (see `src/components/ui/select/Select*.vue`
|
|
||||||
for the pattern already applied there).
|
|
||||||
3. **Diff `src/assets/main.css` anyway** before committing, in case a
|
|
||||||
future shadcn-vue release starts reading a different config key for
|
|
||||||
the same font-injection step.
|
|
||||||
|
|
||||||
## Local development
|
## Local development
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -67,39 +23,16 @@ npm run build # what `make admin-ui` runs, plus webui/generate.mjs
|
|||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
|
|
||||||
- `src/stores/` — Pinia: `auth` (the sessionStorage key gate), `dashboard`
|
- `src/pages/` and `src/panels/` — one page per nav entry and the detail panels they open.
|
||||||
(Providers/Usage, 5s poll), `history` (Charts, fetch-on-selection + 30s
|
- `src/widgets/`, `src/components/`, `src/layout/` — shared presentation built on `@perfect-design/ui`.
|
||||||
refresh).
|
- `src/stores/` — Pinia stores (auth, dashboard, toasts, ...).
|
||||||
- `src/components/` — `AuthGate`, `ProvidersView` (the "Providers" tab —
|
- `src/lib/` — pure helpers with specs; `api.ts` wraps `/admin/api/*`.
|
||||||
named for its UI label; it still fetches GET /admin/api/overview, whose
|
- `src/types/api.ts` — TypeScript mirrors of admin.go's JSON response shapes.
|
||||||
own name is unchanged API surface), `UsageView`,
|
- `mock/` — the dev-only mock admin API behind `npm run dev:mock`.
|
||||||
`ChartsView`/`UsageChart`, `UsageTable`, `DataTable` (the shared
|
- `scripts/bundle-size.mjs` — the bundle gate: gzip JS+CSS of `dist/assets` must stay at or below its `LIMIT`.
|
||||||
sortable-table wrapper — shadcn-vue's DataTable pattern, `@tanstack/
|
- `generate.mjs` — reads `dist/` after `vite build` and writes `../admin_assets_gen.go`; see its header comment for why every asset is base64-encoded.
|
||||||
vue-table`, generic over row type), `SearchInput` (the shared search-box
|
|
||||||
— icon + shadcn `Input` + shadcn `Button` clear button — every search
|
`src/assets/main.css` lists the `@perfect-design/ui` component directories Tailwind scans; add a directory there when you import a new component (`src/lib/tailwind-sources.spec.ts` fails otherwise).
|
||||||
filter in the panel renders); `ui/` holds the shadcn-vue primitives this
|
|
||||||
panel actually uses (Accordion, Card, Table, Tabs, Button, Input, Alert,
|
|
||||||
Select, Badge) — nothing installed and unused. Providers and Groups
|
|
||||||
(Usage) render as a real Accordion — expanding a group shows its
|
|
||||||
member users' own usage rows, a client-side join on
|
|
||||||
`AdminUsageEntryView.groupName`.
|
|
||||||
- `src/composables/` — `useThemeColors` (Chart.js axis/grid/legend colors
|
|
||||||
off the current design tokens), `useSearchQuery` (the shared
|
|
||||||
`query`/`normalized`/`hasQuery` state every `SearchInput` pairs with).
|
|
||||||
- `src/lib/` — `api.ts` (the `/admin/api/*` fetch wrapper), `format.ts`,
|
|
||||||
`key-storage.ts`, `chart-setup.ts`, `search-expand.ts` (search-aware
|
|
||||||
expand state, adapted to drive Accordion's v-model — shared by
|
|
||||||
ProvidersView's providers and UsageView's groups), `usage-search.ts`
|
|
||||||
(shared user/group query-matching helpers, used by UsageView and
|
|
||||||
ChartsView), `usage-columns.ts` (shared `ColumnDef`s for every usage
|
|
||||||
table).
|
|
||||||
- `src/types/api.ts` — TypeScript mirrors of admin.go's JSON response
|
|
||||||
shapes (`adminOverviewResponse`, `adminUsageResponse`,
|
|
||||||
`usageHistoryResponse`) — these keep their backend names; only the
|
|
||||||
frontend tab label/component changed (see `ProvidersView` above).
|
|
||||||
- `generate.mjs` — reads `dist/` after `vite build` and writes
|
|
||||||
`../admin_assets_gen.go`; see its own header comment for why every
|
|
||||||
asset is base64-encoded rather than embedded as a raw string literal.
|
|
||||||
|
|
||||||
## Visual harness
|
## Visual harness
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://shadcn-vue.com/schema.json",
|
|
||||||
"style": "reka-nova",
|
|
||||||
"typescript": true,
|
|
||||||
"tailwind": {
|
|
||||||
"config": "",
|
|
||||||
"css": "src/assets/main.css",
|
|
||||||
"baseColor": "neutral",
|
|
||||||
"cssVariables": true,
|
|
||||||
"prefix": ""
|
|
||||||
},
|
|
||||||
"rtl": false,
|
|
||||||
"pointer": false,
|
|
||||||
"aliases": {
|
|
||||||
"components": "@/components",
|
|
||||||
"utils": "@/lib/utils",
|
|
||||||
"ui": "@/components/ui",
|
|
||||||
"lib": "@/lib",
|
|
||||||
"composables": "@/composables"
|
|
||||||
},
|
|
||||||
"menuColor": "default",
|
|
||||||
"menuAccent": "subtle",
|
|
||||||
"registries": {}
|
|
||||||
}
|
|
||||||
Generated
+87
-4526
File diff suppressed because it is too large
Load Diff
@@ -16,13 +16,9 @@
|
|||||||
"@fortawesome/free-solid-svg-icons": "^7.3.1",
|
"@fortawesome/free-solid-svg-icons": "^7.3.1",
|
||||||
"@perfect-design/ui": "https://github.com/lukaszraczylo/perfect-design/releases/download/v0.4.0/perfect-design-ui-0.4.0.tgz",
|
"@perfect-design/ui": "https://github.com/lukaszraczylo/perfect-design/releases/download/v0.4.0/perfect-design-ui-0.4.0.tgz",
|
||||||
"@vueuse/core": "^14.4.0",
|
"@vueuse/core": "^14.4.0",
|
||||||
"class-variance-authority": "^0.7.1",
|
|
||||||
"clsx": "^2.1.1",
|
|
||||||
"pinia": "^4.0.3",
|
"pinia": "^4.0.3",
|
||||||
"reka-ui": "^2.10.3",
|
"reka-ui": "^2.10.3",
|
||||||
"shadcn-vue": "^2.8.2",
|
|
||||||
"tailwind-merge": "^3.6.0",
|
"tailwind-merge": "^3.6.0",
|
||||||
"tw-animate-css": "^1.4.0",
|
|
||||||
"vue": "^3.5.40"
|
"vue": "^3.5.40"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
@import "tw-animate-css";
|
|
||||||
@import "shadcn-vue/tailwind.css";
|
|
||||||
@import "@perfect-design/ui/theme.css";
|
@import "@perfect-design/ui/theme.css";
|
||||||
@import "@perfect-design/ui/packs.css";
|
@import "@perfect-design/ui/packs.css";
|
||||||
/* Tailwind scans only the perfect-design components this app bundles; scanning all of dist adds ~15 KB gzip of unused utilities. Add a component's directory here when a new one is imported. */
|
/* Tailwind scans only the perfect-design components this app bundles; scanning all of dist adds ~15 KB gzip of unused utilities. Add a component's directory here when a new one is imported. */
|
||||||
@@ -62,7 +60,7 @@
|
|||||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Spinner";
|
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Spinner";
|
||||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/StatusBadge";
|
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/StatusBadge";
|
||||||
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/StatusDot";
|
@source "../../node_modules/@perfect-design/ui/dist/components/primitives/StatusDot";
|
||||||
@source "../../node_modules/@perfect-design/ui/dist/components/typography/RelativeTime/**/*.js";
|
@source "../../node_modules/@perfect-design/ui/dist/components/typography/RelativeTime";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The base palette (background, primary, border, radius, ...) now comes from
|
* The base palette (background, primary, border, radius, ...) now comes from
|
||||||
@@ -70,10 +68,7 @@
|
|||||||
* Dark mode follows the `.dark` class that perfect-design's theme store (and its
|
* Dark mode follows the `.dark` class that perfect-design's theme store (and its
|
||||||
* boot script) maintains on <html>, including the "system" mode.
|
* boot script) maintains on <html>, including the "system" mode.
|
||||||
*
|
*
|
||||||
* Theme tokens (design note, not slop-by-default): shadcn-vue's `init`
|
* Local theme tokens, rewritten here rather than inherited:
|
||||||
* scaffolds an achromatic "stone" palette (chroma 0 everywhere), a Google
|
|
||||||
* Fonts Inter import, and a Geist Variable heading font. All three are
|
|
||||||
* rewritten below:
|
|
||||||
*
|
*
|
||||||
* - No Google Fonts import, no Geist. The admin CSP (admin.go) ships
|
* - No Google Fonts import, no Geist. The admin CSP (admin.go) ships
|
||||||
* style-src 'self' with no external host allowed, and the panel must load
|
* style-src 'self' with no external host allowed, and the panel must load
|
||||||
@@ -86,13 +81,8 @@
|
|||||||
* - Chart series use the Okabe & Ito (2008) colorblind-safe qualitative
|
* - Chart series use the Okabe & Ito (2008) colorblind-safe qualitative
|
||||||
* palette rather than picking hues by eye — distinguishable under
|
* palette rather than picking hues by eye — distinguishable under
|
||||||
* protanopia, deuteranopia, and tritanopia alike.
|
* protanopia, deuteranopia, and tritanopia alike.
|
||||||
* - Dark mode is driven by `prefers-color-scheme`, not a `.dark` class
|
* - Dark mode follows the `.dark` class (see above), so `dark:` utilities and the CSS
|
||||||
* toggle: this panel has no theme switcher, so the OS setting is the only
|
* variables below switch together.
|
||||||
* signal there is. Tailwind v4's default `dark:` variant already means
|
|
||||||
* "@media (prefers-color-scheme: dark)" — shadcn-vue's init overrides it
|
|
||||||
* to a `.dark`-class variant for apps with a manual theme toggle; that
|
|
||||||
* override is dropped here so any `dark:` utility (ours or a generated
|
|
||||||
* ui/ primitive's) follows the OS setting, same as the CSS variables below.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@theme inline {
|
@theme inline {
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { faCheck, faEye, faEyeSlash, faKey } from '@fortawesome/free-solid-svg-icons'
|
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 { 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 { useAuthStore } from '@/stores/auth'
|
||||||
import { useDashboardStore } from '@/stores/dashboard'
|
import { useDashboardStore } from '@/stores/dashboard'
|
||||||
|
|
||||||
@@ -119,10 +116,7 @@ watch(() => auth.error, (err) => {
|
|||||||
Continue
|
Continue
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
<Alert v-if="auth.error" id="authgate-error" variant="destructive">
|
<Callout v-if="auth.error" id="authgate-error" type="danger" role="alert" title="Authentication failed">{{ auth.error }}</Callout>
|
||||||
<AlertTitle>Authentication failed</AlertTitle>
|
|
||||||
<AlertDescription>{{ auth.error }}</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
@@ -134,8 +128,7 @@ watch(() => auth.error, (err) => {
|
|||||||
* needs one yet (grep confirms) but nothing in the Vite/@vitejs/plugin-vue
|
* needs one yet (grep confirms) but nothing in the Vite/@vitejs/plugin-vue
|
||||||
* pipeline forbids it, and the alternative (Tailwind-only) has no shake
|
* pipeline forbids it, and the alternative (Tailwind-only) has no shake
|
||||||
* keyframe to compose from: Tailwind v4 core ships only pulse/bounce/spin/
|
* keyframe to compose from: Tailwind v4 core ships only pulse/bounce/spin/
|
||||||
* ping (node_modules/tailwindcss/theme.css), and tw-animate-css adds
|
* ping (node_modules/tailwindcss/theme.css), none of which reads as
|
||||||
* accordion/collapsible/enter/exit/caret-blink, none of which reads as
|
|
||||||
* "rejected". Contained to this file per the task's file-scope constraint.
|
* "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
|
* Applied only while auth.error is set (a failed submit), not on every
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
|
import { Button, Callout } from '@perfect-design/ui'
|
||||||
import { ref } from 'vue'
|
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`/
|
* ConfigWarningsBanner surfaces GET /admin/api/overview's `warnings`/
|
||||||
* `warningsDropped` (F10, dashboard-plan.md — promoted warnf calls
|
* `warningsDropped` (F10, dashboard-plan.md — promoted warnf calls
|
||||||
@@ -30,19 +27,19 @@ function toggleExpanded(): void {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Alert v-if="props.warnings.length > 0" variant="warn">
|
<Callout
|
||||||
<FontAwesomeIcon :icon="faTriangleExclamation" class="size-4" aria-hidden="true" />
|
v-if="props.warnings.length > 0"
|
||||||
<AlertTitle class="flex items-center justify-between gap-2">
|
type="warning"
|
||||||
<span>{{ props.warnings.length }} configuration {{ props.warnings.length === 1 ? 'warning' : 'warnings' }}</span>
|
:title="`${props.warnings.length} configuration ${props.warnings.length === 1 ? 'warning' : 'warnings'}`"
|
||||||
<!--
|
>
|
||||||
P11 review fix (WCAG 2.5.3 Label in Name): the aria-label used to
|
<template v-if="expanded">
|
||||||
be the fixed text "Toggle configuration warning details", which
|
<ul class="mt-1 list-disc space-y-0.5 pl-4 font-mono text-xs">
|
||||||
shares NO words with the visible "Show"/"Hide" label a sighted
|
<li v-for="(warning, i) in props.warnings" :key="i">{{ warning }}</li>
|
||||||
reader sees — a speech-input user saying "click show" would not
|
</ul>
|
||||||
match this control's accessible name at all. The aria-label now
|
<p v-if="props.warningsDropped" class="mt-1 text-xs">and {{ props.warningsDropped }} more were not kept</p>
|
||||||
STARTS WITH the same word the button visibly displays, so the
|
</template>
|
||||||
accessible name always contains the visible label.
|
<template #actions>
|
||||||
-->
|
<!-- The aria-label starts with the visible word (WCAG 2.5.3 Label in Name). -->
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@@ -53,12 +50,6 @@ function toggleExpanded(): void {
|
|||||||
>
|
>
|
||||||
{{ expanded ? 'Hide' : 'Show' }}
|
{{ expanded ? 'Hide' : 'Show' }}
|
||||||
</Button>
|
</Button>
|
||||||
</AlertTitle>
|
</template>
|
||||||
<AlertDescription v-if="expanded">
|
</Callout>
|
||||||
<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>
|
</template>
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
|
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
|
||||||
import { computed } from 'vue'
|
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 view = computed(() => {
|
||||||
const [width, height, , , path] = props.icon.icon
|
const [width, height, , , path] = props.icon.icon
|
||||||
@@ -15,11 +19,12 @@ const view = computed(() => {
|
|||||||
:class="['svg-inline--fa', `fa-${icon.iconName}`]"
|
:class="['svg-inline--fa', `fa-${icon.iconName}`]"
|
||||||
:data-prefix="icon.prefix"
|
:data-prefix="icon.prefix"
|
||||||
:data-icon="icon.iconName"
|
:data-icon="icon.iconName"
|
||||||
role="img"
|
:role="title ? 'img' : undefined"
|
||||||
aria-hidden="true"
|
:aria-hidden="title ? undefined : 'true'"
|
||||||
focusable="false"
|
focusable="false"
|
||||||
:viewBox="view.box"
|
:viewBox="view.box"
|
||||||
>
|
>
|
||||||
|
<title v-if="title">{{ title }}</title>
|
||||||
<path fill="currentColor" :d="view.path" />
|
<path fill="currentColor" :d="view.path" />
|
||||||
</svg>
|
</svg>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,26 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { NativeSelect } from '@perfect-design/ui'
|
||||||
import { computed, useId } from 'vue'
|
import { computed, useId } from 'vue'
|
||||||
|
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
|
||||||
|
|
||||||
export interface LabeledSelectOption {
|
export interface LabeledSelectOption {
|
||||||
value: string
|
value: string
|
||||||
label: string
|
label: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LabeledSelect (reuse-audit.md F11) is the ONE "label above a Select,
|
* LabeledSelect is the one "label above a native select" block the panel's pickers share.
|
||||||
* wired via aria-labelledby" block this panel used to hand-roll at every
|
* `allLabel`, when set, adds an "All X" option whose value is '' (modelValue === '');
|
||||||
* filter/target picker (GlobalFilterBar's Range, CostAvoidedCard's
|
* omit it for a required-selection picker with no "All" concept.
|
||||||
* 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).
|
|
||||||
*/
|
*/
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -36,30 +26,21 @@ const props = withDefaults(
|
|||||||
|
|
||||||
const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
|
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 selectId = `labeled-select-${useId()}`
|
||||||
const ALL_SENTINEL = '__all__'
|
|
||||||
|
|
||||||
const labelId = `labeled-select-${useId()}`
|
const allOptions = computed(() => (props.allLabel === undefined ? props.options : [{ value: '', label: props.allLabel }, ...props.options]))
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<label :id="labelId" class="text-xs font-medium text-muted-foreground">{{ label }}</label>
|
<label :for="selectId" class="text-xs font-medium text-muted-foreground">{{ label }}</label>
|
||||||
<Select :model-value="selectValue" @update:model-value="onUpdate">
|
<NativeSelect
|
||||||
<SelectTrigger :aria-labelledby="labelId" :class="triggerClass">
|
:id="selectId"
|
||||||
<SelectValue :placeholder="placeholder" />
|
:model-value="modelValue"
|
||||||
</SelectTrigger>
|
:options="allOptions"
|
||||||
<SelectContent>
|
:placeholder="allLabel === undefined ? placeholder : undefined"
|
||||||
<SelectItem v-if="allLabel !== undefined" :value="ALL_SENTINEL">{{ allLabel }}</SelectItem>
|
:class="triggerClass"
|
||||||
<SelectItem v-for="opt in options" :key="opt.value" :value="opt.value">{{ opt.label }}</SelectItem>
|
@update:model-value="emit('update:modelValue', $event)"
|
||||||
</SelectContent>
|
/>
|
||||||
</Select>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -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,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { faArrowRotateRight, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
|
import { faArrowRotateRight, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@perfect-design/ui'
|
||||||
|
|
||||||
function reload(): void {
|
function reload(): void {
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { faCheck, faCopy, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
|
import { faCheck, faCopy, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { Button } from '@perfect-design/ui'
|
||||||
import { useTemplateRef } from 'vue'
|
import { useTemplateRef } from 'vue'
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button'
|
|
||||||
import { useCopyFeedback } from '@/composables/useCopyFeedback'
|
import { useCopyFeedback } from '@/composables/useCopyFeedback'
|
||||||
import { copyText } from '@/lib/clipboard'
|
import { copyText } from '@/lib/clipboard'
|
||||||
import { useToastsStore } from '@/stores/toasts'
|
import { useToastsStore } from '@/stores/toasts'
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { faCheck, faCircleInfo, faTriangleExclamation, faXmark } from '@fortawesome/free-solid-svg-icons'
|
import { ToastItem } from '@perfect-design/ui'
|
||||||
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons'
|
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button'
|
|
||||||
import type { Toast, ToastKind } from '@/stores/toasts'
|
import type { Toast, ToastKind } from '@/stores/toasts'
|
||||||
import { useToastsStore } from '@/stores/toasts'
|
import { useToastsStore } from '@/stores/toasts'
|
||||||
|
|
||||||
@@ -32,16 +30,10 @@ import { useToastsStore } from '@/stores/toasts'
|
|||||||
*/
|
*/
|
||||||
const toasts = useToastsStore()
|
const toasts = useToastsStore()
|
||||||
|
|
||||||
const ICON: Record<ToastKind, IconDefinition> = {
|
const VARIANT: Record<ToastKind, 'success' | 'danger' | 'info'> = {
|
||||||
success: faCheck,
|
success: 'success',
|
||||||
error: faTriangleExclamation,
|
error: 'danger',
|
||||||
info: faCircleInfo,
|
info: 'info',
|
||||||
}
|
|
||||||
|
|
||||||
const ICON_CLASS: Record<ToastKind, string> = {
|
|
||||||
success: 'text-chart-requests',
|
|
||||||
error: 'text-destructive',
|
|
||||||
info: 'text-muted-foreground',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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. */
|
/** 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-active-class="transition duration-150 ease-in motion-reduce:transition-none"
|
||||||
leave-to-class="opacity-0"
|
leave-to-class="opacity-0"
|
||||||
>
|
>
|
||||||
<div
|
<div v-for="toast in assertiveToasts" :key="toast.id" class="pointer-events-auto">
|
||||||
v-for="toast in assertiveToasts"
|
<ToastItem
|
||||||
:key="toast.id"
|
:title="toast.message"
|
||||||
class="pointer-events-auto flex items-start gap-2 rounded-lg border bg-popover px-3 py-2.5 text-popover-foreground shadow-lg"
|
:variant="VARIANT[toast.kind]"
|
||||||
>
|
:announce="false"
|
||||||
<FontAwesomeIcon :icon="ICON[toast.kind]" class="mt-0.5 size-3.5 shrink-0" :class="ICON_CLASS[toast.kind]" aria-hidden="true" />
|
:dismiss-label="`Dismiss: ${toast.message}`"
|
||||||
<p class="min-w-0 flex-1 text-sm">{{ toast.message }}</p>
|
@dismiss="onDismiss(toast)"
|
||||||
<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>
|
</div>
|
||||||
</TransitionGroup>
|
</TransitionGroup>
|
||||||
</div>
|
</div>
|
||||||
@@ -95,23 +78,14 @@ function onDismiss(toast: Toast): void {
|
|||||||
leave-active-class="transition duration-150 ease-in motion-reduce:transition-none"
|
leave-active-class="transition duration-150 ease-in motion-reduce:transition-none"
|
||||||
leave-to-class="opacity-0"
|
leave-to-class="opacity-0"
|
||||||
>
|
>
|
||||||
<div
|
<div v-for="toast in politeToasts" :key="toast.id" class="pointer-events-auto">
|
||||||
v-for="toast in politeToasts"
|
<ToastItem
|
||||||
:key="toast.id"
|
:title="toast.message"
|
||||||
class="pointer-events-auto flex items-start gap-2 rounded-lg border bg-popover px-3 py-2.5 text-popover-foreground shadow-lg"
|
:variant="VARIANT[toast.kind]"
|
||||||
>
|
:announce="false"
|
||||||
<FontAwesomeIcon :icon="ICON[toast.kind]" class="mt-0.5 size-3.5 shrink-0" :class="ICON_CLASS[toast.kind]" aria-hidden="true" />
|
:dismiss-label="`Dismiss: ${toast.message}`"
|
||||||
<p class="min-w-0 flex-1 text-sm">{{ toast.message }}</p>
|
@dismiss="onDismiss(toast)"
|
||||||
<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>
|
</div>
|
||||||
</TransitionGroup>
|
</TransitionGroup>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Callout, Input } from '@perfect-design/ui'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
import TargetPicker from '@/components/forms/TargetPicker.vue'
|
import TargetPicker from '@/components/forms/TargetPicker.vue'
|
||||||
import SnippetBlock from '@/components/SnippetBlock.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 { useTargetPicker } from '@/composables/useTargetPicker'
|
||||||
import { groupGrantSnippet, parseList, userGrantJsonFragment, validatePersonalGrant } from '@/lib/snippets'
|
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.
|
* as a bare JSON fragment for an existing users.json entry.
|
||||||
*
|
*
|
||||||
* Every list field is a comma-separated text Input rather than a proper
|
* 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.
|
* parsed, trimmed, and de-duplicated below.
|
||||||
*/
|
*/
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -103,9 +102,7 @@ const snippet = computed<string | null>(() => {
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Alert v-if="grantError" id="grant-error" variant="destructive">
|
<Callout v-if="grantError" id="grant-error" type="danger" role="alert" size="sm">{{ grantError }}</Callout>
|
||||||
<AlertDescription>{{ grantError }}</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<SnippetBlock v-if="snippet" :label="snippetLabel" :text="snippet" />
|
<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>
|
<p v-else class="text-sm text-muted-foreground">Pick a target and at least one list to build a snippet.</p>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Callout } from '@perfect-design/ui'
|
||||||
import { computed, reactive, ref } from 'vue'
|
import { computed, reactive, ref } from 'vue'
|
||||||
|
|
||||||
import TargetPicker from '@/components/forms/TargetPicker.vue'
|
import TargetPicker from '@/components/forms/TargetPicker.vue'
|
||||||
|
import NumberField from '@/components/NumberField.vue'
|
||||||
import SnippetBlock from '@/components/SnippetBlock.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 { useTargetPicker } from '@/composables/useTargetPicker'
|
||||||
import { groupLimitsSnippet, groupMemberLimitsSnippet, isValidNonNegative, isValidNonNegativeInt, userLimitsJsonFragment } from '@/lib/snippets'
|
import { groupLimitsSnippet, groupMemberLimitsSnippet, isValidNonNegative, isValidNonNegativeInt, userLimitsJsonFragment } from '@/lib/snippets'
|
||||||
import type { LimitKey, LimitsConfig } from '@/types/api'
|
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 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">
|
<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>
|
<label :for="`limits-${field.key}`" class="text-xs font-medium text-muted-foreground">{{ field.label }}</label>
|
||||||
<Input
|
<NumberField
|
||||||
:id="`limits-${field.key}`"
|
:id="`limits-${field.key}`"
|
||||||
v-model="raw[field.key]"
|
v-model="raw[field.key]"
|
||||||
type="number"
|
|
||||||
min="0"
|
min="0"
|
||||||
:step="INTEGER_FIELDS.has(field.key) ? '1' : 'any'"
|
:step="INTEGER_FIELDS.has(field.key) ? '1' : 'any'"
|
||||||
placeholder="unset"
|
placeholder="unset"
|
||||||
@@ -133,12 +132,10 @@ const snippet = computed<string | null>(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Alert v-if="invalidFields.length" id="limits-errors" variant="destructive">
|
<Callout v-if="invalidFields.length" id="limits-errors" type="danger" role="alert" size="sm">
|
||||||
<AlertDescription>
|
|
||||||
<p v-if="invalidIntegerFields.length">Enter a non-negative whole number for: {{ invalidIntegerFields.join(', ') }}.</p>
|
<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>
|
<p v-if="invalidDecimalFields.length">Enter a non-negative number for: {{ invalidDecimalFields.join(', ') }}.</p>
|
||||||
</AlertDescription>
|
</Callout>
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<SnippetBlock v-if="snippet" :label="snippetLabel" :text="snippet" />
|
<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>
|
<p v-else class="text-sm text-muted-foreground">Pick a target and at least one limit to build a snippet.</p>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Callout, Input } from '@perfect-design/ui'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
|
import NumberField from '@/components/NumberField.vue'
|
||||||
import SnippetBlock from '@/components/SnippetBlock.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'
|
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="grid grid-cols-1 gap-3 sm:grid-cols-2 sm:items-end">
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<label for="modelmeta-context" class="text-xs font-medium text-muted-foreground">Context window (tokens)</label>
|
<label for="modelmeta-context" class="text-xs font-medium text-muted-foreground">Context window (tokens)</label>
|
||||||
<Input
|
<NumberField
|
||||||
id="modelmeta-context"
|
id="modelmeta-context"
|
||||||
v-model="contextRaw"
|
v-model="contextRaw"
|
||||||
type="number"
|
|
||||||
min="1"
|
min="1"
|
||||||
step="1"
|
step="1"
|
||||||
placeholder="131072"
|
placeholder="131072"
|
||||||
@@ -65,9 +64,7 @@ const snippet = computed<string | null>(() => {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Alert v-if="contextEntered && !contextValid" id="modelmeta-context-error" variant="destructive">
|
<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>
|
||||||
<AlertDescription>Context window must be a positive whole number of tokens.</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<SnippetBlock v-if="snippet" label="Paste into middleware.yaml" :text="snippet" />
|
<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>
|
<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>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Callout, Input } from '@perfect-design/ui'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
|
import NumberField from '@/components/NumberField.vue'
|
||||||
import SnippetBlock from '@/components/SnippetBlock.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'
|
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="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<label for="pricing-input" class="text-xs font-medium text-muted-foreground">Input price / MTok (USD)</label>
|
<label for="pricing-input" class="text-xs font-medium text-muted-foreground">Input price / MTok (USD)</label>
|
||||||
<Input
|
<NumberField
|
||||||
id="pricing-input"
|
id="pricing-input"
|
||||||
v-model="inputRaw"
|
v-model="inputRaw"
|
||||||
type="number"
|
|
||||||
min="0"
|
min="0"
|
||||||
step="any"
|
step="any"
|
||||||
placeholder="0.50"
|
placeholder="0.50"
|
||||||
@@ -69,10 +68,9 @@ const snippet = computed<string | null>(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<label for="pricing-output" class="text-xs font-medium text-muted-foreground">Output price / MTok (USD)</label>
|
<label for="pricing-output" class="text-xs font-medium text-muted-foreground">Output price / MTok (USD)</label>
|
||||||
<Input
|
<NumberField
|
||||||
id="pricing-output"
|
id="pricing-output"
|
||||||
v-model="outputRaw"
|
v-model="outputRaw"
|
||||||
type="number"
|
|
||||||
min="0"
|
min="0"
|
||||||
step="any"
|
step="any"
|
||||||
placeholder="1.50"
|
placeholder="1.50"
|
||||||
@@ -82,11 +80,9 @@ const snippet = computed<string | null>(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Alert v-if="errors.length" id="pricing-errors" variant="destructive">
|
<Callout v-if="errors.length" id="pricing-errors" type="danger" role="alert" size="sm">
|
||||||
<AlertDescription>
|
|
||||||
<p v-for="(error, index) in errors" :key="index">{{ error }}</p>
|
<p v-for="(error, index) in errors" :key="index">{{ error }}</p>
|
||||||
</AlertDescription>
|
</Callout>
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<SnippetBlock v-if="snippet" label="Paste into middleware.yaml" :text="snippet" />
|
<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>
|
<p v-else class="text-sm text-muted-foreground">Enter a model id and both prices to build a snippet.</p>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Callout, Input } from '@perfect-design/ui'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
|
import NumberField from '@/components/NumberField.vue'
|
||||||
import SnippetBlock from '@/components/SnippetBlock.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 { isValidName, parseList, routerSnippet, validateRouter } from '@/lib/snippets'
|
||||||
import type { RouterInput } from '@/lib/snippets'
|
import type { RouterInput } from '@/lib/snippets'
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ const snippet = computed<string | null>(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1">
|
<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>
|
<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>
|
||||||
<div class="flex flex-col gap-1">
|
<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>
|
<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>
|
||||||
<div class="flex flex-col gap-1">
|
<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>
|
<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>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<input id="router-context-escalation" v-model="contextEscalation" type="checkbox" class="size-4 rounded border-input" />
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Alert v-if="errors.length" id="router-errors" variant="destructive">
|
<Callout v-if="errors.length" id="router-errors" type="danger" role="alert" size="sm">
|
||||||
<AlertDescription>
|
|
||||||
<p v-for="(error, index) in errors" :key="index">{{ error }}</p>
|
<p v-for="(error, index) in errors" :key="index">{{ error }}</p>
|
||||||
</AlertDescription>
|
</Callout>
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<SnippetBlock v-if="snippet" label="Paste into middleware.yaml" :text="snippet" />
|
<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>
|
<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>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<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'
|
import type { GrantTargetKind } from '@/composables/useTargetPicker'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,8 +26,14 @@ const emit = defineEmits<{
|
|||||||
'update:targetName': [value: string]
|
'update:targetName': [value: string]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const kindLabelId = `target-picker-kind-${useId()}`
|
const kindId = `target-picker-kind-${useId()}`
|
||||||
const nameLabelId = `target-picker-name-${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 {
|
function onKindUpdate(value: unknown): void {
|
||||||
if (value === 'group' || value === 'user') emit('update:targetKind', value)
|
if (value === 'group' || value === 'user') emit('update:targetKind', value)
|
||||||
@@ -40,23 +46,12 @@ function onNameUpdate(value: unknown): void {
|
|||||||
<template>
|
<template>
|
||||||
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<label :id="kindLabelId" class="text-xs font-medium text-muted-foreground">Target</label>
|
<label :for="kindId" class="text-xs font-medium text-muted-foreground">Target</label>
|
||||||
<Select :model-value="targetKind" @update:model-value="onKindUpdate">
|
<NativeSelect :id="kindId" :model-value="targetKind" :options="kindOptions" @update:model-value="onKindUpdate" />
|
||||||
<SelectTrigger :aria-labelledby="kindLabelId"><SelectValue /></SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="group">Group</SelectItem>
|
|
||||||
<SelectItem value="user">{{ props.userOptionLabel }}</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-1">
|
<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>
|
<label :for="nameId" class="text-xs font-medium text-muted-foreground">{{ targetKind === 'group' ? 'Group name' : 'User name' }}</label>
|
||||||
<Select :model-value="targetName" @update:model-value="onNameUpdate">
|
<NativeSelect :id="nameId" :model-value="targetName" :options="nameOptions" placeholder="Select…" @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>
|
|
||||||
<p v-if="targetNames.length === 0" class="text-xs text-muted-foreground">No {{ targetKind === 'group' ? 'groups' : 'users' }} loaded yet.</p>
|
<p v-if="targetNames.length === 0" class="text-xs text-muted-foreground">No {{ targetKind === 'group' ? 'groups' : 'users' }} loaded yet.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Button, Callout, Input } from '@perfect-design/ui'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
import LabeledSelect from '@/components/LabeledSelect.vue'
|
import LabeledSelect from '@/components/LabeledSelect.vue'
|
||||||
import SnippetBlock from '@/components/SnippetBlock.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 { API_KEY_PLACEHOLDER, generateApiKey, isValidUserName, parseList, userJsonLine, validatePersonalGrant } from '@/lib/snippets'
|
||||||
import { useToastsStore } from '@/stores/toasts'
|
import { useToastsStore } from '@/stores/toasts'
|
||||||
|
|
||||||
@@ -123,9 +121,7 @@ const snippet = computed<string | null>(() => {
|
|||||||
Admin (full access to /admin/api/*)
|
Admin (full access to /admin/api/*)
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<Alert v-if="grantError" variant="destructive">
|
<Callout v-if="grantError" type="danger" role="alert" size="sm">{{ grantError }}</Callout>
|
||||||
<AlertDescription>{{ grantError }}</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
|
|
||||||
<SnippetBlock v-if="snippet" label="Add as a new line in users.json" :text="snippet" />
|
<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>
|
<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>
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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'
|
|
||||||
@@ -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 +0,0 @@
|
|||||||
export { default as Input } from './Input.vue'
|
|
||||||
@@ -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>
|
|
||||||
@@ -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'
|
|
||||||
@@ -43,8 +43,7 @@ export function kindLabel(kind: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eventKindVariant maps a kind to the shadcn-vue Badge variant its row
|
* eventKindVariant maps a kind to the Badge variant its row renders: destructive for the three kinds where a
|
||||||
* renders (lib/events-columns.ts): destructive for the three kinds where a
|
|
||||||
* request was actually DENIED (rate_limit, budget, capacity — money or
|
* request was actually DENIED (rate_limit, budget, capacity — money or
|
||||||
* quota was protected), secondary for an infra/upstream failure that is
|
* quota was protected), secondary for an infra/upstream failure that is
|
||||||
* not itself a policy decision (store_down, upstream, timeout), outline
|
* not itself a policy decision (store_down, upstream, timeout), outline
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import type { ClassValue } from "clsx"
|
|
||||||
import { clsx } from "clsx"
|
|
||||||
import { twMerge } from "tailwind-merge"
|
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
|
||||||
return twMerge(clsx(inputs))
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user