@buoy-gg/jotai 2.1.15 → 3.0.0
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 +98 -1
- package/lib/commonjs/jotai/components/JotaiAtomBrowser.js +300 -1
- package/lib/commonjs/jotai/components/JotaiAtomChangeItem.js +113 -1
- package/lib/commonjs/jotai/components/JotaiAtomDetailContent.js +754 -1
- package/lib/commonjs/jotai/components/JotaiEventFilterView.js +305 -1
- package/lib/commonjs/jotai/components/JotaiIcon.js +35 -1
- package/lib/commonjs/jotai/components/JotaiModal.js +567 -1
- package/lib/commonjs/jotai/components/index.js +59 -1
- package/lib/commonjs/jotai/hooks/useJotaiAtomChanges.js +83 -1
- package/lib/commonjs/jotai/index.js +85 -1
- package/lib/commonjs/jotai/sync/jotaiSyncAdapter.js +38 -0
- package/lib/commonjs/jotai/utils/jotaiStateStore.js +399 -1
- package/lib/commonjs/jotai/utils/watchAtoms.js +149 -1
- package/lib/commonjs/preset.js +98 -1
- package/lib/module/index.js +79 -1
- package/lib/module/jotai/components/JotaiAtomBrowser.js +296 -1
- package/lib/module/jotai/components/JotaiAtomChangeItem.js +109 -1
- package/lib/module/jotai/components/JotaiAtomDetailContent.js +748 -1
- package/lib/module/jotai/components/JotaiEventFilterView.js +301 -1
- package/lib/module/jotai/components/JotaiIcon.js +31 -1
- package/lib/module/jotai/components/JotaiModal.js +563 -1
- package/lib/module/jotai/components/index.js +8 -1
- package/lib/module/jotai/hooks/useJotaiAtomChanges.js +79 -1
- package/lib/module/jotai/index.js +10 -1
- package/lib/module/jotai/sync/jotaiSyncAdapter.js +35 -0
- package/lib/module/jotai/utils/jotaiStateStore.js +395 -1
- package/lib/module/jotai/utils/watchAtoms.js +144 -1
- package/lib/module/preset.js +94 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/jotai/components/JotaiAtomBrowser.d.ts.map +1 -0
- package/lib/typescript/jotai/components/JotaiAtomChangeItem.d.ts.map +1 -0
- package/lib/typescript/jotai/components/JotaiAtomDetailContent.d.ts.map +1 -0
- package/lib/typescript/jotai/components/JotaiEventFilterView.d.ts.map +1 -0
- package/lib/typescript/jotai/components/JotaiIcon.d.ts.map +1 -0
- package/lib/typescript/jotai/components/JotaiModal.d.ts.map +1 -0
- package/lib/typescript/jotai/components/index.d.ts.map +1 -0
- package/lib/typescript/jotai/hooks/useJotaiAtomChanges.d.ts.map +1 -0
- package/lib/typescript/jotai/index.d.ts.map +1 -0
- package/lib/typescript/jotai/sync/jotaiSyncAdapter.d.ts +23 -0
- package/lib/typescript/jotai/sync/jotaiSyncAdapter.d.ts.map +1 -0
- package/lib/typescript/jotai/types/index.d.ts +11 -0
- package/lib/typescript/jotai/types/index.d.ts.map +1 -0
- package/lib/typescript/jotai/utils/jotaiStateStore.d.ts +29 -1
- package/lib/typescript/jotai/utils/jotaiStateStore.d.ts.map +1 -0
- package/lib/typescript/jotai/utils/watchAtoms.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1,109 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compact list item for displaying a Jotai atom change
|
|
5
|
+
*
|
|
6
|
+
* Mirrors ZustandStateChangeItem.tsx — uses shared CompactRow for consistent styling
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { View, Text, StyleSheet } from "react-native";
|
|
10
|
+
import { CompactRow, buoyColors, Zap, useRelativeTime } from "@buoy-gg/shared-ui";
|
|
11
|
+
import { jotaiStateStore } from "../utils/jotaiStateStore";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
function getStatusLabel(category, atomLabel) {
|
|
14
|
+
if (category === "initial") return "Initial";
|
|
15
|
+
return atomLabel.charAt(0).toUpperCase() + atomLabel.slice(1);
|
|
16
|
+
}
|
|
17
|
+
function getCategoryColor(category, atomLabel) {
|
|
18
|
+
if (category === "initial") return buoyColors.textMuted;
|
|
19
|
+
return jotaiStateStore.getAtomColor(atomLabel);
|
|
20
|
+
}
|
|
21
|
+
function formatCompact(value, maxLen = 20) {
|
|
22
|
+
if (value === undefined) return "undefined";
|
|
23
|
+
if (value === null) return "null";
|
|
24
|
+
if (typeof value === "boolean") return String(value);
|
|
25
|
+
if (typeof value === "number") return String(value);
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
const truncated = value.length > maxLen ? value.slice(0, maxLen - 1) + "…" : value;
|
|
28
|
+
return `"${truncated}"`;
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
return value.length === 0 ? "[]" : `[${value.length} item${value.length === 1 ? "" : "s"}]`;
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === "object") {
|
|
34
|
+
const keys = Object.keys(value);
|
|
35
|
+
if (keys.length === 0) return "{}";
|
|
36
|
+
return `{${keys.slice(0, 2).join(", ")}${keys.length > 2 ? "…" : ""}}`;
|
|
37
|
+
}
|
|
38
|
+
return String(value).slice(0, maxLen);
|
|
39
|
+
}
|
|
40
|
+
function getSublabel(change) {
|
|
41
|
+
if (!change.hasValueChange) return "no change";
|
|
42
|
+
return `${formatCompact(change.prevValue)} → ${formatCompact(change.nextValue)}`;
|
|
43
|
+
}
|
|
44
|
+
function getBadgeText(change) {
|
|
45
|
+
if (change.category === "initial") return "INIT";
|
|
46
|
+
return "WRITE";
|
|
47
|
+
}
|
|
48
|
+
function getPrimaryText(change) {
|
|
49
|
+
if (change.changedKeys.length > 0 && change.changedKeys.length <= 3) {
|
|
50
|
+
return change.changedKeys.join(", ");
|
|
51
|
+
}
|
|
52
|
+
if (change.changedKeys.length > 3) {
|
|
53
|
+
return `${change.changedKeys.slice(0, 2).join(", ")} +${change.changedKeys.length - 2}`;
|
|
54
|
+
}
|
|
55
|
+
return change.valuePreview || "atom()";
|
|
56
|
+
}
|
|
57
|
+
export function JotaiAtomChangeItem({
|
|
58
|
+
change,
|
|
59
|
+
onPress
|
|
60
|
+
}) {
|
|
61
|
+
const statusColor = getCategoryColor(change.category, change.atomLabel);
|
|
62
|
+
const statusLabel = getStatusLabel(change.category, change.atomLabel);
|
|
63
|
+
const sublabel = getSublabel(change);
|
|
64
|
+
const primaryText = getPrimaryText(change);
|
|
65
|
+
const badgeText = getBadgeText(change);
|
|
66
|
+
const relativeTime = useRelativeTime(change.timestamp);
|
|
67
|
+
const customBadge = change.hasValueChange ? /*#__PURE__*/_jsxs(View, {
|
|
68
|
+
style: styles.badgeContainer,
|
|
69
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
70
|
+
style: [styles.badgeText, {
|
|
71
|
+
color: statusColor
|
|
72
|
+
}],
|
|
73
|
+
children: badgeText
|
|
74
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
75
|
+
style: styles.changeBadge,
|
|
76
|
+
children: /*#__PURE__*/_jsx(Zap, {
|
|
77
|
+
size: 12,
|
|
78
|
+
color: buoyColors.warning
|
|
79
|
+
})
|
|
80
|
+
})]
|
|
81
|
+
}) : undefined;
|
|
82
|
+
return /*#__PURE__*/_jsx(CompactRow, {
|
|
83
|
+
statusDotColor: statusColor,
|
|
84
|
+
statusLabel: statusLabel,
|
|
85
|
+
statusSublabel: sublabel,
|
|
86
|
+
primaryText: primaryText,
|
|
87
|
+
bottomRightText: relativeTime,
|
|
88
|
+
customBadge: customBadge,
|
|
89
|
+
badgeText: customBadge ? undefined : badgeText,
|
|
90
|
+
badgeColor: statusColor,
|
|
91
|
+
showChevron: true,
|
|
92
|
+
onPress: () => onPress(change)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const styles = StyleSheet.create({
|
|
96
|
+
badgeContainer: {
|
|
97
|
+
flexDirection: "row",
|
|
98
|
+
alignItems: "center",
|
|
99
|
+
gap: 4
|
|
100
|
+
},
|
|
101
|
+
badgeText: {
|
|
102
|
+
fontSize: 11,
|
|
103
|
+
fontWeight: "600",
|
|
104
|
+
fontFamily: "monospace"
|
|
105
|
+
},
|
|
106
|
+
changeBadge: {
|
|
107
|
+
paddingHorizontal: 4
|
|
108
|
+
}
|
|
109
|
+
});
|