@upstash/react-redis-browser 0.1.2-canary-4 → 0.1.2-canary-6

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
@@ -2891,6 +2891,12 @@ function Toaster() {
2891
2891
 
2892
2892
 
2893
2893
 
2894
+
2895
+
2896
+
2897
+
2898
+
2899
+
2894
2900
  // src/components/databrowser/hooks/use-fetch-keys.ts
2895
2901
 
2896
2902
 
@@ -2908,35 +2914,28 @@ var DATA_TYPE_NAMES = {
2908
2914
 
2909
2915
  // src/components/databrowser/hooks/use-fetch-keys.ts
2910
2916
  var PAGE_SIZE = 30;
2911
- var INITIAL_FETCH_COUNT = 100;
2912
- var MAX_FETCH_COUNT = 1e3;
2917
+ var FETCH_COUNTS = [100, 200, 400, 800];
2913
2918
  var useFetchKeys = (search) => {
2914
2919
  const { redis } = useDatabrowser();
2915
2920
  const cache = _react.useRef.call(void 0, );
2916
2921
  const lastKey = _react.useRef.call(void 0, );
2917
- const getPage = _react.useCallback.call(void 0,
2918
- (page) => {
2919
- const newKey = JSON.stringify(search);
2920
- if (!cache.current || lastKey.current !== newKey) {
2921
- cache.current = new PaginationCache(redis, search.key, search.type);
2922
- lastKey.current = newKey;
2923
- }
2924
- return cache.current.getPage(page);
2925
- },
2926
- [search]
2927
- );
2922
+ const fetchKeys = _react.useCallback.call(void 0, () => {
2923
+ const newKey = JSON.stringify(search);
2924
+ if (!cache.current || lastKey.current !== newKey) {
2925
+ cache.current = new PaginationCache(redis, search.key, search.type);
2926
+ lastKey.current = newKey;
2927
+ }
2928
+ return cache.current.fetchNewKeys();
2929
+ }, [search]);
2928
2930
  const resetCache = _react.useCallback.call(void 0, () => {
2929
2931
  cache.current = void 0;
2930
2932
  lastKey.current = void 0;
2931
2933
  }, []);
2932
2934
  return {
2933
- getPage,
2935
+ fetchKeys,
2934
2936
  resetCache
2935
2937
  };
2936
2938
  };
2937
- function slicePage(keys, page) {
2938
- return keys.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE);
2939
- }
2940
2939
  var PaginationCache = (_class = class {
2941
2940
  constructor(redis, searchTerm, typeFilter) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
2942
2941
  this.redis = redis;
@@ -2952,8 +2951,9 @@ var PaginationCache = (_class = class {
2952
2951
  )}
2953
2952
  __init2() {this.targetCount = 0}
2954
2953
  __init3() {this.isFetching = false}
2955
- async getPage(page) {
2956
- this.targetCount = (page + 1) * PAGE_SIZE + 1;
2954
+ async fetchNewKeys() {
2955
+ const initialKeys = new Set(this.getKeys().map(([key]) => key));
2956
+ this.targetCount = this.getKeys().length + PAGE_SIZE;
2957
2957
  void this.startFetch();
2958
2958
  await new Promise((resolve) => {
2959
2959
  const interval = setInterval(() => {
@@ -2963,10 +2963,9 @@ var PaginationCache = (_class = class {
2963
2963
  }
2964
2964
  }, 100);
2965
2965
  });
2966
- const hasEnoughForNextPage = this.getLength() > (page + 1) * PAGE_SIZE;
2967
- const hasNextPage = !this.isAllEnded() || hasEnoughForNextPage;
2966
+ const hasNextPage = !this.isAllEnded();
2968
2967
  return {
2969
- keys: slicePage(this.getKeys(), page),
2968
+ keys: this.getKeys().filter(([key]) => !initialKeys.has(key)),
2970
2969
  hasNextPage
2971
2970
  };
2972
2971
  }
@@ -2992,33 +2991,29 @@ var PaginationCache = (_class = class {
2992
2991
  }
2993
2992
  }
2994
2993
  __init4() {this.fetchForType = async (type) => {
2995
- let fetchCount = INITIAL_FETCH_COUNT;
2994
+ let i = 0;
2996
2995
  while (true) {
2997
2996
  const cursor = this.cache[type].cursor;
2998
2997
  if (cursor === "-1" || this.getLength() >= this.targetCount) {
2999
2998
  break;
3000
2999
  }
3000
+ const fetchCount = FETCH_COUNTS[Math.min(i, FETCH_COUNTS.length - 1)];
3001
3001
  const [nextCursor, newKeys] = await this.redis.scan(cursor, {
3002
3002
  count: fetchCount,
3003
3003
  match: this.searchTerm,
3004
3004
  type
3005
3005
  });
3006
- fetchCount = Math.min(fetchCount * 2, MAX_FETCH_COUNT);
3007
- const dedupedSet = /* @__PURE__ */ new Set([...this.cache[type].keys, ...newKeys]);
3008
- this.cache[type].keys = [...dedupedSet];
3006
+ this.cache[type].keys = [...this.cache[type].keys, ...newKeys];
3009
3007
  this.cache[type].cursor = nextCursor === "0" ? "-1" : nextCursor;
3008
+ i++;
3010
3009
  }
3011
3010
  }}
3012
3011
  async fetch() {
3013
3012
  const types = this.typeFilter ? [this.typeFilter] : DATA_TYPES;
3014
3013
  await Promise.all(types.map(this.fetchForType));
3015
3014
  }
3016
- // TODO: Yusuf, implement this function
3017
3015
  isAllEnded() {
3018
3016
  const types = this.typeFilter ? [this.typeFilter] : DATA_TYPES;
3019
- if (!Array.isArray(types)) {
3020
- throw new TypeError("types is not an array");
3021
- }
3022
3017
  return types.every((type) => this.cache[type] && this.cache[type].cursor === "-1");
3023
3018
  }
3024
3019
  }, _class);
@@ -3036,17 +3031,21 @@ var KeysProvider = ({ children }) => {
3036
3031
  }),
3037
3032
  [searchState]
3038
3033
  );
3039
- const { getPage, resetCache } = useFetchKeys(search);
3034
+ const { fetchKeys, resetCache } = useFetchKeys(search);
3035
+ const pageRef = _react.useRef.call(void 0, 0);
3040
3036
  const query = _reactquery.useInfiniteQuery.call(void 0, {
3041
3037
  queryKey: [FETCH_KEYS_QUERY_KEY, search],
3042
3038
  initialPageParam: 0,
3043
- queryFn: async ({ pageParam: pageIndex }) => {
3044
- return getPage(pageIndex);
3039
+ queryFn: async ({ pageParam: page }) => {
3040
+ if (pageRef.current > page) resetCache();
3041
+ pageRef.current = page;
3042
+ return await fetchKeys();
3045
3043
  },
3046
3044
  select: (data) => data,
3047
3045
  getNextPageParam: (lastPage, __, lastPageIndex) => {
3048
3046
  return lastPage.hasNextPage ? lastPageIndex + 1 : void 0;
3049
- }
3047
+ },
3048
+ refetchOnMount: false
3050
3049
  });
3051
3050
  const refetch = _react.useCallback.call(void 0, () => {
3052
3051
  resetCache();
@@ -3054,8 +3053,14 @@ var KeysProvider = ({ children }) => {
3054
3053
  }, [query, resetCache]);
3055
3054
  const keys = _react.useMemo.call(void 0, () => {
3056
3055
  const keys2 = _nullishCoalesce(_optionalChain([query, 'access', _10 => _10.data, 'optionalAccess', _11 => _11.pages, 'access', _12 => _12.flatMap, 'call', _13 => _13((page) => page.keys)]), () => ( []));
3057
- const keysSet = new Set(keys2.map(([key, _]) => key));
3058
- return keys2.filter(([key, _]) => keysSet.has(key));
3056
+ const keysSet = /* @__PURE__ */ new Set();
3057
+ const dedupedKeys = [];
3058
+ for (const key of keys2) {
3059
+ if (keysSet.has(key[0])) continue;
3060
+ keysSet.add(key[0]);
3061
+ dedupedKeys.push(key);
3062
+ }
3063
+ return dedupedKeys;
3059
3064
  }, [query.data]);
3060
3065
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3061
3066
  KeysContext.Provider,
@@ -3320,7 +3325,7 @@ var useFetchListItems = ({ dataKey, type }) => {
3320
3325
  count: LIST_DISPLAY_PAGE_SIZE
3321
3326
  });
3322
3327
  return {
3323
- cursor: nextCursor,
3328
+ cursor: nextCursor === "0" ? void 0 : nextCursor,
3324
3329
  keys: keys.map((key) => ({ key }))
3325
3330
  };
3326
3331
  },
@@ -3336,7 +3341,7 @@ var useFetchListItems = ({ dataKey, type }) => {
3336
3341
  rev: true
3337
3342
  });
3338
3343
  return {
3339
- cursor: lastIndex + LIST_DISPLAY_PAGE_SIZE,
3344
+ cursor: res.length < LIST_DISPLAY_PAGE_SIZE ? void 0 : lastIndex + LIST_DISPLAY_PAGE_SIZE,
3340
3345
  keys: transformArray(res)
3341
3346
  };
3342
3347
  },
@@ -3351,7 +3356,7 @@ var useFetchListItems = ({ dataKey, type }) => {
3351
3356
  count: LIST_DISPLAY_PAGE_SIZE
3352
3357
  });
3353
3358
  return {
3354
- cursor: res[0],
3359
+ cursor: res[0] === "0" ? void 0 : res[0],
3355
3360
  keys: transformArray(res[1])
3356
3361
  };
3357
3362
  },
@@ -3365,7 +3370,7 @@ var useFetchListItems = ({ dataKey, type }) => {
3365
3370
  const lastIndex = Number(pageParam);
3366
3371
  const values = await redis.lrange(dataKey, lastIndex, lastIndex + LIST_DISPLAY_PAGE_SIZE);
3367
3372
  return {
3368
- cursor: lastIndex + LIST_DISPLAY_PAGE_SIZE,
3373
+ cursor: values.length < LIST_DISPLAY_PAGE_SIZE ? void 0 : lastIndex + LIST_DISPLAY_PAGE_SIZE,
3369
3374
  keys: values.map((value, i) => ({
3370
3375
  key: (lastIndex + i).toString(),
3371
3376
  value
@@ -3377,17 +3382,18 @@ var useFetchListItems = ({ dataKey, type }) => {
3377
3382
  const streamQuery = _reactquery.useInfiniteQuery.call(void 0, {
3378
3383
  enabled: type === "stream",
3379
3384
  queryKey: [FETCH_LIST_ITEMS_QUERY_KEY, dataKey, "stream"],
3380
- initialPageParam: "0",
3385
+ initialPageParam: "-",
3381
3386
  queryFn: async ({ pageParam: lastId }) => {
3382
3387
  const messages = await redis.xrange(
3383
3388
  dataKey,
3384
- lastId,
3389
+ lastId === "-" ? "-" : `(${lastId}`,
3385
3390
  "+",
3386
- LIST_DISPLAY_PAGE_SIZE
3391
+ // +1 since first message is the last one
3392
+ LIST_DISPLAY_PAGE_SIZE + 1
3387
3393
  );
3388
3394
  const lastMessageId = messages.length > 0 ? _optionalChain([messages, 'access', _15 => _15.at, 'call', _16 => _16(-1), 'optionalAccess', _17 => _17[0]]) : void 0;
3389
3395
  return {
3390
- cursor: lastMessageId,
3396
+ cursor: messages.length < LIST_DISPLAY_PAGE_SIZE ? void 0 : lastMessageId,
3391
3397
  keys: messages.map(([id, fields]) => ({
3392
3398
  key: id,
3393
3399
  value: fields.join("\n")
@@ -3790,30 +3796,30 @@ function DeleteAlertDialog({
3790
3796
  children,
3791
3797
  onDeleteConfirm,
3792
3798
  open,
3793
- onOpenChange
3799
+ onOpenChange,
3800
+ deletionType
3794
3801
  }) {
3795
3802
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AlertDialog, { open, onOpenChange, children: [
3796
3803
  children && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertDialogTrigger, { asChild: true, children }),
3797
3804
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AlertDialogContent, { children: [
3798
3805
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AlertDialogHeader, { children: [
3799
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertDialogTitle, { children: "Irreversible Action!" }),
3806
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertDialogTitle, { children: deletionType === "item" ? "Delete Item" : "Delete Key" }),
3800
3807
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AlertDialogDescription, { className: "mt-5", children: [
3801
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-bold", children: "This action CANNOT BE UNDONE." }),
3802
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "br", {}),
3808
+ "Are you sure you want to delete this ",
3809
+ deletionType,
3810
+ "?",
3803
3811
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "br", {}),
3804
- "By proceeding, you will ",
3805
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-bold", children: "PERMANENTLY REMOVE" }),
3806
- " your data from our servers, resulting in complete and irreversible loss of your information."
3812
+ "This action cannot be undone."
3807
3813
  ] })
3808
3814
  ] }),
3809
3815
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AlertDialogFooter, { children: [
3810
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertDialogCancel, { children: "Cancel" }),
3816
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertDialogCancel, { type: "button", children: "Cancel" }),
3811
3817
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3812
3818
  AlertDialogAction,
3813
3819
  {
3814
3820
  className: "bg-red-500 text-gray-50 hover:bg-red-600",
3815
3821
  onClick: onDeleteConfirm,
3816
- children: "Delete"
3822
+ children: "Yes, Delete"
3817
3823
  }
3818
3824
  )
3819
3825
  ] })
@@ -3826,39 +3832,60 @@ function DeleteAlertDialog({
3826
3832
  var ItemContextMenu = ({
3827
3833
  children,
3828
3834
  dataKey,
3829
- itemKey,
3830
- itemValue,
3831
3835
  type
3832
3836
  }) => {
3833
3837
  const { mutate: editItem } = useEditListItem();
3834
3838
  const [isAlertOpen, setAlertOpen] = _react.useState.call(void 0, false);
3839
+ const [data, setData] = _react.useState.call(void 0, );
3835
3840
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3836
3841
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3837
3842
  DeleteAlertDialog,
3838
3843
  {
3844
+ deletionType: "item",
3839
3845
  open: isAlertOpen,
3840
3846
  onOpenChange: setAlertOpen,
3841
3847
  onDeleteConfirm: (e) => {
3842
3848
  e.stopPropagation();
3843
- editItem({
3844
- type,
3845
- dataKey,
3846
- itemKey,
3847
- // For deletion
3848
- newKey: void 0
3849
- });
3849
+ if (data) {
3850
+ editItem({
3851
+ type,
3852
+ dataKey,
3853
+ itemKey: _optionalChain([data, 'optionalAccess', _20 => _20.key]),
3854
+ // For deletion
3855
+ newKey: void 0
3856
+ });
3857
+ }
3850
3858
  setAlertOpen(false);
3851
3859
  }
3852
3860
  }
3853
3861
  ),
3854
3862
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ContextMenu, { children: [
3855
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContextMenuTrigger, { asChild: true, children }),
3863
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3864
+ ContextMenuTrigger,
3865
+ {
3866
+ asChild: true,
3867
+ onContextMenu: (e) => {
3868
+ const el = e.target;
3869
+ const item = el.closest("[data-item-key]");
3870
+ if (item && item instanceof HTMLElement && item.dataset.itemKey !== void 0) {
3871
+ setData({
3872
+ key: item.dataset.itemKey,
3873
+ value: item.dataset.itemValue
3874
+ });
3875
+ } else {
3876
+ throw new Error("Key not found");
3877
+ }
3878
+ },
3879
+ children
3880
+ }
3881
+ ),
3856
3882
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ContextMenuContent, { children: [
3857
3883
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3858
3884
  ContextMenuItem,
3859
3885
  {
3860
3886
  onClick: () => {
3861
- navigator.clipboard.writeText(itemKey);
3887
+ if (!data) return;
3888
+ navigator.clipboard.writeText(_optionalChain([data, 'optionalAccess', _21 => _21.key]));
3862
3889
  toast({
3863
3890
  description: "Key copied to clipboard"
3864
3891
  });
@@ -3866,11 +3893,11 @@ var ItemContextMenu = ({
3866
3893
  children: "Copy key"
3867
3894
  }
3868
3895
  ),
3869
- itemValue !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3896
+ _optionalChain([data, 'optionalAccess', _22 => _22.value]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3870
3897
  ContextMenuItem,
3871
3898
  {
3872
3899
  onClick: () => {
3873
- navigator.clipboard.writeText(itemValue);
3900
+ navigator.clipboard.writeText(_nullishCoalesce(_optionalChain([data, 'optionalAccess', _23 => _23.value]), () => ( "")));
3874
3901
  toast({
3875
3902
  description: "Value copied to clipboard"
3876
3903
  });
@@ -4362,7 +4389,7 @@ var LengthBadge = ({
4362
4389
  content
4363
4390
  }) => {
4364
4391
  const { data, isLoading } = useFetchKeyLength({ dataKey, type });
4365
- const length = _nullishCoalesce(_optionalChain([content, 'optionalAccess', _20 => _20.length]), () => ( data));
4392
+ const length = _nullishCoalesce(_optionalChain([content, 'optionalAccess', _24 => _24.length]), () => ( data));
4366
4393
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Badge, { label: "Length:", children: isLoading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Skeleton, { className: "ml-1 h-3 w-10 rounded-md opacity-50" }) : length });
4367
4394
  };
4368
4395
  var SizeBadge = ({ dataKey }) => {
@@ -4540,7 +4567,7 @@ function KeyActions({ dataKey, content }) {
4540
4567
  children: "Copy content"
4541
4568
  }
4542
4569
  ),
4543
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DeleteAlertDialog, { onDeleteConfirm: async () => await deleteKey(dataKey), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DropdownMenuItem, { onSelect: (e) => e.preventDefault(), children: "Delete key" }) })
4570
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DeleteAlertDialog, { deletionType: "key", onDeleteConfirm: async () => await deleteKey(dataKey), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DropdownMenuItem, { onSelect: (e) => e.preventDefault(), children: "Delete key" }) })
4544
4571
  ] })
4545
4572
  ] });
4546
4573
  }
@@ -4673,7 +4700,7 @@ var CustomEditor = ({
4673
4700
  language,
4674
4701
  value,
4675
4702
  onChange,
4676
- maxDynamicHeight,
4703
+ height,
4677
4704
  showCopyButton
4678
4705
  }) => {
4679
4706
  const monaco = _react2.useMonaco.call(void 0, );
@@ -4682,14 +4709,14 @@ var CustomEditor = ({
4682
4709
  if (!monaco || !editorRef.current) {
4683
4710
  return;
4684
4711
  }
4685
- _optionalChain([monaco, 'optionalAccess', _21 => _21.editor, 'access', _22 => _22.setModelLanguage, 'call', _23 => _23(editorRef.current.getModel(), language)]);
4712
+ _optionalChain([monaco, 'optionalAccess', _25 => _25.editor, 'access', _26 => _26.setModelLanguage, 'call', _27 => _27(editorRef.current.getModel(), language)]);
4686
4713
  }, [monaco, language]);
4687
4714
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
4688
4715
  "div",
4689
4716
  {
4690
- className: cn("group/editor relative", maxDynamicHeight === void 0 && "h-full p-2"),
4717
+ className: cn("group/editor relative", height === void 0 && "h-full p-2"),
4691
4718
  style: {
4692
- height: maxDynamicHeight
4719
+ height
4693
4720
  },
4694
4721
  children: [
4695
4722
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -4749,7 +4776,7 @@ var CustomEditor = ({
4749
4776
  var useField = ({
4750
4777
  name,
4751
4778
  form,
4752
- isEditorDynamic = false,
4779
+ height,
4753
4780
  showCopyButton
4754
4781
  }) => {
4755
4782
  const { field, fieldState } = _reacthookform.useController.call(void 0, {
@@ -4787,7 +4814,7 @@ var useField = ({
4787
4814
  language: contentType === "JSON" ? "json" : "plaintext",
4788
4815
  value: field.value,
4789
4816
  onChange: field.onChange,
4790
- maxDynamicHeight: isEditorDynamic ? 100 : void 0,
4817
+ height,
4791
4818
  showCopyButton
4792
4819
  }
4793
4820
  ) })
@@ -4839,13 +4866,14 @@ var ListEditForm = ({
4839
4866
  });
4840
4867
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacthookform.FormProvider, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit, className: "flex flex-col gap-2", children: [
4841
4868
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex grow flex-col gap-2", children: [
4842
- type !== "list" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormItem, { name: "key", label: keyLabel }),
4843
- type === "zset" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NumberFormItem, { name: "value", label: valueLabel }) : type !== "set" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormItem, { name: "value", label: valueLabel })
4869
+ type !== "list" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormItem, { name: "key", height: type === "set" ? 250 : 100, label: keyLabel }),
4870
+ type === "zset" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NumberFormItem, { name: "value", label: valueLabel }) : type !== "set" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormItem, { name: "value", height: type === "list" ? 250 : 100, label: valueLabel })
4844
4871
  ] }),
4845
4872
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex justify-end gap-2", children: [
4846
4873
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4847
4874
  Button,
4848
4875
  {
4876
+ type: "button",
4849
4877
  onClick: () => {
4850
4878
  setSelectedListItem(void 0);
4851
4879
  },
@@ -4889,12 +4917,16 @@ var NumberFormItem = ({ name, label }) => {
4889
4917
  )
4890
4918
  ] });
4891
4919
  };
4892
- var FormItem = ({ name, label }) => {
4920
+ var FormItem = ({
4921
+ name,
4922
+ label,
4923
+ height
4924
+ }) => {
4893
4925
  const form = _reacthookform.useFormContext.call(void 0, );
4894
4926
  const { editor, selector } = useField({
4895
4927
  name,
4896
4928
  form,
4897
- isEditorDynamic: true,
4929
+ height,
4898
4930
  showCopyButton: true
4899
4931
  });
4900
4932
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-1", children: [
@@ -4923,7 +4955,7 @@ var ListDisplay = ({ dataKey, type }) => {
4923
4955
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-full flex-col gap-2", children: [
4924
4956
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DisplayHeader, { dataKey, type }),
4925
4957
  selectedListItem && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListEditDisplay, { dataKey, type, item: selectedListItem }),
4926
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cn("min-h-0 grow", selectedListItem && "hidden"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfiniteScroll, { query, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pr-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "table", { className: "w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tbody", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListItems, { dataKey, type, query }) }) }) }) }) })
4958
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cn("min-h-0 grow", selectedListItem && "hidden"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfiniteScroll, { query, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pr-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "table", { className: "w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ItemContextMenu, { dataKey, type, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tbody", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListItems, { dataKey, type, query }) }) }) }) }) }) })
4927
4959
  ] });
4928
4960
  };
4929
4961
  var ListItems = ({
@@ -4932,43 +4964,47 @@ var ListItems = ({
4932
4964
  dataKey
4933
4965
  }) => {
4934
4966
  const { setSelectedListItem } = useDatabrowserStore();
4935
- const keys = _react.useMemo.call(void 0, () => _nullishCoalesce(_optionalChain([query, 'access', _24 => _24.data, 'optionalAccess', _25 => _25.pages, 'access', _26 => _26.flatMap, 'call', _27 => _27((page) => page.keys)]), () => ( [])), [query.data]);
4967
+ const keys = _react.useMemo.call(void 0, () => _nullishCoalesce(_optionalChain([query, 'access', _28 => _28.data, 'optionalAccess', _29 => _29.pages, 'access', _30 => _30.flatMap, 'call', _31 => _31((page) => page.keys)]), () => ( [])), [query.data]);
4936
4968
  const { mutate: editItem } = useEditListItem();
4937
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: keys.map(({ key, value }, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4938
- ItemContextMenu,
4969
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: keys.map(({ key, value }, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
4970
+ "tr",
4939
4971
  {
4940
- dataKey,
4941
- type,
4942
- itemKey: key,
4943
- itemValue: value,
4944
- children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
4945
- "tr",
4946
- {
4947
- onClick: () => {
4948
- setSelectedListItem({ key, value });
4949
- },
4950
- className: "h-10 border-b border-b-zinc-100 hover:bg-zinc-50",
4951
- children: [
4952
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4953
- "td",
4954
- {
4955
- className: cn(
4956
- "cursor-pointer truncate px-3",
4957
- type === "list" || type === "stream" ? "w-32 min-w-24" : "max-w-0"
4958
- ),
4959
- children: key
4960
- }
4961
- ),
4962
- value !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4963
- "td",
4964
- {
4965
- className: cn("cursor-pointer truncate px-3", type === "zset" ? "w-24" : "max-w-0"),
4966
- children: value
4967
- }
4972
+ "data-item-key": key,
4973
+ "data-item-value": value,
4974
+ onClick: () => {
4975
+ setSelectedListItem({ key, value });
4976
+ },
4977
+ className: "h-10 border-b border-b-zinc-100 hover:bg-zinc-50",
4978
+ children: [
4979
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4980
+ "td",
4981
+ {
4982
+ className: cn(
4983
+ "cursor-pointer truncate px-3",
4984
+ type === "list" || type === "stream" ? "w-32 min-w-24" : "max-w-0"
4968
4985
  ),
4969
- type !== "stream" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "td", { width: 20, className: "px-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4986
+ children: key
4987
+ }
4988
+ ),
4989
+ value !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4990
+ "td",
4991
+ {
4992
+ className: cn("cursor-pointer truncate px-3", type === "zset" ? "w-24" : "max-w-0"),
4993
+ children: value
4994
+ }
4995
+ ),
4996
+ type !== "stream" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4997
+ "td",
4998
+ {
4999
+ width: 20,
5000
+ className: "px-3",
5001
+ onClick: (e) => {
5002
+ e.stopPropagation();
5003
+ },
5004
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4970
5005
  DeleteAlertDialog,
4971
5006
  {
5007
+ deletionType: "item",
4972
5008
  onDeleteConfirm: (e) => {
4973
5009
  e.stopPropagation();
4974
5010
  editItem({
@@ -4981,10 +5017,10 @@ var ListItems = ({
4981
5017
  },
4982
5018
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { size: "icon-sm", variant: "secondary", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconTrash, { className: "size-4 text-zinc-500" }) })
4983
5019
  }
4984
- ) })
4985
- ]
4986
- }
4987
- )
5020
+ )
5021
+ }
5022
+ )
5023
+ ]
4988
5024
  },
4989
5025
  `${dataKey}-${key}-${i}`
4990
5026
  )) });
@@ -5060,12 +5096,13 @@ var DataDisplay = () => {
5060
5096
 
5061
5097
  // src/components/databrowser/components/add-key-modal.tsx
5062
5098
 
5099
+ var _reactdialog = require('@radix-ui/react-dialog'); var DialogPrimitive = _interopRequireWildcard(_reactdialog);
5063
5100
 
5064
5101
 
5065
5102
 
5066
5103
  // src/components/ui/dialog.tsx
5067
5104
 
5068
- var _reactdialog = require('@radix-ui/react-dialog'); var DialogPrimitive = _interopRequireWildcard(_reactdialog);
5105
+
5069
5106
 
5070
5107
  var Dialog = DialogPrimitive.Root;
5071
5108
  var DialogTrigger = DialogPrimitive.Trigger;
@@ -5182,7 +5219,7 @@ function AddKeyModal() {
5182
5219
  setSelectedKey(key);
5183
5220
  setOpen(false);
5184
5221
  setTimeout(() => {
5185
- _optionalChain([window, 'access', _28 => _28.document, 'access', _29 => _29.querySelector, 'call', _30 => _30(`[data-key="${key}"]`), 'optionalAccess', _31 => _31.scrollIntoView, 'call', _32 => _32({
5222
+ _optionalChain([window, 'access', _32 => _32.document, 'access', _33 => _33.querySelector, 'call', _34 => _34(`[data-key="${key}"]`), 'optionalAccess', _35 => _35.scrollIntoView, 'call', _36 => _36({
5186
5223
  behavior: "smooth",
5187
5224
  block: "start",
5188
5225
  inline: "nearest"
@@ -5207,6 +5244,7 @@ function AddKeyModal() {
5207
5244
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { variant: "primary", size: "icon-sm", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacticons.PlusIcon, { className: "size-4" }) }) }),
5208
5245
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogContent, { className: "max-w-[400px]", children: [
5209
5246
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTitle, { children: "Create new key" }) }),
5247
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "sr-only", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactdialog.DialogDescription, { children: "Create new key" }) }),
5210
5248
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { className: "mt-4", onSubmit, children: [
5211
5249
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-1", children: [
5212
5250
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -5232,7 +5270,7 @@ function AddKeyModal() {
5232
5270
  }
5233
5271
  )
5234
5272
  ] }),
5235
- formState.errors.key && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-3 mt-2 text-xs text-red-500", children: _optionalChain([formState, 'access', _33 => _33.errors, 'access', _34 => _34.key, 'optionalAccess', _35 => _35.message]) }),
5273
+ formState.errors.key && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-3 mt-2 text-xs text-red-500", children: _optionalChain([formState, 'access', _37 => _37.errors, 'access', _38 => _38.key, 'optionalAccess', _39 => _39.message]) }),
5236
5274
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mt-2 text-xs text-zinc-500", children: "After creating the key, you can edit the value" }),
5237
5275
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-6 flex justify-end gap-2", children: [
5238
5276
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -5268,16 +5306,15 @@ var Empty = () => {
5268
5306
 
5269
5307
 
5270
5308
 
5271
- var SidebarContextMenu = ({
5272
- children,
5273
- dataKey
5274
- }) => {
5309
+ var SidebarContextMenu = ({ children }) => {
5275
5310
  const { mutate: deleteKey } = useDeleteKey();
5276
5311
  const [isAlertOpen, setAlertOpen] = _react.useState.call(void 0, false);
5312
+ const [dataKey, setDataKey] = _react.useState.call(void 0, "");
5277
5313
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
5278
5314
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5279
5315
  DeleteAlertDialog,
5280
5316
  {
5317
+ deletionType: "key",
5281
5318
  open: isAlertOpen,
5282
5319
  onOpenChange: setAlertOpen,
5283
5320
  onDeleteConfirm: (e) => {
@@ -5288,7 +5325,21 @@ var SidebarContextMenu = ({
5288
5325
  }
5289
5326
  ),
5290
5327
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ContextMenu, { children: [
5291
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContextMenuTrigger, { asChild: true, children }),
5328
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5329
+ ContextMenuTrigger,
5330
+ {
5331
+ onContextMenu: (e) => {
5332
+ const el = e.target;
5333
+ const key = el.closest("[data-key]");
5334
+ if (key && key instanceof HTMLElement && key.dataset.key !== void 0) {
5335
+ setDataKey(key.dataset.key);
5336
+ } else {
5337
+ throw new Error("Key not found");
5338
+ }
5339
+ },
5340
+ children
5341
+ }
5342
+ ),
5292
5343
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ContextMenuContent, { children: [
5293
5344
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5294
5345
  ContextMenuItem,
@@ -5313,7 +5364,7 @@ var SidebarContextMenu = ({
5313
5364
 
5314
5365
  var KeysList = () => {
5315
5366
  const { keys } = useKeys();
5316
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pr-3", children: keys.map((data, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, KeyItem, { nextKey: _nullishCoalesce(_optionalChain([keys, 'access', _36 => _36.at, 'call', _37 => _37(i + 1), 'optionalAccess', _38 => _38[0]]), () => ( "")), data }, data[0])) });
5367
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pr-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SidebarContextMenu, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: keys.map((data, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, KeyItem, { nextKey: _nullishCoalesce(_optionalChain([keys, 'access', _40 => _40.at, 'call', _41 => _41(i + 1), 'optionalAccess', _42 => _42[0]]), () => ( "")), data }, data[0])) }) }) });
5317
5368
  };
5318
5369
  var keyStyles = {
5319
5370
  string: "border-sky-400 !bg-sky-50 text-sky-900",
@@ -5329,7 +5380,7 @@ var KeyItem = ({ data, nextKey }) => {
5329
5380
  const [dataKey, dataType] = data;
5330
5381
  const isKeySelected = selectedKey === dataKey;
5331
5382
  const isNextKeySelected = selectedKey === nextKey;
5332
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SidebarContextMenu, { dataKey, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
5383
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
5333
5384
  Button,
5334
5385
  {
5335
5386
  "data-key": dataKey,
@@ -5347,7 +5398,7 @@ var KeyItem = ({ data, nextKey }) => {
5347
5398
  !isKeySelected && !isNextKeySelected && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "absolute -bottom-px left-3 right-3 h-px bg-zinc-100" })
5348
5399
  ]
5349
5400
  }
5350
- ) }, dataKey);
5401
+ );
5351
5402
  };
5352
5403
 
5353
5404
  // src/components/databrowser/components/sidebar/search-input.tsx
@@ -5441,8 +5492,8 @@ function Sidebar() {
5441
5492
 
5442
5493
  var RedisBrowser = ({ token, url }) => {
5443
5494
  const credentials = _react.useMemo.call(void 0, () => ({ token, url }), [token, url]);
5444
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttooltip.TooltipProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DatabrowserProvider, { redisCredentials: credentials, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, KeysProvider, { children: [
5445
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "ups-db", style: { height: "100%" }, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
5495
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttooltip.TooltipProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DatabrowserProvider, { redisCredentials: credentials, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, KeysProvider, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "ups-db", style: { height: "100%" }, children: [
5496
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
5446
5497
  _reactresizablepanels.PanelGroup,
5447
5498
  {
5448
5499
  autoSaveId: "persistence",
@@ -5461,9 +5512,9 @@ var RedisBrowser = ({ token, url }) => {
5461
5512
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactresizablepanels.Panel, { minSize: 40, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DataDisplay, {}) })
5462
5513
  ]
5463
5514
  }
5464
- ) }),
5515
+ ),
5465
5516
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Toaster, {})
5466
- ] }) }) }) });
5517
+ ] }) }) }) }) });
5467
5518
  };
5468
5519
 
5469
5520