@nocode-factory/sanity-kit 2.33.0 → 2.33.2
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 +1 -1
- package/dist/index.js +37 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/tools/presentation/PagesNavigator.tsx +30 -22
- package/src/tools/presentation/PresentationHeader.tsx +12 -14
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {useMemo, useState, type ComponentType} from 'react'
|
|
2
|
-
import {Box, Card, Flex,
|
|
2
|
+
import {Box, Button, Card, Flex, Spinner, Stack, Text, TextInput} from '@sanity/ui'
|
|
3
3
|
import {SearchIcon} from '@sanity/icons/Search'
|
|
4
4
|
import {usePresentationNavigate, usePresentationParams} from 'sanity/presentation'
|
|
5
5
|
import type {NcfKitConfig} from '../../config/types'
|
|
@@ -54,27 +54,35 @@ function PagesNavigator() {
|
|
|
54
54
|
<Text size={1} weight="semibold">
|
|
55
55
|
Pages
|
|
56
56
|
</Text>
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
<TextInput
|
|
58
|
+
icon={SearchIcon}
|
|
59
|
+
fontSize={1}
|
|
60
|
+
padding={2}
|
|
61
|
+
placeholder="Search"
|
|
62
|
+
value={search}
|
|
63
|
+
onChange={(e) => setSearch(e.currentTarget.value)}
|
|
64
|
+
/>
|
|
65
|
+
{/* Langues : boutons sous la recherche (un menu déroulant se décalait dans
|
|
66
|
+
ce panneau étroit). */}
|
|
67
|
+
{i18n && i18n.locales.length > 1 && (
|
|
68
|
+
<Flex gap={1} wrap="wrap">
|
|
69
|
+
{i18n.locales.map((code) => {
|
|
70
|
+
const active = code === activeLocale
|
|
71
|
+
return (
|
|
72
|
+
<Button
|
|
73
|
+
key={code}
|
|
74
|
+
text={code.toUpperCase()}
|
|
75
|
+
fontSize={1}
|
|
76
|
+
padding={2}
|
|
77
|
+
mode={active ? 'default' : 'ghost'}
|
|
78
|
+
tone={active ? 'primary' : 'default'}
|
|
79
|
+
aria-pressed={active}
|
|
80
|
+
onClick={() => setLocale(code)}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
83
|
+
})}
|
|
84
|
+
</Flex>
|
|
85
|
+
)}
|
|
78
86
|
</Stack>
|
|
79
87
|
<Box flex={1} style={{overflowY: 'auto', minHeight: 0}}>
|
|
80
88
|
{loading && !rows.length ? (
|
|
@@ -23,14 +23,10 @@ const save = (key: string, on: boolean) => {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (node.style.flexGrow !== '' && sibling && sibling.style.flexGrow !== '') return node
|
|
31
|
-
}
|
|
32
|
-
return null
|
|
33
|
-
}
|
|
26
|
+
// Panneaux de Presentation : identifiants HTML stables posés par Sanity
|
|
27
|
+
// (getPresentationPanelHtmlId : `presentation-narrow-panel-<onglet>`).
|
|
28
|
+
const previewPanel = () => document.getElementById('presentation-narrow-panel-preview')
|
|
29
|
+
const contentPanel = () => document.getElementById('presentation-narrow-panel-content')
|
|
34
30
|
|
|
35
31
|
/**
|
|
36
32
|
* En-tête de l'aperçu (Presentation) : la barre d'adresse native, plus
|
|
@@ -46,8 +42,7 @@ export function NcfPresentationHeader(props: PreviewHeaderProps) {
|
|
|
46
42
|
|
|
47
43
|
// Tablette : largeur maximale de l'iframe de l'aperçu, centrée.
|
|
48
44
|
useEffect(() => {
|
|
49
|
-
const
|
|
50
|
-
const iframe = panel?.querySelector('iframe') ?? null
|
|
45
|
+
const iframe = previewPanel()?.querySelector('iframe') ?? ref.current?.closest('div[style]')?.parentElement?.querySelector('iframe') ?? null
|
|
51
46
|
if (!iframe) return
|
|
52
47
|
if (tablet) {
|
|
53
48
|
iframe.style.setProperty('max-width', `${TABLET_WIDTH}px`, 'important')
|
|
@@ -62,10 +57,13 @@ export function NcfPresentationHeader(props: PreviewHeaderProps) {
|
|
|
62
57
|
|
|
63
58
|
// Panneau d'édition masqué : panneaux à droite de l'aperçu cachés, aperçu élargi.
|
|
64
59
|
useEffect(() => {
|
|
65
|
-
const panel =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const panel = previewPanel()
|
|
61
|
+
const content = contentPanel()
|
|
62
|
+
if (!panel || !content || !hideForm) return
|
|
63
|
+
// Le panneau d'édition et sa poignée de redimensionnement (juste avant lui).
|
|
64
|
+
const hidden: HTMLElement[] = [content]
|
|
65
|
+
const handle = content.previousElementSibling as HTMLElement | null
|
|
66
|
+
if (handle && handle !== panel && !handle.id) hidden.push(handle)
|
|
69
67
|
const apply = () => {
|
|
70
68
|
for (const h of hidden) if (h.style.getPropertyValue('display') !== 'none') h.style.setProperty('display', 'none', 'important')
|
|
71
69
|
if (panel.style.getPropertyPriority('flex-grow') !== 'important') panel.style.setProperty('flex-grow', '1000', 'important')
|
package/src/version.ts
CHANGED