@nocode-factory/sanity-kit 2.32.1 → 2.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1158,9 +1158,18 @@ export declare function ncfPreviewComponents(): {
1158
1158
  component: typeof NcfPreviewHeader;
1159
1159
  };
1160
1160
  };
1161
+ /**
1162
+ * En-tête de l'aperçu (Presentation) : la barre d'adresse native, plus
1163
+ * - « Tablet » : aperçu à 768 px, centré (Presentation n'a qu'ordinateur et mobile) ;
1164
+ * - « Hide edit panel » : masque le formulaire à droite, l'aperçu prend la place
1165
+ * (la liste des pages à gauche reste).
1166
+ * Choix mémorisés dans le navigateur. Aucune donnée touchée : seulement l'affichage.
1167
+ */
1168
+ declare function NcfPresentationHeader(props: PreviewHeaderProps): import("react").JSX.Element;
1161
1169
  /**
1162
1170
  * Composants à passer à `presentationTool` : liste des pages à gauche de l'aperçu
1163
- * (bouton intégré de Presentation pour l'afficher ou la masquer).
1171
+ * (bouton intégré de Presentation pour l'afficher ou la masquer), et en-tête avec
1172
+ * le format tablette et « Hide edit panel ».
1164
1173
  *
1165
1174
  * ```ts
1166
1175
  * presentationTool({components: ncfPresentationComponents(ncfOptions), ...})
@@ -1172,6 +1181,9 @@ export declare function ncfPresentationComponents(options: NcfKitConfig): {
1172
1181
  minWidth: number;
1173
1182
  maxWidth: number;
1174
1183
  };
1184
+ unstable_header: {
1185
+ component: typeof NcfPresentationHeader;
1186
+ };
1175
1187
  };
1176
1188
  /**
1177
1189
  * Lanceur d'aperçu, posé dans la barre du haut à droite des outils.
@@ -1376,7 +1388,7 @@ export declare function ActorName(props: {
1376
1388
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1377
1389
  * le vérifie.
1378
1390
  */
1379
- export declare const KIT_VERSION = "2.32.1";
1391
+ export declare const KIT_VERSION = "2.33.1";
1380
1392
  /**
1381
1393
  * Données de la page proposées comme colonnes.
1382
1394
  *
package/dist/index.js CHANGED
@@ -40,6 +40,8 @@ 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 { TabletDeviceIcon } from "@sanity/icons/TabletDevice";
44
+ import { PanelRightIcon } from "@sanity/icons/PanelRight";
43
45
  const trimTrailingSlash = (url) => url.replace(/\/+$/, ""), normalizePath = (path) => {
44
46
  let trimmed = path.trim();
45
47
  if (!trimmed || trimmed === "/") return "/";
@@ -1381,7 +1383,7 @@ function explainGrantError(error) {
1381
1383
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1382
1384
  * le vérifie.
1383
1385
  */
1384
- const KIT_VERSION = "2.32.1";
1386
+ const KIT_VERSION = "2.33.1";
1385
1387
  /**
1386
1388
  * Signale ce Studio au service du kit, une fois par montage.
1387
1389
  *
@@ -1724,7 +1726,7 @@ function useKitUpdate() {
1724
1726
  !controller.signal.aborted && body?.version && setLatest(body.version);
1725
1727
  }).catch(() => {}), () => controller.abort();
1726
1728
  }, []);
1727
- let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.32.1") > 0);
1729
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.33.1") > 0);
1728
1730
  return {
1729
1731
  current: KIT_VERSION,
1730
1732
  latest,
@@ -9449,6 +9451,94 @@ function NcfPreviewHeader(props) {
9449
9451
  function ncfPreviewComponents() {
9450
9452
  return { unstable_header: { component: NcfPreviewHeader } };
9451
9453
  }
9454
+ const KEY_TABLET = "ncf.presentation.tablet", KEY_HIDE = "ncf.presentation.hideForm", load = (key) => {
9455
+ try {
9456
+ return window.localStorage.getItem(key) === "1";
9457
+ } catch {
9458
+ return !1;
9459
+ }
9460
+ }, save = (key, on) => {
9461
+ try {
9462
+ window.localStorage.setItem(key, on ? "1" : "0");
9463
+ } catch {}
9464
+ }, previewPanel = () => document.getElementById("presentation-narrow-panel-preview"), contentPanel = () => document.getElementById("presentation-narrow-panel-content");
9465
+ /**
9466
+ * En-tête de l'aperçu (Presentation) : la barre d'adresse native, plus
9467
+ * - « Tablet » : aperçu à 768 px, centré (Presentation n'a qu'ordinateur et mobile) ;
9468
+ * - « Hide edit panel » : masque le formulaire à droite, l'aperçu prend la place
9469
+ * (la liste des pages à gauche reste).
9470
+ * Choix mémorisés dans le navigateur. Aucune donnée touchée : seulement l'affichage.
9471
+ */
9472
+ function NcfPresentationHeader(props) {
9473
+ let ref = useRef(null), [tablet, setTablet] = useState(() => load(KEY_TABLET)), [hideForm, setHideForm] = useState(() => load(KEY_HIDE));
9474
+ return useEffect(() => {
9475
+ let iframe = previewPanel()?.querySelector("iframe") ?? ref.current?.closest("div[style]")?.parentElement?.querySelector("iframe") ?? null;
9476
+ if (iframe) return tablet && (iframe.style.setProperty("max-width", "768px", "important"), iframe.style.setProperty("margin-left", "auto", "important"), iframe.style.setProperty("margin-right", "auto", "important"), iframe.style.setProperty("display", "block", "important")), () => {
9477
+ for (let p of [
9478
+ "max-width",
9479
+ "margin-left",
9480
+ "margin-right",
9481
+ "display"
9482
+ ]) iframe.style.removeProperty(p);
9483
+ };
9484
+ }), useEffect(() => {
9485
+ let panel = previewPanel(), content = contentPanel();
9486
+ if (!panel || !content || !hideForm) return;
9487
+ let hidden = [content], handle = content.previousElementSibling;
9488
+ handle && handle !== panel && !handle.id && hidden.push(handle);
9489
+ let apply = () => {
9490
+ for (let h of hidden) h.style.getPropertyValue("display") !== "none" && h.style.setProperty("display", "none", "important");
9491
+ panel.style.getPropertyPriority("flex-grow") !== "important" && panel.style.setProperty("flex-grow", "1000", "important");
9492
+ };
9493
+ apply();
9494
+ let observer = new MutationObserver(apply);
9495
+ for (let el of [panel, ...hidden]) observer.observe(el, {
9496
+ attributes: !0,
9497
+ attributeFilter: ["style"]
9498
+ });
9499
+ return () => {
9500
+ observer.disconnect();
9501
+ for (let h of hidden) h.style.removeProperty("display");
9502
+ panel.style.removeProperty("flex-grow");
9503
+ };
9504
+ }), /* @__PURE__ */ jsxs(Flex, {
9505
+ ref,
9506
+ align: "center",
9507
+ gap: 1,
9508
+ style: { width: "100%" },
9509
+ children: [
9510
+ /* @__PURE__ */ jsx(Box, {
9511
+ flex: 1,
9512
+ style: { minWidth: 0 },
9513
+ children: props.renderDefault(props)
9514
+ }),
9515
+ /* @__PURE__ */ jsx(Button, {
9516
+ icon: TabletDeviceIcon,
9517
+ mode: tablet ? "default" : "bleed",
9518
+ tone: tablet ? "primary" : "default",
9519
+ padding: 2,
9520
+ fontSize: 1,
9521
+ title: tablet ? "Back to full width" : "Tablet (768px)",
9522
+ "aria-pressed": tablet,
9523
+ onClick: () => {
9524
+ setTablet(!tablet), save(KEY_TABLET, !tablet);
9525
+ }
9526
+ }),
9527
+ /* @__PURE__ */ jsx(Button, {
9528
+ icon: PanelRightIcon,
9529
+ mode: hideForm ? "default" : "bleed",
9530
+ tone: hideForm ? "primary" : "default",
9531
+ padding: 2,
9532
+ fontSize: 1,
9533
+ title: hideForm ? "Show edit panel" : "Hide edit panel",
9534
+ "aria-pressed": hideForm,
9535
+ onClick: () => {
9536
+ setHideForm(!hideForm), save(KEY_HIDE, !hideForm);
9537
+ }
9538
+ })
9539
+ ]
9540
+ });
9541
+ }
9452
9542
  const pathOf = (preview) => {
9453
9543
  if (!preview) return null;
9454
9544
  try {
@@ -9578,7 +9668,8 @@ function PagesNavigator() {
9578
9668
  }
9579
9669
  /**
9580
9670
  * Composants à passer à `presentationTool` : liste des pages à gauche de l'aperçu
9581
- * (bouton intégré de Presentation pour l'afficher ou la masquer).
9671
+ * (bouton intégré de Presentation pour l'afficher ou la masquer), et en-tête avec
9672
+ * le format tablette et « Hide edit panel ».
9582
9673
  *
9583
9674
  * ```ts
9584
9675
  * presentationTool({components: ncfPresentationComponents(ncfOptions), ...})
@@ -9593,11 +9684,14 @@ function ncfPresentationComponents(options) {
9593
9684
  children: /* @__PURE__ */ jsx(PagesNavigator, {})
9594
9685
  });
9595
9686
  }
9596
- return { unstable_navigator: {
9597
- component: NcfPagesNavigator,
9598
- minWidth: 220,
9599
- maxWidth: 420
9600
- } };
9687
+ return {
9688
+ unstable_navigator: {
9689
+ component: NcfPagesNavigator,
9690
+ minWidth: 220,
9691
+ maxWidth: 420
9692
+ },
9693
+ unstable_header: { component: NcfPresentationHeader }
9694
+ };
9601
9695
  }
9602
9696
  const SAFE = /^[A-Za-z0-9_.-]+$/, quote = (value) => JSON.stringify(value);
9603
9697
  /**