@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
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ import { TranslateIcon } from "@sanity/icons/Translate";
34
34
  import { ChevronDownIcon } from "@sanity/icons/ChevronDown";
35
35
  import { ChevronRightIcon } from "@sanity/icons/ChevronRight";
36
36
  import { ChevronUpIcon } from "@sanity/icons/ChevronUp";
37
+ import { Tooltip } from "@sanity/ui/tooltip";
37
38
  import { ChevronLeftIcon } from "@sanity/icons/ChevronLeft";
38
39
  import { UlistIcon } from "@sanity/icons/Ulist";
39
40
  import { SyncIcon } from "@sanity/icons/Sync";
@@ -47,7 +48,6 @@ import { ThLargeIcon } from "@sanity/icons/ThLarge";
47
48
  import { ThListIcon } from "@sanity/icons/ThList";
48
49
  import { UploadIcon } from "@sanity/icons/Upload";
49
50
  import { DocumentIcon } from "@sanity/icons/Document";
50
- import { Tooltip } from "@sanity/ui/tooltip";
51
51
  import { EyeClosedIcon } from "@sanity/icons/EyeClosed";
52
52
  import { usePresentationNavigate, usePresentationParams } from "sanity/presentation";
53
53
  import { useToast } from "@sanity/ui/toast";
@@ -641,7 +641,13 @@ function collectLinks(value) {
641
641
  refs: [...refs]
642
642
  };
643
643
  }
644
- const isDraftId = (id) => id.startsWith("drafts."), isVersionId = (id) => id.startsWith("versions.");
644
+ /** Ordre d'affichage et de tri : du plus urgent au plus calme. */
645
+ const STATUS_ORDER$1 = [
646
+ "scheduled",
647
+ "modified",
648
+ "draft",
649
+ "published"
650
+ ], isDraftId = (id) => id.startsWith("drafts."), isVersionId = (id) => id.startsWith("versions.");
645
651
  /** Identifiant de la release, pour un id `versions.<release>.<doc>`. */
646
652
  function releaseId(id) {
647
653
  if (!isVersionId(id)) return null;
@@ -661,14 +667,17 @@ const mostRecent = (a, b) => a ? b ? a > b ? a : b : a : b;
661
667
  /**
662
668
  * Regroupe les documents par identifiant de base.
663
669
  *
664
- * - publié seul -> 'published'
665
- * - brouillon seul -> 'draft' (jamais publié, absent du site)
670
+ * - publication programmée -> 'scheduled' (prime sur tout : c'est ce qui va changer)
666
671
  * - publié + brouillon -> 'modified' (modifications non publiées)
672
+ * - brouillon seul -> 'draft' (jamais publié ou retiré du site)
673
+ * - publié seul -> 'published'
667
674
  *
668
- * Les versions de release sont conservées mais n'influencent pas le statut :
669
- * elles ne sont ni en ligne, ni des modifications en attente au sens du Studio.
675
+ * Une version de release ne compte que si sa release est programmée
676
+ * (`schedules`) : une release en préparation n'est ni en ligne ni attendue.
677
+ * Un item qui n'existe QUE dans une release programmée (brouillon programmé,
678
+ * jamais publié) est bien listé, en `scheduled`.
670
679
  */
671
- function mergeVersions(docs) {
680
+ function mergeVersions(docs, schedules = /* @__PURE__ */ new Map()) {
672
681
  let groups = /* @__PURE__ */ new Map();
673
682
  for (let doc of docs) {
674
683
  let id = baseId(doc._id), group = groups.get(id) ?? { versions: {} };
@@ -681,9 +690,12 @@ function mergeVersions(docs) {
681
690
  }
682
691
  let merged = [];
683
692
  for (let [id, group] of groups) {
684
- let reference = group.draft ?? group.published ?? Object.values(group.versions)[0];
685
- if (!reference || !group.published && !group.draft) continue;
686
- let status = group.published ? group.draft ? "modified" : "published" : "draft";
693
+ let scheduled = Object.keys(group.versions).map((release) => ({
694
+ release,
695
+ at: schedules.get(release)
696
+ })).filter((entry) => !!entry.at).sort((a, b) => a.at < b.at ? -1 : +(a.at > b.at))[0], reference = group.draft ?? group.published ?? (scheduled ? group.versions[scheduled.release] : void 0);
697
+ if (!reference) continue;
698
+ let status = scheduled ? "scheduled" : group.published ? group.draft ? "modified" : "published" : "draft", updatedAt = mostRecent(group.published?._updatedAt, group.draft?._updatedAt) ?? reference._updatedAt;
687
699
  merged.push({
688
700
  id,
689
701
  status,
@@ -691,7 +703,10 @@ function mergeVersions(docs) {
691
703
  ...group.published ? { published: group.published } : {},
692
704
  ...group.draft ? { draft: group.draft } : {},
693
705
  versions: group.versions,
694
- ...mostRecent(group.published?._updatedAt, group.draft?._updatedAt) ? { updatedAt: mostRecent(group.published?._updatedAt, group.draft?._updatedAt) } : {}
706
+ ...updatedAt ? { updatedAt } : {},
707
+ ...scheduled ? { scheduledAt: scheduled.at } : {},
708
+ live: !!group.published,
709
+ hasDraft: !!group.draft
695
710
  });
696
711
  }
697
712
  return merged;
@@ -700,19 +715,66 @@ const STATUS_LABELS = {
700
715
  published: {
701
716
  label: "Published",
702
717
  tone: "positive",
703
- help: "Live, up to date"
718
+ help: "Live, up to date."
704
719
  },
705
720
  modified: {
706
721
  label: "Modified",
707
722
  tone: "caution",
708
- help: "Live, with unpublished changes"
723
+ help: "Live, with changes not published yet."
724
+ },
725
+ scheduled: {
726
+ label: "Scheduled",
727
+ tone: "primary",
728
+ help: "Publication scheduled: it goes live automatically on the date shown."
709
729
  },
710
730
  draft: {
711
- label: "Not published",
731
+ label: "Draft",
712
732
  tone: "default",
713
- help: "Not on the site: never published, or removed from the site (content kept in the draft)"
733
+ help: "Not on the site: never published, or removed from the site (content kept in the draft)."
714
734
  }
715
- };
735
+ }, STATUS_COLORS = {
736
+ draft: "#8b93a1",
737
+ modified: "#f08a24",
738
+ scheduled: "#2f7bf5",
739
+ published: "#2fb466"
740
+ }, scheduleFormat = new Intl.DateTimeFormat(void 0, {
741
+ day: "numeric",
742
+ month: "short",
743
+ year: "numeric",
744
+ hour: "2-digit",
745
+ minute: "2-digit"
746
+ }), shortFormat = new Intl.DateTimeFormat(void 0, {
747
+ day: "numeric",
748
+ month: "short",
749
+ hour: "2-digit",
750
+ minute: "2-digit"
751
+ });
752
+ /** Date de programmation lisible (« 1 Mar 2027, 10:00 », fuseau du navigateur). */
753
+ function formatSchedule(iso, short = !1) {
754
+ if (!iso) return "";
755
+ let date = new Date(iso);
756
+ return Number.isNaN(date.getTime()) ? "" : (short ? shortFormat : scheduleFormat).format(date);
757
+ }
758
+ /** Lignes de l'infobulle : ce qu'est le statut, puis ce qu'il faut savoir en plus. */
759
+ function statusHelp(details) {
760
+ let { status, scheduledAt, live, hasDraft } = details;
761
+ if (status === "scheduled") {
762
+ let lines = [live ? "Currently live: this update goes live automatically on the date shown." : "Not on the site yet: it goes live automatically on the date shown."];
763
+ return hasDraft && lines.push("Also has other changes not scheduled (draft)."), lines.push("Change the date in Scheduled drafts / Releases."), scheduledAt ? [`Scheduled for ${formatSchedule(scheduledAt)}.`, ...lines] : lines;
764
+ }
765
+ return [STATUS_LABELS[status].help];
766
+ }
767
+ /** Nombre d'items par statut (filtres). */
768
+ function countStatuses(rows) {
769
+ let counts = {
770
+ published: 0,
771
+ modified: 0,
772
+ scheduled: 0,
773
+ draft: 0
774
+ };
775
+ for (let row of rows) counts[row.status] += 1;
776
+ return counts;
777
+ }
716
778
  /**
717
779
  * Graphe des liens réels entre pages.
718
780
  *
@@ -1423,7 +1485,7 @@ function explainGrantError(error) {
1423
1485
  * quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
1424
1486
  * le vérifie.
1425
1487
  */
1426
- const KIT_VERSION = "2.68.0-rc.1";
1488
+ const KIT_VERSION = "2.70.0-rc.2";
1427
1489
  /**
1428
1490
  * Signale ce Studio au service du kit, une fois par montage.
1429
1491
  *
@@ -1931,7 +1993,7 @@ function useKitUpdate() {
1931
1993
  !controller.signal.aborted && body?.version && setLatest(body.version);
1932
1994
  }).catch(() => {}), () => controller.abort();
1933
1995
  }, []);
1934
- let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.68.0-rc.1") > 0);
1996
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.70.0-rc.2") > 0);
1935
1997
  return {
1936
1998
  current: KIT_VERSION,
1937
1999
  latest,
@@ -2300,64 +2362,19 @@ function createPreviewLauncher(config, issues) {
2300
2362
  });
2301
2363
  };
2302
2364
  }
2303
- const entries = /* @__PURE__ */ new Map(), RETRY_MIN_MS = 5e3;
2304
- function listenFilter(types, publishedOnly) {
2305
- return publishedOnly ? "*[_type in $types && !(_id in path(\"drafts.**\")) && !(_id in path(\"versions.**\"))]" : "*[_type in $types]";
2306
- }
2307
- function subscribeShared(client, types, publishedOnly, listener, tag) {
2308
- let { projectId, dataset } = client.config(), sorted = [...types].sort(), key = `${projectId}:${dataset}:${publishedOnly ? "published" : "all"}:${sorted.join(",")}`, entry = entries.get(key);
2309
- if (!entry) {
2310
- let listeners = /* @__PURE__ */ new Set(), notify = () => listeners.forEach((l) => l()), retry = RETRY_MIN_MS, retryTimer, stopped = !1, unsubscribe = () => {}, open = (reconnect) => {
2311
- let subscription = client.listen(listenFilter(sorted, publishedOnly), { types: sorted }, {
2312
- visibility: "query",
2313
- events: ["welcome", "mutation"],
2314
- includeResult: !1,
2315
- includePreviousRevision: !1,
2316
- tag
2317
- }).subscribe({
2318
- next: (event) => {
2319
- if (event.type === "welcome") {
2320
- retry = RETRY_MIN_MS, reconnect && notify();
2321
- return;
2322
- }
2323
- notify();
2324
- },
2325
- error: () => {
2326
- stopped || (retryTimer = setTimeout(() => open(!0), retry), retry = Math.min(retry * 2, 6e4));
2327
- }
2328
- });
2329
- unsubscribe = () => subscription.unsubscribe();
2330
- };
2331
- open(!1), entry = {
2332
- listeners,
2333
- stop: () => {
2334
- stopped = !0, retryTimer && clearTimeout(retryTimer), unsubscribe();
2335
- }
2336
- }, entries.set(key, entry);
2337
- }
2338
- entry.listeners.add(listener);
2339
- let current = entry;
2340
- return () => {
2341
- current.listeners.delete(listener), current.listeners.size === 0 && (current.stop(), entries.delete(key));
2342
- };
2343
- }
2344
- /** Étiquette acceptée par Sanity : lettres, chiffres, . _ - (75 caractères au plus). */
2345
- function kitTag(tag) {
2346
- return `ncf-kit.${(tag ?? "query").replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 66)}`;
2347
- }
2348
2365
  /**
2349
2366
  * Exécute une requête GROQ et la rejoue quand le contenu change.
2350
2367
  *
2351
- * Le rafraîchissement passe par un signal d'écoute puis une nouvelle requête, plutôt
2368
+ * Le rafraîchissement passe par un `listen` puis une nouvelle requête, plutôt
2352
2369
  * que par l'application des mutations reçues : c'est plus lent mais toujours
2353
2370
  * cohérent, y compris quand une publication modifie plusieurs documents.
2354
2371
  */
2355
2372
  function useQueryData(query, params, options = {}) {
2356
- let client = useKitClient(), { listenTypes, enabled = !0, publishedOnly = !1 } = options, tag = kitTag(options.tag), [data, setData] = useState(null), [loading, setLoading] = useState(enabled), [error, setError] = useState(null), [tick, setTick] = useState(0), refresh = useCallback(() => setTick((n) => n + 1), []), paramsKey = JSON.stringify(params), stableParams = useMemo(() => JSON.parse(paramsKey), [paramsKey]);
2373
+ let client = useKitClient(), { listenTypes, listenQuery, enabled = !0 } = options, [data, setData] = useState(null), [loading, setLoading] = useState(enabled), [error, setError] = useState(null), [tick, setTick] = useState(0), refresh = useCallback(() => setTick((n) => n + 1), []), paramsKey = JSON.stringify(params), stableParams = useMemo(() => JSON.parse(paramsKey), [paramsKey]);
2357
2374
  useEffect(() => {
2358
2375
  if (!enabled) return;
2359
2376
  let cancelled = !1;
2360
- return setLoading(!0), client.fetch(query, stableParams, { tag }).then((result) => {
2377
+ return setLoading(!0), client.fetch(query, stableParams).then((result) => {
2361
2378
  cancelled || (setData(result), setError(null));
2362
2379
  }).catch((cause) => {
2363
2380
  cancelled || setError(cause instanceof Error ? cause : Error(String(cause)));
@@ -2377,29 +2394,24 @@ function useQueryData(query, params, options = {}) {
2377
2394
  refreshRef.current = refresh;
2378
2395
  let typesKey = (listenTypes ?? []).join(",");
2379
2396
  return useEffect(() => {
2380
- if (!enabled || !typesKey) return;
2381
- let timer, lastRefresh = Date.now(), staleWhileHidden = !1, run = () => {
2382
- if (timer = void 0, typeof document < "u" && document.hidden) {
2383
- staleWhileHidden = !0;
2384
- return;
2385
- }
2386
- lastRefresh = Date.now(), refreshRef.current();
2387
- }, onChange = () => {
2388
- if (timer) return;
2389
- let wait = Math.max(600, 3e3 - (Date.now() - lastRefresh));
2390
- timer = setTimeout(run, wait);
2391
- }, onVisible = () => {
2392
- !document.hidden && staleWhileHidden && (staleWhileHidden = !1, lastRefresh = Date.now(), refreshRef.current());
2393
- }, unsubscribe = subscribeShared(client, typesKey.split(","), publishedOnly, onChange, tag);
2394
- return document.addEventListener("visibilitychange", onVisible), () => {
2395
- timer && clearTimeout(timer), unsubscribe(), document.removeEventListener("visibilitychange", onVisible);
2397
+ if (!enabled || !typesKey && !listenQuery) return;
2398
+ let types = typesKey ? typesKey.split(",") : [], timer, subscription = client.listen(listenQuery ?? "*[_type in $types]", listenQuery ? {} : { types }, {
2399
+ visibility: "query",
2400
+ events: ["mutation"]
2401
+ }).subscribe({
2402
+ next: () => {
2403
+ timer && clearTimeout(timer), timer = setTimeout(() => refreshRef.current(), 600);
2404
+ },
2405
+ error: () => {}
2406
+ });
2407
+ return () => {
2408
+ timer && clearTimeout(timer), subscription.unsubscribe();
2396
2409
  };
2397
2410
  }, [
2398
2411
  client,
2399
2412
  typesKey,
2400
- enabled,
2401
- publishedOnly,
2402
- tag
2413
+ listenQuery,
2414
+ enabled
2403
2415
  ]), {
2404
2416
  data,
2405
2417
  loading,
@@ -2415,10 +2427,7 @@ const ASSET_TYPES = ["sanity.imageAsset", "sanity.fileAsset"];
2415
2427
  * pris au prochain rafraîchissement.
2416
2428
  */
2417
2429
  function useAssets() {
2418
- return useQueryData("*[_type in $types]{\n _id, _type, _createdAt, _updatedAt, originalFilename, extension, mimeType, size, url,\n title, altText, description,\n \"dimensions\": metadata.dimensions, \"lqip\": metadata.lqip,\n \"uses\": count(*[references(^._id)])\n } | order(_createdAt desc)", { types: ASSET_TYPES }, {
2419
- listenTypes: ASSET_TYPES,
2420
- tag: "assets"
2421
- });
2430
+ return useQueryData("*[_type in $types]{\n _id, _type, _createdAt, _updatedAt, originalFilename, extension, mimeType, size, url,\n title, altText, description,\n \"dimensions\": metadata.dimensions, \"lqip\": metadata.lqip,\n \"uses\": count(*[references(^._id)])\n } | order(_createdAt desc)", { types: ASSET_TYPES }, { listenTypes: ASSET_TYPES });
2422
2431
  }
2423
2432
  const newId$1 = () => `f${Math.random().toString(36).slice(2, 10)}`;
2424
2433
  /**
@@ -3343,8 +3352,8 @@ function reorderBefore(ordered, dragged, target) {
3343
3352
  function formatDocumentValue(value, type, invert = !1) {
3344
3353
  return value == null ? type === "boolean" && invert ? "Yes" : "" : type === "boolean" ? (invert ? !value : value) ? "Yes" : "No" : type === "number" ? typeof value == "number" ? String(value) : "" : typeof value == "string" ? value.trim() : typeof value == "number" || typeof value == "boolean" ? String(value) : "";
3345
3354
  }
3346
- function buildPageRows(docs, config, documentColumns = [], redirects = null) {
3347
- return mergeVersions(docs).map((merged) => {
3355
+ function buildPageRows(docs, config, documentColumns = [], redirects = null, schedules) {
3356
+ return mergeVersions(docs, schedules).map((merged) => {
3348
3357
  let doc = merged.doc, pageType = pageTypeFor(doc._type, config.pageTypes), path = finalPath({
3349
3358
  slug: doc.ncfSlug ?? null,
3350
3359
  locale: doc.ncfLocale ?? null
@@ -3357,6 +3366,9 @@ function buildPageRows(docs, config, documentColumns = [], redirects = null) {
3357
3366
  url: toUrl(config.previewUrl, path),
3358
3367
  locale: doc.ncfLocale ?? null,
3359
3368
  status: merged.status,
3369
+ scheduledAt: merged.scheduledAt ?? null,
3370
+ live: merged.live,
3371
+ hasDraft: merged.hasDraft,
3360
3372
  updatedAt: merged.updatedAt ?? null,
3361
3373
  blockCount: doc.ncfBlockCount ?? 0,
3362
3374
  noindex: !!doc.ncfNoindex,
@@ -3365,11 +3377,7 @@ function buildPageRows(docs, config, documentColumns = [], redirects = null) {
3365
3377
  });
3366
3378
  }
3367
3379
  /** Ordre d'affichage des statuts : du plus « à traiter » au plus stable. */
3368
- const STATUS_ORDER = {
3369
- modified: 0,
3370
- draft: 1,
3371
- published: 2
3372
- }, compare = (a, b, key, options) => {
3380
+ const STATUS_ORDER = Object.fromEntries(STATUS_ORDER$1.map((status, index) => [status, index])), compare = (a, b, key, options) => {
3373
3381
  switch (key) {
3374
3382
  case "structure": {
3375
3383
  let order = options.typeOrder ?? [], rank = (row) => {
@@ -3405,13 +3413,19 @@ function localesInRows(rows) {
3405
3413
  }
3406
3414
  /** Redirections publiées du Studio, tenues à jour : pour afficher les URL finales. */
3407
3415
  function useRedirectMap(redirectType) {
3408
- let { data } = useQueryData("*[_type == $type && defined(from) && defined(to) && !(_id in path(\"drafts.**\"))]{from, to}", useMemo(() => ({ type: redirectType }), [redirectType]), {
3409
- listenTypes: useMemo(() => [redirectType], [redirectType]),
3410
- publishedOnly: !0,
3411
- tag: "redirect-map"
3412
- });
3416
+ let { data } = useQueryData("*[_type == $type && defined(from) && defined(to) && !(_id in path(\"drafts.**\"))]{from, to}", useMemo(() => ({ type: redirectType }), [redirectType]), { listenTypes: useMemo(() => [redirectType], [redirectType]) });
3413
3417
  return useMemo(() => redirectMapOf(data ?? []), [data]);
3414
3418
  }
3419
+ /** Releases programmées (Scheduled drafts et Releases : même mécanisme). */
3420
+ const EMPTY = /* @__PURE__ */ new Map();
3421
+ /**
3422
+ * Publications programmées, tenues à jour : nom de la release -> date.
3423
+ * Sert à afficher le statut « Scheduled » dans les listes du kit.
3424
+ */
3425
+ function useScheduledReleases() {
3426
+ let { data } = useQueryData("*[_id in path(\"_.releases.**\") && state == \"scheduled\"]{name, \"at\": coalesce(publishAt, metadata.intendedPublishAt)}", {}, { listenQuery: "*[_id in path(\"_.releases.**\")]" });
3427
+ return useMemo(() => data?.length ? new Map(data.filter((r) => !!(r.name && r.at)).map((r) => [r.name, r.at])) : EMPTY, [data]);
3428
+ }
3415
3429
  /**
3416
3430
  * Toutes les pages du site, brouillons compris, tenues à jour.
3417
3431
  *
@@ -3427,16 +3441,14 @@ function usePages(documentColumns = []) {
3427
3441
  config,
3428
3442
  pageBuilderField,
3429
3443
  columns
3430
- ]), useMemo(() => ({ types: config.pageTypeNames }), [config.pageTypeNames]), {
3431
- listenTypes: config.pageTypeNames,
3432
- tag: "pages"
3433
- }), redirects = useRedirectMap(config.redirectType);
3444
+ ]), useMemo(() => ({ types: config.pageTypeNames }), [config.pageTypeNames]), { listenTypes: config.pageTypeNames }), redirects = useRedirectMap(config.redirectType), schedules = useScheduledReleases();
3434
3445
  return {
3435
- rows: useMemo(() => data ? buildPageRows(data, config, columns, redirects) : [], [
3446
+ rows: useMemo(() => data ? buildPageRows(data, config, columns, redirects, schedules) : [], [
3436
3447
  data,
3437
3448
  config,
3438
3449
  columns,
3439
- redirects
3450
+ redirects,
3451
+ schedules
3440
3452
  ]),
3441
3453
  loading,
3442
3454
  error,
@@ -4671,7 +4683,6 @@ function LanguagesSync() {
4671
4683
  function useTranslationTodos() {
4672
4684
  let config = useKitConfig(), { data } = useQueryData("*[_type == $type && count(paths) > 0]{documentId, \"count\": count(paths)}", useMemo(() => ({ type: TRANSLATION_TODO_TYPE }), []), {
4673
4685
  listenTypes: [TRANSLATION_TODO_TYPE],
4674
- tag: "translation-todos",
4675
4686
  enabled: !!config.i18n
4676
4687
  });
4677
4688
  return useMemo(() => new Map((data ?? []).map((t) => [t.documentId, t.count])), [data]);
@@ -4739,12 +4750,6 @@ function groupPageRows(rows, groupBy, options) {
4739
4750
  rows: buckets.get(value) ?? []
4740
4751
  }));
4741
4752
  }
4742
- /** Couleurs des statuts, alignées sur les tons des badges. */
4743
- const STATUS_COLORS = {
4744
- published: "#43d675",
4745
- modified: "#f5a623",
4746
- draft: "#8a8a8a"
4747
- };
4748
4753
  /**
4749
4754
  * Applique une opacité à une couleur hexadécimale.
4750
4755
  *
@@ -4948,13 +4953,87 @@ function QueryError(props) {
4948
4953
  })
4949
4954
  });
4950
4955
  }
4951
- function StatusBadge(props) {
4952
- let { label, tone } = STATUS_LABELS[props.status];
4953
- return /* @__PURE__ */ jsx(Badge, {
4954
- tone,
4955
- fontSize: 0,
4956
- title: STATUS_LABELS[props.status].help,
4957
- children: label
4956
+ /**
4957
+ * Pastille de statut, la MÊME partout dans le kit (collections, onglet Pages,
4958
+ * navigateur de Presentation, board) : point de couleur + libellé, jamais la
4959
+ * couleur seule. Survol : ce que veut dire le statut, la date d'une
4960
+ * publication programmée et si l'item est déjà en ligne.
4961
+ */
4962
+ function StatusBadge({ status, scheduledAt, live, hasDraft, showDate }) {
4963
+ let color = STATUS_COLORS[status], { label } = STATUS_LABELS[status], lines = statusHelp({
4964
+ status,
4965
+ scheduledAt,
4966
+ live,
4967
+ hasDraft
4968
+ }), date = showDate && status === "scheduled" ? formatSchedule(scheduledAt, !0) : "";
4969
+ return /* @__PURE__ */ jsx(Tooltip, {
4970
+ portal: !0,
4971
+ placement: "top",
4972
+ content: /* @__PURE__ */ jsx(Box, {
4973
+ padding: 2,
4974
+ style: { maxWidth: 280 },
4975
+ children: /* @__PURE__ */ jsxs(Stack, {
4976
+ gap: 2,
4977
+ children: [/* @__PURE__ */ jsx(Text, {
4978
+ size: 1,
4979
+ weight: "semibold",
4980
+ children: label
4981
+ }), lines.map((line) => /* @__PURE__ */ jsx(Text, {
4982
+ size: 1,
4983
+ muted: !0,
4984
+ children: line
4985
+ }, line))]
4986
+ })
4987
+ }),
4988
+ children: /* @__PURE__ */ jsxs("span", {
4989
+ "data-ncf-status": status,
4990
+ style: {
4991
+ display: "inline-flex",
4992
+ alignItems: "center",
4993
+ gap: 8,
4994
+ flex: "none",
4995
+ maxWidth: "100%"
4996
+ },
4997
+ children: [/* @__PURE__ */ jsxs("span", {
4998
+ style: {
4999
+ display: "inline-flex",
5000
+ alignItems: "center",
5001
+ gap: 6,
5002
+ padding: "2px 9px 2px 7px",
5003
+ borderRadius: 999,
5004
+ background: `color-mix(in srgb, ${color} 15%, transparent)`,
5005
+ color: "var(--card-fg-color)",
5006
+ fontSize: 12,
5007
+ lineHeight: "18px",
5008
+ fontWeight: 500,
5009
+ whiteSpace: "nowrap"
5010
+ },
5011
+ children: [/* @__PURE__ */ jsx(StatusDot, { status }), label]
5012
+ }), date ? /* @__PURE__ */ jsx(Text, {
5013
+ size: 1,
5014
+ muted: !0,
5015
+ style: {
5016
+ whiteSpace: "nowrap",
5017
+ ...TABULAR
5018
+ },
5019
+ children: date
5020
+ }) : null]
5021
+ })
5022
+ });
5023
+ }
5024
+ /** Point de couleur seul (filtres, légendes). Draft : point vide, lisible sans la couleur. */
5025
+ function StatusDot({ status, size = 7 }) {
5026
+ let color = STATUS_COLORS[status];
5027
+ return /* @__PURE__ */ jsx("span", {
5028
+ "aria-hidden": !0,
5029
+ style: {
5030
+ width: size,
5031
+ height: size,
5032
+ flex: "none",
5033
+ borderRadius: "50%",
5034
+ background: status === "draft" ? "transparent" : color,
5035
+ boxShadow: status === "draft" ? `inset 0 0 0 1.5px ${color}` : void 0
5036
+ }
4958
5037
  });
4959
5038
  }
4960
5039
  const formatter = new Intl.DateTimeFormat("en-US", {
@@ -4966,9 +5045,9 @@ const formatter = new Intl.DateTimeFormat("en-US", {
4966
5045
  });
4967
5046
  /** Date lisible, ou un tiret cadratin quand il n'y en a pas. */
4968
5047
  function formatDate$1(value) {
4969
- if (!value) return "—";
5048
+ if (!value) return "";
4970
5049
  let date = new Date(value);
4971
- return Number.isNaN(date.getTime()) ? "—" : formatter.format(date);
5050
+ return Number.isNaN(date.getTime()) ? "" : formatter.format(date);
4972
5051
  }
4973
5052
  /**
4974
5053
  * Champ de saisie d'une cellule de tableau.
@@ -4983,7 +5062,7 @@ function QuietInput(props) {
4983
5062
  return /* @__PURE__ */ jsx("input", {
4984
5063
  type: "text",
4985
5064
  defaultValue: props.value,
4986
- placeholder: props.placeholder ?? "—",
5065
+ placeholder: props.placeholder ?? "",
4987
5066
  onBlur: (event) => {
4988
5067
  event.currentTarget.value !== props.value && props.onCommit(event.currentTarget.value);
4989
5068
  },
@@ -5046,7 +5125,8 @@ function FieldValue(props) {
5046
5125
  })] }) : /* @__PURE__ */ jsx(Text, {
5047
5126
  size: 0,
5048
5127
  muted: !0,
5049
- children: "—"
5128
+ "aria-label": "Not set",
5129
+ children: "\xA0"
5050
5130
  })
5051
5131
  }),
5052
5132
  children: ({ close }) => /* @__PURE__ */ jsx(OptionEditor, {
@@ -5452,7 +5532,7 @@ function PathCell(props) {
5452
5532
  if (!path) return /* @__PURE__ */ jsx(Text, {
5453
5533
  size: 1,
5454
5534
  muted: !0,
5455
- children: "—"
5535
+ children: "No address"
5456
5536
  });
5457
5537
  let segments = path.split("/").filter(Boolean), last = segments.length > 0 ? segments[segments.length - 1] : null, prefix = last ? path.slice(0, path.length - last.length) : path, label = /* @__PURE__ */ jsxs(Text, {
5458
5538
  size: 1,
@@ -5547,7 +5627,8 @@ function TagCell(props) {
5547
5627
  })] }) : /* @__PURE__ */ jsx(Text, {
5548
5628
  size: 0,
5549
5629
  muted: !0,
5550
- children: "—"
5630
+ "aria-label": "Not set",
5631
+ children: "\xA0"
5551
5632
  })
5552
5633
  }),
5553
5634
  children: ({ close }) => /* @__PURE__ */ jsxs(Stack, {
@@ -5823,7 +5904,13 @@ function PagesTable(props) {
5823
5904
  wrap: "wrap",
5824
5905
  style: CELL,
5825
5906
  children: [
5826
- /* @__PURE__ */ jsx(StatusBadge, { status: entryRow.status }),
5907
+ /* @__PURE__ */ jsx(StatusBadge, {
5908
+ status: entryRow.status,
5909
+ scheduledAt: entryRow.scheduledAt,
5910
+ live: entryRow.live,
5911
+ hasDraft: entryRow.hasDraft,
5912
+ showDate: !0
5913
+ }),
5827
5914
  !!todos?.get(entryRow.id) && /* @__PURE__ */ jsxs(Badge, {
5828
5915
  tone: "caution",
5829
5916
  fontSize: 0,
@@ -5865,7 +5952,7 @@ function PagesTable(props) {
5865
5952
  size: 0,
5866
5953
  muted: !value,
5867
5954
  textOverflow: "ellipsis",
5868
- children: value || "—"
5955
+ children: value || ""
5869
5956
  })
5870
5957
  }, column.key);
5871
5958
  }),
@@ -5894,6 +5981,74 @@ function PagesTable(props) {
5894
5981
  })]
5895
5982
  });
5896
5983
  }
5984
+ /** Ordre des filtres : ce qui est en ligne d'abord, puis ce qui demande une action. */
5985
+ const FILTER_ORDER = [
5986
+ "published",
5987
+ "modified",
5988
+ "scheduled",
5989
+ "draft"
5990
+ ];
5991
+ /**
5992
+ * Filtres de statut au-dessus d'une liste (collections, onglet Pages) : « All »
5993
+ * puis un bouton par statut avec son nombre. Un clic filtre, un second clic sur
5994
+ * le même statut revient à « All ».
5995
+ */
5996
+ function StatusFilter({ rows, value, onChange }) {
5997
+ let counts = countStatuses(rows);
5998
+ return /* @__PURE__ */ jsxs(Flex, {
5999
+ gap: 2,
6000
+ wrap: "wrap",
6001
+ role: "group",
6002
+ "aria-label": "Filter by status",
6003
+ children: [/* @__PURE__ */ jsx(Chip, {
6004
+ selected: value === null,
6005
+ onClick: () => onChange(null),
6006
+ label: "All",
6007
+ count: rows.length
6008
+ }), FILTER_ORDER.map((status) => /* @__PURE__ */ jsx(Chip, {
6009
+ selected: value === status,
6010
+ onClick: () => onChange(value === status ? null : status),
6011
+ label: STATUS_LABELS[status].label,
6012
+ count: counts[status],
6013
+ status
6014
+ }, status))]
6015
+ });
6016
+ }
6017
+ function Chip(props) {
6018
+ let { selected, onClick, label, count, status } = props;
6019
+ return /* @__PURE__ */ jsxs("button", {
6020
+ type: "button",
6021
+ "aria-pressed": selected,
6022
+ onClick,
6023
+ style: {
6024
+ display: "inline-flex",
6025
+ alignItems: "center",
6026
+ gap: 6,
6027
+ padding: "3px 10px",
6028
+ borderRadius: 999,
6029
+ border: `1px solid ${selected ? "var(--card-focus-ring-color, #2276fc)" : "var(--card-border-color, rgba(127,127,127,0.25))"}`,
6030
+ background: selected ? "color-mix(in srgb, var(--card-focus-ring-color, #2276fc) 12%, transparent)" : "transparent",
6031
+ color: "var(--card-fg-color)",
6032
+ opacity: count === 0 && !selected ? .55 : 1,
6033
+ font: "inherit",
6034
+ fontSize: 12,
6035
+ lineHeight: "18px",
6036
+ cursor: "pointer"
6037
+ },
6038
+ children: [
6039
+ status ? /* @__PURE__ */ jsx(StatusDot, { status }) : null,
6040
+ /* @__PURE__ */ jsx("span", { children: label }),
6041
+ /* @__PURE__ */ jsx("span", {
6042
+ style: {
6043
+ color: "var(--card-muted-fg-color)",
6044
+ fontWeight: 600,
6045
+ ...TABULAR
6046
+ },
6047
+ children: count
6048
+ })
6049
+ ]
6050
+ });
6051
+ }
5897
6052
  /**
5898
6053
  * Recherche et rafraîchissement.
5899
6054
  *
@@ -6167,7 +6322,13 @@ function PagePanel(props) {
6167
6322
  gap: 2,
6168
6323
  align: "center",
6169
6324
  wrap: "wrap",
6170
- children: [/* @__PURE__ */ jsx(StatusBadge, { status: row.status }), colorLabel && color && /* @__PURE__ */ jsxs(Flex, {
6325
+ children: [/* @__PURE__ */ jsx(StatusBadge, {
6326
+ status: row.status,
6327
+ scheduledAt: row.scheduledAt,
6328
+ live: row.live,
6329
+ hasDraft: row.hasDraft,
6330
+ showDate: !0
6331
+ }), colorLabel && color && /* @__PURE__ */ jsxs(Flex, {
6171
6332
  gap: 2,
6172
6333
  align: "center",
6173
6334
  children: [/* @__PURE__ */ jsx(Box, { style: {
@@ -6187,7 +6348,7 @@ function PagePanel(props) {
6187
6348
  size: 1,
6188
6349
  textOverflow: "ellipsis",
6189
6350
  style: MONO,
6190
- children: row.path ?? "—"
6351
+ children: row.path ?? "No address"
6191
6352
  }),
6192
6353
  /* @__PURE__ */ jsxs(Text, {
6193
6354
  size: 0,
@@ -6398,10 +6559,7 @@ function usePageContents() {
6398
6559
  let config = useKitConfig(), { field: pageBuilderField } = usePageBuilder(), { data, loading, error, refresh } = useQueryData(useMemo(() => buildContentsQuery({
6399
6560
  ...config,
6400
6561
  pageBuilderField
6401
- }, CONTENT_SCAN_LIMIT), [config, pageBuilderField]), useMemo(() => ({ types: config.pageTypeNames }), [config.pageTypeNames]), {
6402
- listenTypes: config.pageTypeNames,
6403
- tag: "page-contents"
6404
- });
6562
+ }, CONTENT_SCAN_LIMIT), [config, pageBuilderField]), useMemo(() => ({ types: config.pageTypeNames }), [config.pageTypeNames]), { listenTypes: config.pageTypeNames });
6405
6563
  return {
6406
6564
  contents: useMemo(() => {
6407
6565
  let map = /* @__PURE__ */ new Map();
@@ -6568,7 +6726,12 @@ function TreeNode(props) {
6568
6726
  }) : /* @__PURE__ */ jsxs(Flex, {
6569
6727
  gap: 2,
6570
6728
  align: "center",
6571
- children: [/* @__PURE__ */ jsx(StatusBadge, { status: row.status }), /* @__PURE__ */ jsxs(Select, {
6729
+ children: [/* @__PURE__ */ jsx(StatusBadge, {
6730
+ status: row.status,
6731
+ scheduledAt: row.scheduledAt,
6732
+ live: row.live,
6733
+ hasDraft: row.hasDraft
6734
+ }), /* @__PURE__ */ jsxs(Select, {
6572
6735
  className: "nodrag",
6573
6736
  fontSize: 0,
6574
6737
  padding: 1,
@@ -6733,11 +6896,7 @@ function useAnnotations(scope) {
6733
6896
  const nodeTypes$1 = {
6734
6897
  page: PageNode,
6735
6898
  annotation: AnnotationNode
6736
- }, isPageNode = (node) => node.type === "page", MINIMAP_COLORS = {
6737
- published: "#43d675",
6738
- modified: "#f5a623",
6739
- draft: "#8a8a8a"
6740
- }, FLOW_THEME$1 = {
6899
+ }, isPageNode = (node) => node.type === "page", MINIMAP_COLORS = STATUS_COLORS, FLOW_THEME$1 = {
6741
6900
  width: "100%",
6742
6901
  height: "100%",
6743
6902
  "--xy-background-color": "var(--card-bg-color)",
@@ -7219,14 +7378,15 @@ function BoardView(props) {
7219
7378
  return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(Board, { ...props }) });
7220
7379
  }
7221
7380
  function PagesTool() {
7222
- let config = useKitConfig(), router = useRouter(), { byId, saveColumns, patchNode, patchField, pageOrder } = useBoardLayout(), columnOptions = useColumnOptions(), preview = usePreviewTarget(), columns = useInternalColumns(), [view, setView] = useState("list"), [search, setSearch] = useState(""), [locale, setLocale] = useState(""), todos = useTranslationTodos(), [onlyTodo, setOnlyTodo] = useState(!1), [groupBy, setGroupBy] = useState("none"), [rawColorBy, setColorBy] = useState("tag"), [sortKey, setSortKey] = useState(null), [sortDirection, setSortDirection] = useState("asc"), [page, setPage] = useState(0), [hidden, setHidden] = useState(/* @__PURE__ */ new Set()), [shownData, setShownData] = useState(/* @__PURE__ */ new Set()), toggleData = useCallback((key) => {
7381
+ let config = useKitConfig(), router = useRouter(), { byId, saveColumns, patchNode, patchField, pageOrder } = useBoardLayout(), columnOptions = useColumnOptions(), preview = usePreviewTarget(), columns = useInternalColumns(), [view, setView] = useState("list"), [search, setSearch] = useState(""), [locale, setLocale] = useState(""), todos = useTranslationTodos(), [onlyTodo, setOnlyTodo] = useState(!1), [statusFilter, setStatusFilter] = useState(null), [groupBy, setGroupBy] = useState("none"), [rawColorBy, setColorBy] = useState("tag"), [sortKey, setSortKey] = useState(null), [sortDirection, setSortDirection] = useState("asc"), [page, setPage] = useState(0), [hidden, setHidden] = useState(/* @__PURE__ */ new Set()), [shownData, setShownData] = useState(/* @__PURE__ */ new Set()), toggleData = useCallback((key) => {
7223
7382
  setShownData((current) => {
7224
7383
  let next = new Set(current);
7225
7384
  return next.has(key) ? next.delete(key) : next.add(key), next;
7226
7385
  });
7227
7386
  }, []), documentColumns = useDocumentColumns(), visibleDataColumns = useMemo(() => documentColumns.filter((column) => shownData.has(column.key)), [documentColumns, shownData]), { rows, loading, error, refresh } = usePages(visibleDataColumns), colorBy = resolveColorBy(rawColorBy, columns), locales = useMemo(() => config.i18n?.locales.length ? config.i18n.locales : localesInRows(rows), [config.i18n, rows]), effectiveSortKey = sortKey ?? (pageOrder.length > 0 ? "manual" : "structure"), visible = useMemo(() => sortRows$1(filterRows$1(rows, {
7228
7387
  search,
7229
- locales: locale ? [locale] : void 0
7388
+ locales: locale ? [locale] : void 0,
7389
+ statuses: statusFilter ? [statusFilter] : void 0
7230
7390
  }).filter((row) => !onlyTodo || todos.has(row.id)), effectiveSortKey, sortDirection, {
7231
7391
  typeOrder: config.pageTypeNames,
7232
7392
  pageOrder
@@ -7234,13 +7394,14 @@ function PagesTool() {
7234
7394
  rows,
7235
7395
  search,
7236
7396
  locale,
7397
+ statusFilter,
7237
7398
  onlyTodo,
7238
7399
  todos,
7239
7400
  effectiveSortKey,
7240
7401
  sortDirection,
7241
7402
  config.pageTypeNames,
7242
7403
  pageOrder
7243
- ]), pageCount = Math.max(1, Math.ceil(visible.length / 100)), current = Math.min(page, pageCount - 1), slice = visible.slice(current * 100, current * 100 + 100), groups = useMemo(() => groupPageRows(slice, groupBy, {
7404
+ ]), statusScope = useMemo(() => filterRows$1(rows, { locales: locale ? [locale] : void 0 }), [rows, locale]), pageCount = Math.max(1, Math.ceil(visible.length / 100)), current = Math.min(page, pageCount - 1), slice = visible.slice(current * 100, current * 100 + 100), groups = useMemo(() => groupPageRows(slice, groupBy, {
7244
7405
  meta: byId,
7245
7406
  tags: config.boardTags,
7246
7407
  fields: columns
@@ -7456,6 +7617,13 @@ function PagesTool() {
7456
7617
  busy: loading,
7457
7618
  summary
7458
7619
  }),
7620
+ rows.length > 0 && /* @__PURE__ */ jsx(StatusFilter, {
7621
+ rows: statusScope,
7622
+ value: statusFilter,
7623
+ onChange: (value) => {
7624
+ setStatusFilter(value), setPage(0);
7625
+ }
7626
+ }),
7459
7627
  view === "list" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Card, {
7460
7628
  radius: 3,
7461
7629
  shadow: 1,
@@ -8588,8 +8756,23 @@ function groupStyle(index) {
8588
8756
  function ComponentsTool() {
8589
8757
  return /* @__PURE__ */ jsx(ComponentMetaProvider, { children: /* @__PURE__ */ jsx(ComponentsToolInner, {}) });
8590
8758
  }
8759
+ const GROUPED_KEY = "ncf-components-grouped";
8760
+ /** Dernier choix « By group » de cet utilisateur, `null` s'il n'a jamais choisi. */
8761
+ function readGroupedChoice() {
8762
+ try {
8763
+ let value = window.localStorage.getItem(GROUPED_KEY);
8764
+ return value === null ? null : value === "1";
8765
+ } catch {
8766
+ return null;
8767
+ }
8768
+ }
8591
8769
  function ComponentsToolInner() {
8592
- let config = useKitConfig(), meta = useComponentMeta(), { blockTypes, occurrences, pagesById, truncated, scanned, loading, error, refresh } = useOccurrences(), [order, setOrder] = useState("type"), [view, setView] = useState("grid"), [grouped, setGrouped] = useState(!1), [editing, setEditing] = useState(null), [groupDialog, setGroupDialog] = useState(null), [deletingGroup, setDeletingGroup] = useState(null), preview = config.componentPreview, canPreview = preview.provider === "designSystemPage" && !!config.previewUrl, openComponent = useOpenComponent(), named = useMemo(() => withCustomNames(blockTypes, meta.names), [blockTypes, meta.names]), cards = useMemo(() => {
8770
+ let config = useKitConfig(), meta = useComponentMeta(), { blockTypes, occurrences, pagesById, truncated, scanned, loading, error, refresh } = useOccurrences(), [order, setOrder] = useState("type"), [view, setView] = useState("grid"), [groupedChoice, setGroupedChoice] = useState(readGroupedChoice), grouped = groupedChoice ?? !0, setGrouped = (value) => {
8771
+ setGroupedChoice(value);
8772
+ try {
8773
+ window.localStorage.setItem(GROUPED_KEY, value ? "1" : "0");
8774
+ } catch {}
8775
+ }, [editing, setEditing] = useState(null), [groupDialog, setGroupDialog] = useState(null), [deletingGroup, setDeletingGroup] = useState(null), preview = config.componentPreview, canPreview = preview.provider === "designSystemPage" && !!config.previewUrl, openComponent = useOpenComponent(), named = useMemo(() => withCustomNames(blockTypes, meta.names), [blockTypes, meta.names]), cards = useMemo(() => {
8593
8776
  let byName = new Map(named.map((b) => [b.name, b])), rows = occurrences.map((occurrence) => ({
8594
8777
  occurrence,
8595
8778
  block: byName.get(occurrence.type)
@@ -8673,7 +8856,7 @@ function ComponentsToolInner() {
8673
8856
  tone: grouped ? "primary" : "default",
8674
8857
  fontSize: 1,
8675
8858
  padding: 2,
8676
- onClick: () => setGrouped((value) => !value)
8859
+ onClick: () => setGrouped(!grouped)
8677
8860
  }) : null,
8678
8861
  grouped && view === "grid" ? /* @__PURE__ */ jsx(Button, {
8679
8862
  text: "New group",
@@ -9248,7 +9431,7 @@ function Line(props) {
9248
9431
  * d'avoir à détenir un jeton Sanity par client.
9249
9432
  */
9250
9433
  function ActorName(props) {
9251
- let [user] = useUser(props.actorId ?? ""), label = props.actorName || user?.displayName || (props.actorId ? "Unknown account" : "—");
9434
+ let [user] = useUser(props.actorId ?? ""), label = props.actorName || user?.displayName || (props.actorId ? "Unknown account" : "Unknown");
9252
9435
  return /* @__PURE__ */ jsx(Text, {
9253
9436
  size: 0,
9254
9437
  muted: !0,
@@ -10275,7 +10458,7 @@ function AssetTable(props) {
10275
10458
  size: 1,
10276
10459
  muted: !0,
10277
10460
  style: TABULAR,
10278
- children: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : "—"
10461
+ children: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : ""
10279
10462
  })
10280
10463
  }),
10281
10464
  /* @__PURE__ */ jsx("td", {
@@ -10287,7 +10470,7 @@ function AssetTable(props) {
10287
10470
  size: 1,
10288
10471
  muted: !0,
10289
10472
  textOverflow: "ellipsis",
10290
- children: folder ? folderName(folder) : "—"
10473
+ children: folder ? folderName(folder) : ""
10291
10474
  })
10292
10475
  }),
10293
10476
  /* @__PURE__ */ jsx("td", {
@@ -10303,7 +10486,7 @@ function AssetTable(props) {
10303
10486
  }) : /* @__PURE__ */ jsx(Text, {
10304
10487
  size: 1,
10305
10488
  style: TABULAR,
10306
- children: asset.uses ?? "—"
10489
+ children: asset.uses ?? ""
10307
10490
  })
10308
10491
  }),
10309
10492
  /* @__PURE__ */ jsx("td", {
@@ -10356,7 +10539,7 @@ function toPatchPath(segments) {
10356
10539
  function assetUnsetPaths(doc, assetId) {
10357
10540
  return findAssetRefPaths(doc, assetId).map(toPatchPath).filter(Boolean);
10358
10541
  }
10359
- const baseId$2 = (id) => id.replace(/^drafts\./, "");
10542
+ const baseId$1 = (id) => id.replace(/^drafts\./, "");
10360
10543
  /**
10361
10544
  * Suppression d'un asset depuis l'outil Assets. Sanity refuse de supprimer un
10362
10545
  * asset référencé : on retire d'abord l'asset de chaque document (le champ
@@ -10368,7 +10551,7 @@ function useAssetDelete() {
10368
10551
  usage: useCallback(async (assetId) => {
10369
10552
  let docs = await client.fetch("*[references($id)]{_id, _type, \"title\": coalesce(title, name, originalFilename, slug.current, _id)}", { id: assetId }), seen = /* @__PURE__ */ new Map();
10370
10553
  for (let doc of docs ?? []) {
10371
- let id = baseId$2(doc._id);
10554
+ let id = baseId$1(doc._id);
10372
10555
  seen.has(id) || seen.set(id, {
10373
10556
  id,
10374
10557
  type: doc._type,
@@ -10481,7 +10664,7 @@ function AssetDetail(props) {
10481
10664
  children: /* @__PURE__ */ jsxs(Text, {
10482
10665
  size: 1,
10483
10666
  muted: !0,
10484
- children: [asset.extension?.toUpperCase() || "Fichier", " — pas d'aperçu"]
10667
+ children: [asset.extension?.toUpperCase() || "Fichier", " (pas d'aperçu)"]
10485
10668
  })
10486
10669
  })
10487
10670
  }),
@@ -10577,7 +10760,7 @@ function AssetDetail(props) {
10577
10760
  children: [
10578
10761
  /* @__PURE__ */ jsx(Metric, {
10579
10762
  label: "Fichier",
10580
- value: asset.originalFilename ?? "—"
10763
+ value: asset.originalFilename ?? "None"
10581
10764
  }),
10582
10765
  /* @__PURE__ */ jsx(Metric, {
10583
10766
  label: "Type",
@@ -10589,11 +10772,11 @@ function AssetDetail(props) {
10589
10772
  }),
10590
10773
  /* @__PURE__ */ jsx(Metric, {
10591
10774
  label: "Dimensions",
10592
- value: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : "—"
10775
+ value: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : "Unknown"
10593
10776
  }),
10594
10777
  /* @__PURE__ */ jsx(Metric, {
10595
10778
  label: "Usage",
10596
- value: asset.uses === void 0 ? "—" : `${asset.uses}`
10779
+ value: asset.uses === void 0 ? "Unknown" : `${asset.uses}`
10597
10780
  }),
10598
10781
  /* @__PURE__ */ jsx(Metric, {
10599
10782
  label: "Ajouté",
@@ -11096,8 +11279,7 @@ function entryFor$1(client, type, languageField, language) {
11096
11279
  load();
11097
11280
  let sub = client.listen(`*[${filter}]`, params, {
11098
11281
  visibility: "query",
11099
- includeResult: !1,
11100
- tag: "ncf-kit.component-defaults"
11282
+ includeResult: !1
11101
11283
  }).subscribe({ next: () => void load() });
11102
11284
  e.stop = () => sub.unsubscribe();
11103
11285
  }
@@ -11648,9 +11830,7 @@ function useComponentNames() {
11648
11830
  load();
11649
11831
  let subscription = client.listen("*[_id == $id]", { id: COMPONENT_META_ID }, {
11650
11832
  visibility: "query",
11651
- events: ["mutation"],
11652
- includeResult: !1,
11653
- tag: "ncf-kit.component-names"
11833
+ events: ["mutation"]
11654
11834
  }).subscribe({
11655
11835
  next: () => void load(),
11656
11836
  error: () => {}
@@ -11703,8 +11883,7 @@ function entryFor(client, documentId) {
11703
11883
  load();
11704
11884
  let sub = client.listen("*[_id == $id]", { id }, {
11705
11885
  visibility: "query",
11706
- includeResult: !1,
11707
- tag: "ncf-kit.translation-todo"
11886
+ includeResult: !1
11708
11887
  }).subscribe({ next: () => void load() });
11709
11888
  e.stop = () => sub.unsubscribe();
11710
11889
  }
@@ -12949,7 +13128,12 @@ function PagesNavigator() {
12949
13128
  children: row.path
12950
13129
  })]
12951
13130
  }),
12952
- row.status !== "published" && /* @__PURE__ */ jsx(StatusBadge, { status: row.status })
13131
+ /* @__PURE__ */ jsx(StatusBadge, {
13132
+ status: row.status,
13133
+ scheduledAt: row.scheduledAt,
13134
+ live: row.live,
13135
+ hasDraft: row.hasDraft
13136
+ })
12953
13137
  ]
12954
13138
  })
12955
13139
  }, row.id);
@@ -13545,7 +13729,7 @@ function buildCollectionQuery(columns, filter) {
13545
13729
  "}"
13546
13730
  ].join("\n");
13547
13731
  }
13548
- const baseId$1 = (id) => id.startsWith("drafts.") ? id.slice(7) : id, isDraft = (id) => id.startsWith("drafts."), dateFormatter = new Intl.DateTimeFormat("en-US", {
13732
+ const dateFormatter = new Intl.DateTimeFormat("en-US", {
13549
13733
  day: "2-digit",
13550
13734
  month: "2-digit",
13551
13735
  year: "numeric"
@@ -13586,30 +13770,29 @@ function cellOf(raw, kind) {
13586
13770
  }
13587
13771
  /**
13588
13772
  * Documents → lignes, une par item. Le client (perspective `raw`) renvoie le
13589
- * brouillon ET la version publiée : on les fusionne par id de base, en gardant
13590
- * le brouillon s'il existe (valeurs les plus fraîches).
13773
+ * brouillon, la version publiée et les versions de release : on les fusionne
13774
+ * par id de base (`mergeVersions`, même règle que les pages), en gardant le
13775
+ * brouillon s'il existe (valeurs les plus fraîches). Une version de release non
13776
+ * programmée ne crée jamais de ligne à part.
13591
13777
  */
13592
- function buildCollectionRows(docs, columns) {
13593
- let byId = /* @__PURE__ */ new Map();
13594
- for (let doc of docs) {
13595
- if (!doc?._id) continue;
13596
- let entry = byId.get(baseId$1(doc._id)) ?? {};
13597
- isDraft(doc._id) ? entry.draft = doc : entry.published = doc, byId.set(baseId$1(doc._id), entry);
13598
- }
13599
- let rows = [];
13600
- for (let [id, { draft, published }] of byId) {
13601
- let source = draft ?? published;
13602
- if (!source) continue;
13603
- let cells = {};
13778
+ function buildCollectionRows(docs, columns, schedules) {
13779
+ return mergeVersions(docs.filter((doc) => !!doc?._id).map((doc) => ({
13780
+ ...doc,
13781
+ _type: "",
13782
+ _updatedAt: doc._updatedAt ?? void 0
13783
+ })), schedules).map((merged) => {
13784
+ let source = merged.doc, cells = {};
13604
13785
  for (let column of columns) cells[column.key] = cellOf(source[`${DATA_PREFIX}${column.key}`], column.kind);
13605
- rows.push({
13606
- id,
13607
- updatedAt: source._updatedAt ?? null,
13608
- draftOnly: !!draft && !published,
13786
+ return {
13787
+ id: merged.id,
13788
+ updatedAt: merged.updatedAt ?? null,
13789
+ status: merged.status,
13790
+ scheduledAt: merged.scheduledAt ?? null,
13791
+ live: merged.live,
13792
+ hasDraft: merged.hasDraft,
13609
13793
  cells
13610
- });
13611
- }
13612
- return rows;
13794
+ };
13795
+ });
13613
13796
  }
13614
13797
  /**
13615
13798
  * Données d'une collection pour la vue table : colonnes tirées du schéma,
@@ -13624,14 +13807,15 @@ function useCollection(type, visibleKeys, options = {}) {
13624
13807
  let { filter, params: extraParams } = options, schema = useSchema(), allColumns = useMemo(() => deriveCollectionColumns(schema.get(type)), [schema, type]), visibleColumns = useMemo(() => visibleKeys.map((key) => allColumns.find((c) => c.key === key)).filter((c) => !!c), [allColumns, visibleKeys]), { data, loading, error, refresh } = useQueryData(useMemo(() => buildCollectionQuery(visibleColumns, filter), [visibleColumns, filter]), {
13625
13808
  type,
13626
13809
  ...extraParams
13627
- }, {
13628
- listenTypes: [type],
13629
- tag: `collection.${type}`
13630
- });
13810
+ }, { listenTypes: [type] }), schedules = useScheduledReleases();
13631
13811
  return {
13632
13812
  allColumns,
13633
13813
  visibleColumns,
13634
- rows: useMemo(() => buildCollectionRows(data ?? [], visibleColumns), [data, visibleColumns]),
13814
+ rows: useMemo(() => buildCollectionRows(data ?? [], visibleColumns, schedules), [
13815
+ data,
13816
+ visibleColumns,
13817
+ schedules
13818
+ ]),
13635
13819
  loading,
13636
13820
  error,
13637
13821
  refresh
@@ -13882,8 +14066,8 @@ function CollectionToolbar(props) {
13882
14066
  ]
13883
14067
  });
13884
14068
  }
13885
- /** Colonnes montrées par défaut : le titre d'abord, puis les premières. */
13886
- const MEDIA = "2.0625rem";
14069
+ /** Clé de tri de la colonne Status (colonne du kit, pas un champ du schéma). */
14070
+ const STATUS_KEY = "__status", MEDIA = "2.0625rem";
13887
14071
  function defaultVisible(columns) {
13888
14072
  let title = columns.find((c) => c.key === "title") ?? columns.find((c) => c.kind === "text");
13889
14073
  return (title ? [title, ...columns.filter((c) => c !== title)] : [...columns]).slice(0, 6).map((c) => c.key);
@@ -13910,21 +14094,29 @@ function CollectionTable({ type, filter, params, newTemplate }) {
13910
14094
  let router = useRouter(), { ChildLink } = usePaneRouter(), [view, setView] = useState("table"), [selected, setSelected] = useState(null), [sort, setSort] = useState({
13911
14095
  key: null,
13912
14096
  direction: "asc"
13913
- }), [search, setSearch] = useState(""), [widths, setWidths] = useState({}), schemaType = useSchema().get(type), TypeIcon = schemaType?.icon, allColumns = useMemo(() => deriveCollectionColumns(schemaType), [schemaType]), visibleKeys = useMemo(() => selected ?? defaultVisible(allColumns), [selected, allColumns]), { visibleColumns, rows, loading, error, refresh } = useCollection(type, visibleKeys, {
14097
+ }), [search, setSearch] = useState(""), [statusFilter, setStatusFilter] = useState(null), [widths, setWidths] = useState({}), schemaType = useSchema().get(type), TypeIcon = schemaType?.icon, allColumns = useMemo(() => deriveCollectionColumns(schemaType), [schemaType]), visibleKeys = useMemo(() => selected ?? defaultVisible(allColumns), [selected, allColumns]), { visibleColumns, rows, loading, error, refresh } = useCollection(type, visibleKeys, {
13914
14098
  filter,
13915
14099
  params
13916
- }), visible = useMemo(() => sortRows(filterRows(rows, {
13917
- search,
13918
- columns: {}
13919
- }, visibleColumns), sort, visibleColumns), [
14100
+ }), visible = useMemo(() => {
14101
+ let searched = filterRows(rows, {
14102
+ search,
14103
+ columns: {}
14104
+ }, visibleColumns), filtered = statusFilter ? searched.filter((row) => row.status === statusFilter) : searched;
14105
+ if (sort.key === STATUS_KEY) {
14106
+ let rank = (status) => STATUS_ORDER$1.indexOf(status), sorted = [...filtered].sort((a, b) => rank(a.status) - rank(b.status));
14107
+ return sort.direction === "asc" ? sorted : sorted.reverse();
14108
+ }
14109
+ return sortRows(filtered, sort, visibleColumns);
14110
+ }, [
13920
14111
  rows,
13921
14112
  search,
14113
+ statusFilter,
13922
14114
  visibleColumns,
13923
14115
  sort
13924
14116
  ]), cols = useMemo(() => visibleColumns.map((column, index) => ({
13925
14117
  column,
13926
14118
  width: widths[column.key] ?? defaultWidth(column, index === 0)
13927
- })), [visibleColumns, widths]), totalWidth = useMemo(() => cols.reduce((sum, c) => sum + c.width, 0), [cols]), onToggleColumn = useCallback((key) => {
14119
+ })), [visibleColumns, widths]), totalWidth = useMemo(() => cols.reduce((sum, c) => sum + c.width, 0) + 230, [cols]), onToggleColumn = useCallback((key) => {
13928
14120
  setSelected((current) => {
13929
14121
  let base = current ?? defaultVisible(allColumns);
13930
14122
  return base.includes(key) ? base.filter((k) => k !== key) : [...base, key];
@@ -13971,153 +14163,89 @@ function CollectionTable({ type, filter, params, newTemplate }) {
13971
14163
  error,
13972
14164
  onRetry: refresh
13973
14165
  });
13974
- let summary = visible.length === rows.length ? `${rows.length} item${rows.length > 1 ? "s" : ""}` : `${visible.length} of ${rows.length}`, titleKey = visibleColumns[0]?.key, subtitleKey = visibleColumns.find((c, i) => i > 0 && /slug|path|url|email/i.test(c.key))?.key ?? visibleColumns.find((c, i) => i > 0 && c.kind === "text")?.key;
13975
- return /* @__PURE__ */ jsxs(Stack, {
13976
- gap: 3,
13977
- children: [/* @__PURE__ */ jsx(CollectionToolbar, {
13978
- view,
13979
- onView: setView,
13980
- search,
13981
- onSearch: setSearch,
13982
- columns: allColumns,
13983
- visible: visibleKeys,
13984
- onToggleColumn,
13985
- onExport,
13986
- onRefresh: refresh,
13987
- onCreate,
13988
- busy: loading,
13989
- summary
13990
- }), loading && rows.length === 0 ? /* @__PURE__ */ jsxs(Flex, {
14166
+ let summary = visible.length === rows.length ? `${rows.length} item${rows.length > 1 ? "s" : ""}` : `${visible.length} of ${rows.length}`, titleKey = visibleColumns[0]?.key, subtitleKey = visibleColumns.find((c, i) => i > 0 && /slug|path|url|email/i.test(c.key))?.key ?? visibleColumns.find((c, i) => i > 0 && c.kind === "text")?.key, StatusArrow = sort.direction === "asc" ? ChevronUpIcon : ChevronDownIcon, statusHeader = /* @__PURE__ */ jsx(Box, {
14167
+ paddingRight: 2,
14168
+ style: {
14169
+ width: 230,
14170
+ flex: "none",
14171
+ boxSizing: "border-box",
14172
+ borderLeft: "2px solid transparent"
14173
+ },
14174
+ children: /* @__PURE__ */ jsxs(Flex, {
13991
14175
  align: "center",
13992
- justify: "center",
13993
- padding: 6,
13994
- gap: 3,
13995
- children: [/* @__PURE__ */ jsx(Spinner, { muted: !0 }), /* @__PURE__ */ jsx(Text, {
13996
- size: 1,
13997
- muted: !0,
13998
- children: "Loading…"
13999
- })]
14000
- }) : visibleColumns.length === 0 ? /* @__PURE__ */ jsx(Box, {
14001
- padding: 5,
14002
- children: /* @__PURE__ */ jsx(Text, {
14003
- size: 1,
14004
- muted: !0,
14005
- align: "center",
14006
- children: "No displayable field in this type. Pick columns above."
14007
- })
14008
- }) : view === "list" ? /* @__PURE__ */ jsxs(Box, {
14176
+ gap: 1,
14177
+ onClick: () => onSort(STATUS_KEY),
14009
14178
  style: {
14010
- border: `1px solid ${BORDER_SOFT}`,
14011
- borderRadius: 6,
14012
- overflow: "hidden"
14179
+ cursor: "pointer",
14180
+ userSelect: "none"
14013
14181
  },
14014
- children: [/* @__PURE__ */ jsx("style", { children: ".ncf-coll-body a{display:block;color:inherit;text-decoration:none}" }), /* @__PURE__ */ jsxs(Box, {
14015
- className: "ncf-coll-body",
14016
- children: [visible.map((row) => /* @__PURE__ */ jsx(ChildLink, {
14017
- childId: row.id,
14018
- children: /* @__PURE__ */ jsx(ListRowView, {
14019
- row,
14020
- titleKey,
14021
- subtitleKey,
14022
- Icon: TypeIcon
14023
- })
14024
- }, row.id)), visible.length === 0 && /* @__PURE__ */ jsx(Box, {
14025
- padding: 5,
14026
- children: /* @__PURE__ */ jsx(Text, {
14027
- size: 1,
14028
- muted: !0,
14029
- align: "center",
14030
- children: rows.length === 0 ? "No item yet." : "No match."
14031
- })
14182
+ title: "Sort by status",
14183
+ children: [/* @__PURE__ */ jsx(Text, {
14184
+ size: 1,
14185
+ weight: "semibold",
14186
+ muted: sort.key !== STATUS_KEY,
14187
+ children: "Status"
14188
+ }), sort.key === STATUS_KEY && /* @__PURE__ */ jsx(StatusArrow, { style: {
14189
+ fontSize: 14,
14190
+ opacity: .7,
14191
+ flex: "none"
14192
+ } })]
14193
+ })
14194
+ }, STATUS_KEY);
14195
+ return /* @__PURE__ */ jsxs(Stack, {
14196
+ gap: 3,
14197
+ children: [
14198
+ /* @__PURE__ */ jsx(CollectionToolbar, {
14199
+ view,
14200
+ onView: setView,
14201
+ search,
14202
+ onSearch: setSearch,
14203
+ columns: allColumns,
14204
+ visible: visibleKeys,
14205
+ onToggleColumn,
14206
+ onExport,
14207
+ onRefresh: refresh,
14208
+ onCreate,
14209
+ busy: loading,
14210
+ summary
14211
+ }),
14212
+ rows.length > 0 && /* @__PURE__ */ jsx(StatusFilter, {
14213
+ rows,
14214
+ value: statusFilter,
14215
+ onChange: setStatusFilter
14216
+ }),
14217
+ loading && rows.length === 0 ? /* @__PURE__ */ jsxs(Flex, {
14218
+ align: "center",
14219
+ justify: "center",
14220
+ padding: 6,
14221
+ gap: 3,
14222
+ children: [/* @__PURE__ */ jsx(Spinner, { muted: !0 }), /* @__PURE__ */ jsx(Text, {
14223
+ size: 1,
14224
+ muted: !0,
14225
+ children: "Loading…"
14032
14226
  })]
14033
- })]
14034
- }) : /* @__PURE__ */ jsxs(Box, {
14035
- style: {
14036
- overflowX: "auto",
14037
- border: `1px solid ${BORDER_SOFT}`,
14038
- borderRadius: 6
14039
- },
14040
- children: [/* @__PURE__ */ jsx("style", { children: ".ncf-coll-body a{display:contents;color:inherit;text-decoration:none}" }), /* @__PURE__ */ jsxs(Box, {
14227
+ }) : visibleColumns.length === 0 ? /* @__PURE__ */ jsx(Box, {
14228
+ padding: 5,
14229
+ children: /* @__PURE__ */ jsx(Text, {
14230
+ size: 1,
14231
+ muted: !0,
14232
+ align: "center",
14233
+ children: "No displayable field in this type. Pick columns above."
14234
+ })
14235
+ }) : view === "list" ? /* @__PURE__ */ jsxs(Box, {
14041
14236
  style: {
14042
- width: totalWidth,
14043
- minWidth: "100%"
14237
+ border: `1px solid ${BORDER_SOFT}`,
14238
+ borderRadius: 6,
14239
+ overflow: "hidden"
14044
14240
  },
14045
- children: [/* @__PURE__ */ jsx(Flex, {
14046
- paddingX: 3,
14047
- paddingY: 3,
14048
- align: "center",
14049
- style: {
14050
- borderBottom: `1px solid ${BORDER}`,
14051
- position: "sticky",
14052
- top: 0,
14053
- background: "var(--card-muted-bg-color, var(--card-bg-color, inherit))",
14054
- zIndex: 2
14055
- },
14056
- children: cols.map(({ column, width }) => {
14057
- let active = sort.key === column.key, Arrow = sort.direction === "asc" ? ChevronUpIcon : ChevronDownIcon, alignEnd = column.kind === "number";
14058
- return /* @__PURE__ */ jsxs(Box, {
14059
- paddingRight: 2,
14060
- onDragOver: (e) => {
14061
- dragKeyRef.current && dragKeyRef.current !== column.key && (e.preventDefault(), setDragOverKey(column.key));
14062
- },
14063
- onDrop: () => onReorder(column.key),
14064
- style: {
14065
- width,
14066
- flex: "none",
14067
- position: "relative",
14068
- boxSizing: "border-box",
14069
- borderLeft: dragOverKey === column.key ? "2px solid var(--card-focus-ring-color, #2276fc)" : "2px solid transparent"
14070
- },
14071
- children: [/* @__PURE__ */ jsxs(Flex, {
14072
- align: "center",
14073
- gap: 1,
14074
- justify: alignEnd ? "flex-end" : "flex-start",
14075
- draggable: !0,
14076
- onDragStart: () => {
14077
- dragKeyRef.current = column.key;
14078
- },
14079
- onDragEnd: () => {
14080
- dragKeyRef.current = null, setDragOverKey(null);
14081
- },
14082
- onClick: () => onSort(column.key),
14083
- style: {
14084
- cursor: "grab",
14085
- userSelect: "none"
14086
- },
14087
- title: `Sort by ${column.label.toLowerCase()} — drag to reorder`,
14088
- children: [/* @__PURE__ */ jsx(Text, {
14089
- size: 1,
14090
- weight: "semibold",
14091
- muted: !active,
14092
- textOverflow: "ellipsis",
14093
- children: column.label
14094
- }), active && /* @__PURE__ */ jsx(Arrow, { style: {
14095
- fontSize: 14,
14096
- opacity: .7,
14097
- flex: "none"
14098
- } })]
14099
- }), /* @__PURE__ */ jsx("div", {
14100
- onPointerDown: onResizeStart(column.key, width),
14101
- title: "Drag to resize",
14102
- style: {
14103
- position: "absolute",
14104
- top: 0,
14105
- right: 0,
14106
- width: 9,
14107
- height: "100%",
14108
- cursor: "col-resize",
14109
- touchAction: "none"
14110
- }
14111
- })]
14112
- }, column.key);
14113
- })
14114
- }), /* @__PURE__ */ jsxs(Box, {
14241
+ children: [/* @__PURE__ */ jsx("style", { children: ".ncf-coll-body a{display:block;color:inherit;text-decoration:none}" }), /* @__PURE__ */ jsxs(Box, {
14115
14242
  className: "ncf-coll-body",
14116
14243
  children: [visible.map((row) => /* @__PURE__ */ jsx(ChildLink, {
14117
14244
  childId: row.id,
14118
- children: /* @__PURE__ */ jsx(TableRowView, {
14245
+ children: /* @__PURE__ */ jsx(ListRowView, {
14119
14246
  row,
14120
- cols,
14247
+ titleKey,
14248
+ subtitleKey,
14121
14249
  Icon: TypeIcon
14122
14250
  })
14123
14251
  }, row.id)), visible.length === 0 && /* @__PURE__ */ jsx(Box, {
@@ -14130,21 +14258,108 @@ function CollectionTable({ type, filter, params, newTemplate }) {
14130
14258
  })
14131
14259
  })]
14132
14260
  })]
14133
- })]
14134
- })]
14135
- });
14136
- }
14137
- /** Pastille de statut : vert = publié, ambre = brouillon jamais publié. */
14138
- function StatusDot(props) {
14139
- return /* @__PURE__ */ jsx("span", {
14140
- title: props.draftOnly ? "Not published" : "Published",
14141
- style: {
14142
- flex: "none",
14143
- width: 9,
14144
- height: 9,
14145
- borderRadius: "50%",
14146
- background: props.draftOnly ? "#f5a623" : "#43d675"
14147
- }
14261
+ }) : /* @__PURE__ */ jsxs(Box, {
14262
+ style: {
14263
+ overflowX: "auto",
14264
+ border: `1px solid ${BORDER_SOFT}`,
14265
+ borderRadius: 6
14266
+ },
14267
+ children: [/* @__PURE__ */ jsx("style", { children: ".ncf-coll-body a{display:contents;color:inherit;text-decoration:none}" }), /* @__PURE__ */ jsxs(Box, {
14268
+ style: {
14269
+ width: totalWidth,
14270
+ minWidth: "100%"
14271
+ },
14272
+ children: [/* @__PURE__ */ jsx(Flex, {
14273
+ paddingX: 3,
14274
+ paddingY: 3,
14275
+ align: "center",
14276
+ style: {
14277
+ borderBottom: `1px solid ${BORDER}`,
14278
+ position: "sticky",
14279
+ top: 0,
14280
+ background: "var(--card-muted-bg-color, var(--card-bg-color, inherit))",
14281
+ zIndex: 2
14282
+ },
14283
+ children: cols.map(({ column, width }, index) => {
14284
+ let active = sort.key === column.key, Arrow = sort.direction === "asc" ? ChevronUpIcon : ChevronDownIcon, alignEnd = column.kind === "number", cell = /* @__PURE__ */ jsxs(Box, {
14285
+ paddingRight: 2,
14286
+ onDragOver: (e) => {
14287
+ dragKeyRef.current && dragKeyRef.current !== column.key && (e.preventDefault(), setDragOverKey(column.key));
14288
+ },
14289
+ onDrop: () => onReorder(column.key),
14290
+ style: {
14291
+ width,
14292
+ flex: "none",
14293
+ position: "relative",
14294
+ boxSizing: "border-box",
14295
+ borderLeft: dragOverKey === column.key ? "2px solid var(--card-focus-ring-color, #2276fc)" : "2px solid transparent"
14296
+ },
14297
+ children: [/* @__PURE__ */ jsxs(Flex, {
14298
+ align: "center",
14299
+ gap: 1,
14300
+ justify: alignEnd ? "flex-end" : "flex-start",
14301
+ draggable: !0,
14302
+ onDragStart: () => {
14303
+ dragKeyRef.current = column.key;
14304
+ },
14305
+ onDragEnd: () => {
14306
+ dragKeyRef.current = null, setDragOverKey(null);
14307
+ },
14308
+ onClick: () => onSort(column.key),
14309
+ style: {
14310
+ cursor: "grab",
14311
+ userSelect: "none"
14312
+ },
14313
+ title: `Sort by ${column.label.toLowerCase()} — drag to reorder`,
14314
+ children: [/* @__PURE__ */ jsx(Text, {
14315
+ size: 1,
14316
+ weight: "semibold",
14317
+ muted: !active,
14318
+ textOverflow: "ellipsis",
14319
+ children: column.label
14320
+ }), active && /* @__PURE__ */ jsx(Arrow, { style: {
14321
+ fontSize: 14,
14322
+ opacity: .7,
14323
+ flex: "none"
14324
+ } })]
14325
+ }), /* @__PURE__ */ jsx("div", {
14326
+ onPointerDown: onResizeStart(column.key, width),
14327
+ title: "Drag to resize",
14328
+ style: {
14329
+ position: "absolute",
14330
+ top: 0,
14331
+ right: 0,
14332
+ width: 9,
14333
+ height: "100%",
14334
+ cursor: "col-resize",
14335
+ touchAction: "none"
14336
+ }
14337
+ })]
14338
+ }, column.key);
14339
+ return index === 0 ? [cell, statusHeader] : cell;
14340
+ })
14341
+ }), /* @__PURE__ */ jsxs(Box, {
14342
+ className: "ncf-coll-body",
14343
+ children: [visible.map((row) => /* @__PURE__ */ jsx(ChildLink, {
14344
+ childId: row.id,
14345
+ children: /* @__PURE__ */ jsx(TableRowView, {
14346
+ row,
14347
+ cols,
14348
+ Icon: TypeIcon
14349
+ })
14350
+ }, row.id)), visible.length === 0 && /* @__PURE__ */ jsx(Box, {
14351
+ padding: 5,
14352
+ children: /* @__PURE__ */ jsx(Text, {
14353
+ size: 1,
14354
+ muted: !0,
14355
+ align: "center",
14356
+ children: rows.length === 0 ? "No item yet." : "No match."
14357
+ })
14358
+ })]
14359
+ })]
14360
+ })]
14361
+ })
14362
+ ]
14148
14363
  });
14149
14364
  }
14150
14365
  /** Ligne de la vue TABLE : une cellule par colonne, largeurs fixes. */
@@ -14162,8 +14377,7 @@ function TableRowView(props) {
14162
14377
  background: hovered ? "var(--card-muted-bg-color, rgba(127,127,127,0.08))" : "transparent"
14163
14378
  },
14164
14379
  children: cols.map(({ column, width }, index) => {
14165
- let cell = row.cells[column.key], empty = !cell || cell.raw === null || cell.text === "", first = index === 0, alignEnd = column.kind === "number";
14166
- return /* @__PURE__ */ jsxs(Flex, {
14380
+ let cell = row.cells[column.key], empty = !cell || cell.raw === null || cell.text === "", first = index === 0, alignEnd = column.kind === "number", content = /* @__PURE__ */ jsxs(Flex, {
14167
14381
  align: "center",
14168
14382
  gap: 2,
14169
14383
  paddingRight: 2,
@@ -14173,36 +14387,43 @@ function TableRowView(props) {
14173
14387
  flex: "none",
14174
14388
  boxSizing: "border-box"
14175
14389
  },
14176
- children: [
14177
- first && /* @__PURE__ */ jsx(Text, {
14178
- size: 1,
14179
- muted: !0,
14180
- style: {
14181
- flex: "none",
14182
- display: "flex"
14183
- },
14184
- children: jsx(Icon || DocumentIcon, {})
14185
- }),
14186
- /* @__PURE__ */ jsx(Text, {
14187
- size: 1,
14188
- muted: empty,
14189
- weight: first ? "medium" : "regular",
14190
- textOverflow: "ellipsis",
14191
- style: {
14192
- flex: alignEnd ? "none" : 1,
14193
- minWidth: 0,
14194
- ...column.kind === "number" || column.kind === "date" ? TABULAR : null
14195
- },
14196
- children: empty ? "—" : cell.text
14197
- }),
14198
- first && row.draftOnly && /* @__PURE__ */ jsx(Badge, {
14199
- tone: "caution",
14200
- fontSize: 0,
14201
- style: { flex: "none" },
14202
- children: "Draft"
14203
- })
14204
- ]
14390
+ children: [first && /* @__PURE__ */ jsx(Text, {
14391
+ size: 1,
14392
+ muted: !0,
14393
+ style: {
14394
+ flex: "none",
14395
+ display: "flex"
14396
+ },
14397
+ children: jsx(Icon || DocumentIcon, {})
14398
+ }), /* @__PURE__ */ jsx(Text, {
14399
+ size: 1,
14400
+ muted: empty,
14401
+ weight: first ? "medium" : "regular",
14402
+ textOverflow: "ellipsis",
14403
+ style: {
14404
+ flex: alignEnd ? "none" : 1,
14405
+ minWidth: 0,
14406
+ ...column.kind === "number" || column.kind === "date" ? TABULAR : null
14407
+ },
14408
+ children: empty ? "" : cell.text
14409
+ })]
14205
14410
  }, column.key);
14411
+ return first ? [content, /* @__PURE__ */ jsx(Flex, {
14412
+ align: "center",
14413
+ paddingRight: 2,
14414
+ style: {
14415
+ width: 230,
14416
+ flex: "none",
14417
+ boxSizing: "border-box"
14418
+ },
14419
+ children: /* @__PURE__ */ jsx(StatusBadge, {
14420
+ status: row.status,
14421
+ scheduledAt: row.scheduledAt,
14422
+ live: row.live,
14423
+ hasDraft: row.hasDraft,
14424
+ showDate: !0
14425
+ })
14426
+ }, STATUS_KEY)] : content;
14206
14427
  })
14207
14428
  });
14208
14429
  }
@@ -14254,7 +14475,13 @@ function ListRowView(props) {
14254
14475
  children: subtitle
14255
14476
  }) : null]
14256
14477
  }),
14257
- /* @__PURE__ */ jsx(StatusDot, { draftOnly: row.draftOnly })
14478
+ /* @__PURE__ */ jsx(StatusBadge, {
14479
+ status: row.status,
14480
+ scheduledAt: row.scheduledAt,
14481
+ live: row.live,
14482
+ hasDraft: row.hasDraft,
14483
+ showDate: !0
14484
+ })
14258
14485
  ]
14259
14486
  });
14260
14487
  }