@nocode-factory/sanity-kit 2.68.0-rc.1 → 2.70.0-rc.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +37 -18
  2. package/dist/index.d.ts +48 -16
  3. package/dist/index.js +610 -383
  4. package/dist/index.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/hooks/useAssets.ts +1 -1
  7. package/src/hooks/useCollection.ts +5 -3
  8. package/src/hooks/useComponentDefaults.ts +1 -1
  9. package/src/hooks/useComponentNames.ts +1 -1
  10. package/src/hooks/usePageContents.ts +0 -1
  11. package/src/hooks/usePages.ts +5 -3
  12. package/src/hooks/useQueryData.ts +27 -59
  13. package/src/hooks/useRedirectMap.ts +1 -1
  14. package/src/hooks/useScheduledReleases.ts +27 -0
  15. package/src/hooks/useTranslationTodo.ts +1 -1
  16. package/src/hooks/useTranslationTodos.ts +0 -1
  17. package/src/lib/collectionRows.ts +26 -26
  18. package/src/lib/colors.ts +3 -6
  19. package/src/lib/pages.ts +16 -3
  20. package/src/lib/status.ts +118 -22
  21. package/src/tools/assets/AssetDetail.tsx +4 -4
  22. package/src/tools/assets/AssetTable.tsx +3 -3
  23. package/src/tools/collections/CollectionTable.tsx +53 -30
  24. package/src/tools/components/ComponentsTool.tsx +25 -2
  25. package/src/tools/pages/FieldValue.tsx +2 -2
  26. package/src/tools/pages/PagesTable.tsx +2 -2
  27. package/src/tools/pages/PagesTool.tsx +25 -2
  28. package/src/tools/pages/PathCell.tsx +1 -1
  29. package/src/tools/pages/TagCell.tsx +2 -2
  30. package/src/tools/pages/board/BoardView.tsx +2 -6
  31. package/src/tools/pages/board/PageNode.tsx +1 -1
  32. package/src/tools/pages/board/PagePanel.tsx +2 -2
  33. package/src/tools/presentation/PagesNavigator.tsx +1 -1
  34. package/src/ui/ActorName.tsx +1 -1
  35. package/src/ui/QuietInput.tsx +1 -1
  36. package/src/ui/StatusBadge.tsx +93 -7
  37. package/src/ui/StatusFilter.tsx +68 -0
  38. package/src/ui/formatDate.ts +2 -2
  39. package/src/version.ts +1 -1
  40. package/src/hooks/sharedListener.ts +0 -101
@@ -109,7 +109,7 @@ export function AssetDetail(props: AssetDetailProps) {
109
109
  ) : (
110
110
  <Flex align="center" justify="center" padding={5}>
111
111
  <Text size={1} muted>
112
- {asset.extension?.toUpperCase() || 'Fichier'} — pas d'aperçu
112
+ {asset.extension?.toUpperCase() || 'Fichier'} (pas d'aperçu)
113
113
  </Text>
114
114
  </Flex>
115
115
  )}
@@ -168,11 +168,11 @@ export function AssetDetail(props: AssetDetailProps) {
168
168
  </Stack>
169
169
 
170
170
  <Grid gridTemplateColumns={[1, 2]} gap={3}>
171
- <Metric label="Fichier" value={asset.originalFilename ?? '—'} />
171
+ <Metric label="Fichier" value={asset.originalFilename ?? 'None'} />
172
172
  <Metric label="Type" value={asset.extension?.toUpperCase() || asset._type.replace('sanity.', '')} />
173
173
  <Metric label="Taille" value={formatBytes(asset.size)} />
174
- <Metric label="Dimensions" value={asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : '—'} />
175
- <Metric label="Usage" value={asset.uses === undefined ? '—' : `${asset.uses}`} />
174
+ <Metric label="Dimensions" value={asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : 'Unknown'} />
175
+ <Metric label="Usage" value={asset.uses === undefined ? 'Unknown' : `${asset.uses}`} />
176
176
  <Metric label="Ajouté" value={formatDate(asset._createdAt)} />
177
177
  </Grid>
178
178
 
@@ -88,12 +88,12 @@ export function AssetTable(props: AssetTableProps) {
88
88
  </td>
89
89
  <td style={{padding: '6px 10px', textAlign: 'right', whiteSpace: 'nowrap'}}>
90
90
  <Text size={1} muted style={TABULAR}>
91
- {asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : '—'}
91
+ {asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : ''}
92
92
  </Text>
93
93
  </td>
94
94
  <td style={{padding: '6px 10px', whiteSpace: 'nowrap'}}>
95
95
  <Text size={1} muted textOverflow="ellipsis">
96
- {folder ? folderName(folder) : '—'}
96
+ {folder ? folderName(folder) : ''}
97
97
  </Text>
98
98
  </td>
99
99
  <td style={{padding: '6px 10px', textAlign: 'right', whiteSpace: 'nowrap'}}>
@@ -103,7 +103,7 @@ export function AssetTable(props: AssetTableProps) {
103
103
  </Badge>
104
104
  ) : (
105
105
  <Text size={1} style={TABULAR}>
106
- {asset.uses ?? '—'}
106
+ {asset.uses ?? ''}
107
107
  </Text>
108
108
  )}
109
109
  </td>
@@ -1,5 +1,5 @@
1
1
  import {useCallback, useMemo, useRef, useState, type ComponentType} from 'react'
2
- import {Badge, Box, Flex, Spinner, Stack, Text} from '@sanity/ui'
2
+ import {Box, Flex, Spinner, Stack, Text} from '@sanity/ui'
3
3
  import {ChevronDownIcon} from '@sanity/icons/ChevronDown'
4
4
  import {ChevronUpIcon} from '@sanity/icons/ChevronUp'
5
5
  import {DocumentIcon} from '@sanity/icons/Document'
@@ -16,6 +16,14 @@ import type {CollectionRow} from '../../lib/collectionRows'
16
16
  import {BORDER, BORDER_SOFT, TABULAR} from '../../ui/tokens'
17
17
  import {QueryError} from '../../ui/QueryError'
18
18
  import {CollectionToolbar, type CollectionView} from './CollectionToolbar'
19
+ import {StatusBadge} from '../../ui/StatusBadge'
20
+ import {StatusFilter} from '../../ui/StatusFilter'
21
+ import {STATUS_ORDER, type PageStatus} from '../../lib/status'
22
+
23
+ /** Clé de tri de la colonne Status (colonne du kit, pas un champ du schéma). */
24
+ const STATUS_KEY = '__status'
25
+ /** Largeur de la colonne Status : pastille + date courte d'une programmation. */
26
+ const STATUS_WIDTH = 230
19
27
 
20
28
  /** Colonnes montrées par défaut : le titre d'abord, puis les premières. */
21
29
  const DEFAULT_MAX = 6
@@ -82,6 +90,7 @@ export function CollectionTable({type, filter, params, newTemplate}: CollectionT
82
90
  const [selected, setSelected] = useState<string[] | null>(null)
83
91
  const [sort, setSort] = useState<CollectionSort>({key: null, direction: 'asc'})
84
92
  const [search, setSearch] = useState('')
93
+ const [statusFilter, setStatusFilter] = useState<PageStatus | null>(null)
85
94
  const [widths, setWidths] = useState<Record<string, number>>({})
86
95
 
87
96
  // Toutes les colonnes viennent du schéma (sans requête) : elles fixent le
@@ -96,16 +105,22 @@ export function CollectionTable({type, filter, params, newTemplate}: CollectionT
96
105
  const {visibleColumns, rows, loading, error, refresh} = useCollection(type, visibleKeys, {filter, params})
97
106
 
98
107
  const visible = useMemo(() => {
99
- const filtered = filterRows(rows, {search, columns: {}}, visibleColumns)
108
+ const searched = filterRows(rows, {search, columns: {}}, visibleColumns)
109
+ const filtered = statusFilter ? searched.filter((row) => row.status === statusFilter) : searched
110
+ if (sort.key === STATUS_KEY) {
111
+ const rank = (status: PageStatus) => STATUS_ORDER.indexOf(status)
112
+ const sorted = [...filtered].sort((a, b) => rank(a.status) - rank(b.status))
113
+ return sort.direction === 'asc' ? sorted : sorted.reverse()
114
+ }
100
115
  return sortRows(filtered, sort, visibleColumns)
101
- }, [rows, search, visibleColumns, sort])
116
+ }, [rows, search, statusFilter, visibleColumns, sort])
102
117
 
103
118
  // Largeur effective de chaque colonne visible (état ou défaut selon le type).
104
119
  const cols = useMemo(
105
120
  () => visibleColumns.map((column, index) => ({column, width: widths[column.key] ?? defaultWidth(column, index === 0)})),
106
121
  [visibleColumns, widths],
107
122
  )
108
- const totalWidth = useMemo(() => cols.reduce((sum, c) => sum + c.width, 0), [cols])
123
+ const totalWidth = useMemo(() => cols.reduce((sum, c) => sum + c.width, 0) + STATUS_WIDTH, [cols])
109
124
 
110
125
  const onToggleColumn = useCallback(
111
126
  (key: string) => {
@@ -182,6 +197,24 @@ export function CollectionTable({type, filter, params, newTemplate}: CollectionT
182
197
  visibleColumns.find((c, i) => i > 0 && /slug|path|url|email/i.test(c.key))?.key ??
183
198
  visibleColumns.find((c, i) => i > 0 && c.kind === 'text')?.key
184
199
 
200
+ const StatusArrow = sort.direction === 'asc' ? ChevronUpIcon : ChevronDownIcon
201
+ const statusHeader = (
202
+ <Box key={STATUS_KEY} paddingRight={2} style={{width: STATUS_WIDTH, flex: 'none', boxSizing: 'border-box', borderLeft: '2px solid transparent'}}>
203
+ <Flex
204
+ align="center"
205
+ gap={1}
206
+ onClick={() => onSort(STATUS_KEY)}
207
+ style={{cursor: 'pointer', userSelect: 'none'}}
208
+ title="Sort by status"
209
+ >
210
+ <Text size={1} weight="semibold" muted={sort.key !== STATUS_KEY}>
211
+ Status
212
+ </Text>
213
+ {sort.key === STATUS_KEY && <StatusArrow style={{fontSize: 14, opacity: 0.7, flex: 'none'}} />}
214
+ </Flex>
215
+ </Box>
216
+ )
217
+
185
218
  return (
186
219
  <Stack gap={3}>
187
220
  <CollectionToolbar
@@ -199,6 +232,8 @@ export function CollectionTable({type, filter, params, newTemplate}: CollectionT
199
232
  summary={summary}
200
233
  />
201
234
 
235
+ {rows.length > 0 && <StatusFilter rows={rows} value={statusFilter} onChange={setStatusFilter} />}
236
+
202
237
  {loading && rows.length === 0 ? (
203
238
  <Flex align="center" justify="center" padding={6} gap={3}>
204
239
  <Spinner muted />
@@ -235,6 +270,7 @@ export function CollectionTable({type, filter, params, newTemplate}: CollectionT
235
270
  <style>{`.ncf-coll-body a{display:contents;color:inherit;text-decoration:none}`}</style>
236
271
  <Box style={{width: totalWidth, minWidth: '100%'}}>
237
272
  {/* En-tête : libellé triable + déplaçable, poignée de largeur. */}
273
+ {/* Colonne Status du kit, toujours juste après le titre. */}
238
274
  <Flex
239
275
  paddingX={3}
240
276
  paddingY={3}
@@ -247,11 +283,11 @@ export function CollectionTable({type, filter, params, newTemplate}: CollectionT
247
283
  zIndex: 2,
248
284
  }}
249
285
  >
250
- {cols.map(({column, width}) => {
286
+ {cols.map(({column, width}, index) => {
251
287
  const active = sort.key === column.key
252
288
  const Arrow = sort.direction === 'asc' ? ChevronUpIcon : ChevronDownIcon
253
289
  const alignEnd = column.kind === 'number'
254
- return (
290
+ const cell = (
255
291
  <Box
256
292
  key={column.key}
257
293
  paddingRight={2}
@@ -307,6 +343,7 @@ export function CollectionTable({type, filter, params, newTemplate}: CollectionT
307
343
  />
308
344
  </Box>
309
345
  )
346
+ return index === 0 ? [cell, statusHeader] : cell
310
347
  })}
311
348
  </Flex>
312
349
 
@@ -332,22 +369,6 @@ export function CollectionTable({type, filter, params, newTemplate}: CollectionT
332
369
  )
333
370
  }
334
371
 
335
- /** Pastille de statut : vert = publié, ambre = brouillon jamais publié. */
336
- function StatusDot(props: {draftOnly?: boolean}) {
337
- return (
338
- <span
339
- title={props.draftOnly ? 'Not published' : 'Published'}
340
- style={{
341
- flex: 'none',
342
- width: 9,
343
- height: 9,
344
- borderRadius: '50%',
345
- background: props.draftOnly ? '#f5a623' : '#43d675',
346
- }}
347
- />
348
- )
349
- }
350
-
351
372
  /** Ligne de la vue TABLE : une cellule par colonne, largeurs fixes. */
352
373
  function TableRowView(props: {
353
374
  row: CollectionRow
@@ -375,7 +396,7 @@ function TableRowView(props: {
375
396
  const empty = !cell || cell.raw === null || cell.text === ''
376
397
  const first = index === 0
377
398
  const alignEnd = column.kind === 'number'
378
- return (
399
+ const content = (
379
400
  <Flex
380
401
  key={column.key}
381
402
  align="center"
@@ -396,15 +417,17 @@ function TableRowView(props: {
396
417
  textOverflow="ellipsis"
397
418
  style={{flex: alignEnd ? 'none' : 1, minWidth: 0, ...(column.kind === 'number' || column.kind === 'date' ? TABULAR : null)}}
398
419
  >
399
- {empty ? '—' : cell.text}
420
+ {empty ? '' : cell.text}
400
421
  </Text>
401
- {first && row.draftOnly && (
402
- <Badge tone="caution" fontSize={0} style={{flex: 'none'}}>
403
- Draft
404
- </Badge>
405
- )}
406
422
  </Flex>
407
423
  )
424
+ if (!first) return content
425
+ return [
426
+ content,
427
+ <Flex key={STATUS_KEY} align="center" paddingRight={2} style={{width: STATUS_WIDTH, flex: 'none', boxSizing: 'border-box'}}>
428
+ <StatusBadge status={row.status} scheduledAt={row.scheduledAt} live={row.live} hasDraft={row.hasDraft} showDate />
429
+ </Flex>,
430
+ ]
408
431
  })}
409
432
  </Flex>
410
433
  )
@@ -459,7 +482,7 @@ function ListRowView(props: {row: CollectionRow; titleKey?: string; subtitleKey?
459
482
  ) : null}
460
483
  </Stack>
461
484
 
462
- <StatusDot draftOnly={row.draftOnly} />
485
+ <StatusBadge status={row.status} scheduledAt={row.scheduledAt} live={row.live} hasDraft={row.hasDraft} showDate />
463
486
  </Flex>
464
487
  )
465
488
  }
@@ -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
- const [grouped, setGrouped] = useState(false)
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((value) => !value)}
168
+ onClick={() => setGrouped(!grouped)}
146
169
  />
147
170
  ) : null}
148
171
  {grouped && view === 'grid' ? (
@@ -64,8 +64,8 @@ export function FieldValue(props: FieldValueProps) {
64
64
  </Text>
65
65
  </>
66
66
  ) : (
67
- <Text size={0} muted>
68
- —
67
+ <Text size={0} muted aria-label="Not set">
68
+ {'\u00a0'}
69
69
  </Text>
70
70
  )}
71
71
  </Flex>
@@ -319,7 +319,7 @@ export function PagesTable(props: PagesTableProps) {
319
319
 
320
320
  {!hidden.has('status') && (
321
321
  <Flex align="center" gap={2} wrap="wrap" style={CELL}>
322
- <StatusBadge status={entryRow.status} />
322
+ <StatusBadge status={entryRow.status} scheduledAt={entryRow.scheduledAt} live={entryRow.live} hasDraft={entryRow.hasDraft} showDate />
323
323
  {Boolean(todos?.get(entryRow.id)) && (
324
324
  <Badge
325
325
  tone="caution"
@@ -364,7 +364,7 @@ export function PagesTable(props: PagesTableProps) {
364
364
  return (
365
365
  <Box key={column.key} style={CELL} title={value || undefined}>
366
366
  <Text size={0} muted={!value} textOverflow="ellipsis">
367
- {value || '—'}
367
+ {value || ''}
368
368
  </Text>
369
369
  </Box>
370
370
  )
@@ -19,6 +19,8 @@ import * as columnOps from '../../lib/columns'
19
19
  import {useColumnOptions} from '../../hooks/useColumnOptions'
20
20
  import {QueryError} from '../../ui/QueryError'
21
21
  import {PagesTable} from './PagesTable'
22
+ import {StatusFilter} from '../../ui/StatusFilter'
23
+ import type {PageStatus} from '../../lib/status'
22
24
  import {PagesToolbar} from './PagesToolbar'
23
25
  import {FieldLabel, ViewTabs, type PagesView} from './ViewTabs'
24
26
  import {ColumnVisibility, type HideableKey} from './ColumnVisibility'
@@ -43,6 +45,7 @@ export function PagesTool() {
43
45
  // Pages avec des champs « À traduire » (propagation depuis la version principale).
44
46
  const todos = useTranslationTodos()
45
47
  const [onlyTodo, setOnlyTodo] = useState(false)
48
+ const [statusFilter, setStatusFilter] = useState<PageStatus | null>(null)
46
49
  const [groupBy, setGroupBy] = useState<GroupBy>('none')
47
50
  const [rawColorBy, setColorBy] = useState<ColorBy>('tag')
48
51
  // `null` = tri automatique : l'ordre manuel (réordonné dans Presentation)
@@ -88,12 +91,21 @@ export function PagesTool() {
88
91
  const visible = useMemo(
89
92
  () =>
90
93
  sortRows(
91
- filterRows(rows, {search, locales: locale ? [locale] : undefined}).filter((row) => !onlyTodo || todos.has(row.id)),
94
+ filterRows(rows, {
95
+ search,
96
+ locales: locale ? [locale] : undefined,
97
+ statuses: statusFilter ? [statusFilter] : undefined,
98
+ }).filter((row) => !onlyTodo || todos.has(row.id)),
92
99
  effectiveSortKey,
93
100
  sortDirection,
94
101
  {typeOrder: config.pageTypeNames, pageOrder},
95
102
  ),
96
- [rows, search, locale, onlyTodo, todos, effectiveSortKey, sortDirection, config.pageTypeNames, pageOrder],
103
+ [rows, search, locale, statusFilter, onlyTodo, todos, effectiveSortKey, sortDirection, config.pageTypeNames, pageOrder],
104
+ )
105
+ // Nombres des filtres de statut : la langue choisie compte, pas le statut.
106
+ const statusScope = useMemo(
107
+ () => filterRows(rows, {locales: locale ? [locale] : undefined}),
108
+ [rows, locale],
97
109
  )
98
110
 
99
111
  // Un filtre qui réduit la liste ne doit pas laisser l'utilisateur sur une
@@ -304,6 +316,17 @@ export function PagesTool() {
304
316
  summary={summary}
305
317
  />
306
318
 
319
+ {rows.length > 0 && (
320
+ <StatusFilter
321
+ rows={statusScope}
322
+ value={statusFilter}
323
+ onChange={(value) => {
324
+ setStatusFilter(value)
325
+ setPage(0)
326
+ }}
327
+ />
328
+ )}
329
+
307
330
  {view !== 'list' ? (
308
331
  loading && rows.length === 0 ? (
309
332
  loadingState
@@ -31,7 +31,7 @@ export function PathCell(props: {
31
31
  if (!path) {
32
32
  return (
33
33
  <Text size={1} muted>
34
- —
34
+ No address
35
35
  </Text>
36
36
  )
37
37
  }
@@ -48,8 +48,8 @@ export function TagCell(props: TagCellProps) {
48
48
  </Text>
49
49
  </>
50
50
  ) : (
51
- <Text size={0} muted>
52
- —
51
+ <Text size={0} muted aria-label="Not set">
52
+ {'\u00a0'}
53
53
  </Text>
54
54
  )}
55
55
  </Flex>
@@ -25,7 +25,7 @@ import {
25
25
  layoutGraph,
26
26
  type LayoutMode,
27
27
  } from '../../../lib/elkLayout'
28
- import {STATUS_LABELS, type PageStatus} from '../../../lib/status'
28
+ import {STATUS_COLORS, STATUS_LABELS, type PageStatus} from '../../../lib/status'
29
29
  import {useBoardLayout} from '../../../context/BoardLayoutContext'
30
30
  import {useInternalColumns} from '../../../hooks/useInternalColumns'
31
31
  import {useColumnOptions} from '../../../hooks/useColumnOptions'
@@ -46,11 +46,7 @@ type BoardFlowNode = PageFlowNode | AnnotationFlowNode
46
46
  const isPageNode = (node: BoardFlowNode): node is PageFlowNode => node.type === 'page'
47
47
 
48
48
  /** Couleurs de la minimap, alignées sur les tons des badges de statut. */
49
- const MINIMAP_COLORS: Record<PageStatus, string> = {
50
- published: '#43d675',
51
- modified: '#f5a623',
52
- draft: '#8a8a8a',
53
- }
49
+ const MINIMAP_COLORS: Record<PageStatus, string> = STATUS_COLORS
54
50
 
55
51
  /**
56
52
  * React Flow s'habille via ses propres variables CSS. On les branche sur
@@ -263,7 +263,7 @@ function TreeNode(props: NodeProps<PageFlowNode> & {data: PageNodeData}) {
263
263
  </Text>
264
264
  ) : (
265
265
  <Flex gap={2} align="center">
266
- <StatusBadge status={row.status} />
266
+ <StatusBadge status={row.status} scheduledAt={row.scheduledAt} live={row.live} hasDraft={row.hasDraft} />
267
267
  {/* `nodrag` : sans ça, ouvrir le menu déplacerait le nœud. */}
268
268
  <Select
269
269
  className="nodrag"
@@ -119,7 +119,7 @@ export function PagePanel(props: PagePanelProps) {
119
119
  </Box>
120
120
 
121
121
  <Flex gap={2} align="center" wrap="wrap">
122
- <StatusBadge status={row.status} />
122
+ <StatusBadge status={row.status} scheduledAt={row.scheduledAt} live={row.live} hasDraft={row.hasDraft} showDate />
123
123
  {/* Pastille + libellé plutôt qu'un badge coloré : le contraste du
124
124
  texte sur une couleur arbitraire n'est jamais garanti. */}
125
125
  {colorLabel && color && (
@@ -141,7 +141,7 @@ export function PagePanel(props: PagePanelProps) {
141
141
  </Flex>
142
142
 
143
143
  <Text size={1} textOverflow="ellipsis" style={MONO}>
144
- {row.path ?? '—'}
144
+ {row.path ?? 'No address'}
145
145
  </Text>
146
146
 
147
147
  <Text size={0} muted>
@@ -158,7 +158,7 @@ function PagesNavigator() {
158
158
  {row.path}
159
159
  </Text>
160
160
  </Stack>
161
- {row.status !== 'published' && <StatusBadge status={row.status} />}
161
+ <StatusBadge status={row.status} scheduledAt={row.scheduledAt} live={row.live} hasDraft={row.hasDraft} />
162
162
  </Flex>
163
163
  </Card>
164
164
  )
@@ -10,7 +10,7 @@ import {useUser} from 'sanity'
10
10
  */
11
11
  export function ActorName(props: {actorId: string | null; actorName: string | null}) {
12
12
  const [user] = useUser(props.actorId ?? '')
13
- const label = props.actorName || user?.displayName || (props.actorId ? 'Unknown account' : '—')
13
+ const label = props.actorName || user?.displayName || (props.actorId ? 'Unknown account' : 'Unknown')
14
14
 
15
15
  return (
16
16
  <Text size={0} muted textOverflow="ellipsis" title={props.actorId ?? undefined}>
@@ -25,7 +25,7 @@ export function QuietInput(props: QuietInputProps) {
25
25
  // l'ancienne saisie après un changement venu d'ailleurs.
26
26
  key={props.value}
27
27
  defaultValue={props.value}
28
- placeholder={props.placeholder ?? '—'}
28
+ placeholder={props.placeholder ?? ''}
29
29
  // `onBlur` plutôt que `onChange` : on n'écrit pas dans Sanity à chaque
30
30
  // frappe.
31
31
  onBlur={(event) => {
@@ -1,11 +1,97 @@
1
- import {Badge} from '@sanity/ui'
2
- import {STATUS_LABELS, type PageStatus} from '../lib/status'
1
+ import {Box, Stack, Text} from '@sanity/ui'
2
+ import {Tooltip} from '@sanity/ui/tooltip'
3
+ import {formatSchedule, STATUS_COLORS, STATUS_LABELS, statusHelp, type PageStatus} from '../lib/status'
4
+ import {TABULAR} from './tokens'
3
5
 
4
- export function StatusBadge(props: {status: PageStatus}) {
5
- const {label, tone} = STATUS_LABELS[props.status]
6
+ export interface StatusBadgeProps {
7
+ status: PageStatus
8
+ /** Date de publication programmée (statut `scheduled`). */
9
+ scheduledAt?: string | null
10
+ /** Une version publiée existe (infobulle d'un `scheduled`). */
11
+ live?: boolean
12
+ /** Un brouillon existe en plus (infobulle d'un `scheduled`). */
13
+ hasDraft?: boolean
14
+ /** Ajoute la date courte après la pastille d'un `scheduled` (listes larges). */
15
+ showDate?: boolean
16
+ }
17
+
18
+ /**
19
+ * Pastille de statut, la MÊME partout dans le kit (collections, onglet Pages,
20
+ * navigateur de Presentation, board) : point de couleur + libellé, jamais la
21
+ * couleur seule. Survol : ce que veut dire le statut, la date d'une
22
+ * publication programmée et si l'item est déjà en ligne.
23
+ */
24
+ export function StatusBadge({status, scheduledAt, live, hasDraft, showDate}: StatusBadgeProps) {
25
+ const color = STATUS_COLORS[status]
26
+ const {label} = STATUS_LABELS[status]
27
+ const lines = statusHelp({status, scheduledAt, live, hasDraft})
28
+ const date = showDate && status === 'scheduled' ? formatSchedule(scheduledAt, true) : ''
29
+
30
+ return (
31
+ <Tooltip
32
+ portal
33
+ placement="top"
34
+ content={
35
+ <Box padding={2} style={{maxWidth: 280}}>
36
+ <Stack gap={2}>
37
+ <Text size={1} weight="semibold">
38
+ {label}
39
+ </Text>
40
+ {lines.map((line) => (
41
+ <Text key={line} size={1} muted>
42
+ {line}
43
+ </Text>
44
+ ))}
45
+ </Stack>
46
+ </Box>
47
+ }
48
+ >
49
+ <span
50
+ data-ncf-status={status}
51
+ style={{display: 'inline-flex', alignItems: 'center', gap: 8, flex: 'none', maxWidth: '100%'}}
52
+ >
53
+ <span
54
+ style={{
55
+ display: 'inline-flex',
56
+ alignItems: 'center',
57
+ gap: 6,
58
+ padding: '2px 9px 2px 7px',
59
+ borderRadius: 999,
60
+ background: `color-mix(in srgb, ${color} 15%, transparent)`,
61
+ color: 'var(--card-fg-color)',
62
+ fontSize: 12,
63
+ lineHeight: '18px',
64
+ fontWeight: 500,
65
+ whiteSpace: 'nowrap',
66
+ }}
67
+ >
68
+ <StatusDot status={status} />
69
+ {label}
70
+ </span>
71
+ {date ? (
72
+ <Text size={1} muted style={{whiteSpace: 'nowrap', ...TABULAR}}>
73
+ {date}
74
+ </Text>
75
+ ) : null}
76
+ </span>
77
+ </Tooltip>
78
+ )
79
+ }
80
+
81
+ /** Point de couleur seul (filtres, légendes). Draft : point vide, lisible sans la couleur. */
82
+ export function StatusDot({status, size = 7}: {status: PageStatus; size?: number}) {
83
+ const color = STATUS_COLORS[status]
6
84
  return (
7
- <Badge tone={tone} fontSize={0} title={STATUS_LABELS[props.status].help}>
8
- {label}
9
- </Badge>
85
+ <span
86
+ aria-hidden
87
+ style={{
88
+ width: size,
89
+ height: size,
90
+ flex: 'none',
91
+ borderRadius: '50%',
92
+ background: status === 'draft' ? 'transparent' : color,
93
+ boxShadow: status === 'draft' ? `inset 0 0 0 1.5px ${color}` : undefined,
94
+ }}
95
+ />
10
96
  )
11
97
  }
@@ -0,0 +1,68 @@
1
+ import {Flex} from '@sanity/ui'
2
+ import {countStatuses, STATUS_LABELS, type PageStatus} from '../lib/status'
3
+ import {StatusDot} from './StatusBadge'
4
+ import {TABULAR} from './tokens'
5
+
6
+ /** Ordre des filtres : ce qui est en ligne d'abord, puis ce qui demande une action. */
7
+ const FILTER_ORDER: readonly PageStatus[] = ['published', 'modified', 'scheduled', 'draft']
8
+
9
+ export interface StatusFilterProps {
10
+ rows: readonly {status: PageStatus}[]
11
+ value: PageStatus | null
12
+ onChange: (value: PageStatus | null) => void
13
+ }
14
+
15
+ /**
16
+ * Filtres de statut au-dessus d'une liste (collections, onglet Pages) : « All »
17
+ * puis un bouton par statut avec son nombre. Un clic filtre, un second clic sur
18
+ * le même statut revient à « All ».
19
+ */
20
+ export function StatusFilter({rows, value, onChange}: StatusFilterProps) {
21
+ const counts = countStatuses(rows)
22
+ return (
23
+ <Flex gap={2} wrap="wrap" role="group" aria-label="Filter by status">
24
+ <Chip selected={value === null} onClick={() => onChange(null)} label="All" count={rows.length} />
25
+ {FILTER_ORDER.map((status) => (
26
+ <Chip
27
+ key={status}
28
+ selected={value === status}
29
+ onClick={() => onChange(value === status ? null : status)}
30
+ label={STATUS_LABELS[status].label}
31
+ count={counts[status]}
32
+ status={status}
33
+ />
34
+ ))}
35
+ </Flex>
36
+ )
37
+ }
38
+
39
+ function Chip(props: {selected: boolean; onClick: () => void; label: string; count: number; status?: PageStatus}) {
40
+ const {selected, onClick, label, count, status} = props
41
+ const empty = count === 0 && !selected
42
+ return (
43
+ <button
44
+ type="button"
45
+ aria-pressed={selected}
46
+ onClick={onClick}
47
+ style={{
48
+ display: 'inline-flex',
49
+ alignItems: 'center',
50
+ gap: 6,
51
+ padding: '3px 10px',
52
+ borderRadius: 999,
53
+ border: `1px solid ${selected ? 'var(--card-focus-ring-color, #2276fc)' : 'var(--card-border-color, rgba(127,127,127,0.25))'}`,
54
+ background: selected ? 'color-mix(in srgb, var(--card-focus-ring-color, #2276fc) 12%, transparent)' : 'transparent',
55
+ color: 'var(--card-fg-color)',
56
+ opacity: empty ? 0.55 : 1,
57
+ font: 'inherit',
58
+ fontSize: 12,
59
+ lineHeight: '18px',
60
+ cursor: 'pointer',
61
+ }}
62
+ >
63
+ {status ? <StatusDot status={status} /> : null}
64
+ <span>{label}</span>
65
+ <span style={{color: 'var(--card-muted-fg-color)', fontWeight: 600, ...TABULAR}}>{count}</span>
66
+ </button>
67
+ )
68
+ }
@@ -8,7 +8,7 @@ const formatter = new Intl.DateTimeFormat('en-US', {
8
8
 
9
9
  /** Date lisible, ou un tiret cadratin quand il n'y en a pas. */
10
10
  export function formatDate(value: string | null | undefined): string {
11
- if (!value) return '—'
11
+ if (!value) return ''
12
12
  const date = new Date(value)
13
- return Number.isNaN(date.getTime()) ? '—' : formatter.format(date)
13
+ return Number.isNaN(date.getTime()) ? '' : formatter.format(date)
14
14
  }