@page-speed/agent-everywhere 0.1.0 → 0.2.0

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.
package/dist/index.cjs CHANGED
@@ -1082,23 +1082,6 @@ function StatusBadge({
1082
1082
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground text-[10px]", children: displayLabel })
1083
1083
  ] });
1084
1084
  }
1085
- var Input = React4__namespace.forwardRef(
1086
- ({ className, type, ...props }, ref) => {
1087
- return /* @__PURE__ */ jsxRuntime.jsx(
1088
- "input",
1089
- {
1090
- type,
1091
- className: cn(
1092
- "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
1093
- className
1094
- ),
1095
- ref,
1096
- ...props
1097
- }
1098
- );
1099
- }
1100
- );
1101
- Input.displayName = "Input";
1102
1085
  var buttonVariants = classVarianceAuthority.cva(
1103
1086
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1104
1087
  {
@@ -1138,6 +1121,8 @@ var Button = React4__namespace.forwardRef(
1138
1121
  }
1139
1122
  );
1140
1123
  Button.displayName = "Button";
1124
+ var LINE_HEIGHT_PX = 20;
1125
+ var VERTICAL_PADDING_PX = 8;
1141
1126
  var PromptInput = React4.forwardRef(
1142
1127
  ({
1143
1128
  value,
@@ -1153,11 +1138,28 @@ var PromptInput = React4.forwardRef(
1153
1138
  rightActions,
1154
1139
  className,
1155
1140
  inputClassName,
1156
- variant = "default"
1141
+ variant = "default",
1142
+ minRows = 1,
1143
+ maxRows = 6
1157
1144
  }, ref) => {
1145
+ const textareaRef = React4.useRef(null);
1146
+ React4.useImperativeHandle(ref, () => textareaRef.current);
1147
+ const resize = React4.useCallback(() => {
1148
+ const el = textareaRef.current;
1149
+ if (!el) return;
1150
+ el.style.height = "auto";
1151
+ const maxHeight = maxRows * LINE_HEIGHT_PX + VERTICAL_PADDING_PX;
1152
+ const minHeight = minRows * LINE_HEIGHT_PX + VERTICAL_PADDING_PX;
1153
+ const next = Math.min(Math.max(el.scrollHeight, minHeight), maxHeight);
1154
+ el.style.height = `${next}px`;
1155
+ el.style.overflowY = el.scrollHeight > maxHeight ? "auto" : "hidden";
1156
+ }, [maxRows, minRows]);
1157
+ React4.useLayoutEffect(() => {
1158
+ resize();
1159
+ }, [value, resize]);
1158
1160
  const handleSubmit = React4.useCallback(
1159
1161
  (e) => {
1160
- e.preventDefault();
1162
+ e?.preventDefault();
1161
1163
  if (!value.trim() || disabled || loading) return;
1162
1164
  onSubmit();
1163
1165
  },
@@ -1167,7 +1169,7 @@ var PromptInput = React4.forwardRef(
1167
1169
  (e) => {
1168
1170
  if (e.key === "Enter" && !e.shiftKey) {
1169
1171
  e.preventDefault();
1170
- handleSubmit(e);
1172
+ handleSubmit();
1171
1173
  }
1172
1174
  },
1173
1175
  [handleSubmit]
@@ -1178,48 +1180,65 @@ var PromptInput = React4.forwardRef(
1178
1180
  bordered: "border rounded-lg px-3 py-2.5"
1179
1181
  };
1180
1182
  const inputVariantStyles = {
1181
- default: "h-9 border-0 bg-transparent shadow-none focus-visible:ring-0",
1182
- minimal: "h-8 border-0 bg-transparent shadow-none focus-visible:ring-0 px-0",
1183
- bordered: "h-9 border-0 bg-muted/50 shadow-none focus-visible:ring-0"
1183
+ default: "bg-transparent",
1184
+ minimal: "bg-transparent px-0",
1185
+ bordered: "bg-muted/50"
1184
1186
  };
1187
+ return /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: handleSubmit, className: cn(variantStyles[variant], className), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-end gap-2", children: [
1188
+ leftActions,
1189
+ /* @__PURE__ */ jsxRuntime.jsx(
1190
+ "textarea",
1191
+ {
1192
+ ref: textareaRef,
1193
+ value,
1194
+ onChange: (e) => onChange(e.target.value),
1195
+ onKeyDown: handleKeyDown,
1196
+ placeholder,
1197
+ disabled: disabled || loading,
1198
+ autoFocus,
1199
+ rows: minRows,
1200
+ className: cn(
1201
+ "flex-1 resize-none border-0 px-0 py-1 text-sm leading-5 shadow-none",
1202
+ "placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0",
1203
+ "disabled:cursor-not-allowed disabled:opacity-50",
1204
+ inputVariantStyles[variant],
1205
+ inputClassName
1206
+ )
1207
+ }
1208
+ ),
1209
+ rightActions,
1210
+ showSendButton && /* @__PURE__ */ jsxRuntime.jsx(
1211
+ Button,
1212
+ {
1213
+ type: "submit",
1214
+ size: "sm",
1215
+ variant: variant === "minimal" ? "ghost" : "outline",
1216
+ disabled: !value.trim() || disabled || loading,
1217
+ className: "size-8 shrink-0 p-0",
1218
+ children: sendButtonContent || /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SendIcon, { className: "size-4" })
1219
+ }
1220
+ )
1221
+ ] }) });
1222
+ }
1223
+ );
1224
+ PromptInput.displayName = "PromptInput";
1225
+ var Input = React4__namespace.forwardRef(
1226
+ ({ className, type, ...props }, ref) => {
1185
1227
  return /* @__PURE__ */ jsxRuntime.jsx(
1186
- "form",
1228
+ "input",
1187
1229
  {
1188
- onSubmit: handleSubmit,
1189
- className: cn(variantStyles[variant], className),
1190
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1191
- leftActions,
1192
- /* @__PURE__ */ jsxRuntime.jsx(
1193
- Input,
1194
- {
1195
- ref,
1196
- value,
1197
- onChange: (e) => onChange(e.target.value),
1198
- onKeyDown: handleKeyDown,
1199
- placeholder,
1200
- disabled: disabled || loading,
1201
- autoFocus,
1202
- className: cn("flex-1 text-sm", inputVariantStyles[variant], inputClassName)
1203
- }
1204
- ),
1205
- rightActions,
1206
- showSendButton && /* @__PURE__ */ jsxRuntime.jsx(
1207
- Button,
1208
- {
1209
- type: "submit",
1210
- size: "sm",
1211
- variant: variant === "minimal" ? "ghost" : "outline",
1212
- disabled: !value.trim() || disabled || loading,
1213
- className: "size-8 shrink-0 p-0",
1214
- children: sendButtonContent || /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SendIcon, { className: "size-4" })
1215
- }
1216
- )
1217
- ] })
1230
+ type,
1231
+ className: cn(
1232
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
1233
+ className
1234
+ ),
1235
+ ref,
1236
+ ...props
1218
1237
  }
1219
1238
  );
1220
1239
  }
1221
1240
  );
1222
- PromptInput.displayName = "PromptInput";
1241
+ Input.displayName = "Input";
1223
1242
  var attachmentIcons = {
1224
1243
  image: lucideReact.ImageIcon,
1225
1244
  audio: lucideReact.MicIcon,
@@ -6253,7 +6272,7 @@ function FloatingWidget({
6253
6272
  children,
6254
6273
  isLoading && /* @__PURE__ */ jsxRuntime.jsx(TypingIndicator, { size: "sm" })
6255
6274
  ] }) }),
6256
- quickReplies && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1.5 overflow-x-auto px-4 pb-2", children: quickReplies }),
6275
+ quickReplies && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-[40%] shrink-0 overflow-y-auto border-t bg-muted/30 px-4 py-2", children: quickReplies }),
6257
6276
  input,
6258
6277
  footer && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t px-4 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-[10px] text-muted-foreground", children: footer }) })
6259
6278
  ]