@buoy-gg/zustand 2.1.9 → 2.1.11
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/index.js +91 -1
- package/lib/commonjs/preset.js +102 -1
- package/lib/commonjs/zustand/components/ZustandActionButton.js +116 -1
- package/lib/commonjs/zustand/components/ZustandDetailViewToggle.js +134 -1
- package/lib/commonjs/zustand/components/ZustandEventFilterView.js +291 -1
- package/lib/commonjs/zustand/components/ZustandIcon.js +35 -1
- package/lib/commonjs/zustand/components/ZustandModal.js +603 -1
- package/lib/commonjs/zustand/components/ZustandStateChangeItem.js +165 -1
- package/lib/commonjs/zustand/components/ZustandStateDetailContent.js +352 -1
- package/lib/commonjs/zustand/components/ZustandStateInfoView.js +508 -1
- package/lib/commonjs/zustand/components/ZustandStoreBrowser.js +307 -1
- package/lib/commonjs/zustand/components/index.js +73 -1
- package/lib/commonjs/zustand/hooks/index.js +12 -1
- package/lib/commonjs/zustand/hooks/useZustandStateChanges.js +92 -1
- package/lib/commonjs/zustand/index.js +99 -1
- package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +220 -1
- package/lib/commonjs/zustand/utils/index.js +31 -1
- package/lib/commonjs/zustand/utils/zustandStateStore.js +361 -1
- package/lib/module/index.js +80 -1
- package/lib/module/preset.js +98 -1
- package/lib/module/zustand/components/ZustandActionButton.js +112 -1
- package/lib/module/zustand/components/ZustandDetailViewToggle.js +129 -1
- package/lib/module/zustand/components/ZustandEventFilterView.js +287 -1
- package/lib/module/zustand/components/ZustandIcon.js +32 -1
- package/lib/module/zustand/components/ZustandModal.js +599 -1
- package/lib/module/zustand/components/ZustandStateChangeItem.js +161 -1
- package/lib/module/zustand/components/ZustandStateDetailContent.js +348 -1
- package/lib/module/zustand/components/ZustandStateInfoView.js +503 -1
- package/lib/module/zustand/components/ZustandStoreBrowser.js +303 -1
- package/lib/module/zustand/components/index.js +10 -1
- package/lib/module/zustand/hooks/index.js +3 -1
- package/lib/module/zustand/hooks/useZustandStateChanges.js +88 -1
- package/lib/module/zustand/index.js +12 -1
- package/lib/module/zustand/utils/buoyZustandMiddleware.js +214 -1
- package/lib/module/zustand/utils/index.js +4 -1
- package/lib/module/zustand/utils/zustandStateStore.js +357 -1
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandActionButton.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandDetailViewToggle.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandEventFilterView.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandIcon.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandModal.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandStateDetailContent.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandStateInfoView.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts.map +1 -0
- package/lib/typescript/zustand/components/index.d.ts.map +1 -0
- package/lib/typescript/zustand/hooks/index.d.ts.map +1 -0
- package/lib/typescript/zustand/hooks/useZustandStateChanges.d.ts.map +1 -0
- package/lib/typescript/zustand/index.d.ts.map +1 -0
- package/lib/typescript/zustand/types/index.d.ts.map +1 -0
- package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts.map +1 -0
- package/lib/typescript/zustand/utils/index.d.ts.map +1 -0
- package/lib/typescript/zustand/utils/zustandStateStore.d.ts.map +1 -0
- package/package.json +10 -10
- package/LICENSE +0 -58
|
@@ -1 +1,165 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ZustandStateChangeItem = ZustandStateChangeItem;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
9
|
+
var _zustandStateStore = require("../utils/zustandStateStore");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
/**
|
|
12
|
+
* Compact list item for displaying a Zustand state change
|
|
13
|
+
*
|
|
14
|
+
* Mirrors ReduxActionItem.tsx - uses shared CompactRow for consistent styling
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get status label based on category
|
|
19
|
+
*/
|
|
20
|
+
function getStatusLabel(category, storeName) {
|
|
21
|
+
switch (category) {
|
|
22
|
+
case "replace":
|
|
23
|
+
return "Replace";
|
|
24
|
+
case "persist":
|
|
25
|
+
return "Hydrate";
|
|
26
|
+
case "initial":
|
|
27
|
+
return "Initial";
|
|
28
|
+
default:
|
|
29
|
+
return storeName.charAt(0).toUpperCase() + storeName.slice(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get color for category
|
|
35
|
+
*/
|
|
36
|
+
function getCategoryColor(category, storeName) {
|
|
37
|
+
switch (category) {
|
|
38
|
+
case "replace":
|
|
39
|
+
return _sharedUi.buoyColors.warning;
|
|
40
|
+
case "persist":
|
|
41
|
+
return _sharedUi.buoyColors.info;
|
|
42
|
+
case "initial":
|
|
43
|
+
return _sharedUi.buoyColors.textMuted;
|
|
44
|
+
default:
|
|
45
|
+
return _zustandStateStore.zustandStateStore.getStoreColor(storeName);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get sublabel with duration and diff info
|
|
51
|
+
*/
|
|
52
|
+
function getSublabel(change) {
|
|
53
|
+
const parts = [];
|
|
54
|
+
if (change.duration !== undefined && change.duration >= 0.1) {
|
|
55
|
+
parts.push(`${change.duration.toFixed(1)}ms`);
|
|
56
|
+
}
|
|
57
|
+
if (change.hasStateChange) {
|
|
58
|
+
if (change.changedKeysCount > 0) {
|
|
59
|
+
parts.push(`${change.changedKeysCount} key${change.changedKeysCount > 1 ? "s" : ""} changed`);
|
|
60
|
+
} else {
|
|
61
|
+
parts.push(change.diffSummary || "state changed");
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
parts.push("no state change");
|
|
65
|
+
}
|
|
66
|
+
return parts.join(" \u00B7 ");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get badge text for the change
|
|
71
|
+
*/
|
|
72
|
+
function getBadgeText(change) {
|
|
73
|
+
if (change.category === "replace") return "REPLACE";
|
|
74
|
+
if (change.category === "persist") return "HYDRATE";
|
|
75
|
+
if (change.category === "initial") return "INIT";
|
|
76
|
+
return "SET";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get primary display text
|
|
81
|
+
*/
|
|
82
|
+
function getPrimaryText(change) {
|
|
83
|
+
if (change.changedKeys.length > 0 && change.changedKeys.length <= 3) {
|
|
84
|
+
return change.changedKeys.join(", ");
|
|
85
|
+
}
|
|
86
|
+
if (change.changedKeys.length > 3) {
|
|
87
|
+
return `${change.changedKeys.slice(0, 2).join(", ")} +${change.changedKeys.length - 2}`;
|
|
88
|
+
}
|
|
89
|
+
return change.partialPreview || "setState()";
|
|
90
|
+
}
|
|
91
|
+
function ZustandStateChangeItem({
|
|
92
|
+
change,
|
|
93
|
+
onPress
|
|
94
|
+
}) {
|
|
95
|
+
const statusColor = getCategoryColor(change.category, change.storeName);
|
|
96
|
+
const statusLabel = getStatusLabel(change.category, change.storeName);
|
|
97
|
+
const sublabel = getSublabel(change);
|
|
98
|
+
const primaryText = getPrimaryText(change);
|
|
99
|
+
const badgeText = getBadgeText(change);
|
|
100
|
+
const relativeTime = (0, _sharedUi.useRelativeTime)(change.timestamp);
|
|
101
|
+
let customBadge = undefined;
|
|
102
|
+
if (change.isSlowUpdate) {
|
|
103
|
+
customBadge = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
104
|
+
style: styles.badgeContainer,
|
|
105
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
106
|
+
style: [styles.badgeText, {
|
|
107
|
+
color: statusColor
|
|
108
|
+
}],
|
|
109
|
+
children: badgeText
|
|
110
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
111
|
+
style: styles.slowBadge,
|
|
112
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Clock, {
|
|
113
|
+
size: 12,
|
|
114
|
+
color: _sharedUi.buoyColors.error
|
|
115
|
+
})
|
|
116
|
+
})]
|
|
117
|
+
});
|
|
118
|
+
} else if (change.hasStateChange) {
|
|
119
|
+
customBadge = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
120
|
+
style: styles.badgeContainer,
|
|
121
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
122
|
+
style: [styles.badgeText, {
|
|
123
|
+
color: statusColor
|
|
124
|
+
}],
|
|
125
|
+
children: badgeText
|
|
126
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
127
|
+
style: styles.changeBadge,
|
|
128
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Zap, {
|
|
129
|
+
size: 12,
|
|
130
|
+
color: _sharedUi.buoyColors.warning
|
|
131
|
+
})
|
|
132
|
+
})]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.CompactRow, {
|
|
136
|
+
statusDotColor: statusColor,
|
|
137
|
+
statusLabel: statusLabel,
|
|
138
|
+
statusSublabel: sublabel,
|
|
139
|
+
primaryText: primaryText,
|
|
140
|
+
bottomRightText: relativeTime,
|
|
141
|
+
customBadge: customBadge,
|
|
142
|
+
badgeText: customBadge ? undefined : badgeText,
|
|
143
|
+
badgeColor: statusColor,
|
|
144
|
+
showChevron: true,
|
|
145
|
+
onPress: () => onPress(change)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const styles = _reactNative.StyleSheet.create({
|
|
149
|
+
badgeContainer: {
|
|
150
|
+
flexDirection: "row",
|
|
151
|
+
alignItems: "center",
|
|
152
|
+
gap: 4
|
|
153
|
+
},
|
|
154
|
+
badgeText: {
|
|
155
|
+
fontSize: 11,
|
|
156
|
+
fontWeight: "600",
|
|
157
|
+
fontFamily: "monospace"
|
|
158
|
+
},
|
|
159
|
+
changeBadge: {
|
|
160
|
+
paddingHorizontal: 4
|
|
161
|
+
},
|
|
162
|
+
slowBadge: {
|
|
163
|
+
paddingHorizontal: 4
|
|
164
|
+
}
|
|
165
|
+
});
|
|
@@ -1 +1,352 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ZustandStateDetailContent = ZustandStateDetailContent;
|
|
7
|
+
exports.ZustandStateDetailFooter = ZustandStateDetailFooter;
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
11
|
+
var _dataViewer = require("@buoy-gg/shared-ui/dataViewer");
|
|
12
|
+
var _ZustandDetailViewToggle = require("./ZustandDetailViewToggle");
|
|
13
|
+
var _ZustandStateInfoView = require("./ZustandStateInfoView");
|
|
14
|
+
var _zustandStateStore = require("../utils/zustandStateStore");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
/**
|
|
17
|
+
* ZustandStateDetailContent
|
|
18
|
+
*
|
|
19
|
+
* Detail view for a Zustand state change with 3 view modes:
|
|
20
|
+
* - CHANGE: View change details, partial, metadata
|
|
21
|
+
* - STATE: View current state after change
|
|
22
|
+
* - DIFF: Compare prev vs next state
|
|
23
|
+
*
|
|
24
|
+
* Mirrors ReduxActionDetailContent.tsx
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
function getChangeColor(change) {
|
|
28
|
+
return _zustandStateStore.zustandStateStore.getStoreColor(change.storeName);
|
|
29
|
+
}
|
|
30
|
+
function getChangeLabel(change) {
|
|
31
|
+
switch (change.category) {
|
|
32
|
+
case "replace":
|
|
33
|
+
return "REPLACE";
|
|
34
|
+
case "persist":
|
|
35
|
+
return "HYDRATE";
|
|
36
|
+
case "initial":
|
|
37
|
+
return "INIT";
|
|
38
|
+
default:
|
|
39
|
+
return "SET";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function getValueType(value) {
|
|
43
|
+
if (value === null) return "null";
|
|
44
|
+
if (value === undefined) return "undefined";
|
|
45
|
+
if (Array.isArray(value)) return "array";
|
|
46
|
+
return typeof value;
|
|
47
|
+
}
|
|
48
|
+
function formatTimestamp(timestamp) {
|
|
49
|
+
const date = new Date(timestamp);
|
|
50
|
+
return date.toLocaleTimeString("en-US", {
|
|
51
|
+
hour12: false,
|
|
52
|
+
hour: "2-digit",
|
|
53
|
+
minute: "2-digit",
|
|
54
|
+
second: "2-digit"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const DIFF_MODE_TABS = [{
|
|
58
|
+
key: "tree",
|
|
59
|
+
label: "TREE VIEW"
|
|
60
|
+
}, {
|
|
61
|
+
key: "split",
|
|
62
|
+
label: "SPLIT VIEW"
|
|
63
|
+
}];
|
|
64
|
+
function ZustandStateDetailContent({
|
|
65
|
+
change,
|
|
66
|
+
changes,
|
|
67
|
+
selectedIndex,
|
|
68
|
+
onIndexChange,
|
|
69
|
+
disableInternalFooter = false
|
|
70
|
+
}) {
|
|
71
|
+
const [activeView, setActiveView] = (0, _react.useState)("change");
|
|
72
|
+
const [diffMode, setDiffMode] = (0, _react.useState)("tree");
|
|
73
|
+
const totalChanges = changes.length;
|
|
74
|
+
const changeColor = getChangeColor(change);
|
|
75
|
+
const changeLabel = getChangeLabel(change);
|
|
76
|
+
const stateType = getValueType((0, _sharedUi.parseValue)(change.nextState));
|
|
77
|
+
|
|
78
|
+
// Changes are in reverse chronological order (newest first)
|
|
79
|
+
const chronologicalNumber = totalChanges - selectedIndex;
|
|
80
|
+
const prevChronologicalNumber = chronologicalNumber - 1;
|
|
81
|
+
const prevChangeIndex = selectedIndex < totalChanges - 1 ? selectedIndex + 1 : null;
|
|
82
|
+
const prevChange = prevChangeIndex !== null ? changes[prevChangeIndex] : null;
|
|
83
|
+
|
|
84
|
+
// Compare bar info
|
|
85
|
+
const leftEvent = (0, _react.useMemo)(() => ({
|
|
86
|
+
index: prevChangeIndex ?? 0,
|
|
87
|
+
label: prevChronologicalNumber > 0 ? `#${prevChronologicalNumber}` : "Initial",
|
|
88
|
+
timestamp: prevChange ? formatTimestamp(prevChange.timestamp) : "",
|
|
89
|
+
relativeTime: prevChange ? (0, _sharedUi.formatRelativeTime)(new Date(prevChange.timestamp)) : "state",
|
|
90
|
+
badge: prevChange ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
91
|
+
style: [styles.changeBadgeSmall, {
|
|
92
|
+
backgroundColor: `${getChangeColor(prevChange)}20`
|
|
93
|
+
}],
|
|
94
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
95
|
+
style: [styles.changeTextSmall, {
|
|
96
|
+
color: getChangeColor(prevChange)
|
|
97
|
+
}],
|
|
98
|
+
children: getChangeLabel(prevChange)
|
|
99
|
+
})
|
|
100
|
+
}) : undefined
|
|
101
|
+
}), [prevChangeIndex, prevChange, prevChronologicalNumber]);
|
|
102
|
+
const rightEvent = (0, _react.useMemo)(() => ({
|
|
103
|
+
index: selectedIndex,
|
|
104
|
+
label: `#${chronologicalNumber}`,
|
|
105
|
+
timestamp: formatTimestamp(change.timestamp),
|
|
106
|
+
relativeTime: (0, _sharedUi.formatRelativeTime)(new Date(change.timestamp)),
|
|
107
|
+
badge: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
108
|
+
style: [styles.changeBadgeSmall, {
|
|
109
|
+
backgroundColor: `${changeColor}20`
|
|
110
|
+
}],
|
|
111
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
112
|
+
style: [styles.changeTextSmall, {
|
|
113
|
+
color: changeColor
|
|
114
|
+
}],
|
|
115
|
+
children: changeLabel
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
}), [selectedIndex, change.timestamp, changeColor, changeLabel, chronologicalNumber]);
|
|
119
|
+
const renderStateView = (0, _react.useCallback)(() => {
|
|
120
|
+
const parsed = (0, _sharedUi.parseValue)(change.nextState);
|
|
121
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
122
|
+
style: styles.contentCard,
|
|
123
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
124
|
+
style: styles.valueHeader,
|
|
125
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
126
|
+
style: styles.valueLabel,
|
|
127
|
+
children: "STATE AFTER CHANGE"
|
|
128
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
129
|
+
style: styles.valueHeaderBadges,
|
|
130
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
131
|
+
style: [styles.changeBadge, {
|
|
132
|
+
backgroundColor: `${changeColor}20`
|
|
133
|
+
}],
|
|
134
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
135
|
+
style: [styles.changeText, {
|
|
136
|
+
color: changeColor
|
|
137
|
+
}],
|
|
138
|
+
children: changeLabel
|
|
139
|
+
})
|
|
140
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
141
|
+
style: styles.typeBadge,
|
|
142
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
143
|
+
style: styles.typeText,
|
|
144
|
+
children: stateType.toUpperCase()
|
|
145
|
+
})
|
|
146
|
+
})]
|
|
147
|
+
})]
|
|
148
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
149
|
+
style: styles.dataViewerContainer,
|
|
150
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataViewer.DataViewer, {
|
|
151
|
+
title: "",
|
|
152
|
+
data: parsed,
|
|
153
|
+
showTypeFilter: true,
|
|
154
|
+
rawMode: true,
|
|
155
|
+
initialExpanded: true
|
|
156
|
+
})
|
|
157
|
+
})]
|
|
158
|
+
});
|
|
159
|
+
}, [change.nextState, changeColor, changeLabel, stateType]);
|
|
160
|
+
const renderDiffContent = (0, _react.useCallback)(() => {
|
|
161
|
+
const prevState = (0, _sharedUi.parseValue)(change.prevState);
|
|
162
|
+
const nextState = (0, _sharedUi.parseValue)(change.nextState);
|
|
163
|
+
if (diffMode === "split") {
|
|
164
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
165
|
+
style: {
|
|
166
|
+
flex: 1
|
|
167
|
+
},
|
|
168
|
+
showsVerticalScrollIndicator: true,
|
|
169
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataViewer.SplitDiffViewer, {
|
|
170
|
+
oldValue: prevState,
|
|
171
|
+
newValue: nextState,
|
|
172
|
+
theme: _dataViewer.diffThemes.devToolsDefault,
|
|
173
|
+
options: {
|
|
174
|
+
hideLineNumbers: false,
|
|
175
|
+
disableWordDiff: false,
|
|
176
|
+
showDiffOnly: false,
|
|
177
|
+
compareMethod: "words",
|
|
178
|
+
contextLines: 3
|
|
179
|
+
},
|
|
180
|
+
showThemeName: false
|
|
181
|
+
})
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataViewer.TreeDiffViewer, {
|
|
185
|
+
oldValue: prevState,
|
|
186
|
+
newValue: nextState
|
|
187
|
+
});
|
|
188
|
+
}, [change.prevState, change.nextState, diffMode]);
|
|
189
|
+
const handleFooterPrevious = (0, _react.useCallback)(() => {
|
|
190
|
+
onIndexChange(Math.min(totalChanges - 1, selectedIndex + 1));
|
|
191
|
+
}, [selectedIndex, totalChanges, onIndexChange]);
|
|
192
|
+
const handleFooterNext = (0, _react.useCallback)(() => {
|
|
193
|
+
onIndexChange(Math.max(0, selectedIndex - 1));
|
|
194
|
+
}, [selectedIndex, onIndexChange]);
|
|
195
|
+
const diffDisabled = totalChanges <= 1;
|
|
196
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
197
|
+
style: styles.container,
|
|
198
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ZustandDetailViewToggle.ZustandDetailViewToggle, {
|
|
199
|
+
activeView: activeView,
|
|
200
|
+
onViewChange: setActiveView,
|
|
201
|
+
diffDisabled: diffDisabled
|
|
202
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
203
|
+
style: styles.contentArea,
|
|
204
|
+
children: [activeView === "change" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ZustandStateInfoView.ZustandStateInfoView, {
|
|
205
|
+
change: change
|
|
206
|
+
}), activeView === "state" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
207
|
+
style: styles.stateContainer,
|
|
208
|
+
children: renderStateView()
|
|
209
|
+
}), activeView === "diff" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
210
|
+
style: styles.diffContainer,
|
|
211
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.DiffModeTabs, {
|
|
212
|
+
tabs: DIFF_MODE_TABS,
|
|
213
|
+
activeTab: diffMode,
|
|
214
|
+
onTabChange: setDiffMode
|
|
215
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.CompareBar, {
|
|
216
|
+
leftEvent: leftEvent,
|
|
217
|
+
rightEvent: rightEvent
|
|
218
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
219
|
+
style: styles.diffContent,
|
|
220
|
+
children: renderDiffContent()
|
|
221
|
+
})]
|
|
222
|
+
})]
|
|
223
|
+
}), !disableInternalFooter && totalChanges > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.EventStepperFooter, {
|
|
224
|
+
currentIndex: chronologicalNumber - 1,
|
|
225
|
+
totalItems: totalChanges,
|
|
226
|
+
onPrevious: handleFooterPrevious,
|
|
227
|
+
onNext: handleFooterNext,
|
|
228
|
+
itemLabel: "Change",
|
|
229
|
+
subtitle: (0, _sharedUi.formatRelativeTime)(new Date(change.timestamp)),
|
|
230
|
+
absolute: true
|
|
231
|
+
})]
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* External footer component for modal use
|
|
237
|
+
*/
|
|
238
|
+
function ZustandStateDetailFooter({
|
|
239
|
+
change,
|
|
240
|
+
changes,
|
|
241
|
+
selectedIndex,
|
|
242
|
+
onIndexChange
|
|
243
|
+
}) {
|
|
244
|
+
const totalChanges = changes.length;
|
|
245
|
+
if (totalChanges <= 1) return null;
|
|
246
|
+
const chronologicalNumber = totalChanges - selectedIndex;
|
|
247
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.EventStepperFooter, {
|
|
248
|
+
currentIndex: chronologicalNumber - 1,
|
|
249
|
+
totalItems: totalChanges,
|
|
250
|
+
onPrevious: () => onIndexChange(Math.min(totalChanges - 1, selectedIndex + 1)),
|
|
251
|
+
onNext: () => onIndexChange(Math.max(0, selectedIndex - 1)),
|
|
252
|
+
itemLabel: "Change",
|
|
253
|
+
subtitle: (0, _sharedUi.formatRelativeTime)(new Date(change.timestamp))
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
const styles = _reactNative.StyleSheet.create({
|
|
257
|
+
container: {
|
|
258
|
+
flex: 1,
|
|
259
|
+
backgroundColor: _sharedUi.macOSColors.background.base
|
|
260
|
+
},
|
|
261
|
+
contentArea: {
|
|
262
|
+
flex: 1,
|
|
263
|
+
paddingBottom: 96
|
|
264
|
+
},
|
|
265
|
+
stateContainer: {
|
|
266
|
+
flex: 1,
|
|
267
|
+
padding: 14
|
|
268
|
+
},
|
|
269
|
+
contentCard: {
|
|
270
|
+
backgroundColor: _sharedUi.macOSColors.background.card,
|
|
271
|
+
borderRadius: 14,
|
|
272
|
+
padding: 14,
|
|
273
|
+
borderWidth: 1,
|
|
274
|
+
borderColor: _sharedUi.macOSColors.border.default
|
|
275
|
+
},
|
|
276
|
+
valueHeader: {
|
|
277
|
+
flexDirection: "row",
|
|
278
|
+
alignItems: "center",
|
|
279
|
+
justifyContent: "space-between",
|
|
280
|
+
marginBottom: 8
|
|
281
|
+
},
|
|
282
|
+
valueLabel: {
|
|
283
|
+
fontSize: 10,
|
|
284
|
+
color: _sharedUi.macOSColors.text.secondary,
|
|
285
|
+
fontFamily: "monospace",
|
|
286
|
+
letterSpacing: 0.5,
|
|
287
|
+
fontWeight: "600"
|
|
288
|
+
},
|
|
289
|
+
valueHeaderBadges: {
|
|
290
|
+
flexDirection: "row",
|
|
291
|
+
alignItems: "center",
|
|
292
|
+
gap: 6
|
|
293
|
+
},
|
|
294
|
+
changeBadge: {
|
|
295
|
+
paddingHorizontal: 8,
|
|
296
|
+
paddingVertical: 2,
|
|
297
|
+
borderRadius: 4
|
|
298
|
+
},
|
|
299
|
+
changeText: {
|
|
300
|
+
fontSize: 9,
|
|
301
|
+
fontWeight: "700",
|
|
302
|
+
fontFamily: "monospace",
|
|
303
|
+
letterSpacing: 0.3
|
|
304
|
+
},
|
|
305
|
+
typeBadge: {
|
|
306
|
+
paddingHorizontal: 8,
|
|
307
|
+
paddingVertical: 2,
|
|
308
|
+
borderRadius: 4,
|
|
309
|
+
backgroundColor: _sharedUi.macOSColors.background.input
|
|
310
|
+
},
|
|
311
|
+
typeText: {
|
|
312
|
+
fontSize: 9,
|
|
313
|
+
fontWeight: "600",
|
|
314
|
+
color: _sharedUi.macOSColors.text.muted,
|
|
315
|
+
fontFamily: "monospace"
|
|
316
|
+
},
|
|
317
|
+
valueBox: {
|
|
318
|
+
backgroundColor: _sharedUi.macOSColors.background.base,
|
|
319
|
+
borderRadius: 6,
|
|
320
|
+
borderWidth: 1,
|
|
321
|
+
borderColor: _sharedUi.macOSColors.border.input,
|
|
322
|
+
padding: 8
|
|
323
|
+
},
|
|
324
|
+
valueText: {
|
|
325
|
+
fontSize: 12,
|
|
326
|
+
color: _sharedUi.macOSColors.text.primary,
|
|
327
|
+
fontFamily: "monospace",
|
|
328
|
+
lineHeight: 18
|
|
329
|
+
},
|
|
330
|
+
diffContainer: {
|
|
331
|
+
flex: 1
|
|
332
|
+
},
|
|
333
|
+
diffContent: {
|
|
334
|
+
flex: 1,
|
|
335
|
+
paddingHorizontal: 14
|
|
336
|
+
},
|
|
337
|
+
changeBadgeSmall: {
|
|
338
|
+
paddingHorizontal: 6,
|
|
339
|
+
paddingVertical: 1,
|
|
340
|
+
borderRadius: 3
|
|
341
|
+
},
|
|
342
|
+
changeTextSmall: {
|
|
343
|
+
fontSize: 8,
|
|
344
|
+
fontWeight: "700",
|
|
345
|
+
fontFamily: "monospace"
|
|
346
|
+
},
|
|
347
|
+
dataViewerContainer: {
|
|
348
|
+
marginTop: -12,
|
|
349
|
+
marginHorizontal: -12,
|
|
350
|
+
marginBottom: -12
|
|
351
|
+
}
|
|
352
|
+
});
|