@nocode-factory/sanity-kit 2.67.0 → 2.70.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/index.d.ts +48 -16
- package/dist/index.js +574 -290
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useCollection.ts +5 -2
- package/src/hooks/usePages.ts +5 -2
- package/src/hooks/useQueryData.ts +10 -5
- package/src/hooks/useScheduledReleases.ts +27 -0
- package/src/lib/collectionRows.ts +26 -26
- package/src/lib/colors.ts +3 -6
- package/src/lib/pages.ts +16 -3
- package/src/lib/status.ts +118 -22
- package/src/tools/assets/AssetDetail.tsx +4 -4
- package/src/tools/assets/AssetTable.tsx +3 -3
- package/src/tools/collections/CollectionTable.tsx +53 -30
- package/src/tools/pages/FieldValue.tsx +2 -2
- package/src/tools/pages/PagesTable.tsx +2 -2
- package/src/tools/pages/PagesTool.tsx +25 -2
- package/src/tools/pages/PathCell.tsx +1 -1
- package/src/tools/pages/TagCell.tsx +2 -2
- package/src/tools/pages/board/BoardView.tsx +2 -6
- package/src/tools/pages/board/PageNode.tsx +1 -1
- package/src/tools/pages/board/PagePanel.tsx +2 -2
- package/src/tools/presentation/PagesNavigator.tsx +1 -1
- package/src/ui/ActorName.tsx +1 -1
- package/src/ui/QuietInput.tsx +1 -1
- package/src/ui/StatusBadge.tsx +93 -7
- package/src/ui/StatusFilter.tsx +68 -0
- package/src/ui/formatDate.ts +2 -2
- package/src/version.ts +1 -1
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
|
-
|
|
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
|
-
* -
|
|
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
|
-
*
|
|
669
|
-
*
|
|
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
|
|
685
|
-
|
|
686
|
-
|
|
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
|
-
...
|
|
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
|
|
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: "
|
|
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.
|
|
1488
|
+
const KIT_VERSION = "2.70.0-rc.1";
|
|
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.
|
|
1996
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.70.0-rc.1") > 0);
|
|
1935
1997
|
return {
|
|
1936
1998
|
current: KIT_VERSION,
|
|
1937
1999
|
latest,
|
|
@@ -2308,7 +2370,7 @@ function createPreviewLauncher(config, issues) {
|
|
|
2308
2370
|
* cohérent, y compris quand une publication modifie plusieurs documents.
|
|
2309
2371
|
*/
|
|
2310
2372
|
function useQueryData(query, params, options = {}) {
|
|
2311
|
-
let client = useKitClient(), { listenTypes, 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]);
|
|
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]);
|
|
2312
2374
|
useEffect(() => {
|
|
2313
2375
|
if (!enabled) return;
|
|
2314
2376
|
let cancelled = !1;
|
|
@@ -2332,8 +2394,8 @@ function useQueryData(query, params, options = {}) {
|
|
|
2332
2394
|
refreshRef.current = refresh;
|
|
2333
2395
|
let typesKey = (listenTypes ?? []).join(",");
|
|
2334
2396
|
return useEffect(() => {
|
|
2335
|
-
if (!enabled || !typesKey) return;
|
|
2336
|
-
let types = typesKey.split(","), timer, subscription = client.listen("*[_type in $types]", { types }, {
|
|
2397
|
+
if (!enabled || !typesKey && !listenQuery) return;
|
|
2398
|
+
let types = typesKey ? typesKey.split(",") : [], timer, subscription = client.listen(listenQuery ?? "*[_type in $types]", listenQuery ? {} : { types }, {
|
|
2337
2399
|
visibility: "query",
|
|
2338
2400
|
events: ["mutation"]
|
|
2339
2401
|
}).subscribe({
|
|
@@ -2348,6 +2410,7 @@ function useQueryData(query, params, options = {}) {
|
|
|
2348
2410
|
}, [
|
|
2349
2411
|
client,
|
|
2350
2412
|
typesKey,
|
|
2413
|
+
listenQuery,
|
|
2351
2414
|
enabled
|
|
2352
2415
|
]), {
|
|
2353
2416
|
data,
|
|
@@ -3289,8 +3352,8 @@ function reorderBefore(ordered, dragged, target) {
|
|
|
3289
3352
|
function formatDocumentValue(value, type, invert = !1) {
|
|
3290
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) : "";
|
|
3291
3354
|
}
|
|
3292
|
-
function buildPageRows(docs, config, documentColumns = [], redirects = null) {
|
|
3293
|
-
return mergeVersions(docs).map((merged) => {
|
|
3355
|
+
function buildPageRows(docs, config, documentColumns = [], redirects = null, schedules) {
|
|
3356
|
+
return mergeVersions(docs, schedules).map((merged) => {
|
|
3294
3357
|
let doc = merged.doc, pageType = pageTypeFor(doc._type, config.pageTypes), path = finalPath({
|
|
3295
3358
|
slug: doc.ncfSlug ?? null,
|
|
3296
3359
|
locale: doc.ncfLocale ?? null
|
|
@@ -3303,6 +3366,9 @@ function buildPageRows(docs, config, documentColumns = [], redirects = null) {
|
|
|
3303
3366
|
url: toUrl(config.previewUrl, path),
|
|
3304
3367
|
locale: doc.ncfLocale ?? null,
|
|
3305
3368
|
status: merged.status,
|
|
3369
|
+
scheduledAt: merged.scheduledAt ?? null,
|
|
3370
|
+
live: merged.live,
|
|
3371
|
+
hasDraft: merged.hasDraft,
|
|
3306
3372
|
updatedAt: merged.updatedAt ?? null,
|
|
3307
3373
|
blockCount: doc.ncfBlockCount ?? 0,
|
|
3308
3374
|
noindex: !!doc.ncfNoindex,
|
|
@@ -3311,11 +3377,7 @@ function buildPageRows(docs, config, documentColumns = [], redirects = null) {
|
|
|
3311
3377
|
});
|
|
3312
3378
|
}
|
|
3313
3379
|
/** Ordre d'affichage des statuts : du plus « à traiter » au plus stable. */
|
|
3314
|
-
const STATUS_ORDER = {
|
|
3315
|
-
modified: 0,
|
|
3316
|
-
draft: 1,
|
|
3317
|
-
published: 2
|
|
3318
|
-
}, compare = (a, b, key, options) => {
|
|
3380
|
+
const STATUS_ORDER = Object.fromEntries(STATUS_ORDER$1.map((status, index) => [status, index])), compare = (a, b, key, options) => {
|
|
3319
3381
|
switch (key) {
|
|
3320
3382
|
case "structure": {
|
|
3321
3383
|
let order = options.typeOrder ?? [], rank = (row) => {
|
|
@@ -3354,6 +3416,16 @@ function useRedirectMap(redirectType) {
|
|
|
3354
3416
|
let { data } = useQueryData("*[_type == $type && defined(from) && defined(to) && !(_id in path(\"drafts.**\"))]{from, to}", useMemo(() => ({ type: redirectType }), [redirectType]), { listenTypes: useMemo(() => [redirectType], [redirectType]) });
|
|
3355
3417
|
return useMemo(() => redirectMapOf(data ?? []), [data]);
|
|
3356
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
|
+
}
|
|
3357
3429
|
/**
|
|
3358
3430
|
* Toutes les pages du site, brouillons compris, tenues à jour.
|
|
3359
3431
|
*
|
|
@@ -3369,13 +3441,14 @@ function usePages(documentColumns = []) {
|
|
|
3369
3441
|
config,
|
|
3370
3442
|
pageBuilderField,
|
|
3371
3443
|
columns
|
|
3372
|
-
]), useMemo(() => ({ types: config.pageTypeNames }), [config.pageTypeNames]), { listenTypes: config.pageTypeNames }), redirects = useRedirectMap(config.redirectType);
|
|
3444
|
+
]), useMemo(() => ({ types: config.pageTypeNames }), [config.pageTypeNames]), { listenTypes: config.pageTypeNames }), redirects = useRedirectMap(config.redirectType), schedules = useScheduledReleases();
|
|
3373
3445
|
return {
|
|
3374
|
-
rows: useMemo(() => data ? buildPageRows(data, config, columns, redirects) : [], [
|
|
3446
|
+
rows: useMemo(() => data ? buildPageRows(data, config, columns, redirects, schedules) : [], [
|
|
3375
3447
|
data,
|
|
3376
3448
|
config,
|
|
3377
3449
|
columns,
|
|
3378
|
-
redirects
|
|
3450
|
+
redirects,
|
|
3451
|
+
schedules
|
|
3379
3452
|
]),
|
|
3380
3453
|
loading,
|
|
3381
3454
|
error,
|
|
@@ -4677,12 +4750,6 @@ function groupPageRows(rows, groupBy, options) {
|
|
|
4677
4750
|
rows: buckets.get(value) ?? []
|
|
4678
4751
|
}));
|
|
4679
4752
|
}
|
|
4680
|
-
/** Couleurs des statuts, alignées sur les tons des badges. */
|
|
4681
|
-
const STATUS_COLORS = {
|
|
4682
|
-
published: "#43d675",
|
|
4683
|
-
modified: "#f5a623",
|
|
4684
|
-
draft: "#8a8a8a"
|
|
4685
|
-
};
|
|
4686
4753
|
/**
|
|
4687
4754
|
* Applique une opacité à une couleur hexadécimale.
|
|
4688
4755
|
*
|
|
@@ -4886,13 +4953,87 @@ function QueryError(props) {
|
|
|
4886
4953
|
})
|
|
4887
4954
|
});
|
|
4888
4955
|
}
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
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
|
+
}
|
|
4896
5037
|
});
|
|
4897
5038
|
}
|
|
4898
5039
|
const formatter = new Intl.DateTimeFormat("en-US", {
|
|
@@ -4904,9 +5045,9 @@ const formatter = new Intl.DateTimeFormat("en-US", {
|
|
|
4904
5045
|
});
|
|
4905
5046
|
/** Date lisible, ou un tiret cadratin quand il n'y en a pas. */
|
|
4906
5047
|
function formatDate$1(value) {
|
|
4907
|
-
if (!value) return "
|
|
5048
|
+
if (!value) return "";
|
|
4908
5049
|
let date = new Date(value);
|
|
4909
|
-
return Number.isNaN(date.getTime()) ? "
|
|
5050
|
+
return Number.isNaN(date.getTime()) ? "" : formatter.format(date);
|
|
4910
5051
|
}
|
|
4911
5052
|
/**
|
|
4912
5053
|
* Champ de saisie d'une cellule de tableau.
|
|
@@ -4921,7 +5062,7 @@ function QuietInput(props) {
|
|
|
4921
5062
|
return /* @__PURE__ */ jsx("input", {
|
|
4922
5063
|
type: "text",
|
|
4923
5064
|
defaultValue: props.value,
|
|
4924
|
-
placeholder: props.placeholder ?? "
|
|
5065
|
+
placeholder: props.placeholder ?? "",
|
|
4925
5066
|
onBlur: (event) => {
|
|
4926
5067
|
event.currentTarget.value !== props.value && props.onCommit(event.currentTarget.value);
|
|
4927
5068
|
},
|
|
@@ -4984,7 +5125,8 @@ function FieldValue(props) {
|
|
|
4984
5125
|
})] }) : /* @__PURE__ */ jsx(Text, {
|
|
4985
5126
|
size: 0,
|
|
4986
5127
|
muted: !0,
|
|
4987
|
-
|
|
5128
|
+
"aria-label": "Not set",
|
|
5129
|
+
children: "\xA0"
|
|
4988
5130
|
})
|
|
4989
5131
|
}),
|
|
4990
5132
|
children: ({ close }) => /* @__PURE__ */ jsx(OptionEditor, {
|
|
@@ -5390,7 +5532,7 @@ function PathCell(props) {
|
|
|
5390
5532
|
if (!path) return /* @__PURE__ */ jsx(Text, {
|
|
5391
5533
|
size: 1,
|
|
5392
5534
|
muted: !0,
|
|
5393
|
-
children: "
|
|
5535
|
+
children: "No address"
|
|
5394
5536
|
});
|
|
5395
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, {
|
|
5396
5538
|
size: 1,
|
|
@@ -5485,7 +5627,8 @@ function TagCell(props) {
|
|
|
5485
5627
|
})] }) : /* @__PURE__ */ jsx(Text, {
|
|
5486
5628
|
size: 0,
|
|
5487
5629
|
muted: !0,
|
|
5488
|
-
|
|
5630
|
+
"aria-label": "Not set",
|
|
5631
|
+
children: "\xA0"
|
|
5489
5632
|
})
|
|
5490
5633
|
}),
|
|
5491
5634
|
children: ({ close }) => /* @__PURE__ */ jsxs(Stack, {
|
|
@@ -5761,7 +5904,13 @@ function PagesTable(props) {
|
|
|
5761
5904
|
wrap: "wrap",
|
|
5762
5905
|
style: CELL,
|
|
5763
5906
|
children: [
|
|
5764
|
-
/* @__PURE__ */ jsx(StatusBadge, {
|
|
5907
|
+
/* @__PURE__ */ jsx(StatusBadge, {
|
|
5908
|
+
status: entryRow.status,
|
|
5909
|
+
scheduledAt: entryRow.scheduledAt,
|
|
5910
|
+
live: entryRow.live,
|
|
5911
|
+
hasDraft: entryRow.hasDraft,
|
|
5912
|
+
showDate: !0
|
|
5913
|
+
}),
|
|
5765
5914
|
!!todos?.get(entryRow.id) && /* @__PURE__ */ jsxs(Badge, {
|
|
5766
5915
|
tone: "caution",
|
|
5767
5916
|
fontSize: 0,
|
|
@@ -5803,7 +5952,7 @@ function PagesTable(props) {
|
|
|
5803
5952
|
size: 0,
|
|
5804
5953
|
muted: !value,
|
|
5805
5954
|
textOverflow: "ellipsis",
|
|
5806
|
-
children: value || "
|
|
5955
|
+
children: value || ""
|
|
5807
5956
|
})
|
|
5808
5957
|
}, column.key);
|
|
5809
5958
|
}),
|
|
@@ -5832,6 +5981,74 @@ function PagesTable(props) {
|
|
|
5832
5981
|
})]
|
|
5833
5982
|
});
|
|
5834
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
|
+
}
|
|
5835
6052
|
/**
|
|
5836
6053
|
* Recherche et rafraîchissement.
|
|
5837
6054
|
*
|
|
@@ -6105,7 +6322,13 @@ function PagePanel(props) {
|
|
|
6105
6322
|
gap: 2,
|
|
6106
6323
|
align: "center",
|
|
6107
6324
|
wrap: "wrap",
|
|
6108
|
-
children: [/* @__PURE__ */ jsx(StatusBadge, {
|
|
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, {
|
|
6109
6332
|
gap: 2,
|
|
6110
6333
|
align: "center",
|
|
6111
6334
|
children: [/* @__PURE__ */ jsx(Box, { style: {
|
|
@@ -6125,7 +6348,7 @@ function PagePanel(props) {
|
|
|
6125
6348
|
size: 1,
|
|
6126
6349
|
textOverflow: "ellipsis",
|
|
6127
6350
|
style: MONO,
|
|
6128
|
-
children: row.path ?? "
|
|
6351
|
+
children: row.path ?? "No address"
|
|
6129
6352
|
}),
|
|
6130
6353
|
/* @__PURE__ */ jsxs(Text, {
|
|
6131
6354
|
size: 0,
|
|
@@ -6503,7 +6726,12 @@ function TreeNode(props) {
|
|
|
6503
6726
|
}) : /* @__PURE__ */ jsxs(Flex, {
|
|
6504
6727
|
gap: 2,
|
|
6505
6728
|
align: "center",
|
|
6506
|
-
children: [/* @__PURE__ */ jsx(StatusBadge, {
|
|
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, {
|
|
6507
6735
|
className: "nodrag",
|
|
6508
6736
|
fontSize: 0,
|
|
6509
6737
|
padding: 1,
|
|
@@ -6668,11 +6896,7 @@ function useAnnotations(scope) {
|
|
|
6668
6896
|
const nodeTypes$1 = {
|
|
6669
6897
|
page: PageNode,
|
|
6670
6898
|
annotation: AnnotationNode
|
|
6671
|
-
}, isPageNode = (node) => node.type === "page", MINIMAP_COLORS = {
|
|
6672
|
-
published: "#43d675",
|
|
6673
|
-
modified: "#f5a623",
|
|
6674
|
-
draft: "#8a8a8a"
|
|
6675
|
-
}, FLOW_THEME$1 = {
|
|
6899
|
+
}, isPageNode = (node) => node.type === "page", MINIMAP_COLORS = STATUS_COLORS, FLOW_THEME$1 = {
|
|
6676
6900
|
width: "100%",
|
|
6677
6901
|
height: "100%",
|
|
6678
6902
|
"--xy-background-color": "var(--card-bg-color)",
|
|
@@ -7154,14 +7378,15 @@ function BoardView(props) {
|
|
|
7154
7378
|
return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(Board, { ...props }) });
|
|
7155
7379
|
}
|
|
7156
7380
|
function PagesTool() {
|
|
7157
|
-
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) => {
|
|
7158
7382
|
setShownData((current) => {
|
|
7159
7383
|
let next = new Set(current);
|
|
7160
7384
|
return next.has(key) ? next.delete(key) : next.add(key), next;
|
|
7161
7385
|
});
|
|
7162
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, {
|
|
7163
7387
|
search,
|
|
7164
|
-
locales: locale ? [locale] : void 0
|
|
7388
|
+
locales: locale ? [locale] : void 0,
|
|
7389
|
+
statuses: statusFilter ? [statusFilter] : void 0
|
|
7165
7390
|
}).filter((row) => !onlyTodo || todos.has(row.id)), effectiveSortKey, sortDirection, {
|
|
7166
7391
|
typeOrder: config.pageTypeNames,
|
|
7167
7392
|
pageOrder
|
|
@@ -7169,13 +7394,14 @@ function PagesTool() {
|
|
|
7169
7394
|
rows,
|
|
7170
7395
|
search,
|
|
7171
7396
|
locale,
|
|
7397
|
+
statusFilter,
|
|
7172
7398
|
onlyTodo,
|
|
7173
7399
|
todos,
|
|
7174
7400
|
effectiveSortKey,
|
|
7175
7401
|
sortDirection,
|
|
7176
7402
|
config.pageTypeNames,
|
|
7177
7403
|
pageOrder
|
|
7178
|
-
]), 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, {
|
|
7179
7405
|
meta: byId,
|
|
7180
7406
|
tags: config.boardTags,
|
|
7181
7407
|
fields: columns
|
|
@@ -7391,6 +7617,13 @@ function PagesTool() {
|
|
|
7391
7617
|
busy: loading,
|
|
7392
7618
|
summary
|
|
7393
7619
|
}),
|
|
7620
|
+
rows.length > 0 && /* @__PURE__ */ jsx(StatusFilter, {
|
|
7621
|
+
rows: statusScope,
|
|
7622
|
+
value: statusFilter,
|
|
7623
|
+
onChange: (value) => {
|
|
7624
|
+
setStatusFilter(value), setPage(0);
|
|
7625
|
+
}
|
|
7626
|
+
}),
|
|
7394
7627
|
view === "list" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Card, {
|
|
7395
7628
|
radius: 3,
|
|
7396
7629
|
shadow: 1,
|
|
@@ -9183,7 +9416,7 @@ function Line(props) {
|
|
|
9183
9416
|
* d'avoir à détenir un jeton Sanity par client.
|
|
9184
9417
|
*/
|
|
9185
9418
|
function ActorName(props) {
|
|
9186
|
-
let [user] = useUser(props.actorId ?? ""), label = props.actorName || user?.displayName || (props.actorId ? "Unknown account" : "
|
|
9419
|
+
let [user] = useUser(props.actorId ?? ""), label = props.actorName || user?.displayName || (props.actorId ? "Unknown account" : "Unknown");
|
|
9187
9420
|
return /* @__PURE__ */ jsx(Text, {
|
|
9188
9421
|
size: 0,
|
|
9189
9422
|
muted: !0,
|
|
@@ -10210,7 +10443,7 @@ function AssetTable(props) {
|
|
|
10210
10443
|
size: 1,
|
|
10211
10444
|
muted: !0,
|
|
10212
10445
|
style: TABULAR,
|
|
10213
|
-
children: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : "
|
|
10446
|
+
children: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : ""
|
|
10214
10447
|
})
|
|
10215
10448
|
}),
|
|
10216
10449
|
/* @__PURE__ */ jsx("td", {
|
|
@@ -10222,7 +10455,7 @@ function AssetTable(props) {
|
|
|
10222
10455
|
size: 1,
|
|
10223
10456
|
muted: !0,
|
|
10224
10457
|
textOverflow: "ellipsis",
|
|
10225
|
-
children: folder ? folderName(folder) : "
|
|
10458
|
+
children: folder ? folderName(folder) : ""
|
|
10226
10459
|
})
|
|
10227
10460
|
}),
|
|
10228
10461
|
/* @__PURE__ */ jsx("td", {
|
|
@@ -10238,7 +10471,7 @@ function AssetTable(props) {
|
|
|
10238
10471
|
}) : /* @__PURE__ */ jsx(Text, {
|
|
10239
10472
|
size: 1,
|
|
10240
10473
|
style: TABULAR,
|
|
10241
|
-
children: asset.uses ?? "
|
|
10474
|
+
children: asset.uses ?? ""
|
|
10242
10475
|
})
|
|
10243
10476
|
}),
|
|
10244
10477
|
/* @__PURE__ */ jsx("td", {
|
|
@@ -10291,7 +10524,7 @@ function toPatchPath(segments) {
|
|
|
10291
10524
|
function assetUnsetPaths(doc, assetId) {
|
|
10292
10525
|
return findAssetRefPaths(doc, assetId).map(toPatchPath).filter(Boolean);
|
|
10293
10526
|
}
|
|
10294
|
-
const baseId$
|
|
10527
|
+
const baseId$1 = (id) => id.replace(/^drafts\./, "");
|
|
10295
10528
|
/**
|
|
10296
10529
|
* Suppression d'un asset depuis l'outil Assets. Sanity refuse de supprimer un
|
|
10297
10530
|
* asset référencé : on retire d'abord l'asset de chaque document (le champ
|
|
@@ -10303,7 +10536,7 @@ function useAssetDelete() {
|
|
|
10303
10536
|
usage: useCallback(async (assetId) => {
|
|
10304
10537
|
let docs = await client.fetch("*[references($id)]{_id, _type, \"title\": coalesce(title, name, originalFilename, slug.current, _id)}", { id: assetId }), seen = /* @__PURE__ */ new Map();
|
|
10305
10538
|
for (let doc of docs ?? []) {
|
|
10306
|
-
let id = baseId$
|
|
10539
|
+
let id = baseId$1(doc._id);
|
|
10307
10540
|
seen.has(id) || seen.set(id, {
|
|
10308
10541
|
id,
|
|
10309
10542
|
type: doc._type,
|
|
@@ -10416,7 +10649,7 @@ function AssetDetail(props) {
|
|
|
10416
10649
|
children: /* @__PURE__ */ jsxs(Text, {
|
|
10417
10650
|
size: 1,
|
|
10418
10651
|
muted: !0,
|
|
10419
|
-
children: [asset.extension?.toUpperCase() || "Fichier", "
|
|
10652
|
+
children: [asset.extension?.toUpperCase() || "Fichier", " (pas d'aperçu)"]
|
|
10420
10653
|
})
|
|
10421
10654
|
})
|
|
10422
10655
|
}),
|
|
@@ -10512,7 +10745,7 @@ function AssetDetail(props) {
|
|
|
10512
10745
|
children: [
|
|
10513
10746
|
/* @__PURE__ */ jsx(Metric, {
|
|
10514
10747
|
label: "Fichier",
|
|
10515
|
-
value: asset.originalFilename ?? "
|
|
10748
|
+
value: asset.originalFilename ?? "None"
|
|
10516
10749
|
}),
|
|
10517
10750
|
/* @__PURE__ */ jsx(Metric, {
|
|
10518
10751
|
label: "Type",
|
|
@@ -10524,11 +10757,11 @@ function AssetDetail(props) {
|
|
|
10524
10757
|
}),
|
|
10525
10758
|
/* @__PURE__ */ jsx(Metric, {
|
|
10526
10759
|
label: "Dimensions",
|
|
10527
|
-
value: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : "
|
|
10760
|
+
value: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : "Unknown"
|
|
10528
10761
|
}),
|
|
10529
10762
|
/* @__PURE__ */ jsx(Metric, {
|
|
10530
10763
|
label: "Usage",
|
|
10531
|
-
value: asset.uses === void 0 ? "
|
|
10764
|
+
value: asset.uses === void 0 ? "Unknown" : `${asset.uses}`
|
|
10532
10765
|
}),
|
|
10533
10766
|
/* @__PURE__ */ jsx(Metric, {
|
|
10534
10767
|
label: "Ajouté",
|
|
@@ -12880,7 +13113,12 @@ function PagesNavigator() {
|
|
|
12880
13113
|
children: row.path
|
|
12881
13114
|
})]
|
|
12882
13115
|
}),
|
|
12883
|
-
|
|
13116
|
+
/* @__PURE__ */ jsx(StatusBadge, {
|
|
13117
|
+
status: row.status,
|
|
13118
|
+
scheduledAt: row.scheduledAt,
|
|
13119
|
+
live: row.live,
|
|
13120
|
+
hasDraft: row.hasDraft
|
|
13121
|
+
})
|
|
12884
13122
|
]
|
|
12885
13123
|
})
|
|
12886
13124
|
}, row.id);
|
|
@@ -13476,7 +13714,7 @@ function buildCollectionQuery(columns, filter) {
|
|
|
13476
13714
|
"}"
|
|
13477
13715
|
].join("\n");
|
|
13478
13716
|
}
|
|
13479
|
-
const
|
|
13717
|
+
const dateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
13480
13718
|
day: "2-digit",
|
|
13481
13719
|
month: "2-digit",
|
|
13482
13720
|
year: "numeric"
|
|
@@ -13517,30 +13755,29 @@ function cellOf(raw, kind) {
|
|
|
13517
13755
|
}
|
|
13518
13756
|
/**
|
|
13519
13757
|
* Documents → lignes, une par item. Le client (perspective `raw`) renvoie le
|
|
13520
|
-
* brouillon
|
|
13521
|
-
*
|
|
13758
|
+
* brouillon, la version publiée et les versions de release : on les fusionne
|
|
13759
|
+
* par id de base (`mergeVersions`, même règle que les pages), en gardant le
|
|
13760
|
+
* brouillon s'il existe (valeurs les plus fraîches). Une version de release non
|
|
13761
|
+
* programmée ne crée jamais de ligne à part.
|
|
13522
13762
|
*/
|
|
13523
|
-
function buildCollectionRows(docs, columns) {
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
let rows = [];
|
|
13531
|
-
for (let [id, { draft, published }] of byId) {
|
|
13532
|
-
let source = draft ?? published;
|
|
13533
|
-
if (!source) continue;
|
|
13534
|
-
let cells = {};
|
|
13763
|
+
function buildCollectionRows(docs, columns, schedules) {
|
|
13764
|
+
return mergeVersions(docs.filter((doc) => !!doc?._id).map((doc) => ({
|
|
13765
|
+
...doc,
|
|
13766
|
+
_type: "",
|
|
13767
|
+
_updatedAt: doc._updatedAt ?? void 0
|
|
13768
|
+
})), schedules).map((merged) => {
|
|
13769
|
+
let source = merged.doc, cells = {};
|
|
13535
13770
|
for (let column of columns) cells[column.key] = cellOf(source[`${DATA_PREFIX}${column.key}`], column.kind);
|
|
13536
|
-
|
|
13537
|
-
id,
|
|
13538
|
-
updatedAt:
|
|
13539
|
-
|
|
13771
|
+
return {
|
|
13772
|
+
id: merged.id,
|
|
13773
|
+
updatedAt: merged.updatedAt ?? null,
|
|
13774
|
+
status: merged.status,
|
|
13775
|
+
scheduledAt: merged.scheduledAt ?? null,
|
|
13776
|
+
live: merged.live,
|
|
13777
|
+
hasDraft: merged.hasDraft,
|
|
13540
13778
|
cells
|
|
13541
|
-
}
|
|
13542
|
-
}
|
|
13543
|
-
return rows;
|
|
13779
|
+
};
|
|
13780
|
+
});
|
|
13544
13781
|
}
|
|
13545
13782
|
/**
|
|
13546
13783
|
* Données d'une collection pour la vue table : colonnes tirées du schéma,
|
|
@@ -13555,11 +13792,15 @@ function useCollection(type, visibleKeys, options = {}) {
|
|
|
13555
13792
|
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]), {
|
|
13556
13793
|
type,
|
|
13557
13794
|
...extraParams
|
|
13558
|
-
}, { listenTypes: [type] });
|
|
13795
|
+
}, { listenTypes: [type] }), schedules = useScheduledReleases();
|
|
13559
13796
|
return {
|
|
13560
13797
|
allColumns,
|
|
13561
13798
|
visibleColumns,
|
|
13562
|
-
rows: useMemo(() => buildCollectionRows(data ?? [], visibleColumns), [
|
|
13799
|
+
rows: useMemo(() => buildCollectionRows(data ?? [], visibleColumns, schedules), [
|
|
13800
|
+
data,
|
|
13801
|
+
visibleColumns,
|
|
13802
|
+
schedules
|
|
13803
|
+
]),
|
|
13563
13804
|
loading,
|
|
13564
13805
|
error,
|
|
13565
13806
|
refresh
|
|
@@ -13810,8 +14051,8 @@ function CollectionToolbar(props) {
|
|
|
13810
14051
|
]
|
|
13811
14052
|
});
|
|
13812
14053
|
}
|
|
13813
|
-
/**
|
|
13814
|
-
const MEDIA = "2.0625rem";
|
|
14054
|
+
/** Clé de tri de la colonne Status (colonne du kit, pas un champ du schéma). */
|
|
14055
|
+
const STATUS_KEY = "__status", MEDIA = "2.0625rem";
|
|
13815
14056
|
function defaultVisible(columns) {
|
|
13816
14057
|
let title = columns.find((c) => c.key === "title") ?? columns.find((c) => c.kind === "text");
|
|
13817
14058
|
return (title ? [title, ...columns.filter((c) => c !== title)] : [...columns]).slice(0, 6).map((c) => c.key);
|
|
@@ -13838,21 +14079,29 @@ function CollectionTable({ type, filter, params, newTemplate }) {
|
|
|
13838
14079
|
let router = useRouter(), { ChildLink } = usePaneRouter(), [view, setView] = useState("table"), [selected, setSelected] = useState(null), [sort, setSort] = useState({
|
|
13839
14080
|
key: null,
|
|
13840
14081
|
direction: "asc"
|
|
13841
|
-
}), [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, {
|
|
14082
|
+
}), [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, {
|
|
13842
14083
|
filter,
|
|
13843
14084
|
params
|
|
13844
|
-
}), visible = useMemo(() =>
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
14085
|
+
}), visible = useMemo(() => {
|
|
14086
|
+
let searched = filterRows(rows, {
|
|
14087
|
+
search,
|
|
14088
|
+
columns: {}
|
|
14089
|
+
}, visibleColumns), filtered = statusFilter ? searched.filter((row) => row.status === statusFilter) : searched;
|
|
14090
|
+
if (sort.key === STATUS_KEY) {
|
|
14091
|
+
let rank = (status) => STATUS_ORDER$1.indexOf(status), sorted = [...filtered].sort((a, b) => rank(a.status) - rank(b.status));
|
|
14092
|
+
return sort.direction === "asc" ? sorted : sorted.reverse();
|
|
14093
|
+
}
|
|
14094
|
+
return sortRows(filtered, sort, visibleColumns);
|
|
14095
|
+
}, [
|
|
13848
14096
|
rows,
|
|
13849
14097
|
search,
|
|
14098
|
+
statusFilter,
|
|
13850
14099
|
visibleColumns,
|
|
13851
14100
|
sort
|
|
13852
14101
|
]), cols = useMemo(() => visibleColumns.map((column, index) => ({
|
|
13853
14102
|
column,
|
|
13854
14103
|
width: widths[column.key] ?? defaultWidth(column, index === 0)
|
|
13855
|
-
})), [visibleColumns, widths]), totalWidth = useMemo(() => cols.reduce((sum, c) => sum + c.width, 0), [cols]), onToggleColumn = useCallback((key) => {
|
|
14104
|
+
})), [visibleColumns, widths]), totalWidth = useMemo(() => cols.reduce((sum, c) => sum + c.width, 0) + 230, [cols]), onToggleColumn = useCallback((key) => {
|
|
13856
14105
|
setSelected((current) => {
|
|
13857
14106
|
let base = current ?? defaultVisible(allColumns);
|
|
13858
14107
|
return base.includes(key) ? base.filter((k) => k !== key) : [...base, key];
|
|
@@ -13899,153 +14148,89 @@ function CollectionTable({ type, filter, params, newTemplate }) {
|
|
|
13899
14148
|
error,
|
|
13900
14149
|
onRetry: refresh
|
|
13901
14150
|
});
|
|
13902
|
-
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
|
|
13903
|
-
|
|
13904
|
-
|
|
13905
|
-
|
|
13906
|
-
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
visible: visibleKeys,
|
|
13912
|
-
onToggleColumn,
|
|
13913
|
-
onExport,
|
|
13914
|
-
onRefresh: refresh,
|
|
13915
|
-
onCreate,
|
|
13916
|
-
busy: loading,
|
|
13917
|
-
summary
|
|
13918
|
-
}), loading && rows.length === 0 ? /* @__PURE__ */ jsxs(Flex, {
|
|
14151
|
+
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, {
|
|
14152
|
+
paddingRight: 2,
|
|
14153
|
+
style: {
|
|
14154
|
+
width: 230,
|
|
14155
|
+
flex: "none",
|
|
14156
|
+
boxSizing: "border-box",
|
|
14157
|
+
borderLeft: "2px solid transparent"
|
|
14158
|
+
},
|
|
14159
|
+
children: /* @__PURE__ */ jsxs(Flex, {
|
|
13919
14160
|
align: "center",
|
|
13920
|
-
|
|
13921
|
-
|
|
13922
|
-
gap: 3,
|
|
13923
|
-
children: [/* @__PURE__ */ jsx(Spinner, { muted: !0 }), /* @__PURE__ */ jsx(Text, {
|
|
13924
|
-
size: 1,
|
|
13925
|
-
muted: !0,
|
|
13926
|
-
children: "Loading…"
|
|
13927
|
-
})]
|
|
13928
|
-
}) : visibleColumns.length === 0 ? /* @__PURE__ */ jsx(Box, {
|
|
13929
|
-
padding: 5,
|
|
13930
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
13931
|
-
size: 1,
|
|
13932
|
-
muted: !0,
|
|
13933
|
-
align: "center",
|
|
13934
|
-
children: "No displayable field in this type. Pick columns above."
|
|
13935
|
-
})
|
|
13936
|
-
}) : view === "list" ? /* @__PURE__ */ jsxs(Box, {
|
|
14161
|
+
gap: 1,
|
|
14162
|
+
onClick: () => onSort(STATUS_KEY),
|
|
13937
14163
|
style: {
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
overflow: "hidden"
|
|
14164
|
+
cursor: "pointer",
|
|
14165
|
+
userSelect: "none"
|
|
13941
14166
|
},
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
13945
|
-
|
|
13946
|
-
|
|
13947
|
-
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
|
|
13954
|
-
|
|
13955
|
-
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
14167
|
+
title: "Sort by status",
|
|
14168
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
14169
|
+
size: 1,
|
|
14170
|
+
weight: "semibold",
|
|
14171
|
+
muted: sort.key !== STATUS_KEY,
|
|
14172
|
+
children: "Status"
|
|
14173
|
+
}), sort.key === STATUS_KEY && /* @__PURE__ */ jsx(StatusArrow, { style: {
|
|
14174
|
+
fontSize: 14,
|
|
14175
|
+
opacity: .7,
|
|
14176
|
+
flex: "none"
|
|
14177
|
+
} })]
|
|
14178
|
+
})
|
|
14179
|
+
}, STATUS_KEY);
|
|
14180
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
14181
|
+
gap: 3,
|
|
14182
|
+
children: [
|
|
14183
|
+
/* @__PURE__ */ jsx(CollectionToolbar, {
|
|
14184
|
+
view,
|
|
14185
|
+
onView: setView,
|
|
14186
|
+
search,
|
|
14187
|
+
onSearch: setSearch,
|
|
14188
|
+
columns: allColumns,
|
|
14189
|
+
visible: visibleKeys,
|
|
14190
|
+
onToggleColumn,
|
|
14191
|
+
onExport,
|
|
14192
|
+
onRefresh: refresh,
|
|
14193
|
+
onCreate,
|
|
14194
|
+
busy: loading,
|
|
14195
|
+
summary
|
|
14196
|
+
}),
|
|
14197
|
+
rows.length > 0 && /* @__PURE__ */ jsx(StatusFilter, {
|
|
14198
|
+
rows,
|
|
14199
|
+
value: statusFilter,
|
|
14200
|
+
onChange: setStatusFilter
|
|
14201
|
+
}),
|
|
14202
|
+
loading && rows.length === 0 ? /* @__PURE__ */ jsxs(Flex, {
|
|
14203
|
+
align: "center",
|
|
14204
|
+
justify: "center",
|
|
14205
|
+
padding: 6,
|
|
14206
|
+
gap: 3,
|
|
14207
|
+
children: [/* @__PURE__ */ jsx(Spinner, { muted: !0 }), /* @__PURE__ */ jsx(Text, {
|
|
14208
|
+
size: 1,
|
|
14209
|
+
muted: !0,
|
|
14210
|
+
children: "Loading…"
|
|
13960
14211
|
})]
|
|
13961
|
-
})
|
|
13962
|
-
|
|
13963
|
-
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
|
|
13968
|
-
|
|
14212
|
+
}) : visibleColumns.length === 0 ? /* @__PURE__ */ jsx(Box, {
|
|
14213
|
+
padding: 5,
|
|
14214
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
14215
|
+
size: 1,
|
|
14216
|
+
muted: !0,
|
|
14217
|
+
align: "center",
|
|
14218
|
+
children: "No displayable field in this type. Pick columns above."
|
|
14219
|
+
})
|
|
14220
|
+
}) : view === "list" ? /* @__PURE__ */ jsxs(Box, {
|
|
13969
14221
|
style: {
|
|
13970
|
-
|
|
13971
|
-
|
|
14222
|
+
border: `1px solid ${BORDER_SOFT}`,
|
|
14223
|
+
borderRadius: 6,
|
|
14224
|
+
overflow: "hidden"
|
|
13972
14225
|
},
|
|
13973
|
-
children: [/* @__PURE__ */ jsx(
|
|
13974
|
-
paddingX: 3,
|
|
13975
|
-
paddingY: 3,
|
|
13976
|
-
align: "center",
|
|
13977
|
-
style: {
|
|
13978
|
-
borderBottom: `1px solid ${BORDER}`,
|
|
13979
|
-
position: "sticky",
|
|
13980
|
-
top: 0,
|
|
13981
|
-
background: "var(--card-muted-bg-color, var(--card-bg-color, inherit))",
|
|
13982
|
-
zIndex: 2
|
|
13983
|
-
},
|
|
13984
|
-
children: cols.map(({ column, width }) => {
|
|
13985
|
-
let active = sort.key === column.key, Arrow = sort.direction === "asc" ? ChevronUpIcon : ChevronDownIcon, alignEnd = column.kind === "number";
|
|
13986
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
13987
|
-
paddingRight: 2,
|
|
13988
|
-
onDragOver: (e) => {
|
|
13989
|
-
dragKeyRef.current && dragKeyRef.current !== column.key && (e.preventDefault(), setDragOverKey(column.key));
|
|
13990
|
-
},
|
|
13991
|
-
onDrop: () => onReorder(column.key),
|
|
13992
|
-
style: {
|
|
13993
|
-
width,
|
|
13994
|
-
flex: "none",
|
|
13995
|
-
position: "relative",
|
|
13996
|
-
boxSizing: "border-box",
|
|
13997
|
-
borderLeft: dragOverKey === column.key ? "2px solid var(--card-focus-ring-color, #2276fc)" : "2px solid transparent"
|
|
13998
|
-
},
|
|
13999
|
-
children: [/* @__PURE__ */ jsxs(Flex, {
|
|
14000
|
-
align: "center",
|
|
14001
|
-
gap: 1,
|
|
14002
|
-
justify: alignEnd ? "flex-end" : "flex-start",
|
|
14003
|
-
draggable: !0,
|
|
14004
|
-
onDragStart: () => {
|
|
14005
|
-
dragKeyRef.current = column.key;
|
|
14006
|
-
},
|
|
14007
|
-
onDragEnd: () => {
|
|
14008
|
-
dragKeyRef.current = null, setDragOverKey(null);
|
|
14009
|
-
},
|
|
14010
|
-
onClick: () => onSort(column.key),
|
|
14011
|
-
style: {
|
|
14012
|
-
cursor: "grab",
|
|
14013
|
-
userSelect: "none"
|
|
14014
|
-
},
|
|
14015
|
-
title: `Sort by ${column.label.toLowerCase()} — drag to reorder`,
|
|
14016
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
14017
|
-
size: 1,
|
|
14018
|
-
weight: "semibold",
|
|
14019
|
-
muted: !active,
|
|
14020
|
-
textOverflow: "ellipsis",
|
|
14021
|
-
children: column.label
|
|
14022
|
-
}), active && /* @__PURE__ */ jsx(Arrow, { style: {
|
|
14023
|
-
fontSize: 14,
|
|
14024
|
-
opacity: .7,
|
|
14025
|
-
flex: "none"
|
|
14026
|
-
} })]
|
|
14027
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
14028
|
-
onPointerDown: onResizeStart(column.key, width),
|
|
14029
|
-
title: "Drag to resize",
|
|
14030
|
-
style: {
|
|
14031
|
-
position: "absolute",
|
|
14032
|
-
top: 0,
|
|
14033
|
-
right: 0,
|
|
14034
|
-
width: 9,
|
|
14035
|
-
height: "100%",
|
|
14036
|
-
cursor: "col-resize",
|
|
14037
|
-
touchAction: "none"
|
|
14038
|
-
}
|
|
14039
|
-
})]
|
|
14040
|
-
}, column.key);
|
|
14041
|
-
})
|
|
14042
|
-
}), /* @__PURE__ */ jsxs(Box, {
|
|
14226
|
+
children: [/* @__PURE__ */ jsx("style", { children: ".ncf-coll-body a{display:block;color:inherit;text-decoration:none}" }), /* @__PURE__ */ jsxs(Box, {
|
|
14043
14227
|
className: "ncf-coll-body",
|
|
14044
14228
|
children: [visible.map((row) => /* @__PURE__ */ jsx(ChildLink, {
|
|
14045
14229
|
childId: row.id,
|
|
14046
|
-
children: /* @__PURE__ */ jsx(
|
|
14230
|
+
children: /* @__PURE__ */ jsx(ListRowView, {
|
|
14047
14231
|
row,
|
|
14048
|
-
|
|
14232
|
+
titleKey,
|
|
14233
|
+
subtitleKey,
|
|
14049
14234
|
Icon: TypeIcon
|
|
14050
14235
|
})
|
|
14051
14236
|
}, row.id)), visible.length === 0 && /* @__PURE__ */ jsx(Box, {
|
|
@@ -14058,21 +14243,108 @@ function CollectionTable({ type, filter, params, newTemplate }) {
|
|
|
14058
14243
|
})
|
|
14059
14244
|
})]
|
|
14060
14245
|
})]
|
|
14061
|
-
})
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
}
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14246
|
+
}) : /* @__PURE__ */ jsxs(Box, {
|
|
14247
|
+
style: {
|
|
14248
|
+
overflowX: "auto",
|
|
14249
|
+
border: `1px solid ${BORDER_SOFT}`,
|
|
14250
|
+
borderRadius: 6
|
|
14251
|
+
},
|
|
14252
|
+
children: [/* @__PURE__ */ jsx("style", { children: ".ncf-coll-body a{display:contents;color:inherit;text-decoration:none}" }), /* @__PURE__ */ jsxs(Box, {
|
|
14253
|
+
style: {
|
|
14254
|
+
width: totalWidth,
|
|
14255
|
+
minWidth: "100%"
|
|
14256
|
+
},
|
|
14257
|
+
children: [/* @__PURE__ */ jsx(Flex, {
|
|
14258
|
+
paddingX: 3,
|
|
14259
|
+
paddingY: 3,
|
|
14260
|
+
align: "center",
|
|
14261
|
+
style: {
|
|
14262
|
+
borderBottom: `1px solid ${BORDER}`,
|
|
14263
|
+
position: "sticky",
|
|
14264
|
+
top: 0,
|
|
14265
|
+
background: "var(--card-muted-bg-color, var(--card-bg-color, inherit))",
|
|
14266
|
+
zIndex: 2
|
|
14267
|
+
},
|
|
14268
|
+
children: cols.map(({ column, width }, index) => {
|
|
14269
|
+
let active = sort.key === column.key, Arrow = sort.direction === "asc" ? ChevronUpIcon : ChevronDownIcon, alignEnd = column.kind === "number", cell = /* @__PURE__ */ jsxs(Box, {
|
|
14270
|
+
paddingRight: 2,
|
|
14271
|
+
onDragOver: (e) => {
|
|
14272
|
+
dragKeyRef.current && dragKeyRef.current !== column.key && (e.preventDefault(), setDragOverKey(column.key));
|
|
14273
|
+
},
|
|
14274
|
+
onDrop: () => onReorder(column.key),
|
|
14275
|
+
style: {
|
|
14276
|
+
width,
|
|
14277
|
+
flex: "none",
|
|
14278
|
+
position: "relative",
|
|
14279
|
+
boxSizing: "border-box",
|
|
14280
|
+
borderLeft: dragOverKey === column.key ? "2px solid var(--card-focus-ring-color, #2276fc)" : "2px solid transparent"
|
|
14281
|
+
},
|
|
14282
|
+
children: [/* @__PURE__ */ jsxs(Flex, {
|
|
14283
|
+
align: "center",
|
|
14284
|
+
gap: 1,
|
|
14285
|
+
justify: alignEnd ? "flex-end" : "flex-start",
|
|
14286
|
+
draggable: !0,
|
|
14287
|
+
onDragStart: () => {
|
|
14288
|
+
dragKeyRef.current = column.key;
|
|
14289
|
+
},
|
|
14290
|
+
onDragEnd: () => {
|
|
14291
|
+
dragKeyRef.current = null, setDragOverKey(null);
|
|
14292
|
+
},
|
|
14293
|
+
onClick: () => onSort(column.key),
|
|
14294
|
+
style: {
|
|
14295
|
+
cursor: "grab",
|
|
14296
|
+
userSelect: "none"
|
|
14297
|
+
},
|
|
14298
|
+
title: `Sort by ${column.label.toLowerCase()} — drag to reorder`,
|
|
14299
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
14300
|
+
size: 1,
|
|
14301
|
+
weight: "semibold",
|
|
14302
|
+
muted: !active,
|
|
14303
|
+
textOverflow: "ellipsis",
|
|
14304
|
+
children: column.label
|
|
14305
|
+
}), active && /* @__PURE__ */ jsx(Arrow, { style: {
|
|
14306
|
+
fontSize: 14,
|
|
14307
|
+
opacity: .7,
|
|
14308
|
+
flex: "none"
|
|
14309
|
+
} })]
|
|
14310
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
14311
|
+
onPointerDown: onResizeStart(column.key, width),
|
|
14312
|
+
title: "Drag to resize",
|
|
14313
|
+
style: {
|
|
14314
|
+
position: "absolute",
|
|
14315
|
+
top: 0,
|
|
14316
|
+
right: 0,
|
|
14317
|
+
width: 9,
|
|
14318
|
+
height: "100%",
|
|
14319
|
+
cursor: "col-resize",
|
|
14320
|
+
touchAction: "none"
|
|
14321
|
+
}
|
|
14322
|
+
})]
|
|
14323
|
+
}, column.key);
|
|
14324
|
+
return index === 0 ? [cell, statusHeader] : cell;
|
|
14325
|
+
})
|
|
14326
|
+
}), /* @__PURE__ */ jsxs(Box, {
|
|
14327
|
+
className: "ncf-coll-body",
|
|
14328
|
+
children: [visible.map((row) => /* @__PURE__ */ jsx(ChildLink, {
|
|
14329
|
+
childId: row.id,
|
|
14330
|
+
children: /* @__PURE__ */ jsx(TableRowView, {
|
|
14331
|
+
row,
|
|
14332
|
+
cols,
|
|
14333
|
+
Icon: TypeIcon
|
|
14334
|
+
})
|
|
14335
|
+
}, row.id)), visible.length === 0 && /* @__PURE__ */ jsx(Box, {
|
|
14336
|
+
padding: 5,
|
|
14337
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
14338
|
+
size: 1,
|
|
14339
|
+
muted: !0,
|
|
14340
|
+
align: "center",
|
|
14341
|
+
children: rows.length === 0 ? "No item yet." : "No match."
|
|
14342
|
+
})
|
|
14343
|
+
})]
|
|
14344
|
+
})]
|
|
14345
|
+
})]
|
|
14346
|
+
})
|
|
14347
|
+
]
|
|
14076
14348
|
});
|
|
14077
14349
|
}
|
|
14078
14350
|
/** Ligne de la vue TABLE : une cellule par colonne, largeurs fixes. */
|
|
@@ -14090,8 +14362,7 @@ function TableRowView(props) {
|
|
|
14090
14362
|
background: hovered ? "var(--card-muted-bg-color, rgba(127,127,127,0.08))" : "transparent"
|
|
14091
14363
|
},
|
|
14092
14364
|
children: cols.map(({ column, width }, index) => {
|
|
14093
|
-
let cell = row.cells[column.key], empty = !cell || cell.raw === null || cell.text === "", first = index === 0, alignEnd = column.kind === "number"
|
|
14094
|
-
return /* @__PURE__ */ jsxs(Flex, {
|
|
14365
|
+
let cell = row.cells[column.key], empty = !cell || cell.raw === null || cell.text === "", first = index === 0, alignEnd = column.kind === "number", content = /* @__PURE__ */ jsxs(Flex, {
|
|
14095
14366
|
align: "center",
|
|
14096
14367
|
gap: 2,
|
|
14097
14368
|
paddingRight: 2,
|
|
@@ -14101,36 +14372,43 @@ function TableRowView(props) {
|
|
|
14101
14372
|
flex: "none",
|
|
14102
14373
|
boxSizing: "border-box"
|
|
14103
14374
|
},
|
|
14104
|
-
children: [
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
children: empty ? "—" : cell.text
|
|
14125
|
-
}),
|
|
14126
|
-
first && row.draftOnly && /* @__PURE__ */ jsx(Badge, {
|
|
14127
|
-
tone: "caution",
|
|
14128
|
-
fontSize: 0,
|
|
14129
|
-
style: { flex: "none" },
|
|
14130
|
-
children: "Draft"
|
|
14131
|
-
})
|
|
14132
|
-
]
|
|
14375
|
+
children: [first && /* @__PURE__ */ jsx(Text, {
|
|
14376
|
+
size: 1,
|
|
14377
|
+
muted: !0,
|
|
14378
|
+
style: {
|
|
14379
|
+
flex: "none",
|
|
14380
|
+
display: "flex"
|
|
14381
|
+
},
|
|
14382
|
+
children: jsx(Icon || DocumentIcon, {})
|
|
14383
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
14384
|
+
size: 1,
|
|
14385
|
+
muted: empty,
|
|
14386
|
+
weight: first ? "medium" : "regular",
|
|
14387
|
+
textOverflow: "ellipsis",
|
|
14388
|
+
style: {
|
|
14389
|
+
flex: alignEnd ? "none" : 1,
|
|
14390
|
+
minWidth: 0,
|
|
14391
|
+
...column.kind === "number" || column.kind === "date" ? TABULAR : null
|
|
14392
|
+
},
|
|
14393
|
+
children: empty ? "" : cell.text
|
|
14394
|
+
})]
|
|
14133
14395
|
}, column.key);
|
|
14396
|
+
return first ? [content, /* @__PURE__ */ jsx(Flex, {
|
|
14397
|
+
align: "center",
|
|
14398
|
+
paddingRight: 2,
|
|
14399
|
+
style: {
|
|
14400
|
+
width: 230,
|
|
14401
|
+
flex: "none",
|
|
14402
|
+
boxSizing: "border-box"
|
|
14403
|
+
},
|
|
14404
|
+
children: /* @__PURE__ */ jsx(StatusBadge, {
|
|
14405
|
+
status: row.status,
|
|
14406
|
+
scheduledAt: row.scheduledAt,
|
|
14407
|
+
live: row.live,
|
|
14408
|
+
hasDraft: row.hasDraft,
|
|
14409
|
+
showDate: !0
|
|
14410
|
+
})
|
|
14411
|
+
}, STATUS_KEY)] : content;
|
|
14134
14412
|
})
|
|
14135
14413
|
});
|
|
14136
14414
|
}
|
|
@@ -14182,7 +14460,13 @@ function ListRowView(props) {
|
|
|
14182
14460
|
children: subtitle
|
|
14183
14461
|
}) : null]
|
|
14184
14462
|
}),
|
|
14185
|
-
/* @__PURE__ */ jsx(
|
|
14463
|
+
/* @__PURE__ */ jsx(StatusBadge, {
|
|
14464
|
+
status: row.status,
|
|
14465
|
+
scheduledAt: row.scheduledAt,
|
|
14466
|
+
live: row.live,
|
|
14467
|
+
hasDraft: row.hasDraft,
|
|
14468
|
+
showDate: !0
|
|
14469
|
+
})
|
|
14186
14470
|
]
|
|
14187
14471
|
});
|
|
14188
14472
|
}
|