@upstash/react-redis-browser 0.1.4 → 0.1.5
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 +55 -18
- package/dist/index.mjs +55 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3279,11 +3279,21 @@ var useFetchSimpleKey = (dataKey, type) => {
|
|
|
3279
3279
|
if (type === "string") result = await redis.get(dataKey);
|
|
3280
3280
|
else if (type === "json") result = await redis.json.get(dataKey);
|
|
3281
3281
|
else throw new Error(`Invalid type when fetching simple key: ${type}`);
|
|
3282
|
+
if (type === "json" && result !== null)
|
|
3283
|
+
result = JSON.stringify(sortObject(JSON.parse(result)));
|
|
3282
3284
|
if (result === null) deleteKeyCache(dataKey);
|
|
3283
3285
|
return result;
|
|
3284
3286
|
}
|
|
3285
3287
|
});
|
|
3286
3288
|
};
|
|
3289
|
+
var sortObject = (obj) => {
|
|
3290
|
+
if (typeof obj !== "object" || obj === null) return obj;
|
|
3291
|
+
return Object.fromEntries(
|
|
3292
|
+
Object.entries(obj).sort((a, b) => a[0].localeCompare(b[0])).map(
|
|
3293
|
+
([key, value]) => typeof value === "object" && !Array.isArray(value) && value !== null ? [key, sortObject(value)] : [key, value]
|
|
3294
|
+
)
|
|
3295
|
+
);
|
|
3296
|
+
};
|
|
3287
3297
|
|
|
3288
3298
|
// src/components/databrowser/hooks/use-delete-key-cache.ts
|
|
3289
3299
|
var useDeleteKeyCache = () => {
|
|
@@ -4591,7 +4601,7 @@ var DisplayHeader = ({
|
|
|
4591
4601
|
}) => {
|
|
4592
4602
|
const { setSelectedListItem } = useDatabrowserStore();
|
|
4593
4603
|
const handleAddItem = () => {
|
|
4594
|
-
setSelectedListItem({ key: type === "stream" ? "*" : "",
|
|
4604
|
+
setSelectedListItem({ key: type === "stream" ? "*" : "", isNew: true });
|
|
4595
4605
|
};
|
|
4596
4606
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rounded-lg bg-zinc-100 px-3 py-2", children: [
|
|
4597
4607
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex min-h-10 items-center justify-between gap-4", children: [
|
|
@@ -4613,6 +4623,7 @@ var DisplayHeader = ({
|
|
|
4613
4623
|
// src/components/databrowser/components/display/display-list-edit.tsx
|
|
4614
4624
|
|
|
4615
4625
|
|
|
4626
|
+
|
|
4616
4627
|
// src/components/ui/tooltip.tsx
|
|
4617
4628
|
|
|
4618
4629
|
|
|
@@ -4790,7 +4801,8 @@ var useField = ({
|
|
|
4790
4801
|
form,
|
|
4791
4802
|
height,
|
|
4792
4803
|
showCopyButton,
|
|
4793
|
-
readOnly
|
|
4804
|
+
readOnly,
|
|
4805
|
+
data
|
|
4794
4806
|
}) => {
|
|
4795
4807
|
const { field, fieldState } = _reacthookform.useController.call(void 0, {
|
|
4796
4808
|
name,
|
|
@@ -4800,13 +4812,13 @@ var useField = ({
|
|
|
4800
4812
|
() => checkIsValidJSON(field.value) ? "JSON" : "Text"
|
|
4801
4813
|
);
|
|
4802
4814
|
_react.useEffect.call(void 0, () => {
|
|
4803
|
-
if (!checkIsValidJSON(
|
|
4815
|
+
if (!checkIsValidJSON(data)) {
|
|
4804
4816
|
return;
|
|
4805
4817
|
}
|
|
4806
|
-
form.setValue(name, formatJSON(
|
|
4818
|
+
form.setValue(name, formatJSON(data), {
|
|
4807
4819
|
shouldDirty: false
|
|
4808
4820
|
});
|
|
4809
|
-
}, []);
|
|
4821
|
+
}, [data]);
|
|
4810
4822
|
const handleTypeChange = (type) => {
|
|
4811
4823
|
setContentType(type);
|
|
4812
4824
|
if (type === "JSON") {
|
|
@@ -4856,14 +4868,32 @@ var ListEditDisplay = ({
|
|
|
4856
4868
|
var ListEditForm = ({
|
|
4857
4869
|
type,
|
|
4858
4870
|
dataKey,
|
|
4859
|
-
item: { key: itemKey,
|
|
4871
|
+
item: { key: itemKey, isNew }
|
|
4860
4872
|
}) => {
|
|
4873
|
+
const query = useFetchListItems({
|
|
4874
|
+
type,
|
|
4875
|
+
dataKey
|
|
4876
|
+
});
|
|
4877
|
+
const findValue = () => {
|
|
4878
|
+
for (const page of _nullishCoalesce(_optionalChain([query, 'access', _28 => _28.data, 'optionalAccess', _29 => _29.pages]), () => ( []))) {
|
|
4879
|
+
const item = page.keys.find((item2) => item2.key === itemKey);
|
|
4880
|
+
if (item && "value" in item) return item.value;
|
|
4881
|
+
}
|
|
4882
|
+
return;
|
|
4883
|
+
};
|
|
4884
|
+
const itemValue = findValue();
|
|
4861
4885
|
const form = _reacthookform.useForm.call(void 0, {
|
|
4862
4886
|
defaultValues: {
|
|
4863
4887
|
key: itemKey,
|
|
4864
4888
|
value: itemValue
|
|
4865
4889
|
}
|
|
4866
4890
|
});
|
|
4891
|
+
_react.useEffect.call(void 0, () => {
|
|
4892
|
+
form.reset({
|
|
4893
|
+
key: itemKey,
|
|
4894
|
+
value: itemValue
|
|
4895
|
+
});
|
|
4896
|
+
}, [itemKey, itemValue]);
|
|
4867
4897
|
const { mutateAsync: editItem, isPending } = useEditListItem();
|
|
4868
4898
|
const { setSelectedListItem } = useDatabrowserStore();
|
|
4869
4899
|
const [keyLabel, valueLabel] = headerLabels[type];
|
|
@@ -4886,7 +4916,8 @@ var ListEditForm = ({
|
|
|
4886
4916
|
readOnly: type === "stream",
|
|
4887
4917
|
name: "key",
|
|
4888
4918
|
height: type === "set" ? 250 : 100,
|
|
4889
|
-
label: keyLabel
|
|
4919
|
+
label: keyLabel,
|
|
4920
|
+
data: itemKey
|
|
4890
4921
|
}
|
|
4891
4922
|
),
|
|
4892
4923
|
type === "zset" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NumberFormItem, { name: "value", label: valueLabel }) : type !== "set" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -4895,7 +4926,8 @@ var ListEditForm = ({
|
|
|
4895
4926
|
readOnly: type === "stream",
|
|
4896
4927
|
name: "value",
|
|
4897
4928
|
height: type === "list" ? 250 : 100,
|
|
4898
|
-
label: valueLabel
|
|
4929
|
+
label: valueLabel,
|
|
4930
|
+
data: _nullishCoalesce(itemValue, () => ( ""))
|
|
4899
4931
|
}
|
|
4900
4932
|
)
|
|
4901
4933
|
] }),
|
|
@@ -4951,7 +4983,8 @@ var FormItem = ({
|
|
|
4951
4983
|
name,
|
|
4952
4984
|
label,
|
|
4953
4985
|
height,
|
|
4954
|
-
readOnly
|
|
4986
|
+
readOnly,
|
|
4987
|
+
data
|
|
4955
4988
|
}) => {
|
|
4956
4989
|
const form = _reacthookform.useFormContext.call(void 0, );
|
|
4957
4990
|
const { editor, selector } = useField({
|
|
@@ -4959,7 +4992,8 @@ var FormItem = ({
|
|
|
4959
4992
|
form,
|
|
4960
4993
|
height,
|
|
4961
4994
|
showCopyButton: true,
|
|
4962
|
-
readOnly
|
|
4995
|
+
readOnly,
|
|
4996
|
+
data
|
|
4963
4997
|
});
|
|
4964
4998
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-1", children: [
|
|
4965
4999
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1 text-xs", children: [
|
|
@@ -4996,7 +5030,7 @@ var ListItems = ({
|
|
|
4996
5030
|
dataKey
|
|
4997
5031
|
}) => {
|
|
4998
5032
|
const { setSelectedListItem } = useDatabrowserStore();
|
|
4999
|
-
const keys = _react.useMemo.call(void 0, () => _nullishCoalesce(_optionalChain([query, 'access',
|
|
5033
|
+
const keys = _react.useMemo.call(void 0, () => _nullishCoalesce(_optionalChain([query, 'access', _30 => _30.data, 'optionalAccess', _31 => _31.pages, 'access', _32 => _32.flatMap, 'call', _33 => _33((page) => page.keys)]), () => ( [])), [query.data]);
|
|
5000
5034
|
const { mutate: editItem } = useEditListItem();
|
|
5001
5035
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: keys.map(({ key, value }, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
5002
5036
|
"tr",
|
|
@@ -5004,7 +5038,7 @@ var ListItems = ({
|
|
|
5004
5038
|
"data-item-key": key,
|
|
5005
5039
|
"data-item-value": value,
|
|
5006
5040
|
onClick: () => {
|
|
5007
|
-
setSelectedListItem({ key
|
|
5041
|
+
setSelectedListItem({ key });
|
|
5008
5042
|
},
|
|
5009
5043
|
className: "h-10 border-b border-b-zinc-100 hover:bg-zinc-50",
|
|
5010
5044
|
children: [
|
|
@@ -5083,16 +5117,16 @@ var EditorDisplayForm = ({
|
|
|
5083
5117
|
const form = _reacthookform.useForm.call(void 0, {
|
|
5084
5118
|
defaultValues: { value: data }
|
|
5085
5119
|
});
|
|
5086
|
-
const { editor, selector } = useField({ name: "value", form });
|
|
5087
|
-
const { mutateAsync: setKey, isPending: isSettingKey } = useSetSimpleKey(dataKey, type);
|
|
5088
5120
|
_react.useEffect.call(void 0, () => {
|
|
5089
5121
|
form.reset(
|
|
5090
5122
|
{ value: data },
|
|
5091
5123
|
{
|
|
5092
|
-
keepValues:
|
|
5124
|
+
keepValues: false
|
|
5093
5125
|
}
|
|
5094
5126
|
);
|
|
5095
5127
|
}, [data]);
|
|
5128
|
+
const { editor, selector } = useField({ name: "value", form, data });
|
|
5129
|
+
const { mutateAsync: setKey, isPending: isSettingKey } = useSetSimpleKey(dataKey, type);
|
|
5096
5130
|
const handleCancel = () => {
|
|
5097
5131
|
form.reset();
|
|
5098
5132
|
};
|
|
@@ -5254,7 +5288,7 @@ function AddKeyModal() {
|
|
|
5254
5288
|
setSelectedKey(key);
|
|
5255
5289
|
setOpen(false);
|
|
5256
5290
|
setTimeout(() => {
|
|
5257
|
-
_optionalChain([window, 'access',
|
|
5291
|
+
_optionalChain([window, 'access', _34 => _34.document, 'access', _35 => _35.querySelector, 'call', _36 => _36(`[data-key="${key}"]`), 'optionalAccess', _37 => _37.scrollIntoView, 'call', _38 => _38({
|
|
5258
5292
|
behavior: "smooth",
|
|
5259
5293
|
block: "start",
|
|
5260
5294
|
inline: "nearest"
|
|
@@ -5299,7 +5333,7 @@ function AddKeyModal() {
|
|
|
5299
5333
|
}
|
|
5300
5334
|
)
|
|
5301
5335
|
] }),
|
|
5302
|
-
formState.errors.key && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-3 mt-2 text-xs text-red-500", children: _optionalChain([formState, 'access',
|
|
5336
|
+
formState.errors.key && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-3 mt-2 text-xs text-red-500", children: _optionalChain([formState, 'access', _39 => _39.errors, 'access', _40 => _40.key, 'optionalAccess', _41 => _41.message]) }),
|
|
5303
5337
|
/* @__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" }),
|
|
5304
5338
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-6 flex justify-end gap-2", children: [
|
|
5305
5339
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -5393,7 +5427,7 @@ var SidebarContextMenu = ({ children }) => {
|
|
|
5393
5427
|
|
|
5394
5428
|
var KeysList = () => {
|
|
5395
5429
|
const { keys } = useKeys();
|
|
5396
|
-
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',
|
|
5430
|
+
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', _42 => _42.at, 'call', _43 => _43(i + 1), 'optionalAccess', _44 => _44[0]]), () => ( "")), data }, data[0])) }) }) });
|
|
5397
5431
|
};
|
|
5398
5432
|
var keyStyles = {
|
|
5399
5433
|
string: "border-sky-400 !bg-sky-50 text-sky-900",
|
|
@@ -5529,6 +5563,9 @@ function Sidebar() {
|
|
|
5529
5563
|
queryClient.invalidateQueries({
|
|
5530
5564
|
queryKey: [FETCH_LIST_ITEMS_QUERY_KEY]
|
|
5531
5565
|
});
|
|
5566
|
+
queryClient.invalidateQueries({
|
|
5567
|
+
queryKey: [FETCH_SIMPLE_KEY_QUERY_KEY]
|
|
5568
|
+
});
|
|
5532
5569
|
queryClient.invalidateQueries({
|
|
5533
5570
|
queryKey: [FETCH_DB_SIZE_QUERY_KEY]
|
|
5534
5571
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/databrowser/index.tsx
|
|
2
|
-
import { useEffect as
|
|
2
|
+
import { useEffect as useEffect10, useMemo as useMemo6 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/store.tsx
|
|
5
5
|
import { createContext, useContext, useMemo, useState as useState2 } from "react";
|
|
@@ -3279,11 +3279,21 @@ var useFetchSimpleKey = (dataKey, type) => {
|
|
|
3279
3279
|
if (type === "string") result = await redis.get(dataKey);
|
|
3280
3280
|
else if (type === "json") result = await redis.json.get(dataKey);
|
|
3281
3281
|
else throw new Error(`Invalid type when fetching simple key: ${type}`);
|
|
3282
|
+
if (type === "json" && result !== null)
|
|
3283
|
+
result = JSON.stringify(sortObject(JSON.parse(result)));
|
|
3282
3284
|
if (result === null) deleteKeyCache(dataKey);
|
|
3283
3285
|
return result;
|
|
3284
3286
|
}
|
|
3285
3287
|
});
|
|
3286
3288
|
};
|
|
3289
|
+
var sortObject = (obj) => {
|
|
3290
|
+
if (typeof obj !== "object" || obj === null) return obj;
|
|
3291
|
+
return Object.fromEntries(
|
|
3292
|
+
Object.entries(obj).sort((a, b) => a[0].localeCompare(b[0])).map(
|
|
3293
|
+
([key, value]) => typeof value === "object" && !Array.isArray(value) && value !== null ? [key, sortObject(value)] : [key, value]
|
|
3294
|
+
)
|
|
3295
|
+
);
|
|
3296
|
+
};
|
|
3287
3297
|
|
|
3288
3298
|
// src/components/databrowser/hooks/use-delete-key-cache.ts
|
|
3289
3299
|
var useDeleteKeyCache = () => {
|
|
@@ -4591,7 +4601,7 @@ var DisplayHeader = ({
|
|
|
4591
4601
|
}) => {
|
|
4592
4602
|
const { setSelectedListItem } = useDatabrowserStore();
|
|
4593
4603
|
const handleAddItem = () => {
|
|
4594
|
-
setSelectedListItem({ key: type === "stream" ? "*" : "",
|
|
4604
|
+
setSelectedListItem({ key: type === "stream" ? "*" : "", isNew: true });
|
|
4595
4605
|
};
|
|
4596
4606
|
return /* @__PURE__ */ jsxs15("div", { className: "rounded-lg bg-zinc-100 px-3 py-2", children: [
|
|
4597
4607
|
/* @__PURE__ */ jsxs15("div", { className: "flex min-h-10 items-center justify-between gap-4", children: [
|
|
@@ -4611,6 +4621,7 @@ var DisplayHeader = ({
|
|
|
4611
4621
|
};
|
|
4612
4622
|
|
|
4613
4623
|
// src/components/databrowser/components/display/display-list-edit.tsx
|
|
4624
|
+
import { useEffect as useEffect8 } from "react";
|
|
4614
4625
|
import { Controller as Controller2, FormProvider, useForm as useForm2, useFormContext } from "react-hook-form";
|
|
4615
4626
|
|
|
4616
4627
|
// src/components/ui/tooltip.tsx
|
|
@@ -4790,7 +4801,8 @@ var useField = ({
|
|
|
4790
4801
|
form,
|
|
4791
4802
|
height,
|
|
4792
4803
|
showCopyButton,
|
|
4793
|
-
readOnly
|
|
4804
|
+
readOnly,
|
|
4805
|
+
data
|
|
4794
4806
|
}) => {
|
|
4795
4807
|
const { field, fieldState } = useController({
|
|
4796
4808
|
name,
|
|
@@ -4800,13 +4812,13 @@ var useField = ({
|
|
|
4800
4812
|
() => checkIsValidJSON(field.value) ? "JSON" : "Text"
|
|
4801
4813
|
);
|
|
4802
4814
|
useEffect7(() => {
|
|
4803
|
-
if (!checkIsValidJSON(
|
|
4815
|
+
if (!checkIsValidJSON(data)) {
|
|
4804
4816
|
return;
|
|
4805
4817
|
}
|
|
4806
|
-
form.setValue(name, formatJSON(
|
|
4818
|
+
form.setValue(name, formatJSON(data), {
|
|
4807
4819
|
shouldDirty: false
|
|
4808
4820
|
});
|
|
4809
|
-
}, []);
|
|
4821
|
+
}, [data]);
|
|
4810
4822
|
const handleTypeChange = (type) => {
|
|
4811
4823
|
setContentType(type);
|
|
4812
4824
|
if (type === "JSON") {
|
|
@@ -4856,14 +4868,32 @@ var ListEditDisplay = ({
|
|
|
4856
4868
|
var ListEditForm = ({
|
|
4857
4869
|
type,
|
|
4858
4870
|
dataKey,
|
|
4859
|
-
item: { key: itemKey,
|
|
4871
|
+
item: { key: itemKey, isNew }
|
|
4860
4872
|
}) => {
|
|
4873
|
+
const query = useFetchListItems({
|
|
4874
|
+
type,
|
|
4875
|
+
dataKey
|
|
4876
|
+
});
|
|
4877
|
+
const findValue = () => {
|
|
4878
|
+
for (const page of query.data?.pages ?? []) {
|
|
4879
|
+
const item = page.keys.find((item2) => item2.key === itemKey);
|
|
4880
|
+
if (item && "value" in item) return item.value;
|
|
4881
|
+
}
|
|
4882
|
+
return;
|
|
4883
|
+
};
|
|
4884
|
+
const itemValue = findValue();
|
|
4861
4885
|
const form = useForm2({
|
|
4862
4886
|
defaultValues: {
|
|
4863
4887
|
key: itemKey,
|
|
4864
4888
|
value: itemValue
|
|
4865
4889
|
}
|
|
4866
4890
|
});
|
|
4891
|
+
useEffect8(() => {
|
|
4892
|
+
form.reset({
|
|
4893
|
+
key: itemKey,
|
|
4894
|
+
value: itemValue
|
|
4895
|
+
});
|
|
4896
|
+
}, [itemKey, itemValue]);
|
|
4867
4897
|
const { mutateAsync: editItem, isPending } = useEditListItem();
|
|
4868
4898
|
const { setSelectedListItem } = useDatabrowserStore();
|
|
4869
4899
|
const [keyLabel, valueLabel] = headerLabels[type];
|
|
@@ -4886,7 +4916,8 @@ var ListEditForm = ({
|
|
|
4886
4916
|
readOnly: type === "stream",
|
|
4887
4917
|
name: "key",
|
|
4888
4918
|
height: type === "set" ? 250 : 100,
|
|
4889
|
-
label: keyLabel
|
|
4919
|
+
label: keyLabel,
|
|
4920
|
+
data: itemKey
|
|
4890
4921
|
}
|
|
4891
4922
|
),
|
|
4892
4923
|
type === "zset" ? /* @__PURE__ */ jsx29(NumberFormItem, { name: "value", label: valueLabel }) : type !== "set" && /* @__PURE__ */ jsx29(
|
|
@@ -4895,7 +4926,8 @@ var ListEditForm = ({
|
|
|
4895
4926
|
readOnly: type === "stream",
|
|
4896
4927
|
name: "value",
|
|
4897
4928
|
height: type === "list" ? 250 : 100,
|
|
4898
|
-
label: valueLabel
|
|
4929
|
+
label: valueLabel,
|
|
4930
|
+
data: itemValue ?? ""
|
|
4899
4931
|
}
|
|
4900
4932
|
)
|
|
4901
4933
|
] }),
|
|
@@ -4951,7 +4983,8 @@ var FormItem = ({
|
|
|
4951
4983
|
name,
|
|
4952
4984
|
label,
|
|
4953
4985
|
height,
|
|
4954
|
-
readOnly
|
|
4986
|
+
readOnly,
|
|
4987
|
+
data
|
|
4955
4988
|
}) => {
|
|
4956
4989
|
const form = useFormContext();
|
|
4957
4990
|
const { editor, selector } = useField({
|
|
@@ -4959,7 +4992,8 @@ var FormItem = ({
|
|
|
4959
4992
|
form,
|
|
4960
4993
|
height,
|
|
4961
4994
|
showCopyButton: true,
|
|
4962
|
-
readOnly
|
|
4995
|
+
readOnly,
|
|
4996
|
+
data
|
|
4963
4997
|
});
|
|
4964
4998
|
return /* @__PURE__ */ jsxs19("div", { className: "flex flex-col gap-1", children: [
|
|
4965
4999
|
/* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-1 text-xs", children: [
|
|
@@ -5004,7 +5038,7 @@ var ListItems = ({
|
|
|
5004
5038
|
"data-item-key": key,
|
|
5005
5039
|
"data-item-value": value,
|
|
5006
5040
|
onClick: () => {
|
|
5007
|
-
setSelectedListItem({ key
|
|
5041
|
+
setSelectedListItem({ key });
|
|
5008
5042
|
},
|
|
5009
5043
|
className: "h-10 border-b border-b-zinc-100 hover:bg-zinc-50",
|
|
5010
5044
|
children: [
|
|
@@ -5059,7 +5093,7 @@ var ListItems = ({
|
|
|
5059
5093
|
};
|
|
5060
5094
|
|
|
5061
5095
|
// src/components/databrowser/components/display/display-simple.tsx
|
|
5062
|
-
import { useEffect as
|
|
5096
|
+
import { useEffect as useEffect9 } from "react";
|
|
5063
5097
|
import { useForm as useForm3 } from "react-hook-form";
|
|
5064
5098
|
import { Fragment as Fragment6, jsx as jsx31, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
5065
5099
|
var EditorDisplay = ({ dataKey, type }) => {
|
|
@@ -5083,16 +5117,16 @@ var EditorDisplayForm = ({
|
|
|
5083
5117
|
const form = useForm3({
|
|
5084
5118
|
defaultValues: { value: data }
|
|
5085
5119
|
});
|
|
5086
|
-
|
|
5087
|
-
const { mutateAsync: setKey, isPending: isSettingKey } = useSetSimpleKey(dataKey, type);
|
|
5088
|
-
useEffect8(() => {
|
|
5120
|
+
useEffect9(() => {
|
|
5089
5121
|
form.reset(
|
|
5090
5122
|
{ value: data },
|
|
5091
5123
|
{
|
|
5092
|
-
keepValues:
|
|
5124
|
+
keepValues: false
|
|
5093
5125
|
}
|
|
5094
5126
|
);
|
|
5095
5127
|
}, [data]);
|
|
5128
|
+
const { editor, selector } = useField({ name: "value", form, data });
|
|
5129
|
+
const { mutateAsync: setKey, isPending: isSettingKey } = useSetSimpleKey(dataKey, type);
|
|
5096
5130
|
const handleCancel = () => {
|
|
5097
5131
|
form.reset();
|
|
5098
5132
|
};
|
|
@@ -5529,6 +5563,9 @@ function Sidebar() {
|
|
|
5529
5563
|
queryClient.invalidateQueries({
|
|
5530
5564
|
queryKey: [FETCH_LIST_ITEMS_QUERY_KEY]
|
|
5531
5565
|
});
|
|
5566
|
+
queryClient.invalidateQueries({
|
|
5567
|
+
queryKey: [FETCH_SIMPLE_KEY_QUERY_KEY]
|
|
5568
|
+
});
|
|
5532
5569
|
queryClient.invalidateQueries({
|
|
5533
5570
|
queryKey: [FETCH_DB_SIZE_QUERY_KEY]
|
|
5534
5571
|
});
|
|
@@ -5552,7 +5589,7 @@ function Sidebar() {
|
|
|
5552
5589
|
import { jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
5553
5590
|
var RedisBrowser = ({ token, url }) => {
|
|
5554
5591
|
const credentials = useMemo6(() => ({ token, url }), [token, url]);
|
|
5555
|
-
|
|
5592
|
+
useEffect10(() => {
|
|
5556
5593
|
queryClient.resetQueries();
|
|
5557
5594
|
}, [credentials.url]);
|
|
5558
5595
|
return /* @__PURE__ */ jsx42(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx42(TooltipProvider, { children: /* @__PURE__ */ jsx42(DatabrowserProvider, { redisCredentials: credentials, children: /* @__PURE__ */ jsx42(KeysProvider, { children: /* @__PURE__ */ jsxs31("div", { className: "ups-db", style: { height: "100%" }, children: [
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "@upstash/react-redis-browser", "version": "v0.1.
|
|
1
|
+
{ "name": "@upstash/react-redis-browser", "version": "v0.1.5", "main": "./dist/index.js", "types": "./dist/index.d.ts", "license": "MIT", "private": false, "publishConfig": { "access": "public" }, "bugs": { "url": "https://github.com/upstash/react-redis-browser/issues" }, "homepage": "https://github.com/upstash/react-redis-browser", "files": [ "./dist/**" ], "scripts": { "build": "tsup", "dev": "vite", "lint": "tsc && eslint", "fmt": "prettier --write ./src" }, "lint-staged": { "**/*.{js,ts,tsx}": [ "prettier --write", "eslint --fix" ] }, "dependencies": { "@ianvs/prettier-plugin-sort-imports": "^4.4.0", "@monaco-editor/react": "^4.6.0", "@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-context-menu": "^2.2.2", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dropdown-menu": "^2.1.2", "@radix-ui/react-icons": "1.3.0", "@radix-ui/react-popover": "^1.0.7", "@radix-ui/react-portal": "^1.1.2", "@radix-ui/react-scroll-area": "^1.0.3", "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-toast": "^1.1.5", "@radix-ui/react-tooltip": "^1.0.7", "@tabler/icons-react": "^3.19.0", "@tanstack/react-query": "^5.32.0", "@types/bytes": "^3.1.4", "@upstash/redis": "^1.34.3", "bytes": "^3.1.2", "react-hook-form": "^7.53.0", "react-resizable-panels": "^2.1.4", "zustand": "5.0.0" }, "devDependencies": { "postcss-prefix-selector": "^2.1.0", "@types/node": "^22.8.4", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@typescript-eslint/eslint-plugin": "8.4.0", "@typescript-eslint/parser": "8.4.0", "@vitejs/plugin-react": "^4.1.0", "autoprefixer": "^10.4.14", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", "eslint": "9.10.0", "eslint-plugin-unicorn": "55.0.0", "postcss": "^8.4.31", "prettier": "^3.0.3", "prettier-plugin-tailwindcss": "^0.5.5", "react": "^18.3.1", "react-dom": "^18.3.1", "tailwind-merge": "^2.5.4", "tailwindcss": "^3.4.14", "tailwindcss-animate": "^1.0.7", "tsup": "^8.3.5", "typescript": "^5.0.4", "vite": "^5.4.10", "vite-tsconfig-paths": "^5.0.1" }, "peerDependencies": { "react": "^18.2.0 || ^19", "react-dom": "^18.2.0 || ^19" } }
|