@nocode-factory/sanity-kit 2.34.0 → 2.36.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/index.d.ts +1 -1
- package/dist/index.js +299 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/actions/DeleteTranslations.tsx +187 -0
- package/src/actions/PropagatePublish.tsx +4 -1
- package/src/actions/RemoveFromSite.tsx +79 -16
- package/src/index.ts +28 -4
- package/src/lib/localizeReferences.ts +48 -0
- package/src/lib/translateDocument.ts +3 -0
- package/src/version.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1389,7 +1389,7 @@ export declare function ActorName(props: {
|
|
|
1389
1389
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1390
1390
|
* le vérifie.
|
|
1391
1391
|
*/
|
|
1392
|
-
export declare const KIT_VERSION = "2.
|
|
1392
|
+
export declare const KIT_VERSION = "2.36.0";
|
|
1393
1393
|
/**
|
|
1394
1394
|
* Données de la page proposées comme colonnes.
|
|
1395
1395
|
*
|
package/dist/index.js
CHANGED
|
@@ -1384,7 +1384,7 @@ function explainGrantError(error) {
|
|
|
1384
1384
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1385
1385
|
* le vérifie.
|
|
1386
1386
|
*/
|
|
1387
|
-
const KIT_VERSION = "2.
|
|
1387
|
+
const KIT_VERSION = "2.36.0";
|
|
1388
1388
|
/**
|
|
1389
1389
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1390
1390
|
*
|
|
@@ -1727,7 +1727,7 @@ function useKitUpdate() {
|
|
|
1727
1727
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1728
1728
|
}).catch(() => {}), () => controller.abort();
|
|
1729
1729
|
}, []);
|
|
1730
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.
|
|
1730
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.36.0") > 0);
|
|
1731
1731
|
return {
|
|
1732
1732
|
current: KIT_VERSION,
|
|
1733
1733
|
latest,
|
|
@@ -2924,6 +2924,42 @@ function SharePreview() {
|
|
|
2924
2924
|
})
|
|
2925
2925
|
}) : null;
|
|
2926
2926
|
}
|
|
2927
|
+
/** Références de contenu d'une valeur (hors fichiers et images : leurs assets n'ont pas de langue). */
|
|
2928
|
+
function contentRefs(value, out = /* @__PURE__ */ new Set()) {
|
|
2929
|
+
if (Array.isArray(value)) for (let item of value) contentRefs(item, out);
|
|
2930
|
+
else if (value && typeof value == "object") {
|
|
2931
|
+
let ref = value._ref;
|
|
2932
|
+
typeof ref == "string" && !/^(image|file)-/.test(ref) && out.add(ref.replace(/^drafts\./, ""));
|
|
2933
|
+
for (let [k, v] of Object.entries(value)) k !== "_ref" && contentRefs(v, out);
|
|
2934
|
+
}
|
|
2935
|
+
return out;
|
|
2936
|
+
}
|
|
2937
|
+
/** Remplace chaque référence par celle de `map` (sans toucher au reste). Rend une copie. */
|
|
2938
|
+
function replaceRefs(value, map) {
|
|
2939
|
+
if (Array.isArray(value)) return value.map((item) => replaceRefs(item, map));
|
|
2940
|
+
if (value && typeof value == "object") {
|
|
2941
|
+
let out = {};
|
|
2942
|
+
for (let [k, v] of Object.entries(value)) out[k] = k === "_ref" && typeof v == "string" && map.has(v.replace(/^drafts\./, "")) ? map.get(v.replace(/^drafts\./, "")) : replaceRefs(v, map);
|
|
2943
|
+
return out;
|
|
2944
|
+
}
|
|
2945
|
+
return value;
|
|
2946
|
+
}
|
|
2947
|
+
/**
|
|
2948
|
+
* Version d'une autre langue : chaque référence vers un document traduit pointe la
|
|
2949
|
+
* traduction de CETTE langue (type de publication, catégorie, pages liées...). Une
|
|
2950
|
+
* référence sans traduction dans la langue reste telle quelle (document commun à
|
|
2951
|
+
* toutes les langues, ou traduction pas encore créée).
|
|
2952
|
+
*/
|
|
2953
|
+
async function localizeReferences(client, value, language) {
|
|
2954
|
+
let refs = [...contentRefs(value)];
|
|
2955
|
+
if (!refs.length) return value;
|
|
2956
|
+
let rows = await client.fetch("*[_type == \"translation.metadata\" && count(translations[value._ref in $refs]) > 0]{\n \"pairs\": translations[value._ref in $refs]{\"from\": value._ref, \"to\": ^.translations[_key == $language || language == $language][0].value._ref}\n }.pairs[]", {
|
|
2957
|
+
refs,
|
|
2958
|
+
language
|
|
2959
|
+
}), map = /* @__PURE__ */ new Map();
|
|
2960
|
+
for (let row of rows ?? []) row?.from && row.to && row.to !== row.from && map.set(row.from, row.to);
|
|
2961
|
+
return map.size ? replaceRefs(value, map) : value;
|
|
2962
|
+
}
|
|
2927
2963
|
const isObj$1 = (v) => typeof v == "object" && !!v && !Array.isArray(v);
|
|
2928
2964
|
/** Textes d'une valeur, dans l'ordre. */
|
|
2929
2965
|
function collectTexts$1(value) {
|
|
@@ -3233,7 +3269,7 @@ async function createTranslatedVersion(opts) {
|
|
|
3233
3269
|
} catch (cause) {
|
|
3234
3270
|
aiError = cause instanceof Error ? cause.message : String(cause);
|
|
3235
3271
|
}
|
|
3236
|
-
doc[field] = language;
|
|
3272
|
+
doc[field] = language, Object.assign(doc, await localizeReferences(client, doc, language));
|
|
3237
3273
|
let pageType = config.pageTypes.find((t) => t.type === type), slugField = pageType?.slugField ?? (source.slug?.current ? "slug" : null);
|
|
3238
3274
|
if (slugField && source[slugField]?.current) {
|
|
3239
3275
|
let titleField = pageType?.titleField ?? "title", base = slugify(typeof doc[titleField] == "string" ? doc[titleField] : "") || String(source[slugField].current), slug = base;
|
|
@@ -8592,23 +8628,56 @@ function OverrideDot(props) {
|
|
|
8592
8628
|
* leurs liens vers elle disparaîtront du site. Une référence FORTE (non `weak`)
|
|
8593
8629
|
* empêche Sanity de dépublier : le message l'explique au lieu d'une erreur brute.
|
|
8594
8630
|
*/
|
|
8595
|
-
const RemoveFromSiteAction = (
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8631
|
+
const RemoveFromSiteAction = createRemoveFromSite();
|
|
8632
|
+
/**
|
|
8633
|
+
* Variante multilingue : sur la version PRINCIPALE d'un document traduit (page ou
|
|
8634
|
+
* fiche de collection), la fenêtre propose aussi de retirer du site ses autres
|
|
8635
|
+
* langues publiées (cochées par défaut), en une seule opération.
|
|
8636
|
+
*/
|
|
8637
|
+
function createRemoveFromSite(config, masterLocale) {
|
|
8638
|
+
let i18n = config?.i18n, master = masterLocale ?? i18n?.defaultLocale, Action = (props) => useRemoveFromSite(props, i18n?.field, master);
|
|
8639
|
+
return Action.action = "unpublish", Action;
|
|
8640
|
+
}
|
|
8641
|
+
function useRemoveFromSite(props, field, master) {
|
|
8642
|
+
let client = useKitClient(), current = props.draft ?? props.published, isMaster = !!field && !!master && current?.[field] === master, [versions, setVersions] = useState([]), [open, setOpen] = useState(!1), [referrers, setReferrers] = useState(null), [busy, setBusy] = useState(!1), [error, setError] = useState(null);
|
|
8643
|
+
useEffect(() => {
|
|
8644
|
+
if (!open || !isMaster) return;
|
|
8645
|
+
let alive = !0;
|
|
8646
|
+
return translationsOf(client, props.id).then(async (list) => {
|
|
8647
|
+
let others = list.filter((t) => t.id !== props.id), live = new Set(await client.fetch("*[_id in $ids]._id", { ids: others.map((t) => t.id) }));
|
|
8648
|
+
alive && setVersions(others.filter((t) => live.has(t.id)).map((t) => ({
|
|
8649
|
+
...t,
|
|
8650
|
+
selected: !0
|
|
8651
|
+
})));
|
|
8652
|
+
}).catch(() => alive && setVersions([])), () => {
|
|
8653
|
+
alive = !1;
|
|
8654
|
+
};
|
|
8599
8655
|
}, [
|
|
8600
8656
|
open,
|
|
8657
|
+
isMaster,
|
|
8601
8658
|
client,
|
|
8602
8659
|
props.id
|
|
8660
|
+
]);
|
|
8661
|
+
let ids = [props.id, ...versions.filter((v) => v.selected).map((v) => v.id)];
|
|
8662
|
+
if (useEffect(() => {
|
|
8663
|
+
open && (setReferrers(null), client.fetch("*[references($ids) && !(_id in path(\"drafts.**\")) && !(_id in $ids) && _type != \"translation.metadata\"]{_id, _type, \"title\": coalesce(title, name, _id)}", { ids }).then(setReferrers).catch(() => setReferrers([])));
|
|
8664
|
+
}, [
|
|
8665
|
+
open,
|
|
8666
|
+
client,
|
|
8667
|
+
ids.join(",")
|
|
8603
8668
|
]), !props.published) return null;
|
|
8604
8669
|
let confirm = async () => {
|
|
8605
8670
|
setBusy(!0), setError(null);
|
|
8606
8671
|
try {
|
|
8607
|
-
let
|
|
8608
|
-
|
|
8609
|
-
...published,
|
|
8610
|
-
|
|
8611
|
-
|
|
8672
|
+
let tx = client.transaction(), docs = await client.fetch("*[_id in $ids]", { ids }), drafts = new Set(await client.fetch("*[_id in $drafts]._id", { drafts: ids.map((id) => `drafts.${id}`) }));
|
|
8673
|
+
for (let doc of docs) {
|
|
8674
|
+
let { _rev, _updatedAt, ...published } = doc, id = String(doc._id);
|
|
8675
|
+
drafts.has(`drafts.${id}`) || tx.createIfNotExists({
|
|
8676
|
+
...published,
|
|
8677
|
+
_id: `drafts.${id}`
|
|
8678
|
+
}), tx.delete(id);
|
|
8679
|
+
}
|
|
8680
|
+
await tx.commit(), setOpen(!1), props.onComplete();
|
|
8612
8681
|
} catch (cause) {
|
|
8613
8682
|
let message = cause instanceof Error ? cause.message : String(cause);
|
|
8614
8683
|
setError(/referenc/i.test(message) ? "Sanity refused: a published document points to this page with a strong reference. Remove or change that link, then try again." : `Removal failed, nothing was changed. (${message.slice(0, 140)})`);
|
|
@@ -8635,16 +8704,44 @@ const RemoveFromSiteAction = (props) => {
|
|
|
8635
8704
|
children: [
|
|
8636
8705
|
/* @__PURE__ */ jsx(Text, {
|
|
8637
8706
|
size: 1,
|
|
8638
|
-
children: "
|
|
8707
|
+
children: "It leaves the site (production and staging \"Published\"). All its content stays in the draft: to put it back online, publish it."
|
|
8708
|
+
}),
|
|
8709
|
+
versions.length > 0 && /* @__PURE__ */ jsxs(Stack, {
|
|
8710
|
+
gap: 2,
|
|
8711
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
8712
|
+
size: 1,
|
|
8713
|
+
weight: "semibold",
|
|
8714
|
+
children: "Also remove the other languages from the site:"
|
|
8715
|
+
}), versions.map((v, index) => /* @__PURE__ */ jsx(Card, {
|
|
8716
|
+
padding: 2,
|
|
8717
|
+
radius: 2,
|
|
8718
|
+
border: !0,
|
|
8719
|
+
children: /* @__PURE__ */ jsxs(Flex, {
|
|
8720
|
+
as: "label",
|
|
8721
|
+
gap: 3,
|
|
8722
|
+
align: "center",
|
|
8723
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
8724
|
+
checked: v.selected,
|
|
8725
|
+
disabled: busy,
|
|
8726
|
+
onChange: () => setVersions(versions.map((x, i) => i === index ? {
|
|
8727
|
+
...x,
|
|
8728
|
+
selected: !x.selected
|
|
8729
|
+
} : x))
|
|
8730
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
8731
|
+
size: 1,
|
|
8732
|
+
children: v.language.toUpperCase()
|
|
8733
|
+
})]
|
|
8734
|
+
})
|
|
8735
|
+
}, v.id))]
|
|
8639
8736
|
}),
|
|
8640
8737
|
referrers === null ? /* @__PURE__ */ jsx(Text, {
|
|
8641
8738
|
size: 1,
|
|
8642
8739
|
muted: !0,
|
|
8643
|
-
children: "Looking for links
|
|
8740
|
+
children: "Looking for links…"
|
|
8644
8741
|
}) : referrers.length > 0 ? /* @__PURE__ */ jsxs(Text, {
|
|
8645
8742
|
size: 1,
|
|
8646
8743
|
children: [
|
|
8647
|
-
"These published documents point to it; their links
|
|
8744
|
+
"These published documents point to it; their links will disappear from the site:",
|
|
8648
8745
|
" ",
|
|
8649
8746
|
referrers.map((r) => r.title || r._id).join(", "),
|
|
8650
8747
|
"."
|
|
@@ -8652,7 +8749,7 @@ const RemoveFromSiteAction = (props) => {
|
|
|
8652
8749
|
}) : /* @__PURE__ */ jsx(Text, {
|
|
8653
8750
|
size: 1,
|
|
8654
8751
|
muted: !0,
|
|
8655
|
-
children: "No published document points to
|
|
8752
|
+
children: "No published document points to it."
|
|
8656
8753
|
}),
|
|
8657
8754
|
error && /* @__PURE__ */ jsx(Text, {
|
|
8658
8755
|
size: 1,
|
|
@@ -8663,8 +8760,7 @@ const RemoveFromSiteAction = (props) => {
|
|
|
8663
8760
|
})
|
|
8664
8761
|
}
|
|
8665
8762
|
};
|
|
8666
|
-
}
|
|
8667
|
-
RemoveFromSiteAction.action = "unpublish";
|
|
8763
|
+
}
|
|
8668
8764
|
/**
|
|
8669
8765
|
* Sous le champ Slug d'une page (types de pages du kit) : l'adresse COMPLÈTE de la
|
|
8670
8766
|
* page sur le site en ligne, avec « Copier » et « Ouvrir ». Le slug seul ne dit pas
|
|
@@ -9130,7 +9226,7 @@ function PropagateDialog(props) {
|
|
|
9130
9226
|
created.aiError && (aiError = created.aiError), (created.published ? published : drafted).push(t.language.toUpperCase());
|
|
9131
9227
|
continue;
|
|
9132
9228
|
}
|
|
9133
|
-
let { _id, _rev, _createdAt, _updatedAt, ...
|
|
9229
|
+
let { _id, _rev, _createdAt, _updatedAt, ...raw } = structuredClone(t.result.document), doc = await localizeReferences(client, raw, t.language), targetId = t.id, kept = overwrite ? [] : t.edited, remaining = t.result.toTranslate, failed = !1, written = [];
|
|
9134
9230
|
if (ai && config.history && remaining.length) {
|
|
9135
9231
|
let toDo = remaining.filter((p) => !kept.includes(p));
|
|
9136
9232
|
try {
|
|
@@ -9289,6 +9385,184 @@ function summary(r) {
|
|
|
9289
9385
|
let parts = [];
|
|
9290
9386
|
return r.added && parts.push(`${r.added} item${r.added > 1 ? "s" : ""} added`), r.removed && parts.push(`${r.removed} removed`), r.moved && parts.push("order updated"), r.copied.length && parts.push(`${r.copied.length} value${r.copied.length > 1 ? "s" : ""} copied (images, links, options…)`), r.toTranslate.length && parts.push(`${r.toTranslate.length} text${r.toTranslate.length > 1 ? "s" : ""} to translate`), parts.join(" · ");
|
|
9291
9387
|
}
|
|
9388
|
+
/** Identifiants publiés + brouillons d'une liste de documents. */
|
|
9389
|
+
const withDrafts = (ids) => ids.flatMap((id) => [id, `drafts.${id}`]);
|
|
9390
|
+
/**
|
|
9391
|
+
* Supprimer la version PRINCIPALE d'un document traduit (page, fiche de collection,
|
|
9392
|
+
* réglage par langue) : la fenêtre propose de supprimer aussi ses autres langues
|
|
9393
|
+
* (cochées par défaut), en une fois. Bloqué, avec la liste, si un autre document y
|
|
9394
|
+
* fait encore référence (comme la suppression native de Sanity). Les liens de
|
|
9395
|
+
* traduction sont nettoyés. Sans traduction, ou depuis une autre langue : la
|
|
9396
|
+
* suppression native, inchangée.
|
|
9397
|
+
*/
|
|
9398
|
+
function withTranslationDelete(Delete, config, masterLocale) {
|
|
9399
|
+
let i18n = config.i18n, master = masterLocale ?? i18n?.defaultLocale, Wrapped = (props) => {
|
|
9400
|
+
let base = Delete(props), client = useKitClient(), [versions, setVersions] = useState(null), current = props.draft ?? props.published;
|
|
9401
|
+
useEffect(() => {
|
|
9402
|
+
if (!i18n || current?.[i18n.field] !== master) return;
|
|
9403
|
+
let alive = !0;
|
|
9404
|
+
return translationsOf(client, props.id).then((list) => alive && setVersions(list.filter((t) => t.id !== props.id).map((t) => ({
|
|
9405
|
+
...t,
|
|
9406
|
+
selected: !0
|
|
9407
|
+
})))).catch(() => alive && setVersions([])), () => {
|
|
9408
|
+
alive = !1;
|
|
9409
|
+
};
|
|
9410
|
+
}, [
|
|
9411
|
+
client,
|
|
9412
|
+
props.id,
|
|
9413
|
+
current?.[i18n?.field ?? "language"]
|
|
9414
|
+
]);
|
|
9415
|
+
let [open, setOpen] = useState(!1);
|
|
9416
|
+
return !base || !i18n || current?.[i18n.field] !== master || !versions?.length ? base : {
|
|
9417
|
+
...base,
|
|
9418
|
+
onHandle: () => setOpen(!0),
|
|
9419
|
+
dialog: open ? {
|
|
9420
|
+
type: "dialog",
|
|
9421
|
+
header: "Delete this document",
|
|
9422
|
+
width: "medium",
|
|
9423
|
+
onClose: () => setOpen(!1),
|
|
9424
|
+
content: /* @__PURE__ */ jsx(DeleteDialog, {
|
|
9425
|
+
id: props.id,
|
|
9426
|
+
language: String(current?.[i18n.field] ?? ""),
|
|
9427
|
+
versions,
|
|
9428
|
+
onDone: () => {
|
|
9429
|
+
setOpen(!1), props.onComplete();
|
|
9430
|
+
}
|
|
9431
|
+
})
|
|
9432
|
+
} : base.dialog
|
|
9433
|
+
};
|
|
9434
|
+
};
|
|
9435
|
+
return Wrapped;
|
|
9436
|
+
}
|
|
9437
|
+
function DeleteDialog(props) {
|
|
9438
|
+
let { id, language, onDone } = props, client = useKitClient(), toast = useToast(), [versions, setVersions] = useState(props.versions), [referrers, setReferrers] = useState(null), [busy, setBusy] = useState(!1), [error, setError] = useState(null), ids = [id, ...versions.filter((v) => v.selected).map((v) => v.id)], key = ids.join(",");
|
|
9439
|
+
useEffect(() => {
|
|
9440
|
+
setReferrers(null);
|
|
9441
|
+
let all = withDrafts(ids);
|
|
9442
|
+
client.fetch("*[references($ids) && !(_id in $all) && _type != \"translation.metadata\"]{_id, _type, \"title\": coalesce(title, name, heading, _id)}", {
|
|
9443
|
+
ids,
|
|
9444
|
+
all
|
|
9445
|
+
}).then(setReferrers).catch(() => setReferrers([]));
|
|
9446
|
+
}, [client, key]);
|
|
9447
|
+
let remove = async () => {
|
|
9448
|
+
setBusy(!0), setError(null);
|
|
9449
|
+
try {
|
|
9450
|
+
let tx = client.transaction();
|
|
9451
|
+
for (let docId of withDrafts(ids)) tx.delete(docId);
|
|
9452
|
+
let meta = await client.fetch("*[_type == \"translation.metadata\" && references($id)][0]{_id, translations}", { id });
|
|
9453
|
+
if (meta) {
|
|
9454
|
+
let gone = (meta.translations ?? []).filter((t) => ids.includes(t.value?._ref ?? ""));
|
|
9455
|
+
(meta.translations ?? []).length - gone.length > 1 ? tx.patch(meta._id, (p) => p.unset(gone.map((t) => `translations[_key == "${t._key}"]`))) : tx.delete(meta._id);
|
|
9456
|
+
}
|
|
9457
|
+
await tx.commit({ visibility: "async" }), toast.push({
|
|
9458
|
+
status: "success",
|
|
9459
|
+
title: `Deleted: ${[language, ...versions.filter((v) => v.selected).map((v) => v.language)].map((l) => l.toUpperCase()).join(", ")}`,
|
|
9460
|
+
duration: 6e3
|
|
9461
|
+
}), onDone();
|
|
9462
|
+
} catch (cause) {
|
|
9463
|
+
setError(`Failed. (${(cause instanceof Error ? cause.message : String(cause)).slice(0, 160)})`), setBusy(!1);
|
|
9464
|
+
}
|
|
9465
|
+
}, blocked = !!referrers?.length;
|
|
9466
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
9467
|
+
gap: 4,
|
|
9468
|
+
padding: 4,
|
|
9469
|
+
children: [
|
|
9470
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
9471
|
+
size: 1,
|
|
9472
|
+
children: [
|
|
9473
|
+
"The ",
|
|
9474
|
+
language.toUpperCase(),
|
|
9475
|
+
" version will be deleted for good (published and draft). Delete the other language versions too?"
|
|
9476
|
+
]
|
|
9477
|
+
}),
|
|
9478
|
+
/* @__PURE__ */ jsx(Stack, {
|
|
9479
|
+
gap: 2,
|
|
9480
|
+
children: versions.map((v, index) => /* @__PURE__ */ jsx(Card, {
|
|
9481
|
+
padding: 3,
|
|
9482
|
+
radius: 2,
|
|
9483
|
+
border: !0,
|
|
9484
|
+
children: /* @__PURE__ */ jsxs(Flex, {
|
|
9485
|
+
as: "label",
|
|
9486
|
+
gap: 3,
|
|
9487
|
+
align: "center",
|
|
9488
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
9489
|
+
checked: v.selected,
|
|
9490
|
+
disabled: busy,
|
|
9491
|
+
onChange: () => setVersions(versions.map((x, i) => i === index ? {
|
|
9492
|
+
...x,
|
|
9493
|
+
selected: !x.selected
|
|
9494
|
+
} : x))
|
|
9495
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
9496
|
+
size: 1,
|
|
9497
|
+
weight: "semibold",
|
|
9498
|
+
children: v.language.toUpperCase()
|
|
9499
|
+
})]
|
|
9500
|
+
})
|
|
9501
|
+
}, v.id))
|
|
9502
|
+
}),
|
|
9503
|
+
referrers === null ? /* @__PURE__ */ jsx(Flex, {
|
|
9504
|
+
justify: "center",
|
|
9505
|
+
children: /* @__PURE__ */ jsx(Spinner, { muted: !0 })
|
|
9506
|
+
}) : blocked ? /* @__PURE__ */ jsx(Card, {
|
|
9507
|
+
tone: "critical",
|
|
9508
|
+
padding: 3,
|
|
9509
|
+
radius: 2,
|
|
9510
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
9511
|
+
gap: 2,
|
|
9512
|
+
children: [
|
|
9513
|
+
/* @__PURE__ */ jsx(Text, {
|
|
9514
|
+
size: 1,
|
|
9515
|
+
children: "Still referenced by these documents: remove the references first."
|
|
9516
|
+
}),
|
|
9517
|
+
referrers.slice(0, 8).map((r) => /* @__PURE__ */ jsxs(Text, {
|
|
9518
|
+
size: 1,
|
|
9519
|
+
muted: !0,
|
|
9520
|
+
children: [
|
|
9521
|
+
r.title,
|
|
9522
|
+
" (",
|
|
9523
|
+
r._type,
|
|
9524
|
+
")"
|
|
9525
|
+
]
|
|
9526
|
+
}, r._id)),
|
|
9527
|
+
referrers.length > 8 && /* @__PURE__ */ jsxs(Text, {
|
|
9528
|
+
size: 1,
|
|
9529
|
+
muted: !0,
|
|
9530
|
+
children: [
|
|
9531
|
+
"…and ",
|
|
9532
|
+
referrers.length - 8,
|
|
9533
|
+
" more"
|
|
9534
|
+
]
|
|
9535
|
+
})
|
|
9536
|
+
]
|
|
9537
|
+
})
|
|
9538
|
+
}) : null,
|
|
9539
|
+
error && /* @__PURE__ */ jsx(Card, {
|
|
9540
|
+
tone: "critical",
|
|
9541
|
+
padding: 3,
|
|
9542
|
+
radius: 2,
|
|
9543
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
9544
|
+
size: 1,
|
|
9545
|
+
children: error
|
|
9546
|
+
})
|
|
9547
|
+
}),
|
|
9548
|
+
/* @__PURE__ */ jsxs(Flex, {
|
|
9549
|
+
justify: "flex-end",
|
|
9550
|
+
gap: 2,
|
|
9551
|
+
children: [/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Button, {
|
|
9552
|
+
text: "Cancel",
|
|
9553
|
+
mode: "ghost",
|
|
9554
|
+
onClick: onDone,
|
|
9555
|
+
disabled: busy
|
|
9556
|
+
}) }), /* @__PURE__ */ jsx(Button, {
|
|
9557
|
+
text: busy ? "Deleting…" : `Delete ${ids.length > 1 ? `${ids.length} versions` : `${language.toUpperCase()} only`}`,
|
|
9558
|
+
tone: "critical",
|
|
9559
|
+
onClick: () => void remove(),
|
|
9560
|
+
disabled: busy || referrers === null || blocked
|
|
9561
|
+
})]
|
|
9562
|
+
})
|
|
9563
|
+
]
|
|
9564
|
+
});
|
|
9565
|
+
}
|
|
9292
9566
|
/**
|
|
9293
9567
|
* `pageTypes` déduits du registre du starter, pour ne pas redire au kit ce que
|
|
9294
9568
|
* le site sait déjà : l'accueil (chemin fixe `/`) et chaque collection avec
|
|
@@ -9930,12 +10204,17 @@ const ncfKit = definePlugin((options) => {
|
|
|
9930
10204
|
},
|
|
9931
10205
|
document: {
|
|
9932
10206
|
newDocumentOptions: (prev) => prev.filter((option) => option.templateId !== BOARD_LAYOUT_TYPE),
|
|
9933
|
-
actions: (prev, context) => config.pageTypeNames.includes(context.schemaType) ? prev.map((action) => action.action === "unpublish" ? RemoveFromSiteAction : action.action === "publish" && config.i18n ? withPropagation(action, config, void 0, { allowCreate: !0 }) : action) : context.schemaType === config.componentPreview.defaultsType && config.i18n ? prev.map((action) => action.action === "publish" ? withPropagation(action, config, config.i18n?.defaultsSourceLocale) : action) : prev
|
|
10207
|
+
actions: (prev, context) => config.pageTypeNames.includes(context.schemaType) ? prev.map((action) => action.action === "unpublish" ? config.i18n ? createRemoveFromSite(config) : RemoveFromSiteAction : action.action === "publish" && config.i18n ? withPropagation(action, config, void 0, { allowCreate: !0 }) : action.action === "delete" && config.i18n ? withTranslationDelete(action, config) : action) : context.schemaType === config.componentPreview.defaultsType && config.i18n ? prev.map((action) => action.action === "publish" ? withPropagation(action, config, config.i18n?.defaultsSourceLocale) : action.action === "delete" ? withTranslationDelete(action, config, config.i18n?.defaultsSourceLocale) : action) : config.i18n && !isKitType(context.schemaType) && hasLanguageField(context.schema.get(context.schemaType), config.i18n.field) ? prev.map((action) => action.action === "publish" ? withPropagation(action, config, void 0, { allowCreate: !0 }) : action.action === "delete" ? withTranslationDelete(action, config) : action.action === "unpublish" ? createRemoveFromSite(config) : action) : prev
|
|
9934
10208
|
},
|
|
9935
10209
|
studio: { components: { toolMenu: createPreviewLauncher(config, issues) } },
|
|
9936
10210
|
form: { components: { input: createKitInput(config) } }
|
|
9937
10211
|
};
|
|
9938
10212
|
});
|
|
10213
|
+
/** Le type de document porte-t-il le champ de langue (traduit document par document) ? */
|
|
10214
|
+
function hasLanguageField(schemaType, field) {
|
|
10215
|
+
let fields = schemaType?.fields;
|
|
10216
|
+
return Array.isArray(fields) && fields.some((f) => f?.name === field);
|
|
10217
|
+
}
|
|
9939
10218
|
export { ANNOTATION_TYPE, ActorName, BOARD_LAYOUT_ID, BOARD_LAYOUT_TYPE, BRAIN_NODE_SIZE, BoardLayoutProvider, COLUMN_TYPE, CONTENT_SCAN_LIMIT, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, CUSTOM_ENVIRONMENT_ID, DATA_PREFIX, DEFAULT_BOARD_TAGS, DEFAULT_COMPONENT_DEFAULTS_TYPE, DEFAULT_COMPONENT_PREVIEW, DEFAULT_I18N, DEFAULT_INTERNAL_FIELDS, DEFAULT_MORE_TOOLS, DEFAULT_PAGE_BUILDER_FIELD, DEFAULT_SLUG_FIELD, DEFAULT_TITLE_FIELD, KIT_API_VERSION, KIT_VERSION, NCF_COMPONENTS_TOOL, NCF_DESIGN_SYSTEM_TOOL, NCF_HIDDEN_TYPES, NCF_HISTORY_TOOL, NCF_MORE_TOOL, NCF_PAGES_TOOL, NCF_TOOL_NAMES, NODE_FIELD_TYPE, NODE_HEIGHT, NODE_WIDTH, NcfKitUpdate, NcfPreviewHeader, NcfPreviewLauncher, PERSPECTIVES, PROJECTION, SECTION_NODE_TYPE, STATUS_COLORS, STATUS_LABELS, SharePreview, UNSET_LABEL, addColumn, addColumnOption, announce, applySavedPositions, baseId, blockName, blockTypesFromSchema, buildContentsQuery, buildLinkGraph, buildPageRows, buildPagesQuery, collectLinks, collectOccurrences, colorForRow, colorFromString, columnId, compareVersions, componentDefaultsMainDocument, componentDefaultsMainDocuments, createPreviewLauncher, customEnvironment, defaultNodeSize, defaultsFieldName, defineComponentDefaults, depth, deriveDocumentColumns, diffDocuments, diffWords, editIntentPath, explainGrantError, fallbackLayout, fetchDetail, fetchTimeline, fillTemplate, filterRows, flatten, formatDocumentValue, groupPageRows, groupValue, hasBlockingIssue, humanizeBlockName, isDraftId, isKitType, isPrerelease, isSafeColumnKey, isSafeFieldPath, isTextChange, isVersionId, issuesForTool, keyForPath, kitSchemaTypes, layoutGraph, layoutSectionsMap, localesInRows, mergeVersions, missingPageTypes, moveColumn, ncfAllowedOrigins, ncfKit, ncfMainDocuments, ncfPresentationComponents, ncfPreviewComponents, normalizeInternalPath, normalizePath, occurrencesForTypes, pageThumbnailUrl, pageTypeFor, pageTypesFromSiteRoutes, pageTypesWithoutBuilder, parentPath, presentationPath, pruneSavedPositions, releaseId, removeColumn, renameColumn, requestPreviewGrant, requiredUnlessDefault, requiredUnlessDefaultFor, resolveColorBy, resolveConfig, segments, slugKey, sortRows, summarize, toKebabCase, toPath, toUrl, topLevelBlockCount, uniqueColumnId, upsertLayout, urlOn, useAnnotations, useBoardLayout, useDocumentColumns, useHistory, useInternalColumns, useKitClient, useKitConfig, useKitContext, useKitUpdate, useOccurrences, usePageContents, usePages, usePreviewTarget, useRegistration, validateConfig, withAlpha, withMoreTool };
|
|
9940
10219
|
|
|
9941
10220
|
//# sourceMappingURL=index.js.map
|