@nocode-factory/sanity-kit 2.62.0-rc.0 → 2.62.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/CHANGELOG.md +3 -0
- package/dist/index.d.ts +23 -21
- package/dist/index.js +82 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/tools/navbar/KitUpdate.tsx +12 -18
- package/src/tools/navbar/KitUpdateNavbar.tsx +52 -0
- package/src/tools/navbar/PreviewLauncher.tsx +7 -2
- package/src/version.ts +1 -1
package/package.json
CHANGED
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'
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import {useState} from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import {Button, Flex, Stack, Text} from '@sanity/ui'
|
|
3
3
|
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'
|
|
8
|
-
import {BORDER, MONO} from '../../ui/tokens'
|
|
7
|
+
import {useKitUpdate, type KitUpdate} from '../../hooks/useKitUpdate'
|
|
9
8
|
|
|
10
9
|
const CHANGELOG = 'https://github.com/nocode-factory/ncf-sanity-kit/blob/main/docs/CHANGELOG.md'
|
|
11
10
|
|
|
@@ -20,8 +19,9 @@ const CHANGELOG = 'https://github.com/nocode-factory/ncf-sanity-kit/blob/main/do
|
|
|
20
19
|
* Invisible tant que le kit est à jour : un bouton permanent qui ne dit rien
|
|
21
20
|
* finit par ne plus être lu.
|
|
22
21
|
*/
|
|
23
|
-
export function NcfKitUpdate(props: {inline?: boolean}) {
|
|
24
|
-
const
|
|
22
|
+
export function NcfKitUpdate(props: {inline?: boolean; update?: KitUpdate}) {
|
|
23
|
+
const own = useKitUpdate()
|
|
24
|
+
const update = props.update ?? own
|
|
25
25
|
const [copied, setCopied] = useState(false)
|
|
26
26
|
|
|
27
27
|
if (!update.available) return null
|
|
@@ -65,12 +65,6 @@ export function NcfKitUpdate(props: {inline?: boolean}) {
|
|
|
65
65
|
</Text>
|
|
66
66
|
</Stack>
|
|
67
67
|
|
|
68
|
-
<Card padding={2} radius={2} style={{border: `1px solid ${BORDER}`}}>
|
|
69
|
-
<Text size={0} style={{...MONO, whiteSpace: 'pre-wrap', wordBreak: 'break-word', maxHeight: 160, overflowY: 'auto', display: 'block'}}>
|
|
70
|
-
{update.prompt}
|
|
71
|
-
</Text>
|
|
72
|
-
</Card>
|
|
73
|
-
|
|
74
68
|
<Flex gap={2} wrap="wrap">
|
|
75
69
|
<Button
|
|
76
70
|
mode="default"
|
|
@@ -94,13 +88,13 @@ export function NcfKitUpdate(props: {inline?: boolean}) {
|
|
|
94
88
|
/>
|
|
95
89
|
</Flex>
|
|
96
90
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
</
|
|
91
|
+
{/* Pas de texte de la consigne ici : le panneau (240 px) le couperait et
|
|
92
|
+
cacherait le bouton. Le bouton suffit ; la consigne est dans le presse-papiers. */}
|
|
93
|
+
<Text size={0} muted>
|
|
94
|
+
Copies the full instructions for Claude Code. Paste them into Claude Code, opened
|
|
95
|
+
on this project: it updates the kit, wires what the project needs and redeploys
|
|
96
|
+
the Studio.
|
|
97
|
+
</Text>
|
|
104
98
|
</Stack>
|
|
105
99
|
)}
|
|
106
100
|
</InlinePopover>
|
|
@@ -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
|
|
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
|
|
88
|
+
{inline && <NcfKitUpdate inline />}
|
|
84
89
|
|
|
85
90
|
<InlinePopover
|
|
86
91
|
width={248}
|
package/src/version.ts
CHANGED