@nocode-factory/sanity-kit 2.62.0-rc.1 → 2.63.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocode-factory/sanity-kit",
3
- "version": "2.62.0-rc.1",
3
+ "version": "2.63.0-rc.1",
4
4
  "description": "Outils Studio de NoCode Factory : Pages (liste + board), Composants, Historique",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ import {resolveConfig} from './config/resolve'
11
11
  import {validateConfig} from './config/validate'
12
12
  import {createToolComponent} from './tools/createToolComponent'
13
13
  import {createPreviewLauncher} from './tools/navbar/PreviewLauncher'
14
+ import {NcfKitNavbar} from './tools/navbar/KitUpdateNavbar'
14
15
  import {createKitLayout} from './ui/PreviewEditBridge'
15
16
  import {ncfAllowedOrigins} from './lib/studioLinks'
16
17
  import {PagesTool} from './tools/pages/PagesTool'
@@ -248,7 +249,7 @@ export const ncfKit = definePlugin<NcfKitConfig>((options) => {
248
249
  // outils techniques (Vision, planification) dans « Plus » (option moreTools).
249
250
  // Un projet n'a donc plus de menu d'outils à écrire.
250
251
  studio: {
251
- components: {toolMenu: createPreviewLauncher(config, issues), layout: createKitLayout(ncfAllowedOrigins(config), config.componentPreview.defaultsType)},
252
+ components: {toolMenu: createPreviewLauncher(config, issues), navbar: NcfKitNavbar, layout: createKitLayout(ncfAllowedOrigins(config), config.componentPreview.defaultsType)},
252
253
  },
253
254
 
254
255
  // Pastille bleue sur les champs d'une instance de composant qui surchargent
@@ -394,6 +395,7 @@ export {NcfPreviewHeader, ncfPreviewComponents} from './tools/presentation/Previ
394
395
  export {ncfPresentationComponents} from './tools/presentation/PagesNavigator'
395
396
  export {NcfPreviewLauncher, createPreviewLauncher} from './tools/navbar/PreviewLauncher'
396
397
  export {NcfKitUpdate} from './tools/navbar/KitUpdate'
398
+ export {NcfKitNavbar} from './tools/navbar/KitUpdateNavbar'
397
399
  export {HelpTextStyle} from './ui/HelpTextStyle'
398
400
  export {defineCodeEmbedType} from './form/codeEmbedType'
399
401
  export type {CodeEmbedTypeOptions} from './form/codeEmbedType'
@@ -4,7 +4,7 @@ import {ArrowUpIcon} from '@sanity/icons/ArrowUp'
4
4
  import {CheckmarkIcon} from '@sanity/icons/Checkmark'
5
5
  import {CopyIcon} from '@sanity/icons/Copy'
6
6
  import {InlinePopover} from '../../ui/Popover'
7
- import {useKitUpdate} from '../../hooks/useKitUpdate'
7
+ import {useKitUpdate, type KitUpdate} from '../../hooks/useKitUpdate'
8
8
 
9
9
  const CHANGELOG = 'https://github.com/nocode-factory/ncf-sanity-kit/blob/main/docs/CHANGELOG.md'
10
10
 
@@ -19,8 +19,9 @@ const CHANGELOG = 'https://github.com/nocode-factory/ncf-sanity-kit/blob/main/do
19
19
  * Invisible tant que le kit est à jour : un bouton permanent qui ne dit rien
20
20
  * finit par ne plus être lu.
21
21
  */
22
- export function NcfKitUpdate(props: {inline?: boolean}) {
23
- const update = useKitUpdate()
22
+ export function NcfKitUpdate(props: {inline?: boolean; update?: KitUpdate}) {
23
+ const own = useKitUpdate()
24
+ const update = props.update ?? own
24
25
  const [copied, setCopied] = useState(false)
25
26
 
26
27
  if (!update.available) return null
@@ -0,0 +1,52 @@
1
+ import {useEffect, useSyncExternalStore} from 'react'
2
+ import {Card, Flex, Box} from '@sanity/ui'
3
+ import type {NavbarProps} from 'sanity'
4
+ import {useKitUpdate} from '../../hooks/useKitUpdate'
5
+ import {NcfKitUpdate} from './KitUpdate'
6
+
7
+ /**
8
+ * La pastille de mise à jour du kit reste TOUJOURS dans la barre du haut.
9
+ *
10
+ * Fenêtre large : elle est dans la barre des outils (à côté de « Preview »).
11
+ * Fenêtre étroite : Sanity range les outils dans le menu ☰ ; la pastille, elle,
12
+ * reste visible à droite de la barre (fond blanc, même bordure). Une mise à jour en
13
+ * attente ne doit jamais être cachée dans un menu.
14
+ */
15
+ let inToolbar = 0
16
+ const listeners = new Set<() => void>()
17
+ const emit = () => listeners.forEach((l) => l())
18
+ const subscribe = (l: () => void) => {
19
+ listeners.add(l)
20
+ return () => listeners.delete(l)
21
+ }
22
+
23
+ /** Monté par la barre des outils quand elle s'affiche dans la barre du haut. */
24
+ export function useKitUpdateInToolbar(active: boolean) {
25
+ useEffect(() => {
26
+ if (!active) return
27
+ inToolbar++
28
+ emit()
29
+ return () => {
30
+ inToolbar--
31
+ emit()
32
+ }
33
+ }, [active])
34
+ }
35
+
36
+ export function NcfKitNavbar(props: NavbarProps) {
37
+ const shownInToolbar = useSyncExternalStore(subscribe, () => inToolbar > 0, () => false)
38
+ const update = useKitUpdate()
39
+ const pinned = update.available && !shownInToolbar
40
+ return (
41
+ <Flex align="stretch">
42
+ <Box flex={1} style={{minWidth: 0}}>
43
+ {props.renderDefault(props)}
44
+ </Box>
45
+ {pinned && (
46
+ <Card borderBottom tone="default" paddingX={2} style={{display: 'flex', alignItems: 'center', background: '#ffffff'}}>
47
+ <NcfKitUpdate inline update={update} />
48
+ </Card>
49
+ )}
50
+ </Flex>
51
+ )
52
+ }
@@ -10,6 +10,7 @@ import type {ConfigIssue, NcfEnvironment, ResolvedKitConfig} from '../../config/
10
10
  import {EyeOpenIcon} from '@sanity/icons/EyeOpen'
11
11
  import {LaunchIcon} from '@sanity/icons/Launch'
12
12
  import {NcfKitUpdate} from './KitUpdate'
13
+ import {useKitUpdateInToolbar} from './KitUpdateNavbar'
13
14
 
14
15
  /** Couleurs des trois cibles : brouillons (jaune pastel), préprod en ligne (vert pastel), prod (vert plein). */
15
16
  const TARGET_TONES = {
@@ -35,12 +36,16 @@ export function NcfPreviewLauncher(props: ToolMenuProps) {
35
36
  const router = useRouter()
36
37
  const open = useOpenOnline()
37
38
  const environments = config.environments
39
+ // Dans la barre du haut : la pastille est ici. Dans le menu ☰ (fenêtre étroite) :
40
+ // elle n'y est pas, la barre du haut l'affiche (NcfKitNavbar).
41
+ const topbar = props.context === 'topbar'
42
+ useKitUpdateInToolbar(topbar)
38
43
 
39
44
  if (environments.length === 0) {
40
45
  return (
41
46
  <Flex align="center" gap={2}>
42
47
  <NcfToolButtons {...props} more={config.moreTools} />
43
- <NcfKitUpdate inline={props.context === 'topbar'} />
48
+ {topbar && <NcfKitUpdate inline />}
44
49
  </Flex>
45
50
  )
46
51
  }
@@ -80,7 +85,7 @@ export function NcfPreviewLauncher(props: ToolMenuProps) {
80
85
  >
81
86
  <NcfToolButtons {...props} more={config.moreTools} />
82
87
 
83
- <NcfKitUpdate inline={inline} />
88
+ {inline && <NcfKitUpdate inline />}
84
89
 
85
90
  <InlinePopover
86
91
  width={248}
package/src/version.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
4
4
  * le vérifie.
5
5
  */
6
- export const KIT_VERSION = '2.62.0-rc.1'
6
+ export const KIT_VERSION = '2.63.0-rc.1'