@superinterface/react 2.21.0 → 2.22.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 +145 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +137 -114
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2628,7 +2628,7 @@ var mutationFn = function(param) {
|
|
|
2628
2628
|
var superinterfaceContext = param.superinterfaceContext, queryClient = param.queryClient, threadContext = param.threadContext;
|
|
2629
2629
|
return function() {
|
|
2630
2630
|
var _ref = _async_to_generator(function(variables) {
|
|
2631
|
-
var abortController, response, parser, reader, messagesQueryKey, _ref, done, value;
|
|
2631
|
+
var abortController, response, errorResponse, error, parser, reader, messagesQueryKey, _ref, done, value;
|
|
2632
2632
|
return _ts_generator(this, function(_state) {
|
|
2633
2633
|
switch(_state.label){
|
|
2634
2634
|
case 0:
|
|
@@ -2647,6 +2647,29 @@ var mutationFn = function(param) {
|
|
|
2647
2647
|
];
|
|
2648
2648
|
case 1:
|
|
2649
2649
|
response = _state.sent();
|
|
2650
|
+
if (!(response.status !== 200)) return [
|
|
2651
|
+
3,
|
|
2652
|
+
5
|
|
2653
|
+
];
|
|
2654
|
+
_state.label = 2;
|
|
2655
|
+
case 2:
|
|
2656
|
+
_state.trys.push([
|
|
2657
|
+
2,
|
|
2658
|
+
4,
|
|
2659
|
+
,
|
|
2660
|
+
5
|
|
2661
|
+
]);
|
|
2662
|
+
return [
|
|
2663
|
+
4,
|
|
2664
|
+
response.json()
|
|
2665
|
+
];
|
|
2666
|
+
case 3:
|
|
2667
|
+
errorResponse = _state.sent();
|
|
2668
|
+
throw new Error(errorResponse.error);
|
|
2669
|
+
case 4:
|
|
2670
|
+
error = _state.sent();
|
|
2671
|
+
throw new Error("There was a problem sending your message. Please try again.");
|
|
2672
|
+
case 5:
|
|
2650
2673
|
if (response.body == null) {
|
|
2651
2674
|
throw new Error("The response body is empty.");
|
|
2652
2675
|
}
|
|
@@ -2662,21 +2685,21 @@ var mutationFn = function(param) {
|
|
|
2662
2685
|
"messages",
|
|
2663
2686
|
threadContext.variables
|
|
2664
2687
|
];
|
|
2665
|
-
_state.label =
|
|
2666
|
-
case
|
|
2688
|
+
_state.label = 6;
|
|
2689
|
+
case 6:
|
|
2667
2690
|
if (!true) return [
|
|
2668
2691
|
3,
|
|
2669
|
-
|
|
2692
|
+
8
|
|
2670
2693
|
];
|
|
2671
2694
|
return [
|
|
2672
2695
|
4,
|
|
2673
2696
|
reader.read()
|
|
2674
2697
|
];
|
|
2675
|
-
case
|
|
2698
|
+
case 7:
|
|
2676
2699
|
_ref = _state.sent(), done = _ref.done, value = _ref.value;
|
|
2677
2700
|
if (done) return [
|
|
2678
2701
|
3,
|
|
2679
|
-
|
|
2702
|
+
8
|
|
2680
2703
|
];
|
|
2681
2704
|
handleResponse({
|
|
2682
2705
|
value: value,
|
|
@@ -2686,9 +2709,9 @@ var mutationFn = function(param) {
|
|
|
2686
2709
|
});
|
|
2687
2710
|
return [
|
|
2688
2711
|
3,
|
|
2689
|
-
|
|
2712
|
+
6
|
|
2690
2713
|
];
|
|
2691
|
-
case
|
|
2714
|
+
case 8:
|
|
2692
2715
|
return [
|
|
2693
2716
|
2
|
|
2694
2717
|
];
|
|
@@ -3432,34 +3455,118 @@ MessageForm.Root = Root4;
|
|
|
3432
3455
|
MessageForm.Field = Field;
|
|
3433
3456
|
MessageForm.Submit = Submit;
|
|
3434
3457
|
// src/components/threads/Thread/Root/index.tsx
|
|
3435
|
-
import { Flex as
|
|
3458
|
+
import { Flex as Flex22 } from "@radix-ui/themes";
|
|
3436
3459
|
// src/components/threads/Thread/Provider/index.tsx
|
|
3437
3460
|
var Provider2 = SuperinterfaceProvider;
|
|
3461
|
+
// src/components/toasts/ToastsProvider/index.tsx
|
|
3462
|
+
import { useState as useState2, useCallback as useCallback3 } from "react";
|
|
3463
|
+
import * as Toast2 from "@radix-ui/react-toast";
|
|
3464
|
+
// src/components/toasts/ToastsProvider/CustomToast.tsx
|
|
3465
|
+
import * as Toast from "@radix-ui/react-toast";
|
|
3466
|
+
import { Card as Card2, Text as Text7, Flex as Flex21 } from "@radix-ui/themes";
|
|
3467
|
+
import { CheckCircledIcon as CheckCircledIcon2, CrossCircledIcon } from "@radix-ui/react-icons";
|
|
3468
|
+
import { jsx as jsx58, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3469
|
+
var CustomToast = function(param) {
|
|
3470
|
+
var toast = param.toast;
|
|
3471
|
+
return /* @__PURE__ */ jsx58(Toast.Root, {
|
|
3472
|
+
children: /* @__PURE__ */ jsx58(Card2, {
|
|
3473
|
+
children: /* @__PURE__ */ jsx58(Toast.Title, {
|
|
3474
|
+
children: /* @__PURE__ */ jsxs21(Flex21, {
|
|
3475
|
+
children: [
|
|
3476
|
+
/* @__PURE__ */ jsx58(Flex21, {
|
|
3477
|
+
pr: "2",
|
|
3478
|
+
height: "14px",
|
|
3479
|
+
align: "center",
|
|
3480
|
+
children: toast.type === "success" ? /* @__PURE__ */ jsx58(CheckCircledIcon2, {
|
|
3481
|
+
color: "var(--accent-9)"
|
|
3482
|
+
}) : /* @__PURE__ */ jsx58(CrossCircledIcon, {
|
|
3483
|
+
color: "var(--red-9)"
|
|
3484
|
+
})
|
|
3485
|
+
}),
|
|
3486
|
+
/* @__PURE__ */ jsx58(Text7, {
|
|
3487
|
+
weight: "medium",
|
|
3488
|
+
size: "1",
|
|
3489
|
+
children: toast.message
|
|
3490
|
+
})
|
|
3491
|
+
]
|
|
3492
|
+
})
|
|
3493
|
+
})
|
|
3494
|
+
})
|
|
3495
|
+
});
|
|
3496
|
+
};
|
|
3497
|
+
// src/components/toasts/ToastsProvider/index.tsx
|
|
3498
|
+
import { jsx as jsx59, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3499
|
+
var ToastsProvider = function(param) {
|
|
3500
|
+
var children = param.children;
|
|
3501
|
+
var _useState2 = _sliced_to_array(useState2([]), 2), toasts = _useState2[0], setToasts = _useState2[1];
|
|
3502
|
+
var addToast = useCallback3(function(toast) {
|
|
3503
|
+
return setToasts(function(prevToasts) {
|
|
3504
|
+
return _to_consumable_array(prevToasts).concat([
|
|
3505
|
+
toast
|
|
3506
|
+
]);
|
|
3507
|
+
});
|
|
3508
|
+
}, []);
|
|
3509
|
+
return /* @__PURE__ */ jsx59(ToastsContext.Provider, {
|
|
3510
|
+
value: {
|
|
3511
|
+
toasts: toasts,
|
|
3512
|
+
addToast: addToast
|
|
3513
|
+
},
|
|
3514
|
+
children: /* @__PURE__ */ jsxs22(Toast2.Provider, {
|
|
3515
|
+
children: [
|
|
3516
|
+
children,
|
|
3517
|
+
Array.from(toasts).map(function(toast, index) {
|
|
3518
|
+
return /* @__PURE__ */ jsx59(CustomToast, {
|
|
3519
|
+
toast: toast
|
|
3520
|
+
}, index);
|
|
3521
|
+
}),
|
|
3522
|
+
/* @__PURE__ */ jsx59(Toast2.Viewport, {
|
|
3523
|
+
style: {
|
|
3524
|
+
position: "absolute",
|
|
3525
|
+
bottom: "var(--space-9)",
|
|
3526
|
+
right: 0,
|
|
3527
|
+
display: "flex",
|
|
3528
|
+
flexDirection: "column",
|
|
3529
|
+
padding: "var(--space-5)",
|
|
3530
|
+
gap: "var(--space-3)",
|
|
3531
|
+
width: "390px",
|
|
3532
|
+
maxWidth: "100vw",
|
|
3533
|
+
margin: 0,
|
|
3534
|
+
listStyle: "none",
|
|
3535
|
+
zIndex: 99999999999999,
|
|
3536
|
+
outline: "none"
|
|
3537
|
+
}
|
|
3538
|
+
})
|
|
3539
|
+
]
|
|
3540
|
+
})
|
|
3541
|
+
});
|
|
3542
|
+
};
|
|
3438
3543
|
// src/components/threads/Thread/Root/index.tsx
|
|
3439
|
-
import { jsx as
|
|
3440
|
-
var
|
|
3544
|
+
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
3545
|
+
var Root8 = function(_param) {
|
|
3441
3546
|
var children = _param.children, rest = _object_without_properties(_param, [
|
|
3442
3547
|
"children"
|
|
3443
3548
|
]);
|
|
3444
|
-
return /* @__PURE__ */
|
|
3445
|
-
children: /* @__PURE__ */
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3549
|
+
return /* @__PURE__ */ jsx60(ToastsProvider, {
|
|
3550
|
+
children: /* @__PURE__ */ jsx60(Provider2, _object_spread_props(_object_spread({}, rest), {
|
|
3551
|
+
children: /* @__PURE__ */ jsx60(Flex22, {
|
|
3552
|
+
direction: "column",
|
|
3553
|
+
flexGrow: "1",
|
|
3554
|
+
children: children
|
|
3555
|
+
})
|
|
3556
|
+
}))
|
|
3557
|
+
});
|
|
3451
3558
|
};
|
|
3452
3559
|
// src/components/threads/Thread/index.tsx
|
|
3453
|
-
import { jsx as
|
|
3560
|
+
import { jsx as jsx61, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3454
3561
|
var Thread = function(props) {
|
|
3455
|
-
return /* @__PURE__ */
|
|
3562
|
+
return /* @__PURE__ */ jsxs23(Root8, _object_spread_props(_object_spread({}, props), {
|
|
3456
3563
|
children: [
|
|
3457
|
-
/* @__PURE__ */
|
|
3458
|
-
/* @__PURE__ */
|
|
3564
|
+
/* @__PURE__ */ jsx61(Messages, {}),
|
|
3565
|
+
/* @__PURE__ */ jsx61(MessageForm, {})
|
|
3459
3566
|
]
|
|
3460
3567
|
}));
|
|
3461
3568
|
};
|
|
3462
|
-
Thread.Root =
|
|
3569
|
+
Thread.Root = Root8;
|
|
3463
3570
|
Thread.Messages = Messages;
|
|
3464
3571
|
Thread.MessageForm = MessageForm;
|
|
3465
3572
|
// src/hooks/messages/useMessageContext/index.ts
|
|
@@ -3566,7 +3673,7 @@ var useAssistant = function(param) {
|
|
|
3566
3673
|
]);
|
|
3567
3674
|
};
|
|
3568
3675
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
3569
|
-
import { useState as
|
|
3676
|
+
import { useState as useState3 } from "react";
|
|
3570
3677
|
// src/contexts/threads/ThreadDialogContext/index.ts
|
|
3571
3678
|
import { createContext as createContext11 } from "react";
|
|
3572
3679
|
var ThreadDialogContext = createContext11({
|
|
@@ -3579,12 +3686,12 @@ var useThreadDialogContext = function() {
|
|
|
3579
3686
|
return useContext13(ThreadDialogContext);
|
|
3580
3687
|
};
|
|
3581
3688
|
// src/components/threads/ThreadDialog/Provider/index.tsx
|
|
3582
|
-
import { jsx as
|
|
3583
|
-
var
|
|
3689
|
+
import { jsx as jsx62 } from "react/jsx-runtime";
|
|
3690
|
+
var Provider4 = function(param) {
|
|
3584
3691
|
var children = param.children;
|
|
3585
3692
|
var threadDialogContext = useThreadDialogContext();
|
|
3586
|
-
var
|
|
3587
|
-
return /* @__PURE__ */
|
|
3693
|
+
var _useState3 = _sliced_to_array(useState3(threadDialogContext.isOpen), 2), isOpen = _useState3[0], setIsOpen = _useState3[1];
|
|
3694
|
+
return /* @__PURE__ */ jsx62(ThreadDialogContext.Provider, {
|
|
3588
3695
|
value: {
|
|
3589
3696
|
isOpen: isOpen,
|
|
3590
3697
|
setIsOpen: setIsOpen
|
|
@@ -3592,96 +3699,12 @@ var Provider3 = function(param) {
|
|
|
3592
3699
|
children: children
|
|
3593
3700
|
});
|
|
3594
3701
|
};
|
|
3595
|
-
// src/components/toasts/ToastsProvider/index.tsx
|
|
3596
|
-
import { useState as useState3, useCallback as useCallback3 } from "react";
|
|
3597
|
-
import * as Toast2 from "@radix-ui/react-toast";
|
|
3598
|
-
// src/components/toasts/ToastsProvider/CustomToast.tsx
|
|
3599
|
-
import * as Toast from "@radix-ui/react-toast";
|
|
3600
|
-
import { Card as Card2, Text as Text7, Flex as Flex22 } from "@radix-ui/themes";
|
|
3601
|
-
import { CheckCircledIcon as CheckCircledIcon2, CrossCircledIcon } from "@radix-ui/react-icons";
|
|
3602
|
-
import { jsx as jsx61, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3603
|
-
var CustomToast = function(param) {
|
|
3604
|
-
var toast = param.toast;
|
|
3605
|
-
return /* @__PURE__ */ jsx61(Toast.Root, {
|
|
3606
|
-
children: /* @__PURE__ */ jsx61(Card2, {
|
|
3607
|
-
children: /* @__PURE__ */ jsx61(Toast.Title, {
|
|
3608
|
-
children: /* @__PURE__ */ jsxs22(Flex22, {
|
|
3609
|
-
children: [
|
|
3610
|
-
/* @__PURE__ */ jsx61(Flex22, {
|
|
3611
|
-
pr: "2",
|
|
3612
|
-
height: "14px",
|
|
3613
|
-
align: "center",
|
|
3614
|
-
children: toast.type === "success" ? /* @__PURE__ */ jsx61(CheckCircledIcon2, {
|
|
3615
|
-
color: "var(--accent-9)"
|
|
3616
|
-
}) : /* @__PURE__ */ jsx61(CrossCircledIcon, {
|
|
3617
|
-
color: "var(--red-9)"
|
|
3618
|
-
})
|
|
3619
|
-
}),
|
|
3620
|
-
/* @__PURE__ */ jsx61(Text7, {
|
|
3621
|
-
weight: "medium",
|
|
3622
|
-
size: "1",
|
|
3623
|
-
children: toast.message
|
|
3624
|
-
})
|
|
3625
|
-
]
|
|
3626
|
-
})
|
|
3627
|
-
})
|
|
3628
|
-
})
|
|
3629
|
-
});
|
|
3630
|
-
};
|
|
3631
|
-
// src/components/toasts/ToastsProvider/index.tsx
|
|
3632
|
-
import { jsx as jsx62, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3633
|
-
var ToastsProvider = function(param) {
|
|
3634
|
-
var children = param.children;
|
|
3635
|
-
var _useState3 = _sliced_to_array(useState3([]), 2), toasts = _useState3[0], setToasts = _useState3[1];
|
|
3636
|
-
var addToast = useCallback3(function(toast) {
|
|
3637
|
-
return setToasts(function(prevToasts) {
|
|
3638
|
-
return _to_consumable_array(prevToasts).concat([
|
|
3639
|
-
toast
|
|
3640
|
-
]);
|
|
3641
|
-
});
|
|
3642
|
-
}, []);
|
|
3643
|
-
return /* @__PURE__ */ jsx62(ToastsContext.Provider, {
|
|
3644
|
-
value: {
|
|
3645
|
-
toasts: toasts,
|
|
3646
|
-
addToast: addToast
|
|
3647
|
-
},
|
|
3648
|
-
children: /* @__PURE__ */ jsxs23(Toast2.Provider, {
|
|
3649
|
-
children: [
|
|
3650
|
-
children,
|
|
3651
|
-
Array.from(toasts).map(function(toast, index) {
|
|
3652
|
-
return /* @__PURE__ */ jsx62(CustomToast, {
|
|
3653
|
-
toast: toast
|
|
3654
|
-
}, index);
|
|
3655
|
-
}),
|
|
3656
|
-
/* @__PURE__ */ jsx62(Toast2.Viewport, {
|
|
3657
|
-
style: {
|
|
3658
|
-
position: "absolute",
|
|
3659
|
-
bottom: 0,
|
|
3660
|
-
right: 0,
|
|
3661
|
-
display: "flex",
|
|
3662
|
-
flexDirection: "column",
|
|
3663
|
-
padding: "var(--space-5)",
|
|
3664
|
-
gap: "var(--space-3)",
|
|
3665
|
-
width: "390px",
|
|
3666
|
-
maxWidth: "100vw",
|
|
3667
|
-
margin: 0,
|
|
3668
|
-
listStyle: "none",
|
|
3669
|
-
zIndex: 99999999999999,
|
|
3670
|
-
outline: "none"
|
|
3671
|
-
}
|
|
3672
|
-
})
|
|
3673
|
-
]
|
|
3674
|
-
})
|
|
3675
|
-
});
|
|
3676
|
-
};
|
|
3677
3702
|
// src/components/threads/ThreadDialog/Root/index.tsx
|
|
3678
3703
|
import { jsx as jsx63 } from "react/jsx-runtime";
|
|
3679
3704
|
var Root9 = function(param) {
|
|
3680
3705
|
var children = param.children;
|
|
3681
|
-
return /* @__PURE__ */ jsx63(
|
|
3682
|
-
children:
|
|
3683
|
-
children: children
|
|
3684
|
-
})
|
|
3706
|
+
return /* @__PURE__ */ jsx63(Provider4, {
|
|
3707
|
+
children: children
|
|
3685
3708
|
});
|
|
3686
3709
|
};
|
|
3687
3710
|
// src/components/threads/ThreadDialog/Trigger/index.tsx
|