@upstash/react-redis-browser 0.2.1 → 0.2.2
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.css +53 -0
- package/dist/index.js +163 -5
- package/dist/index.mjs +166 -8
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -374,6 +374,9 @@
|
|
|
374
374
|
.ups-db .pointer-events-auto {
|
|
375
375
|
pointer-events: auto;
|
|
376
376
|
}
|
|
377
|
+
.ups-db .visible {
|
|
378
|
+
visibility: visible;
|
|
379
|
+
}
|
|
377
380
|
.ups-db .fixed {
|
|
378
381
|
position: fixed;
|
|
379
382
|
}
|
|
@@ -692,6 +695,9 @@
|
|
|
692
695
|
--tw-translate-y: 1px;
|
|
693
696
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
694
697
|
}
|
|
698
|
+
.ups-db .transform {
|
|
699
|
+
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
700
|
+
}
|
|
695
701
|
@keyframes pulse {
|
|
696
702
|
50% {
|
|
697
703
|
opacity: .5;
|
|
@@ -711,6 +717,12 @@
|
|
|
711
717
|
.ups-db .cursor-default {
|
|
712
718
|
cursor: default;
|
|
713
719
|
}
|
|
720
|
+
.ups-db .cursor-grab {
|
|
721
|
+
cursor: grab;
|
|
722
|
+
}
|
|
723
|
+
.ups-db .cursor-grabbing {
|
|
724
|
+
cursor: grabbing;
|
|
725
|
+
}
|
|
714
726
|
.ups-db .cursor-pointer {
|
|
715
727
|
cursor: pointer;
|
|
716
728
|
}
|
|
@@ -1404,6 +1416,47 @@
|
|
|
1404
1416
|
-webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
|
|
1405
1417
|
backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
|
|
1406
1418
|
}
|
|
1419
|
+
.ups-db .transition {
|
|
1420
|
+
transition-property:
|
|
1421
|
+
color,
|
|
1422
|
+
background-color,
|
|
1423
|
+
border-color,
|
|
1424
|
+
text-decoration-color,
|
|
1425
|
+
fill,
|
|
1426
|
+
stroke,
|
|
1427
|
+
opacity,
|
|
1428
|
+
box-shadow,
|
|
1429
|
+
transform,
|
|
1430
|
+
filter,
|
|
1431
|
+
-webkit-backdrop-filter;
|
|
1432
|
+
transition-property:
|
|
1433
|
+
color,
|
|
1434
|
+
background-color,
|
|
1435
|
+
border-color,
|
|
1436
|
+
text-decoration-color,
|
|
1437
|
+
fill,
|
|
1438
|
+
stroke,
|
|
1439
|
+
opacity,
|
|
1440
|
+
box-shadow,
|
|
1441
|
+
transform,
|
|
1442
|
+
filter,
|
|
1443
|
+
backdrop-filter;
|
|
1444
|
+
transition-property:
|
|
1445
|
+
color,
|
|
1446
|
+
background-color,
|
|
1447
|
+
border-color,
|
|
1448
|
+
text-decoration-color,
|
|
1449
|
+
fill,
|
|
1450
|
+
stroke,
|
|
1451
|
+
opacity,
|
|
1452
|
+
box-shadow,
|
|
1453
|
+
transform,
|
|
1454
|
+
filter,
|
|
1455
|
+
backdrop-filter,
|
|
1456
|
+
-webkit-backdrop-filter;
|
|
1457
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
1458
|
+
transition-duration: 150ms;
|
|
1459
|
+
}
|
|
1407
1460
|
.ups-db .transition-all {
|
|
1408
1461
|
transition-property: all;
|
|
1409
1462
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
package/dist/index.js
CHANGED
|
@@ -278,6 +278,15 @@ var storeCreator = (set, get) => ({
|
|
|
278
278
|
tabs: [...old.tabs, [id, newTabData]],
|
|
279
279
|
selectedTab: id
|
|
280
280
|
}));
|
|
281
|
+
return id;
|
|
282
|
+
},
|
|
283
|
+
reorderTabs: (oldIndex, newIndex) => {
|
|
284
|
+
set((old) => {
|
|
285
|
+
const newTabs = [...old.tabs];
|
|
286
|
+
const [movedTab] = newTabs.splice(oldIndex, 1);
|
|
287
|
+
newTabs.splice(newIndex, 0, movedTab);
|
|
288
|
+
return { ...old, tabs: newTabs };
|
|
289
|
+
});
|
|
281
290
|
},
|
|
282
291
|
removeTab: (id) => {
|
|
283
292
|
set((old) => {
|
|
@@ -393,7 +402,8 @@ var useTab = () => {
|
|
|
393
402
|
} = useDatabrowserStore();
|
|
394
403
|
const tabId = useTabId();
|
|
395
404
|
const tabData = _react.useMemo.call(void 0, () => _optionalChain([tabs, 'access', _10 => _10.find, 'call', _11 => _11(([id]) => id === tabId), 'optionalAccess', _12 => _12[1]]), [tabs, tabId]);
|
|
396
|
-
if (!selectedTab
|
|
405
|
+
if (!selectedTab) throw new Error("selectedTab is undefined when using useTab()");
|
|
406
|
+
if (!tabData) throw new Error("tabData is undefined when using useTab()");
|
|
397
407
|
return _react.useMemo.call(void 0,
|
|
398
408
|
() => ({
|
|
399
409
|
active: selectedTab === tabId,
|
|
@@ -4394,6 +4404,7 @@ var ItemContextMenu = ({
|
|
|
4394
4404
|
const { mutate: editItem } = useEditListItem();
|
|
4395
4405
|
const [isAlertOpen, setAlertOpen] = _react.useState.call(void 0, false);
|
|
4396
4406
|
const [data, setData] = _react.useState.call(void 0, );
|
|
4407
|
+
const { addTab, setSelectedKey, selectTab, setSelectedListItem } = useDatabrowserStore();
|
|
4397
4408
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4398
4409
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4399
4410
|
DeleteAlertDialog,
|
|
@@ -4462,6 +4473,21 @@ var ItemContextMenu = ({
|
|
|
4462
4473
|
children: "Copy value"
|
|
4463
4474
|
}
|
|
4464
4475
|
),
|
|
4476
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4477
|
+
ContextMenuItem,
|
|
4478
|
+
{
|
|
4479
|
+
onClick: () => {
|
|
4480
|
+
if (!data) return;
|
|
4481
|
+
const newTabId = addTab();
|
|
4482
|
+
selectTab(newTabId);
|
|
4483
|
+
setSelectedKey(newTabId, dataKey);
|
|
4484
|
+
setSelectedListItem(newTabId, {
|
|
4485
|
+
key: data.key
|
|
4486
|
+
});
|
|
4487
|
+
},
|
|
4488
|
+
children: "Open in new tab"
|
|
4489
|
+
}
|
|
4490
|
+
),
|
|
4465
4491
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcontextmenu.ContextMenuSeparator, {}),
|
|
4466
4492
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContextMenuItem, { disabled: type === "stream", onClick: () => setAlertOpen(true), children: "Delete item" })
|
|
4467
4493
|
] })
|
|
@@ -5675,6 +5701,8 @@ var SidebarContextMenu = ({ children }) => {
|
|
|
5675
5701
|
const { mutate: deleteKey } = useDeleteKey();
|
|
5676
5702
|
const [isAlertOpen, setAlertOpen] = _react.useState.call(void 0, false);
|
|
5677
5703
|
const [dataKey, setDataKey] = _react.useState.call(void 0, "");
|
|
5704
|
+
const { addTab, setSelectedKey, selectTab, setSearch } = useDatabrowserStore();
|
|
5705
|
+
const { search: currentSearch } = useTab();
|
|
5678
5706
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
5679
5707
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5680
5708
|
DeleteAlertDialog,
|
|
@@ -5718,6 +5746,18 @@ var SidebarContextMenu = ({ children }) => {
|
|
|
5718
5746
|
children: "Copy key"
|
|
5719
5747
|
}
|
|
5720
5748
|
),
|
|
5749
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5750
|
+
ContextMenuItem,
|
|
5751
|
+
{
|
|
5752
|
+
onClick: () => {
|
|
5753
|
+
const newTabId = addTab();
|
|
5754
|
+
setSelectedKey(newTabId, dataKey);
|
|
5755
|
+
setSearch(newTabId, currentSearch);
|
|
5756
|
+
selectTab(newTabId);
|
|
5757
|
+
},
|
|
5758
|
+
children: "Open in new tab"
|
|
5759
|
+
}
|
|
5760
|
+
),
|
|
5721
5761
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcontextmenu.ContextMenuSeparator, {}),
|
|
5722
5762
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContextMenuItem, { onClick: () => setAlertOpen(true), children: "Delete key" })
|
|
5723
5763
|
] })
|
|
@@ -5998,6 +6038,18 @@ var DatabrowserInstance = ({ hidden }) => {
|
|
|
5998
6038
|
// src/components/databrowser/components/databrowser-tabs.tsx
|
|
5999
6039
|
|
|
6000
6040
|
|
|
6041
|
+
|
|
6042
|
+
|
|
6043
|
+
|
|
6044
|
+
|
|
6045
|
+
|
|
6046
|
+
|
|
6047
|
+
var _core = require('@dnd-kit/core');
|
|
6048
|
+
var _modifiers = require('@dnd-kit/modifiers');
|
|
6049
|
+
var _sortable = require('@dnd-kit/sortable');
|
|
6050
|
+
var _utilities = require('@dnd-kit/utilities');
|
|
6051
|
+
|
|
6052
|
+
|
|
6001
6053
|
// src/components/databrowser/components/tab.tsx
|
|
6002
6054
|
|
|
6003
6055
|
|
|
@@ -6074,12 +6126,116 @@ var Tab = ({ id }) => {
|
|
|
6074
6126
|
|
|
6075
6127
|
// src/components/databrowser/components/databrowser-tabs.tsx
|
|
6076
6128
|
|
|
6129
|
+
var SortableTab = ({ id }) => {
|
|
6130
|
+
const [originalWidth, setOriginalWidth] = _react.useState.call(void 0, null);
|
|
6131
|
+
const textRef = _react.useRef.call(void 0, null);
|
|
6132
|
+
const { attributes, listeners: listeners2, setNodeRef, transform, transition, isDragging } = _sortable.useSortable.call(void 0, {
|
|
6133
|
+
id,
|
|
6134
|
+
resizeObserverConfig: {
|
|
6135
|
+
disabled: true
|
|
6136
|
+
}
|
|
6137
|
+
});
|
|
6138
|
+
const measureRef = (element) => {
|
|
6139
|
+
if (element && !originalWidth) {
|
|
6140
|
+
const width = element.getBoundingClientRect().width;
|
|
6141
|
+
setOriginalWidth(width);
|
|
6142
|
+
if (element) {
|
|
6143
|
+
const textSpan = element.querySelector("span");
|
|
6144
|
+
if (textSpan) {
|
|
6145
|
+
textRef.current = textSpan;
|
|
6146
|
+
}
|
|
6147
|
+
}
|
|
6148
|
+
}
|
|
6149
|
+
setNodeRef(element);
|
|
6150
|
+
};
|
|
6151
|
+
_react.useEffect.call(void 0, () => {
|
|
6152
|
+
if (textRef.current && isDragging) {
|
|
6153
|
+
const originalMaxWidth = textRef.current.style.maxWidth;
|
|
6154
|
+
const originalWhiteSpace = textRef.current.style.whiteSpace;
|
|
6155
|
+
const originalOverflow = textRef.current.style.overflow;
|
|
6156
|
+
const originalTextOverflow = textRef.current.style.textOverflow;
|
|
6157
|
+
textRef.current.style.maxWidth = "none";
|
|
6158
|
+
textRef.current.style.whiteSpace = "nowrap";
|
|
6159
|
+
textRef.current.style.overflow = "visible";
|
|
6160
|
+
textRef.current.style.textOverflow = "clip";
|
|
6161
|
+
return () => {
|
|
6162
|
+
if (textRef.current) {
|
|
6163
|
+
textRef.current.style.maxWidth = originalMaxWidth;
|
|
6164
|
+
textRef.current.style.whiteSpace = originalWhiteSpace;
|
|
6165
|
+
textRef.current.style.overflow = originalOverflow;
|
|
6166
|
+
textRef.current.style.textOverflow = originalTextOverflow;
|
|
6167
|
+
}
|
|
6168
|
+
};
|
|
6169
|
+
}
|
|
6170
|
+
}, [isDragging]);
|
|
6171
|
+
_react.useEffect.call(void 0, () => {
|
|
6172
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
6173
|
+
if (entries[0]) {
|
|
6174
|
+
setOriginalWidth(entries[0].contentRect.width);
|
|
6175
|
+
}
|
|
6176
|
+
});
|
|
6177
|
+
return () => resizeObserver.disconnect();
|
|
6178
|
+
}, []);
|
|
6179
|
+
const style = {
|
|
6180
|
+
transform: transform ? _utilities.CSS.Transform.toString({
|
|
6181
|
+
...transform,
|
|
6182
|
+
y: 0,
|
|
6183
|
+
scaleX: 1,
|
|
6184
|
+
scaleY: 1
|
|
6185
|
+
}) : "",
|
|
6186
|
+
transition,
|
|
6187
|
+
...isDragging ? {
|
|
6188
|
+
zIndex: 50,
|
|
6189
|
+
minWidth: originalWidth ? `${originalWidth}px` : void 0
|
|
6190
|
+
} : {}
|
|
6191
|
+
};
|
|
6192
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
6193
|
+
"div",
|
|
6194
|
+
{
|
|
6195
|
+
ref: measureRef,
|
|
6196
|
+
style,
|
|
6197
|
+
className: isDragging ? "cursor-grabbing" : "cursor-grab",
|
|
6198
|
+
...attributes,
|
|
6199
|
+
...listeners2,
|
|
6200
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TabIdProvider, { value: id, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tab, { id }) })
|
|
6201
|
+
}
|
|
6202
|
+
);
|
|
6203
|
+
};
|
|
6077
6204
|
var DatabrowserTabs = () => {
|
|
6078
|
-
const { tabs, addTab } = useDatabrowserStore();
|
|
6205
|
+
const { tabs, addTab, reorderTabs, selectedTab } = useDatabrowserStore();
|
|
6206
|
+
const sensors = _core.useSensors.call(void 0,
|
|
6207
|
+
_core.useSensor.call(void 0, _core.PointerSensor, {
|
|
6208
|
+
activationConstraint: {
|
|
6209
|
+
distance: 5
|
|
6210
|
+
}
|
|
6211
|
+
})
|
|
6212
|
+
);
|
|
6213
|
+
const handleDragEnd = (event) => {
|
|
6214
|
+
const { active, over } = event;
|
|
6215
|
+
if (over && active.id !== over.id) {
|
|
6216
|
+
const oldIndex = tabs.findIndex(([id]) => id === active.id);
|
|
6217
|
+
const newIndex = tabs.findIndex(([id]) => id === over.id);
|
|
6218
|
+
reorderTabs(oldIndex, newIndex);
|
|
6219
|
+
}
|
|
6220
|
+
};
|
|
6079
6221
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative mb-2 shrink-0", children: [
|
|
6080
6222
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "absolute bottom-0 left-0 right-0 -z-10 h-[1px] w-full bg-zinc-200" }),
|
|
6081
6223
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "scrollbar-hide flex translate-y-[1px] items-center gap-1 overflow-x-scroll pb-[1px] [&::-webkit-scrollbar]:hidden", children: [
|
|
6082
|
-
|
|
6224
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
6225
|
+
_core.DndContext,
|
|
6226
|
+
{
|
|
6227
|
+
sensors,
|
|
6228
|
+
collisionDetection: _core.closestCenter,
|
|
6229
|
+
onDragEnd: handleDragEnd,
|
|
6230
|
+
modifiers: [_modifiers.restrictToHorizontalAxis],
|
|
6231
|
+
measuring: {
|
|
6232
|
+
droppable: {
|
|
6233
|
+
strategy: _core.MeasuringStrategy.Always
|
|
6234
|
+
}
|
|
6235
|
+
},
|
|
6236
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _sortable.SortableContext, { items: tabs.map(([id]) => id), strategy: _sortable.horizontalListSortingStrategy, children: selectedTab && tabs.map(([id]) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SortableTab, { id }, id)) })
|
|
6237
|
+
}
|
|
6238
|
+
),
|
|
6083
6239
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
6084
6240
|
Button,
|
|
6085
6241
|
{
|
|
@@ -6120,10 +6276,12 @@ var RedisBrowser = ({
|
|
|
6120
6276
|
) }) }) }) });
|
|
6121
6277
|
};
|
|
6122
6278
|
var DatabrowserInstances = () => {
|
|
6123
|
-
const { tabs, selectedTab, addTab } = useDatabrowserStore();
|
|
6279
|
+
const { tabs, selectedTab, selectTab, addTab } = useDatabrowserStore();
|
|
6124
6280
|
_react.useEffect.call(void 0, () => {
|
|
6125
6281
|
if (tabs.length === 0) addTab();
|
|
6126
|
-
|
|
6282
|
+
else if (!selectedTab) selectTab(tabs[0][0]);
|
|
6283
|
+
}, [tabs, selectedTab, addTab, selectTab]);
|
|
6284
|
+
if (!selectedTab) return;
|
|
6127
6285
|
return tabs.map(([id]) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TabIdProvider, { value: id, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DatabrowserInstance, { hidden: id !== selectedTab }) }, id));
|
|
6128
6286
|
};
|
|
6129
6287
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/databrowser/index.tsx
|
|
2
|
-
import { useEffect as
|
|
2
|
+
import { useEffect as useEffect14, useMemo as useMemo8 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/redis-context.tsx
|
|
5
5
|
import { createContext, useContext, useMemo } from "react";
|
|
@@ -278,6 +278,15 @@ var storeCreator = (set, get) => ({
|
|
|
278
278
|
tabs: [...old.tabs, [id, newTabData]],
|
|
279
279
|
selectedTab: id
|
|
280
280
|
}));
|
|
281
|
+
return id;
|
|
282
|
+
},
|
|
283
|
+
reorderTabs: (oldIndex, newIndex) => {
|
|
284
|
+
set((old) => {
|
|
285
|
+
const newTabs = [...old.tabs];
|
|
286
|
+
const [movedTab] = newTabs.splice(oldIndex, 1);
|
|
287
|
+
newTabs.splice(newIndex, 0, movedTab);
|
|
288
|
+
return { ...old, tabs: newTabs };
|
|
289
|
+
});
|
|
281
290
|
},
|
|
282
291
|
removeTab: (id) => {
|
|
283
292
|
set((old) => {
|
|
@@ -393,7 +402,8 @@ var useTab = () => {
|
|
|
393
402
|
} = useDatabrowserStore();
|
|
394
403
|
const tabId = useTabId();
|
|
395
404
|
const tabData = useMemo3(() => tabs.find(([id]) => id === tabId)?.[1], [tabs, tabId]);
|
|
396
|
-
if (!selectedTab
|
|
405
|
+
if (!selectedTab) throw new Error("selectedTab is undefined when using useTab()");
|
|
406
|
+
if (!tabData) throw new Error("tabData is undefined when using useTab()");
|
|
397
407
|
return useMemo3(
|
|
398
408
|
() => ({
|
|
399
409
|
active: selectedTab === tabId,
|
|
@@ -4394,6 +4404,7 @@ var ItemContextMenu = ({
|
|
|
4394
4404
|
const { mutate: editItem } = useEditListItem();
|
|
4395
4405
|
const [isAlertOpen, setAlertOpen] = useState5(false);
|
|
4396
4406
|
const [data, setData] = useState5();
|
|
4407
|
+
const { addTab, setSelectedKey, selectTab, setSelectedListItem } = useDatabrowserStore();
|
|
4397
4408
|
return /* @__PURE__ */ jsxs11(Fragment2, { children: [
|
|
4398
4409
|
/* @__PURE__ */ jsx20(
|
|
4399
4410
|
DeleteAlertDialog,
|
|
@@ -4462,6 +4473,21 @@ var ItemContextMenu = ({
|
|
|
4462
4473
|
children: "Copy value"
|
|
4463
4474
|
}
|
|
4464
4475
|
),
|
|
4476
|
+
/* @__PURE__ */ jsx20(
|
|
4477
|
+
ContextMenuItem,
|
|
4478
|
+
{
|
|
4479
|
+
onClick: () => {
|
|
4480
|
+
if (!data) return;
|
|
4481
|
+
const newTabId = addTab();
|
|
4482
|
+
selectTab(newTabId);
|
|
4483
|
+
setSelectedKey(newTabId, dataKey);
|
|
4484
|
+
setSelectedListItem(newTabId, {
|
|
4485
|
+
key: data.key
|
|
4486
|
+
});
|
|
4487
|
+
},
|
|
4488
|
+
children: "Open in new tab"
|
|
4489
|
+
}
|
|
4490
|
+
),
|
|
4465
4491
|
/* @__PURE__ */ jsx20(ContextMenuSeparator2, {}),
|
|
4466
4492
|
/* @__PURE__ */ jsx20(ContextMenuItem, { disabled: type === "stream", onClick: () => setAlertOpen(true), children: "Delete item" })
|
|
4467
4493
|
] })
|
|
@@ -5675,6 +5701,8 @@ var SidebarContextMenu = ({ children }) => {
|
|
|
5675
5701
|
const { mutate: deleteKey } = useDeleteKey();
|
|
5676
5702
|
const [isAlertOpen, setAlertOpen] = useState10(false);
|
|
5677
5703
|
const [dataKey, setDataKey] = useState10("");
|
|
5704
|
+
const { addTab, setSelectedKey, selectTab, setSearch } = useDatabrowserStore();
|
|
5705
|
+
const { search: currentSearch } = useTab();
|
|
5678
5706
|
return /* @__PURE__ */ jsxs26(Fragment8, { children: [
|
|
5679
5707
|
/* @__PURE__ */ jsx41(
|
|
5680
5708
|
DeleteAlertDialog,
|
|
@@ -5718,6 +5746,18 @@ var SidebarContextMenu = ({ children }) => {
|
|
|
5718
5746
|
children: "Copy key"
|
|
5719
5747
|
}
|
|
5720
5748
|
),
|
|
5749
|
+
/* @__PURE__ */ jsx41(
|
|
5750
|
+
ContextMenuItem,
|
|
5751
|
+
{
|
|
5752
|
+
onClick: () => {
|
|
5753
|
+
const newTabId = addTab();
|
|
5754
|
+
setSelectedKey(newTabId, dataKey);
|
|
5755
|
+
setSearch(newTabId, currentSearch);
|
|
5756
|
+
selectTab(newTabId);
|
|
5757
|
+
},
|
|
5758
|
+
children: "Open in new tab"
|
|
5759
|
+
}
|
|
5760
|
+
),
|
|
5721
5761
|
/* @__PURE__ */ jsx41(ContextMenuSeparator3, {}),
|
|
5722
5762
|
/* @__PURE__ */ jsx41(ContextMenuItem, { onClick: () => setAlertOpen(true), children: "Delete key" })
|
|
5723
5763
|
] })
|
|
@@ -5996,6 +6036,18 @@ var DatabrowserInstance = ({ hidden }) => {
|
|
|
5996
6036
|
};
|
|
5997
6037
|
|
|
5998
6038
|
// src/components/databrowser/components/databrowser-tabs.tsx
|
|
6039
|
+
import { useEffect as useEffect13, useRef as useRef5, useState as useState13 } from "react";
|
|
6040
|
+
import {
|
|
6041
|
+
closestCenter,
|
|
6042
|
+
DndContext,
|
|
6043
|
+
MeasuringStrategy,
|
|
6044
|
+
PointerSensor,
|
|
6045
|
+
useSensor,
|
|
6046
|
+
useSensors
|
|
6047
|
+
} from "@dnd-kit/core";
|
|
6048
|
+
import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
|
|
6049
|
+
import { horizontalListSortingStrategy, SortableContext, useSortable } from "@dnd-kit/sortable";
|
|
6050
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
5999
6051
|
import { IconPlus as IconPlus2 } from "@tabler/icons-react";
|
|
6000
6052
|
|
|
6001
6053
|
// src/components/databrowser/components/tab.tsx
|
|
@@ -6074,12 +6126,116 @@ var Tab = ({ id }) => {
|
|
|
6074
6126
|
|
|
6075
6127
|
// src/components/databrowser/components/databrowser-tabs.tsx
|
|
6076
6128
|
import { jsx as jsx50, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
6129
|
+
var SortableTab = ({ id }) => {
|
|
6130
|
+
const [originalWidth, setOriginalWidth] = useState13(null);
|
|
6131
|
+
const textRef = useRef5(null);
|
|
6132
|
+
const { attributes, listeners: listeners2, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
6133
|
+
id,
|
|
6134
|
+
resizeObserverConfig: {
|
|
6135
|
+
disabled: true
|
|
6136
|
+
}
|
|
6137
|
+
});
|
|
6138
|
+
const measureRef = (element) => {
|
|
6139
|
+
if (element && !originalWidth) {
|
|
6140
|
+
const width = element.getBoundingClientRect().width;
|
|
6141
|
+
setOriginalWidth(width);
|
|
6142
|
+
if (element) {
|
|
6143
|
+
const textSpan = element.querySelector("span");
|
|
6144
|
+
if (textSpan) {
|
|
6145
|
+
textRef.current = textSpan;
|
|
6146
|
+
}
|
|
6147
|
+
}
|
|
6148
|
+
}
|
|
6149
|
+
setNodeRef(element);
|
|
6150
|
+
};
|
|
6151
|
+
useEffect13(() => {
|
|
6152
|
+
if (textRef.current && isDragging) {
|
|
6153
|
+
const originalMaxWidth = textRef.current.style.maxWidth;
|
|
6154
|
+
const originalWhiteSpace = textRef.current.style.whiteSpace;
|
|
6155
|
+
const originalOverflow = textRef.current.style.overflow;
|
|
6156
|
+
const originalTextOverflow = textRef.current.style.textOverflow;
|
|
6157
|
+
textRef.current.style.maxWidth = "none";
|
|
6158
|
+
textRef.current.style.whiteSpace = "nowrap";
|
|
6159
|
+
textRef.current.style.overflow = "visible";
|
|
6160
|
+
textRef.current.style.textOverflow = "clip";
|
|
6161
|
+
return () => {
|
|
6162
|
+
if (textRef.current) {
|
|
6163
|
+
textRef.current.style.maxWidth = originalMaxWidth;
|
|
6164
|
+
textRef.current.style.whiteSpace = originalWhiteSpace;
|
|
6165
|
+
textRef.current.style.overflow = originalOverflow;
|
|
6166
|
+
textRef.current.style.textOverflow = originalTextOverflow;
|
|
6167
|
+
}
|
|
6168
|
+
};
|
|
6169
|
+
}
|
|
6170
|
+
}, [isDragging]);
|
|
6171
|
+
useEffect13(() => {
|
|
6172
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
6173
|
+
if (entries[0]) {
|
|
6174
|
+
setOriginalWidth(entries[0].contentRect.width);
|
|
6175
|
+
}
|
|
6176
|
+
});
|
|
6177
|
+
return () => resizeObserver.disconnect();
|
|
6178
|
+
}, []);
|
|
6179
|
+
const style = {
|
|
6180
|
+
transform: transform ? CSS.Transform.toString({
|
|
6181
|
+
...transform,
|
|
6182
|
+
y: 0,
|
|
6183
|
+
scaleX: 1,
|
|
6184
|
+
scaleY: 1
|
|
6185
|
+
}) : "",
|
|
6186
|
+
transition,
|
|
6187
|
+
...isDragging ? {
|
|
6188
|
+
zIndex: 50,
|
|
6189
|
+
minWidth: originalWidth ? `${originalWidth}px` : void 0
|
|
6190
|
+
} : {}
|
|
6191
|
+
};
|
|
6192
|
+
return /* @__PURE__ */ jsx50(
|
|
6193
|
+
"div",
|
|
6194
|
+
{
|
|
6195
|
+
ref: measureRef,
|
|
6196
|
+
style,
|
|
6197
|
+
className: isDragging ? "cursor-grabbing" : "cursor-grab",
|
|
6198
|
+
...attributes,
|
|
6199
|
+
...listeners2,
|
|
6200
|
+
children: /* @__PURE__ */ jsx50(TabIdProvider, { value: id, children: /* @__PURE__ */ jsx50(Tab, { id }) })
|
|
6201
|
+
}
|
|
6202
|
+
);
|
|
6203
|
+
};
|
|
6077
6204
|
var DatabrowserTabs = () => {
|
|
6078
|
-
const { tabs, addTab } = useDatabrowserStore();
|
|
6205
|
+
const { tabs, addTab, reorderTabs, selectedTab } = useDatabrowserStore();
|
|
6206
|
+
const sensors = useSensors(
|
|
6207
|
+
useSensor(PointerSensor, {
|
|
6208
|
+
activationConstraint: {
|
|
6209
|
+
distance: 5
|
|
6210
|
+
}
|
|
6211
|
+
})
|
|
6212
|
+
);
|
|
6213
|
+
const handleDragEnd = (event) => {
|
|
6214
|
+
const { active, over } = event;
|
|
6215
|
+
if (over && active.id !== over.id) {
|
|
6216
|
+
const oldIndex = tabs.findIndex(([id]) => id === active.id);
|
|
6217
|
+
const newIndex = tabs.findIndex(([id]) => id === over.id);
|
|
6218
|
+
reorderTabs(oldIndex, newIndex);
|
|
6219
|
+
}
|
|
6220
|
+
};
|
|
6079
6221
|
return /* @__PURE__ */ jsxs34("div", { className: "relative mb-2 shrink-0", children: [
|
|
6080
6222
|
/* @__PURE__ */ jsx50("div", { className: "absolute bottom-0 left-0 right-0 -z-10 h-[1px] w-full bg-zinc-200" }),
|
|
6081
6223
|
/* @__PURE__ */ jsxs34("div", { className: "scrollbar-hide flex translate-y-[1px] items-center gap-1 overflow-x-scroll pb-[1px] [&::-webkit-scrollbar]:hidden", children: [
|
|
6082
|
-
|
|
6224
|
+
/* @__PURE__ */ jsx50(
|
|
6225
|
+
DndContext,
|
|
6226
|
+
{
|
|
6227
|
+
sensors,
|
|
6228
|
+
collisionDetection: closestCenter,
|
|
6229
|
+
onDragEnd: handleDragEnd,
|
|
6230
|
+
modifiers: [restrictToHorizontalAxis],
|
|
6231
|
+
measuring: {
|
|
6232
|
+
droppable: {
|
|
6233
|
+
strategy: MeasuringStrategy.Always
|
|
6234
|
+
}
|
|
6235
|
+
},
|
|
6236
|
+
children: /* @__PURE__ */ jsx50(SortableContext, { items: tabs.map(([id]) => id), strategy: horizontalListSortingStrategy, children: selectedTab && tabs.map(([id]) => /* @__PURE__ */ jsx50(SortableTab, { id }, id)) })
|
|
6237
|
+
}
|
|
6238
|
+
),
|
|
6083
6239
|
/* @__PURE__ */ jsx50(
|
|
6084
6240
|
Button,
|
|
6085
6241
|
{
|
|
@@ -6104,7 +6260,7 @@ var RedisBrowser = ({
|
|
|
6104
6260
|
storage
|
|
6105
6261
|
}) => {
|
|
6106
6262
|
const credentials = useMemo8(() => ({ token, url }), [token, url]);
|
|
6107
|
-
|
|
6263
|
+
useEffect14(() => {
|
|
6108
6264
|
queryClient.resetQueries();
|
|
6109
6265
|
}, [credentials.url]);
|
|
6110
6266
|
return /* @__PURE__ */ jsx51(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx51(RedisProvider, { redisCredentials: credentials, children: /* @__PURE__ */ jsx51(DatabrowserProvider, { storage, children: /* @__PURE__ */ jsx51(TooltipProvider, { children: /* @__PURE__ */ jsxs35(
|
|
@@ -6120,10 +6276,12 @@ var RedisBrowser = ({
|
|
|
6120
6276
|
) }) }) }) });
|
|
6121
6277
|
};
|
|
6122
6278
|
var DatabrowserInstances = () => {
|
|
6123
|
-
const { tabs, selectedTab, addTab } = useDatabrowserStore();
|
|
6124
|
-
|
|
6279
|
+
const { tabs, selectedTab, selectTab, addTab } = useDatabrowserStore();
|
|
6280
|
+
useEffect14(() => {
|
|
6125
6281
|
if (tabs.length === 0) addTab();
|
|
6126
|
-
|
|
6282
|
+
else if (!selectedTab) selectTab(tabs[0][0]);
|
|
6283
|
+
}, [tabs, selectedTab, addTab, selectTab]);
|
|
6284
|
+
if (!selectedTab) return;
|
|
6127
6285
|
return tabs.map(([id]) => /* @__PURE__ */ jsx51(TabIdProvider, { value: id, children: /* @__PURE__ */ jsx51(DatabrowserInstance, { hidden: id !== selectedTab }) }, id));
|
|
6128
6286
|
};
|
|
6129
6287
|
export {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "@upstash/react-redis-browser", "version": "v0.2.
|
|
1
|
+
{ "name": "@upstash/react-redis-browser", "version": "v0.2.2", "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": { "@dnd-kit/core": "^6.3.1", "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", "@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.15", "@radix-ui/react-icons": "1.3.0", "@radix-ui/react-label": "^2.1.7", "@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.8", "bytes": "^3.1.2", "react-hook-form": "^7.53.0", "react-resizable-panels": "^2.1.4", "zustand": "5.0.0" }, "devDependencies": { "@playwright/test": "^1.53.1", "@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", "dotenv": "^16.5.0", "eslint": "9.10.0", "eslint-plugin-unicorn": "55.0.0", "postcss": "^8.4.31", "postcss-prefix-selector": "^2.1.0", "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" } }
|