@nocode-factory/sanity-kit 2.45.0 → 2.46.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
@@ -1,6 +1,6 @@
1
1
  import { A as ResolvedDocumentColumn, C as NcfInternalFieldOption, D as NcfToolName, E as NcfPageTypeInput, M as ResolvedI18n, N as ResolvedKitConfig, O as NcfToolsConfig, P as ResolvedPageType, S as NcfInternalField, T as NcfPageTypeConfig, _ as NcfComponentPreviewConfig, a as pageTypesFromSiteRoutes, b as NcfHistoryConfig, c as componentDefaultsMainDocuments, d as requiredUnlessDefault, f as requiredUnlessDefaultFor, g as NcfBoardTag, h as KitContextValue, i as SiteRoutesRegistry, j as ResolvedHistory, k as ResolvedComponentPreview, l as defaultsFieldName, m as IssueLevel, n as fixCrossLanguageReferences, o as DEFAULT_COMPONENT_DEFAULTS_TYPE, p as ConfigIssue, r as withSameLanguageReferences, s as componentDefaultsMainDocument, t as CrossLanguageReport, u as defineComponentDefaults, v as NcfDocumentColumn, w as NcfKitConfig, x as NcfI18nConfig, y as NcfEnvironment } from "./fixCrossLanguageReferences-CFZax-Nb.js";
2
2
  import { ComponentType, ReactNode } from "react";
3
- import { SanityClient, Schema, Tool, ToolMenuProps } from "sanity";
3
+ import { LayoutProps, SanityClient, Schema, Tool, ToolMenuProps } from "sanity";
4
4
  import { PreviewHeaderProps } from "sanity/presentation";
5
5
  /** Garantit un chemin absolu ('accueil' -> '/accueil', '' -> '/'). */
6
6
  export declare const normalizePath: (path: string) => string;
@@ -889,6 +889,11 @@ export declare function createPreviewLauncher(config: ResolvedKitConfig, issues:
889
889
  export declare function NcfKitUpdate(props: {
890
890
  inline?: boolean;
891
891
  }): import("react").JSX.Element | null;
892
+ /**
893
+ * Posé sur `studio.components.layout` : rend le Studio tel quel, et ajoute la
894
+ * feuille de style. Un seul `<style>` pour tout le Studio.
895
+ */
896
+ export declare function HelpTextStyle(props: LayoutProps): import("react").JSX.Element;
892
897
  interface KitUpdate {
893
898
  current: string;
894
899
  latest: string | null;
@@ -1059,7 +1064,7 @@ export declare function ActorName(props: {
1059
1064
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1060
1065
  * le vérifie.
1061
1066
  */
1062
- export declare const KIT_VERSION = "2.45.0";
1067
+ export declare const KIT_VERSION = "2.46.1";
1063
1068
  /**
1064
1069
  * Données de la page proposées comme colonnes.
1065
1070
  *
package/dist/index.js CHANGED
@@ -977,6 +977,20 @@ function pathOf$1(url) {
977
977
  return url.startsWith("/") ? url : `/${url}`;
978
978
  }
979
979
  }
980
+ /**
981
+ * Chemin de la page actuellement montrée dans Presentation.
982
+ *
983
+ * Presentation garde l'adresse prévisualisée dans le paramètre `preview` de
984
+ * l'URL du Studio — une URL complète (`https://site.fr/a-propos`) ou un chemin.
985
+ * Le lanceur s'en sert pour rouvrir la MÊME page sur un autre environnement,
986
+ * au lieu de retomber sur l'accueil.
987
+ *
988
+ * Rend `null` hors de Presentation, ou si le paramètre est absent.
989
+ */
990
+ function previewPathFromLocation(search) {
991
+ let preview = new URLSearchParams(search).get("preview");
992
+ return preview ? pathOf$1(preview) : null;
993
+ }
980
994
  /** Lien d'édition classique, pour les cas où l'on veut le formulaire. */
981
995
  function editIntentPath(id, type) {
982
996
  return `/intent/edit/id=${encodeURIComponent(id)};type=${encodeURIComponent(type)}/`;
@@ -1260,7 +1274,7 @@ function explainGrantError(error) {
1260
1274
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1261
1275
  * le vérifie.
1262
1276
  */
1263
- const KIT_VERSION = "2.45.0";
1277
+ const KIT_VERSION = "2.46.1";
1264
1278
  /**
1265
1279
  * Signale ce Studio au service du kit, une fois par montage.
1266
1280
  *
@@ -1603,7 +1617,7 @@ function useKitUpdate() {
1603
1617
  !controller.signal.aborted && body?.version && setLatest(body.version);
1604
1618
  }).catch(() => {}), () => controller.abort();
1605
1619
  }, []);
1606
- let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.45.0") > 0);
1620
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.46.1") > 0);
1607
1621
  return {
1608
1622
  current: KIT_VERSION,
1609
1623
  latest,
@@ -1861,13 +1875,17 @@ function NcfPreviewLauncher(props) {
1861
1875
  }), /* @__PURE__ */ jsx(NcfKitUpdate, { inline: props.context === "topbar" })]
1862
1876
  });
1863
1877
  let openInStudio = (environment, perspective) => {
1864
- let target = editableEnvironment(environment, environments, config.previewUrl) ?? environment, shown = isPublicEnvironment(environment, config.previewUrl) ? "published" : perspective, path = presentationPath(target.url, {
1878
+ let target = editableEnvironment(environment, environments, config.previewUrl) ?? environment, shown = isPublicEnvironment(environment, config.previewUrl) ? "published" : perspective, path = presentationPath((typeof window > "u" ? null : previewPathFromLocation(window.location.search)) ?? target.url, {
1865
1879
  environment: target,
1866
1880
  perspective: shown
1867
1881
  });
1868
1882
  path && router.navigateUrl({ path });
1869
1883
  }, openOnline = (environment, perspective) => {
1870
- open(environment, { perspective });
1884
+ let current = typeof window > "u" ? null : previewPathFromLocation(window.location.search);
1885
+ open(environment, {
1886
+ perspective,
1887
+ path: current
1888
+ });
1871
1889
  }, inline = props.context === "topbar";
1872
1890
  return /* @__PURE__ */ jsxs(Flex, {
1873
1891
  align: inline ? "center" : "stretch",
@@ -1975,6 +1993,16 @@ function createPreviewLauncher(config, issues) {
1975
1993
  };
1976
1994
  }
1977
1995
  /**
1996
+ * Posé sur `studio.components.layout` : rend le Studio tel quel, et ajoute la
1997
+ * feuille de style. Un seul `<style>` pour tout le Studio.
1998
+ */
1999
+ function HelpTextStyle(props) {
2000
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("style", {
2001
+ "data-ncf": "help-text",
2002
+ children: "\n[id^=\"desc_\"] {\n font-size: 0.72rem !important;\n font-style: italic !important;\n line-height: 1.45 !important;\n opacity: 0.72;\n}\n"
2003
+ }), props.renderDefault(props)] });
2004
+ }
2005
+ /**
1978
2006
  * RÈGLE D'OR : URL finales. Le site (starter : /api/url-check) appelle chaque URL de
1979
2007
  * sa sitemap et chaque redirection du Studio ; ce bandeau prévient l'équipe quand
1980
2008
  * une page de la sitemap répond 301 / 308 / 404, ou qu'une redirection fait deux
@@ -8392,6 +8420,24 @@ function shortValue(value, max = 32) {
8392
8420
  return d.length > max ? `${d.slice(0, max - 1)}…` : d;
8393
8421
  }
8394
8422
  /**
8423
+ * Un champ hérité doit-il afficher la valeur par défaut **pré-sélectionnée**
8424
+ * dans son contrôle ?
8425
+ *
8426
+ * Oui pour un choix (liste d'options : style, taille, position, niveau de
8427
+ * titre…) et pour une case à cocher : l'éditeur voit ce qui s'appliquera, au
8428
+ * lieu d'un contrôle vide doublé d'une mention. La valeur n'est pas écrite —
8429
+ * le champ reste vide, donc hérité ; choisir autre chose l'emporte et fait
8430
+ * apparaître la pastille de réinitialisation.
8431
+ *
8432
+ * Non pour le texte libre (déjà traité par un placeholder grisé) ni pour les
8433
+ * objets, listes et images (pas de « valeur sélectionnée » à montrer).
8434
+ */
8435
+ function preselectsDefault(schemaType, inherited) {
8436
+ if (isEmptyValue(inherited)) return !1;
8437
+ let jt = schemaType?.jsonType;
8438
+ return jt === "boolean" || (jt === "string" || jt === "number") && (schemaType?.options?.list?.length ?? 0) > 0;
8439
+ }
8440
+ /**
8395
8441
  * Pastille bleue sur tout champ d'une instance de composant dont la valeur
8396
8442
  * DIFFÈRE de la valeur par défaut du composant (valeur par défaut vide comprise),
8397
8443
  * éléments de liste compris (comparés à l'élément de même rang). Au survol, elle
@@ -8437,7 +8483,10 @@ function createOverrideInput(config) {
8437
8483
  setTranslating(!1);
8438
8484
  }
8439
8485
  }
8440
- }, router = useRouter(), inherits = isEmptyValue(inputProps.value) && !isEmptyValue(inherited), st = inputProps.schemaType, freeText = (st.jsonType === "string" || st.jsonType === "number") && !st.options?.list?.length, placeholder = inherits && freeText ? inheritedPlaceholder(inherited) : null, shown = placeholder === null ? inputProps : {
8486
+ }, router = useRouter(), inherits = isEmptyValue(inputProps.value) && !isEmptyValue(inherited), st = inputProps.schemaType, freeText = (st.jsonType === "string" || st.jsonType === "number") && !st.options?.list?.length, placeholder = inherits && freeText ? inheritedPlaceholder(inherited) : null, preselect = inherits && placeholder === null && preselectsDefault(st, inherited), shown = placeholder === null ? preselect ? {
8487
+ ...inputProps,
8488
+ value: inherited
8489
+ } : inputProps : {
8441
8490
  ...inputProps,
8442
8491
  elementProps: {
8443
8492
  ...inputProps.elementProps,
@@ -8483,7 +8532,7 @@ function createOverrideInput(config) {
8483
8532
  })
8484
8533
  ]
8485
8534
  }),
8486
- inherits && placeholder === null && /* @__PURE__ */ jsxs(Flex, {
8535
+ inherits && placeholder === null && !preselect && /* @__PURE__ */ jsxs(Flex, {
8487
8536
  align: "center",
8488
8537
  gap: 2,
8489
8538
  marginTop: 2,
@@ -10176,7 +10225,10 @@ const ncfKit = definePlugin((options) => {
10176
10225
  newDocumentOptions: (prev) => prev.filter((option) => option.templateId !== BOARD_LAYOUT_TYPE),
10177
10226
  actions: (prev, context) => config.pageTypeNames.includes(context.schemaType) ? prev.map((action) => action.action === "unpublish" ? config.i18n ? createRemoveFromSite(config) : RemoveFromSiteAction : action.action === "publish" && config.i18n ? withTranslationRedirects(withPropagation(action, config, void 0, { allowCreate: !0 }), config) : 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
10178
10227
  },
10179
- studio: { components: { toolMenu: createPreviewLauncher(config, issues) } },
10228
+ studio: { components: {
10229
+ toolMenu: createPreviewLauncher(config, issues),
10230
+ layout: HelpTextStyle
10231
+ } },
10180
10232
  form: { components: { input: createKitInput(config) } }
10181
10233
  };
10182
10234
  });
@@ -10185,6 +10237,6 @@ function hasLanguageField(schemaType, field) {
10185
10237
  let fields = schemaType?.fields;
10186
10238
  return Array.isArray(fields) && fields.some((f) => f?.name === field);
10187
10239
  }
10188
- 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, fixCrossLanguageReferences, 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, withSameLanguageReferences };
10240
+ 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, HelpTextStyle, 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, fixCrossLanguageReferences, 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, withSameLanguageReferences };
10189
10241
 
10190
10242
  //# sourceMappingURL=index.js.map