@melony/react 0.1.22 → 0.1.23

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.d.cts CHANGED
@@ -42,6 +42,7 @@ interface ComposerOptionGroup {
42
42
  label: string;
43
43
  options: ComposerOption[];
44
44
  type?: "single" | "multiple";
45
+ defaultSelectedIds?: string[];
45
46
  }
46
47
  interface AuthService {
47
48
  getMe: () => Promise<User | null>;
package/dist/index.d.ts CHANGED
@@ -42,6 +42,7 @@ interface ComposerOptionGroup {
42
42
  label: string;
43
43
  options: ComposerOption[];
44
44
  type?: "single" | "multiple";
45
+ defaultSelectedIds?: string[];
45
46
  }
46
47
  interface AuthService {
47
48
  getMe: () => Promise<User | null>;
package/dist/index.js CHANGED
@@ -2341,6 +2341,14 @@ function Thread({
2341
2341
  });
2342
2342
  const starterPrompts = localStarterPrompts ?? config?.starterPrompts;
2343
2343
  const options = localOptions ?? config?.options;
2344
+ const allDefaultSelectedIds = useMemo(() => {
2345
+ const defaultSelectedIdsFromOptions = options?.flatMap(
2346
+ (group) => group.defaultSelectedIds ?? []
2347
+ ) ?? [];
2348
+ return [
2349
+ .../* @__PURE__ */ new Set([...defaultSelectedIdsFromOptions, ...defaultSelectedIds ?? []])
2350
+ ];
2351
+ }, [options, defaultSelectedIds]);
2344
2352
  const [input, setInput] = useState("");
2345
2353
  const messagesEndRef = useRef(null);
2346
2354
  useEffect(() => {
@@ -2412,7 +2420,7 @@ function Thread({
2412
2420
  isLoading,
2413
2421
  options,
2414
2422
  autoFocus,
2415
- defaultSelectedIds
2423
+ defaultSelectedIds: allDefaultSelectedIds
2416
2424
  }
2417
2425
  ) }) })
2418
2426
  ]