import { NumberField as KNumberField } from "@kobalte/core/number-field"; import { splitProps, type ComponentProps, Show } from "solid-js"; import { tv, type VariantProps } from "tailwind-variants"; import { ChevronUp, ChevronDown } from "lucide-solid"; const numberFieldStyles = tv( { slots: { root: "flex flex-col gap-1.5 w-full antialiased", label: "text-sm font-medium text-main ml-1", container: [ "relative flex items-center rounded-md border border-slate-200 bg-app transition-shadow shadow-sm", "focus-within:ring-2 focus-within:ring-blue-500/20 focus-within:border-blue-500", ], input: "flex-1 bg-transparent px-3 py-2 text-sm outline-none placeholder:text-muted disabled:cursor-not-allowed", controls: "flex flex-col border-l border-slate-200 dark:border-slate-800", stepper: [ "flex h-1/2 w-8 items-center justify-center transition-colors hover:bg-foreground active:bg-foreground", "disabled:opacity-30 disabled:pointer-events-none", ], errorMessage: "text-xs text-danger font-medium ml-1 mt-1", }, }, { twMerge: true, }, ); type NumberFieldVariants = VariantProps; export interface NumberFieldProps extends Omit, "class">, NumberFieldVariants { label?: string; description?: string; class?: string; } export const NumberField = (props: NumberFieldProps) => { // 严格处理属性,防止 TS 报错“已声明但未使用” const [local, others] = splitProps(props, [ "label", "description", "class", ]); const s = numberFieldStyles(); return ( {local.label}
); };