@nocode-factory/sanity-kit 2.33.3 → 2.35.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 +7 -6
- package/dist/index.js +179 -48
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/actions/PropagatePublish.tsx +4 -1
- package/src/index.ts +14 -1
- package/src/lib/localizeReferences.ts +48 -0
- package/src/lib/translateDocument.ts +3 -0
- package/src/tools/presentation/PresentationHeader.tsx +101 -45
- package/src/version.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1159,11 +1159,12 @@ export declare function ncfPreviewComponents(): {
|
|
|
1159
1159
|
};
|
|
1160
1160
|
};
|
|
1161
1161
|
/**
|
|
1162
|
-
* En-tête de l'aperçu (Presentation) : la barre
|
|
1163
|
-
* -
|
|
1164
|
-
*
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1162
|
+
* En-tête de l'aperçu (Presentation) : la barre native, plus
|
|
1163
|
+
* - un menu d'APPAREILS, posé juste à côté du bouton mobile natif : iPhone 12 Pro
|
|
1164
|
+
* (390×844), iPad Air (820×1180)... L'aperçu prend les dimensions de l'appareil,
|
|
1165
|
+
* affichées à côté de l'icône ;
|
|
1166
|
+
* - « Hide edit panel » : masque le formulaire à droite (la liste des pages reste).
|
|
1167
|
+
* Choix mémorisés dans le navigateur. Seulement l'affichage : aucune donnée touchée.
|
|
1167
1168
|
*/
|
|
1168
1169
|
declare function NcfPresentationHeader(props: PreviewHeaderProps): import("react").JSX.Element;
|
|
1169
1170
|
/**
|
|
@@ -1388,7 +1389,7 @@ export declare function ActorName(props: {
|
|
|
1388
1389
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1389
1390
|
* le vérifie.
|
|
1390
1391
|
*/
|
|
1391
|
-
export declare const KIT_VERSION = "2.
|
|
1392
|
+
export declare const KIT_VERSION = "2.35.0";
|
|
1392
1393
|
/**
|
|
1393
1394
|
* Données de la page proposées comme colonnes.
|
|
1394
1395
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as DEFAULT_TOOLBAR_MORE, a as defineComponentDefaults, c as DEFAULT_BOARD_TAGS, d as DEFAULT_INTERNAL_FIELDS, f as DEFAULT_NOINDEX_FIELDS, g as DEFAULT_TITLE_FIELD, h as DEFAULT_SLUG_FIELD, i as defaultsFieldName, l as DEFAULT_COMPONENT_PREVIEW, n as componentDefaultsMainDocument, o as requiredUnlessDefault, p as DEFAULT_PAGE_BUILDER_FIELD, r as componentDefaultsMainDocuments, s as requiredUnlessDefaultFor, t as DEFAULT_COMPONENT_DEFAULTS_TYPE, u as DEFAULT_I18N, v as DEFAULT_TOOLS } from "./componentDefaults-CelL5Ain.js";
|
|
2
|
-
import { createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
2
|
+
import { createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { ToolLink, defineField, definePlugin, defineType, pathToString, set, unset, useClient, useCurrentUser, useFormValue, usePerspective, useSchema, useSetPerspective, useUser, useWorkspace } from "sanity";
|
|
4
4
|
import { ClockIcon } from "@sanity/icons/Clock";
|
|
5
5
|
import { ComponentIcon } from "@sanity/icons/Component";
|
|
@@ -13,7 +13,7 @@ import { LaunchIcon } from "@sanity/icons/Launch";
|
|
|
13
13
|
import { ArrowUpIcon } from "@sanity/icons/ArrowUp";
|
|
14
14
|
import { CheckmarkIcon } from "@sanity/icons/Checkmark";
|
|
15
15
|
import { CopyIcon } from "@sanity/icons/Copy";
|
|
16
|
-
import { Menu, MenuButton, MenuItem } from "@sanity/ui/menu";
|
|
16
|
+
import { Menu, MenuButton, MenuDivider, MenuItem } from "@sanity/ui/menu";
|
|
17
17
|
import { EllipsisHorizontalIcon } from "@sanity/icons/EllipsisHorizontal";
|
|
18
18
|
import { CloseIcon } from "@sanity/icons/Close";
|
|
19
19
|
import { EarthGlobeIcon } from "@sanity/icons/EarthGlobe";
|
|
@@ -40,6 +40,7 @@ import { Tooltip } from "@sanity/ui/tooltip";
|
|
|
40
40
|
import { EyeClosedIcon } from "@sanity/icons/EyeClosed";
|
|
41
41
|
import { usePresentationNavigate, usePresentationParams } from "sanity/presentation";
|
|
42
42
|
import { useToast } from "@sanity/ui/toast";
|
|
43
|
+
import { createPortal } from "react-dom";
|
|
43
44
|
import { TabletDeviceIcon } from "@sanity/icons/TabletDevice";
|
|
44
45
|
import { PanelRightIcon } from "@sanity/icons/PanelRight";
|
|
45
46
|
const trimTrailingSlash = (url) => url.replace(/\/+$/, ""), normalizePath = (path) => {
|
|
@@ -1173,14 +1174,14 @@ function customEnvironment(raw) {
|
|
|
1173
1174
|
}
|
|
1174
1175
|
}
|
|
1175
1176
|
/** Lit une préférence locale sans jamais faire échouer le montage. */
|
|
1176
|
-
function read(key) {
|
|
1177
|
+
function read$1(key) {
|
|
1177
1178
|
try {
|
|
1178
1179
|
return window.localStorage.getItem(key);
|
|
1179
1180
|
} catch {
|
|
1180
1181
|
return null;
|
|
1181
1182
|
}
|
|
1182
1183
|
}
|
|
1183
|
-
function write(key, value) {
|
|
1184
|
+
function write$1(key, value) {
|
|
1184
1185
|
try {
|
|
1185
1186
|
window.localStorage.setItem(key, value);
|
|
1186
1187
|
} catch {}
|
|
@@ -1195,13 +1196,13 @@ function write(key, value) {
|
|
|
1195
1196
|
*/
|
|
1196
1197
|
function usePreviewTargetState() {
|
|
1197
1198
|
let config = useKitConfig(), scope = `ncf-kit:preview-target:${useKitClient().config().projectId ?? "sans-projet"}`, environments = config.environments, fallback = defaultEnvironmentId(environments, config.previewUrl), [environmentId, setStoredEnvironment] = useState(() => {
|
|
1198
|
-
let saved = read(`${scope}:environment`);
|
|
1199
|
+
let saved = read$1(`${scope}:environment`);
|
|
1199
1200
|
return saved && environments.some((e) => e.id === saved) ? saved : fallback;
|
|
1200
|
-
}), [customUrl, setStoredCustomUrl] = useState(() => read(`${scope}:custom`)), [perspective, setStoredPerspective] = useState(() => read(`${scope}:perspective`) === "published" ? "published" : "drafts"), setEnvironment = useCallback((id) => {
|
|
1201
|
-
setStoredEnvironment(id), write(`${scope}:environment`, id);
|
|
1201
|
+
}), [customUrl, setStoredCustomUrl] = useState(() => read$1(`${scope}:custom`)), [perspective, setStoredPerspective] = useState(() => read$1(`${scope}:perspective`) === "published" ? "published" : "drafts"), setEnvironment = useCallback((id) => {
|
|
1202
|
+
setStoredEnvironment(id), write$1(`${scope}:environment`, id);
|
|
1202
1203
|
}, [scope]), setPerspective = useCallback((next) => {
|
|
1203
|
-
setStoredPerspective(next), write(`${scope}:perspective`, next);
|
|
1204
|
-
}, [scope]), custom = useMemo(() => customUrl ? customEnvironment(customUrl) : null, [customUrl]), allEnvironments = useMemo(() => custom ? [...environments, custom] : environments, [environments, custom]), environment = useMemo(() => allEnvironments.find((item) => item.id === environmentId) ?? allEnvironments[0] ?? null, [allEnvironments, environmentId]), setCustomUrl = useCallback((url) => url.trim() ? customEnvironment(url) ? (setStoredCustomUrl(url), write(`${scope}:custom`, url), setEnvironment(CUSTOM_ENVIRONMENT_ID), !0) : !1 : (setStoredCustomUrl(null), write(`${scope}:custom`, ""), setEnvironment(fallback ?? ""), !0), [
|
|
1204
|
+
setStoredPerspective(next), write$1(`${scope}:perspective`, next);
|
|
1205
|
+
}, [scope]), custom = useMemo(() => customUrl ? customEnvironment(customUrl) : null, [customUrl]), allEnvironments = useMemo(() => custom ? [...environments, custom] : environments, [environments, custom]), environment = useMemo(() => allEnvironments.find((item) => item.id === environmentId) ?? allEnvironments[0] ?? null, [allEnvironments, environmentId]), setCustomUrl = useCallback((url) => url.trim() ? customEnvironment(url) ? (setStoredCustomUrl(url), write$1(`${scope}:custom`, url), setEnvironment(CUSTOM_ENVIRONMENT_ID), !0) : !1 : (setStoredCustomUrl(null), write$1(`${scope}:custom`, ""), setEnvironment(fallback ?? ""), !0), [
|
|
1205
1206
|
scope,
|
|
1206
1207
|
setEnvironment,
|
|
1207
1208
|
fallback
|
|
@@ -1383,7 +1384,7 @@ function explainGrantError(error) {
|
|
|
1383
1384
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1384
1385
|
* le vérifie.
|
|
1385
1386
|
*/
|
|
1386
|
-
const KIT_VERSION = "2.
|
|
1387
|
+
const KIT_VERSION = "2.35.0";
|
|
1387
1388
|
/**
|
|
1388
1389
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1389
1390
|
*
|
|
@@ -1726,7 +1727,7 @@ function useKitUpdate() {
|
|
|
1726
1727
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1727
1728
|
}).catch(() => {}), () => controller.abort();
|
|
1728
1729
|
}, []);
|
|
1729
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.
|
|
1730
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.35.0") > 0);
|
|
1730
1731
|
return {
|
|
1731
1732
|
current: KIT_VERSION,
|
|
1732
1733
|
latest,
|
|
@@ -2923,6 +2924,42 @@ function SharePreview() {
|
|
|
2923
2924
|
})
|
|
2924
2925
|
}) : null;
|
|
2925
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
|
+
}
|
|
2926
2963
|
const isObj$1 = (v) => typeof v == "object" && !!v && !Array.isArray(v);
|
|
2927
2964
|
/** Textes d'une valeur, dans l'ordre. */
|
|
2928
2965
|
function collectTexts$1(value) {
|
|
@@ -3232,7 +3269,7 @@ async function createTranslatedVersion(opts) {
|
|
|
3232
3269
|
} catch (cause) {
|
|
3233
3270
|
aiError = cause instanceof Error ? cause.message : String(cause);
|
|
3234
3271
|
}
|
|
3235
|
-
doc[field] = language;
|
|
3272
|
+
doc[field] = language, Object.assign(doc, await localizeReferences(client, doc, language));
|
|
3236
3273
|
let pageType = config.pageTypes.find((t) => t.type === type), slugField = pageType?.slugField ?? (source.slug?.current ? "slug" : null);
|
|
3237
3274
|
if (slugField && source[slugField]?.current) {
|
|
3238
3275
|
let titleField = pageType?.titleField ?? "title", base = slugify(typeof doc[titleField] == "string" ? doc[titleField] : "") || String(source[slugField].current), slug = base;
|
|
@@ -9129,7 +9166,7 @@ function PropagateDialog(props) {
|
|
|
9129
9166
|
created.aiError && (aiError = created.aiError), (created.published ? published : drafted).push(t.language.toUpperCase());
|
|
9130
9167
|
continue;
|
|
9131
9168
|
}
|
|
9132
|
-
let { _id, _rev, _createdAt, _updatedAt, ...
|
|
9169
|
+
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 = [];
|
|
9133
9170
|
if (ai && config.history && remaining.length) {
|
|
9134
9171
|
let toDo = remaining.filter((p) => !kept.includes(p));
|
|
9135
9172
|
try {
|
|
@@ -9451,35 +9488,103 @@ function NcfPreviewHeader(props) {
|
|
|
9451
9488
|
function ncfPreviewComponents() {
|
|
9452
9489
|
return { unstable_header: { component: NcfPreviewHeader } };
|
|
9453
9490
|
}
|
|
9454
|
-
|
|
9491
|
+
/** Appareils proposés (dimensions CSS de l'écran, portrait). */
|
|
9492
|
+
const PREVIEW_DEVICES = [
|
|
9493
|
+
{
|
|
9494
|
+
id: "iphone-se",
|
|
9495
|
+
label: "iPhone SE",
|
|
9496
|
+
width: 375,
|
|
9497
|
+
height: 667
|
|
9498
|
+
},
|
|
9499
|
+
{
|
|
9500
|
+
id: "iphone-12-pro",
|
|
9501
|
+
label: "iPhone 12 Pro",
|
|
9502
|
+
width: 390,
|
|
9503
|
+
height: 844
|
|
9504
|
+
},
|
|
9505
|
+
{
|
|
9506
|
+
id: "iphone-15-pro-max",
|
|
9507
|
+
label: "iPhone 15 Pro Max",
|
|
9508
|
+
width: 430,
|
|
9509
|
+
height: 932
|
|
9510
|
+
},
|
|
9511
|
+
{
|
|
9512
|
+
id: "pixel-7",
|
|
9513
|
+
label: "Pixel 7",
|
|
9514
|
+
width: 412,
|
|
9515
|
+
height: 915
|
|
9516
|
+
},
|
|
9517
|
+
{
|
|
9518
|
+
id: "galaxy-s20",
|
|
9519
|
+
label: "Galaxy S20",
|
|
9520
|
+
width: 360,
|
|
9521
|
+
height: 800
|
|
9522
|
+
},
|
|
9523
|
+
{
|
|
9524
|
+
id: "ipad-mini",
|
|
9525
|
+
label: "iPad Mini",
|
|
9526
|
+
width: 768,
|
|
9527
|
+
height: 1024
|
|
9528
|
+
},
|
|
9529
|
+
{
|
|
9530
|
+
id: "ipad-air",
|
|
9531
|
+
label: "iPad Air",
|
|
9532
|
+
width: 820,
|
|
9533
|
+
height: 1180
|
|
9534
|
+
},
|
|
9535
|
+
{
|
|
9536
|
+
id: "ipad-pro-11",
|
|
9537
|
+
label: "iPad Pro 11\"",
|
|
9538
|
+
width: 834,
|
|
9539
|
+
height: 1194
|
|
9540
|
+
},
|
|
9541
|
+
{
|
|
9542
|
+
id: "ipad-pro-13",
|
|
9543
|
+
label: "iPad Pro 12.9\"",
|
|
9544
|
+
width: 1024,
|
|
9545
|
+
height: 1366
|
|
9546
|
+
}
|
|
9547
|
+
], KEY_DEVICE = "ncf.presentation.device", KEY_HIDE = "ncf.presentation.hideForm", read = (key) => {
|
|
9455
9548
|
try {
|
|
9456
|
-
return window.localStorage.getItem(key)
|
|
9549
|
+
return window.localStorage.getItem(key);
|
|
9457
9550
|
} catch {
|
|
9458
|
-
return
|
|
9551
|
+
return null;
|
|
9459
9552
|
}
|
|
9460
|
-
},
|
|
9553
|
+
}, write = (key, value) => {
|
|
9461
9554
|
try {
|
|
9462
|
-
window.localStorage.setItem(key,
|
|
9555
|
+
value === null ? window.localStorage.removeItem(key) : window.localStorage.setItem(key, value);
|
|
9463
9556
|
} catch {}
|
|
9464
9557
|
}, previewPanel = () => document.getElementById("presentation-narrow-panel-preview"), contentPanel = () => document.getElementById("presentation-narrow-panel-content");
|
|
9465
9558
|
/**
|
|
9466
|
-
* En-tête de l'aperçu (Presentation) : la barre
|
|
9467
|
-
* -
|
|
9468
|
-
*
|
|
9469
|
-
*
|
|
9470
|
-
*
|
|
9559
|
+
* En-tête de l'aperçu (Presentation) : la barre native, plus
|
|
9560
|
+
* - un menu d'APPAREILS, posé juste à côté du bouton mobile natif : iPhone 12 Pro
|
|
9561
|
+
* (390×844), iPad Air (820×1180)... L'aperçu prend les dimensions de l'appareil,
|
|
9562
|
+
* affichées à côté de l'icône ;
|
|
9563
|
+
* - « Hide edit panel » : masque le formulaire à droite (la liste des pages reste).
|
|
9564
|
+
* Choix mémorisés dans le navigateur. Seulement l'affichage : aucune donnée touchée.
|
|
9471
9565
|
*/
|
|
9472
9566
|
function NcfPresentationHeader(props) {
|
|
9473
|
-
let ref = useRef(null), [
|
|
9474
|
-
|
|
9475
|
-
let
|
|
9476
|
-
if (
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9567
|
+
let ref = useRef(null), [deviceId, setDeviceId] = useState(() => read(KEY_DEVICE) ?? null), [hideForm, setHideForm] = useState(() => read(KEY_HIDE) === "1"), [slot, setSlot] = useState(null), device = PREVIEW_DEVICES.find((d) => d.id === deviceId) ?? null;
|
|
9568
|
+
useLayoutEffect(() => {
|
|
9569
|
+
let root = ref.current, button = (root?.querySelector("[data-sanity-icon=\"mobile-device\"], [data-sanity-icon=\"desktop\"]"))?.closest("button") ?? null;
|
|
9570
|
+
if (!button) return;
|
|
9571
|
+
let target = root?.querySelector("[data-ncf-device-slot]") ?? null;
|
|
9572
|
+
target || (target = document.createElement("span"), target.setAttribute("data-ncf-device-slot", ""), target.style.display = "inline-flex", button.insertAdjacentElement("afterend", target)), target !== slot && setSlot(target);
|
|
9573
|
+
}), useEffect(() => {
|
|
9574
|
+
let iframe = previewPanel()?.querySelector("iframe") ?? null;
|
|
9575
|
+
if (!iframe || !device) return;
|
|
9576
|
+
let set = [
|
|
9577
|
+
["width", `${device.width}px`],
|
|
9578
|
+
["max-width", "100%"],
|
|
9579
|
+
["height", `${device.height}px`],
|
|
9580
|
+
["margin-left", "auto"],
|
|
9581
|
+
["margin-right", "auto"],
|
|
9582
|
+
["display", "block"],
|
|
9583
|
+
["flex", "none"]
|
|
9584
|
+
];
|
|
9585
|
+
for (let [p, v] of set) iframe.style.setProperty(p, v, "important");
|
|
9586
|
+
return () => {
|
|
9587
|
+
for (let [p] of set) iframe.style.removeProperty(p);
|
|
9483
9588
|
};
|
|
9484
9589
|
}), useEffect(() => {
|
|
9485
9590
|
let panel = previewPanel(), content = contentPanel();
|
|
@@ -9499,7 +9604,39 @@ function NcfPresentationHeader(props) {
|
|
|
9499
9604
|
observer.disconnect();
|
|
9500
9605
|
for (let h of hidden) h.style.removeProperty("display");
|
|
9501
9606
|
};
|
|
9502
|
-
})
|
|
9607
|
+
});
|
|
9608
|
+
let choose = (id) => {
|
|
9609
|
+
setDeviceId(id), write(KEY_DEVICE, id);
|
|
9610
|
+
}, deviceMenu = /* @__PURE__ */ jsx(MenuButton, {
|
|
9611
|
+
id: "ncf-preview-device",
|
|
9612
|
+
button: /* @__PURE__ */ jsx(Button, {
|
|
9613
|
+
icon: TabletDeviceIcon,
|
|
9614
|
+
text: device ? `${device.width}×${device.height}` : void 0,
|
|
9615
|
+
mode: device ? "default" : "bleed",
|
|
9616
|
+
tone: device ? "primary" : "default",
|
|
9617
|
+
padding: 2,
|
|
9618
|
+
fontSize: 1,
|
|
9619
|
+
title: device ? `${device.label} (${device.width}×${device.height})` : "Preview on a device"
|
|
9620
|
+
}),
|
|
9621
|
+
menu: /* @__PURE__ */ jsxs(Menu, { children: [
|
|
9622
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
9623
|
+
text: "Full width",
|
|
9624
|
+
pressed: !device,
|
|
9625
|
+
onClick: () => choose(null)
|
|
9626
|
+
}),
|
|
9627
|
+
/* @__PURE__ */ jsx(MenuDivider, {}),
|
|
9628
|
+
PREVIEW_DEVICES.map((d) => /* @__PURE__ */ jsx(MenuItem, {
|
|
9629
|
+
text: `${d.label} ${d.width}×${d.height}`,
|
|
9630
|
+
pressed: d.id === deviceId,
|
|
9631
|
+
onClick: () => choose(d.id)
|
|
9632
|
+
}, d.id))
|
|
9633
|
+
] }),
|
|
9634
|
+
popover: {
|
|
9635
|
+
portal: !0,
|
|
9636
|
+
placement: "bottom-end"
|
|
9637
|
+
}
|
|
9638
|
+
});
|
|
9639
|
+
return /* @__PURE__ */ jsxs(Flex, {
|
|
9503
9640
|
ref,
|
|
9504
9641
|
align: "center",
|
|
9505
9642
|
gap: 1,
|
|
@@ -9510,18 +9647,7 @@ function NcfPresentationHeader(props) {
|
|
|
9510
9647
|
style: { minWidth: 0 },
|
|
9511
9648
|
children: props.renderDefault(props)
|
|
9512
9649
|
}),
|
|
9513
|
-
|
|
9514
|
-
icon: TabletDeviceIcon,
|
|
9515
|
-
mode: tablet ? "default" : "bleed",
|
|
9516
|
-
tone: tablet ? "primary" : "default",
|
|
9517
|
-
padding: 2,
|
|
9518
|
-
fontSize: 1,
|
|
9519
|
-
title: tablet ? "Back to full width" : "Tablet (768px)",
|
|
9520
|
-
"aria-pressed": tablet,
|
|
9521
|
-
onClick: () => {
|
|
9522
|
-
setTablet(!tablet), save(KEY_TABLET, !tablet);
|
|
9523
|
-
}
|
|
9524
|
-
}),
|
|
9650
|
+
slot ? createPortal(deviceMenu, slot) : deviceMenu,
|
|
9525
9651
|
/* @__PURE__ */ jsx(Button, {
|
|
9526
9652
|
icon: PanelRightIcon,
|
|
9527
9653
|
mode: hideForm ? "default" : "bleed",
|
|
@@ -9531,7 +9657,7 @@ function NcfPresentationHeader(props) {
|
|
|
9531
9657
|
title: hideForm ? "Show edit panel" : "Hide edit panel",
|
|
9532
9658
|
"aria-pressed": hideForm,
|
|
9533
9659
|
onClick: () => {
|
|
9534
|
-
setHideForm(!hideForm),
|
|
9660
|
+
setHideForm(!hideForm), write(KEY_HIDE, hideForm ? "0" : "1");
|
|
9535
9661
|
}
|
|
9536
9662
|
})
|
|
9537
9663
|
]
|
|
@@ -9840,12 +9966,17 @@ const ncfKit = definePlugin((options) => {
|
|
|
9840
9966
|
},
|
|
9841
9967
|
document: {
|
|
9842
9968
|
newDocumentOptions: (prev) => prev.filter((option) => option.templateId !== BOARD_LAYOUT_TYPE),
|
|
9843
|
-
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
|
|
9969
|
+
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) : 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) : prev
|
|
9844
9970
|
},
|
|
9845
9971
|
studio: { components: { toolMenu: createPreviewLauncher(config, issues) } },
|
|
9846
9972
|
form: { components: { input: createKitInput(config) } }
|
|
9847
9973
|
};
|
|
9848
9974
|
});
|
|
9975
|
+
/** Le type de document porte-t-il le champ de langue (traduit document par document) ? */
|
|
9976
|
+
function hasLanguageField(schemaType, field) {
|
|
9977
|
+
let fields = schemaType?.fields;
|
|
9978
|
+
return Array.isArray(fields) && fields.some((f) => f?.name === field);
|
|
9979
|
+
}
|
|
9849
9980
|
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 };
|
|
9850
9981
|
|
|
9851
9982
|
//# sourceMappingURL=index.js.map
|