@superinterface/react 2.22.0 → 2.22.1

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.js CHANGED
@@ -2773,6 +2773,32 @@ var formOptions = {
2773
2773
  };
2774
2774
  // src/components/threads/Thread/MessageForm/Root/index.tsx
2775
2775
  import { partob as partob2 } from "radash";
2776
+ // src/lib/errors/createMessageDefaultOnError.ts
2777
+ var createMessageDefaultOnError = function(param) {
2778
+ var queryClient = param.queryClient, addToast = param.addToast, threadContext = param.threadContext;
2779
+ return function(error) {
2780
+ if (error.name === "AbortError") {
2781
+ queryClient.invalidateQueries({
2782
+ queryKey: [
2783
+ "messages",
2784
+ threadContext.variables
2785
+ ]
2786
+ });
2787
+ queryClient.invalidateQueries({
2788
+ queryKey: [
2789
+ "runs",
2790
+ threadContext.variables
2791
+ ]
2792
+ });
2793
+ return;
2794
+ }
2795
+ addToast({
2796
+ type: "error",
2797
+ message: error.message
2798
+ });
2799
+ };
2800
+ };
2801
+ // src/components/threads/Thread/MessageForm/Root/index.tsx
2776
2802
  import { jsx as jsx51 } from "react/jsx-runtime";
2777
2803
  var Root4 = function(param) {
2778
2804
  var children = param.children, onSubmitArg = param.onSubmit, isDisabledArg = param.isDisabled;
@@ -2783,27 +2809,11 @@ var Root4 = function(param) {
2783
2809
  var queryClient = useQueryClient4();
2784
2810
  var threadContext = useSuperinterfaceContext();
2785
2811
  var createMessage = useCreateMessage({
2786
- onError: function(error) {
2787
- if (error.name === "AbortError") {
2788
- queryClient.invalidateQueries({
2789
- queryKey: [
2790
- "messages",
2791
- threadContext.variables
2792
- ]
2793
- });
2794
- queryClient.invalidateQueries({
2795
- queryKey: [
2796
- "runs",
2797
- threadContext.variables
2798
- ]
2799
- });
2800
- return;
2801
- }
2802
- addToast({
2803
- type: "error",
2804
- message: error.message
2805
- });
2806
- }
2812
+ onError: createMessageDefaultOnError({
2813
+ queryClient: queryClient,
2814
+ addToast: addToast,
2815
+ threadContext: threadContext
2816
+ })
2807
2817
  }).createMessage;
2808
2818
  var isMutatingMessage = useIsMutatingMessage();
2809
2819
  var isFileLoading = useMemo8(function() {
@@ -3497,7 +3507,7 @@ var CustomToast = function(param) {
3497
3507
  // src/components/toasts/ToastsProvider/index.tsx
3498
3508
  import { jsx as jsx59, jsxs as jsxs22 } from "react/jsx-runtime";
3499
3509
  var ToastsProvider = function(param) {
3500
- var children = param.children;
3510
+ var children = param.children, _param_bottom = param.bottom, bottom = _param_bottom === void 0 ? 0 : _param_bottom;
3501
3511
  var _useState2 = _sliced_to_array(useState2([]), 2), toasts = _useState2[0], setToasts = _useState2[1];
3502
3512
  var addToast = useCallback3(function(toast) {
3503
3513
  return setToasts(function(prevToasts) {
@@ -3522,7 +3532,7 @@ var ToastsProvider = function(param) {
3522
3532
  /* @__PURE__ */ jsx59(Toast2.Viewport, {
3523
3533
  style: {
3524
3534
  position: "absolute",
3525
- bottom: "var(--space-9)",
3535
+ bottom: bottom,
3526
3536
  right: 0,
3527
3537
  display: "flex",
3528
3538
  flexDirection: "column",
@@ -3547,6 +3557,7 @@ var Root8 = function(_param) {
3547
3557
  "children"
3548
3558
  ]);
3549
3559
  return /* @__PURE__ */ jsx60(ToastsProvider, {
3560
+ bottom: "var(--space-9)",
3550
3561
  children: /* @__PURE__ */ jsx60(Provider2, _object_spread_props(_object_spread({}, rest), {
3551
3562
  children: /* @__PURE__ */ jsx60(Flex22, {
3552
3563
  direction: "column",
@@ -4409,10 +4420,23 @@ var useMessageAudio = function(param) {
4409
4420
  });
4410
4421
  };
4411
4422
  // src/components/threads/AudioThread/Root/index.tsx
4423
+ import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
4412
4424
  import { jsx as jsx69 } from "react/jsx-runtime";
4413
- var Root12 = function(param) {
4425
+ var Content6 = function(param) {
4414
4426
  var children = param.children;
4415
- var createMessageProps = useCreateMessage();
4427
+ var addToast = useToasts().addToast;
4428
+ var queryClient = useQueryClient6();
4429
+ var threadContext = useSuperinterfaceContext();
4430
+ var createMessageProps = useCreateMessage({
4431
+ onError: function(error) {
4432
+ createMessageDefaultOnError({
4433
+ queryClient: queryClient,
4434
+ addToast: addToast,
4435
+ threadContext: threadContext
4436
+ })(error);
4437
+ recorderProps.start();
4438
+ }
4439
+ });
4416
4440
  var recorderProps = useRecorder({
4417
4441
  isStopOnSilence: true,
4418
4442
  onStart: /*#__PURE__*/ _async_to_generator(function() {
@@ -4481,6 +4505,14 @@ var Root12 = function(param) {
4481
4505
  })
4482
4506
  });
4483
4507
  };
4508
+ var Root12 = function(param) {
4509
+ var children = param.children;
4510
+ return /* @__PURE__ */ jsx69(ToastsProvider, {
4511
+ children: /* @__PURE__ */ jsx69(Content6, {
4512
+ children: children
4513
+ })
4514
+ });
4515
+ };
4484
4516
  // src/components/threads/AudioThread/Visualization/index.tsx
4485
4517
  import { useContext as useContext15, useState as useState8, useCallback as useCallback6, useEffect as useEffect10 } from "react";
4486
4518
  import _9 from "lodash";
@@ -4869,11 +4901,21 @@ import { Flex as Flex32 } from "@radix-ui/themes";
4869
4901
  // src/components/suggestions/Suggestions/Item.tsx
4870
4902
  import { ArrowUpIcon as ArrowUpIcon3 } from "@radix-ui/react-icons";
4871
4903
  import { Text as Text9, Button as Button4, Spinner as Spinner2 } from "@radix-ui/themes";
4904
+ import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
4872
4905
  import { jsx as jsx79, jsxs as jsxs32 } from "react/jsx-runtime";
4873
4906
  var Item = function(param) {
4874
4907
  var suggestion = param.suggestion, isDisabled = param.isDisabled;
4875
- var _useCreateMessage = useCreateMessage(), createMessage = _useCreateMessage.createMessage, isPending = _useCreateMessage.isPending;
4876
- return /* @__PURE__ */ jsx79(Content6, {
4908
+ var addToast = useToasts().addToast;
4909
+ var queryClient = useQueryClient7();
4910
+ var threadContext = useSuperinterfaceContext();
4911
+ var _useCreateMessage = useCreateMessage({
4912
+ onError: createMessageDefaultOnError({
4913
+ queryClient: queryClient,
4914
+ addToast: addToast,
4915
+ threadContext: threadContext
4916
+ })
4917
+ }), createMessage = _useCreateMessage.createMessage, isPending = _useCreateMessage.isPending;
4918
+ return /* @__PURE__ */ jsx79(Content7, {
4877
4919
  onClick: function() {
4878
4920
  createMessage({
4879
4921
  // @ts-ignore-next-line
@@ -4885,7 +4927,7 @@ var Item = function(param) {
4885
4927
  children: suggestion
4886
4928
  });
4887
4929
  };
4888
- var Content6 = function(param) {
4930
+ var Content7 = function(param) {
4889
4931
  var onClick = param.onClick, isDisabled = param.isDisabled, isPending = param.isPending, children = param.children;
4890
4932
  return /* @__PURE__ */ jsxs32(Button4, {
4891
4933
  variant: "soft",
@@ -4913,10 +4955,10 @@ var Content6 = function(param) {
4913
4955
  ]
4914
4956
  });
4915
4957
  };
4916
- Item.Content = Content6;
4958
+ Item.Content = Content7;
4917
4959
  // src/components/suggestions/Suggestions/Content.tsx
4918
4960
  import { jsx as jsx80 } from "react/jsx-runtime";
4919
- var Content7 = function(param) {
4961
+ var Content8 = function(param) {
4920
4962
  var children = param.children;
4921
4963
  var isMutatingMessage = useIsMutatingMessage();
4922
4964
  var suggestions = useMemo14(function() {
@@ -4955,7 +4997,7 @@ var Suggestions = function(param) {
4955
4997
  ]);
4956
4998
  if (latestMessageProps.isLoading) return null;
4957
4999
  if (isDisabled) return null;
4958
- return /* @__PURE__ */ jsx81(Content7, {
5000
+ return /* @__PURE__ */ jsx81(Content8, {
4959
5001
  children: children
4960
5002
  });
4961
5003
  };