@alwith/module-chat 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,7 @@ import { type MenuRadioOption } from "./menu-radio.js";
|
|
|
5
5
|
export interface ChatModelOption {
|
|
6
6
|
api_id: string;
|
|
7
7
|
label: string;
|
|
8
|
+
icon?: ReactNode;
|
|
8
9
|
more?: boolean;
|
|
9
10
|
description?: string;
|
|
10
11
|
}
|
|
@@ -17,6 +18,12 @@ export interface ModelSelectProps<T extends ChatModelOption> extends Omit<Compon
|
|
|
17
18
|
name: string;
|
|
18
19
|
models: T[];
|
|
19
20
|
}>;
|
|
21
|
+
compactCatalog?: boolean;
|
|
22
|
+
effortPresentation?: "slider" | "menu";
|
|
23
|
+
unavailableEffort?: {
|
|
24
|
+
name: string;
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
20
27
|
providerMenu?: {
|
|
21
28
|
value: string;
|
|
22
29
|
icon: ReactNode;
|
|
@@ -43,6 +50,9 @@ export interface ModelSelectProps<T extends ChatModelOption> extends Omit<Compon
|
|
|
43
50
|
id: string;
|
|
44
51
|
name: string;
|
|
45
52
|
currentValue: boolean;
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
title?: string;
|
|
55
|
+
icon?: ReactNode;
|
|
46
56
|
}>;
|
|
47
57
|
onBooleanChange?: (id: string, value: boolean) => void;
|
|
48
58
|
selectOptions?: Array<{
|
|
@@ -54,4 +64,4 @@ export interface ModelSelectProps<T extends ChatModelOption> extends Omit<Compon
|
|
|
54
64
|
}>;
|
|
55
65
|
t: (key: "model.loadingModels" | "model.switchProvider" | "model.moreModels" | "model.selectModel" | "model.switchModel" | "model.noModelsAvailable") => string;
|
|
56
66
|
}
|
|
57
|
-
export declare function ModelSelect<T extends ChatModelOption>({ value: selectedModel, onChange: setSelectedModel, models: currentProviderModels, modelGroups, providerMenu, header, className, condensed, stripLabelPrefix, showDescription, showModelList, loading, switching, isLoading, effortConfig, booleanOptions, onBooleanChange, selectOptions, t, ...props }: ModelSelectProps<T>): import("react").JSX.Element;
|
|
67
|
+
export declare function ModelSelect<T extends ChatModelOption>({ value: selectedModel, onChange: setSelectedModel, models: currentProviderModels, modelGroups, compactCatalog, effortPresentation, unavailableEffort, providerMenu, header, className, condensed, stripLabelPrefix, showDescription, showModelList, loading, switching, isLoading, effortConfig, booleanOptions, onBooleanChange, selectOptions, t, ...props }: ModelSelectProps<T>): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as a,Fragment as
|
|
1
|
+
import{jsx as e,jsxs as a,Fragment as o}from"react/jsx-runtime";import{cn as t}from"cn";import{ArrowUpRight as ue,ChevronUp as H,Loader2Icon as J,Zap as K}from"lucide-react";import{Fragment as oe,useState as Q}from"react";import{Button as I}from"../ui/button.js";import{DropdownMenu as X,DropdownMenuContent as Y,DropdownMenuCheckboxItem as C,DropdownMenuGroup as V,DropdownMenuItem as _,DropdownMenuLabel as R,DropdownMenuSeparator as h,DropdownMenuSub as j,DropdownMenuSubContent as O,DropdownMenuSubTrigger as S,DropdownMenuTrigger as G}from"../ui/dropdown-menu.js";import{Switch as pe}from"../ui/switch.js";import{Tooltip as E,TooltipContent as P,TooltipTrigger as ee}from"../ui/tooltip.js";import{EffortSlider as ne}from"./effort-slider.js";import{MenuRadioSelect as u}from"./menu-radio.js";function De({value:p,onChange:ae,models:g,modelGroups:f,compactCatalog:d,effortPresentation:U="slider",unavailableEffort:v,providerMenu:x,header:w,className:L,condensed:M,stripLabelPrefix:T,showDescription:ie,showModelList:le=!0,loading:se,switching:W,isLoading:de,effortConfig:i,booleanOptions:D,onBooleanChange:A,selectOptions:re=[],t:c,...m}){let[me,te]=Q(!1),[ce,he]=Q(!1),r=D?.find((n)=>n.id==="fast_mode"),F=d?D?.filter((n)=>n!==r):D,Z=(n)=>T&&n.startsWith(T)?n.slice(T.length):n;if(se)return e("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:a(I,{variant:"ghost",disabled:!0,className:t("h-7 min-w-0 shrink gap-1.5 rounded-md px-2 text-xs font-normal",L),children:[e(J,{className:"size-3 animate-spin"}),e("span",{className:"text-muted-foreground truncate",children:c("model.loadingModels")})]})});return a("div",{className:"inline-flex min-w-0 items-center gap-1.5",children:[x&&a(X,{open:me,onOpenChange:te,children:[a(E,{children:[e(ee,{render:e(G,{render:a(I,{"data-testid":"provider-trigger",variant:"ghost",disabled:m.disabled,className:t("h-7 shrink-0 gap-1 rounded-md px-1.5","hover:bg-accent"),children:[x.icon,e(H,{className:"size-2.5 shrink-0 opacity-60"})]})})}),e(P,{children:c("model.switchProvider")})]}),a(Y,{side:"top",align:"end",sideOffset:4,className:"z-100 min-w-[10rem]",children:[x.groups.map((n,s)=>a(oe,{children:[s>0&&n.length>0&&e(h,{}),e(u,{value:x.value,onValueChange:x.onChange,options:n})]},s)),x.moreAction&&a(o,{children:[e(h,{}),a(_,{onClick:x.moreAction,className:"whitespace-nowrap",children:[e("span",{className:"min-w-0 flex-1 truncate",children:c("model.moreModels")}),e(ue,{className:"size-4"})]})]})]})]}),a(X,{open:ce,onOpenChange:he,children:[a(E,{children:[e(ee,{render:e(G,{render:a(I,{"data-testid":"model-trigger","aria-busy":W,variant:"ghost",className:t("h-7 gap-1.5 rounded-md px-2 text-xs font-normal","hover:bg-accent","max-w-full min-w-0 shrink",M&&"h-7 gap-1 px-1.5 text-[11px]",L),...m,children:[p.icon,D?.some((n)=>n.id==="fast_mode"&&n.currentValue&&!n.disabled)&&e(K,{"aria-hidden":"true",className:"size-3 shrink-0"}),e("span",{className:t("min-w-0 flex-1 truncate text-start",M&&"text-[11px]"),children:Z(p.label)||c("model.selectModel")}),i&&a("span",{className:"text-muted-foreground grid shrink-0 justify-items-center",children:[e("span",{className:"invisible col-start-1 row-start-1",children:i.sizer??i.levels.reduce((n,s)=>s.name.length>n.length?s.name:n,"")}),e("span",{className:"col-start-1 row-start-1",children:i.levels.find((n)=>n.value===i.value)?.name??i.value})]}),W?e(J,{"data-testid":"model-switch-loading",className:"size-3 shrink-0 animate-spin"}):e(H,{className:t("size-3 shrink-0",M&&"size-2.5")})]})})}),e(P,{children:c("model.switchModel")})]}),a(Y,{side:"top",align:"end",sideOffset:4,className:t("z-100 w-auto max-w-[min(24rem,calc(100vw-1rem))] min-w-[14rem]",d&&"flex h-[350px] w-80 min-w-0 flex-col overflow-hidden rounded-xl p-1.5"),children:[d&&a(o,{children:[a(V,{"data-model-menu-header":!0,className:"flex shrink-0 items-center justify-between gap-2 px-1 py-1",children:[i?U==="slider"?e("div",{role:"menuitem","aria-label":i.name,className:"min-w-0 [&>div]:justify-start [&>div]:gap-3 [&>div]:px-2 [&>div]:py-1.5",children:e(ne,{...i,disabled:m.disabled})}):a(j,{children:[a(S,{disabled:m.disabled,className:"h-8 min-w-0 flex-1 gap-2 rounded-md",children:[e("span",{children:i.name}),e("span",{className:"text-muted-foreground min-w-0 truncate text-xs",children:i.levels.find((n)=>n.value===i.value)?.name??i.value})]}),e(O,{children:e(u,{value:i.value,onValueChange:i.onChange,options:i.levels.map((n)=>({value:n.value,label:n.name}))})})]}):v?a(_,{disabled:!0,className:"h-8 min-w-0 flex-1 gap-2",children:[e("span",{children:v.name}),e("span",{className:"text-muted-foreground truncate text-xs",children:v.label})]}):e(R,{className:"min-w-0 flex-1 truncate",children:w?.name}),r&&e(C,{"aria-label":r.name,title:r.title??r.name,disabled:m.disabled||r.disabled,checked:r.currentValue,closeOnClick:!1,onCheckedChange:(n)=>A?.(r.id,n),className:t("ml-auto size-8 shrink-0 justify-center rounded-md p-0 focus:bg-transparent hover:bg-accent focus:hover:bg-accent focus-visible:bg-accent [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",r.currentValue&&!r.disabled?"text-foreground [&_svg]:fill-current":"text-muted-foreground"),children:r.icon??e(K,{className:"size-4","aria-hidden":"true"})})]}),e(h,{className:"shrink-0"})]}),w&&!d&&a(o,{children:[a("div",{className:"flex items-center gap-2 px-2 py-2",children:[w.icon,e("span",{className:"min-w-0 flex-1 truncate text-sm font-medium",children:w.name}),w.action]}),e(h,{})]}),a(V,{"data-model-menu-list":d?"":void 0,className:d?"min-h-0 flex-1 overflow-y-auto overscroll-contain":void 0,children:[le&&(de?e(_,{disabled:!0,className:"text-muted-foreground",children:c("model.loadingModels")}):g.length===0?e(_,{disabled:!0,className:"text-muted-foreground",children:c("model.noModelsAvailable")}):(()=>{let n=g.filter((l)=>!l.more),s=g.filter((l)=>l.more),q=n.length>0&&s.length>0,k=(l,b)=>({disabled:m.disabled,icon:l.icon,value:l.api_id,label:Z(l.label),description:b?.noDescription?void 0:ie?l.description:void 0}),y=(l)=>{let b=g.find((z)=>z.api_id===l);if(b)ae(b)};if(d)return e(u,{value:p.api_id,onValueChange:y,itemClassName:"font-normal whitespace-nowrap",options:g.map((l)=>k(l))});return a(o,{children:[f?f.map((l)=>{let b=l.models.filter((N)=>!N.more),z=l.models.filter((N)=>N.more),B=b.length>0&&z.length>0;return a(V,{children:[e(R,{className:"text-muted-foreground text-xs font-normal",children:l.name}),e(u,{value:p.api_id,onValueChange:y,itemClassName:"font-medium whitespace-nowrap",options:(B?b:l.models).map((N)=>k(N))}),B&&a(j,{children:[e(S,{className:"font-medium whitespace-nowrap",children:c("model.moreModels")}),e(O,{children:e(u,{value:p.api_id,onValueChange:y,itemClassName:"font-medium whitespace-nowrap",options:z.map((N)=>k(N,{noDescription:!0}))})})]})]},l.id)}):e(u,{value:p.api_id,onValueChange:y,itemClassName:"font-medium whitespace-nowrap",options:(q?n:g).map((l)=>k(l))}),!f&&q&&a(j,{children:[e(S,{className:"font-medium whitespace-nowrap",children:c("model.moreModels")}),e(O,{children:e(u,{value:p.api_id,onValueChange:y,itemClassName:"font-medium whitespace-nowrap",options:s.map((l)=>k(l,{noDescription:!0}))})})]})]})})()),!d&&i&&a(o,{children:[e(h,{}),U==="menu"?a(j,{children:[a(S,{disabled:m.disabled,children:[e("span",{className:"flex-1",children:i.name}),e("span",{className:"text-muted-foreground",children:i.levels.find((n)=>n.value===i.value)?.name??i.value})]}),e(O,{children:e(u,{value:i.value,onValueChange:i.onChange,options:i.levels.map((n)=>({value:n.value,label:n.name}))})})]}):e(ne,{...i,disabled:m.disabled})]}),!d&&!i&&v&&a(o,{children:[e(h,{}),a(_,{disabled:!0,children:[e("span",{className:"flex-1",children:v.name}),e("span",{children:v.label})]})]}),re.map((n)=>a(V,{children:[e(h,{}),e(R,{children:n.name}),e(u,{value:n.value,onValueChange:n.onChange,options:n.options,itemClassName:"whitespace-nowrap"})]},n.id)),F&&F.length>0&&a(o,{children:[!i&&e(h,{}),F.map((n)=>d?a(C,{"aria-label":n.name,title:n.title,disabled:m.disabled||n.disabled,checked:n.currentValue,closeOnClick:!1,onCheckedChange:(s)=>A?.(n.id,s),className:"justify-between gap-3 py-2.5 pr-2 [&_[data-slot=dropdown-menu-checkbox-item-indicator]]:hidden",children:[a("span",{className:"flex items-center gap-2",children:[n.icon,n.name]}),e("span",{"aria-hidden":"true",className:t("flex h-[18px] w-8 shrink-0 items-center rounded-full p-0.5",n.currentValue?"bg-primary":"bg-input"),children:e("span",{className:t("size-3.5 rounded-full bg-background shadow-xs transition-transform",n.currentValue&&"translate-x-3.5")})})]},n.id):a("div",{title:n.title,className:t("flex items-center justify-between gap-3 px-2 py-2.5",n.disabled&&"opacity-50"),children:[a("span",{className:"flex items-center gap-2 text-sm font-medium",children:[n.icon,n.name]}),e(pe,{"aria-label":n.name,disabled:m.disabled||n.disabled,checked:n.currentValue,onCheckedChange:(s)=>A?.(n.id,s)})]},n.id))]})]}),d&&w?.action&&a(o,{children:[e(h,{className:"shrink-0"}),e(V,{"data-model-menu-footer":!0,className:"shrink-0",children:w.action})]})]})]})]})}export{De as ModelSelect};
|
|
@@ -6,8 +6,9 @@ export interface PermissionModeSelectProps {
|
|
|
6
6
|
icon: ReactNode;
|
|
7
7
|
options: MenuRadioOption[];
|
|
8
8
|
label: string;
|
|
9
|
+
header?: ReactNode;
|
|
9
10
|
onValueChange: (value: string) => void;
|
|
10
11
|
showLabel?: boolean;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare function PermissionModeSelect({ value, currentName, icon, options, label, onValueChange, showLabel, disabled }: PermissionModeSelectProps): import("react").JSX.Element;
|
|
14
|
+
export declare function PermissionModeSelect({ value, currentName, icon, options, label, header, onValueChange, showLabel, disabled }: PermissionModeSelectProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as c}from"react";import{Button as x}from"../ui/button.js";import{DropdownMenu as f,DropdownMenuContent as g,DropdownMenuTrigger as h}from"../ui/dropdown-menu.js";import{MenuRadioSelect as w}from"./menu-radio.js";function D({value:a,currentName:n,icon:r,options:p,label:s,header:o,onValueChange:i,showLabel:l=!1,disabled:d=!1}){let[m,u]=c(!1);return t(f,{open:m,onOpenChange:u,children:[e(h,{render:t(x,{disabled:d,variant:"ghost","aria-label":`${s}: ${n}`,title:n,className:"h-7 gap-1.5 rounded-full bg-transparent px-2 text-xs font-normal whitespace-nowrap text-muted-foreground data-popup-open:bg-transparent data-popup-open:hover:bg-muted",children:[r,e("span",{className:l?"max-w-40 truncate":"hidden max-w-40 truncate @[40rem]/input-footer:inline-block",children:n})]})}),t(g,{align:"start",sideOffset:4,className:"permission-mode-menu z-100 w-auto min-w-72 max-w-[calc(100vw-2rem)] rounded-xl p-1.5",children:[o&&e("div",{className:"flex items-center px-1.5 pt-0.5 pb-1 text-[11px] leading-4 text-muted-foreground",children:e("span",{children:o})}),e(w,{value:a,onValueChange:i,itemClassName:"items-center gap-2 py-1 pr-6 pl-2 whitespace-nowrap",options:p})]})]})}export{D as PermissionModeSelect};
|