@motiadev/plugin-states 0.14.0-beta.165-602289 → 0.14.0-beta.165-210612
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/dist/index.js +726 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { Button, Checkbox, Input, Sidebar, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, cn, useThemeStore } from "@motiadev/ui";
|
|
3
|
+
import { AlertCircle, Check, Loader2, RefreshCw, Save, Search, Trash, X } from "lucide-react";
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { create } from "zustand";
|
|
6
|
+
import JsonView from "react18-json-view";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import Editor, { useMonaco } from "@monaco-editor/react";
|
|
9
|
+
|
|
10
|
+
//#region src/hooks/states-hooks.ts
|
|
11
|
+
const useGetStateItems = () => {
|
|
12
|
+
const $ = c(8);
|
|
13
|
+
if ($[0] !== "c7199b15726ef92a8b1236966886099ddb103f2294b30414c1123a90f5c60f8c") {
|
|
14
|
+
for (let $i = 0; $i < 8; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
15
|
+
$[0] = "c7199b15726ef92a8b1236966886099ddb103f2294b30414c1123a90f5c60f8c";
|
|
16
|
+
}
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
19
|
+
t0 = [];
|
|
20
|
+
$[1] = t0;
|
|
21
|
+
} else t0 = $[1];
|
|
22
|
+
const [items, setItems] = useState(t0);
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
25
|
+
t1 = () => {
|
|
26
|
+
fetch("/__motia/state").then(_temp$2).then(setItems).catch(_temp2$1);
|
|
27
|
+
};
|
|
28
|
+
$[2] = t1;
|
|
29
|
+
} else t1 = $[2];
|
|
30
|
+
const refetch = t1;
|
|
31
|
+
let t2;
|
|
32
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
33
|
+
t2 = (ids) => {
|
|
34
|
+
fetch("/__motia/state/delete", {
|
|
35
|
+
method: "POST",
|
|
36
|
+
headers: { "Content-Type": "application/json" },
|
|
37
|
+
body: JSON.stringify({ ids })
|
|
38
|
+
}).then(() => refetch());
|
|
39
|
+
};
|
|
40
|
+
$[3] = t2;
|
|
41
|
+
} else t2 = $[3];
|
|
42
|
+
const deleteItems = t2;
|
|
43
|
+
let t3;
|
|
44
|
+
let t4;
|
|
45
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
46
|
+
t3 = () => {
|
|
47
|
+
refetch();
|
|
48
|
+
};
|
|
49
|
+
t4 = [refetch];
|
|
50
|
+
$[4] = t3;
|
|
51
|
+
$[5] = t4;
|
|
52
|
+
} else {
|
|
53
|
+
t3 = $[4];
|
|
54
|
+
t4 = $[5];
|
|
55
|
+
}
|
|
56
|
+
useEffect(t3, t4);
|
|
57
|
+
let t5;
|
|
58
|
+
if ($[6] !== items) {
|
|
59
|
+
t5 = {
|
|
60
|
+
items,
|
|
61
|
+
deleteItems,
|
|
62
|
+
refetch
|
|
63
|
+
};
|
|
64
|
+
$[6] = items;
|
|
65
|
+
$[7] = t5;
|
|
66
|
+
} else t5 = $[7];
|
|
67
|
+
return t5;
|
|
68
|
+
};
|
|
69
|
+
async function _temp$2(res) {
|
|
70
|
+
if (res.ok) return res.json();
|
|
71
|
+
else throw await res.json();
|
|
72
|
+
}
|
|
73
|
+
function _temp2$1(err) {
|
|
74
|
+
return console.error(err);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/stores/use-states-store.ts
|
|
79
|
+
const useStatesStore = create()((set) => ({
|
|
80
|
+
selectedStateId: void 0,
|
|
81
|
+
selectStateId: (stateId) => set({ selectedStateId: stateId })
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/components/state-details.tsx
|
|
86
|
+
const StateDetails = (t0) => {
|
|
87
|
+
const $ = c(3);
|
|
88
|
+
if ($[0] !== "5995831aa1bc747830da5e0bb4a1d2bc36c1eaf62fb9c2f142532ffec8710bf4") {
|
|
89
|
+
for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
90
|
+
$[0] = "5995831aa1bc747830da5e0bb4a1d2bc36c1eaf62fb9c2f142532ffec8710bf4";
|
|
91
|
+
}
|
|
92
|
+
const { state } = t0;
|
|
93
|
+
let t1;
|
|
94
|
+
if ($[1] !== state.value) {
|
|
95
|
+
t1 = /* @__PURE__ */ jsx(JsonView, {
|
|
96
|
+
src: state.value,
|
|
97
|
+
theme: "default"
|
|
98
|
+
});
|
|
99
|
+
$[1] = state.value;
|
|
100
|
+
$[2] = t1;
|
|
101
|
+
} else t1 = $[2];
|
|
102
|
+
return t1;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/components/json-editor.tsx
|
|
107
|
+
const JsonEditor = (t0) => {
|
|
108
|
+
const $ = c(24);
|
|
109
|
+
if ($[0] !== "d1386dfeba00fe12241776daa47cf42300103748d5dcfe271adcb17c673326c6") {
|
|
110
|
+
for (let $i = 0; $i < 24; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
111
|
+
$[0] = "d1386dfeba00fe12241776daa47cf42300103748d5dcfe271adcb17c673326c6";
|
|
112
|
+
}
|
|
113
|
+
const { value, height: t1, schema, onChange, onValidate, language: t2, readOnly: t3 } = t0;
|
|
114
|
+
const height = t1 === void 0 ? 300 : t1;
|
|
115
|
+
const language = t2 === void 0 ? "json" : t2;
|
|
116
|
+
const readOnly = t3 === void 0 ? false : t3;
|
|
117
|
+
const monaco = useMonaco();
|
|
118
|
+
const editorTheme = useThemeStore(_temp$1) === "dark" ? "vs-dark" : "light";
|
|
119
|
+
let t4;
|
|
120
|
+
if ($[1] !== monaco || $[2] !== schema) {
|
|
121
|
+
t4 = () => {
|
|
122
|
+
if (!monaco) return;
|
|
123
|
+
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({ isolatedModules: true });
|
|
124
|
+
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ schemas: schema ? [{
|
|
125
|
+
uri: window.location.href,
|
|
126
|
+
fileMatch: ["*"],
|
|
127
|
+
schema
|
|
128
|
+
}] : [] });
|
|
129
|
+
};
|
|
130
|
+
$[1] = monaco;
|
|
131
|
+
$[2] = schema;
|
|
132
|
+
$[3] = t4;
|
|
133
|
+
} else t4 = $[3];
|
|
134
|
+
let t5;
|
|
135
|
+
if ($[4] !== language || $[5] !== monaco || $[6] !== schema) {
|
|
136
|
+
t5 = [
|
|
137
|
+
monaco,
|
|
138
|
+
schema,
|
|
139
|
+
language
|
|
140
|
+
];
|
|
141
|
+
$[4] = language;
|
|
142
|
+
$[5] = monaco;
|
|
143
|
+
$[6] = schema;
|
|
144
|
+
$[7] = t5;
|
|
145
|
+
} else t5 = $[7];
|
|
146
|
+
useEffect(t4, t5);
|
|
147
|
+
let t6;
|
|
148
|
+
if ($[8] !== onChange || $[9] !== onValidate) {
|
|
149
|
+
t6 = (value_0) => {
|
|
150
|
+
if (!value_0) onValidate?.(false);
|
|
151
|
+
onChange?.(value_0 ?? "");
|
|
152
|
+
};
|
|
153
|
+
$[8] = onChange;
|
|
154
|
+
$[9] = onValidate;
|
|
155
|
+
$[10] = t6;
|
|
156
|
+
} else t6 = $[10];
|
|
157
|
+
let t7;
|
|
158
|
+
if ($[11] !== onValidate) {
|
|
159
|
+
t7 = (markers) => onValidate?.(markers.length === 0);
|
|
160
|
+
$[11] = onValidate;
|
|
161
|
+
$[12] = t7;
|
|
162
|
+
} else t7 = $[12];
|
|
163
|
+
let t8;
|
|
164
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
165
|
+
t8 = { enabled: false };
|
|
166
|
+
$[13] = t8;
|
|
167
|
+
} else t8 = $[13];
|
|
168
|
+
let t9;
|
|
169
|
+
if ($[14] !== readOnly) {
|
|
170
|
+
t9 = {
|
|
171
|
+
readOnly,
|
|
172
|
+
scrollBeyondLastLine: false,
|
|
173
|
+
minimap: t8
|
|
174
|
+
};
|
|
175
|
+
$[14] = readOnly;
|
|
176
|
+
$[15] = t9;
|
|
177
|
+
} else t9 = $[15];
|
|
178
|
+
let t10;
|
|
179
|
+
if ($[16] !== editorTheme || $[17] !== height || $[18] !== language || $[19] !== t6 || $[20] !== t7 || $[21] !== t9 || $[22] !== value) {
|
|
180
|
+
t10 = /* @__PURE__ */ jsx(Editor, {
|
|
181
|
+
"data-testid": "json-editor",
|
|
182
|
+
height,
|
|
183
|
+
language,
|
|
184
|
+
value,
|
|
185
|
+
theme: editorTheme,
|
|
186
|
+
onChange: t6,
|
|
187
|
+
onValidate: t7,
|
|
188
|
+
options: t9
|
|
189
|
+
});
|
|
190
|
+
$[16] = editorTheme;
|
|
191
|
+
$[17] = height;
|
|
192
|
+
$[18] = language;
|
|
193
|
+
$[19] = t6;
|
|
194
|
+
$[20] = t7;
|
|
195
|
+
$[21] = t9;
|
|
196
|
+
$[22] = value;
|
|
197
|
+
$[23] = t10;
|
|
198
|
+
} else t10 = $[23];
|
|
199
|
+
return t10;
|
|
200
|
+
};
|
|
201
|
+
function _temp$1(state) {
|
|
202
|
+
return state.theme;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/components/state-editor.tsx
|
|
207
|
+
const StateEditor = ({ state }) => {
|
|
208
|
+
const [isRequestLoading, setIsRequestLoading] = useState(false);
|
|
209
|
+
const [isValid, setIsValid] = useState(true);
|
|
210
|
+
const [jsonValue, setJsonValue] = useState(JSON.stringify(state.value, null, 2));
|
|
211
|
+
const [hasChanges, setHasChanges] = useState(false);
|
|
212
|
+
const [saveStatus, setSaveStatus] = useState("idle");
|
|
213
|
+
const lastSavedValue = useRef(JSON.stringify(state.value, null, 2));
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
setJsonValue(JSON.stringify(state.value, null, 2));
|
|
216
|
+
}, [state.value]);
|
|
217
|
+
const handleJsonChange = useCallback((value) => {
|
|
218
|
+
setHasChanges(value !== lastSavedValue.current);
|
|
219
|
+
setJsonValue(value);
|
|
220
|
+
setSaveStatus("idle");
|
|
221
|
+
}, []);
|
|
222
|
+
const handleSave = async () => {
|
|
223
|
+
if (!isValid || !hasChanges) return;
|
|
224
|
+
try {
|
|
225
|
+
setIsRequestLoading(true);
|
|
226
|
+
setSaveStatus("idle");
|
|
227
|
+
const response = await fetch("/__motia/state", {
|
|
228
|
+
method: "POST",
|
|
229
|
+
headers: { "Content-Type": "application/json" },
|
|
230
|
+
body: JSON.stringify({
|
|
231
|
+
key: state.key,
|
|
232
|
+
groupId: state.groupId,
|
|
233
|
+
value: JSON.parse(jsonValue)
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
|
237
|
+
lastSavedValue.current = jsonValue;
|
|
238
|
+
setSaveStatus("success");
|
|
239
|
+
setHasChanges(false);
|
|
240
|
+
setTimeout(() => {
|
|
241
|
+
setSaveStatus("idle");
|
|
242
|
+
}, 3e3);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error("Failed to save state:", error);
|
|
245
|
+
setSaveStatus("error");
|
|
246
|
+
} finally {
|
|
247
|
+
setIsRequestLoading(false);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const resetChanges = useCallback(() => {
|
|
251
|
+
setJsonValue(JSON.stringify(state.value, null, 2));
|
|
252
|
+
setHasChanges(false);
|
|
253
|
+
setSaveStatus("idle");
|
|
254
|
+
}, [state.value]);
|
|
255
|
+
const statusView = useMemo(() => {
|
|
256
|
+
if (saveStatus === "success") return /* @__PURE__ */ jsx("div", {
|
|
257
|
+
className: "bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 rounded-lg p-2",
|
|
258
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
259
|
+
className: "flex items-center gap-2 text-green-700 dark:text-green-400 text-sm",
|
|
260
|
+
children: [/* @__PURE__ */ jsx(Check, { className: "w-4 h-4" }), "State saved successfully!"]
|
|
261
|
+
})
|
|
262
|
+
});
|
|
263
|
+
if (saveStatus === "error") return /* @__PURE__ */ jsx("div", {
|
|
264
|
+
className: "bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800 rounded-lg p-2",
|
|
265
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
266
|
+
className: "flex items-center gap-2 text-red-700 dark:text-red-400 text-sm",
|
|
267
|
+
children: [/* @__PURE__ */ jsx(AlertCircle, { className: "w-4 h-4" }), "Failed to save state. Please try again."]
|
|
268
|
+
})
|
|
269
|
+
});
|
|
270
|
+
return /* @__PURE__ */ jsx("div", {
|
|
271
|
+
className: "text-xs text-muted-foreground",
|
|
272
|
+
children: hasChanges ? /* @__PURE__ */ jsxs("span", {
|
|
273
|
+
className: "flex items-center gap-1",
|
|
274
|
+
children: [/* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-orange-500 rounded-full" }), "Unsaved changes"]
|
|
275
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
276
|
+
className: "flex items-center gap-1",
|
|
277
|
+
children: [/* @__PURE__ */ jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }), "Up to date"]
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
}, [saveStatus, hasChanges]);
|
|
281
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
282
|
+
className: "flex flex-col gap-2 h-full",
|
|
283
|
+
children: [
|
|
284
|
+
/* @__PURE__ */ jsx("p", {
|
|
285
|
+
className: "text-xs text-muted-foreground",
|
|
286
|
+
children: "Modify the state value using the JSON editor below."
|
|
287
|
+
}),
|
|
288
|
+
/* @__PURE__ */ jsx("div", {
|
|
289
|
+
className: "space-y-3 pt-2 flex flex-col",
|
|
290
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
291
|
+
className: "relative flex-1",
|
|
292
|
+
children: [/* @__PURE__ */ jsx(JsonEditor, {
|
|
293
|
+
value: jsonValue,
|
|
294
|
+
onChange: handleJsonChange,
|
|
295
|
+
onValidate: setIsValid,
|
|
296
|
+
height: "calc(100vh - 300px)"
|
|
297
|
+
}), !isValid && /* @__PURE__ */ jsxs("div", {
|
|
298
|
+
className: "absolute top-2 right-2 bg-destructive/90 text-destructive-foreground px-2 py-1 rounded text-xs flex items-center gap-1",
|
|
299
|
+
children: [/* @__PURE__ */ jsx(AlertCircle, { className: "w-3 h-3" }), "Invalid JSON"]
|
|
300
|
+
})]
|
|
301
|
+
})
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ jsxs("div", {
|
|
304
|
+
className: "flex items-center justify-between pt-2",
|
|
305
|
+
children: [statusView, /* @__PURE__ */ jsxs("div", {
|
|
306
|
+
className: "flex items-center gap-2",
|
|
307
|
+
children: [hasChanges && /* @__PURE__ */ jsx(Button, {
|
|
308
|
+
variant: "secondary",
|
|
309
|
+
onClick: resetChanges,
|
|
310
|
+
disabled: isRequestLoading,
|
|
311
|
+
children: "Reset"
|
|
312
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
313
|
+
onClick: handleSave,
|
|
314
|
+
variant: "accent",
|
|
315
|
+
disabled: isRequestLoading || !isValid || !hasChanges,
|
|
316
|
+
"data-testid": "state-save-button",
|
|
317
|
+
children: isRequestLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Loader2, { className: "w-3 h-3 animate-spin mr-1" }), "Saving..."] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Save, { className: "w-3 h-3 mr-1" }), "Save Changes"] })
|
|
318
|
+
})]
|
|
319
|
+
})]
|
|
320
|
+
})
|
|
321
|
+
]
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/components/state-sidebar.tsx
|
|
327
|
+
const StateSidebar = (t0) => {
|
|
328
|
+
const $ = c(15);
|
|
329
|
+
if ($[0] !== "99df8f944367e03b0c8d3e46933b073a4ba8e236d0058ad7eeca4ca6f223a516") {
|
|
330
|
+
for (let $i = 0; $i < 15; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
331
|
+
$[0] = "99df8f944367e03b0c8d3e46933b073a4ba8e236d0058ad7eeca4ca6f223a516";
|
|
332
|
+
}
|
|
333
|
+
const { state, onClose } = t0;
|
|
334
|
+
let t1;
|
|
335
|
+
if ($[1] !== state) {
|
|
336
|
+
t1 = {
|
|
337
|
+
label: "Overview",
|
|
338
|
+
content: /* @__PURE__ */ jsx(StateDetails, { state })
|
|
339
|
+
};
|
|
340
|
+
$[1] = state;
|
|
341
|
+
$[2] = t1;
|
|
342
|
+
} else t1 = $[2];
|
|
343
|
+
let t2;
|
|
344
|
+
if ($[3] !== state) {
|
|
345
|
+
t2 = {
|
|
346
|
+
label: "Editor",
|
|
347
|
+
content: /* @__PURE__ */ jsx(StateEditor, { state })
|
|
348
|
+
};
|
|
349
|
+
$[3] = state;
|
|
350
|
+
$[4] = t2;
|
|
351
|
+
} else t2 = $[4];
|
|
352
|
+
let t3;
|
|
353
|
+
if ($[5] !== t1 || $[6] !== t2) {
|
|
354
|
+
t3 = [t1, t2];
|
|
355
|
+
$[5] = t1;
|
|
356
|
+
$[6] = t2;
|
|
357
|
+
$[7] = t3;
|
|
358
|
+
} else t3 = $[7];
|
|
359
|
+
let t4;
|
|
360
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
361
|
+
t4 = /* @__PURE__ */ jsx(X, {});
|
|
362
|
+
$[8] = t4;
|
|
363
|
+
} else t4 = $[8];
|
|
364
|
+
let t5;
|
|
365
|
+
if ($[9] !== onClose) {
|
|
366
|
+
t5 = [{
|
|
367
|
+
icon: t4,
|
|
368
|
+
onClick: onClose,
|
|
369
|
+
label: "Close"
|
|
370
|
+
}];
|
|
371
|
+
$[9] = onClose;
|
|
372
|
+
$[10] = t5;
|
|
373
|
+
} else t5 = $[10];
|
|
374
|
+
let t6;
|
|
375
|
+
if ($[11] !== onClose || $[12] !== t3 || $[13] !== t5) {
|
|
376
|
+
t6 = /* @__PURE__ */ jsx(Sidebar, {
|
|
377
|
+
onClose,
|
|
378
|
+
title: "State Details",
|
|
379
|
+
initialWidth: 500,
|
|
380
|
+
tabs: t3,
|
|
381
|
+
actions: t5
|
|
382
|
+
});
|
|
383
|
+
$[11] = onClose;
|
|
384
|
+
$[12] = t3;
|
|
385
|
+
$[13] = t5;
|
|
386
|
+
$[14] = t6;
|
|
387
|
+
} else t6 = $[14];
|
|
388
|
+
return t6;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region src/components/states-page.tsx
|
|
393
|
+
const StatesPage = () => {
|
|
394
|
+
const $ = c(71);
|
|
395
|
+
if ($[0] !== "8ce039bfe0442ab4fc42929a358dacc664184bfe41f3767f703d231a71f688eb") {
|
|
396
|
+
for (let $i = 0; $i < 71; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
397
|
+
$[0] = "8ce039bfe0442ab4fc42929a358dacc664184bfe41f3767f703d231a71f688eb";
|
|
398
|
+
}
|
|
399
|
+
const selectedStateId = useStatesStore(_temp);
|
|
400
|
+
const selectStateId = useStatesStore(_temp2);
|
|
401
|
+
const { items, deleteItems, refetch } = useGetStateItems();
|
|
402
|
+
const [search, setSearch] = useState("");
|
|
403
|
+
let t0;
|
|
404
|
+
if ($[1] !== items || $[2] !== search) {
|
|
405
|
+
let t1$1;
|
|
406
|
+
if ($[4] !== search) {
|
|
407
|
+
t1$1 = (item) => item.groupId.toLowerCase().includes(search.toLowerCase()) || item.key.toLowerCase().includes(search.toLowerCase());
|
|
408
|
+
$[4] = search;
|
|
409
|
+
$[5] = t1$1;
|
|
410
|
+
} else t1$1 = $[5];
|
|
411
|
+
t0 = items.filter(t1$1);
|
|
412
|
+
$[1] = items;
|
|
413
|
+
$[2] = search;
|
|
414
|
+
$[3] = t0;
|
|
415
|
+
} else t0 = $[3];
|
|
416
|
+
const filteredItems = t0;
|
|
417
|
+
let t1;
|
|
418
|
+
if ($[6] !== filteredItems || $[7] !== selectedStateId) {
|
|
419
|
+
t1 = selectedStateId ? filteredItems.find((item_0) => `${item_0.groupId}:${item_0.key}` === selectedStateId) : null;
|
|
420
|
+
$[6] = filteredItems;
|
|
421
|
+
$[7] = selectedStateId;
|
|
422
|
+
$[8] = t1;
|
|
423
|
+
} else t1 = $[8];
|
|
424
|
+
const selectedItem = t1;
|
|
425
|
+
let t2;
|
|
426
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
427
|
+
t2 = /* @__PURE__ */ new Set();
|
|
428
|
+
$[9] = t2;
|
|
429
|
+
} else t2 = $[9];
|
|
430
|
+
const [checkedItems, setCheckedItems] = useState(t2);
|
|
431
|
+
let t3;
|
|
432
|
+
if ($[10] !== selectStateId) {
|
|
433
|
+
t3 = (item_1) => selectStateId(`${item_1.groupId}:${item_1.key}`);
|
|
434
|
+
$[10] = selectStateId;
|
|
435
|
+
$[11] = t3;
|
|
436
|
+
} else t3 = $[11];
|
|
437
|
+
const handleRowClick = t3;
|
|
438
|
+
let t4;
|
|
439
|
+
if ($[12] !== selectStateId) {
|
|
440
|
+
t4 = () => selectStateId(void 0);
|
|
441
|
+
$[12] = selectStateId;
|
|
442
|
+
$[13] = t4;
|
|
443
|
+
} else t4 = $[13];
|
|
444
|
+
const onClose = t4;
|
|
445
|
+
let t5;
|
|
446
|
+
if ($[14] !== checkedItems || $[15] !== deleteItems) {
|
|
447
|
+
t5 = () => {
|
|
448
|
+
deleteItems(Array.from(checkedItems));
|
|
449
|
+
setCheckedItems(/* @__PURE__ */ new Set());
|
|
450
|
+
};
|
|
451
|
+
$[14] = checkedItems;
|
|
452
|
+
$[15] = deleteItems;
|
|
453
|
+
$[16] = t5;
|
|
454
|
+
} else t5 = $[16];
|
|
455
|
+
const deleteStates = t5;
|
|
456
|
+
let t6;
|
|
457
|
+
if ($[17] !== checkedItems) {
|
|
458
|
+
t6 = (item_2) => {
|
|
459
|
+
const isChecked = checkedItems.has(`${item_2.groupId}:${item_2.key}`);
|
|
460
|
+
setCheckedItems((prev) => {
|
|
461
|
+
const newSet = new Set(prev);
|
|
462
|
+
if (isChecked) newSet.delete(`${item_2.groupId}:${item_2.key}`);
|
|
463
|
+
else newSet.add(`${item_2.groupId}:${item_2.key}`);
|
|
464
|
+
return newSet;
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
$[17] = checkedItems;
|
|
468
|
+
$[18] = t6;
|
|
469
|
+
} else t6 = $[18];
|
|
470
|
+
const handleCheckboxChange = t6;
|
|
471
|
+
let t7;
|
|
472
|
+
if ($[19] !== filteredItems) {
|
|
473
|
+
t7 = (checked) => {
|
|
474
|
+
setCheckedItems((prev_0) => {
|
|
475
|
+
const newSet_0 = new Set(prev_0);
|
|
476
|
+
if (checked) filteredItems.forEach((item_3) => {
|
|
477
|
+
newSet_0.add(`${item_3.groupId}:${item_3.key}`);
|
|
478
|
+
});
|
|
479
|
+
else filteredItems.forEach((item_4) => {
|
|
480
|
+
newSet_0.delete(`${item_4.groupId}:${item_4.key}`);
|
|
481
|
+
});
|
|
482
|
+
return newSet_0;
|
|
483
|
+
});
|
|
484
|
+
};
|
|
485
|
+
$[19] = filteredItems;
|
|
486
|
+
$[20] = t7;
|
|
487
|
+
} else t7 = $[20];
|
|
488
|
+
const toggleSelectAll = t7;
|
|
489
|
+
let t8;
|
|
490
|
+
if ($[21] !== onClose || $[22] !== selectedItem) {
|
|
491
|
+
t8 = selectedItem && /* @__PURE__ */ jsx(StateSidebar, {
|
|
492
|
+
state: selectedItem,
|
|
493
|
+
onClose
|
|
494
|
+
});
|
|
495
|
+
$[21] = onClose;
|
|
496
|
+
$[22] = selectedItem;
|
|
497
|
+
$[23] = t8;
|
|
498
|
+
} else t8 = $[23];
|
|
499
|
+
let t9;
|
|
500
|
+
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
501
|
+
t9 = (e) => setSearch(e.target.value);
|
|
502
|
+
$[24] = t9;
|
|
503
|
+
} else t9 = $[24];
|
|
504
|
+
let t10;
|
|
505
|
+
if ($[25] !== search) {
|
|
506
|
+
t10 = /* @__PURE__ */ jsx(Input, {
|
|
507
|
+
variant: "shade",
|
|
508
|
+
value: search,
|
|
509
|
+
onChange: t9,
|
|
510
|
+
className: "px-9! font-medium",
|
|
511
|
+
placeholder: "Search by Group ID or Key"
|
|
512
|
+
});
|
|
513
|
+
$[25] = search;
|
|
514
|
+
$[26] = t10;
|
|
515
|
+
} else t10 = $[26];
|
|
516
|
+
let t11;
|
|
517
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
518
|
+
t11 = /* @__PURE__ */ jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50" });
|
|
519
|
+
$[27] = t11;
|
|
520
|
+
} else t11 = $[27];
|
|
521
|
+
let t12;
|
|
522
|
+
if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
|
|
523
|
+
t12 = /* @__PURE__ */ jsx(X, {
|
|
524
|
+
className: "cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 hover:text-muted-foreground",
|
|
525
|
+
onClick: () => setSearch("")
|
|
526
|
+
});
|
|
527
|
+
$[28] = t12;
|
|
528
|
+
} else t12 = $[28];
|
|
529
|
+
let t13;
|
|
530
|
+
if ($[29] !== t10) {
|
|
531
|
+
t13 = /* @__PURE__ */ jsxs("div", {
|
|
532
|
+
className: "flex-1 relative",
|
|
533
|
+
children: [
|
|
534
|
+
t10,
|
|
535
|
+
t11,
|
|
536
|
+
t12
|
|
537
|
+
]
|
|
538
|
+
});
|
|
539
|
+
$[29] = t10;
|
|
540
|
+
$[30] = t13;
|
|
541
|
+
} else t13 = $[30];
|
|
542
|
+
const t14 = checkedItems.size === 0;
|
|
543
|
+
let t15;
|
|
544
|
+
if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
|
|
545
|
+
t15 = /* @__PURE__ */ jsx(Trash, {});
|
|
546
|
+
$[31] = t15;
|
|
547
|
+
} else t15 = $[31];
|
|
548
|
+
let t16;
|
|
549
|
+
if ($[32] !== deleteStates || $[33] !== t14) {
|
|
550
|
+
t16 = /* @__PURE__ */ jsxs(Button, {
|
|
551
|
+
variant: "default",
|
|
552
|
+
className: "h-[34px]",
|
|
553
|
+
disabled: t14,
|
|
554
|
+
onClick: deleteStates,
|
|
555
|
+
children: [t15, " Delete"]
|
|
556
|
+
});
|
|
557
|
+
$[32] = deleteStates;
|
|
558
|
+
$[33] = t14;
|
|
559
|
+
$[34] = t16;
|
|
560
|
+
} else t16 = $[34];
|
|
561
|
+
let t17;
|
|
562
|
+
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
|
|
563
|
+
t17 = /* @__PURE__ */ jsx(RefreshCw, { className: "w-4 h-4 text-muted-foreground" });
|
|
564
|
+
$[35] = t17;
|
|
565
|
+
} else t17 = $[35];
|
|
566
|
+
let t18;
|
|
567
|
+
if ($[36] !== refetch) {
|
|
568
|
+
t18 = /* @__PURE__ */ jsx(Button, {
|
|
569
|
+
variant: "default",
|
|
570
|
+
className: "h-[34px]",
|
|
571
|
+
onClick: refetch,
|
|
572
|
+
children: t17
|
|
573
|
+
});
|
|
574
|
+
$[36] = refetch;
|
|
575
|
+
$[37] = t18;
|
|
576
|
+
} else t18 = $[37];
|
|
577
|
+
let t19;
|
|
578
|
+
if ($[38] !== t13 || $[39] !== t16 || $[40] !== t18) {
|
|
579
|
+
t19 = /* @__PURE__ */ jsxs("div", {
|
|
580
|
+
className: "flex p-2 border-b gap-2",
|
|
581
|
+
"data-testid": "logs-search-container",
|
|
582
|
+
children: [
|
|
583
|
+
t13,
|
|
584
|
+
t16,
|
|
585
|
+
t18
|
|
586
|
+
]
|
|
587
|
+
});
|
|
588
|
+
$[38] = t13;
|
|
589
|
+
$[39] = t16;
|
|
590
|
+
$[40] = t18;
|
|
591
|
+
$[41] = t19;
|
|
592
|
+
} else t19 = $[41];
|
|
593
|
+
let t20;
|
|
594
|
+
if ($[42] !== toggleSelectAll) {
|
|
595
|
+
t20 = /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
596
|
+
onClick: _temp3,
|
|
597
|
+
onCheckedChange: toggleSelectAll
|
|
598
|
+
}) });
|
|
599
|
+
$[42] = toggleSelectAll;
|
|
600
|
+
$[43] = t20;
|
|
601
|
+
} else t20 = $[43];
|
|
602
|
+
let t21;
|
|
603
|
+
let t22;
|
|
604
|
+
let t23;
|
|
605
|
+
if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
|
|
606
|
+
t21 = /* @__PURE__ */ jsx(TableHead, {
|
|
607
|
+
className: "rounded-0",
|
|
608
|
+
children: "Group ID"
|
|
609
|
+
});
|
|
610
|
+
t22 = /* @__PURE__ */ jsx(TableHead, { children: "Key" });
|
|
611
|
+
t23 = /* @__PURE__ */ jsx(TableHead, { children: "Type" });
|
|
612
|
+
$[44] = t21;
|
|
613
|
+
$[45] = t22;
|
|
614
|
+
$[46] = t23;
|
|
615
|
+
} else {
|
|
616
|
+
t21 = $[44];
|
|
617
|
+
t22 = $[45];
|
|
618
|
+
t23 = $[46];
|
|
619
|
+
}
|
|
620
|
+
let t24;
|
|
621
|
+
if ($[47] !== t20) {
|
|
622
|
+
t24 = /* @__PURE__ */ jsx(TableHeader, {
|
|
623
|
+
className: "sticky top-0 bg-background/20 backdrop-blur-sm",
|
|
624
|
+
children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
625
|
+
t20,
|
|
626
|
+
t21,
|
|
627
|
+
t22,
|
|
628
|
+
t23
|
|
629
|
+
] })
|
|
630
|
+
});
|
|
631
|
+
$[47] = t20;
|
|
632
|
+
$[48] = t24;
|
|
633
|
+
} else t24 = $[48];
|
|
634
|
+
let t25;
|
|
635
|
+
if ($[49] !== checkedItems || $[50] !== filteredItems || $[51] !== handleCheckboxChange || $[52] !== handleRowClick || $[53] !== selectedItem) {
|
|
636
|
+
let t26$1;
|
|
637
|
+
if ($[55] !== checkedItems || $[56] !== handleCheckboxChange || $[57] !== handleRowClick || $[58] !== selectedItem) {
|
|
638
|
+
t26$1 = (item_5) => /* @__PURE__ */ jsxs(TableRow, {
|
|
639
|
+
"data-testid": `item-${item_5}`,
|
|
640
|
+
onClick: () => handleRowClick(item_5),
|
|
641
|
+
className: cn("font-mono font-semibold cursor-pointer border-0", selectedItem === item_5 ? "bg-muted-foreground/10 hover:bg-muted-foreground/20" : "hover:bg-muted-foreground/10"),
|
|
642
|
+
children: [
|
|
643
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
644
|
+
onClick: _temp4,
|
|
645
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
646
|
+
checked: checkedItems.has(`${item_5.groupId}:${item_5.key}`),
|
|
647
|
+
onClick: () => handleCheckboxChange(item_5)
|
|
648
|
+
})
|
|
649
|
+
}),
|
|
650
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
651
|
+
className: "hover:bg-transparent",
|
|
652
|
+
children: item_5.groupId
|
|
653
|
+
}),
|
|
654
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
655
|
+
className: "hover:bg-transparent",
|
|
656
|
+
children: item_5.key
|
|
657
|
+
}),
|
|
658
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
659
|
+
className: "hover:bg-transparent",
|
|
660
|
+
children: item_5.type
|
|
661
|
+
})
|
|
662
|
+
]
|
|
663
|
+
}, `${item_5.groupId}:${item_5.key}`);
|
|
664
|
+
$[55] = checkedItems;
|
|
665
|
+
$[56] = handleCheckboxChange;
|
|
666
|
+
$[57] = handleRowClick;
|
|
667
|
+
$[58] = selectedItem;
|
|
668
|
+
$[59] = t26$1;
|
|
669
|
+
} else t26$1 = $[59];
|
|
670
|
+
t25 = filteredItems.map(t26$1);
|
|
671
|
+
$[49] = checkedItems;
|
|
672
|
+
$[50] = filteredItems;
|
|
673
|
+
$[51] = handleCheckboxChange;
|
|
674
|
+
$[52] = handleRowClick;
|
|
675
|
+
$[53] = selectedItem;
|
|
676
|
+
$[54] = t25;
|
|
677
|
+
} else t25 = $[54];
|
|
678
|
+
let t26;
|
|
679
|
+
if ($[60] !== t25) {
|
|
680
|
+
t26 = /* @__PURE__ */ jsx(TableBody, { children: t25 });
|
|
681
|
+
$[60] = t25;
|
|
682
|
+
$[61] = t26;
|
|
683
|
+
} else t26 = $[61];
|
|
684
|
+
let t27;
|
|
685
|
+
if ($[62] !== t24 || $[63] !== t26) {
|
|
686
|
+
t27 = /* @__PURE__ */ jsxs(Table, { children: [t24, t26] });
|
|
687
|
+
$[62] = t24;
|
|
688
|
+
$[63] = t26;
|
|
689
|
+
$[64] = t27;
|
|
690
|
+
} else t27 = $[64];
|
|
691
|
+
let t28;
|
|
692
|
+
if ($[65] !== t19 || $[66] !== t27) {
|
|
693
|
+
t28 = /* @__PURE__ */ jsxs("div", {
|
|
694
|
+
className: "grid grid-rows-[auto_1fr] h-full",
|
|
695
|
+
"data-testid": "states-container",
|
|
696
|
+
children: [t19, t27]
|
|
697
|
+
});
|
|
698
|
+
$[65] = t19;
|
|
699
|
+
$[66] = t27;
|
|
700
|
+
$[67] = t28;
|
|
701
|
+
} else t28 = $[67];
|
|
702
|
+
let t29;
|
|
703
|
+
if ($[68] !== t28 || $[69] !== t8) {
|
|
704
|
+
t29 = /* @__PURE__ */ jsxs(Fragment, { children: [t8, t28] });
|
|
705
|
+
$[68] = t28;
|
|
706
|
+
$[69] = t8;
|
|
707
|
+
$[70] = t29;
|
|
708
|
+
} else t29 = $[70];
|
|
709
|
+
return t29;
|
|
710
|
+
};
|
|
711
|
+
function _temp(state) {
|
|
712
|
+
return state.selectedStateId;
|
|
713
|
+
}
|
|
714
|
+
function _temp2(state_0) {
|
|
715
|
+
return state_0.selectStateId;
|
|
716
|
+
}
|
|
717
|
+
function _temp3(evt) {
|
|
718
|
+
return evt.stopPropagation();
|
|
719
|
+
}
|
|
720
|
+
function _temp4(evt_0) {
|
|
721
|
+
return evt_0.stopPropagation();
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
//#endregion
|
|
725
|
+
export { StatesPage };
|
|
726
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motiadev/plugin-states",
|
|
3
|
-
"version": "0.14.0-beta.165-
|
|
3
|
+
"version": "0.14.0-beta.165-210612",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"zustand": "^5.0.8"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@motiadev/core": "0.14.0-beta.165-
|
|
24
|
-
"@motiadev/ui": "0.14.0-beta.165-
|
|
23
|
+
"@motiadev/core": "0.14.0-beta.165-210612",
|
|
24
|
+
"@motiadev/ui": "0.14.0-beta.165-210612"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@bosh-code/tsdown-plugin-inject-css": "^2.0.0",
|