@buoy-gg/zustand 7.0.30 → 7.0.32
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/lib/commonjs/zustand/components/ZustandActionButton.js +3 -1
- package/lib/commonjs/zustand/components/ZustandDetailViewToggle.js +7 -0
- package/lib/commonjs/zustand/components/ZustandEventFilterView.js +19 -4
- package/lib/commonjs/zustand/components/ZustandModal.js +174 -32
- package/lib/commonjs/zustand/components/ZustandStateChangeItem.js +36 -37
- package/lib/commonjs/zustand/components/ZustandStateDetailContent.js +22 -5
- package/lib/commonjs/zustand/components/ZustandStateInfoView.js +30 -7
- package/lib/commonjs/zustand/components/ZustandStoreBrowser.js +23 -126
- package/lib/commonjs/zustand/components/ZustandStoreDetailContent.js +471 -0
- package/lib/commonjs/zustand/components/ZustandStoreEditorScreen.js +393 -0
- package/lib/commonjs/zustand/sync/zustandSyncAdapter.js +54 -0
- package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +71 -7
- package/lib/commonjs/zustand/utils/editableState.js +139 -0
- package/lib/commonjs/zustand/utils/snapshotProvider.js +10 -37
- package/lib/commonjs/zustand/utils/testIDs.js +82 -0
- package/lib/commonjs/zustand/utils/zustandStateStore.js +16 -3
- package/lib/module/zustand/components/ZustandActionButton.js +3 -1
- package/lib/module/zustand/components/ZustandDetailViewToggle.js +7 -0
- package/lib/module/zustand/components/ZustandEventFilterView.js +19 -4
- package/lib/module/zustand/components/ZustandModal.js +175 -33
- package/lib/module/zustand/components/ZustandStateChangeItem.js +36 -37
- package/lib/module/zustand/components/ZustandStateDetailContent.js +22 -5
- package/lib/module/zustand/components/ZustandStateInfoView.js +30 -7
- package/lib/module/zustand/components/ZustandStoreBrowser.js +26 -129
- package/lib/module/zustand/components/ZustandStoreDetailContent.js +469 -0
- package/lib/module/zustand/components/ZustandStoreEditorScreen.js +389 -0
- package/lib/module/zustand/sync/zustandSyncAdapter.js +54 -0
- package/lib/module/zustand/utils/buoyZustandMiddleware.js +71 -7
- package/lib/module/zustand/utils/editableState.js +131 -0
- package/lib/module/zustand/utils/snapshotProvider.js +4 -30
- package/lib/module/zustand/utils/testIDs.js +74 -0
- package/lib/module/zustand/utils/zustandStateStore.js +16 -3
- package/lib/typescript/zustand/components/ZustandActionButton.d.ts +2 -1
- package/lib/typescript/zustand/components/ZustandActionButton.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandDetailViewToggle.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandEventFilterView.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandModal.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts +6 -0
- package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStateDetailContent.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStateInfoView.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts +7 -9
- package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStoreDetailContent.d.ts +40 -0
- package/lib/typescript/zustand/components/ZustandStoreDetailContent.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandStoreEditorScreen.d.ts +42 -0
- package/lib/typescript/zustand/components/ZustandStoreEditorScreen.d.ts.map +1 -0
- package/lib/typescript/zustand/sync/zustandSyncAdapter.d.ts +35 -0
- package/lib/typescript/zustand/sync/zustandSyncAdapter.d.ts.map +1 -1
- package/lib/typescript/zustand/types/index.d.ts +13 -0
- package/lib/typescript/zustand/types/index.d.ts.map +1 -1
- package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts +31 -3
- package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts.map +1 -1
- package/lib/typescript/zustand/utils/editableState.d.ts +65 -0
- package/lib/typescript/zustand/utils/editableState.d.ts.map +1 -0
- package/lib/typescript/zustand/utils/testIDs.d.ts +54 -0
- package/lib/typescript/zustand/utils/testIDs.d.ts.map +1 -0
- package/lib/typescript/zustand/utils/zustandStateStore.d.ts +1 -0
- package/lib/typescript/zustand/utils/zustandStateStore.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -18,6 +18,7 @@ import { useIsPro } from "@buoy-gg/license";
|
|
|
18
18
|
import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
|
|
19
19
|
import { ZustandActionButton } from "./ZustandActionButton";
|
|
20
20
|
import { zustandStateStore } from "../utils/zustandStateStore";
|
|
21
|
+
import { ZUSTAND_TEST_ID } from "../utils/testIDs";
|
|
21
22
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
23
|
function getCategoryInfo(category) {
|
|
23
24
|
switch (category) {
|
|
@@ -55,10 +56,12 @@ function formatDuration(duration) {
|
|
|
55
56
|
function SectionHeader({
|
|
56
57
|
icon: Icon,
|
|
57
58
|
title,
|
|
58
|
-
badge
|
|
59
|
+
badge,
|
|
60
|
+
testID
|
|
59
61
|
}) {
|
|
60
62
|
return /*#__PURE__*/_jsxs(View, {
|
|
61
63
|
style: styles.sectionHeader,
|
|
64
|
+
testID: testID,
|
|
62
65
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
63
66
|
style: styles.sectionHeaderLeft,
|
|
64
67
|
children: [/*#__PURE__*/_jsx(Icon, {
|
|
@@ -75,7 +78,8 @@ function InfoRow({
|
|
|
75
78
|
label,
|
|
76
79
|
value,
|
|
77
80
|
valueColor,
|
|
78
|
-
mono = false
|
|
81
|
+
mono = false,
|
|
82
|
+
testID
|
|
79
83
|
}) {
|
|
80
84
|
return /*#__PURE__*/_jsxs(View, {
|
|
81
85
|
style: styles.infoRow,
|
|
@@ -83,6 +87,7 @@ function InfoRow({
|
|
|
83
87
|
style: styles.infoLabel,
|
|
84
88
|
children: label
|
|
85
89
|
}), /*#__PURE__*/_jsx(Text, {
|
|
90
|
+
testID: testID,
|
|
86
91
|
style: [styles.infoValue, mono && styles.infoValueMono, valueColor ? {
|
|
87
92
|
color: valueColor
|
|
88
93
|
} : undefined],
|
|
@@ -138,8 +143,10 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
138
143
|
style: styles.container,
|
|
139
144
|
contentContainerStyle: styles.contentContainer,
|
|
140
145
|
showsVerticalScrollIndicator: false,
|
|
146
|
+
testID: `${ZUSTAND_TEST_ID}-detail-scroll`,
|
|
141
147
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
142
148
|
style: styles.card,
|
|
149
|
+
testID: `${ZUSTAND_TEST_ID}-info-card`,
|
|
143
150
|
children: [/*#__PURE__*/_jsx(SectionHeader, {
|
|
144
151
|
icon: Info,
|
|
145
152
|
title: "CHANGE INFO"
|
|
@@ -149,11 +156,13 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
149
156
|
label: "Store",
|
|
150
157
|
value: change.storeName,
|
|
151
158
|
mono: true,
|
|
152
|
-
valueColor: storeColor
|
|
159
|
+
valueColor: storeColor,
|
|
160
|
+
testID: `${ZUSTAND_TEST_ID}-info-store`
|
|
153
161
|
}), /*#__PURE__*/_jsx(InfoRow, {
|
|
154
162
|
label: "Time",
|
|
155
163
|
value: formatTime(change.timestamp),
|
|
156
|
-
mono: true
|
|
164
|
+
mono: true,
|
|
165
|
+
testID: `${ZUSTAND_TEST_ID}-info-time`
|
|
157
166
|
}), /*#__PURE__*/_jsxs(View, {
|
|
158
167
|
style: styles.badgeRow,
|
|
159
168
|
children: [/*#__PURE__*/_jsx(View, {
|
|
@@ -164,6 +173,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
164
173
|
style: [styles.categoryText, {
|
|
165
174
|
color: categoryInfo.color
|
|
166
175
|
}],
|
|
176
|
+
testID: `${ZUSTAND_TEST_ID}-info-category`,
|
|
167
177
|
children: categoryInfo.label
|
|
168
178
|
})
|
|
169
179
|
}), /*#__PURE__*/_jsxs(View, {
|
|
@@ -173,6 +183,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
173
183
|
color: change.isSlowUpdate ? buoyColors.error : night.color.textSecondary
|
|
174
184
|
}), /*#__PURE__*/_jsx(Text, {
|
|
175
185
|
style: [styles.durationText, change.isSlowUpdate && styles.durationTextSlow],
|
|
186
|
+
testID: `${ZUSTAND_TEST_ID}-info-duration`,
|
|
176
187
|
children: formatDuration(change.duration)
|
|
177
188
|
}), change.isSlowUpdate && /*#__PURE__*/_jsx(AlertTriangle, {
|
|
178
189
|
size: 10,
|
|
@@ -185,12 +196,14 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
185
196
|
color: buoyColors.success
|
|
186
197
|
}), /*#__PURE__*/_jsx(Text, {
|
|
187
198
|
style: styles.changesText,
|
|
199
|
+
testID: `${ZUSTAND_TEST_ID}-info-changes`,
|
|
188
200
|
children: change.diffSummary || "changed"
|
|
189
201
|
})]
|
|
190
202
|
}) : /*#__PURE__*/_jsx(View, {
|
|
191
203
|
style: styles.noChangesBadge,
|
|
192
204
|
children: /*#__PURE__*/_jsx(Text, {
|
|
193
205
|
style: styles.noChangesText,
|
|
206
|
+
testID: `${ZUSTAND_TEST_ID}-info-no-changes`,
|
|
194
207
|
children: "no change"
|
|
195
208
|
})
|
|
196
209
|
}), change.isPersisted && /*#__PURE__*/_jsxs(View, {
|
|
@@ -200,6 +213,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
200
213
|
color: buoyColors.info
|
|
201
214
|
}), /*#__PURE__*/_jsx(Text, {
|
|
202
215
|
style: styles.persistText,
|
|
216
|
+
testID: `${ZUSTAND_TEST_ID}-info-persisted`,
|
|
203
217
|
children: "PERSISTED"
|
|
204
218
|
})]
|
|
205
219
|
})]
|
|
@@ -207,6 +221,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
207
221
|
})]
|
|
208
222
|
}), hasChangedKeys && /*#__PURE__*/_jsxs(View, {
|
|
209
223
|
style: styles.card,
|
|
224
|
+
testID: `${ZUSTAND_TEST_ID}-keys-card`,
|
|
210
225
|
children: [/*#__PURE__*/_jsx(SectionHeader, {
|
|
211
226
|
icon: Zap,
|
|
212
227
|
title: "CHANGED KEYS",
|
|
@@ -214,6 +229,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
214
229
|
style: styles.countBadge,
|
|
215
230
|
children: /*#__PURE__*/_jsx(Text, {
|
|
216
231
|
style: styles.countText,
|
|
232
|
+
testID: `${ZUSTAND_TEST_ID}-keys-count`,
|
|
217
233
|
children: change.changedKeys.length
|
|
218
234
|
})
|
|
219
235
|
})
|
|
@@ -225,6 +241,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
225
241
|
style: styles.keyBadge,
|
|
226
242
|
children: /*#__PURE__*/_jsx(Text, {
|
|
227
243
|
style: styles.keyText,
|
|
244
|
+
testID: `${ZUSTAND_TEST_ID}-key-${key}`,
|
|
228
245
|
children: key
|
|
229
246
|
})
|
|
230
247
|
}, key))
|
|
@@ -232,6 +249,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
232
249
|
})]
|
|
233
250
|
}), hasPartial && /*#__PURE__*/_jsxs(View, {
|
|
234
251
|
style: styles.card,
|
|
252
|
+
testID: `${ZUSTAND_TEST_ID}-partial-card`,
|
|
235
253
|
children: [/*#__PURE__*/_jsx(SectionHeader, {
|
|
236
254
|
icon: Box,
|
|
237
255
|
title: "PARTIAL (setState argument)",
|
|
@@ -239,6 +257,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
239
257
|
style: styles.typeBadge,
|
|
240
258
|
children: /*#__PURE__*/_jsx(Text, {
|
|
241
259
|
style: styles.typeText,
|
|
260
|
+
testID: `${ZUSTAND_TEST_ID}-partial-type`,
|
|
242
261
|
children: Array.isArray(change.partial) ? "ARRAY" : typeof change.partial === "object" ? "OBJECT" : String(typeof change.partial).toUpperCase()
|
|
243
262
|
})
|
|
244
263
|
})
|
|
@@ -254,6 +273,7 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
254
273
|
})]
|
|
255
274
|
}), change.partial === "(updater fn)" && /*#__PURE__*/_jsxs(View, {
|
|
256
275
|
style: styles.card,
|
|
276
|
+
testID: `${ZUSTAND_TEST_ID}-updater-card`,
|
|
257
277
|
children: [/*#__PURE__*/_jsx(SectionHeader, {
|
|
258
278
|
icon: Box,
|
|
259
279
|
title: "SET STATE CALL"
|
|
@@ -272,15 +292,18 @@ export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoV
|
|
|
272
292
|
children: [/*#__PURE__*/_jsx(ZustandActionButton, {
|
|
273
293
|
type: "jump",
|
|
274
294
|
text: "JUMP",
|
|
275
|
-
onPress: handleJumpToState
|
|
295
|
+
onPress: handleJumpToState,
|
|
296
|
+
testID: `${ZUSTAND_TEST_ID}-jump`
|
|
276
297
|
}), /*#__PURE__*/_jsx(ZustandActionButton, {
|
|
277
298
|
type: "reset",
|
|
278
299
|
text: "RESET STORE",
|
|
279
|
-
onPress: handleResetStore
|
|
300
|
+
onPress: handleResetStore,
|
|
301
|
+
testID: `${ZUSTAND_TEST_ID}-reset`
|
|
280
302
|
}), /*#__PURE__*/_jsx(ZustandActionButton, {
|
|
281
303
|
type: "copy",
|
|
282
304
|
text: "COPY STATE",
|
|
283
|
-
onPress: handleCopyState
|
|
305
|
+
onPress: handleCopyState,
|
|
306
|
+
testID: `${ZUSTAND_TEST_ID}-copy-state`
|
|
284
307
|
})]
|
|
285
308
|
}), /*#__PURE__*/_jsx(ProUpgradeModal, {
|
|
286
309
|
visible: showProModal,
|
|
@@ -3,18 +3,17 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* ZustandStoreBrowser
|
|
5
5
|
*
|
|
6
|
-
* Browse tab —
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* via the shared DataViewer component.
|
|
6
|
+
* Browse tab — lists all registered Zustand stores. Tapping a card opens the
|
|
7
|
+
* store's detail screen (ZustandStoreDetailContent): live state editor on
|
|
8
|
+
* top, store details and the read-only tree below — the React Query
|
|
9
|
+
* interaction, replacing the old expand-in-place card.
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
|
-
import {
|
|
14
|
-
import { View, Text, StyleSheet, ScrollView,
|
|
15
|
-
import { CompactRow,
|
|
16
|
-
import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
|
|
12
|
+
import { useMemo } from "react";
|
|
13
|
+
import { View, Text, StyleSheet, ScrollView, ActivityIndicator } from "react-native";
|
|
14
|
+
import { CompactRow, night, Box } from "@buoy-gg/shared-ui";
|
|
17
15
|
import { zustandStateStore } from "../utils/zustandStateStore";
|
|
16
|
+
import { ZUSTAND_TEST_ID, storeRowTestID } from "../utils/testIDs";
|
|
18
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
18
|
/**
|
|
20
19
|
* Get a preview of the store's top-level keys
|
|
@@ -40,80 +39,10 @@ function getKeysPreview(store) {
|
|
|
40
39
|
return "";
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
|
-
function StoreExpandedContent({
|
|
44
|
-
store,
|
|
45
|
-
onViewHistory
|
|
46
|
-
}) {
|
|
47
|
-
const state = store.api.getState();
|
|
48
|
-
const displayState = useMemo(() => {
|
|
49
|
-
if (state && typeof state === "object") {
|
|
50
|
-
const filtered = {};
|
|
51
|
-
for (const [key, value] of Object.entries(state)) {
|
|
52
|
-
if (typeof value !== "function") {
|
|
53
|
-
filtered[key] = value;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return parseValue(filtered);
|
|
57
|
-
}
|
|
58
|
-
return parseValue(state);
|
|
59
|
-
}, [state]);
|
|
60
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
61
|
-
style: expandedStyles.container,
|
|
62
|
-
children: [/*#__PURE__*/_jsx(ExpandedInfoRow, {
|
|
63
|
-
label: "Type",
|
|
64
|
-
children: /*#__PURE__*/_jsx(PillBadge, {
|
|
65
|
-
color: store.color,
|
|
66
|
-
children: "ZUSTAND"
|
|
67
|
-
})
|
|
68
|
-
}), store.stateChangeCount > 0 && /*#__PURE__*/_jsxs(ExpandedInfoRow, {
|
|
69
|
-
label: "Changes",
|
|
70
|
-
children: [/*#__PURE__*/_jsx(PillBadge, {
|
|
71
|
-
color: buoyColors.warning,
|
|
72
|
-
children: String(store.stateChangeCount)
|
|
73
|
-
}), /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
74
|
-
onPress: () => onViewHistory(store.name),
|
|
75
|
-
style: expandedStyles.viewHistoryButton,
|
|
76
|
-
hitSlop: {
|
|
77
|
-
top: 6,
|
|
78
|
-
bottom: 6,
|
|
79
|
-
left: 6,
|
|
80
|
-
right: 6
|
|
81
|
-
},
|
|
82
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
83
|
-
style: [expandedStyles.viewHistoryText, {
|
|
84
|
-
color: store.color
|
|
85
|
-
}],
|
|
86
|
-
children: "view history \u2192"
|
|
87
|
-
})
|
|
88
|
-
})]
|
|
89
|
-
}), store.isPersisted && /*#__PURE__*/_jsx(ExpandedInfoRow, {
|
|
90
|
-
label: "Persist",
|
|
91
|
-
children: /*#__PURE__*/_jsx(PillBadge, {
|
|
92
|
-
color: buoyColors.info,
|
|
93
|
-
icon: /*#__PURE__*/_jsx(Database, {
|
|
94
|
-
size: 9,
|
|
95
|
-
color: buoyColors.info
|
|
96
|
-
}),
|
|
97
|
-
children: store.persistName || "persisted"
|
|
98
|
-
})
|
|
99
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
100
|
-
style: expandedStyles.dataContainer,
|
|
101
|
-
children: displayState && typeof displayState === "object" ? /*#__PURE__*/_jsx(DataViewer, {
|
|
102
|
-
title: "",
|
|
103
|
-
data: displayState,
|
|
104
|
-
showTypeFilter: true,
|
|
105
|
-
rawMode: true,
|
|
106
|
-
initialExpanded: true
|
|
107
|
-
}) : /*#__PURE__*/_jsx(Text, {
|
|
108
|
-
style: expandedStyles.emptyText,
|
|
109
|
-
children: "Empty state"
|
|
110
|
-
})
|
|
111
|
-
})]
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
42
|
function LoadingBrowserState() {
|
|
115
43
|
return /*#__PURE__*/_jsxs(View, {
|
|
116
44
|
style: styles.emptyState,
|
|
45
|
+
testID: `${ZUSTAND_TEST_ID}-stores-loading`,
|
|
117
46
|
children: [/*#__PURE__*/_jsx(ActivityIndicator, {
|
|
118
47
|
size: "small",
|
|
119
48
|
color: night.color.textTertiary
|
|
@@ -129,11 +58,13 @@ function LoadingBrowserState() {
|
|
|
129
58
|
function EmptyBrowserState() {
|
|
130
59
|
return /*#__PURE__*/_jsxs(View, {
|
|
131
60
|
style: styles.emptyState,
|
|
61
|
+
testID: `${ZUSTAND_TEST_ID}-stores-empty`,
|
|
132
62
|
children: [/*#__PURE__*/_jsx(Box, {
|
|
133
63
|
size: 32,
|
|
134
64
|
color: night.color.textTertiary
|
|
135
65
|
}), /*#__PURE__*/_jsx(Text, {
|
|
136
66
|
style: styles.emptyTitle,
|
|
67
|
+
testID: `${ZUSTAND_TEST_ID}-stores-empty-title`,
|
|
137
68
|
children: "No stores registered"
|
|
138
69
|
}), /*#__PURE__*/_jsx(Text, {
|
|
139
70
|
style: styles.emptyText,
|
|
@@ -144,33 +75,25 @@ function EmptyBrowserState() {
|
|
|
144
75
|
export function ZustandStoreBrowser({
|
|
145
76
|
stores,
|
|
146
77
|
searchQuery,
|
|
147
|
-
onViewHistory,
|
|
148
78
|
isLoading = false,
|
|
149
|
-
|
|
79
|
+
onOpenStore
|
|
150
80
|
}) {
|
|
151
|
-
const [expandedStore, setExpandedStore] = useState(null);
|
|
152
|
-
|
|
153
81
|
// Filter stores by search query
|
|
154
82
|
const filteredStores = useMemo(() => {
|
|
155
83
|
if (!searchQuery) return stores;
|
|
156
84
|
const search = searchQuery.toLowerCase();
|
|
157
85
|
return stores.filter(s => s.name.toLowerCase().includes(search) || s.persistName && s.persistName.toLowerCase().includes(search));
|
|
158
86
|
}, [stores, searchQuery]);
|
|
159
|
-
const handleStorePress = useCallback(store => {
|
|
160
|
-
setExpandedStore(prev => {
|
|
161
|
-
const next = prev === store.name ? null : store.name;
|
|
162
|
-
if (next) onStoreExpand?.(store.name);
|
|
163
|
-
return next;
|
|
164
|
-
});
|
|
165
|
-
}, [onStoreExpand]);
|
|
166
87
|
if (filteredStores.length === 0 && !searchQuery) {
|
|
167
88
|
return isLoading ? /*#__PURE__*/_jsx(LoadingBrowserState, {}) : /*#__PURE__*/_jsx(EmptyBrowserState, {});
|
|
168
89
|
}
|
|
169
90
|
if (filteredStores.length === 0 && searchQuery) {
|
|
170
91
|
return /*#__PURE__*/_jsxs(View, {
|
|
171
92
|
style: styles.emptyState,
|
|
93
|
+
testID: `${ZUSTAND_TEST_ID}-stores-no-match`,
|
|
172
94
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
173
95
|
style: styles.emptyTitle,
|
|
96
|
+
testID: `${ZUSTAND_TEST_ID}-stores-no-match-title`,
|
|
174
97
|
children: "No matching stores"
|
|
175
98
|
}), /*#__PURE__*/_jsxs(Text, {
|
|
176
99
|
style: styles.emptyText,
|
|
@@ -182,6 +105,7 @@ export function ZustandStoreBrowser({
|
|
|
182
105
|
style: styles.container,
|
|
183
106
|
contentContainerStyle: styles.scrollContent,
|
|
184
107
|
showsVerticalScrollIndicator: true,
|
|
108
|
+
testID: `${ZUSTAND_TEST_ID}-stores-scroll`,
|
|
185
109
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
186
110
|
style: styles.sectionHeader,
|
|
187
111
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
@@ -191,27 +115,27 @@ export function ZustandStoreBrowser({
|
|
|
191
115
|
style: styles.sectionCountBadge,
|
|
192
116
|
children: /*#__PURE__*/_jsx(Text, {
|
|
193
117
|
style: styles.sectionCountText,
|
|
118
|
+
testID: `${ZUSTAND_TEST_ID}-stores-count`,
|
|
194
119
|
children: filteredStores.length
|
|
195
120
|
})
|
|
196
121
|
})]
|
|
197
122
|
}), filteredStores.map(store => {
|
|
198
|
-
const isExpanded = expandedStore === store.name;
|
|
199
123
|
const keysPreview = getKeysPreview(store);
|
|
200
124
|
const storeColor = zustandStateStore.getStoreColor(store.name);
|
|
125
|
+
const rowID = storeRowTestID(store.name);
|
|
201
126
|
return /*#__PURE__*/_jsxs(View, {
|
|
202
127
|
style: styles.storeRowWrapper,
|
|
203
128
|
children: [/*#__PURE__*/_jsx(CompactRow, {
|
|
204
129
|
statusDotColor: storeColor,
|
|
205
|
-
statusLabel: store.
|
|
206
|
-
|
|
207
|
-
|
|
130
|
+
statusLabel: store.isPersisted ? "persisted" : "in-memory",
|
|
131
|
+
primaryText: store.name,
|
|
132
|
+
secondaryText: keysPreview || undefined,
|
|
208
133
|
showChevron: true,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}) : undefined
|
|
134
|
+
onPress: () => onOpenStore(store.name),
|
|
135
|
+
testID: rowID,
|
|
136
|
+
statusTestID: `${rowID}-backing`,
|
|
137
|
+
primaryTestID: `${rowID}-name`,
|
|
138
|
+
secondaryTestID: `${rowID}-keys`
|
|
215
139
|
}), store.stateChangeCount > 0 && /*#__PURE__*/_jsx(View, {
|
|
216
140
|
style: [styles.absCountBadge, {
|
|
217
141
|
backgroundColor: storeColor + "22",
|
|
@@ -222,6 +146,7 @@ export function ZustandStoreBrowser({
|
|
|
222
146
|
style: [styles.absCountText, {
|
|
223
147
|
color: storeColor
|
|
224
148
|
}],
|
|
149
|
+
testID: `${rowID}-count`,
|
|
225
150
|
children: String(store.stateChangeCount)
|
|
226
151
|
})
|
|
227
152
|
})]
|
|
@@ -297,32 +222,4 @@ const styles = StyleSheet.create({
|
|
|
297
222
|
textAlign: "center",
|
|
298
223
|
lineHeight: 18
|
|
299
224
|
}
|
|
300
|
-
});
|
|
301
|
-
const expandedStyles = StyleSheet.create({
|
|
302
|
-
container: {
|
|
303
|
-
gap: 10
|
|
304
|
-
},
|
|
305
|
-
viewHistoryButton: {
|
|
306
|
-
marginLeft: 4
|
|
307
|
-
},
|
|
308
|
-
viewHistoryText: {
|
|
309
|
-
fontSize: 10,
|
|
310
|
-
fontWeight: "600",
|
|
311
|
-
fontFamily: "monospace"
|
|
312
|
-
},
|
|
313
|
-
dataContainer: {
|
|
314
|
-
// Inset display panel — darker than the card, the night track color.
|
|
315
|
-
backgroundColor: night.color.bg,
|
|
316
|
-
borderRadius: 6,
|
|
317
|
-
borderWidth: 1,
|
|
318
|
-
borderColor: night.color.border,
|
|
319
|
-
overflow: "hidden",
|
|
320
|
-
minHeight: 60
|
|
321
|
-
},
|
|
322
|
-
emptyText: {
|
|
323
|
-
color: night.color.textTertiary,
|
|
324
|
-
fontSize: 12,
|
|
325
|
-
padding: 14,
|
|
326
|
-
fontStyle: "italic"
|
|
327
|
-
}
|
|
328
225
|
});
|