@buoy-gg/zustand 2.1.12 → 2.1.13

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.
Files changed (56) hide show
  1. package/lib/commonjs/index.js +1 -91
  2. package/lib/commonjs/preset.js +1 -102
  3. package/lib/commonjs/zustand/components/ZustandActionButton.js +1 -116
  4. package/lib/commonjs/zustand/components/ZustandDetailViewToggle.js +1 -134
  5. package/lib/commonjs/zustand/components/ZustandEventFilterView.js +1 -291
  6. package/lib/commonjs/zustand/components/ZustandIcon.js +1 -35
  7. package/lib/commonjs/zustand/components/ZustandModal.js +1 -603
  8. package/lib/commonjs/zustand/components/ZustandStateChangeItem.js +1 -165
  9. package/lib/commonjs/zustand/components/ZustandStateDetailContent.js +1 -352
  10. package/lib/commonjs/zustand/components/ZustandStateInfoView.js +1 -508
  11. package/lib/commonjs/zustand/components/ZustandStoreBrowser.js +1 -307
  12. package/lib/commonjs/zustand/components/index.js +1 -73
  13. package/lib/commonjs/zustand/hooks/index.js +1 -12
  14. package/lib/commonjs/zustand/hooks/useZustandStateChanges.js +1 -92
  15. package/lib/commonjs/zustand/index.js +1 -99
  16. package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +1 -220
  17. package/lib/commonjs/zustand/utils/index.js +1 -31
  18. package/lib/commonjs/zustand/utils/zustandStateStore.js +1 -361
  19. package/lib/module/index.js +1 -80
  20. package/lib/module/preset.js +1 -98
  21. package/lib/module/zustand/components/ZustandActionButton.js +1 -112
  22. package/lib/module/zustand/components/ZustandDetailViewToggle.js +1 -129
  23. package/lib/module/zustand/components/ZustandEventFilterView.js +1 -287
  24. package/lib/module/zustand/components/ZustandIcon.js +1 -32
  25. package/lib/module/zustand/components/ZustandModal.js +1 -599
  26. package/lib/module/zustand/components/ZustandStateChangeItem.js +1 -161
  27. package/lib/module/zustand/components/ZustandStateDetailContent.js +1 -348
  28. package/lib/module/zustand/components/ZustandStateInfoView.js +1 -503
  29. package/lib/module/zustand/components/ZustandStoreBrowser.js +1 -303
  30. package/lib/module/zustand/components/index.js +1 -10
  31. package/lib/module/zustand/hooks/index.js +1 -3
  32. package/lib/module/zustand/hooks/useZustandStateChanges.js +1 -88
  33. package/lib/module/zustand/index.js +1 -12
  34. package/lib/module/zustand/utils/buoyZustandMiddleware.js +1 -214
  35. package/lib/module/zustand/utils/index.js +1 -4
  36. package/lib/module/zustand/utils/zustandStateStore.js +1 -357
  37. package/package.json +3 -3
  38. package/lib/typescript/index.d.ts.map +0 -1
  39. package/lib/typescript/preset.d.ts.map +0 -1
  40. package/lib/typescript/zustand/components/ZustandActionButton.d.ts.map +0 -1
  41. package/lib/typescript/zustand/components/ZustandDetailViewToggle.d.ts.map +0 -1
  42. package/lib/typescript/zustand/components/ZustandEventFilterView.d.ts.map +0 -1
  43. package/lib/typescript/zustand/components/ZustandIcon.d.ts.map +0 -1
  44. package/lib/typescript/zustand/components/ZustandModal.d.ts.map +0 -1
  45. package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts.map +0 -1
  46. package/lib/typescript/zustand/components/ZustandStateDetailContent.d.ts.map +0 -1
  47. package/lib/typescript/zustand/components/ZustandStateInfoView.d.ts.map +0 -1
  48. package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts.map +0 -1
  49. package/lib/typescript/zustand/components/index.d.ts.map +0 -1
  50. package/lib/typescript/zustand/hooks/index.d.ts.map +0 -1
  51. package/lib/typescript/zustand/hooks/useZustandStateChanges.d.ts.map +0 -1
  52. package/lib/typescript/zustand/index.d.ts.map +0 -1
  53. package/lib/typescript/zustand/types/index.d.ts.map +0 -1
  54. package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts.map +0 -1
  55. package/lib/typescript/zustand/utils/index.d.ts.map +0 -1
  56. package/lib/typescript/zustand/utils/zustandStateStore.d.ts.map +0 -1
@@ -1,165 +1 @@
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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ZustandStateChangeItem=ZustandStateChangeItem;var _reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_zustandStateStore=require("../utils/zustandStateStore"),_jsxRuntime=require("react/jsx-runtime");function getStatusLabel(e,t){switch(e){case"replace":return"Replace";case"persist":return"Hydrate";case"initial":return"Initial";default:return t.charAt(0).toUpperCase()+t.slice(1)}}function getCategoryColor(e,t){switch(e){case"replace":return _sharedUi.buoyColors.warning;case"persist":return _sharedUi.buoyColors.info;case"initial":return _sharedUi.buoyColors.textMuted;default:return _zustandStateStore.zustandStateStore.getStoreColor(t)}}function getSublabel(e){const t=[];return void 0!==e.duration&&e.duration>=.1&&t.push(`${e.duration.toFixed(1)}ms`),e.hasStateChange?e.changedKeysCount>0?t.push(`${e.changedKeysCount} key${e.changedKeysCount>1?"s":""} changed`):t.push(e.diffSummary||"state changed"):t.push("no state change"),t.join(" · ")}function getBadgeText(e){return"replace"===e.category?"REPLACE":"persist"===e.category?"HYDRATE":"initial"===e.category?"INIT":"SET"}function getPrimaryText(e){return e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.partialPreview||"setState()"}function ZustandStateChangeItem({change:e,onPress:t}){const a=getCategoryColor(e.category,e.storeName),s=getStatusLabel(e.category,e.storeName),r=getSublabel(e),n=getPrimaryText(e),i=getBadgeText(e),o=(0,_sharedUi.useRelativeTime)(e.timestamp);let u;return e.isSlowUpdate?u=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.badgeContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.badgeText,{color:a}],children:i}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.slowBadge,children:(0,_jsxRuntime.jsx)(_sharedUi.Clock,{size:12,color:_sharedUi.buoyColors.error})})]}):e.hasStateChange&&(u=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.badgeContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.badgeText,{color:a}],children:i}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.changeBadge,children:(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:12,color:_sharedUi.buoyColors.warning})})]})),(0,_jsxRuntime.jsx)(_sharedUi.CompactRow,{statusDotColor:a,statusLabel:s,statusSublabel:r,primaryText:n,bottomRightText:o,customBadge:u,badgeText:u?void 0:i,badgeColor:a,showChevron:!0,onPress:()=>t(e)})}const styles=_reactNative.StyleSheet.create({badgeContainer:{flexDirection:"row",alignItems:"center",gap:4},badgeText:{fontSize:11,fontWeight:"600",fontFamily:"monospace"},changeBadge:{paddingHorizontal:4},slowBadge:{paddingHorizontal:4}});
@@ -1,352 +1 @@
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
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ZustandStateDetailContent=ZustandStateDetailContent,exports.ZustandStateDetailFooter=ZustandStateDetailFooter;var _reactNative=require("react-native"),_react=require("react"),_sharedUi=require("@buoy-gg/shared-ui"),_dataViewer=require("@buoy-gg/shared-ui/dataViewer"),_ZustandDetailViewToggle=require("./ZustandDetailViewToggle"),_ZustandStateInfoView=require("./ZustandStateInfoView"),_zustandStateStore=require("../utils/zustandStateStore"),_jsxRuntime=require("react/jsx-runtime");function getChangeColor(e){return _zustandStateStore.zustandStateStore.getStoreColor(e.storeName)}function getChangeLabel(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function getValueType(e){return null===e?"null":void 0===e?"undefined":Array.isArray(e)?"array":typeof e}function formatTimestamp(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}const DIFF_MODE_TABS=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];function ZustandStateDetailContent({change:e,changes:t,selectedIndex:a,onIndexChange:i,disableInternalFooter:r=!1}){const[n,s]=(0,_react.useState)("change"),[o,l]=(0,_react.useState)("tree"),d=t.length,c=getChangeColor(e),u=getChangeLabel(e),m=getValueType((0,_sharedUi.parseValue)(e.nextState)),g=d-a,x=g-1,h=a<d-1?a+1:null,_=null!==h?t[h]:null,f=(0,_react.useMemo)(()=>({index:h??0,label:x>0?`#${x}`:"Initial",timestamp:_?formatTimestamp(_.timestamp):"",relativeTime:_?(0,_sharedUi.formatRelativeTime)(new Date(_.timestamp)):"state",badge:_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${getChangeColor(_)}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:getChangeColor(_)}],children:getChangeLabel(_)})}):void 0}),[h,_,x]),p=(0,_react.useMemo)(()=>({index:a,label:`#${g}`,timestamp:formatTimestamp(e.timestamp),relativeTime:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${c}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:c}],children:u})})}),[a,e.timestamp,c,u,g]),y=(0,_react.useCallback)(()=>{const t=(0,_sharedUi.parseValue)(e.nextState);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.contentCard,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.valueLabel,children:"STATE AFTER CHANGE"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeaderBadges,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadge,{backgroundColor:`${c}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeText,{color:c}],children:u})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.typeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.typeText,children:m.toUpperCase()})})]})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:t,showTypeFilter:!0,rawMode:!0,initialExpanded:!0})})]})},[e.nextState,c,u,m]),S=(0,_react.useCallback)(()=>{const t=(0,_sharedUi.parseValue)(e.prevState),a=(0,_sharedUi.parseValue)(e.nextState);return"split"===o?(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:{flex:1},showsVerticalScrollIndicator:!0,children:(0,_jsxRuntime.jsx)(_dataViewer.SplitDiffViewer,{oldValue:t,newValue:a,theme:_dataViewer.diffThemes.devToolsDefault,options:{hideLineNumbers:!1,disableWordDiff:!1,showDiffOnly:!1,compareMethod:"words",contextLines:3},showThemeName:!1})}):(0,_jsxRuntime.jsx)(_dataViewer.TreeDiffViewer,{oldValue:t,newValue:a})},[e.prevState,e.nextState,o]),j=(0,_react.useCallback)(()=>{i(Math.min(d-1,a+1))},[a,d,i]),C=(0,_react.useCallback)(()=>{i(Math.max(0,a-1))},[a,i]),b=d<=1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_ZustandDetailViewToggle.ZustandDetailViewToggle,{activeView:n,onViewChange:s,diffDisabled:b}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.contentArea,children:["change"===n&&(0,_jsxRuntime.jsx)(_ZustandStateInfoView.ZustandStateInfoView,{change:e}),"state"===n&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.stateContainer,children:y()}),"diff"===n&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.diffContainer,children:[(0,_jsxRuntime.jsx)(_sharedUi.DiffModeTabs,{tabs:DIFF_MODE_TABS,activeTab:o,onTabChange:l}),(0,_jsxRuntime.jsx)(_sharedUi.CompareBar,{leftEvent:f,rightEvent:p}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.diffContent,children:S()})]})]}),!r&&d>1&&(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:g-1,totalItems:d,onPrevious:j,onNext:C,itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),absolute:!0})]})}function ZustandStateDetailFooter({change:e,changes:t,selectedIndex:a,onIndexChange:i}){const r=t.length;if(r<=1)return null;const n=r-a;return(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:n-1,totalItems:r,onPrevious:()=>i(Math.min(r-1,a+1)),onNext:()=>i(Math.max(0,a-1)),itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp))})}const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:_sharedUi.macOSColors.background.base},contentArea:{flex:1,paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:_sharedUi.macOSColors.background.card,borderRadius:14,padding:14,borderWidth:1,borderColor:_sharedUi.macOSColors.border.default},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:_sharedUi.macOSColors.text.secondary,fontFamily:"monospace",letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:"monospace",letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:_sharedUi.macOSColors.background.input},typeText:{fontSize:9,fontWeight:"600",color:_sharedUi.macOSColors.text.muted,fontFamily:"monospace"},valueBox:{backgroundColor:_sharedUi.macOSColors.background.base,borderRadius:6,borderWidth:1,borderColor:_sharedUi.macOSColors.border.input,padding:8},valueText:{fontSize:12,color:_sharedUi.macOSColors.text.primary,fontFamily:"monospace",lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:"monospace"},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});