@nocode-factory/sanity-kit 2.44.1 → 2.45.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/{fixCrossLanguageReferences-DQ6bDuSZ.js → fixCrossLanguageReferences-CQGzpNii.js} +2 -2
- package/dist/{fixCrossLanguageReferences-DQ6bDuSZ.js.map → fixCrossLanguageReferences-CQGzpNii.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/schema.js +1 -1
- package/package.json +1 -1
- package/src/form/OverrideInput.tsx +3 -0
- package/src/lib/mainDocuments.ts +12 -1
- package/src/lib/propagate.ts +4 -1
- package/src/schema/componentDefaults.ts +3 -1
- package/src/version.ts +1 -1
package/dist/schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as DEFAULT_PAGE_BUILDER_FIELD, S as toPath, _ as redirectMapOf, a as componentDefaultsMainDocument, c as defineComponentDefaults, d as syncTranslationRedirects, f as translationRedirectId, g as redirectKey, h as followRedirects, i as DEFAULT_COMPONENT_DEFAULTS_TYPE, l as requiredUnlessDefault, n as withSameLanguageReferences, o as componentDefaultsMainDocuments, r as pageTypesFromSiteRoutes, s as defaultsFieldName, t as fixCrossLanguageReferences, u as requiredUnlessDefaultFor } from "./fixCrossLanguageReferences-
|
|
1
|
+
import { A as DEFAULT_PAGE_BUILDER_FIELD, S as toPath, _ as redirectMapOf, a as componentDefaultsMainDocument, c as defineComponentDefaults, d as syncTranslationRedirects, f as translationRedirectId, g as redirectKey, h as followRedirects, i as DEFAULT_COMPONENT_DEFAULTS_TYPE, l as requiredUnlessDefault, n as withSameLanguageReferences, o as componentDefaultsMainDocuments, r as pageTypesFromSiteRoutes, s as defaultsFieldName, t as fixCrossLanguageReferences, u as requiredUnlessDefaultFor } from "./fixCrossLanguageReferences-CQGzpNii.js";
|
|
2
2
|
/**
|
|
3
3
|
* Onglets du formulaire d'un document : Content, Sections, SEO, Settings.
|
|
4
4
|
*
|
package/package.json
CHANGED
|
@@ -196,6 +196,9 @@ export function createOverrideInput(config: ResolvedKitConfig): ComponentType<In
|
|
|
196
196
|
// (image, référence, ou objet à saisie personnalisée comme une couleur de charte).
|
|
197
197
|
type TypeChain = {name?: string; type?: TypeChain; components?: {input?: unknown}}
|
|
198
198
|
function carriesDot(schemaType: InputProps['schemaType']): boolean {
|
|
199
|
+
// Champ propre à l'instance (options.instanceOnly, ex. ancre) : pas de valeur par
|
|
200
|
+
// défaut, donc ni pastille ni héritage.
|
|
201
|
+
if ((schemaType.options as {instanceOnly?: boolean} | undefined)?.instanceOnly) return false
|
|
199
202
|
if (schemaType.jsonType !== 'object') return true
|
|
200
203
|
let t: TypeChain | undefined = schemaType as unknown as TypeChain
|
|
201
204
|
while (t) {
|
package/src/lib/mainDocuments.ts
CHANGED
|
@@ -67,12 +67,23 @@ export function ncfMainDocuments(
|
|
|
67
67
|
// Dossier traduit par langue (localizedPrefixes) s'il existe.
|
|
68
68
|
const prefixOf = (t: (typeof slugTypes)[number]) => (locale && t.localizedPrefixes?.[locale] !== undefined ? t.localizedPrefixes[locale] : t.pathPrefix) ?? ''
|
|
69
69
|
const collections = [...slugTypes].sort((a, b) => prefixOf(b).length - prefixOf(a).length)
|
|
70
|
+
// Types qui partagent un même dossier (ex. Page et Legal page à la racine) : UNE
|
|
71
|
+
// route qui cherche dans tous ces types. Presentation prend la PREMIÈRE route qui
|
|
72
|
+
// correspond à l'adresse : une route par type ne trouverait jamais le second.
|
|
73
|
+
const byBase = new Map<string, (typeof slugTypes)[number][]>()
|
|
70
74
|
for (const t of collections) {
|
|
71
75
|
const p = prefixOf(t)
|
|
72
76
|
const base = p && p !== '/' ? p : ''
|
|
77
|
+
byBase.set(base, [...(byBase.get(base) ?? []), t])
|
|
78
|
+
}
|
|
79
|
+
for (const [base, types] of byBase) {
|
|
80
|
+
const match = types.map((t) => `(_type == ${quote(t.type)} && ${t.slugField}.current == $slug)`)
|
|
73
81
|
// `:slug+` : un slug peut avoir plusieurs niveaux (« telecom/projets ») ; la valeur
|
|
74
82
|
// transmise à $slug est alors le slug complet (URLPattern de Presentation).
|
|
75
|
-
out.push({
|
|
83
|
+
out.push({
|
|
84
|
+
route: at(`${base}/:slug+`),
|
|
85
|
+
filter: types.length === 1 && types[0] ? `_type == ${quote(types[0].type)} && ${types[0].slugField}.current == $slug${lang}` : `(${match.join(' || ')})${lang}`,
|
|
86
|
+
})
|
|
76
87
|
}
|
|
77
88
|
}
|
|
78
89
|
return out
|
package/src/lib/propagate.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface SchemaTypeLike {
|
|
|
27
27
|
fields?: {name: string; type: SchemaTypeLike}[]
|
|
28
28
|
of?: SchemaTypeLike[]
|
|
29
29
|
to?: unknown
|
|
30
|
-
options?: {list?: unknown[]}
|
|
30
|
+
options?: {list?: unknown[]; instanceOnly?: boolean}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface PropagationResult {
|
|
@@ -58,6 +58,9 @@ function typeNames(t: SchemaTypeLike | undefined): string[] {
|
|
|
58
58
|
export function kindOf(t: SchemaTypeLike | undefined, value: unknown): FieldKind {
|
|
59
59
|
if (t) {
|
|
60
60
|
const names = typeNames(t)
|
|
61
|
+
// Champ propre à l'instance (options.instanceOnly, ex. ancre d'une section) :
|
|
62
|
+
// une valeur recopiée telle quelle, jamais traduite.
|
|
63
|
+
if (t.options?.instanceOnly) return 'value'
|
|
61
64
|
if (names.some((n) => VALUE_TYPE_NAMES.has(n)) || t.to) return 'value'
|
|
62
65
|
if (t.jsonType === 'array') {
|
|
63
66
|
const of = t.of ?? []
|
|
@@ -52,7 +52,9 @@ export function defineComponentDefaults(options: {sections: readonly unknown[];
|
|
|
52
52
|
type: 'object',
|
|
53
53
|
description: 'Default values of this component. Empty = design system value.',
|
|
54
54
|
options: {collapsible: true, collapsed: true},
|
|
55
|
-
|
|
55
|
+
// Un champ propre à l'instance (options.instanceOnly, ex. ancre) n'a pas de
|
|
56
|
+
// valeur par défaut : absent des réglages du composant.
|
|
57
|
+
fields: t.fields.filter((f) => !(f.options as {instanceOnly?: boolean} | undefined)?.instanceOnly).map(relax) as never,
|
|
56
58
|
}),
|
|
57
59
|
),
|
|
58
60
|
preview: {prepare: () => ({title: title.replace(/^\S+\s/, '')})},
|
package/src/version.ts
CHANGED