camox 0.76.0 → 0.77.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/dist/core/editing/createEditableBlock.js +1077 -1681
- package/dist/core/editing/fieldSlot.js +251 -0
- package/dist/core/editing/useFieldSlot.js +159 -0
- package/dist/core/layoutContext.d.ts +2 -0
- package/dist/core/layoutContext.js +27 -1
- package/dist/core/lib/artifactTheme.js +43 -6
- package/dist/features/canvas/CanvasPageFrame.js +2 -2
- package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
- package/dist/features/canvas/canvasCameraController.js +595 -0
- package/dist/features/canvas/useCanvasCamera.js +141 -587
- package/dist/features/canvas/useCanvasFrame.js +1 -1
- package/dist/features/page/DerivedPageContent.js +4 -8
- package/dist/features/preview/components/AssetLightbox.js +6 -65
- package/dist/features/preview/components/CanvasPreview.js +2 -2
- package/dist/features/preview/components/Frame.js +3 -3
- package/dist/features/preview/components/ItemFieldsEditor.js +376 -460
- package/dist/features/preview/components/Overlays.js +4 -9
- package/dist/features/preview/components/PreviewPanel.js +3 -3
- package/dist/features/preview/components/RemovedBlockPlaceholder.js +2 -2
- package/dist/features/preview/components/SelectionEditor.js +285 -339
- package/dist/features/preview/components/ZoomableImage.js +105 -0
- package/dist/features/preview/components/contentFieldSchema.js +3 -1
- package/dist/features/preview/components/useFieldWriter.js +30 -51
- package/dist/features/preview/components/useRecordView.js +3 -3
- package/dist/features/preview/overlayMessages.js +20 -58
- package/dist/features/preview/previewStore.js +6 -123
- package/dist/features/preview/repeatableItemPath.js +47 -0
- package/dist/features/renderer/RendererApp.js +6 -6
- package/dist/features/renderer/RendererFrames.js +2 -2
- package/dist/features/renderer/rendererHost.js +1 -1
- package/dist/features/routes/pageRuntime.d.ts +2 -8
- package/dist/features/routes/pageRuntime.js +21 -105
- package/dist/features/runtime/pageApp.js +1 -1
- package/dist/features/runtime/pageRead.js +105 -0
- package/dist/features/runtime/reader.d.ts +25 -0
- package/dist/features/runtime/reader.js +142 -0
- package/dist/features/runtime/runtime.d.ts +9 -3
- package/dist/features/runtime/runtime.js +608 -776
- package/dist/features/sdkBundle/buildSdkBundle.d.ts +5 -0
- package/dist/features/sdkBundle/buildSdkBundle.js +9 -3
- package/dist/features/studio/components/DraftsSheet.js +124 -65
- package/dist/features/studio/components/LocalePicker.js +518 -134
- package/dist/features/studio/components/ThreadMessages.js +5 -9
- package/dist/features/studio/showInCanvas.js +9 -19
- package/dist/features/studio/useEditorSelection.js +8 -19
- package/dist/lib/locale-path.js +2 -2
- package/dist/lib/queries.js +5 -1
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/skills/camox/references/artifacts.md +7 -0
- package/dist/core/hooks/useFieldSelection.js +0 -67
- package/dist/core/hooks/useIsEditable.js +0 -21
- package/dist/core/hooks/useOverlayMessage.js +0 -70
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { localizedPath } from "../../../lib/locale-path.js";
|
|
1
|
+
import { localePrefix, localizedPath } from "../../../lib/locale-path.js";
|
|
2
2
|
import { useCurrentDraftId } from "../../../lib/draft-scope.js";
|
|
3
3
|
import { useViewLocale } from "../../../lib/view-locale-context.js";
|
|
4
4
|
import { useLocation, useNavigate } from "../../navigation/navigation.js";
|
|
@@ -19,7 +19,7 @@ import { useMutation } from "@tanstack/react-query";
|
|
|
19
19
|
import { Button } from "@camox/ui/button";
|
|
20
20
|
import { Input } from "@camox/ui/input";
|
|
21
21
|
import { Label } from "@camox/ui/label";
|
|
22
|
-
import { ChevronsUpDown, Languages, Plus, Trash2 } from "lucide-react";
|
|
22
|
+
import { ChevronsUpDown, Languages, Plus, Settings2, Trash2 } from "lucide-react";
|
|
23
23
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@camox/ui/dialog";
|
|
24
24
|
import { toast } from "@camox/ui/toaster";
|
|
25
25
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
|
|
@@ -27,18 +27,19 @@ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent,
|
|
|
27
27
|
import { Combobox } from "@base-ui/react/combobox";
|
|
28
28
|
import { Spinner } from "@camox/ui/spinner";
|
|
29
29
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@camox/ui/dropdown-menu";
|
|
30
|
+
import { Badge } from "@camox/ui/badge";
|
|
30
31
|
|
|
31
32
|
//#region src/features/studio/components/LocalePicker.tsx
|
|
32
33
|
/**
|
|
33
|
-
* The studio's languages (GLOSSARY: Locale): the one viewed, the others to switch to,
|
|
34
|
-
* and
|
|
35
|
-
* that language's home otherwise; the URL names the
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* names the language viewed.
|
|
34
|
+
* The studio's languages (GLOSSARY: Locale): the one viewed, the others to switch to, adding them,
|
|
35
|
+
* and managing them: removing one, or making it the default. Switching keeps the page shown when
|
|
36
|
+
* the other language has it, and goes to that language's home otherwise; the URL names the
|
|
37
|
+
* language by its prefix. Adding, removing and changing the default language are content writes,
|
|
38
|
+
* so on Live they start a draft. While Camox translates the draft into its languages, the picker
|
|
39
|
+
* shows a spinner, and nothing else does. A `disabled` picker still names the language viewed.
|
|
39
40
|
*/
|
|
40
41
|
function LocalePicker(t0) {
|
|
41
|
-
const $ = c(
|
|
42
|
+
const $ = c(71);
|
|
42
43
|
const { recordPage, disabled: t1 } = t0;
|
|
43
44
|
const disabled = t1 === void 0 ? false : t1;
|
|
44
45
|
const projectUuid = useProjectUuid();
|
|
@@ -81,6 +82,7 @@ function LocalePicker(t0) {
|
|
|
81
82
|
} else t8 = $[10];
|
|
82
83
|
const viewed = t8;
|
|
83
84
|
const switchTo = useSwitchLocale(recordPage);
|
|
85
|
+
const followDefault = useFollowNewDefault();
|
|
84
86
|
const draftId = useCurrentDraftId();
|
|
85
87
|
let t9;
|
|
86
88
|
if ($[11] !== draftId || $[12] !== projectId) {
|
|
@@ -231,84 +233,87 @@ function LocalePicker(t0) {
|
|
|
231
233
|
$[46] = t27;
|
|
232
234
|
$[47] = t29;
|
|
233
235
|
} else t29 = $[47];
|
|
234
|
-
|
|
235
|
-
if ($[48] !== projectId || $[49] !== viewed.isDefault || $[50] !== viewed.tag) {
|
|
236
|
-
t30 = !viewed.isDefault && /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
237
|
-
variant: "destructive",
|
|
238
|
-
disabled: !projectId,
|
|
239
|
-
onClick: _temp5,
|
|
240
|
-
children: [
|
|
241
|
-
/* @__PURE__ */ jsx(Trash2, {}),
|
|
242
|
-
"Remove ",
|
|
243
|
-
localeLabel(viewed.tag),
|
|
244
|
-
"…"
|
|
245
|
-
]
|
|
246
|
-
});
|
|
247
|
-
$[48] = projectId;
|
|
248
|
-
$[49] = viewed.isDefault;
|
|
249
|
-
$[50] = viewed.tag;
|
|
250
|
-
$[51] = t30;
|
|
251
|
-
} else t30 = $[51];
|
|
236
|
+
const t30 = !projectId;
|
|
252
237
|
let t31;
|
|
253
|
-
if ($[
|
|
254
|
-
t31 = /* @__PURE__ */
|
|
255
|
-
$[
|
|
256
|
-
|
|
257
|
-
$[54] = t31;
|
|
258
|
-
} else t31 = $[54];
|
|
238
|
+
if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
|
|
239
|
+
t31 = /* @__PURE__ */ jsx(Settings2, {});
|
|
240
|
+
$[48] = t31;
|
|
241
|
+
} else t31 = $[48];
|
|
259
242
|
let t32;
|
|
260
|
-
if ($[
|
|
261
|
-
t32 = /* @__PURE__ */ jsxs(
|
|
243
|
+
if ($[49] !== t30) {
|
|
244
|
+
t32 = /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
245
|
+
disabled: t30,
|
|
246
|
+
onClick: _temp5,
|
|
247
|
+
children: [t31, "Manage languages…"]
|
|
248
|
+
});
|
|
249
|
+
$[49] = t30;
|
|
250
|
+
$[50] = t32;
|
|
251
|
+
} else t32 = $[50];
|
|
252
|
+
let t33;
|
|
253
|
+
if ($[51] !== t29 || $[52] !== t32) {
|
|
254
|
+
t33 = /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [t29, t32] });
|
|
255
|
+
$[51] = t29;
|
|
256
|
+
$[52] = t32;
|
|
257
|
+
$[53] = t33;
|
|
258
|
+
} else t33 = $[53];
|
|
259
|
+
let t34;
|
|
260
|
+
if ($[54] !== t25 || $[55] !== t33) {
|
|
261
|
+
t34 = /* @__PURE__ */ jsxs(DropdownMenuContent, {
|
|
262
262
|
className: "w-64",
|
|
263
263
|
align: "start",
|
|
264
264
|
children: [
|
|
265
265
|
t25,
|
|
266
266
|
t26,
|
|
267
|
-
|
|
267
|
+
t33
|
|
268
268
|
]
|
|
269
269
|
});
|
|
270
|
-
$[
|
|
271
|
-
$[
|
|
272
|
-
$[
|
|
273
|
-
} else
|
|
274
|
-
let
|
|
275
|
-
if ($[
|
|
276
|
-
|
|
277
|
-
$[
|
|
278
|
-
$[
|
|
279
|
-
$[
|
|
280
|
-
} else
|
|
281
|
-
let
|
|
282
|
-
if ($[
|
|
283
|
-
|
|
270
|
+
$[54] = t25;
|
|
271
|
+
$[55] = t33;
|
|
272
|
+
$[56] = t34;
|
|
273
|
+
} else t34 = $[56];
|
|
274
|
+
let t35;
|
|
275
|
+
if ($[57] !== t19 || $[58] !== t34) {
|
|
276
|
+
t35 = /* @__PURE__ */ jsxs(DropdownMenu, { children: [t19, t34] });
|
|
277
|
+
$[57] = t19;
|
|
278
|
+
$[58] = t34;
|
|
279
|
+
$[59] = t35;
|
|
280
|
+
} else t35 = $[59];
|
|
281
|
+
let t36;
|
|
282
|
+
if ($[60] !== dialog || $[61] !== followDefault || $[62] !== locales || $[63] !== projectId || $[64] !== switchTo || $[65] !== translatingLocales.length || $[66] !== viewed) {
|
|
283
|
+
t36 = projectId && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(AddLocaleDialog, {
|
|
284
284
|
projectId,
|
|
285
285
|
locales,
|
|
286
286
|
open: dialog === "add",
|
|
287
287
|
onAdded: (added) => switchTo(added)
|
|
288
|
-
}),
|
|
288
|
+
}), /* @__PURE__ */ jsx(ManageLocalesDialog, {
|
|
289
289
|
projectId,
|
|
290
|
-
|
|
291
|
-
open: dialog === "
|
|
292
|
-
|
|
290
|
+
locales,
|
|
291
|
+
open: dialog === "manage",
|
|
292
|
+
translating: translatingLocales.length > 0,
|
|
293
|
+
onRemoved: (removed) => {
|
|
294
|
+
if (removed.tag !== viewed.tag) return;
|
|
293
295
|
const fallback = locales.find(_temp6);
|
|
294
296
|
if (fallback) switchTo(fallback);
|
|
295
|
-
}
|
|
297
|
+
},
|
|
298
|
+
onDefaultChanged: (tag_0) => followDefault(viewed, tag_0)
|
|
296
299
|
})] });
|
|
297
|
-
$[
|
|
300
|
+
$[60] = dialog;
|
|
301
|
+
$[61] = followDefault;
|
|
298
302
|
$[62] = locales;
|
|
299
303
|
$[63] = projectId;
|
|
300
304
|
$[64] = switchTo;
|
|
301
|
-
$[65] =
|
|
302
|
-
$[66] =
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
$[68] =
|
|
309
|
-
$[69] =
|
|
310
|
-
|
|
311
|
-
|
|
305
|
+
$[65] = translatingLocales.length;
|
|
306
|
+
$[66] = viewed;
|
|
307
|
+
$[67] = t36;
|
|
308
|
+
} else t36 = $[67];
|
|
309
|
+
let t37;
|
|
310
|
+
if ($[68] !== t35 || $[69] !== t36) {
|
|
311
|
+
t37 = /* @__PURE__ */ jsxs(Fragment, { children: [t35, t36] });
|
|
312
|
+
$[68] = t35;
|
|
313
|
+
$[69] = t36;
|
|
314
|
+
$[70] = t37;
|
|
315
|
+
} else t37 = $[70];
|
|
316
|
+
return t37;
|
|
312
317
|
}
|
|
313
318
|
function _temp6(locale_2) {
|
|
314
319
|
return locale_2.isDefault;
|
|
@@ -316,7 +321,7 @@ function _temp6(locale_2) {
|
|
|
316
321
|
function _temp5() {
|
|
317
322
|
return studioStore.send({
|
|
318
323
|
type: "openLocaleDialog",
|
|
319
|
-
dialog: "
|
|
324
|
+
dialog: "manage"
|
|
320
325
|
});
|
|
321
326
|
}
|
|
322
327
|
function _temp4() {
|
|
@@ -455,6 +460,40 @@ function _temp8() {
|
|
|
455
460
|
function _temp7(location) {
|
|
456
461
|
return location.search;
|
|
457
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* Keeps the studio on the language viewed once another language became the default: the new
|
|
465
|
+
* default's pages move to unprefixed paths, and the old default's under its prefix.
|
|
466
|
+
*/
|
|
467
|
+
function useFollowNewDefault() {
|
|
468
|
+
const $ = c(5);
|
|
469
|
+
const navigate = useNavigate();
|
|
470
|
+
const path = useLocalePath();
|
|
471
|
+
let t0;
|
|
472
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
473
|
+
t0 = { select: _temp10 };
|
|
474
|
+
$[0] = t0;
|
|
475
|
+
} else t0 = $[0];
|
|
476
|
+
const search = useLocation(t0);
|
|
477
|
+
let t1;
|
|
478
|
+
if ($[1] !== navigate || $[2] !== path || $[3] !== search) {
|
|
479
|
+
t1 = (viewed, tag) => {
|
|
480
|
+
const isDefault = viewed.tag === tag;
|
|
481
|
+
if (isDefault === viewed.isDefault) return;
|
|
482
|
+
navigate({ to: `${localizedPath(path, {
|
|
483
|
+
tag: viewed.tag,
|
|
484
|
+
isDefault
|
|
485
|
+
})}${search}` });
|
|
486
|
+
};
|
|
487
|
+
$[1] = navigate;
|
|
488
|
+
$[2] = path;
|
|
489
|
+
$[3] = search;
|
|
490
|
+
$[4] = t1;
|
|
491
|
+
} else t1 = $[4];
|
|
492
|
+
return t1;
|
|
493
|
+
}
|
|
494
|
+
function _temp10(location) {
|
|
495
|
+
return location.search;
|
|
496
|
+
}
|
|
458
497
|
function closeLocaleDialog() {
|
|
459
498
|
studioStore.send({ type: "closeLocaleDialog" });
|
|
460
499
|
}
|
|
@@ -487,7 +526,7 @@ function AddLocaleDialog(t0) {
|
|
|
487
526
|
cache.invalidate(reads.localeList({ projectId }));
|
|
488
527
|
onAdded(added);
|
|
489
528
|
},
|
|
490
|
-
onError:
|
|
529
|
+
onError: _temp11
|
|
491
530
|
};
|
|
492
531
|
$[3] = cache;
|
|
493
532
|
$[4] = onAdded;
|
|
@@ -555,7 +594,7 @@ function AddLocaleDialog(t0) {
|
|
|
555
594
|
})
|
|
556
595
|
}), /* @__PURE__ */ jsx(Combobox.List, {
|
|
557
596
|
className: "max-h-64 min-h-0 overflow-y-auto",
|
|
558
|
-
children:
|
|
597
|
+
children: _temp15
|
|
559
598
|
})]
|
|
560
599
|
})
|
|
561
600
|
}) });
|
|
@@ -569,9 +608,9 @@ function AddLocaleDialog(t0) {
|
|
|
569
608
|
items: options,
|
|
570
609
|
value: picked,
|
|
571
610
|
onValueChange: setPicked,
|
|
572
|
-
itemToStringLabel:
|
|
573
|
-
itemToStringValue:
|
|
574
|
-
isItemEqualToValue:
|
|
611
|
+
itemToStringLabel: _temp12,
|
|
612
|
+
itemToStringValue: _temp13,
|
|
613
|
+
isItemEqualToValue: _temp14,
|
|
575
614
|
autoHighlight: true,
|
|
576
615
|
children: [t8, t9]
|
|
577
616
|
})]
|
|
@@ -650,7 +689,7 @@ function AddLocaleDialog(t0) {
|
|
|
650
689
|
} else t17 = $[37];
|
|
651
690
|
return t17;
|
|
652
691
|
}
|
|
653
|
-
function
|
|
692
|
+
function _temp15(option_2) {
|
|
654
693
|
return /* @__PURE__ */ jsx(Combobox.Item, {
|
|
655
694
|
value: option_2,
|
|
656
695
|
className: "data-highlighted:bg-accent data-highlighted:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-none",
|
|
@@ -660,22 +699,196 @@ function _temp14(option_2) {
|
|
|
660
699
|
})
|
|
661
700
|
}, option_2.tag);
|
|
662
701
|
}
|
|
663
|
-
function
|
|
702
|
+
function _temp14(option_1, value) {
|
|
664
703
|
return option_1.tag === value.tag;
|
|
665
704
|
}
|
|
666
|
-
function
|
|
705
|
+
function _temp13(option_0) {
|
|
667
706
|
return option_0.tag;
|
|
668
707
|
}
|
|
669
|
-
function
|
|
708
|
+
function _temp12(option) {
|
|
670
709
|
return option.label;
|
|
671
710
|
}
|
|
672
|
-
function
|
|
711
|
+
function _temp11(error) {
|
|
673
712
|
return toast.error(error.message || "Could not add the language");
|
|
674
713
|
}
|
|
714
|
+
/**
|
|
715
|
+
* Lists the languages, to remove one or make it the default, each after a confirmation. Changing
|
|
716
|
+
* the default waits until Camox has translated the draft, since translations follow the default.
|
|
717
|
+
*/
|
|
718
|
+
function ManageLocalesDialog(t0) {
|
|
719
|
+
const $ = c(33);
|
|
720
|
+
const { projectId, locales, open, translating, onRemoved, onDefaultChanged } = t0;
|
|
721
|
+
const [confirming, setConfirming] = React.useState(null);
|
|
722
|
+
let t1;
|
|
723
|
+
if ($[0] !== locales) {
|
|
724
|
+
t1 = locales.find(_temp16);
|
|
725
|
+
$[0] = locales;
|
|
726
|
+
$[1] = t1;
|
|
727
|
+
} else t1 = $[1];
|
|
728
|
+
const current = t1;
|
|
729
|
+
let t2;
|
|
730
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
731
|
+
t2 = () => setConfirming(null);
|
|
732
|
+
$[2] = t2;
|
|
733
|
+
} else t2 = $[2];
|
|
734
|
+
const closeConfirmation = t2;
|
|
735
|
+
let t3;
|
|
736
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
737
|
+
t3 = /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Manage languages" }), /* @__PURE__ */ jsx(DialogDescription, { children: "Removing a language or changing the default one happens in a draft. It goes live when the draft is published." })] });
|
|
738
|
+
$[3] = t3;
|
|
739
|
+
} else t3 = $[3];
|
|
740
|
+
let t4;
|
|
741
|
+
if ($[4] !== locales || $[5] !== translating) {
|
|
742
|
+
let t5;
|
|
743
|
+
if ($[7] !== translating) {
|
|
744
|
+
t5 = (locale_0) => {
|
|
745
|
+
const label = localeLabel(locale_0.tag);
|
|
746
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
747
|
+
className: "flex min-h-11 items-center gap-2 py-1.5",
|
|
748
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
749
|
+
className: "min-w-0 flex-1 truncate text-sm",
|
|
750
|
+
children: label
|
|
751
|
+
}), locale_0.isDefault ? /* @__PURE__ */ jsx(Badge, {
|
|
752
|
+
variant: "secondary",
|
|
753
|
+
children: "Default"
|
|
754
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
|
|
755
|
+
type: "button",
|
|
756
|
+
size: "sm",
|
|
757
|
+
variant: "outline",
|
|
758
|
+
disabled: translating,
|
|
759
|
+
onClick: () => setConfirming({
|
|
760
|
+
action: "makeDefault",
|
|
761
|
+
locale: locale_0
|
|
762
|
+
}),
|
|
763
|
+
children: "Make default"
|
|
764
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
765
|
+
type: "button",
|
|
766
|
+
size: "icon-sm",
|
|
767
|
+
variant: "ghost",
|
|
768
|
+
"aria-label": `Remove ${label}`,
|
|
769
|
+
onClick: () => setConfirming({
|
|
770
|
+
action: "remove",
|
|
771
|
+
locale: locale_0
|
|
772
|
+
}),
|
|
773
|
+
children: /* @__PURE__ */ jsx(Trash2, {})
|
|
774
|
+
})] })]
|
|
775
|
+
}, locale_0.tag);
|
|
776
|
+
};
|
|
777
|
+
$[7] = translating;
|
|
778
|
+
$[8] = t5;
|
|
779
|
+
} else t5 = $[8];
|
|
780
|
+
t4 = locales.map(t5);
|
|
781
|
+
$[4] = locales;
|
|
782
|
+
$[5] = translating;
|
|
783
|
+
$[6] = t4;
|
|
784
|
+
} else t4 = $[6];
|
|
785
|
+
let t5;
|
|
786
|
+
if ($[9] !== t4) {
|
|
787
|
+
t5 = /* @__PURE__ */ jsx("ul", {
|
|
788
|
+
"aria-label": "Languages",
|
|
789
|
+
className: "flex flex-col divide-y",
|
|
790
|
+
children: t4
|
|
791
|
+
});
|
|
792
|
+
$[9] = t4;
|
|
793
|
+
$[10] = t5;
|
|
794
|
+
} else t5 = $[10];
|
|
795
|
+
let t6;
|
|
796
|
+
if ($[11] !== translating) {
|
|
797
|
+
t6 = translating && /* @__PURE__ */ jsx("p", {
|
|
798
|
+
className: "text-muted-foreground text-xs",
|
|
799
|
+
children: "Camox is translating this draft. You can change the default language once it's done."
|
|
800
|
+
});
|
|
801
|
+
$[11] = translating;
|
|
802
|
+
$[12] = t6;
|
|
803
|
+
} else t6 = $[12];
|
|
804
|
+
let t7;
|
|
805
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
806
|
+
t7 = /* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsx(Button, {
|
|
807
|
+
type: "button",
|
|
808
|
+
variant: "outline",
|
|
809
|
+
onClick: closeLocaleDialog,
|
|
810
|
+
children: "Done"
|
|
811
|
+
}) });
|
|
812
|
+
$[13] = t7;
|
|
813
|
+
} else t7 = $[13];
|
|
814
|
+
let t8;
|
|
815
|
+
if ($[14] !== t5 || $[15] !== t6) {
|
|
816
|
+
t8 = /* @__PURE__ */ jsxs(DialogContent, {
|
|
817
|
+
className: "sm:max-w-md",
|
|
818
|
+
children: [
|
|
819
|
+
t3,
|
|
820
|
+
t5,
|
|
821
|
+
t6,
|
|
822
|
+
t7
|
|
823
|
+
]
|
|
824
|
+
});
|
|
825
|
+
$[14] = t5;
|
|
826
|
+
$[15] = t6;
|
|
827
|
+
$[16] = t8;
|
|
828
|
+
} else t8 = $[16];
|
|
829
|
+
let t9;
|
|
830
|
+
if ($[17] !== open || $[18] !== t8) {
|
|
831
|
+
t9 = /* @__PURE__ */ jsx(Dialog, {
|
|
832
|
+
open,
|
|
833
|
+
onOpenChange: _temp17,
|
|
834
|
+
children: t8
|
|
835
|
+
});
|
|
836
|
+
$[17] = open;
|
|
837
|
+
$[18] = t8;
|
|
838
|
+
$[19] = t9;
|
|
839
|
+
} else t9 = $[19];
|
|
840
|
+
let t10;
|
|
841
|
+
if ($[20] !== confirming || $[21] !== onRemoved || $[22] !== projectId) {
|
|
842
|
+
t10 = confirming?.action === "remove" && /* @__PURE__ */ jsx(RemoveLocaleDialog, {
|
|
843
|
+
projectId,
|
|
844
|
+
locale: confirming.locale,
|
|
845
|
+
onClose: closeConfirmation,
|
|
846
|
+
onRemoved
|
|
847
|
+
});
|
|
848
|
+
$[20] = confirming;
|
|
849
|
+
$[21] = onRemoved;
|
|
850
|
+
$[22] = projectId;
|
|
851
|
+
$[23] = t10;
|
|
852
|
+
} else t10 = $[23];
|
|
853
|
+
let t11;
|
|
854
|
+
if ($[24] !== confirming || $[25] !== current || $[26] !== onDefaultChanged || $[27] !== projectId) {
|
|
855
|
+
t11 = confirming?.action === "makeDefault" && current && /* @__PURE__ */ jsx(MakeDefaultLocaleDialog, {
|
|
856
|
+
projectId,
|
|
857
|
+
locale: confirming.locale,
|
|
858
|
+
from: current,
|
|
859
|
+
onClose: closeConfirmation,
|
|
860
|
+
onChanged: onDefaultChanged
|
|
861
|
+
});
|
|
862
|
+
$[24] = confirming;
|
|
863
|
+
$[25] = current;
|
|
864
|
+
$[26] = onDefaultChanged;
|
|
865
|
+
$[27] = projectId;
|
|
866
|
+
$[28] = t11;
|
|
867
|
+
} else t11 = $[28];
|
|
868
|
+
let t12;
|
|
869
|
+
if ($[29] !== t10 || $[30] !== t11 || $[31] !== t9) {
|
|
870
|
+
t12 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
871
|
+
t9,
|
|
872
|
+
t10,
|
|
873
|
+
t11
|
|
874
|
+
] });
|
|
875
|
+
$[29] = t10;
|
|
876
|
+
$[30] = t11;
|
|
877
|
+
$[31] = t9;
|
|
878
|
+
$[32] = t12;
|
|
879
|
+
} else t12 = $[32];
|
|
880
|
+
return t12;
|
|
881
|
+
}
|
|
882
|
+
function _temp17(next) {
|
|
883
|
+
if (!next) closeLocaleDialog();
|
|
884
|
+
}
|
|
885
|
+
function _temp16(locale) {
|
|
886
|
+
return locale.isDefault;
|
|
887
|
+
}
|
|
675
888
|
/** Asks before removing a locale with all its content, then removes it in the draft. */
|
|
676
889
|
function RemoveLocaleDialog(t0) {
|
|
677
|
-
const $ = c(
|
|
678
|
-
const { projectId, locale,
|
|
890
|
+
const $ = c(36);
|
|
891
|
+
const { projectId, locale, onClose, onRemoved } = t0;
|
|
679
892
|
const cache = useStudioCache();
|
|
680
893
|
let t1;
|
|
681
894
|
if ($[0] !== locale.tag) {
|
|
@@ -690,34 +903,37 @@ function RemoveLocaleDialog(t0) {
|
|
|
690
903
|
$[2] = t2;
|
|
691
904
|
} else t2 = $[2];
|
|
692
905
|
let t3;
|
|
693
|
-
if ($[3] !== cache || $[4] !== label || $[5] !==
|
|
906
|
+
if ($[3] !== cache || $[4] !== label || $[5] !== locale || $[6] !== onClose || $[7] !== onRemoved || $[8] !== projectId) {
|
|
694
907
|
t3 = {
|
|
695
908
|
...t2,
|
|
696
909
|
onSuccess: () => {
|
|
697
|
-
|
|
910
|
+
onClose();
|
|
698
911
|
toast.success(`Removed ${label}`);
|
|
699
912
|
cache.invalidate(reads.localeList({ projectId }));
|
|
700
|
-
onRemoved();
|
|
913
|
+
onRemoved(locale);
|
|
701
914
|
},
|
|
702
|
-
onError:
|
|
915
|
+
onError: _temp18
|
|
703
916
|
};
|
|
704
917
|
$[3] = cache;
|
|
705
918
|
$[4] = label;
|
|
706
|
-
$[5] =
|
|
707
|
-
$[6] =
|
|
708
|
-
$[7] =
|
|
709
|
-
|
|
919
|
+
$[5] = locale;
|
|
920
|
+
$[6] = onClose;
|
|
921
|
+
$[7] = onRemoved;
|
|
922
|
+
$[8] = projectId;
|
|
923
|
+
$[9] = t3;
|
|
924
|
+
} else t3 = $[9];
|
|
710
925
|
const remove = useMutation(t3);
|
|
711
926
|
let t4;
|
|
712
|
-
if ($[
|
|
927
|
+
if ($[10] !== onClose || $[11] !== remove.isPending) {
|
|
713
928
|
t4 = (next) => {
|
|
714
|
-
if (!next && !remove.isPending)
|
|
929
|
+
if (!next && !remove.isPending) onClose();
|
|
715
930
|
};
|
|
716
|
-
$[
|
|
717
|
-
$[
|
|
718
|
-
|
|
931
|
+
$[10] = onClose;
|
|
932
|
+
$[11] = remove.isPending;
|
|
933
|
+
$[12] = t4;
|
|
934
|
+
} else t4 = $[12];
|
|
719
935
|
let t5;
|
|
720
|
-
if ($[
|
|
936
|
+
if ($[13] !== label) {
|
|
721
937
|
t5 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsxs(AlertDialogTitle, { children: [
|
|
722
938
|
"Remove ",
|
|
723
939
|
label,
|
|
@@ -727,80 +943,248 @@ function RemoveLocaleDialog(t0) {
|
|
|
727
943
|
label,
|
|
728
944
|
" are removed in this draft. Once the draft is published, its content will be gone for good."
|
|
729
945
|
] })] });
|
|
730
|
-
$[
|
|
731
|
-
$[
|
|
732
|
-
} else t5 = $[
|
|
946
|
+
$[13] = label;
|
|
947
|
+
$[14] = t5;
|
|
948
|
+
} else t5 = $[14];
|
|
733
949
|
let t6;
|
|
734
|
-
if ($[
|
|
950
|
+
if ($[15] !== remove.isPending) {
|
|
735
951
|
t6 = /* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
736
952
|
variant: "outline",
|
|
737
953
|
size: "default",
|
|
738
954
|
disabled: remove.isPending,
|
|
739
955
|
children: "Cancel"
|
|
740
956
|
});
|
|
741
|
-
$[
|
|
742
|
-
$[
|
|
743
|
-
} else t6 = $[
|
|
957
|
+
$[15] = remove.isPending;
|
|
958
|
+
$[16] = t6;
|
|
959
|
+
} else t6 = $[16];
|
|
744
960
|
let t7;
|
|
745
|
-
if ($[
|
|
961
|
+
if ($[17] !== locale.tag || $[18] !== projectId || $[19] !== remove) {
|
|
746
962
|
t7 = () => remove.mutate({
|
|
747
963
|
projectId,
|
|
748
964
|
tag: locale.tag
|
|
749
965
|
});
|
|
750
|
-
$[
|
|
751
|
-
$[
|
|
752
|
-
$[
|
|
753
|
-
$[
|
|
754
|
-
} else t7 = $[
|
|
966
|
+
$[17] = locale.tag;
|
|
967
|
+
$[18] = projectId;
|
|
968
|
+
$[19] = remove;
|
|
969
|
+
$[20] = t7;
|
|
970
|
+
} else t7 = $[20];
|
|
755
971
|
let t8;
|
|
756
|
-
if ($[
|
|
972
|
+
if ($[21] !== remove.isPending) {
|
|
757
973
|
t8 = remove.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
|
|
758
|
-
$[
|
|
759
|
-
$[
|
|
760
|
-
} else t8 = $[
|
|
974
|
+
$[21] = remove.isPending;
|
|
975
|
+
$[22] = t8;
|
|
976
|
+
} else t8 = $[22];
|
|
761
977
|
let t9;
|
|
762
|
-
if ($[
|
|
978
|
+
if ($[23] !== remove.isPending || $[24] !== t7 || $[25] !== t8) {
|
|
763
979
|
t9 = /* @__PURE__ */ jsxs(AlertDialogAction, {
|
|
764
980
|
variant: "destructive",
|
|
765
981
|
disabled: remove.isPending,
|
|
766
982
|
onClick: t7,
|
|
767
983
|
children: [t8, "Remove language"]
|
|
768
984
|
});
|
|
769
|
-
$[
|
|
770
|
-
$[
|
|
771
|
-
$[
|
|
772
|
-
$[
|
|
773
|
-
} else t9 = $[
|
|
985
|
+
$[23] = remove.isPending;
|
|
986
|
+
$[24] = t7;
|
|
987
|
+
$[25] = t8;
|
|
988
|
+
$[26] = t9;
|
|
989
|
+
} else t9 = $[26];
|
|
774
990
|
let t10;
|
|
775
|
-
if ($[
|
|
991
|
+
if ($[27] !== t6 || $[28] !== t9) {
|
|
776
992
|
t10 = /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t6, t9] });
|
|
777
|
-
$[
|
|
778
|
-
$[
|
|
779
|
-
$[
|
|
780
|
-
} else t10 = $[
|
|
993
|
+
$[27] = t6;
|
|
994
|
+
$[28] = t9;
|
|
995
|
+
$[29] = t10;
|
|
996
|
+
} else t10 = $[29];
|
|
781
997
|
let t11;
|
|
782
|
-
if ($[
|
|
998
|
+
if ($[30] !== t10 || $[31] !== t5) {
|
|
783
999
|
t11 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t5, t10] });
|
|
784
|
-
$[
|
|
785
|
-
$[
|
|
786
|
-
$[
|
|
787
|
-
} else t11 = $[
|
|
1000
|
+
$[30] = t10;
|
|
1001
|
+
$[31] = t5;
|
|
1002
|
+
$[32] = t11;
|
|
1003
|
+
} else t11 = $[32];
|
|
788
1004
|
let t12;
|
|
789
|
-
if ($[
|
|
1005
|
+
if ($[33] !== t11 || $[34] !== t4) {
|
|
790
1006
|
t12 = /* @__PURE__ */ jsx(AlertDialog, {
|
|
791
|
-
open,
|
|
1007
|
+
open: true,
|
|
792
1008
|
onOpenChange: t4,
|
|
793
1009
|
children: t11
|
|
794
1010
|
});
|
|
795
|
-
$[
|
|
1011
|
+
$[33] = t11;
|
|
1012
|
+
$[34] = t4;
|
|
1013
|
+
$[35] = t12;
|
|
1014
|
+
} else t12 = $[35];
|
|
1015
|
+
return t12;
|
|
1016
|
+
}
|
|
1017
|
+
function _temp18(error) {
|
|
1018
|
+
return toast.error(error.message || "Could not remove the language");
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Asks before making a locale the default one, saying what moves, then makes it the default in
|
|
1022
|
+
* the draft.
|
|
1023
|
+
*/
|
|
1024
|
+
function MakeDefaultLocaleDialog(t0) {
|
|
1025
|
+
const $ = c(47);
|
|
1026
|
+
const { projectId, locale, from, onClose, onChanged } = t0;
|
|
1027
|
+
const cache = useStudioCache();
|
|
1028
|
+
let t1;
|
|
1029
|
+
if ($[0] !== locale.tag) {
|
|
1030
|
+
t1 = localeLabel(locale.tag);
|
|
1031
|
+
$[0] = locale.tag;
|
|
1032
|
+
$[1] = t1;
|
|
1033
|
+
} else t1 = $[1];
|
|
1034
|
+
const label = t1;
|
|
1035
|
+
let t2;
|
|
1036
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1037
|
+
t2 = localeMutations.setDefault();
|
|
1038
|
+
$[2] = t2;
|
|
1039
|
+
} else t2 = $[2];
|
|
1040
|
+
let t3;
|
|
1041
|
+
if ($[3] !== cache || $[4] !== label || $[5] !== locale.tag || $[6] !== onChanged || $[7] !== onClose || $[8] !== projectId) {
|
|
1042
|
+
t3 = {
|
|
1043
|
+
...t2,
|
|
1044
|
+
onSuccess: () => {
|
|
1045
|
+
onClose();
|
|
1046
|
+
toast.success(`${label} is now the default language`);
|
|
1047
|
+
cache.invalidate(reads.localeList({ projectId }));
|
|
1048
|
+
onChanged(locale.tag);
|
|
1049
|
+
},
|
|
1050
|
+
onError: _temp19
|
|
1051
|
+
};
|
|
1052
|
+
$[3] = cache;
|
|
1053
|
+
$[4] = label;
|
|
1054
|
+
$[5] = locale.tag;
|
|
1055
|
+
$[6] = onChanged;
|
|
1056
|
+
$[7] = onClose;
|
|
1057
|
+
$[8] = projectId;
|
|
1058
|
+
$[9] = t3;
|
|
1059
|
+
} else t3 = $[9];
|
|
1060
|
+
const setDefault = useMutation(t3);
|
|
1061
|
+
let t4;
|
|
1062
|
+
if ($[10] !== onClose || $[11] !== setDefault.isPending) {
|
|
1063
|
+
t4 = (next) => {
|
|
1064
|
+
if (!next && !setDefault.isPending) onClose();
|
|
1065
|
+
};
|
|
1066
|
+
$[10] = onClose;
|
|
1067
|
+
$[11] = setDefault.isPending;
|
|
1068
|
+
$[12] = t4;
|
|
1069
|
+
} else t4 = $[12];
|
|
1070
|
+
let t5;
|
|
1071
|
+
if ($[13] !== label) {
|
|
1072
|
+
t5 = /* @__PURE__ */ jsxs(AlertDialogTitle, { children: [
|
|
1073
|
+
"Make ",
|
|
1074
|
+
label,
|
|
1075
|
+
" the default language?"
|
|
1076
|
+
] });
|
|
1077
|
+
$[13] = label;
|
|
1078
|
+
$[14] = t5;
|
|
1079
|
+
} else t5 = $[14];
|
|
1080
|
+
let t6;
|
|
1081
|
+
if ($[15] !== from.tag) {
|
|
1082
|
+
t6 = localeLabel(from.tag);
|
|
1083
|
+
$[15] = from.tag;
|
|
1084
|
+
$[16] = t6;
|
|
1085
|
+
} else t6 = $[16];
|
|
1086
|
+
let t7;
|
|
1087
|
+
if ($[17] !== from.tag) {
|
|
1088
|
+
t7 = localePrefix({
|
|
1089
|
+
tag: from.tag,
|
|
1090
|
+
isDefault: false
|
|
1091
|
+
});
|
|
1092
|
+
$[17] = from.tag;
|
|
1093
|
+
$[18] = t7;
|
|
1094
|
+
} else t7 = $[18];
|
|
1095
|
+
let t8;
|
|
1096
|
+
if ($[19] !== label || $[20] !== t6 || $[21] !== t7) {
|
|
1097
|
+
t8 = /* @__PURE__ */ jsxs(AlertDialogDescription, { children: [
|
|
1098
|
+
"Camox translates every other language from ",
|
|
1099
|
+
label,
|
|
1100
|
+
" from now on. Its pages move to the website's URLs without a language prefix, and ",
|
|
1101
|
+
t6,
|
|
1102
|
+
" pages move under",
|
|
1103
|
+
" ",
|
|
1104
|
+
t7,
|
|
1105
|
+
". Nothing is translated again now. The change goes live when the draft is published."
|
|
1106
|
+
] });
|
|
1107
|
+
$[19] = label;
|
|
1108
|
+
$[20] = t6;
|
|
1109
|
+
$[21] = t7;
|
|
1110
|
+
$[22] = t8;
|
|
1111
|
+
} else t8 = $[22];
|
|
1112
|
+
let t9;
|
|
1113
|
+
if ($[23] !== t5 || $[24] !== t8) {
|
|
1114
|
+
t9 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [t5, t8] });
|
|
1115
|
+
$[23] = t5;
|
|
1116
|
+
$[24] = t8;
|
|
1117
|
+
$[25] = t9;
|
|
1118
|
+
} else t9 = $[25];
|
|
1119
|
+
let t10;
|
|
1120
|
+
if ($[26] !== setDefault.isPending) {
|
|
1121
|
+
t10 = /* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
1122
|
+
variant: "outline",
|
|
1123
|
+
size: "default",
|
|
1124
|
+
disabled: setDefault.isPending,
|
|
1125
|
+
children: "Cancel"
|
|
1126
|
+
});
|
|
1127
|
+
$[26] = setDefault.isPending;
|
|
1128
|
+
$[27] = t10;
|
|
1129
|
+
} else t10 = $[27];
|
|
1130
|
+
let t11;
|
|
1131
|
+
if ($[28] !== locale.tag || $[29] !== projectId || $[30] !== setDefault) {
|
|
1132
|
+
t11 = () => setDefault.mutate({
|
|
1133
|
+
projectId,
|
|
1134
|
+
tag: locale.tag
|
|
1135
|
+
});
|
|
1136
|
+
$[28] = locale.tag;
|
|
1137
|
+
$[29] = projectId;
|
|
1138
|
+
$[30] = setDefault;
|
|
796
1139
|
$[31] = t11;
|
|
797
|
-
|
|
1140
|
+
} else t11 = $[31];
|
|
1141
|
+
let t12;
|
|
1142
|
+
if ($[32] !== setDefault.isPending) {
|
|
1143
|
+
t12 = setDefault.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
|
|
1144
|
+
$[32] = setDefault.isPending;
|
|
798
1145
|
$[33] = t12;
|
|
799
1146
|
} else t12 = $[33];
|
|
800
|
-
|
|
1147
|
+
let t13;
|
|
1148
|
+
if ($[34] !== setDefault.isPending || $[35] !== t11 || $[36] !== t12) {
|
|
1149
|
+
t13 = /* @__PURE__ */ jsxs(AlertDialogAction, {
|
|
1150
|
+
disabled: setDefault.isPending,
|
|
1151
|
+
onClick: t11,
|
|
1152
|
+
children: [t12, "Make default"]
|
|
1153
|
+
});
|
|
1154
|
+
$[34] = setDefault.isPending;
|
|
1155
|
+
$[35] = t11;
|
|
1156
|
+
$[36] = t12;
|
|
1157
|
+
$[37] = t13;
|
|
1158
|
+
} else t13 = $[37];
|
|
1159
|
+
let t14;
|
|
1160
|
+
if ($[38] !== t10 || $[39] !== t13) {
|
|
1161
|
+
t14 = /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t10, t13] });
|
|
1162
|
+
$[38] = t10;
|
|
1163
|
+
$[39] = t13;
|
|
1164
|
+
$[40] = t14;
|
|
1165
|
+
} else t14 = $[40];
|
|
1166
|
+
let t15;
|
|
1167
|
+
if ($[41] !== t14 || $[42] !== t9) {
|
|
1168
|
+
t15 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t9, t14] });
|
|
1169
|
+
$[41] = t14;
|
|
1170
|
+
$[42] = t9;
|
|
1171
|
+
$[43] = t15;
|
|
1172
|
+
} else t15 = $[43];
|
|
1173
|
+
let t16;
|
|
1174
|
+
if ($[44] !== t15 || $[45] !== t4) {
|
|
1175
|
+
t16 = /* @__PURE__ */ jsx(AlertDialog, {
|
|
1176
|
+
open: true,
|
|
1177
|
+
onOpenChange: t4,
|
|
1178
|
+
children: t15
|
|
1179
|
+
});
|
|
1180
|
+
$[44] = t15;
|
|
1181
|
+
$[45] = t4;
|
|
1182
|
+
$[46] = t16;
|
|
1183
|
+
} else t16 = $[46];
|
|
1184
|
+
return t16;
|
|
801
1185
|
}
|
|
802
|
-
function
|
|
803
|
-
return toast.error(error.message || "Could not
|
|
1186
|
+
function _temp19(error) {
|
|
1187
|
+
return toast.error(error.message || "Could not change the default language");
|
|
804
1188
|
}
|
|
805
1189
|
|
|
806
1190
|
//#endregion
|