camox 0.57.0 → 0.58.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camox",
3
- "version": "0.57.0",
3
+ "version": "0.58.1",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "camox": "./bin/camox.mjs"
@@ -135,9 +135,9 @@
135
135
  "takumi-js": "^2.18.1",
136
136
  "unhead": "^3.4.3",
137
137
  "zod": "^4.6.7",
138
- "@camox/api-contract": "0.57.0",
139
- "@camox/cli": "0.57.0",
140
- "@camox/ui": "0.57.0"
138
+ "@camox/cli": "0.58.1",
139
+ "@camox/ui": "0.58.1",
140
+ "@camox/api-contract": "0.58.1"
141
141
  },
142
142
  "devDependencies": {
143
143
  "@earendil-works/pi-ai": "1.3.0",
@@ -1,206 +0,0 @@
1
- import { getDraftReadClient } from "../../../lib/api-client.js";
2
- import { reads, useStudioCache } from "../../../lib/studio-reads.js";
3
- import { c } from "react/compiler-runtime";
4
- import * as React from "react";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- import { useMutation } from "@tanstack/react-query";
7
- import { Button } from "@camox/ui/button";
8
- import { Input } from "@camox/ui/input";
9
- import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@camox/ui/dialog";
10
- import { toast } from "@camox/ui/toaster";
11
- import { Spinner } from "@camox/ui/spinner";
12
-
13
- //#region src/features/studio/components/RenameDraftDialog.tsx
14
- /**
15
- * Renames a regular draft, whichever draft the studio views: the request names the draft it
16
- * renames. A blank name clears it, so the draft shows its computed label again.
17
- */
18
- function useRenameDraft(projectId) {
19
- const $ = c(8);
20
- const studioCache = useStudioCache();
21
- let t0;
22
- if ($[0] !== projectId) {
23
- t0 = (t1) => {
24
- const { draftId, name } = t1;
25
- return getDraftReadClient(draftId).drafts.rename({
26
- projectId,
27
- name
28
- });
29
- };
30
- $[0] = projectId;
31
- $[1] = t0;
32
- } else t0 = $[1];
33
- let t1;
34
- if ($[2] !== projectId || $[3] !== studioCache) {
35
- t1 = (renamed) => {
36
- studioCache.set(reads.draft({
37
- projectId,
38
- draftId: renamed.id
39
- }), renamed);
40
- studioCache.invalidate(reads.draftList({ projectId }));
41
- };
42
- $[2] = projectId;
43
- $[3] = studioCache;
44
- $[4] = t1;
45
- } else t1 = $[4];
46
- let t2;
47
- if ($[5] !== t0 || $[6] !== t1) {
48
- t2 = {
49
- mutationFn: t0,
50
- onSuccess: t1,
51
- onError: _temp
52
- };
53
- $[5] = t0;
54
- $[6] = t1;
55
- $[7] = t2;
56
- } else t2 = $[7];
57
- return useMutation(t2);
58
- }
59
- function _temp(error) {
60
- return toast.error(error.message || "Could not rename the draft");
61
- }
62
- /** Asks for a draft's new name, starting from its current name, selected to type over. */
63
- function RenameDraftDialog(t0) {
64
- const $ = c(8);
65
- const { projectId, draft, onOpenChange } = t0;
66
- const t1 = !!draft;
67
- let t2;
68
- if ($[0] !== draft || $[1] !== onOpenChange || $[2] !== projectId) {
69
- t2 = draft && /* @__PURE__ */ jsx(RenameDraftForm, {
70
- projectId,
71
- draft,
72
- onDone: () => onOpenChange(false)
73
- }, draft.id);
74
- $[0] = draft;
75
- $[1] = onOpenChange;
76
- $[2] = projectId;
77
- $[3] = t2;
78
- } else t2 = $[3];
79
- let t3;
80
- if ($[4] !== onOpenChange || $[5] !== t1 || $[6] !== t2) {
81
- t3 = /* @__PURE__ */ jsx(Dialog, {
82
- open: t1,
83
- onOpenChange,
84
- children: t2
85
- });
86
- $[4] = onOpenChange;
87
- $[5] = t1;
88
- $[6] = t2;
89
- $[7] = t3;
90
- } else t3 = $[7];
91
- return t3;
92
- }
93
- function RenameDraftForm(t0) {
94
- const $ = c(26);
95
- const { projectId, draft, onDone } = t0;
96
- const [value, setValue] = React.useState(draft.name ?? "");
97
- const input = React.useRef(null);
98
- const rename = useRenameDraft(projectId);
99
- let t1;
100
- if ($[0] !== draft.id || $[1] !== draft.name || $[2] !== onDone || $[3] !== rename || $[4] !== value) {
101
- t1 = () => {
102
- if ((value.trim() || null) === draft.name) return onDone();
103
- rename.mutate({
104
- draftId: draft.id,
105
- name: value
106
- }, { onSuccess: onDone });
107
- };
108
- $[0] = draft.id;
109
- $[1] = draft.name;
110
- $[2] = onDone;
111
- $[3] = rename;
112
- $[4] = value;
113
- $[5] = t1;
114
- } else t1 = $[5];
115
- const submit = t1;
116
- let t2;
117
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
118
- t2 = /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Rename draft" }) });
119
- $[6] = t2;
120
- } else t2 = $[6];
121
- let t3;
122
- if ($[7] !== submit) {
123
- t3 = (event) => {
124
- event.preventDefault();
125
- submit();
126
- };
127
- $[7] = submit;
128
- $[8] = t3;
129
- } else t3 = $[8];
130
- let t4;
131
- if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
132
- t4 = (event_1) => setValue(event_1.target.value);
133
- $[9] = t4;
134
- } else t4 = $[9];
135
- let t5;
136
- if ($[10] !== value) {
137
- t5 = /* @__PURE__ */ jsx(Input, {
138
- ref: input,
139
- "aria-label": "Draft name",
140
- value,
141
- placeholder: "Name this draft (optional)",
142
- maxLength: 200,
143
- onFocus: _temp2,
144
- onChange: t4
145
- });
146
- $[10] = value;
147
- $[11] = t5;
148
- } else t5 = $[11];
149
- let t6;
150
- if ($[12] !== onDone) {
151
- t6 = /* @__PURE__ */ jsx(Button, {
152
- type: "button",
153
- variant: "outline",
154
- onClick: onDone,
155
- children: "Cancel"
156
- });
157
- $[12] = onDone;
158
- $[13] = t6;
159
- } else t6 = $[13];
160
- let t7;
161
- if ($[14] !== rename.isPending) {
162
- t7 = rename.isPending && /* @__PURE__ */ jsx(Spinner, {});
163
- $[14] = rename.isPending;
164
- $[15] = t7;
165
- } else t7 = $[15];
166
- let t8;
167
- if ($[16] !== rename.isPending || $[17] !== t7) {
168
- t8 = /* @__PURE__ */ jsxs(Button, {
169
- type: "submit",
170
- disabled: rename.isPending,
171
- children: [t7, "Rename"]
172
- });
173
- $[16] = rename.isPending;
174
- $[17] = t7;
175
- $[18] = t8;
176
- } else t8 = $[18];
177
- let t9;
178
- if ($[19] !== t6 || $[20] !== t8) {
179
- t9 = /* @__PURE__ */ jsxs(DialogFooter, { children: [t6, t8] });
180
- $[19] = t6;
181
- $[20] = t8;
182
- $[21] = t9;
183
- } else t9 = $[21];
184
- let t10;
185
- if ($[22] !== t3 || $[23] !== t5 || $[24] !== t9) {
186
- t10 = /* @__PURE__ */ jsxs(DialogContent, {
187
- initialFocus: input,
188
- children: [t2, /* @__PURE__ */ jsxs("form", {
189
- className: "grid gap-6",
190
- onSubmit: t3,
191
- children: [t5, t9]
192
- })]
193
- });
194
- $[22] = t3;
195
- $[23] = t5;
196
- $[24] = t9;
197
- $[25] = t10;
198
- } else t10 = $[25];
199
- return t10;
200
- }
201
- function _temp2(event_0) {
202
- return event_0.currentTarget.select();
203
- }
204
-
205
- //#endregion
206
- export { RenameDraftDialog, useRenameDraft };