camox 0.18.2 → 0.19.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.
@@ -1,5 +1,6 @@
1
1
  import { useProjectSlug } from "../../lib/auth.js";
2
2
  import { fileMutations, fileQueries, projectQueries } from "../../lib/queries.js";
3
+ import { checkIfInputFocused } from "../../lib/utils.js";
3
4
  import { UploadDropZone } from "./components/UploadDropZone.js";
4
5
  import { UploadProgressDrawer } from "./components/UploadProgressDrawer.js";
5
6
  import { useFileUpload } from "../../hooks/use-file-upload.js";
@@ -10,7 +11,7 @@ import { AssetCardSkeleton } from "./components/AssetCardSkeleton.js";
10
11
  import { ContentSidebar } from "./components/ContentSidebar.js";
11
12
  import { c } from "react/compiler-runtime";
12
13
  import { useMutation, useQuery } from "@tanstack/react-query";
13
- import { useRef, useState } from "react";
14
+ import { useEffect, useRef, useState } from "react";
14
15
  import { jsx, jsxs } from "react/jsx-runtime";
15
16
  import { Button } from "@camox/ui/button";
16
17
  import { PanelContent } from "@camox/ui/panel";
@@ -18,10 +19,10 @@ import { FloatingToolbar } from "@camox/ui/floating-toolbar";
18
19
 
19
20
  //#region src/features/content/CamoxContent.tsx
20
21
  const CamoxContent = () => {
21
- const $ = c(50);
22
- if ($[0] !== "555aaa7d0dfb9d48290ff084e4bccb6f79b8d215cf4511a7189c87640abf6593") {
23
- for (let $i = 0; $i < 50; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
24
- $[0] = "555aaa7d0dfb9d48290ff084e4bccb6f79b8d215cf4511a7189c87640abf6593";
22
+ const $ = c(53);
23
+ if ($[0] !== "41ba2e77784594f1ce07296c7a619951f1b5765164f78c588070f4799d74d906") {
24
+ for (let $i = 0; $i < 53; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
25
+ $[0] = "41ba2e77784594f1ce07296c7a619951f1b5765164f78c588070f4799d74d906";
25
26
  }
26
27
  const projectSlug = useProjectSlug();
27
28
  let t0;
@@ -80,54 +81,76 @@ const CamoxContent = () => {
80
81
  $[12] = t8;
81
82
  } else t8 = $[12];
82
83
  const { selectionRect, didDragRef, handlers } = useMarqueeSelection(containerRef, t8);
83
- let t9;
84
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
85
- t9 = /* @__PURE__ */ jsx(ContentSidebar, {});
86
- $[13] = t9;
87
- } else t9 = $[13];
88
84
  let t10;
89
- if ($[14] !== didDragRef) {
90
- t10 = () => {
85
+ let t9;
86
+ if ($[13] !== lightboxFileId) {
87
+ t9 = () => {
88
+ const handleKeyDown = (event) => {
89
+ if (event.key !== "Escape") return;
90
+ if (lightboxFileId !== null) return;
91
+ if (checkIfInputFocused()) return;
92
+ setSelectedIds(_temp);
93
+ };
94
+ document.addEventListener("keydown", handleKeyDown);
95
+ return () => document.removeEventListener("keydown", handleKeyDown);
96
+ };
97
+ t10 = [lightboxFileId];
98
+ $[13] = lightboxFileId;
99
+ $[14] = t10;
100
+ $[15] = t9;
101
+ } else {
102
+ t10 = $[14];
103
+ t9 = $[15];
104
+ }
105
+ useEffect(t9, t10);
106
+ let t11;
107
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
108
+ t11 = /* @__PURE__ */ jsx(ContentSidebar, {});
109
+ $[16] = t11;
110
+ } else t11 = $[16];
111
+ let t12;
112
+ if ($[17] !== didDragRef) {
113
+ t12 = () => {
91
114
  if (didDragRef.current) {
92
115
  didDragRef.current = false;
93
116
  return;
94
117
  }
95
118
  setSelectedIds(/* @__PURE__ */ new Set());
96
119
  };
97
- $[14] = didDragRef;
98
- $[15] = t10;
99
- } else t10 = $[15];
100
- let t11;
101
- if ($[16] !== files) {
102
- t11 = files === void 0 && /* @__PURE__ */ jsx("div", {
120
+ $[17] = didDragRef;
121
+ $[18] = t12;
122
+ } else t12 = $[18];
123
+ let t13;
124
+ if ($[19] !== files) {
125
+ t13 = files === void 0 && /* @__PURE__ */ jsx("div", {
103
126
  className: "grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-4",
104
- children: Array.from({ length: 12 }, _temp)
127
+ children: Array.from({ length: 12 }, _temp2)
105
128
  });
106
- $[16] = files;
107
- $[17] = t11;
108
- } else t11 = $[17];
109
- let t12;
110
- if ($[18] !== files?.length) {
111
- t12 = files?.length === 0 && /* @__PURE__ */ jsx("div", {
129
+ $[19] = files;
130
+ $[20] = t13;
131
+ } else t13 = $[20];
132
+ let t14;
133
+ if ($[21] !== files?.length) {
134
+ t14 = files?.length === 0 && /* @__PURE__ */ jsx("div", {
112
135
  className: "flex h-full flex-1 items-center justify-center",
113
136
  children: /* @__PURE__ */ jsx("p", {
114
137
  className: "text-muted-foreground",
115
138
  children: "No assets yet"
116
139
  })
117
140
  });
118
- $[18] = files?.length;
119
- $[19] = t12;
120
- } else t12 = $[19];
121
- let t13;
122
- if ($[20] !== files || $[21] !== selectedIds) {
123
- t13 = files && files.length > 0 && /* @__PURE__ */ jsx("div", {
141
+ $[21] = files?.length;
142
+ $[22] = t14;
143
+ } else t14 = $[22];
144
+ let t15;
145
+ if ($[23] !== files || $[24] !== selectedIds) {
146
+ t15 = files && files.length > 0 && /* @__PURE__ */ jsx("div", {
124
147
  className: "grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-4",
125
148
  children: files.map((file) => /* @__PURE__ */ jsx(AssetCard, {
126
149
  file,
127
150
  selected: selectedIds.has(String(file.id)),
128
151
  onSelect: () => {
129
- setSelectedIds((prev) => {
130
- const next = new Set(prev);
152
+ setSelectedIds((prev_0) => {
153
+ const next = new Set(prev_0);
131
154
  if (next.has(String(file.id))) next.delete(String(file.id));
132
155
  else next.add(String(file.id));
133
156
  return next;
@@ -136,13 +159,13 @@ const CamoxContent = () => {
136
159
  onOpen: () => setLightboxFileId(file.id)
137
160
  }, file.id))
138
161
  });
139
- $[20] = files;
140
- $[21] = selectedIds;
141
- $[22] = t13;
142
- } else t13 = $[22];
143
- let t14;
144
- if ($[23] !== selectionRect) {
145
- t14 = selectionRect && /* @__PURE__ */ jsx("div", {
162
+ $[23] = files;
163
+ $[24] = selectedIds;
164
+ $[25] = t15;
165
+ } else t15 = $[25];
166
+ let t16;
167
+ if ($[26] !== selectionRect) {
168
+ t16 = selectionRect && /* @__PURE__ */ jsx("div", {
146
169
  className: "border-primary bg-primary/10 pointer-events-none absolute z-50 border",
147
170
  style: {
148
171
  left: selectionRect.left,
@@ -151,62 +174,62 @@ const CamoxContent = () => {
151
174
  height: selectionRect.height
152
175
  }
153
176
  });
154
- $[23] = selectionRect;
155
- $[24] = t14;
156
- } else t14 = $[24];
157
- let t15;
158
- if ($[25] !== handlers.onPointerDown || $[26] !== handlers.onPointerMove || $[27] !== handlers.onPointerUp || $[28] !== t10 || $[29] !== t11 || $[30] !== t12 || $[31] !== t13 || $[32] !== t14) {
159
- t15 = /* @__PURE__ */ jsxs(PanelContent, {
177
+ $[26] = selectionRect;
178
+ $[27] = t16;
179
+ } else t16 = $[27];
180
+ let t17;
181
+ if ($[28] !== handlers.onPointerDown || $[29] !== handlers.onPointerMove || $[30] !== handlers.onPointerUp || $[31] !== t12 || $[32] !== t13 || $[33] !== t14 || $[34] !== t15 || $[35] !== t16) {
182
+ t17 = /* @__PURE__ */ jsxs(PanelContent, {
160
183
  ref: containerRef,
161
184
  className: "relative p-4 select-none",
162
- onClick: t10,
185
+ onClick: t12,
163
186
  onPointerDown: handlers.onPointerDown,
164
187
  onPointerMove: handlers.onPointerMove,
165
188
  onPointerUp: handlers.onPointerUp,
166
189
  children: [
167
- t11,
168
- t12,
169
190
  t13,
170
- t14
191
+ t14,
192
+ t15,
193
+ t16
171
194
  ]
172
195
  });
173
- $[25] = handlers.onPointerDown;
174
- $[26] = handlers.onPointerMove;
175
- $[27] = handlers.onPointerUp;
176
- $[28] = t10;
177
- $[29] = t11;
178
- $[30] = t12;
179
- $[31] = t13;
180
- $[32] = t14;
181
- $[33] = t15;
182
- } else t15 = $[33];
183
- let t16;
184
- if ($[34] !== t15 || $[35] !== uploadFiles) {
185
- t16 = /* @__PURE__ */ jsx("div", {
186
- className: "flex min-w-0 flex-1 flex-col",
196
+ $[28] = handlers.onPointerDown;
197
+ $[29] = handlers.onPointerMove;
198
+ $[30] = handlers.onPointerUp;
199
+ $[31] = t12;
200
+ $[32] = t13;
201
+ $[33] = t14;
202
+ $[34] = t15;
203
+ $[35] = t16;
204
+ $[36] = t17;
205
+ } else t17 = $[36];
206
+ let t18;
207
+ if ($[37] !== t17 || $[38] !== uploadFiles) {
208
+ t18 = /* @__PURE__ */ jsx("div", {
209
+ className: "flex min-h-0 min-w-0 flex-1 flex-col",
187
210
  children: /* @__PURE__ */ jsx(UploadDropZone, {
188
211
  onDrop: uploadFiles,
189
- className: "flex flex-1 flex-col",
190
- children: t15
212
+ className: "flex min-h-0 flex-1 flex-col",
213
+ children: t17
191
214
  })
192
215
  });
193
- $[34] = t15;
194
- $[35] = uploadFiles;
195
- $[36] = t16;
196
- } else t16 = $[36];
197
- let t17;
198
- if ($[37] !== clearAll || $[38] !== uploads) {
199
- t17 = /* @__PURE__ */ jsx(UploadProgressDrawer, {
216
+ $[37] = t17;
217
+ $[38] = uploadFiles;
218
+ $[39] = t18;
219
+ } else t18 = $[39];
220
+ let t19;
221
+ if ($[40] !== clearAll || $[41] !== uploads) {
222
+ t19 = /* @__PURE__ */ jsx(UploadProgressDrawer, {
200
223
  uploads,
201
224
  onClose: clearAll
202
225
  });
203
- $[37] = clearAll;
204
- $[38] = uploads;
205
- $[39] = t17;
206
- } else t17 = $[39];
207
- let t18;
208
- if ($[40] !== deleteFiles || $[41] !== selectedIds) {
209
- t18 = selectedIds.size > 0 && /* @__PURE__ */ jsxs(FloatingToolbar, {
226
+ $[40] = clearAll;
227
+ $[41] = uploads;
228
+ $[42] = t19;
229
+ } else t19 = $[42];
230
+ let t20;
231
+ if ($[43] !== deleteFiles || $[44] !== selectedIds) {
232
+ t20 = selectedIds.size > 0 && /* @__PURE__ */ jsxs(FloatingToolbar, {
210
233
  className: "bottom-4 min-w-xs justify-between gap-4 pl-3",
211
234
  children: [/* @__PURE__ */ jsxs("span", {
212
235
  className: "text-muted-foreground",
@@ -226,43 +249,46 @@ const CamoxContent = () => {
226
249
  children: deleteFiles.isPending ? "Deleting…" : "Delete"
227
250
  })]
228
251
  });
229
- $[40] = deleteFiles;
230
- $[41] = selectedIds;
231
- $[42] = t18;
232
- } else t18 = $[42];
233
- let t19;
234
- if ($[43] !== lightboxFileId) {
235
- t19 = lightboxFileId && /* @__PURE__ */ jsx(AssetLightbox, {
252
+ $[43] = deleteFiles;
253
+ $[44] = selectedIds;
254
+ $[45] = t20;
255
+ } else t20 = $[45];
256
+ let t21;
257
+ if ($[46] !== lightboxFileId) {
258
+ t21 = lightboxFileId && /* @__PURE__ */ jsx(AssetLightbox, {
236
259
  open: true,
237
260
  onOpenChange: (open) => {
238
261
  if (!open) setLightboxFileId(null);
239
262
  },
240
263
  fileId: lightboxFileId
241
264
  });
242
- $[43] = lightboxFileId;
243
- $[44] = t19;
244
- } else t19 = $[44];
245
- let t20;
246
- if ($[45] !== t16 || $[46] !== t17 || $[47] !== t18 || $[48] !== t19) {
247
- t20 = /* @__PURE__ */ jsxs("div", {
265
+ $[46] = lightboxFileId;
266
+ $[47] = t21;
267
+ } else t21 = $[47];
268
+ let t22;
269
+ if ($[48] !== t18 || $[49] !== t19 || $[50] !== t20 || $[51] !== t21) {
270
+ t22 = /* @__PURE__ */ jsxs("div", {
248
271
  className: "flex flex-1 flex-row",
249
272
  children: [
250
- t9,
251
- t16,
252
- t17,
273
+ t11,
253
274
  t18,
254
- t19
275
+ t19,
276
+ t20,
277
+ t21
255
278
  ]
256
279
  });
257
- $[45] = t16;
258
- $[46] = t17;
259
- $[47] = t18;
260
- $[48] = t19;
261
- $[49] = t20;
262
- } else t20 = $[49];
263
- return t20;
280
+ $[48] = t18;
281
+ $[49] = t19;
282
+ $[50] = t20;
283
+ $[51] = t21;
284
+ $[52] = t22;
285
+ } else t22 = $[52];
286
+ return t22;
264
287
  };
265
- function _temp(_, i) {
288
+ function _temp(prev) {
289
+ return prev.size === 0 ? prev : /* @__PURE__ */ new Set();
290
+ }
291
+ function _temp2(_, i) {
266
292
  return /* @__PURE__ */ jsx(AssetCardSkeleton, {}, i);
267
293
  }
268
294
 
@@ -1,3 +1,4 @@
1
+ import { useDebouncedField } from "../../../hooks/use-debounced-field.js";
1
2
  import { c } from "react/compiler-runtime";
2
3
  import { Input } from "@camox/ui/input";
3
4
  import { Label } from "@camox/ui/label";
@@ -7,77 +8,45 @@ import { Textarea } from "@camox/ui/textarea";
7
8
 
8
9
  //#region src/features/preview/components/DebouncedFieldEditor.tsx
9
10
  const DebouncedFieldEditor = (t0) => {
10
- const $ = c(23);
11
- if ($[0] !== "b4acdbdf8d2c83fc60b024b0d396faa1ca600b59ef52a07c5cbc6cb95d6648a6") {
12
- for (let $i = 0; $i < 23; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
13
- $[0] = "b4acdbdf8d2c83fc60b024b0d396faa1ca600b59ef52a07c5cbc6cb95d6648a6";
11
+ const $ = c(20);
12
+ if ($[0] !== "b055596bded307c924a7395888c92fcea4e52513ebc4fda5ab62fb2105997062") {
13
+ for (let $i = 0; $i < 20; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
14
+ $[0] = "b055596bded307c924a7395888c92fcea4e52513ebc4fda5ab62fb2105997062";
14
15
  }
15
16
  const { label, placeholder, initialValue, onSave, disabled, rows } = t0;
16
- const [value, setValue] = React.useState(initialValue);
17
- const timerRef = React.useRef(null);
17
+ const { value, setValue, onFocus, onBlur } = useDebouncedField(initialValue, onSave);
18
18
  const inputId = React.useId();
19
19
  let t1;
20
- let t2;
21
- if ($[1] !== initialValue) {
22
- t1 = () => {
23
- setValue(initialValue);
24
- };
25
- t2 = [initialValue];
26
- $[1] = initialValue;
27
- $[2] = t1;
28
- $[3] = t2;
29
- } else {
30
- t1 = $[2];
31
- t2 = $[3];
32
- }
33
- React.useEffect(t1, t2);
34
- let t3;
35
- if ($[4] !== disabled || $[5] !== onSave || $[6] !== rows) {
36
- t3 = (newValue) => {
20
+ if ($[1] !== disabled || $[2] !== rows || $[3] !== setValue) {
21
+ t1 = (newValue) => {
37
22
  if (disabled) return;
38
23
  if (rows) newValue = newValue.replace(/\n/g, " ");
39
24
  setValue(newValue);
40
- if (timerRef.current) clearTimeout(timerRef.current);
41
- timerRef.current = window.setTimeout(() => {
42
- onSave(newValue);
43
- }, 500);
44
- };
45
- $[4] = disabled;
46
- $[5] = onSave;
47
- $[6] = rows;
48
- $[7] = t3;
49
- } else t3 = $[7];
50
- const handleChange = t3;
51
- let t4;
52
- let t5;
53
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
54
- t4 = () => () => {
55
- if (timerRef.current) clearTimeout(timerRef.current);
56
25
  };
57
- t5 = [];
58
- $[8] = t4;
59
- $[9] = t5;
60
- } else {
61
- t4 = $[8];
62
- t5 = $[9];
63
- }
64
- React.useEffect(t4, t5);
65
- let t6;
66
- if ($[10] !== inputId || $[11] !== label) {
67
- t6 = /* @__PURE__ */ jsx(Label, {
26
+ $[1] = disabled;
27
+ $[2] = rows;
28
+ $[3] = setValue;
29
+ $[4] = t1;
30
+ } else t1 = $[4];
31
+ const handleChange = t1;
32
+ let t2;
33
+ if ($[5] !== inputId || $[6] !== label) {
34
+ t2 = /* @__PURE__ */ jsx(Label, {
68
35
  htmlFor: inputId,
69
36
  children: label
70
37
  });
71
- $[10] = inputId;
72
- $[11] = label;
73
- $[12] = t6;
74
- } else t6 = $[12];
75
- let t7;
76
- if ($[13] !== disabled || $[14] !== handleChange || $[15] !== inputId || $[16] !== placeholder || $[17] !== rows || $[18] !== value) {
77
- t7 = rows ? /* @__PURE__ */ jsx(Textarea, {
38
+ $[5] = inputId;
39
+ $[6] = label;
40
+ $[7] = t2;
41
+ } else t2 = $[7];
42
+ let t3;
43
+ if ($[8] !== disabled || $[9] !== handleChange || $[10] !== inputId || $[11] !== onBlur || $[12] !== onFocus || $[13] !== placeholder || $[14] !== rows || $[15] !== value) {
44
+ t3 = rows ? /* @__PURE__ */ jsx(Textarea, {
78
45
  id: inputId,
79
46
  value,
80
47
  onChange: (e) => handleChange(e.target.value),
48
+ onFocus,
49
+ onBlur,
81
50
  placeholder,
82
51
  disabled,
83
52
  rows,
@@ -86,28 +55,32 @@ const DebouncedFieldEditor = (t0) => {
86
55
  id: inputId,
87
56
  value,
88
57
  onChange: (e_0) => handleChange(e_0.target.value),
58
+ onFocus,
59
+ onBlur,
89
60
  placeholder,
90
61
  disabled
91
62
  });
92
- $[13] = disabled;
93
- $[14] = handleChange;
94
- $[15] = inputId;
95
- $[16] = placeholder;
96
- $[17] = rows;
97
- $[18] = value;
98
- $[19] = t7;
99
- } else t7 = $[19];
100
- let t8;
101
- if ($[20] !== t6 || $[21] !== t7) {
102
- t8 = /* @__PURE__ */ jsxs("div", {
63
+ $[8] = disabled;
64
+ $[9] = handleChange;
65
+ $[10] = inputId;
66
+ $[11] = onBlur;
67
+ $[12] = onFocus;
68
+ $[13] = placeholder;
69
+ $[14] = rows;
70
+ $[15] = value;
71
+ $[16] = t3;
72
+ } else t3 = $[16];
73
+ let t4;
74
+ if ($[17] !== t2 || $[18] !== t3) {
75
+ t4 = /* @__PURE__ */ jsxs("div", {
103
76
  className: "space-y-2",
104
- children: [t6, t7]
77
+ children: [t2, t3]
105
78
  });
106
- $[20] = t6;
107
- $[21] = t7;
108
- $[22] = t8;
109
- } else t8 = $[22];
110
- return t8;
79
+ $[17] = t2;
80
+ $[18] = t3;
81
+ $[19] = t4;
82
+ } else t4 = $[19];
83
+ return t4;
111
84
  };
112
85
 
113
86
  //#endregion