@buoy-gg/jotai 3.0.1 → 4.0.1

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 (48) hide show
  1. package/lib/commonjs/index.js +98 -1
  2. package/lib/commonjs/jotai/components/JotaiAtomBrowser.js +300 -1
  3. package/lib/commonjs/jotai/components/JotaiAtomChangeItem.js +113 -1
  4. package/lib/commonjs/jotai/components/JotaiAtomDetailContent.js +754 -1
  5. package/lib/commonjs/jotai/components/JotaiEventFilterView.js +305 -1
  6. package/lib/commonjs/jotai/components/JotaiIcon.js +35 -1
  7. package/lib/commonjs/jotai/components/JotaiModal.js +567 -1
  8. package/lib/commonjs/jotai/components/index.js +59 -1
  9. package/lib/commonjs/jotai/hooks/useJotaiAtomChanges.js +83 -1
  10. package/lib/commonjs/jotai/index.js +85 -1
  11. package/lib/commonjs/jotai/sync/jotaiSyncAdapter.js +38 -0
  12. package/lib/commonjs/jotai/utils/jotaiStateStore.js +399 -1
  13. package/lib/commonjs/jotai/utils/watchAtoms.js +149 -1
  14. package/lib/commonjs/preset.js +98 -1
  15. package/lib/module/index.js +79 -1
  16. package/lib/module/jotai/components/JotaiAtomBrowser.js +296 -1
  17. package/lib/module/jotai/components/JotaiAtomChangeItem.js +109 -1
  18. package/lib/module/jotai/components/JotaiAtomDetailContent.js +748 -1
  19. package/lib/module/jotai/components/JotaiEventFilterView.js +301 -1
  20. package/lib/module/jotai/components/JotaiIcon.js +31 -1
  21. package/lib/module/jotai/components/JotaiModal.js +563 -1
  22. package/lib/module/jotai/components/index.js +8 -1
  23. package/lib/module/jotai/hooks/useJotaiAtomChanges.js +79 -1
  24. package/lib/module/jotai/index.js +10 -1
  25. package/lib/module/jotai/sync/jotaiSyncAdapter.js +35 -0
  26. package/lib/module/jotai/utils/jotaiStateStore.js +395 -1
  27. package/lib/module/jotai/utils/watchAtoms.js +144 -1
  28. package/lib/module/preset.js +94 -1
  29. package/lib/typescript/index.d.ts +2 -1
  30. package/lib/typescript/index.d.ts.map +1 -0
  31. package/lib/typescript/jotai/components/JotaiAtomBrowser.d.ts.map +1 -0
  32. package/lib/typescript/jotai/components/JotaiAtomChangeItem.d.ts.map +1 -0
  33. package/lib/typescript/jotai/components/JotaiAtomDetailContent.d.ts.map +1 -0
  34. package/lib/typescript/jotai/components/JotaiEventFilterView.d.ts.map +1 -0
  35. package/lib/typescript/jotai/components/JotaiIcon.d.ts.map +1 -0
  36. package/lib/typescript/jotai/components/JotaiModal.d.ts.map +1 -0
  37. package/lib/typescript/jotai/components/index.d.ts.map +1 -0
  38. package/lib/typescript/jotai/hooks/useJotaiAtomChanges.d.ts.map +1 -0
  39. package/lib/typescript/jotai/index.d.ts.map +1 -0
  40. package/lib/typescript/jotai/sync/jotaiSyncAdapter.d.ts +23 -0
  41. package/lib/typescript/jotai/sync/jotaiSyncAdapter.d.ts.map +1 -0
  42. package/lib/typescript/jotai/types/index.d.ts +11 -0
  43. package/lib/typescript/jotai/types/index.d.ts.map +1 -0
  44. package/lib/typescript/jotai/utils/jotaiStateStore.d.ts +29 -1
  45. package/lib/typescript/jotai/utils/jotaiStateStore.d.ts.map +1 -0
  46. package/lib/typescript/jotai/utils/watchAtoms.d.ts.map +1 -0
  47. package/lib/typescript/preset.d.ts.map +1 -0
  48. package/package.json +3 -3
@@ -1 +1,109 @@
1
- "use strict";import{View,Text,StyleSheet}from"react-native";import{CompactRow,buoyColors,Zap,useRelativeTime}from"@buoy-gg/shared-ui";import{jotaiStateStore}from"../utils/jotaiStateStore";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function getStatusLabel(e,t){return"initial"===e?"Initial":t.charAt(0).toUpperCase()+t.slice(1)}function getCategoryColor(e,t){return"initial"===e?buoyColors.textMuted:jotaiStateStore.getAtomColor(t)}function formatCompact(e,t=20){if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return String(e);if("number"==typeof e)return String(e);if("string"==typeof e)return`"${e.length>t?e.slice(0,t-1)+"…":e}"`;if(Array.isArray(e))return 0===e.length?"[]":`[${e.length} item${1===e.length?"":"s"}]`;if("object"==typeof e){const t=Object.keys(e);return 0===t.length?"{}":`{${t.slice(0,2).join(", ")}${t.length>2?"…":""}}`}return String(e).slice(0,t)}function getSublabel(e){return e.hasValueChange?`${formatCompact(e.prevValue)} → ${formatCompact(e.nextValue)}`:"no change"}function getBadgeText(e){return"initial"===e.category?"INIT":"WRITE"}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.valuePreview||"atom()"}export function JotaiAtomChangeItem({change:e,onPress:t}){const o=getCategoryColor(e.category,e.atomLabel),a=getStatusLabel(e.category,e.atomLabel),n=getSublabel(e),r=getPrimaryText(e),i=getBadgeText(e),s=useRelativeTime(e.timestamp),l=e.hasValueChange?_jsxs(View,{style:styles.badgeContainer,children:[_jsx(Text,{style:[styles.badgeText,{color:o}],children:i}),_jsx(View,{style:styles.changeBadge,children:_jsx(Zap,{size:12,color:buoyColors.warning})})]}):void 0;return _jsx(CompactRow,{statusDotColor:o,statusLabel:a,statusSublabel:n,primaryText:r,bottomRightText:s,customBadge:l,badgeText:l?void 0:i,badgeColor:o,showChevron:!0,onPress:()=>t(e)})}const styles=StyleSheet.create({badgeContainer:{flexDirection:"row",alignItems:"center",gap:4},badgeText:{fontSize:11,fontWeight:"600",fontFamily:"monospace"},changeBadge:{paddingHorizontal:4}});
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
+ });