@nocode-factory/sanity-kit 2.9.1 → 2.10.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @nocode-factory/sanity-kit
2
2
 
3
3
  Outils Sanity Studio de NoCode Factory : **Pages** (liste + board), **Composants**,
4
- **Historique**, aperçu multi-environnements et partage de préversion. Plus, côté
4
+ **Historique**, **Design system**, aperçu multi-environnements et partage de préversion. Plus, côté
5
5
  site Next.js : garde de préproduction, bascule brouillons / en ligne, bandeau.
6
6
 
7
7
  ## Installer
@@ -41,6 +41,35 @@ npx ncf-kit doctor
41
41
 
42
42
  Zéro ✖ = projet complet. Sortie 1 sinon (utilisable en CI).
43
43
 
44
+ ## Design system : la page de tous les styles et composants
45
+
46
+ La page `/design-system` du site (option `componentPreview.path`) est **LA page du
47
+ design system** : fondations (couleurs, typographie, grille), marque, icônes et
48
+ chaque composant rendu avec ses valeurs par défaut. Le bouton **Design system** de
49
+ la barre du Studio l'ouvre dans Presentation, avec le document des valeurs par
50
+ défaut des composants à côté.
51
+
52
+ **Un style changé sur cette page change le composant global** : cliquer un composant
53
+ ouvre ses réglages par défaut, et la modification s'applique partout où une
54
+ instance ne l'a pas surchargée (pastille bleue sur les champs surchargés).
55
+
56
+ Côté Studio, lier les pages du design system au document des valeurs par défaut :
57
+
58
+ ```ts
59
+ presentationTool({resolve: {mainDocuments: defineDocuments([
60
+ ...componentDefaultsMainDocuments({language: 'fr'}), // /design-system et /design-system/composant
61
+ ])}})
62
+ ```
63
+
64
+ Côté site, la page rend chaque démo avec les valeurs par défaut prioritaires
65
+ (`inherit(defaults[type], demo)`), lues dans Sanity : en Presentation, les textes et
66
+ options proviennent du document des valeurs par défaut, donc cliquables.
67
+
68
+ Barre du Studio : le kit rend les boutons d'outils. Les outils techniques (Vision,
69
+ planification « Scheduled drafts » / Releases) sont rangés dans **Plus** (option
70
+ `moreTools`, `false` pour tout garder en boutons). Ne pas définir de
71
+ `studio.components.toolMenu` dans le projet : il masquerait ce menu.
72
+
44
73
  ## Composants : valeurs par défaut, instances et overrides
45
74
 
46
75
  Chaque composant (section du page builder) a des **valeurs par défaut**, réglées
@@ -72,6 +72,21 @@ function componentDefaultsMainDocument(options = {}) {
72
72
  filter: `_type == "${type}"${safeLang ? ` && language == "${safeLang}"` : ""}`
73
73
  };
74
74
  }
75
- export { requiredUnlessDefault as a, defineComponentDefaults as i, componentDefaultsMainDocument as n, requiredUnlessDefaultFor as o, defaultsFieldName as r, DEFAULT_COMPONENT_DEFAULTS_TYPE as t };
75
+ /**
76
+ * Presentation : les pages du design system ont pour document principal les valeurs
77
+ * par défaut des composants. `/design-system` (toute la bibliothèque) et
78
+ * `/design-system/composant` (un composant seul) : cliquer un composant ouvre ses
79
+ * réglages globaux, et un style changé change le composant partout où il n'est
80
+ * pas surchargé.
81
+ * `presentationTool({resolve: {mainDocuments: defineDocuments(componentDefaultsMainDocuments({language: 'fr'}))}})`
82
+ */
83
+ function componentDefaultsMainDocuments(options = {}) {
84
+ let { routes = ["/design-system/composant", "/design-system"], ...rest } = options;
85
+ return routes.map((route) => componentDefaultsMainDocument({
86
+ ...rest,
87
+ route
88
+ }));
89
+ }
90
+ export { defineComponentDefaults as a, defaultsFieldName as i, componentDefaultsMainDocument as n, requiredUnlessDefault as o, componentDefaultsMainDocuments as r, requiredUnlessDefaultFor as s, DEFAULT_COMPONENT_DEFAULTS_TYPE as t };
76
91
 
77
- //# sourceMappingURL=componentDefaults-YFpAqFb4.js.map
92
+ //# sourceMappingURL=componentDefaults-BY3hQ6aD.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"componentDefaults-YFpAqFb4.js","names":[],"sources":["../src/schema/componentDefaults.ts"],"sourcesContent":["import {defineField, defineType, type Rule} from 'sanity'\n\n/**\n * VALEURS PAR DÉFAUT DES COMPOSANTS, côté Studio.\n *\n * Un document (un par langue) avec un bloc par composant de la bibliothèque,\n * GÉNÉRÉ depuis les schémas des sections : une section ajoutée y apparaît sans\n * rien faire. Une instance dont un champ est vide affiche la valeur par défaut ;\n * un champ rempli (override) n'est jamais écrasé. Côté site :\n * `@nocode-factory/sanity-kit/web/defaults`. Dans le Studio, l'onglet Composants\n * ouvre chaque composant (rendu réel + réglages), et une pastille bleue marque\n * chaque champ d'instance qui diffère de la valeur par défaut.\n *\n * Deux règles pour les champs de section, qui en découlent :\n * - jamais d'`initialValue` (ce serait un override involontaire) ;\n * - « obligatoire » = `requiredUnlessDefault`.\n */\n\ntype FieldDef = {name: string; type: string; validation?: unknown; initialValue?: unknown; fields?: FieldDef[]; of?: FieldDef[]; [k: string]: unknown}\ntype SectionDef = {name: string; title?: string; fields: FieldDef[]}\n\nexport const DEFAULT_COMPONENT_DEFAULTS_TYPE = 'componentDefaults'\n\n/** Nom du champ d'un composant dans le document des valeurs par défaut : `section.cta` -> `cta`. */\nexport function defaultsFieldName(type: string, namespace = 'section.'): string {\n return type.startsWith(namespace) ? type.slice(namespace.length) : type\n}\n\n// Dans les valeurs par défaut, rien n'est obligatoire et rien n'est prérempli.\nconst relax = (f: FieldDef): FieldDef => {\n const {validation: _v, initialValue: _i, ...rest} = f\n return {\n ...rest,\n ...(rest.fields ? {fields: rest.fields.map(relax)} : {}),\n ...(rest.of ? {of: rest.of.map(relax)} : {}),\n }\n}\n\n/** Document « Composants : valeurs par défaut », généré depuis les sections. */\nexport function defineComponentDefaults(options: {sections: readonly unknown[]; name?: string; title?: string; namespace?: string}) {\n const {name = DEFAULT_COMPONENT_DEFAULTS_TYPE, title = '🧩 Composants : valeurs par défaut', namespace = 'section.'} = options\n return defineType({\n name,\n title,\n type: 'document',\n description:\n 'Valeurs appliquées à chaque instance d\\'un composant dont le champ est vide. Un champ rempli dans une instance reste prioritaire (override).',\n fields: (options.sections as SectionDef[]).map((t) =>\n defineField({\n name: defaultsFieldName(t.name, namespace),\n title: t.title || t.name,\n type: 'object',\n description: 'Valeurs par défaut de ce composant. Vide = valeur du design system.',\n options: {collapsible: true, collapsed: true},\n fields: t.fields.map(relax) as never,\n }),\n ),\n preview: {prepare: () => ({title: title.replace(/^\\S+\\s/, '')})},\n })\n}\n\nconst isEmpty = (v: unknown) => v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0)\n\n/**\n * Règle « obligatoire SAUF si le composant a une valeur par défaut » pour un autre\n * type de document des valeurs par défaut ou un autre espace de noms.\n * `validation: requiredUnlessDefaultFor({type: 'mesDefauts'})`\n */\nexport function requiredUnlessDefaultFor(options: {type?: string; namespace?: string} = {}) {\n const {type: defaultsType = DEFAULT_COMPONENT_DEFAULTS_TYPE, namespace = 'section.'} = options\n return <R>(rule: R): R =>\n (rule as unknown as Rule).custom(async (value, context) => {\n if (!isEmpty(value)) return true\n const type = (context.parent as {_type?: string} | undefined)?._type\n const field = context.path?.[context.path.length - 1]\n const name = type ? defaultsFieldName(type, namespace) : ''\n if (!type?.startsWith(namespace) || typeof field !== 'string' || !/^\\w+$/.test(name) || !/^\\w+$/.test(field)) return 'Obligatoire.'\n const language = (context.document as {language?: string} | undefined)?.language ?? null\n const inherited = await context\n .getClient({apiVersion: '2024-10-01'})\n .fetch(\n `*[_type == $defaultsType && !(_id in path(\"drafts.**\")) && ($language == null || language == $language)][0].${name}.${field}`,\n {defaultsType, language},\n )\n return isEmpty(inherited) ? 'Obligatoire (ou à définir dans Composants > valeurs par défaut).' : true\n }) as unknown as R\n}\n\n/**\n * Champ de section obligatoire, SAUF si le composant a une valeur par défaut\n * pour ce champ (elle s'affichera). Tout type de champ.\n * `validation: requiredUnlessDefault`\n */\nexport const requiredUnlessDefault: <R>(rule: R) => R = requiredUnlessDefaultFor()\n\n/**\n * Presentation : la page qui rend un composant seul (par défaut\n * `/design-system/composant`) a pour document principal les valeurs par défaut.\n * Rendu réel et réglages côte à côte, en direct.\n * `presentationTool({resolve: {mainDocuments: defineDocuments([componentDefaultsMainDocument({language: 'fr'})])}})`\n */\nexport function componentDefaultsMainDocument(options: {language?: string; route?: string; type?: string} = {}): {route: string; filter: string} {\n const {language, route = '/design-system/composant', type = DEFAULT_COMPONENT_DEFAULTS_TYPE} = options\n const safeLang = language && /^[a-z]{2}(-[A-Za-z]{2})?$/.test(language) ? language : null\n return {route, filter: `_type == \"${type}\"${safeLang ? ` && language == \"${safeLang}\"` : ''}`}\n}\n"],"mappings":";AAqBA,MAAa,kCAAkC;;AAG/C,SAAgB,kBAAkB,MAAc,YAAY,YAAoB;CAC9E,OAAO,KAAK,WAAW,SAAS,IAAI,KAAK,MAAM,UAAU,MAAM,IAAI;AACrE;AAGA,MAAM,SAAS,MAA0B;CACvC,IAAM,EAAC,YAAY,IAAI,cAAc,IAAI,GAAG,SAAQ;CACpD,OAAO;EACL,GAAG;EACH,GAAI,KAAK,SAAS,EAAC,QAAQ,KAAK,OAAO,IAAI,KAAK,EAAC,IAAI,CAAC;EACtD,GAAI,KAAK,KAAK,EAAC,IAAI,KAAK,GAAG,IAAI,KAAK,EAAC,IAAI,CAAC;CAC5C;AACF;;AAGA,SAAgB,wBAAwB,SAA4F;CAClI,IAAM,EAAC,OAAO,iCAAiC,QAAQ,sCAAsC,YAAY,eAAc;CACvH,OAAO,WAAW;EAChB;EACA;EACA,MAAM;EACN,aACE;EACF,QAAS,QAAQ,SAA0B,KAAK,MAC9C,YAAY;GACV,MAAM,kBAAkB,EAAE,MAAM,SAAS;GACzC,OAAO,EAAE,SAAS,EAAE;GACpB,MAAM;GACN,aAAa;GACb,SAAS;IAAC,aAAa;IAAM,WAAW;GAAI;GAC5C,QAAQ,EAAE,OAAO,IAAI,KAAK;EAC5B,CAAC,CACH;EACA,SAAS,EAAC,gBAAgB,EAAC,OAAO,MAAM,QAAQ,UAAU,EAAE,EAAC,GAAE;CACjE,CAAC;AACH;AAEA,MAAM,WAAW,MAAe,KAAyB,QAAQ,MAAM,MAAO,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW;;;;;;AAO/G,SAAgB,yBAAyB,UAA+C,CAAC,GAAG;CAC1F,IAAM,EAAC,MAAM,eAAe,iCAAiC,YAAY,eAAc;CACvF,QAAW,SACR,KAAyB,OAAO,OAAO,OAAO,YAAY;EACzD,IAAI,CAAC,QAAQ,KAAK,GAAG,OAAO;EAC5B,IAAM,OAAQ,QAAQ,QAAyC,OACzD,QAAQ,QAAQ,OAAO,QAAQ,KAAK,SAAS,IAC7C,OAAO,OAAO,kBAAkB,MAAM,SAAS,IAAI;EACzD,IAAI,CAAC,MAAM,WAAW,SAAS,KAAK,OAAO,SAAU,YAAY,CAAC,QAAQ,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,GAAG,OAAO;EACrH,IAAM,WAAY,QAAQ,UAA8C,YAAY,MAC9E,YAAY,MAAM,QACrB,UAAU,EAAC,YAAY,aAAY,CAAC,CAAC,CACrC,MACC,+GAA+G,KAAK,GAAG,SACvH;GAAC;GAAc;EAAQ,CACzB;EACF,OAAO,SAAQ,SAAS,KAAI;CAC9B,CAAC;AACL;;;;;;AAOA,MAAa,wBAA2C,yBAAyB;;;;;;;AAQjF,SAAgB,8BAA8B,UAA8D,CAAC,GAAoC;CAC/I,IAAM,EAAC,UAAU,QAAQ,4BAA4B,OAAO,oCAAmC,SACzF,WAAW,YAAY,4BAA4B,KAAK,QAAQ,IAAI,WAAW;CACrF,OAAO;EAAC;EAAO,QAAQ,aAAa,KAAK,GAAG,WAAW,oBAAoB,SAAS,KAAK;CAAI;AAC/F"}
1
+ {"version":3,"file":"componentDefaults-BY3hQ6aD.js","names":[],"sources":["../src/schema/componentDefaults.ts"],"sourcesContent":["import {defineField, defineType, type Rule} from 'sanity'\n\n/**\n * VALEURS PAR DÉFAUT DES COMPOSANTS, côté Studio.\n *\n * Un document (un par langue) avec un bloc par composant de la bibliothèque,\n * GÉNÉRÉ depuis les schémas des sections : une section ajoutée y apparaît sans\n * rien faire. Une instance dont un champ est vide affiche la valeur par défaut ;\n * un champ rempli (override) n'est jamais écrasé. Côté site :\n * `@nocode-factory/sanity-kit/web/defaults`. Dans le Studio, l'onglet Composants\n * ouvre chaque composant (rendu réel + réglages), et une pastille bleue marque\n * chaque champ d'instance qui diffère de la valeur par défaut.\n *\n * Deux règles pour les champs de section, qui en découlent :\n * - jamais d'`initialValue` (ce serait un override involontaire) ;\n * - « obligatoire » = `requiredUnlessDefault`.\n */\n\ntype FieldDef = {name: string; type: string; validation?: unknown; initialValue?: unknown; fields?: FieldDef[]; of?: FieldDef[]; [k: string]: unknown}\ntype SectionDef = {name: string; title?: string; fields: FieldDef[]}\n\nexport const DEFAULT_COMPONENT_DEFAULTS_TYPE = 'componentDefaults'\n\n/** Nom du champ d'un composant dans le document des valeurs par défaut : `section.cta` -> `cta`. */\nexport function defaultsFieldName(type: string, namespace = 'section.'): string {\n return type.startsWith(namespace) ? type.slice(namespace.length) : type\n}\n\n// Dans les valeurs par défaut, rien n'est obligatoire et rien n'est prérempli.\nconst relax = (f: FieldDef): FieldDef => {\n const {validation: _v, initialValue: _i, ...rest} = f\n return {\n ...rest,\n ...(rest.fields ? {fields: rest.fields.map(relax)} : {}),\n ...(rest.of ? {of: rest.of.map(relax)} : {}),\n }\n}\n\n/** Document « Composants : valeurs par défaut », généré depuis les sections. */\nexport function defineComponentDefaults(options: {sections: readonly unknown[]; name?: string; title?: string; namespace?: string}) {\n const {name = DEFAULT_COMPONENT_DEFAULTS_TYPE, title = '🧩 Composants : valeurs par défaut', namespace = 'section.'} = options\n return defineType({\n name,\n title,\n type: 'document',\n description:\n 'Valeurs appliquées à chaque instance d\\'un composant dont le champ est vide. Un champ rempli dans une instance reste prioritaire (override).',\n fields: (options.sections as SectionDef[]).map((t) =>\n defineField({\n name: defaultsFieldName(t.name, namespace),\n title: t.title || t.name,\n type: 'object',\n description: 'Valeurs par défaut de ce composant. Vide = valeur du design system.',\n options: {collapsible: true, collapsed: true},\n fields: t.fields.map(relax) as never,\n }),\n ),\n preview: {prepare: () => ({title: title.replace(/^\\S+\\s/, '')})},\n })\n}\n\nconst isEmpty = (v: unknown) => v === undefined || v === null || v === '' || (Array.isArray(v) && v.length === 0)\n\n/**\n * Règle « obligatoire SAUF si le composant a une valeur par défaut » pour un autre\n * type de document des valeurs par défaut ou un autre espace de noms.\n * `validation: requiredUnlessDefaultFor({type: 'mesDefauts'})`\n */\nexport function requiredUnlessDefaultFor(options: {type?: string; namespace?: string} = {}) {\n const {type: defaultsType = DEFAULT_COMPONENT_DEFAULTS_TYPE, namespace = 'section.'} = options\n return <R>(rule: R): R =>\n (rule as unknown as Rule).custom(async (value, context) => {\n if (!isEmpty(value)) return true\n const type = (context.parent as {_type?: string} | undefined)?._type\n const field = context.path?.[context.path.length - 1]\n const name = type ? defaultsFieldName(type, namespace) : ''\n if (!type?.startsWith(namespace) || typeof field !== 'string' || !/^\\w+$/.test(name) || !/^\\w+$/.test(field)) return 'Obligatoire.'\n const language = (context.document as {language?: string} | undefined)?.language ?? null\n const inherited = await context\n .getClient({apiVersion: '2024-10-01'})\n .fetch(\n `*[_type == $defaultsType && !(_id in path(\"drafts.**\")) && ($language == null || language == $language)][0].${name}.${field}`,\n {defaultsType, language},\n )\n return isEmpty(inherited) ? 'Obligatoire (ou à définir dans Composants > valeurs par défaut).' : true\n }) as unknown as R\n}\n\n/**\n * Champ de section obligatoire, SAUF si le composant a une valeur par défaut\n * pour ce champ (elle s'affichera). Tout type de champ.\n * `validation: requiredUnlessDefault`\n */\nexport const requiredUnlessDefault: <R>(rule: R) => R = requiredUnlessDefaultFor()\n\n/**\n * Presentation : la page qui rend un composant seul (par défaut\n * `/design-system/composant`) a pour document principal les valeurs par défaut.\n * Rendu réel et réglages côte à côte, en direct.\n * `presentationTool({resolve: {mainDocuments: defineDocuments([componentDefaultsMainDocument({language: 'fr'})])}})`\n */\nexport function componentDefaultsMainDocument(options: {language?: string; route?: string; type?: string} = {}): {route: string; filter: string} {\n const {language, route = '/design-system/composant', type = DEFAULT_COMPONENT_DEFAULTS_TYPE} = options\n const safeLang = language && /^[a-z]{2}(-[A-Za-z]{2})?$/.test(language) ? language : null\n return {route, filter: `_type == \"${type}\"${safeLang ? ` && language == \"${safeLang}\"` : ''}`}\n}\n\n/**\n * Presentation : les pages du design system ont pour document principal les valeurs\n * par défaut des composants. `/design-system` (toute la bibliothèque) et\n * `/design-system/composant` (un composant seul) : cliquer un composant ouvre ses\n * réglages globaux, et un style changé change le composant partout où il n'est\n * pas surchargé.\n * `presentationTool({resolve: {mainDocuments: defineDocuments(componentDefaultsMainDocuments({language: 'fr'}))}})`\n */\nexport function componentDefaultsMainDocuments(\n options: {language?: string; type?: string; routes?: string[]} = {},\n): {route: string; filter: string}[] {\n const {routes = ['/design-system/composant', '/design-system'], ...rest} = options\n return routes.map((route) => componentDefaultsMainDocument({...rest, route}))\n}\n"],"mappings":";AAqBA,MAAa,kCAAkC;;AAG/C,SAAgB,kBAAkB,MAAc,YAAY,YAAoB;CAC9E,OAAO,KAAK,WAAW,SAAS,IAAI,KAAK,MAAM,UAAU,MAAM,IAAI;AACrE;AAGA,MAAM,SAAS,MAA0B;CACvC,IAAM,EAAC,YAAY,IAAI,cAAc,IAAI,GAAG,SAAQ;CACpD,OAAO;EACL,GAAG;EACH,GAAI,KAAK,SAAS,EAAC,QAAQ,KAAK,OAAO,IAAI,KAAK,EAAC,IAAI,CAAC;EACtD,GAAI,KAAK,KAAK,EAAC,IAAI,KAAK,GAAG,IAAI,KAAK,EAAC,IAAI,CAAC;CAC5C;AACF;;AAGA,SAAgB,wBAAwB,SAA4F;CAClI,IAAM,EAAC,OAAO,iCAAiC,QAAQ,sCAAsC,YAAY,eAAc;CACvH,OAAO,WAAW;EAChB;EACA;EACA,MAAM;EACN,aACE;EACF,QAAS,QAAQ,SAA0B,KAAK,MAC9C,YAAY;GACV,MAAM,kBAAkB,EAAE,MAAM,SAAS;GACzC,OAAO,EAAE,SAAS,EAAE;GACpB,MAAM;GACN,aAAa;GACb,SAAS;IAAC,aAAa;IAAM,WAAW;GAAI;GAC5C,QAAQ,EAAE,OAAO,IAAI,KAAK;EAC5B,CAAC,CACH;EACA,SAAS,EAAC,gBAAgB,EAAC,OAAO,MAAM,QAAQ,UAAU,EAAE,EAAC,GAAE;CACjE,CAAC;AACH;AAEA,MAAM,WAAW,MAAe,KAAyB,QAAQ,MAAM,MAAO,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW;;;;;;AAO/G,SAAgB,yBAAyB,UAA+C,CAAC,GAAG;CAC1F,IAAM,EAAC,MAAM,eAAe,iCAAiC,YAAY,eAAc;CACvF,QAAW,SACR,KAAyB,OAAO,OAAO,OAAO,YAAY;EACzD,IAAI,CAAC,QAAQ,KAAK,GAAG,OAAO;EAC5B,IAAM,OAAQ,QAAQ,QAAyC,OACzD,QAAQ,QAAQ,OAAO,QAAQ,KAAK,SAAS,IAC7C,OAAO,OAAO,kBAAkB,MAAM,SAAS,IAAI;EACzD,IAAI,CAAC,MAAM,WAAW,SAAS,KAAK,OAAO,SAAU,YAAY,CAAC,QAAQ,KAAK,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,GAAG,OAAO;EACrH,IAAM,WAAY,QAAQ,UAA8C,YAAY,MAC9E,YAAY,MAAM,QACrB,UAAU,EAAC,YAAY,aAAY,CAAC,CAAC,CACrC,MACC,+GAA+G,KAAK,GAAG,SACvH;GAAC;GAAc;EAAQ,CACzB;EACF,OAAO,SAAQ,SAAS,KAAI;CAC9B,CAAC;AACL;;;;;;AAOA,MAAa,wBAA2C,yBAAyB;;;;;;;AAQjF,SAAgB,8BAA8B,UAA8D,CAAC,GAAoC;CAC/I,IAAM,EAAC,UAAU,QAAQ,4BAA4B,OAAO,oCAAmC,SACzF,WAAW,YAAY,4BAA4B,KAAK,QAAQ,IAAI,WAAW;CACrF,OAAO;EAAC;EAAO,QAAQ,aAAa,KAAK,GAAG,WAAW,oBAAoB,SAAS,KAAK;CAAI;AAC/F;;;;;;;;;AAUA,SAAgB,+BACd,UAAiE,CAAC,GAC/B;CACnC,IAAM,EAAC,SAAS,CAAC,4BAA4B,gBAAgB,GAAG,GAAG,SAAQ;CAC3E,OAAO,OAAO,KAAK,UAAU,8BAA8B;EAAC,GAAG;EAAM;CAAK,CAAC,CAAC;AAC9E"}
@@ -58,5 +58,21 @@ declare function componentDefaultsMainDocument(options?: {
58
58
  route: string;
59
59
  filter: string;
60
60
  };
61
- export { requiredUnlessDefault as a, defineComponentDefaults as i, componentDefaultsMainDocument as n, requiredUnlessDefaultFor as o, defaultsFieldName as r, DEFAULT_COMPONENT_DEFAULTS_TYPE as t };
62
- //# sourceMappingURL=componentDefaults-CbOXLaYE.d.ts.map
61
+ /**
62
+ * Presentation : les pages du design system ont pour document principal les valeurs
63
+ * par défaut des composants. `/design-system` (toute la bibliothèque) et
64
+ * `/design-system/composant` (un composant seul) : cliquer un composant ouvre ses
65
+ * réglages globaux, et un style changé change le composant partout où il n'est
66
+ * pas surchargé.
67
+ * `presentationTool({resolve: {mainDocuments: defineDocuments(componentDefaultsMainDocuments({language: 'fr'}))}})`
68
+ */
69
+ declare function componentDefaultsMainDocuments(options?: {
70
+ language?: string;
71
+ type?: string;
72
+ routes?: string[];
73
+ }): {
74
+ route: string;
75
+ filter: string;
76
+ }[];
77
+ export { defineComponentDefaults as a, defaultsFieldName as i, componentDefaultsMainDocument as n, requiredUnlessDefault as o, componentDefaultsMainDocuments as r, requiredUnlessDefaultFor as s, DEFAULT_COMPONENT_DEFAULTS_TYPE as t };
78
+ //# sourceMappingURL=componentDefaults-CNiuukLt.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as requiredUnlessDefault, i as defineComponentDefaults, n as componentDefaultsMainDocument, o as requiredUnlessDefaultFor, r as defaultsFieldName, t as DEFAULT_COMPONENT_DEFAULTS_TYPE } from "./componentDefaults-CbOXLaYE.js";
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
2
  import { SanityClient, Schema, Tool, ToolMenuProps } from "sanity";
3
3
  import { ReactNode } from "react";
4
4
  import { PreviewHeaderProps } from "sanity/presentation";
@@ -136,6 +136,8 @@ interface NcfToolsConfig {
136
136
  pages?: boolean;
137
137
  components?: boolean;
138
138
  history?: boolean;
139
+ /** Bouton « Design system » : ouvre la page /design-system dans Presentation. */
140
+ designSystem?: boolean;
139
141
  }
140
142
  interface NcfKitConfig {
141
143
  /** Types de documents traités comme des pages. Au moins un. */
@@ -192,6 +194,12 @@ interface NcfKitConfig {
192
194
  serviceEndpoint?: string | false;
193
195
  /** Permet de n'activer qu'une partie des outils. */
194
196
  tools?: NcfToolsConfig;
197
+ /**
198
+ * Outils techniques rangés dans le menu « Plus » de la barre du Studio, pour ne
199
+ * pas encombrer le marketing. Par défaut : Vision et la planification
200
+ * (« Scheduled drafts » / Releases, nom d'outil `releases`). `false` : aucun.
201
+ */
202
+ moreTools?: string[] | false;
195
203
  /**
196
204
  * Étiquettes de suivi du board. Remplacent entièrement les valeurs par
197
205
  * défaut quand elles sont fournies.
@@ -245,6 +253,8 @@ interface ResolvedKitConfig {
245
253
  /** `null` quand on a explicitement coupé les appels sortants. */
246
254
  serviceEndpoint: string | null;
247
255
  tools: Required<NcfToolsConfig>;
256
+ /** Outils rangés dans le menu « Plus » de la barre (noms d'outils). */
257
+ moreTools: string[];
248
258
  boardTags: NcfBoardTag[];
249
259
  internalFields: NcfInternalField[];
250
260
  documentColumns: ResolvedDocumentColumn[];
@@ -278,7 +288,7 @@ interface ConfigIssue {
278
288
  /** Quels outils sont concernés. Vide = tous. */
279
289
  tools?: NcfToolName[];
280
290
  }
281
- type NcfToolName = 'pages' | 'components' | 'history';
291
+ type NcfToolName = 'pages' | 'components' | 'history' | 'designSystem';
282
292
  interface KitContextValue {
283
293
  config: ResolvedKitConfig;
284
294
  issues: ConfigIssue[];
@@ -1292,7 +1302,7 @@ export declare function ActorName(props: {
1292
1302
  * Version du kit, rapportée au service pour savoir quels projets tournent sur
1293
1303
  * quelle version. Tenue à jour avec `package.json`.
1294
1304
  */
1295
- export declare const KIT_VERSION = "2.9.1";
1305
+ export declare const KIT_VERSION = "2.10.1";
1296
1306
  /**
1297
1307
  * Données de la page proposées comme colonnes.
1298
1308
  *
@@ -1760,7 +1770,8 @@ export declare function humanizeBlockName(type: string, namespace: string): stri
1760
1770
  export declare const NCF_PAGES_TOOL = "ncf-pages";
1761
1771
  export declare const NCF_COMPONENTS_TOOL = "ncf-components";
1762
1772
  export declare const NCF_HISTORY_TOOL = "ncf-history";
1763
- export declare const NCF_TOOL_NAMES: readonly ["ncf-pages", "ncf-components", "ncf-history"];
1773
+ export declare const NCF_DESIGN_SYSTEM_TOOL = "ncf-design-system";
1774
+ export declare const NCF_TOOL_NAMES: readonly ["ncf-pages", "ncf-components", "ncf-history", "ncf-design-system"];
1764
1775
  export declare const ncfKit: import("sanity").Plugin<NcfKitConfig>;
1765
- export { type AddColumnInput, type Annotation, type AnnotationsState, type BlockOccurrence, type BlockTypeInfo, type BoardEdge, type BoardGraph, type BoardLayoutState, type BoardNode, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, type Change, type ChangeKind, type CollectedLinks, type ColorBy, type ColorOptions, type ConfigIssue, DEFAULT_COMPONENT_DEFAULTS_TYPE, type DeriveOptions, type GroupBy, type GroupOptions, type HistoryDetail, type HistoryEvent, type IssueLevel, type KitContextValue, type KitUpdate, type LayoutMode, type MergedDoc, type NcfBoardTag, type NcfComponentPreviewConfig, type NcfDocumentColumn, type NcfEnvironment, type NcfHistoryConfig, type NcfI18nConfig, type NcfInternalField, type NcfInternalFieldOption, type NcfKitConfig, type NcfPageTypeConfig, type NcfPageTypeInput, type NcfToolName, type NcfToolsConfig, type NodeLayout, type NodePosition, type OccurrenceInput, type OccurrencePage, type OccurrencesState, type PageContent, type PageContentsState, type PageDoc, type PageFilters, type PageRow, type PageStatus, type PagesState, type PathInput, type Positioned, type PresentationOptions, type PreviewGrant, type PreviewPerspective, type PreviewTargetState, type ProjectStatus, type Registration, type ResolvedComponentPreview, type ResolvedDocumentColumn, type ResolvedHistory, type ResolvedI18n, type ResolvedKitConfig, type ResolvedPageType, type RowColor, type RowGroup, type SchemaFieldLike, type SchemaTypeLike, type SectionLayout, type SectionMapNode, type SectionOrder, type SectionsMapOptions, type Segment, type SiteRoutesRegistry, type SortDirection, type SortKey, type ThumbnailInput, type VersionedDoc, componentDefaultsMainDocument, defaultsFieldName, defineComponentDefaults, requiredUnlessDefault, requiredUnlessDefaultFor };
1776
+ export { type AddColumnInput, type Annotation, type AnnotationsState, type BlockOccurrence, type BlockTypeInfo, type BoardEdge, type BoardGraph, type BoardLayoutState, type BoardNode, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, type Change, type ChangeKind, type CollectedLinks, type ColorBy, type ColorOptions, type ConfigIssue, DEFAULT_COMPONENT_DEFAULTS_TYPE, type DeriveOptions, type GroupBy, type GroupOptions, type HistoryDetail, type HistoryEvent, type IssueLevel, type KitContextValue, type KitUpdate, type LayoutMode, type MergedDoc, type NcfBoardTag, type NcfComponentPreviewConfig, type NcfDocumentColumn, type NcfEnvironment, type NcfHistoryConfig, type NcfI18nConfig, type NcfInternalField, type NcfInternalFieldOption, type NcfKitConfig, type NcfPageTypeConfig, type NcfPageTypeInput, type NcfToolName, type NcfToolsConfig, type NodeLayout, type NodePosition, type OccurrenceInput, type OccurrencePage, type OccurrencesState, type PageContent, type PageContentsState, type PageDoc, type PageFilters, type PageRow, type PageStatus, type PagesState, type PathInput, type Positioned, type PresentationOptions, type PreviewGrant, type PreviewPerspective, type PreviewTargetState, type ProjectStatus, type Registration, type ResolvedComponentPreview, type ResolvedDocumentColumn, type ResolvedHistory, type ResolvedI18n, type ResolvedKitConfig, type ResolvedPageType, type RowColor, type RowGroup, type SchemaFieldLike, type SchemaTypeLike, type SectionLayout, type SectionMapNode, type SectionOrder, type SectionsMapOptions, type Segment, type SiteRoutesRegistry, type SortDirection, type SortKey, type ThumbnailInput, type VersionedDoc, componentDefaultsMainDocument, componentDefaultsMainDocuments, defaultsFieldName, defineComponentDefaults, requiredUnlessDefault, requiredUnlessDefaultFor };
1766
1777
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
- import { a as requiredUnlessDefault, i as defineComponentDefaults, n as componentDefaultsMainDocument, o as requiredUnlessDefaultFor, r as defaultsFieldName, t as DEFAULT_COMPONENT_DEFAULTS_TYPE } from "./componentDefaults-YFpAqFb4.js";
2
- import { defineField, definePlugin, defineType, pathToString, set, unset, useClient, useCurrentUser, useFormValue, useSchema, useUser } from "sanity";
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-BY3hQ6aD.js";
2
+ import { ToolLink, defineField, definePlugin, defineType, pathToString, set, unset, useClient, useCurrentUser, useFormValue, useSchema, useUser, useWorkspace } from "sanity";
3
3
  import { ClockIcon } from "@sanity/icons/Clock";
4
4
  import { ComponentIcon } from "@sanity/icons/Component";
5
5
  import { DocumentsIcon } from "@sanity/icons/Documents";
6
+ import { ColorWheelIcon } from "@sanity/icons/ColorWheel";
6
7
  import { Badge, Box, Button, Card, Container, Flex, Grid, Select, Spinner, Stack, Tab, TabList, TabPanel, Text, TextArea, TextInput } from "@sanity/ui";
7
- import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
8
+ import { createContext, forwardRef, memo, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
8
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
10
  import { IntentLink, useRouter } from "sanity/router";
10
11
  import { EyeOpenIcon } from "@sanity/icons/EyeOpen";
@@ -12,6 +13,8 @@ import { LaunchIcon } from "@sanity/icons/Launch";
12
13
  import { ArrowUpIcon } from "@sanity/icons/ArrowUp";
13
14
  import { CheckmarkIcon } from "@sanity/icons/Checkmark";
14
15
  import { CopyIcon } from "@sanity/icons/Copy";
16
+ import { Menu, MenuButton, MenuItem } from "@sanity/ui/menu";
17
+ import { EllipsisHorizontalIcon } from "@sanity/icons/EllipsisHorizontal";
15
18
  import { CloseIcon } from "@sanity/icons/Close";
16
19
  import { EarthGlobeIcon } from "@sanity/icons/EarthGlobe";
17
20
  import { ProjectsIcon } from "@sanity/icons/Projects";
@@ -32,7 +35,6 @@ import { TrashIcon } from "@sanity/icons/Trash";
32
35
  import { RefreshIcon } from "@sanity/icons/Refresh";
33
36
  import { RestoreIcon } from "@sanity/icons/Restore";
34
37
  import { Tooltip } from "@sanity/ui/tooltip";
35
- import { EllipsisHorizontalIcon } from "@sanity/icons/EllipsisHorizontal";
36
38
  const DEFAULT_PAGE_BUILDER_FIELD = "sections", DEFAULT_SLUG_FIELD = "slug", DEFAULT_TITLE_FIELD = "title", DEFAULT_NOINDEX_FIELDS = ["seo.noindex", "noindex"], DEFAULT_I18N = {
37
39
  field: "language",
38
40
  defaultLocale: "fr",
@@ -47,8 +49,13 @@ const DEFAULT_PAGE_BUILDER_FIELD = "sections", DEFAULT_SLUG_FIELD = "slug", DEFA
47
49
  }, DEFAULT_TOOLS = {
48
50
  pages: !0,
49
51
  components: !0,
50
- history: !0
51
- }, DEFAULT_BOARD_TAGS = [
52
+ history: !0,
53
+ designSystem: !0
54
+ }, DEFAULT_TOOLBAR_MORE = [
55
+ "vision",
56
+ "releases",
57
+ "schedules"
58
+ ], DEFAULT_BOARD_TAGS = [
52
59
  {
53
60
  id: "en-cours",
54
61
  label: "En cours",
@@ -145,6 +152,7 @@ function resolveConfig(input) {
145
152
  ...DEFAULT_TOOLS,
146
153
  ...input.tools
147
154
  },
155
+ moreTools: input.moreTools === !1 ? [] : input.moreTools ?? DEFAULT_TOOLBAR_MORE,
148
156
  boardTags: input.boardTags?.length ? input.boardTags : DEFAULT_BOARD_TAGS,
149
157
  internalFields: input.internalFields?.length ? input.internalFields : DEFAULT_INTERNAL_FIELDS,
150
158
  documentColumns: (input.documentColumns ?? []).map((column) => ({
@@ -244,7 +252,7 @@ function validateConfig(config) {
244
252
  }), config.previewUrl && !isAbsoluteHttpUrl(config.previewUrl) && error("previewUrl", `« ${config.previewUrl} » n'est pas une URL absolue. Attendu : https://exemple.fr`), config.componentPreview.provider === "designSystemPage" && (config.previewUrl || warn("previewUrl", "Aperçu des composants actif mais `previewUrl` est absent : les vignettes et les liens vers la page design system seront désactivés.", ["components"]), !config.componentPreview.thumbnail.includes("{name}") && !config.componentPreview.thumbnail.includes("{kebab}") && warn("componentPreview.thumbnail", "Le gabarit ne contient ni {name} ni {kebab} : tous les blocs afficheront la même image.", ["components"]));
245
253
  let seenEnvironments = /* @__PURE__ */ new Set();
246
254
  for (let environment of config.environments) isAbsoluteHttpUrl(environment.url) || error(`environments.${environment.id}.url`, `« ${environment.url} » n'est pas une URL absolue. L'aperçu ne pourra pas charger cet environnement.`, ["pages"]), seenEnvironments.has(environment.id) && error("environments", `Deux environnements portent l'identifiant « ${environment.id} » : le choix retenu serait imprévisible.`, ["pages"]), seenEnvironments.add(environment.id);
247
- config.environments.length > 1 && warn("environments", `${config.environments.length} environnements sont déclarés. Vérifie que leurs origines figurent dans \`allowOrigins\` de presentationTool — \`ncfAllowedOrigins(config)\` les produit.`, ["pages"]), config.tools.history && (config.history ? ((!config.history.endpoint || !isAbsoluteHttpUrl(config.history.endpoint)) && error("history.endpoint", `« ${config.history.endpoint || ""} » n'est pas une URL absolue vers l'Edge Function de lecture.`, ["history"]), config.history.projectKey?.trim() || error("history.projectKey", "`history.projectKey` est vide.", ["history"]), /^eyJ|^sb_secret_|service_role/i.test(config.history.projectKey ?? "") && error("history.projectKey", "Cette valeur ressemble à une clé Supabase. Le Studio est public : n'y place jamais qu'un identifiant de projet opaque, sans droit d'écriture.", ["history"])) : warn("history", "L'onglet Historique est activé mais aucune clé de lecture n'est configurée. Lance `npx ncf-kit setup` dans le dossier du studio (elle est écrite dans .env), ou passe tools: {history: false}.", ["history"]));
255
+ config.tools.history && (config.history ? ((!config.history.endpoint || !isAbsoluteHttpUrl(config.history.endpoint)) && error("history.endpoint", `« ${config.history.endpoint || ""} » n'est pas une URL absolue vers l'Edge Function de lecture.`, ["history"]), config.history.projectKey?.trim() || error("history.projectKey", "`history.projectKey` est vide.", ["history"]), /^eyJ|^sb_secret_|service_role/i.test(config.history.projectKey ?? "") && error("history.projectKey", "Cette valeur ressemble à une clé Supabase. Le Studio est public : n'y place jamais qu'un identifiant de projet opaque, sans droit d'écriture.", ["history"])) : warn("history", "L'onglet Historique est activé mais aucune clé de lecture n'est configurée. Lance `npx ncf-kit setup` dans le dossier du studio (elle est écrite dans .env), ou passe tools: {history: false}.", ["history"]));
248
256
  let fieldIds = /* @__PURE__ */ new Set();
249
257
  return config.internalFields.forEach((field, index) => {
250
258
  let at = `internalFields[${index}]`;
@@ -1074,6 +1082,26 @@ function ncfAllowedOrigins(config) {
1074
1082
  }).filter((origin) => !!origin);
1075
1083
  return [...new Set(origins)];
1076
1084
  }
1085
+ /**
1086
+ * Origines d'aperçu que Presentation refuserait : celles des environnements du kit
1087
+ * qui ne correspondent à aucune entrée de `allowOrigins` (motifs avec `*` acceptés)
1088
+ * ni à l'origine de son `previewUrl` (toujours autorisée). Sans liste lisible
1089
+ * (fonction, absente) : rien n'est signalé, faute de pouvoir vérifier.
1090
+ */
1091
+ function missingPreviewOrigins(required, presentationOptions) {
1092
+ let allow = presentationOptions?.allowOrigins;
1093
+ if (!Array.isArray(allow)) return [];
1094
+ let patterns = allow.filter((p) => typeof p == "string"), preview = presentationOptions?.previewUrl, previewOrigin = (() => {
1095
+ let raw = typeof preview == "string" ? preview : preview?.origin;
1096
+ if (typeof raw != "string") return null;
1097
+ try {
1098
+ return new URL(raw).origin;
1099
+ } catch {
1100
+ return null;
1101
+ }
1102
+ })(), matches = (origin, pattern) => RegExp(`^${pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`).test(origin);
1103
+ return required.filter((origin) => origin !== previewOrigin && !patterns.some((p) => matches(origin, p)));
1104
+ }
1077
1105
  /** Identifiant de l'environnement libre, saisi à la volée. */
1078
1106
  const CUSTOM_ENVIRONMENT_ID = "ncf-custom";
1079
1107
  /**
@@ -1306,7 +1334,7 @@ function explainGrantError(error) {
1306
1334
  * Version du kit, rapportée au service pour savoir quels projets tournent sur
1307
1335
  * quelle version. Tenue à jour avec `package.json`.
1308
1336
  */
1309
- const KIT_VERSION = "2.9.1";
1337
+ const KIT_VERSION = "2.10.1";
1310
1338
  /**
1311
1339
  * Signale ce Studio au service du kit, une fois par montage.
1312
1340
  *
@@ -1389,6 +1417,48 @@ function ProjectStatusNotice(props) {
1389
1417
  });
1390
1418
  }
1391
1419
  /**
1420
+ * Vérifie pour de vrai que Presentation accepte chaque environnement d'aperçu du kit
1421
+ * (option `allowOrigins`). Ne s'affiche que s'il en manque : sans elle, l'aperçu de
1422
+ * cet environnement s'affiche mais reste muet (ni édition visuelle, ni surlignage).
1423
+ */
1424
+ function PreviewOriginsNotice() {
1425
+ let config = useKitConfig(), { tools } = useWorkspace(), presentation = tools.find((tool) => tool.__internalApplicationType === "sanity/presentation" || tool.name === "presentation");
1426
+ if (!presentation) return null;
1427
+ let missing = missingPreviewOrigins(ncfAllowedOrigins(config), presentation.options);
1428
+ return missing.length === 0 ? null : /* @__PURE__ */ jsx(Container, {
1429
+ width: 2,
1430
+ children: /* @__PURE__ */ jsx(Card, {
1431
+ padding: 4,
1432
+ radius: 3,
1433
+ shadow: 1,
1434
+ tone: "caution",
1435
+ children: /* @__PURE__ */ jsxs(Stack, {
1436
+ gap: 3,
1437
+ children: [
1438
+ /* @__PURE__ */ jsxs(Text, {
1439
+ weight: "semibold",
1440
+ children: ["Aperçu muet sur ", missing.length > 1 ? "ces environnements" : "cet environnement"]
1441
+ }),
1442
+ /* @__PURE__ */ jsx(Stack, {
1443
+ gap: 2,
1444
+ children: missing.map((origin) => /* @__PURE__ */ jsx(InlineCode, { children: origin }, origin))
1445
+ }),
1446
+ /* @__PURE__ */ jsxs(Text, {
1447
+ size: 1,
1448
+ children: [
1449
+ "Presentation n'autorise pas ",
1450
+ missing.length > 1 ? "ces origines" : "cette origine",
1451
+ " : la page s'affiche sans édition visuelle. Dans sanity.config.ts, passer ",
1452
+ /* @__PURE__ */ jsx(InlineCode, { children: "allowOrigins: ncfAllowedOrigins(options)" }),
1453
+ " à presentationTool."
1454
+ ]
1455
+ })
1456
+ ]
1457
+ })
1458
+ })
1459
+ });
1460
+ }
1461
+ /**
1392
1462
  * Signale la présence du Studio et rend l'avis qui en découle.
1393
1463
  *
1394
1464
  * Monté dans l'enveloppe plutôt que dans chaque outil : le signalement doit
@@ -1421,6 +1491,7 @@ function createToolComponent(args) {
1421
1491
  issues: scoped,
1422
1492
  toolTitle: title
1423
1493
  }),
1494
+ name === "pages" && /* @__PURE__ */ jsx(PreviewOriginsNotice, {}),
1424
1495
  /* @__PURE__ */ jsx(Registered, {}),
1425
1496
  blocking ? null : /* @__PURE__ */ jsx(Component, {})
1426
1497
  ]
@@ -1617,7 +1688,7 @@ function useKitUpdate() {
1617
1688
  !controller.signal.aborted && body?.version && setLatest(body.version);
1618
1689
  }).catch(() => {}), () => controller.abort();
1619
1690
  }, []);
1620
- let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.9.1") > 0);
1691
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.10.1") > 0);
1621
1692
  return {
1622
1693
  current: KIT_VERSION,
1623
1694
  latest,
@@ -1743,6 +1814,75 @@ function NcfKitUpdate(props) {
1743
1814
  });
1744
1815
  }
1745
1816
  /**
1817
+ * Sépare les outils de la barre : ceux du quotidien restent en boutons, les outils
1818
+ * techniques (`more`) passent dans le menu « Plus ». L'ordre d'origine est gardé.
1819
+ */
1820
+ function splitTools(tools, more) {
1821
+ return [tools.filter((t) => !more.includes(t.name)), tools.filter((t) => more.includes(t.name))];
1822
+ }
1823
+ const ToolAnchor = forwardRef(function ToolAnchor({ children, ...props }, ref) {
1824
+ return /* @__PURE__ */ jsx(ToolLink, {
1825
+ ...props,
1826
+ ref,
1827
+ children
1828
+ });
1829
+ });
1830
+ /**
1831
+ * Barre d'outils du Studio : les outils du quotidien en boutons (dont « Design
1832
+ * system »), les outils techniques (Vision, planification) dans « Plus ». Dans le
1833
+ * volet latéral (mobile), tout est listé.
1834
+ */
1835
+ function NcfToolButtons(props) {
1836
+ let { activeToolName, context, tools, closeSidebar, isSidebarOpen, more: moreNames } = props, [main, more] = useMemo(() => splitTools(tools, moreNames), [tools, moreNames]), isSidebar = context === "sidebar", onClick = useCallback(() => {
1837
+ isSidebar && isSidebarOpen && closeSidebar();
1838
+ }, [
1839
+ closeSidebar,
1840
+ isSidebar,
1841
+ isSidebarOpen
1842
+ ]), button = (tool) => /* @__PURE__ */ jsx(Button, {
1843
+ as: ToolAnchor,
1844
+ name: tool.name,
1845
+ icon: tool.icon,
1846
+ text: tool.title || tool.name,
1847
+ mode: "bleed",
1848
+ selected: activeToolName === tool.name,
1849
+ justify: isSidebar ? "flex-start" : void 0,
1850
+ onClick,
1851
+ fontSize: 1,
1852
+ padding: 3
1853
+ }, tool.name);
1854
+ return isSidebar ? /* @__PURE__ */ jsx(Stack, {
1855
+ gap: 1,
1856
+ children: [...main, ...more].map(button)
1857
+ }) : /* @__PURE__ */ jsxs(Flex, {
1858
+ gap: 1,
1859
+ align: "center",
1860
+ children: [main.map(button), more.length > 0 && /* @__PURE__ */ jsx(MenuButton, {
1861
+ id: "ncf-tool-menu-more",
1862
+ button: /* @__PURE__ */ jsx(Button, {
1863
+ icon: EllipsisHorizontalIcon,
1864
+ text: "Plus",
1865
+ mode: "bleed",
1866
+ fontSize: 1,
1867
+ padding: 3,
1868
+ selected: more.some((t) => t.name === activeToolName),
1869
+ title: `Outils techniques (${more.map((t) => t.title || t.name).join(", ")})`
1870
+ }),
1871
+ menu: /* @__PURE__ */ jsx(Menu, { children: more.map((tool) => /* @__PURE__ */ jsx(MenuItem, {
1872
+ as: ToolAnchor,
1873
+ name: tool.name,
1874
+ icon: tool.icon,
1875
+ text: tool.title || tool.name,
1876
+ pressed: activeToolName === tool.name
1877
+ }, tool.name)) }),
1878
+ popover: {
1879
+ portal: !0,
1880
+ placement: "bottom-end"
1881
+ }
1882
+ })]
1883
+ });
1884
+ }
1885
+ /**
1746
1886
  * Lanceur d'aperçu, posé dans la barre du haut à droite des outils.
1747
1887
  *
1748
1888
  * Deux questions, une seule poignée : **quelle version du site**, et **quel
@@ -1758,7 +1898,10 @@ function NcfPreviewLauncher(props) {
1758
1898
  if (environments.length === 0) return /* @__PURE__ */ jsxs(Flex, {
1759
1899
  align: "center",
1760
1900
  gap: 2,
1761
- children: [props.renderDefault(props), /* @__PURE__ */ jsx(NcfKitUpdate, { inline: props.context === "topbar" })]
1901
+ children: [/* @__PURE__ */ jsx(NcfToolButtons, {
1902
+ ...props,
1903
+ more: config.moreTools
1904
+ }), /* @__PURE__ */ jsx(NcfKitUpdate, { inline: props.context === "topbar" })]
1762
1905
  });
1763
1906
  let openInStudio = (environment, perspective) => {
1764
1907
  let path = presentationPath(environment.url, {
@@ -1774,7 +1917,10 @@ function NcfPreviewLauncher(props) {
1774
1917
  direction: inline ? "row" : "column",
1775
1918
  gap: inline ? 2 : 1,
1776
1919
  children: [
1777
- props.renderDefault(props),
1920
+ /* @__PURE__ */ jsx(NcfToolButtons, {
1921
+ ...props,
1922
+ more: config.moreTools
1923
+ }),
1778
1924
  /* @__PURE__ */ jsx(NcfKitUpdate, { inline }),
1779
1925
  /* @__PURE__ */ jsx(InlinePopover, {
1780
1926
  width: 248,
@@ -5679,11 +5825,43 @@ async function openComponentDefaults(options) {
5679
5825
  config.previewUrl && window.open(`${config.previewUrl}${preview.path}#${fillTemplate(preview.anchor, type, config.blockNamespace)}`, "_blank", "noopener");
5680
5826
  return;
5681
5827
  }
5682
- let lang = config.i18n?.defaultLocale ?? null, id = await client.fetch(`*[_type == $type] | order(select($lang != null && ${config.i18n?.field ?? "language"} == $lang => 0, 1))[0]._id`, {
5683
- type: preview.defaultsType,
5828
+ let id = await defaultsDocumentId(config, client);
5829
+ navigateIntent("edit", componentIntentParams(type, config.blockNamespace, preview, id ?? preview.defaultsType));
5830
+ }
5831
+ /** Document des valeurs par défaut (langue par défaut en priorité), ou null. */
5832
+ async function defaultsDocumentId(config, client) {
5833
+ let lang = config.i18n?.defaultLocale ?? null;
5834
+ return client.fetch(`*[_type == $type] | order(select($lang != null && ${config.i18n?.field ?? "language"} == $lang => 0, 1))[0]._id`, {
5835
+ type: config.componentPreview.defaultsType,
5684
5836
  lang
5685
5837
  }).catch(() => null);
5686
- navigateIntent("edit", componentIntentParams(type, config.blockNamespace, preview, id ?? preview.defaultsType));
5838
+ }
5839
+ /**
5840
+ * Paramètres de l'intention qui ouvre la page du design system dans Presentation,
5841
+ * avec le document des valeurs par défaut des composants à côté : un style changé
5842
+ * sur cette page change le composant partout où il n'est pas surchargé.
5843
+ */
5844
+ function designSystemIntentParams(config, documentId) {
5845
+ return {
5846
+ id: documentId.replace(/^drafts\./, ""),
5847
+ type: config.componentPreview.defaultsType,
5848
+ mode: "presentation",
5849
+ preview: config.componentPreview.path
5850
+ };
5851
+ }
5852
+ /**
5853
+ * Ouvre le design system : Presentation sur la page `/design-system`, document des
5854
+ * valeurs par défaut à côté. Sans valeurs par défaut dans le schéma : la page seule
5855
+ * dans Presentation.
5856
+ */
5857
+ async function openDesignSystem(options) {
5858
+ let { config, hasDefaults, client, navigateIntent, navigateUrl } = options;
5859
+ if (hasDefaults) {
5860
+ navigateIntent("edit", designSystemIntentParams(config, await defaultsDocumentId(config, client) ?? config.componentPreview.defaultsType));
5861
+ return;
5862
+ }
5863
+ let path = presentationPath(config.previewUrl ? `${config.previewUrl}${config.componentPreview.path}` : null);
5864
+ path && navigateUrl(path);
5687
5865
  }
5688
5866
  /** Ouvre un composant (voir openComponentDefaults). `null` : rien à ouvrir. */
5689
5867
  function useOpenComponent() {
@@ -7155,6 +7333,58 @@ function HistoryTool() {
7155
7333
  })
7156
7334
  });
7157
7335
  }
7336
+ /**
7337
+ * Onglet « Design system » : un raccourci, pas un écran. Il ouvre aussitôt la page
7338
+ * `/design-system` du site dans Presentation, avec le document des valeurs par
7339
+ * défaut des composants à côté. Cliquer un composant sur la page ouvre ses
7340
+ * réglages globaux : un style changé ici change le composant partout où il n'est
7341
+ * pas surchargé.
7342
+ */
7343
+ function DesignSystemTool() {
7344
+ let config = useKitConfig(), schema = useSchema(), router = useRouter(), client = useKitClient(), hasDefaults = !!schema.get(config.componentPreview.defaultsType), opened = useRef(!1), open = useCallback(() => void openDesignSystem({
7345
+ config,
7346
+ hasDefaults,
7347
+ client,
7348
+ navigateIntent: (intent, params) => router.navigateIntent(intent, params),
7349
+ navigateUrl: (path) => router.navigateUrl({ path })
7350
+ }), [
7351
+ config,
7352
+ hasDefaults,
7353
+ client,
7354
+ router
7355
+ ]);
7356
+ useEffect(() => {
7357
+ opened.current || (opened.current = !0, open());
7358
+ }, [open]);
7359
+ let available = hasDefaults || !!config.previewUrl;
7360
+ return /* @__PURE__ */ jsx(Card, {
7361
+ padding: 4,
7362
+ radius: 2,
7363
+ tone: available ? "default" : "caution",
7364
+ border: !0,
7365
+ children: /* @__PURE__ */ jsxs(Stack, {
7366
+ gap: 3,
7367
+ children: [
7368
+ /* @__PURE__ */ jsx(Text, {
7369
+ size: 1,
7370
+ weight: "semibold",
7371
+ children: "Design system"
7372
+ }),
7373
+ /* @__PURE__ */ jsx(Text, {
7374
+ size: 1,
7375
+ muted: !0,
7376
+ children: available ? `Ouverture de la page ${config.componentPreview.path} dans Presentation, avec les valeurs par défaut des composants. Un style changé ici change le composant partout où il n’est pas surchargé.` : "Ni document de valeurs par défaut des composants, ni previewUrl : rien à ouvrir. Voir la checklist du kit (README)."
7377
+ }),
7378
+ available && /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(Button, {
7379
+ text: "Ouvrir le design system",
7380
+ tone: "primary",
7381
+ fontSize: 1,
7382
+ onClick: open
7383
+ }) })
7384
+ ]
7385
+ })
7386
+ });
7387
+ }
7158
7388
  const store = /* @__PURE__ */ new Map();
7159
7389
  function entryFor(client, type, languageField, language) {
7160
7390
  let { projectId, dataset } = client.config(), key = `${projectId}:${dataset}:${type}:${language ?? ""}`, entry = store.get(key);
@@ -7616,10 +7846,11 @@ function ncfPreviewComponents() {
7616
7846
  * pas le Studio de démarrer : l'onglet concerné affiche le détail à corriger.
7617
7847
  */
7618
7848
  /** Noms des outils dans la barre du Studio. Exportés pour filtrer `tools`. */
7619
- const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_HISTORY_TOOL = "ncf-history", NCF_TOOL_NAMES = [
7849
+ const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_HISTORY_TOOL = "ncf-history", NCF_DESIGN_SYSTEM_TOOL = "ncf-design-system", NCF_TOOL_NAMES = [
7620
7850
  NCF_PAGES_TOOL,
7621
7851
  NCF_COMPONENTS_TOOL,
7622
- NCF_HISTORY_TOOL
7852
+ NCF_HISTORY_TOOL,
7853
+ NCF_DESIGN_SYSTEM_TOOL
7623
7854
  ], ncfKit = definePlugin((options) => {
7624
7855
  let config = resolveConfig(options), issues = validateConfig(config);
7625
7856
  return {
@@ -7669,6 +7900,21 @@ const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_
7669
7900
  Component: HistoryTool
7670
7901
  })
7671
7902
  }
7903
+ },
7904
+ {
7905
+ name: "designSystem",
7906
+ tool: {
7907
+ name: NCF_DESIGN_SYSTEM_TOOL,
7908
+ title: "Design system",
7909
+ icon: ColorWheelIcon,
7910
+ component: createToolComponent({
7911
+ name: "designSystem",
7912
+ title: "Design system",
7913
+ config,
7914
+ issues,
7915
+ Component: DesignSystemTool
7916
+ })
7917
+ }
7672
7918
  }
7673
7919
  ].filter((d) => config.tools[d.name]).map((d) => d.tool),
7674
7920
  schema: {
@@ -7680,6 +7926,6 @@ const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_
7680
7926
  form: { components: { input: createOverrideInput(config) } }
7681
7927
  };
7682
7928
  });
7683
- 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_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, 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, 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 };
7929
+ 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, 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 };
7684
7930
 
7685
7931
  //# sourceMappingURL=index.js.map