@nocode-factory/sanity-kit 2.70.0-rc.1 → 2.70.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 +1 -1
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/tools/components/ComponentsTool.tsx +25 -2
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -59,13 +59,36 @@ export function ComponentsTool() {
|
|
|
59
59
|
)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const GROUPED_KEY = 'ncf-components-grouped'
|
|
63
|
+
|
|
64
|
+
/** Dernier choix « By group » de cet utilisateur, `null` s'il n'a jamais choisi. */
|
|
65
|
+
function readGroupedChoice(): boolean | null {
|
|
66
|
+
try {
|
|
67
|
+
const value = window.localStorage.getItem(GROUPED_KEY)
|
|
68
|
+
return value === null ? null : value === '1'
|
|
69
|
+
} catch {
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
62
74
|
function ComponentsToolInner() {
|
|
63
75
|
const config = useKitConfig()
|
|
64
76
|
const meta = useComponentMeta()
|
|
65
77
|
const {blockTypes, occurrences, pagesById, truncated, scanned, loading, error, refresh} = useOccurrences()
|
|
66
78
|
const [order, setOrder] = useState<Order>('type')
|
|
67
79
|
const [view, setView] = useState<View>('grid')
|
|
68
|
-
|
|
80
|
+
// « By group » ouvert par défaut (sans groupe, tout est sous « Sans groupe »,
|
|
81
|
+
// avec « New group » à portée) ; le choix de l'utilisateur est mémorisé (navigateur).
|
|
82
|
+
const [groupedChoice, setGroupedChoice] = useState<boolean | null>(readGroupedChoice)
|
|
83
|
+
const grouped = groupedChoice ?? true
|
|
84
|
+
const setGrouped = (value: boolean) => {
|
|
85
|
+
setGroupedChoice(value)
|
|
86
|
+
try {
|
|
87
|
+
window.localStorage.setItem(GROUPED_KEY, value ? '1' : '0')
|
|
88
|
+
} catch {
|
|
89
|
+
// Stockage indisponible : le choix vaut pour cette visite.
|
|
90
|
+
}
|
|
91
|
+
}
|
|
69
92
|
const [editing, setEditing] = useState<string | null>(null)
|
|
70
93
|
const [groupDialog, setGroupDialog] = useState<{mode: 'create' | 'rename'; id?: string; name: string} | null>(null)
|
|
71
94
|
const [deletingGroup, setDeletingGroup] = useState<ComponentGroup | null>(null)
|
|
@@ -142,7 +165,7 @@ function ComponentsToolInner() {
|
|
|
142
165
|
tone={grouped ? 'primary' : 'default'}
|
|
143
166
|
fontSize={1}
|
|
144
167
|
padding={2}
|
|
145
|
-
onClick={() => setGrouped(
|
|
168
|
+
onClick={() => setGrouped(!grouped)}
|
|
146
169
|
/>
|
|
147
170
|
) : null}
|
|
148
171
|
{grouped && view === 'grid' ? (
|
package/src/version.ts
CHANGED