@superinterface/react 2.16.1 → 2.16.3

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
@@ -10,6 +10,47 @@ function _array_with_holes(arr) {
10
10
  function _array_without_holes(arr) {
11
11
  if (Array.isArray(arr)) return _array_like_to_array(arr);
12
12
  }
13
+ function _async_iterator(iterable) {
14
+ var method, async, sync, retry = 2;
15
+ for("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;){
16
+ if (async && null != (method = iterable[async])) return method.call(iterable);
17
+ if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
18
+ async = "@@asyncIterator", sync = "@@iterator";
19
+ }
20
+ throw new TypeError("Object is not async iterable");
21
+ }
22
+ function AsyncFromSyncIterator(s) {
23
+ function AsyncFromSyncIteratorContinuation(r) {
24
+ if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
25
+ var done = r.done;
26
+ return Promise.resolve(r.value).then(function(value) {
27
+ return {
28
+ value: value,
29
+ done: done
30
+ };
31
+ });
32
+ }
33
+ return AsyncFromSyncIterator = function(s) {
34
+ this.s = s, this.n = s.next;
35
+ }, AsyncFromSyncIterator.prototype = {
36
+ s: null,
37
+ n: null,
38
+ next: function() {
39
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
40
+ },
41
+ return: function(value) {
42
+ var ret = this.s.return;
43
+ return void 0 === ret ? Promise.resolve({
44
+ value: value,
45
+ done: !0
46
+ }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
47
+ },
48
+ throw: function(value) {
49
+ var thr = this.s.return;
50
+ return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
51
+ }
52
+ }, new AsyncFromSyncIterator(s);
53
+ }
13
54
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
55
  try {
15
56
  var info = gen[key](arg);
@@ -263,6 +304,20 @@ function _ts_generator(thisArg, body) {
263
304
  };
264
305
  }
265
306
  }
307
+ function _ts_values(o) {
308
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
309
+ if (m) return m.call(o);
310
+ if (o && typeof o.length === "number") return {
311
+ next: function() {
312
+ if (o && i >= o.length) o = void 0;
313
+ return {
314
+ value: o && o[i++],
315
+ done: !o
316
+ };
317
+ }
318
+ };
319
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
320
+ }
266
321
  var _2;
267
322
  var _detect;
268
323
  import { useRef } from "react";
@@ -767,11 +822,13 @@ var FunctionComponentsContext = createContext6({});
767
822
  // src/components/functions/FunctionBase/index.tsx
768
823
  import { Popover } from "@radix-ui/themes";
769
824
  // src/components/toolCalls/ToolCallBase/index.tsx
825
+ import { forwardRef as forwardRef3 } from "react";
770
826
  import { Flex as Flex6, Button } from "@radix-ui/themes";
771
827
  import { jsx as jsx10 } from "react/jsx-runtime";
772
- var ToolCallBase = function(param) {
828
+ var ToolCallBase = forwardRef3(function ToolCallBase2(param, ref) {
773
829
  var children = param.children;
774
830
  return /* @__PURE__ */ jsx10(Flex6, {
831
+ ref: ref,
775
832
  py: "1",
776
833
  ml: "-2",
777
834
  children: /* @__PURE__ */ jsx10(Button, {
@@ -784,7 +841,7 @@ var ToolCallBase = function(param) {
784
841
  children: children
785
842
  })
786
843
  });
787
- };
844
+ });
788
845
  // src/components/toolCalls/ToolCallBase/ToolCallTitle.tsx
789
846
  import { Text as Text2 } from "@radix-ui/themes";
790
847
  import { jsx as jsx11 } from "react/jsx-runtime";
@@ -2430,10 +2487,10 @@ import { useFormContext } from "react-hook-form";
2430
2487
  import { usePrevious } from "react-use";
2431
2488
  import { useContext as useContext11, useMemo as useMemo9, useRef as useRef4, useEffect as useEffect3 } from "react";
2432
2489
  // src/components/textareas/TextareaBase/index.tsx
2433
- import { forwardRef as forwardRef3 } from "react";
2490
+ import { forwardRef as forwardRef4 } from "react";
2434
2491
  import TextareaAutosize from "react-textarea-autosize";
2435
2492
  import { Fragment as Fragment3, jsx as jsx47, jsxs as jsxs15 } from "react/jsx-runtime";
2436
- var TextareaBase = forwardRef3(function TextareaBase2(props, ref) {
2493
+ var TextareaBase = forwardRef4(function TextareaBase2(props, ref) {
2437
2494
  return /* @__PURE__ */ jsxs15(Fragment3, {
2438
2495
  children: [
2439
2496
  /* @__PURE__ */ jsx47("style", {
@@ -2584,6 +2641,7 @@ var Preview = function() {
2584
2641
  };
2585
2642
  // src/components/threads/Thread/MessageForm/Field/Files/Control.tsx
2586
2643
  import { useCallback as useCallback2 } from "react";
2644
+ import { omit as omit4 } from "radash";
2587
2645
  import dayjs2 from "dayjs";
2588
2646
  import { FilePlusIcon } from "@radix-ui/react-icons";
2589
2647
  import { IconButton as IconButton3, Flex as Flex16 } from "@radix-ui/themes";
@@ -2703,50 +2761,174 @@ var Control2 = function() {
2703
2761
  var _useMessageFormContext = useMessageFormContext(), isDisabled = _useMessageFormContext.isDisabled, isLoading = _useMessageFormContext.isLoading, setFiles = _useMessageFormContext.setFiles;
2704
2762
  var createFile = useCreateFile().createFile;
2705
2763
  var addToast = useToasts().addToast;
2706
- var onChange = useCallback2(function(event) {
2707
- var files = event.target.files;
2708
- if (!files) return;
2709
- var newFiles = Array.from(files).map(function(file) {
2710
- var id = optimisticId();
2711
- createFile({
2712
- file: file
2713
- }, {
2714
- onSuccess: function(param) {
2715
- var file2 = param.file;
2716
- setFiles(function(prev) {
2717
- return _to_consumable_array(prev.filter(function(prevFile) {
2718
- return prevFile.id !== id;
2719
- })).concat([
2720
- file2
2721
- ]);
2722
- });
2723
- },
2724
- onError: function() {
2725
- addToast({
2726
- type: "error",
2727
- message: "Could not upload file. Please try again."
2728
- });
2729
- setFiles(function(prev) {
2730
- return prev.filter(function(prevFile) {
2731
- return prevFile.id !== id;
2764
+ var onChange = useCallback2(function() {
2765
+ var _ref = _async_to_generator(function(event) {
2766
+ var fileObjects, newFiles, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, err;
2767
+ return _ts_generator(this, function(_state) {
2768
+ switch(_state.label){
2769
+ case 0:
2770
+ fileObjects = event.target.files;
2771
+ if (!fileObjects) return [
2772
+ 2
2773
+ ];
2774
+ newFiles = Array.from(fileObjects).map(function(fileObject) {
2775
+ return {
2776
+ id: optimisticId(),
2777
+ filename: fileObject.name,
2778
+ object: "file",
2779
+ purpose: "assistants",
2780
+ created_at: dayjs2().unix(),
2781
+ bytes: fileObject.size,
2782
+ status: "processed",
2783
+ fileObject: fileObject
2784
+ };
2785
+ });
2786
+ setFiles(function(prev) {
2787
+ return _to_consumable_array(prev).concat(_to_consumable_array(newFiles.map(function(file) {
2788
+ return omit4(file, [
2789
+ "fileObject"
2790
+ ]);
2791
+ })));
2732
2792
  });
2733
- });
2793
+ _iteratorAbruptCompletion = false, _didIteratorError = false;
2794
+ _state.label = 1;
2795
+ case 1:
2796
+ _state.trys.push([
2797
+ 1,
2798
+ 7,
2799
+ 8,
2800
+ 13
2801
+ ]);
2802
+ _loop = function() {
2803
+ var _value, newFile;
2804
+ return _ts_generator(this, function(_state) {
2805
+ switch(_state.label){
2806
+ case 0:
2807
+ _value = _step.value;
2808
+ newFile = _value;
2809
+ return [
2810
+ 4,
2811
+ createFile({
2812
+ file: newFile.fileObject
2813
+ }, {
2814
+ onSuccess: function(param) {
2815
+ var file = param.file;
2816
+ return setFiles(function(prev) {
2817
+ return _to_consumable_array(prev.filter(function(prevFile) {
2818
+ return prevFile.id !== newFile.id;
2819
+ })).concat([
2820
+ file
2821
+ ]);
2822
+ });
2823
+ },
2824
+ onError: function() {
2825
+ addToast({
2826
+ type: "error",
2827
+ message: "Could not upload file. Please try again."
2828
+ });
2829
+ setFiles(function(prev) {
2830
+ return prev.filter(function(prevFile) {
2831
+ return prevFile.id !== newFile.id;
2832
+ });
2833
+ });
2834
+ }
2835
+ })
2836
+ ];
2837
+ case 1:
2838
+ _state.sent();
2839
+ return [
2840
+ 2
2841
+ ];
2842
+ }
2843
+ });
2844
+ };
2845
+ _iterator = _async_iterator(newFiles);
2846
+ _state.label = 2;
2847
+ case 2:
2848
+ return [
2849
+ 4,
2850
+ _iterator.next()
2851
+ ];
2852
+ case 3:
2853
+ if (!(_iteratorAbruptCompletion = !(_step = _state.sent()).done)) return [
2854
+ 3,
2855
+ 6
2856
+ ];
2857
+ return [
2858
+ 5,
2859
+ _ts_values(_loop())
2860
+ ];
2861
+ case 4:
2862
+ _state.sent();
2863
+ _state.label = 5;
2864
+ case 5:
2865
+ _iteratorAbruptCompletion = false;
2866
+ return [
2867
+ 3,
2868
+ 2
2869
+ ];
2870
+ case 6:
2871
+ return [
2872
+ 3,
2873
+ 13
2874
+ ];
2875
+ case 7:
2876
+ err = _state.sent();
2877
+ _didIteratorError = true;
2878
+ _iteratorError = err;
2879
+ return [
2880
+ 3,
2881
+ 13
2882
+ ];
2883
+ case 8:
2884
+ _state.trys.push([
2885
+ 8,
2886
+ ,
2887
+ 11,
2888
+ 12
2889
+ ]);
2890
+ if (!(_iteratorAbruptCompletion && _iterator.return != null)) return [
2891
+ 3,
2892
+ 10
2893
+ ];
2894
+ return [
2895
+ 4,
2896
+ _iterator.return()
2897
+ ];
2898
+ case 9:
2899
+ _state.sent();
2900
+ _state.label = 10;
2901
+ case 10:
2902
+ return [
2903
+ 3,
2904
+ 12
2905
+ ];
2906
+ case 11:
2907
+ if (_didIteratorError) {
2908
+ throw _iteratorError;
2909
+ }
2910
+ return [
2911
+ 7
2912
+ ];
2913
+ case 12:
2914
+ return [
2915
+ 7
2916
+ ];
2917
+ case 13:
2918
+ return [
2919
+ 2
2920
+ ];
2734
2921
  }
2735
2922
  });
2736
- return {
2737
- id: id,
2738
- filename: file.name,
2739
- object: "file",
2740
- purpose: "assistants",
2741
- created_at: dayjs2().unix(),
2742
- bytes: file.size,
2743
- status: "processed"
2744
- };
2745
2923
  });
2746
- setFiles(function(prev) {
2747
- return _to_consumable_array(prev).concat(_to_consumable_array(newFiles));
2748
- });
2749
- }, []);
2924
+ return function(event) {
2925
+ return _ref.apply(this, arguments);
2926
+ };
2927
+ }(), [
2928
+ addToast,
2929
+ createFile,
2930
+ setFiles
2931
+ ]);
2750
2932
  return /* @__PURE__ */ jsx50(Flex16, {
2751
2933
  pt: "2",
2752
2934
  pr: "2",
@@ -2764,6 +2946,7 @@ var Control2 = function() {
2764
2946
  /* @__PURE__ */ jsx50(FilePlusIcon, {}),
2765
2947
  /* @__PURE__ */ jsx50("input", {
2766
2948
  type: "file",
2949
+ multiple: true,
2767
2950
  accept: accept,
2768
2951
  onChange: onChange,
2769
2952
  style: {