@nocode-factory/sanity-kit 2.30.1 → 2.32.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/bin/ncf-kit.mjs CHANGED
@@ -303,6 +303,9 @@ async function doctor() {
303
303
  const config = ['sanity.config.ts', 'sanity.config.tsx', 'sanity.config.js'].map((f) => read(join(studio, f))).find(Boolean) ?? ''
304
304
  if (!config.includes('ncfKit(')) ko('Plugin', 'ncfKit(...) absent de sanity.config')
305
305
  else ok('Plugin', 'ncfKit branché')
306
+ if (!config.includes('ncfPresentationComponents('))
307
+ warn('Presentation : liste des pages', "le kit a besoin de ncfPresentationComponents dans presentationTool pour afficher la liste des pages à gauche de l'aperçu ; le projet ne l'a pas : presentationTool({components: ncfPresentationComponents(ncfOptions), ...}).")
308
+ else ok('Presentation : liste des pages', 'ncfPresentationComponents')
306
309
  if (!config.includes('ncfAllowedOrigins')) ko('Origines autorisées', "presentationTool sans allowOrigins: ncfAllowedOrigins(options) : l'aperçu de la préproduction s'affiche mais reste muet.")
307
310
  else ok('Origines autorisées', 'ncfAllowedOrigins')
308
311
  if (/preprodUrl\s*:\s*false/.test(config)) ko('Préproduction désactivée', "sanity.config contient preprodUrl: false : la préproduction conventionnelle est retirée. À n'utiliser que si le projet n'en a vraiment pas.")
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as defineComponentDefaults, i as defaultsFieldName, n as componentDefaultsMainDocument, o as requiredUnlessDefault, r as componentDefaultsMainDocuments, s as requiredUnlessDefaultFor, t as DEFAULT_COMPONENT_DEFAULTS_TYPE } from "./componentDefaults-CNiuukLt.js";
2
- import { ReactNode } from "react";
2
+ import { ComponentType, ReactNode } from "react";
3
3
  import { SanityClient, Schema, Tool, ToolMenuProps } from "sanity";
4
4
  import { PreviewHeaderProps } from "sanity/presentation";
5
5
  /**
@@ -1158,6 +1158,21 @@ export declare function ncfPreviewComponents(): {
1158
1158
  component: typeof NcfPreviewHeader;
1159
1159
  };
1160
1160
  };
1161
+ /**
1162
+ * Composants à passer à `presentationTool` : liste des pages à gauche de l'aperçu
1163
+ * (bouton intégré de Presentation pour l'afficher ou la masquer).
1164
+ *
1165
+ * ```ts
1166
+ * presentationTool({components: ncfPresentationComponents(ncfOptions), ...})
1167
+ * ```
1168
+ */
1169
+ export declare function ncfPresentationComponents(options: NcfKitConfig): {
1170
+ unstable_navigator: {
1171
+ component: ComponentType;
1172
+ minWidth: number;
1173
+ maxWidth: number;
1174
+ };
1175
+ };
1161
1176
  /**
1162
1177
  * Lanceur d'aperçu, posé dans la barre du haut à droite des outils.
1163
1178
  *
@@ -1361,7 +1376,7 @@ export declare function ActorName(props: {
1361
1376
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1362
1377
  * le vérifie.
1363
1378
  */
1364
- export declare const KIT_VERSION = "2.30.1";
1379
+ export declare const KIT_VERSION = "2.32.0";
1365
1380
  /**
1366
1381
  * Données de la page proposées comme colonnes.
1367
1382
  *
package/dist/index.js CHANGED
@@ -1084,13 +1084,13 @@ function onlineUrl(environment, perspective, options = {}) {
1084
1084
  * dans le paramètre `preview`, et la perspective dans `perspective`.
1085
1085
  */
1086
1086
  function presentationPath(url, options = {}) {
1087
- let target = options.environment ? urlOn(options.environment, pathOf(url)) : url;
1087
+ let target = options.environment ? urlOn(options.environment, pathOf$1(url)) : url;
1088
1088
  if (!target) return null;
1089
1089
  let params = new URLSearchParams({ preview: target });
1090
1090
  return options.perspective && options.perspective !== "drafts" && params.set("perspective", options.perspective), `/presentation?${params.toString()}`;
1091
1091
  }
1092
1092
  /** Chemin d'une URL absolue, ou la valeur telle quelle si elle est relative. */
1093
- function pathOf(url) {
1093
+ function pathOf$1(url) {
1094
1094
  if (!url) return null;
1095
1095
  try {
1096
1096
  return new URL(url).pathname;
@@ -1381,7 +1381,7 @@ function explainGrantError(error) {
1381
1381
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1382
1382
  * le vérifie.
1383
1383
  */
1384
- const KIT_VERSION = "2.30.1";
1384
+ const KIT_VERSION = "2.32.0";
1385
1385
  /**
1386
1386
  * Signale ce Studio au service du kit, une fois par montage.
1387
1387
  *
@@ -1724,7 +1724,7 @@ function useKitUpdate() {
1724
1724
  !controller.signal.aborted && body?.version && setLatest(body.version);
1725
1725
  }).catch(() => {}), () => controller.abort();
1726
1726
  }, []);
1727
- let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.30.1") > 0);
1727
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.32.0") > 0);
1728
1728
  return {
1729
1729
  current: KIT_VERSION,
1730
1730
  latest,
@@ -8494,13 +8494,23 @@ function createOverrideInput(config) {
8494
8494
  })
8495
8495
  ]
8496
8496
  }),
8497
- inherits && placeholder === null && /* @__PURE__ */ jsx(Box, {
8497
+ inherits && placeholder === null && /* @__PURE__ */ jsxs(Flex, {
8498
+ align: "center",
8499
+ gap: 2,
8498
8500
  marginTop: 2,
8499
- children: /* @__PURE__ */ jsxs(Text, {
8501
+ wrap: "wrap",
8502
+ children: [/* @__PURE__ */ jsxs(Text, {
8500
8503
  size: 0,
8501
8504
  muted: !0,
8502
8505
  children: ["Component default value: ", describeValue(inherited)]
8503
- })
8506
+ }), Array.isArray(inherited) && !inputProps.readOnly && /* @__PURE__ */ jsx(Button, {
8507
+ mode: "ghost",
8508
+ tone: "primary",
8509
+ fontSize: 0,
8510
+ padding: 2,
8511
+ text: "Edit default items",
8512
+ onClick: () => inputProps.onChange(set(structuredClone(inherited)))
8513
+ })]
8504
8514
  })
8505
8515
  ]
8506
8516
  }), override && !inputProps.readOnly && /* @__PURE__ */ jsx(OverrideDot, {
@@ -9439,6 +9449,156 @@ function NcfPreviewHeader(props) {
9439
9449
  function ncfPreviewComponents() {
9440
9450
  return { unstable_header: { component: NcfPreviewHeader } };
9441
9451
  }
9452
+ const pathOf = (preview) => {
9453
+ if (!preview) return null;
9454
+ try {
9455
+ return new URL(preview, "http://preview.local").pathname.replace(/\/$/, "") || "/";
9456
+ } catch {
9457
+ return null;
9458
+ }
9459
+ };
9460
+ /**
9461
+ * Liste des pages à gauche de l'aperçu (Presentation) : passer d'une page à l'autre
9462
+ * sans repasser par Structure. Langue de la page affichée par défaut, recherche par
9463
+ * titre ou adresse ; un clic ouvre la page dans l'aperçu ET son document à côté.
9464
+ */
9465
+ function PagesNavigator() {
9466
+ let config = useKitConfig(), { rows, loading } = usePages(), params = usePresentationParams(!1), navigate = usePresentationNavigate(), i18n = config.i18n, shownLocale = localeOfPreview(params?.preview, i18n), [locale, setLocale] = useState(null), [search, setSearch] = useState(""), activeLocale = locale ?? shownLocale ?? "", current = pathOf(params?.preview), visible = useMemo(() => {
9467
+ let q = search.trim().toLowerCase();
9468
+ return rows.filter((r) => r.path !== null).filter((r) => !i18n || !activeLocale || r.locale === activeLocale).filter((r) => !q || r.title.toLowerCase().includes(q) || (r.path ?? "").toLowerCase().includes(q)).sort((a, b) => (a.path ?? "").localeCompare(b.path ?? ""));
9469
+ }, [
9470
+ rows,
9471
+ search,
9472
+ activeLocale,
9473
+ i18n
9474
+ ]);
9475
+ return /* @__PURE__ */ jsxs(Card, {
9476
+ height: "fill",
9477
+ borderRight: !0,
9478
+ style: {
9479
+ display: "flex",
9480
+ flexDirection: "column",
9481
+ minHeight: 0
9482
+ },
9483
+ children: [/* @__PURE__ */ jsxs(Stack, {
9484
+ gap: 2,
9485
+ padding: 2,
9486
+ style: { flex: "none" },
9487
+ children: [/* @__PURE__ */ jsx(Text, {
9488
+ size: 1,
9489
+ weight: "semibold",
9490
+ children: "Pages"
9491
+ }), /* @__PURE__ */ jsxs(Flex, {
9492
+ gap: 2,
9493
+ children: [/* @__PURE__ */ jsx(Box, {
9494
+ flex: 1,
9495
+ children: /* @__PURE__ */ jsx(TextInput, {
9496
+ icon: SearchIcon,
9497
+ fontSize: 1,
9498
+ padding: 2,
9499
+ placeholder: "Search",
9500
+ value: search,
9501
+ onChange: (e) => setSearch(e.currentTarget.value)
9502
+ })
9503
+ }), i18n && i18n.locales.length > 1 && /* @__PURE__ */ jsx(Select, {
9504
+ fontSize: 1,
9505
+ padding: 2,
9506
+ value: activeLocale,
9507
+ onChange: (e) => setLocale(e.currentTarget.value),
9508
+ style: { width: 72 },
9509
+ children: i18n.locales.map((code) => /* @__PURE__ */ jsx("option", {
9510
+ value: code,
9511
+ children: code.toUpperCase()
9512
+ }, code))
9513
+ })]
9514
+ })]
9515
+ }), /* @__PURE__ */ jsx(Box, {
9516
+ flex: 1,
9517
+ style: {
9518
+ overflowY: "auto",
9519
+ minHeight: 0
9520
+ },
9521
+ children: loading && !rows.length ? /* @__PURE__ */ jsx(Flex, {
9522
+ justify: "center",
9523
+ padding: 4,
9524
+ children: /* @__PURE__ */ jsx(Spinner, { muted: !0 })
9525
+ }) : /* @__PURE__ */ jsxs(Stack, {
9526
+ gap: 1,
9527
+ padding: 1,
9528
+ children: [visible.map((row) => {
9529
+ let selected = current !== null && current === ((row.path ?? "").replace(/\/$/, "") || "/");
9530
+ return /* @__PURE__ */ jsx(Card, {
9531
+ as: "button",
9532
+ padding: 2,
9533
+ radius: 2,
9534
+ tone: selected ? "primary" : "default",
9535
+ pressed: selected,
9536
+ style: {
9537
+ textAlign: "left",
9538
+ cursor: "pointer",
9539
+ border: 0,
9540
+ width: "100%"
9541
+ },
9542
+ onClick: () => navigate(row.path ?? void 0, {
9543
+ type: row.type,
9544
+ id: row.id
9545
+ }),
9546
+ children: /* @__PURE__ */ jsxs(Flex, {
9547
+ align: "center",
9548
+ gap: 2,
9549
+ children: [/* @__PURE__ */ jsxs(Stack, {
9550
+ gap: 1,
9551
+ flex: 1,
9552
+ style: { minWidth: 0 },
9553
+ children: [/* @__PURE__ */ jsx(Text, {
9554
+ size: 1,
9555
+ weight: selected ? "semibold" : "regular",
9556
+ textOverflow: "ellipsis",
9557
+ children: row.title || row.path
9558
+ }), /* @__PURE__ */ jsx(Text, {
9559
+ size: 0,
9560
+ muted: !0,
9561
+ textOverflow: "ellipsis",
9562
+ children: row.path
9563
+ })]
9564
+ }), row.status !== "published" && /* @__PURE__ */ jsx(StatusBadge, { status: row.status })]
9565
+ })
9566
+ }, row.id);
9567
+ }), !visible.length && /* @__PURE__ */ jsx(Box, {
9568
+ padding: 3,
9569
+ children: /* @__PURE__ */ jsx(Text, {
9570
+ size: 1,
9571
+ muted: !0,
9572
+ children: "No page."
9573
+ })
9574
+ })]
9575
+ })
9576
+ })]
9577
+ });
9578
+ }
9579
+ /**
9580
+ * Composants à passer à `presentationTool` : liste des pages à gauche de l'aperçu
9581
+ * (bouton intégré de Presentation pour l'afficher ou la masquer).
9582
+ *
9583
+ * ```ts
9584
+ * presentationTool({components: ncfPresentationComponents(ncfOptions), ...})
9585
+ * ```
9586
+ */
9587
+ function ncfPresentationComponents(options) {
9588
+ let config = resolveConfig(options), issues = validateConfig(config);
9589
+ function NcfPagesNavigator() {
9590
+ return /* @__PURE__ */ jsx(KitProvider, {
9591
+ config,
9592
+ issues,
9593
+ children: /* @__PURE__ */ jsx(PagesNavigator, {})
9594
+ });
9595
+ }
9596
+ return { unstable_navigator: {
9597
+ component: NcfPagesNavigator,
9598
+ minWidth: 220,
9599
+ maxWidth: 420
9600
+ } };
9601
+ }
9442
9602
  const SAFE = /^[A-Za-z0-9_.-]+$/, quote = (value) => JSON.stringify(value);
9443
9603
  /**
9444
9604
  * Presentation : le document du panneau de droite est TOUJOURS celui de la page
@@ -9591,6 +9751,6 @@ const ncfKit = definePlugin((options) => {
9591
9751
  form: { components: { input: createKitInput(config) } }
9592
9752
  };
9593
9753
  });
9594
- 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, 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 };
9754
+ 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 };
9595
9755
 
9596
9756
  //# sourceMappingURL=index.js.map