@nocode-factory/sanity-kit 2.51.1 → 2.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/index.d.ts +35 -4
- package/dist/index.js +679 -106
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/form/AssetSourceBrowser.tsx +110 -0
- package/src/hooks/useAssetDelete.ts +60 -0
- package/src/hooks/useAssetUpload.ts +46 -0
- package/src/hooks/useBoardLayout.ts +25 -1
- package/src/index.ts +26 -1
- package/src/lib/assetRefs.ts +53 -0
- package/src/lib/i18nTemplates.ts +40 -0
- package/src/lib/pageOrder.ts +36 -0
- package/src/lib/pages.ts +11 -1
- package/src/schema/boardLayout.ts +7 -0
- package/src/tools/assets/AssetCard.tsx +8 -10
- package/src/tools/assets/AssetDetail.tsx +97 -2
- package/src/tools/assets/AssetsTool.tsx +90 -13
- package/src/tools/assets/AssetsToolbar.tsx +17 -0
- package/src/tools/pages/PagesTool.tsx +15 -9
- package/src/tools/presentation/PagesNavigator.tsx +51 -6
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -44,11 +44,13 @@ import { UndoIcon } from "@sanity/icons/Undo";
|
|
|
44
44
|
import { FolderIcon } from "@sanity/icons/Folder";
|
|
45
45
|
import { ThLargeIcon } from "@sanity/icons/ThLarge";
|
|
46
46
|
import { ThListIcon } from "@sanity/icons/ThList";
|
|
47
|
+
import { UploadIcon } from "@sanity/icons/Upload";
|
|
47
48
|
import { DocumentIcon } from "@sanity/icons/Document";
|
|
48
49
|
import { Tooltip } from "@sanity/ui/tooltip";
|
|
49
50
|
import { EyeClosedIcon } from "@sanity/icons/EyeClosed";
|
|
50
51
|
import { usePresentationNavigate, usePresentationParams } from "sanity/presentation";
|
|
51
52
|
import { useToast } from "@sanity/ui/toast";
|
|
53
|
+
import { DragHandleIcon } from "@sanity/icons/DragHandle";
|
|
52
54
|
import { createPortal } from "react-dom";
|
|
53
55
|
import { TabletDeviceIcon } from "@sanity/icons/TabletDevice";
|
|
54
56
|
import { PanelRightIcon } from "@sanity/icons/PanelRight";
|
|
@@ -565,6 +567,12 @@ const TRANSLATION_TODO_TYPE = "ncfTranslationTodo", translationTodoId = (documen
|
|
|
565
567
|
type: "array",
|
|
566
568
|
of: [{ type: SECTION_NODE_TYPE }]
|
|
567
569
|
}),
|
|
570
|
+
defineField({
|
|
571
|
+
name: "pageOrder",
|
|
572
|
+
title: "Manual page order",
|
|
573
|
+
type: "array",
|
|
574
|
+
of: [{ type: "string" }]
|
|
575
|
+
}),
|
|
568
576
|
defineField({
|
|
569
577
|
name: "updatedBy",
|
|
570
578
|
title: "Modified by",
|
|
@@ -844,10 +852,10 @@ const fieldsFromStored = (stored) => {
|
|
|
844
852
|
* instance fournie par `BoardLayoutProvider`.
|
|
845
853
|
*/
|
|
846
854
|
function useBoardLayoutState() {
|
|
847
|
-
let client = useKitClient(), user = useCurrentUser(), [layout, setLayout] = useState([]), [sections, setSections] = useState([]), [columns, setColumns] = useState([]), [columnsSet, setColumnsSet] = useState(!1), [annotations, setAnnotations] = useState([]), [loading, setLoading] = useState(!0), [saveError, setSaveError] = useState(null);
|
|
855
|
+
let client = useKitClient(), user = useCurrentUser(), [layout, setLayout] = useState([]), [sections, setSections] = useState([]), [columns, setColumns] = useState([]), [columnsSet, setColumnsSet] = useState(!1), [annotations, setAnnotations] = useState([]), [pageOrder, setPageOrder] = useState([]), [loading, setLoading] = useState(!0), [saveError, setSaveError] = useState(null);
|
|
848
856
|
useEffect(() => {
|
|
849
857
|
let cancelled = !1;
|
|
850
|
-
return client.fetch("*[_id == $id][0]{nodes, sections, columns, columnsSet, annotations}", { id: BOARD_LAYOUT_ID }).then((doc) => {
|
|
858
|
+
return client.fetch("*[_id == $id][0]{nodes, sections, columns, columnsSet, annotations, pageOrder}", { id: BOARD_LAYOUT_ID }).then((doc) => {
|
|
851
859
|
cancelled || (setLayout(clean(doc?.nodes ?? [])), setSections((doc?.sections ?? []).map(({ blockName, x, y }) => ({
|
|
852
860
|
blockName,
|
|
853
861
|
x,
|
|
@@ -861,9 +869,9 @@ function useBoardLayoutState() {
|
|
|
861
869
|
label: ol,
|
|
862
870
|
...color ? { color } : {}
|
|
863
871
|
})) } : {}
|
|
864
|
-
}))), setColumnsSet(!!doc?.columnsSet), setAnnotations((doc?.annotations ?? []).map(({ _key, ...rest }) => ({ ...rest }))));
|
|
872
|
+
}))), setColumnsSet(!!doc?.columnsSet), setAnnotations((doc?.annotations ?? []).map(({ _key, ...rest }) => ({ ...rest }))), setPageOrder(Array.isArray(doc?.pageOrder) ? doc.pageOrder.filter((id) => typeof id == "string") : []));
|
|
865
873
|
}).catch(() => {
|
|
866
|
-
cancelled || (setLayout([]), setSections([]), setColumns([]), setColumnsSet(!1), setAnnotations([]));
|
|
874
|
+
cancelled || (setLayout([]), setSections([]), setColumns([]), setColumnsSet(!1), setAnnotations([]), setPageOrder([]));
|
|
867
875
|
}).finally(() => {
|
|
868
876
|
cancelled || setLoading(!1);
|
|
869
877
|
}), () => {
|
|
@@ -874,10 +882,10 @@ function useBoardLayoutState() {
|
|
|
874
882
|
useEffect(() => () => {
|
|
875
883
|
timer.current && clearTimeout(timer.current);
|
|
876
884
|
}, []);
|
|
877
|
-
let layoutRef = useRef([]), sectionsRef = useRef([]), columnsRef = useRef([]), columnsSetRef = useRef(!1), annotationsRef = useRef([]);
|
|
878
|
-
layoutRef.current = layout, sectionsRef.current = sections, columnsRef.current = columns, columnsSetRef.current = columnsSet, annotationsRef.current = annotations;
|
|
885
|
+
let layoutRef = useRef([]), sectionsRef = useRef([]), columnsRef = useRef([]), columnsSetRef = useRef(!1), annotationsRef = useRef([]), pageOrderRef = useRef([]);
|
|
886
|
+
layoutRef.current = layout, sectionsRef.current = sections, columnsRef.current = columns, columnsSetRef.current = columnsSet, annotationsRef.current = annotations, pageOrderRef.current = pageOrder;
|
|
879
887
|
let write = useCallback((next) => {
|
|
880
|
-
let nodes = next?.nodes ?? layoutRef.current, nextSections = next?.sections ?? sectionsRef.current, nextColumns = next?.columns ?? columnsRef.current, nextColumnsSet = next?.columnsSet ?? columnsSetRef.current, nextAnnotations = next?.annotations ?? annotationsRef.current;
|
|
888
|
+
let nodes = next?.nodes ?? layoutRef.current, nextSections = next?.sections ?? sectionsRef.current, nextColumns = next?.columns ?? columnsRef.current, nextColumnsSet = next?.columnsSet ?? columnsSetRef.current, nextAnnotations = next?.annotations ?? annotationsRef.current, nextPageOrder = next?.pageOrder ?? pageOrderRef.current;
|
|
881
889
|
client.createOrReplace({
|
|
882
890
|
_id: BOARD_LAYOUT_ID,
|
|
883
891
|
_type: BOARD_LAYOUT_TYPE,
|
|
@@ -908,6 +916,7 @@ function useBoardLayoutState() {
|
|
|
908
916
|
}))
|
|
909
917
|
})),
|
|
910
918
|
columnsSet: nextColumnsSet,
|
|
919
|
+
pageOrder: nextPageOrder,
|
|
911
920
|
annotations: nextAnnotations.map((annotation) => ({
|
|
912
921
|
_key: annotation.id,
|
|
913
922
|
_type: "ncfAnnotation",
|
|
@@ -962,6 +971,9 @@ function useBoardLayoutState() {
|
|
|
962
971
|
setAnnotations(value), timer.current && clearTimeout(timer.current), timer.current = setTimeout(() => write({ annotations: value }), 800);
|
|
963
972
|
}, [write]), resetSections = useCallback(() => {
|
|
964
973
|
timer.current && clearTimeout(timer.current), setSections([]), write({ sections: [] });
|
|
974
|
+
}, [write]), savePageOrder = useCallback((ids) => {
|
|
975
|
+
let value = [...ids];
|
|
976
|
+
setPageOrder(value), timer.current && clearTimeout(timer.current), timer.current = setTimeout(() => write({ pageOrder: value }), 800);
|
|
965
977
|
}, [write]), sectionsByName = useMemo(() => new Map(sections.map((entry) => [entry.blockName, entry])), [sections]);
|
|
966
978
|
return {
|
|
967
979
|
layout,
|
|
@@ -979,6 +991,8 @@ function useBoardLayoutState() {
|
|
|
979
991
|
saveColumns,
|
|
980
992
|
annotations,
|
|
981
993
|
saveAnnotations,
|
|
994
|
+
pageOrder,
|
|
995
|
+
savePageOrder,
|
|
982
996
|
reset,
|
|
983
997
|
resetSections
|
|
984
998
|
};
|
|
@@ -1406,7 +1420,7 @@ function explainGrantError(error) {
|
|
|
1406
1420
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1407
1421
|
* le vérifie.
|
|
1408
1422
|
*/
|
|
1409
|
-
const KIT_VERSION = "2.
|
|
1423
|
+
const KIT_VERSION = "2.53.0";
|
|
1410
1424
|
/**
|
|
1411
1425
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1412
1426
|
*
|
|
@@ -1904,7 +1918,7 @@ function useKitUpdate() {
|
|
|
1904
1918
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1905
1919
|
}).catch(() => {}), () => controller.abort();
|
|
1906
1920
|
}, []);
|
|
1907
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.
|
|
1921
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.53.0") > 0);
|
|
1908
1922
|
return {
|
|
1909
1923
|
current: KIT_VERSION,
|
|
1910
1924
|
latest,
|
|
@@ -2462,6 +2476,39 @@ function buildContentsQuery(config, limit) {
|
|
|
2462
2476
|
].join("\n");
|
|
2463
2477
|
}
|
|
2464
2478
|
/**
|
|
2479
|
+
* Ordre manuel des pages, partagé par le navigateur de Presentation et l'onglet
|
|
2480
|
+
* Pages. Stocké comme une liste d'ids (board singleton `pageOrder`). Pur.
|
|
2481
|
+
*/
|
|
2482
|
+
/**
|
|
2483
|
+
* Ordonne des éléments par la liste d'ids `order` : ceux présents d'abord (dans
|
|
2484
|
+
* l'ordre de `order`), les autres ensuite dans leur ordre d'entrée (donc une
|
|
2485
|
+
* page nouvelle, absente de l'ordre manuel, apparaît à la fin).
|
|
2486
|
+
*/
|
|
2487
|
+
function orderByIds(items, order) {
|
|
2488
|
+
if (order.length === 0) return [...items];
|
|
2489
|
+
let rank = new Map(order.map((id, index) => [id, index]));
|
|
2490
|
+
return [...items].sort((a, b) => {
|
|
2491
|
+
let ra = rank.get(a.id), rb = rank.get(b.id);
|
|
2492
|
+
return ra === void 0 && rb === void 0 ? 0 : ra === void 0 ? 1 : rb === void 0 ? -1 : ra - rb;
|
|
2493
|
+
});
|
|
2494
|
+
}
|
|
2495
|
+
/**
|
|
2496
|
+
* Déplace `dragged` juste avant `target` dans la séquence d'ids `ordered`
|
|
2497
|
+
* (l'ordre courant complet). `target` null = place en fin. Filtre-sûr : on
|
|
2498
|
+
* travaille sur les ids, pas sur une vue filtrée.
|
|
2499
|
+
*/
|
|
2500
|
+
function reorderBefore(ordered, dragged, target) {
|
|
2501
|
+
if (dragged === target) return [...ordered];
|
|
2502
|
+
let without = ordered.filter((id) => id !== dragged);
|
|
2503
|
+
if (target === null) return [...without, dragged];
|
|
2504
|
+
let index = without.indexOf(target);
|
|
2505
|
+
return index < 0 ? [...without, dragged] : [
|
|
2506
|
+
...without.slice(0, index),
|
|
2507
|
+
dragged,
|
|
2508
|
+
...without.slice(index)
|
|
2509
|
+
];
|
|
2510
|
+
}
|
|
2511
|
+
/**
|
|
2465
2512
|
* Met une valeur du document en forme pour une cellule.
|
|
2466
2513
|
*
|
|
2467
2514
|
* Ce qui ne tient pas sur une ligne — un objet, un tableau de sections — n'est
|
|
@@ -2515,6 +2562,10 @@ const STATUS_ORDER = {
|
|
|
2515
2562
|
}
|
|
2516
2563
|
};
|
|
2517
2564
|
function sortRows(rows, key, direction, options = {}) {
|
|
2565
|
+
if (key === "manual") {
|
|
2566
|
+
let sorted = orderByIds([...rows].sort((a, b) => a.title.localeCompare(b.title, void 0, { sensitivity: "base" })), options.pageOrder ?? []);
|
|
2567
|
+
return direction === "asc" ? sorted : sorted.reverse();
|
|
2568
|
+
}
|
|
2518
2569
|
let sorted = [...rows].sort((a, b) => compare(a, b, key, options));
|
|
2519
2570
|
return direction === "asc" ? sorted : sorted.reverse();
|
|
2520
2571
|
}
|
|
@@ -3277,7 +3328,7 @@ const VALUE_TYPE_NAMES = /* @__PURE__ */ new Set([
|
|
|
3277
3328
|
"datetime",
|
|
3278
3329
|
"number",
|
|
3279
3330
|
"boolean"
|
|
3280
|
-
]), SKIP_KEYS = /* @__PURE__ */ new Set(["language", "slug"]), isObj$
|
|
3331
|
+
]), SKIP_KEYS = /* @__PURE__ */ new Set(["language", "slug"]), isObj$2 = (v) => typeof v == "object" && !!v && !Array.isArray(v), same$2 = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null), keyed$1 = (v) => Array.isArray(v) && v.length > 0 && v.every((i) => isObj$2(i) && typeof i._key == "string");
|
|
3281
3332
|
function typeNames(t) {
|
|
3282
3333
|
let out = [];
|
|
3283
3334
|
for (let c = t; c; c = c.type) c.name && out.push(c.name);
|
|
@@ -3297,7 +3348,7 @@ function kindOf(t, value) {
|
|
|
3297
3348
|
}
|
|
3298
3349
|
return t.jsonType === "object" ? "object" : t.jsonType === "string" ? t.options?.list?.length ? "value" : "text" : "value";
|
|
3299
3350
|
}
|
|
3300
|
-
return keyed$1(value) ? "list" : isObj$
|
|
3351
|
+
return keyed$1(value) ? "list" : isObj$2(value) ? "object" : "value";
|
|
3301
3352
|
}
|
|
3302
3353
|
function fieldType(t, name) {
|
|
3303
3354
|
for (let c = t; c; c = c.type) {
|
|
@@ -3314,8 +3365,8 @@ function itemType(t, item) {
|
|
|
3314
3365
|
function collectTexts(value, t, path, acc) {
|
|
3315
3366
|
let kind = kindOf(t, value);
|
|
3316
3367
|
if (kind === "text") value != null && value !== "" && acc.toTranslate.push(path);
|
|
3317
|
-
else if (kind === "object" && isObj$
|
|
3318
|
-
else if (kind === "list" && Array.isArray(value)) for (let item of value) isObj$
|
|
3368
|
+
else if (kind === "object" && isObj$2(value)) for (let [k, v] of Object.entries(value)) k.startsWith("_") || collectTexts(v, fieldType(t, k), `${path}.${k}`, acc);
|
|
3369
|
+
else if (kind === "list" && Array.isArray(value)) for (let item of value) isObj$2(item) && collectTexts(item, itemType(t, item), `${path}[${String(item._key)}]`, acc);
|
|
3319
3370
|
}
|
|
3320
3371
|
const ABSENT$1 = Symbol("absent");
|
|
3321
3372
|
function merge(target, before, after, t, path, acc) {
|
|
@@ -3324,8 +3375,8 @@ function merge(target, before, after, t, path, acc) {
|
|
|
3324
3375
|
if (kind === "text") return after == null || after === "" ? (target != null && target !== "" && acc.toTranslate.push(path), target === void 0 ? ABSENT$1 : target) : (acc.toTranslate.push(path), target == null || target === "" || same$2(target, before) ? after : target);
|
|
3325
3376
|
if (kind === "value") return acc.copied.push(path), after === void 0 ? ABSENT$1 : after;
|
|
3326
3377
|
if (kind === "object") {
|
|
3327
|
-
if (!isObj$
|
|
3328
|
-
let base = isObj$
|
|
3378
|
+
if (!isObj$2(after)) return acc.copied.push(path), after === void 0 ? ABSENT$1 : after;
|
|
3379
|
+
let base = isObj$2(target) ? { ...target } : { _type: after._type }, b = isObj$2(before) ? before : {};
|
|
3329
3380
|
for (let k of /* @__PURE__ */ new Set([...Object.keys(b), ...Object.keys(after)])) {
|
|
3330
3381
|
if (k.startsWith("_") || SKIP_KEYS.has(k)) continue;
|
|
3331
3382
|
let v = merge(base[k], b[k], after[k], fieldType(t, k), path ? `${path}.${k}` : k, acc);
|
|
@@ -3333,7 +3384,7 @@ function merge(target, before, after, t, path, acc) {
|
|
|
3333
3384
|
}
|
|
3334
3385
|
return base;
|
|
3335
3386
|
}
|
|
3336
|
-
let tgt = Array.isArray(target) ? target.filter(isObj$
|
|
3387
|
+
let tgt = Array.isArray(target) ? target.filter(isObj$2) : [], bef = Array.isArray(before) ? before.filter(isObj$2) : [], aft = Array.isArray(after) ? after.filter(isObj$2) : [], byKey = (list) => new Map(list.map((i) => [i._key, i])), tMap = byKey(tgt), bMap = byKey(bef), aMap = byKey(aft), result = [];
|
|
3337
3388
|
for (let item of aft) {
|
|
3338
3389
|
let key = item._key, it = itemType(t, item);
|
|
3339
3390
|
if (tMap.has(key)) {
|
|
@@ -3367,7 +3418,7 @@ function propagate(target, before, after, documentType) {
|
|
|
3367
3418
|
return {
|
|
3368
3419
|
document: {
|
|
3369
3420
|
...target ?? {},
|
|
3370
|
-
...isObj$
|
|
3421
|
+
...isObj$2(merged) ? merged : {}
|
|
3371
3422
|
},
|
|
3372
3423
|
...acc
|
|
3373
3424
|
};
|
|
@@ -6375,23 +6426,27 @@ function BoardView(props) {
|
|
|
6375
6426
|
return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(Board, { ...props }) });
|
|
6376
6427
|
}
|
|
6377
6428
|
function PagesTool() {
|
|
6378
|
-
let config = useKitConfig(), router = useRouter(), { byId, saveColumns, patchNode, patchField } = 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(
|
|
6429
|
+
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) => {
|
|
6379
6430
|
setShownData((current) => {
|
|
6380
6431
|
let next = new Set(current);
|
|
6381
6432
|
return next.has(key) ? next.delete(key) : next.add(key), next;
|
|
6382
6433
|
});
|
|
6383
|
-
}, []), 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]), visible = useMemo(() => sortRows(filterRows(rows, {
|
|
6434
|
+
}, []), 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(filterRows(rows, {
|
|
6384
6435
|
search,
|
|
6385
6436
|
locales: locale ? [locale] : void 0
|
|
6386
|
-
}).filter((row) => !onlyTodo || todos.has(row.id)),
|
|
6437
|
+
}).filter((row) => !onlyTodo || todos.has(row.id)), effectiveSortKey, sortDirection, {
|
|
6438
|
+
typeOrder: config.pageTypeNames,
|
|
6439
|
+
pageOrder
|
|
6440
|
+
}), [
|
|
6387
6441
|
rows,
|
|
6388
6442
|
search,
|
|
6389
6443
|
locale,
|
|
6390
6444
|
onlyTodo,
|
|
6391
6445
|
todos,
|
|
6392
|
-
|
|
6446
|
+
effectiveSortKey,
|
|
6393
6447
|
sortDirection,
|
|
6394
|
-
config.pageTypeNames
|
|
6448
|
+
config.pageTypeNames,
|
|
6449
|
+
pageOrder
|
|
6395
6450
|
]), 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, {
|
|
6396
6451
|
meta: byId,
|
|
6397
6452
|
tags: config.boardTags,
|
|
@@ -6412,7 +6467,7 @@ function PagesTool() {
|
|
|
6412
6467
|
let next = new Set(current);
|
|
6413
6468
|
return next.has(key) ? next.delete(key) : next.add(key), next;
|
|
6414
6469
|
}), onSort = (key) => {
|
|
6415
|
-
key ===
|
|
6470
|
+
key === effectiveSortKey ? setSortDirection((d) => d === "asc" ? "desc" : "asc") : (setSortKey(key), setSortDirection("asc")), setPage(0);
|
|
6416
6471
|
};
|
|
6417
6472
|
if (error) return /* @__PURE__ */ jsx(QueryError, {
|
|
6418
6473
|
error,
|
|
@@ -6631,7 +6686,7 @@ function PagesTool() {
|
|
|
6631
6686
|
})
|
|
6632
6687
|
}) : /* @__PURE__ */ jsx(PagesTable, {
|
|
6633
6688
|
groups,
|
|
6634
|
-
sortKey,
|
|
6689
|
+
sortKey: effectiveSortKey,
|
|
6635
6690
|
sortDirection,
|
|
6636
6691
|
onSort,
|
|
6637
6692
|
columns,
|
|
@@ -9043,6 +9098,34 @@ function useAssetMeta() {
|
|
|
9043
9098
|
moveAssets
|
|
9044
9099
|
};
|
|
9045
9100
|
}
|
|
9101
|
+
/** Détermine le type d'asset Sanity d'après le fichier. */
|
|
9102
|
+
const assetKind = (file) => file.type.startsWith("image/") ? "image" : "file";
|
|
9103
|
+
/**
|
|
9104
|
+
* Téléverse des assets dans le dataset depuis l'outil Assets
|
|
9105
|
+
* (`client.assets.upload`). La liste se met à jour toute seule (écoute des
|
|
9106
|
+
* mutations d'assets) ; `onUploaded` permet de ranger l'asset dans un dossier.
|
|
9107
|
+
*/
|
|
9108
|
+
function useAssetUpload() {
|
|
9109
|
+
let client = useKitClient(), [uploading, setUploading] = useState(0), [error, setError] = useState(null);
|
|
9110
|
+
return {
|
|
9111
|
+
upload: useCallback(async (files, onUploaded) => {
|
|
9112
|
+
let list = Array.from(files);
|
|
9113
|
+
if (list.length) {
|
|
9114
|
+
setError(null), setUploading((count) => count + list.length);
|
|
9115
|
+
for (let file of list) try {
|
|
9116
|
+
let asset = await client.assets.upload(assetKind(file), file, { filename: file.name });
|
|
9117
|
+
onUploaded?.(asset._id);
|
|
9118
|
+
} catch (cause) {
|
|
9119
|
+
setError(cause instanceof Error ? cause : Error(String(cause)));
|
|
9120
|
+
} finally {
|
|
9121
|
+
setUploading((count) => Math.max(0, count - 1));
|
|
9122
|
+
}
|
|
9123
|
+
}
|
|
9124
|
+
}, [client]),
|
|
9125
|
+
uploading,
|
|
9126
|
+
error
|
|
9127
|
+
};
|
|
9128
|
+
}
|
|
9046
9129
|
const isImageAsset = (asset) => asset._type === "sanity.imageAsset";
|
|
9047
9130
|
/** Nom affiché : titre saisi, sinon nom de fichier, sinon id. */
|
|
9048
9131
|
function assetName(asset) {
|
|
@@ -9318,6 +9401,16 @@ function AssetsToolbar(props) {
|
|
|
9318
9401
|
align: "center",
|
|
9319
9402
|
wrap: "wrap",
|
|
9320
9403
|
children: [
|
|
9404
|
+
props.onImport ? /* @__PURE__ */ jsx(Button, {
|
|
9405
|
+
icon: UploadIcon,
|
|
9406
|
+
text: props.uploading ? `Import… (${props.uploading})` : "Importer",
|
|
9407
|
+
tone: "primary",
|
|
9408
|
+
fontSize: 1,
|
|
9409
|
+
padding: 2,
|
|
9410
|
+
disabled: !!props.uploading,
|
|
9411
|
+
onClick: props.onImport,
|
|
9412
|
+
style: { flex: "none" }
|
|
9413
|
+
}) : null,
|
|
9321
9414
|
/* @__PURE__ */ jsx(Box, {
|
|
9322
9415
|
flex: 1,
|
|
9323
9416
|
style: { minWidth: 180 },
|
|
@@ -9458,10 +9551,7 @@ function AssetsToolbar(props) {
|
|
|
9458
9551
|
}
|
|
9459
9552
|
/** Tuile d'un asset dans la grille : aperçu, nom, taille, type, usage. */
|
|
9460
9553
|
function AssetCard(props) {
|
|
9461
|
-
let { asset, selected, onToggleSelect, onOpen } = props, [failed, setFailed] = useState(!1), thumb = thumbnailUrl(asset, {
|
|
9462
|
-
w: 320,
|
|
9463
|
-
h: 220
|
|
9464
|
-
}), unused = asset.uses === 0, meta = [
|
|
9554
|
+
let { asset, selected, onToggleSelect, onOpen } = props, [failed, setFailed] = useState(!1), thumb = thumbnailUrl(asset, { w: 500 }), unused = asset.uses === 0, natural = asset.dimensions?.width && asset.dimensions?.height ? asset.dimensions.width / asset.dimensions.height : 4 / 3, ratio = thumb ? Math.min(2, Math.max(.56, natural)) : 4 / 3, meta = [
|
|
9465
9555
|
formatBytes(asset.size),
|
|
9466
9556
|
asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : null,
|
|
9467
9557
|
asset.extension?.toUpperCase()
|
|
@@ -9472,9 +9562,9 @@ function AssetCard(props) {
|
|
|
9472
9562
|
padding: 0,
|
|
9473
9563
|
tone: selected ? "primary" : "default",
|
|
9474
9564
|
style: {
|
|
9475
|
-
height: "100%",
|
|
9476
9565
|
overflow: "hidden",
|
|
9477
|
-
position: "relative"
|
|
9566
|
+
position: "relative",
|
|
9567
|
+
width: "100%"
|
|
9478
9568
|
},
|
|
9479
9569
|
children: [/* @__PURE__ */ jsx(Box, {
|
|
9480
9570
|
style: {
|
|
@@ -9500,7 +9590,6 @@ function AssetCard(props) {
|
|
|
9500
9590
|
as: "button",
|
|
9501
9591
|
onClick: onOpen,
|
|
9502
9592
|
style: {
|
|
9503
|
-
height: "100%",
|
|
9504
9593
|
width: "100%",
|
|
9505
9594
|
textAlign: "left",
|
|
9506
9595
|
cursor: "pointer",
|
|
@@ -9510,7 +9599,7 @@ function AssetCard(props) {
|
|
|
9510
9599
|
},
|
|
9511
9600
|
children: [/* @__PURE__ */ jsx(Box, {
|
|
9512
9601
|
style: {
|
|
9513
|
-
aspectRatio:
|
|
9602
|
+
aspectRatio: ratio,
|
|
9514
9603
|
overflow: "hidden",
|
|
9515
9604
|
background: "var(--card-muted-bg-color, rgba(127,127,127,0.08))"
|
|
9516
9605
|
},
|
|
@@ -9788,6 +9877,68 @@ function AssetTable(props) {
|
|
|
9788
9877
|
})
|
|
9789
9878
|
});
|
|
9790
9879
|
}
|
|
9880
|
+
const isObj$1 = (v) => typeof v == "object" && !!v && !Array.isArray(v);
|
|
9881
|
+
/** Chemins (segments) des objets du document qui pointent vers `assetId`. */
|
|
9882
|
+
function findAssetRefPaths(value, assetId, path = []) {
|
|
9883
|
+
let out = [], walk = (node, current) => {
|
|
9884
|
+
if (Array.isArray(node)) {
|
|
9885
|
+
node.forEach((item, index) => {
|
|
9886
|
+
let segment = isObj$1(item) && typeof item._key == "string" ? { _key: item._key } : index;
|
|
9887
|
+
walk(item, [...current, segment]);
|
|
9888
|
+
});
|
|
9889
|
+
return;
|
|
9890
|
+
}
|
|
9891
|
+
if (isObj$1(node)) {
|
|
9892
|
+
if ((isObj$1(node.asset) ? node.asset._ref : void 0) === assetId || node._type === "reference" && node._ref === assetId) {
|
|
9893
|
+
out.push(current);
|
|
9894
|
+
return;
|
|
9895
|
+
}
|
|
9896
|
+
for (let [key, child] of Object.entries(node)) key.startsWith("_") || walk(child, [...current, key]);
|
|
9897
|
+
}
|
|
9898
|
+
};
|
|
9899
|
+
return walk(value, path), out;
|
|
9900
|
+
}
|
|
9901
|
+
/** Chemin Sanity (`gallery[_key=="ab"].asset`) depuis des segments. */
|
|
9902
|
+
function toPatchPath(segments) {
|
|
9903
|
+
let out = "";
|
|
9904
|
+
for (let segment of segments) out += typeof segment == "string" ? out ? `.${segment}` : segment : typeof segment == "number" ? `[${segment}]` : `[_key=="${segment._key}"]`;
|
|
9905
|
+
return out;
|
|
9906
|
+
}
|
|
9907
|
+
/** Chemins Sanity (chaînes) à retirer d'un document pour en ôter l'asset. */
|
|
9908
|
+
function assetUnsetPaths(doc, assetId) {
|
|
9909
|
+
return findAssetRefPaths(doc, assetId).map(toPatchPath).filter(Boolean);
|
|
9910
|
+
}
|
|
9911
|
+
const baseId$1 = (id) => id.replace(/^drafts\./, "");
|
|
9912
|
+
/**
|
|
9913
|
+
* Suppression d'un asset depuis l'outil Assets. Sanity refuse de supprimer un
|
|
9914
|
+
* asset référencé : on retire d'abord l'asset de chaque document (le champ
|
|
9915
|
+
* devient vide), puis on supprime, dans une seule transaction.
|
|
9916
|
+
*/
|
|
9917
|
+
function useAssetDelete() {
|
|
9918
|
+
let client = useKitClient();
|
|
9919
|
+
return {
|
|
9920
|
+
usage: useCallback(async (assetId) => {
|
|
9921
|
+
let docs = await client.fetch("*[references($id)]{_id, _type, \"title\": coalesce(title, name, originalFilename, slug.current, _id)}", { id: assetId }), seen = /* @__PURE__ */ new Map();
|
|
9922
|
+
for (let doc of docs ?? []) {
|
|
9923
|
+
let id = baseId$1(doc._id);
|
|
9924
|
+
seen.has(id) || seen.set(id, {
|
|
9925
|
+
id,
|
|
9926
|
+
type: doc._type,
|
|
9927
|
+
title: doc.title ?? id
|
|
9928
|
+
});
|
|
9929
|
+
}
|
|
9930
|
+
return [...seen.values()];
|
|
9931
|
+
}, [client]),
|
|
9932
|
+
remove: useCallback(async (assetId) => {
|
|
9933
|
+
let docs = await client.fetch("*[references($id)]", { id: assetId }), transaction = client.transaction();
|
|
9934
|
+
for (let doc of docs ?? []) {
|
|
9935
|
+
let paths = assetUnsetPaths(doc, assetId);
|
|
9936
|
+
paths.length && transaction.patch(doc._id, { unset: paths });
|
|
9937
|
+
}
|
|
9938
|
+
transaction.delete(assetId), await transaction.commit({ visibility: "async" });
|
|
9939
|
+
}, [client])
|
|
9940
|
+
};
|
|
9941
|
+
}
|
|
9791
9942
|
function Metric(props) {
|
|
9792
9943
|
return /* @__PURE__ */ jsxs(Stack, {
|
|
9793
9944
|
gap: 2,
|
|
@@ -9804,7 +9955,13 @@ function Metric(props) {
|
|
|
9804
9955
|
});
|
|
9805
9956
|
}
|
|
9806
9957
|
function AssetDetail(props) {
|
|
9807
|
-
let { asset, folders, folder, onMove, onClose } = props, client = useKitClient(), [title, setTitle] = useState(asset.title ?? ""), [alt, setAlt] = useState(asset.altText ?? ""), [description, setDescription] = useState(asset.description ?? ""), [copied, setCopied] = useState(!1)
|
|
9958
|
+
let { asset, folders, folder, onMove, onClose, onDeleted } = props, client = useKitClient(), { usage, remove } = useAssetDelete(), [title, setTitle] = useState(asset.title ?? ""), [alt, setAlt] = useState(asset.altText ?? ""), [description, setDescription] = useState(asset.description ?? ""), [copied, setCopied] = useState(!1), [confirming, setConfirming] = useState(!1), [uses, setUses] = useState(null), [busy, setBusy] = useState(!1), [deleteError, setDeleteError] = useState(null), openDelete = () => {
|
|
9959
|
+
setConfirming(!0), setUses(null), setDeleteError(null), usage(asset._id).then((list) => setUses(list)).catch(() => setUses([]));
|
|
9960
|
+
}, doDelete = () => {
|
|
9961
|
+
setBusy(!0), setDeleteError(null), remove(asset._id).then(() => {
|
|
9962
|
+
setConfirming(!1), onDeleted?.(), onClose();
|
|
9963
|
+
}).catch((cause) => setDeleteError(cause instanceof Error ? cause.message : String(cause))).finally(() => setBusy(!1));
|
|
9964
|
+
};
|
|
9808
9965
|
useEffect(() => {
|
|
9809
9966
|
setTitle(asset.title ?? ""), setAlt(asset.altText ?? ""), setDescription(asset.description ?? "");
|
|
9810
9967
|
}, [
|
|
@@ -9823,7 +9980,7 @@ function AssetDetail(props) {
|
|
|
9823
9980
|
setCopied(!0), setTimeout(() => setCopied(!1), 1500);
|
|
9824
9981
|
});
|
|
9825
9982
|
};
|
|
9826
|
-
return /* @__PURE__ */
|
|
9983
|
+
return /* @__PURE__ */ jsxs(Card, {
|
|
9827
9984
|
borderLeft: !0,
|
|
9828
9985
|
height: "fill",
|
|
9829
9986
|
style: {
|
|
@@ -9832,7 +9989,7 @@ function AssetDetail(props) {
|
|
|
9832
9989
|
},
|
|
9833
9990
|
overflow: "auto",
|
|
9834
9991
|
tone: "transparent",
|
|
9835
|
-
children: /* @__PURE__ */ jsxs(Stack, {
|
|
9992
|
+
children: [/* @__PURE__ */ jsxs(Stack, {
|
|
9836
9993
|
gap: 4,
|
|
9837
9994
|
padding: 4,
|
|
9838
9995
|
children: [
|
|
@@ -9995,13 +10152,142 @@ function AssetDetail(props) {
|
|
|
9995
10152
|
value: formatDate(asset._createdAt)
|
|
9996
10153
|
})
|
|
9997
10154
|
]
|
|
10155
|
+
}),
|
|
10156
|
+
/* @__PURE__ */ jsx(Box, {
|
|
10157
|
+
style: { borderTop: "1px solid var(--card-border-color)" },
|
|
10158
|
+
paddingTop: 3,
|
|
10159
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
10160
|
+
icon: TrashIcon,
|
|
10161
|
+
text: "Supprimer le média",
|
|
10162
|
+
tone: "critical",
|
|
10163
|
+
mode: "ghost",
|
|
10164
|
+
fontSize: 1,
|
|
10165
|
+
onClick: openDelete,
|
|
10166
|
+
style: { width: "100%" }
|
|
10167
|
+
})
|
|
9998
10168
|
})
|
|
9999
10169
|
]
|
|
10000
|
-
})
|
|
10170
|
+
}), confirming ? /* @__PURE__ */ jsx(Dialog, {
|
|
10171
|
+
id: "asset-delete",
|
|
10172
|
+
header: "Supprimer le média",
|
|
10173
|
+
width: 1,
|
|
10174
|
+
onClose: () => busy ? void 0 : setConfirming(!1),
|
|
10175
|
+
footer: /* @__PURE__ */ jsxs(Flex, {
|
|
10176
|
+
justify: "flex-end",
|
|
10177
|
+
gap: 2,
|
|
10178
|
+
padding: 2,
|
|
10179
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
10180
|
+
text: "Annuler",
|
|
10181
|
+
mode: "bleed",
|
|
10182
|
+
disabled: busy,
|
|
10183
|
+
onClick: () => setConfirming(!1)
|
|
10184
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
10185
|
+
text: busy ? "Suppression…" : "Supprimer",
|
|
10186
|
+
tone: "critical",
|
|
10187
|
+
disabled: busy || uses === null,
|
|
10188
|
+
onClick: doDelete
|
|
10189
|
+
})]
|
|
10190
|
+
}),
|
|
10191
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
10192
|
+
padding: 4,
|
|
10193
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
10194
|
+
gap: 3,
|
|
10195
|
+
children: [
|
|
10196
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
10197
|
+
size: 1,
|
|
10198
|
+
children: [
|
|
10199
|
+
"Supprimer « ",
|
|
10200
|
+
assetName(asset),
|
|
10201
|
+
" » définitivement ?"
|
|
10202
|
+
]
|
|
10203
|
+
}),
|
|
10204
|
+
uses === null ? /* @__PURE__ */ jsxs(Flex, {
|
|
10205
|
+
align: "center",
|
|
10206
|
+
gap: 2,
|
|
10207
|
+
children: [/* @__PURE__ */ jsx(Spinner, {
|
|
10208
|
+
muted: !0,
|
|
10209
|
+
size: 1
|
|
10210
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
10211
|
+
size: 1,
|
|
10212
|
+
muted: !0,
|
|
10213
|
+
children: "Recherche des endroits où il est utilisé…"
|
|
10214
|
+
})]
|
|
10215
|
+
}) : uses.length === 0 ? /* @__PURE__ */ jsx(Text, {
|
|
10216
|
+
size: 1,
|
|
10217
|
+
muted: !0,
|
|
10218
|
+
children: "Il n'est utilisé nulle part : aucune page ne sera affectée."
|
|
10219
|
+
}) : /* @__PURE__ */ jsxs(Stack, {
|
|
10220
|
+
gap: 2,
|
|
10221
|
+
children: [/* @__PURE__ */ jsxs(Text, {
|
|
10222
|
+
size: 1,
|
|
10223
|
+
weight: "medium",
|
|
10224
|
+
children: [
|
|
10225
|
+
"L'image deviendra vide à ",
|
|
10226
|
+
uses.length,
|
|
10227
|
+
" endroit",
|
|
10228
|
+
uses.length > 1 ? "s" : "",
|
|
10229
|
+
" :"
|
|
10230
|
+
]
|
|
10231
|
+
}), /* @__PURE__ */ jsx(Card, {
|
|
10232
|
+
tone: "caution",
|
|
10233
|
+
border: !0,
|
|
10234
|
+
radius: 2,
|
|
10235
|
+
padding: 3,
|
|
10236
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
10237
|
+
gap: 2,
|
|
10238
|
+
as: "ul",
|
|
10239
|
+
style: {
|
|
10240
|
+
margin: 0,
|
|
10241
|
+
paddingLeft: 16
|
|
10242
|
+
},
|
|
10243
|
+
children: [uses.slice(0, 20).map((use) => /* @__PURE__ */ jsxs(Text, {
|
|
10244
|
+
size: 1,
|
|
10245
|
+
as: "li",
|
|
10246
|
+
children: [
|
|
10247
|
+
use.title,
|
|
10248
|
+
" ",
|
|
10249
|
+
/* @__PURE__ */ jsxs("span", {
|
|
10250
|
+
style: { opacity: .6 },
|
|
10251
|
+
children: [
|
|
10252
|
+
"(",
|
|
10253
|
+
use.type,
|
|
10254
|
+
")"
|
|
10255
|
+
]
|
|
10256
|
+
})
|
|
10257
|
+
]
|
|
10258
|
+
}, use.id)), uses.length > 20 ? /* @__PURE__ */ jsxs(Text, {
|
|
10259
|
+
size: 1,
|
|
10260
|
+
muted: !0,
|
|
10261
|
+
as: "li",
|
|
10262
|
+
children: [
|
|
10263
|
+
"… et ",
|
|
10264
|
+
uses.length - 20,
|
|
10265
|
+
" autre",
|
|
10266
|
+
uses.length - 20 > 1 ? "s" : "",
|
|
10267
|
+
"."
|
|
10268
|
+
]
|
|
10269
|
+
}) : null]
|
|
10270
|
+
})
|
|
10271
|
+
})]
|
|
10272
|
+
}),
|
|
10273
|
+
deleteError ? /* @__PURE__ */ jsx(Card, {
|
|
10274
|
+
tone: "critical",
|
|
10275
|
+
border: !0,
|
|
10276
|
+
radius: 2,
|
|
10277
|
+
padding: 3,
|
|
10278
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
10279
|
+
size: 1,
|
|
10280
|
+
children: ["Suppression échouée : ", deleteError]
|
|
10281
|
+
})
|
|
10282
|
+
}) : null
|
|
10283
|
+
]
|
|
10284
|
+
})
|
|
10285
|
+
})
|
|
10286
|
+
}) : null]
|
|
10001
10287
|
});
|
|
10002
10288
|
}
|
|
10003
10289
|
function AssetsTool() {
|
|
10004
|
-
let { data, loading, error, refresh } = useAssets(), meta = useAssetMeta(), assets = useMemo(() => data ?? [], [data]), [search, setSearch] = useState(""), [type, setType] = useState("all"), [usage, setUsage] = useState("all"), [sort, setSort] = useState("date"), [direction, setDirection] = useState("desc"), [view, setView] = useState("grid"), [selection, setSelection] = useState(null), [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set()), [openedId, setOpenedId] = useState(null), folderMap = useMemo(() => assignmentMap(meta.assignments), [meta.assignments]), counts = useMemo(() => countByFolder(assets, folderMap), [assets, folderMap]), folderName = useCallback((id) => meta.folders.find((f) => f.id === id)?.name ?? id, [meta.folders]), folderOf = useCallback((assetId) => folderMap.get(assetId) ?? null, [folderMap]), visible = useMemo(() => sortAssets(filterAssets(assetsInFolder(assets, folderMap, selection), {
|
|
10290
|
+
let { data, loading, error, refresh } = useAssets(), meta = useAssetMeta(), { upload, uploading, error: uploadError } = useAssetUpload(), fileInputRef = useRef(null), [dragging, setDragging] = useState(!1), assets = useMemo(() => data ?? [], [data]), [search, setSearch] = useState(""), [type, setType] = useState("all"), [usage, setUsage] = useState("all"), [sort, setSort] = useState("date"), [direction, setDirection] = useState("desc"), [view, setView] = useState("grid"), [selection, setSelection] = useState(null), [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set()), [openedId, setOpenedId] = useState(null), folderMap = useMemo(() => assignmentMap(meta.assignments), [meta.assignments]), counts = useMemo(() => countByFolder(assets, folderMap), [assets, folderMap]), folderName = useCallback((id) => meta.folders.find((f) => f.id === id)?.name ?? id, [meta.folders]), folderOf = useCallback((assetId) => folderMap.get(assetId) ?? null, [folderMap]), visible = useMemo(() => sortAssets(filterAssets(assetsInFolder(assets, folderMap, selection), {
|
|
10005
10291
|
search,
|
|
10006
10292
|
type,
|
|
10007
10293
|
usage
|
|
@@ -10036,6 +10322,15 @@ function AssetsTool() {
|
|
|
10036
10322
|
meta,
|
|
10037
10323
|
selectedIds,
|
|
10038
10324
|
clearSelection
|
|
10325
|
+
]), handleFiles = useCallback((files) => {
|
|
10326
|
+
if (!files || !files.length) return;
|
|
10327
|
+
let folder = typeof selection == "string" && selection !== "" ? selection : null;
|
|
10328
|
+
upload(files, folder ? (assetId) => meta.moveAsset(assetId, folder) : void 0).then(() => refresh());
|
|
10329
|
+
}, [
|
|
10330
|
+
upload,
|
|
10331
|
+
selection,
|
|
10332
|
+
meta,
|
|
10333
|
+
refresh
|
|
10039
10334
|
]);
|
|
10040
10335
|
return loading && assets.length === 0 ? /* @__PURE__ */ jsx(Flex, {
|
|
10041
10336
|
align: "center",
|
|
@@ -10048,8 +10343,47 @@ function AssetsTool() {
|
|
|
10048
10343
|
}) : /* @__PURE__ */ jsxs(Flex, {
|
|
10049
10344
|
gap: 4,
|
|
10050
10345
|
align: "stretch",
|
|
10051
|
-
style: {
|
|
10346
|
+
style: {
|
|
10347
|
+
minHeight: 420,
|
|
10348
|
+
position: "relative"
|
|
10349
|
+
},
|
|
10350
|
+
onDragOver: (event) => {
|
|
10351
|
+
event.preventDefault(), dragging || setDragging(!0);
|
|
10352
|
+
},
|
|
10353
|
+
onDragLeave: (event) => {
|
|
10354
|
+
event.currentTarget === event.target && setDragging(!1);
|
|
10355
|
+
},
|
|
10356
|
+
onDrop: (event) => {
|
|
10357
|
+
event.preventDefault(), setDragging(!1), handleFiles(event.dataTransfer.files);
|
|
10358
|
+
},
|
|
10052
10359
|
children: [
|
|
10360
|
+
/* @__PURE__ */ jsx("input", {
|
|
10361
|
+
ref: fileInputRef,
|
|
10362
|
+
type: "file",
|
|
10363
|
+
multiple: !0,
|
|
10364
|
+
hidden: !0,
|
|
10365
|
+
onChange: (event) => {
|
|
10366
|
+
handleFiles(event.currentTarget.files), event.currentTarget.value = "";
|
|
10367
|
+
}
|
|
10368
|
+
}),
|
|
10369
|
+
dragging ? /* @__PURE__ */ jsx(Flex, {
|
|
10370
|
+
align: "center",
|
|
10371
|
+
justify: "center",
|
|
10372
|
+
style: {
|
|
10373
|
+
position: "absolute",
|
|
10374
|
+
inset: 0,
|
|
10375
|
+
zIndex: 5,
|
|
10376
|
+
borderRadius: 6,
|
|
10377
|
+
border: "2px dashed var(--card-focus-ring-color, #2276fc)",
|
|
10378
|
+
background: "var(--card-bg-color, rgba(255,255,255,0.85))",
|
|
10379
|
+
pointerEvents: "none"
|
|
10380
|
+
},
|
|
10381
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
10382
|
+
size: 2,
|
|
10383
|
+
weight: "medium",
|
|
10384
|
+
children: "Déposer pour importer"
|
|
10385
|
+
})
|
|
10386
|
+
}) : null,
|
|
10053
10387
|
/* @__PURE__ */ jsx(Box, {
|
|
10054
10388
|
style: {
|
|
10055
10389
|
width: 220,
|
|
@@ -10088,8 +10422,20 @@ function AssetsTool() {
|
|
|
10088
10422
|
view,
|
|
10089
10423
|
onView: setView,
|
|
10090
10424
|
onRefresh: refresh,
|
|
10091
|
-
busy: loading
|
|
10425
|
+
busy: loading,
|
|
10426
|
+
onImport: () => fileInputRef.current?.click(),
|
|
10427
|
+
uploading
|
|
10092
10428
|
}),
|
|
10429
|
+
uploadError ? /* @__PURE__ */ jsx(Card, {
|
|
10430
|
+
tone: "critical",
|
|
10431
|
+
border: !0,
|
|
10432
|
+
radius: 2,
|
|
10433
|
+
padding: 3,
|
|
10434
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
10435
|
+
size: 1,
|
|
10436
|
+
children: ["Import échoué : ", uploadError.message]
|
|
10437
|
+
})
|
|
10438
|
+
}) : null,
|
|
10093
10439
|
selectedIds.size > 0 ? /* @__PURE__ */ jsx(Card, {
|
|
10094
10440
|
tone: "primary",
|
|
10095
10441
|
border: !0,
|
|
@@ -10175,19 +10521,22 @@ function AssetsTool() {
|
|
|
10175
10521
|
"."
|
|
10176
10522
|
]
|
|
10177
10523
|
})
|
|
10178
|
-
}) : view === "grid" ? /* @__PURE__ */ jsx(
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10524
|
+
}) : view === "grid" ? /* @__PURE__ */ jsx(Box, {
|
|
10525
|
+
style: {
|
|
10526
|
+
columnWidth: 200,
|
|
10527
|
+
columnGap: 12
|
|
10528
|
+
},
|
|
10529
|
+
children: visible.map((asset) => /* @__PURE__ */ jsx(Box, {
|
|
10530
|
+
style: {
|
|
10531
|
+
breakInside: "avoid",
|
|
10532
|
+
marginBottom: 12
|
|
10533
|
+
},
|
|
10534
|
+
children: /* @__PURE__ */ jsx(AssetCard, {
|
|
10535
|
+
asset,
|
|
10536
|
+
selected: selectedIds.has(asset._id),
|
|
10537
|
+
onToggleSelect: () => toggleSelect(asset._id),
|
|
10538
|
+
onOpen: () => setOpenedId(asset._id)
|
|
10539
|
+
})
|
|
10191
10540
|
}, asset._id))
|
|
10192
10541
|
}) : /* @__PURE__ */ jsx(AssetTable, {
|
|
10193
10542
|
assets: visible,
|
|
@@ -10210,11 +10559,46 @@ function AssetsTool() {
|
|
|
10210
10559
|
folders: meta.folders,
|
|
10211
10560
|
folder: folderOf(opened._id),
|
|
10212
10561
|
onMove: (folder) => meta.moveAsset(opened._id, folder),
|
|
10213
|
-
onClose: () => setOpenedId(null)
|
|
10562
|
+
onClose: () => setOpenedId(null),
|
|
10563
|
+
onDeleted: () => {
|
|
10564
|
+
setSelectedIds((prev) => {
|
|
10565
|
+
let next = new Set(prev);
|
|
10566
|
+
return next.delete(opened._id), next;
|
|
10567
|
+
}), setOpenedId(null), refresh();
|
|
10568
|
+
}
|
|
10214
10569
|
}) : null
|
|
10215
10570
|
]
|
|
10216
10571
|
});
|
|
10217
10572
|
}
|
|
10573
|
+
/**
|
|
10574
|
+
* Menu « + » du Studio en situation monolingue. Pur.
|
|
10575
|
+
*
|
|
10576
|
+
* `@sanity/document-internationalization` ajoute, pour chaque type traduit, un
|
|
10577
|
+
* template « paramétré » (`${type}-parameterized`) et un template statique par
|
|
10578
|
+
* langue (`${type}-${langue}`, p. ex. `article-fr`, titré « Français Article »).
|
|
10579
|
+
* Avec une seule langue branchée, ces deux-là font doublon avec le « + Article »
|
|
10580
|
+
* de base : le menu de création montre « + Article » ET « + Français Article ».
|
|
10581
|
+
*
|
|
10582
|
+
* On ne garde alors que la base. Avec plusieurs langues on ne touche à rien
|
|
10583
|
+
* (« + master » et « + langues » sont voulus).
|
|
10584
|
+
*
|
|
10585
|
+
* Détection sans connaître la liste des langues : le template `-parameterized`
|
|
10586
|
+
* est la signature du plugin ; s'il n'existe qu'UN statique pour ce type (et que
|
|
10587
|
+
* la base du type est bien présente), on est en monolingue pour ce type. Zéro ou
|
|
10588
|
+
* plusieurs statiques : on laisse tout, par prudence — jamais retirer la seule
|
|
10589
|
+
* façon de créer un document.
|
|
10590
|
+
*/
|
|
10591
|
+
function dropRedundantLanguageTemplates(options) {
|
|
10592
|
+
let ids = new Set(options.map((option) => option.templateId)), remove = /* @__PURE__ */ new Set();
|
|
10593
|
+
for (let { templateId } of options) {
|
|
10594
|
+
if (!templateId.endsWith("-parameterized")) continue;
|
|
10595
|
+
let base = templateId.slice(0, -14);
|
|
10596
|
+
if (!ids.has(base)) continue;
|
|
10597
|
+
let statics = options.filter((option) => option.templateId !== templateId && option.templateId.startsWith(`${base}-`)), only = statics.length === 1 ? statics[0] : void 0;
|
|
10598
|
+
only && (remove.add(templateId), remove.add(only.templateId));
|
|
10599
|
+
}
|
|
10600
|
+
return options.filter((option) => !remove.has(option.templateId));
|
|
10601
|
+
}
|
|
10218
10602
|
const store$1 = /* @__PURE__ */ new Map();
|
|
10219
10603
|
function entryFor$1(client, type, languageField, language) {
|
|
10220
10604
|
let { projectId, dataset } = client.config(), key = `${projectId}:${dataset}:${type}:${language ?? ""}`, entry = store$1.get(key);
|
|
@@ -10822,6 +11206,143 @@ function createArrayNamesInput(Fallback) {
|
|
|
10822
11206
|
});
|
|
10823
11207
|
};
|
|
10824
11208
|
}
|
|
11209
|
+
/**
|
|
11210
|
+
* Source d'asset « NCF Médias » : le sélecteur d'image/fichier d'un champ montre
|
|
11211
|
+
* les mêmes DOSSIERS et la même recherche que l'onglet Assets. Sans ça,
|
|
11212
|
+
* l'organisation ne servirait qu'à l'onglet et pas au choix d'un média.
|
|
11213
|
+
*/
|
|
11214
|
+
function AssetSourceBrowser(props) {
|
|
11215
|
+
let { assetType, onSelect, onClose, dialogHeaderTitle } = props, { data, loading } = useAssets(), meta = useAssetMeta(), [search, setSearch] = useState(""), [selection, setSelection] = useState(null), wantImages = assetType !== "file", all = useMemo(() => (data ?? []).filter((asset) => wantImages ? isImageAsset(asset) : !isImageAsset(asset)), [data, wantImages]), folderMap = useMemo(() => assignmentMap(meta.assignments), [meta.assignments]), counts = useMemo(() => countByFolder(all, folderMap), [all, folderMap]), visible = useMemo(() => sortAssets(filterAssets(assetsInFolder(all, folderMap, selection), { search }), "date", "desc"), [
|
|
11216
|
+
all,
|
|
11217
|
+
folderMap,
|
|
11218
|
+
selection,
|
|
11219
|
+
search
|
|
11220
|
+
]), pick = (asset) => {
|
|
11221
|
+
onSelect([{
|
|
11222
|
+
kind: "assetDocumentId",
|
|
11223
|
+
value: asset._id
|
|
11224
|
+
}]), onClose();
|
|
11225
|
+
};
|
|
11226
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
11227
|
+
id: "ncf-asset-source",
|
|
11228
|
+
header: dialogHeaderTitle || "NCF Médias",
|
|
11229
|
+
width: 3,
|
|
11230
|
+
onClose,
|
|
11231
|
+
children: /* @__PURE__ */ jsxs(Flex, {
|
|
11232
|
+
style: { minHeight: 420 },
|
|
11233
|
+
align: "stretch",
|
|
11234
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
11235
|
+
padding: 3,
|
|
11236
|
+
style: {
|
|
11237
|
+
width: 220,
|
|
11238
|
+
flex: "none",
|
|
11239
|
+
borderRight: "1px solid var(--card-border-color)"
|
|
11240
|
+
},
|
|
11241
|
+
overflow: "auto",
|
|
11242
|
+
children: /* @__PURE__ */ jsx(FolderSidebar, {
|
|
11243
|
+
folders: meta.folders,
|
|
11244
|
+
counts,
|
|
11245
|
+
total: all.length,
|
|
11246
|
+
selection,
|
|
11247
|
+
onSelect: setSelection,
|
|
11248
|
+
onCreate: meta.createFolder,
|
|
11249
|
+
onRename: meta.renameFolder,
|
|
11250
|
+
onDelete: (id) => {
|
|
11251
|
+
selection === id && setSelection(null), meta.deleteFolder(id);
|
|
11252
|
+
}
|
|
11253
|
+
})
|
|
11254
|
+
}), /* @__PURE__ */ jsxs(Stack, {
|
|
11255
|
+
flex: 1,
|
|
11256
|
+
gap: 3,
|
|
11257
|
+
padding: 3,
|
|
11258
|
+
style: { minWidth: 0 },
|
|
11259
|
+
children: [/* @__PURE__ */ jsx(TextInput, {
|
|
11260
|
+
value: search,
|
|
11261
|
+
onChange: (event) => setSearch(event.currentTarget.value),
|
|
11262
|
+
placeholder: "Rechercher un média",
|
|
11263
|
+
icon: SearchIcon,
|
|
11264
|
+
clearButton: search.length > 0,
|
|
11265
|
+
onClear: () => setSearch(""),
|
|
11266
|
+
fontSize: 1,
|
|
11267
|
+
radius: 2
|
|
11268
|
+
}), /* @__PURE__ */ jsx(Box, {
|
|
11269
|
+
flex: 1,
|
|
11270
|
+
overflow: "auto",
|
|
11271
|
+
children: loading && all.length === 0 ? /* @__PURE__ */ jsx(Flex, {
|
|
11272
|
+
align: "center",
|
|
11273
|
+
justify: "center",
|
|
11274
|
+
padding: 5,
|
|
11275
|
+
children: /* @__PURE__ */ jsx(Spinner, { muted: !0 })
|
|
11276
|
+
}) : visible.length === 0 ? /* @__PURE__ */ jsx(Flex, {
|
|
11277
|
+
align: "center",
|
|
11278
|
+
justify: "center",
|
|
11279
|
+
padding: 5,
|
|
11280
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
11281
|
+
size: 1,
|
|
11282
|
+
muted: !0,
|
|
11283
|
+
children: [
|
|
11284
|
+
"Aucun média",
|
|
11285
|
+
selection ? " dans ce dossier" : "",
|
|
11286
|
+
"."
|
|
11287
|
+
]
|
|
11288
|
+
})
|
|
11289
|
+
}) : /* @__PURE__ */ jsx(Grid, {
|
|
11290
|
+
gridTemplateColumns: [
|
|
11291
|
+
2,
|
|
11292
|
+
3,
|
|
11293
|
+
4
|
|
11294
|
+
],
|
|
11295
|
+
gap: 3,
|
|
11296
|
+
children: visible.map((asset) => {
|
|
11297
|
+
let thumb = thumbnailUrl(asset, {
|
|
11298
|
+
w: 240,
|
|
11299
|
+
h: 180
|
|
11300
|
+
});
|
|
11301
|
+
return /* @__PURE__ */ jsxs(Card, {
|
|
11302
|
+
radius: 2,
|
|
11303
|
+
shadow: 1,
|
|
11304
|
+
padding: 0,
|
|
11305
|
+
as: "button",
|
|
11306
|
+
onClick: () => pick(asset),
|
|
11307
|
+
style: {
|
|
11308
|
+
overflow: "hidden",
|
|
11309
|
+
cursor: "pointer",
|
|
11310
|
+
textAlign: "left",
|
|
11311
|
+
border: 0
|
|
11312
|
+
},
|
|
11313
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
11314
|
+
style: {
|
|
11315
|
+
aspectRatio: "4 / 3",
|
|
11316
|
+
background: "var(--card-muted-bg-color, rgba(127,127,127,0.08))"
|
|
11317
|
+
},
|
|
11318
|
+
children: thumb ? /* @__PURE__ */ jsx("img", {
|
|
11319
|
+
src: thumb,
|
|
11320
|
+
alt: "",
|
|
11321
|
+
loading: "lazy",
|
|
11322
|
+
style: {
|
|
11323
|
+
width: "100%",
|
|
11324
|
+
height: "100%",
|
|
11325
|
+
objectFit: "cover",
|
|
11326
|
+
display: "block"
|
|
11327
|
+
}
|
|
11328
|
+
}) : null
|
|
11329
|
+
}), /* @__PURE__ */ jsx(Box, {
|
|
11330
|
+
padding: 2,
|
|
11331
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
11332
|
+
size: 0,
|
|
11333
|
+
textOverflow: "ellipsis",
|
|
11334
|
+
style: MONO,
|
|
11335
|
+
children: assetName(asset)
|
|
11336
|
+
})
|
|
11337
|
+
})]
|
|
11338
|
+
}, asset._id);
|
|
11339
|
+
})
|
|
11340
|
+
})
|
|
11341
|
+
})]
|
|
11342
|
+
})]
|
|
11343
|
+
})
|
|
11344
|
+
});
|
|
11345
|
+
}
|
|
10825
11346
|
const store = /* @__PURE__ */ new Map();
|
|
10826
11347
|
function entryFor(client, documentId) {
|
|
10827
11348
|
let { projectId, dataset } = client.config(), id = translationTodoId(documentId), key = `${projectId}:${dataset}:${id}`, entry = store.get(key);
|
|
@@ -11965,15 +12486,20 @@ const pathOf = (preview) => {
|
|
|
11965
12486
|
* titre ou adresse ; un clic ouvre la page dans l'aperçu ET son document à côté.
|
|
11966
12487
|
*/
|
|
11967
12488
|
function PagesNavigator() {
|
|
11968
|
-
let config = useKitConfig(), { rows, loading } = usePages(), params = usePresentationParams(!1), navigate = usePresentationNavigate(), i18n = config.i18n, shownLocale = localeOfPreview(params?.preview, i18n), [locale, setLocale] = useState(null), [search, setSearch] = useState(""), activeLocale = locale ?? shownLocale ?? i18n?.defaultLocale ?? "", current = pathOf(params?.preview), visible = useMemo(() => {
|
|
12489
|
+
let config = useKitConfig(), { rows, loading } = usePages(), { pageOrder, savePageOrder } = useBoardLayout(), params = usePresentationParams(!1), navigate = usePresentationNavigate(), i18n = config.i18n, shownLocale = localeOfPreview(params?.preview, i18n), [locale, setLocale] = useState(null), [search, setSearch] = useState(""), [dragId, setDragId] = useState(null), activeLocale = locale ?? shownLocale ?? i18n?.defaultLocale ?? "", current = pathOf(params?.preview), withPath = useMemo(() => rows.filter((r) => r.path !== null).sort((a, b) => (a.path ?? "").localeCompare(b.path ?? "")), [rows]), visible = useMemo(() => {
|
|
11969
12490
|
let q = search.trim().toLowerCase();
|
|
11970
|
-
return
|
|
12491
|
+
return orderByIds(withPath.filter((r) => !i18n || !activeLocale || !r.locale || r.locale === activeLocale).filter((r) => !q || r.title.toLowerCase().includes(q) || (r.path ?? "").toLowerCase().includes(q)), pageOrder);
|
|
11971
12492
|
}, [
|
|
11972
|
-
|
|
12493
|
+
withPath,
|
|
11973
12494
|
search,
|
|
11974
12495
|
activeLocale,
|
|
11975
|
-
i18n
|
|
11976
|
-
|
|
12496
|
+
i18n,
|
|
12497
|
+
pageOrder
|
|
12498
|
+
]), onReorder = (targetId) => {
|
|
12499
|
+
if (!dragId) return;
|
|
12500
|
+
let fullIds = orderByIds(withPath, pageOrder).map((r) => r.id);
|
|
12501
|
+
savePageOrder(reorderBefore(fullIds, dragId, targetId)), setDragId(null);
|
|
12502
|
+
};
|
|
11977
12503
|
return /* @__PURE__ */ jsxs(Card, {
|
|
11978
12504
|
height: "fill",
|
|
11979
12505
|
borderRight: !0,
|
|
@@ -12030,53 +12556,89 @@ function PagesNavigator() {
|
|
|
12030
12556
|
}) : /* @__PURE__ */ jsxs(Stack, {
|
|
12031
12557
|
gap: 1,
|
|
12032
12558
|
padding: 1,
|
|
12033
|
-
children: [
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12559
|
+
children: [
|
|
12560
|
+
visible.map((row) => {
|
|
12561
|
+
let selected = current !== null && current === ((row.path ?? "").replace(/\/$/, "") || "/");
|
|
12562
|
+
return /* @__PURE__ */ jsx(Card, {
|
|
12563
|
+
as: "button",
|
|
12564
|
+
padding: 2,
|
|
12565
|
+
radius: 2,
|
|
12566
|
+
tone: selected ? "primary" : "default",
|
|
12567
|
+
pressed: selected,
|
|
12568
|
+
draggable: !0,
|
|
12569
|
+
onDragStart: (event) => {
|
|
12570
|
+
setDragId(row.id), event.dataTransfer.effectAllowed = "move";
|
|
12571
|
+
},
|
|
12572
|
+
onDragOver: (event) => {
|
|
12573
|
+
dragId && dragId !== row.id && event.preventDefault();
|
|
12574
|
+
},
|
|
12575
|
+
onDrop: (event) => {
|
|
12576
|
+
event.preventDefault(), onReorder(row.id);
|
|
12577
|
+
},
|
|
12578
|
+
onDragEnd: () => setDragId(null),
|
|
12579
|
+
style: {
|
|
12580
|
+
textAlign: "left",
|
|
12581
|
+
cursor: "pointer",
|
|
12582
|
+
border: 0,
|
|
12583
|
+
width: "100%",
|
|
12584
|
+
opacity: dragId === row.id ? .4 : 1
|
|
12585
|
+
},
|
|
12586
|
+
onClick: () => navigate(row.path ?? void 0, {
|
|
12587
|
+
type: row.type,
|
|
12588
|
+
id: row.id
|
|
12589
|
+
}),
|
|
12590
|
+
children: /* @__PURE__ */ jsxs(Flex, {
|
|
12591
|
+
align: "center",
|
|
12592
|
+
gap: 2,
|
|
12593
|
+
children: [
|
|
12594
|
+
/* @__PURE__ */ jsx(Text, {
|
|
12595
|
+
size: 1,
|
|
12596
|
+
muted: !0,
|
|
12597
|
+
style: {
|
|
12598
|
+
flex: "none",
|
|
12599
|
+
cursor: "grab"
|
|
12600
|
+
},
|
|
12601
|
+
title: "Glisser pour réordonner",
|
|
12602
|
+
children: /* @__PURE__ */ jsx(DragHandleIcon, {})
|
|
12603
|
+
}),
|
|
12604
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
12605
|
+
gap: 1,
|
|
12606
|
+
flex: 1,
|
|
12607
|
+
style: { minWidth: 0 },
|
|
12608
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
12609
|
+
size: 1,
|
|
12610
|
+
weight: selected ? "semibold" : "regular",
|
|
12611
|
+
textOverflow: "ellipsis",
|
|
12612
|
+
children: row.title || row.path
|
|
12613
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
12614
|
+
size: 0,
|
|
12615
|
+
muted: !0,
|
|
12616
|
+
textOverflow: "ellipsis",
|
|
12617
|
+
children: row.path
|
|
12618
|
+
})]
|
|
12619
|
+
}),
|
|
12620
|
+
row.status !== "published" && /* @__PURE__ */ jsx(StatusBadge, { status: row.status })
|
|
12621
|
+
]
|
|
12622
|
+
})
|
|
12623
|
+
}, row.id);
|
|
12624
|
+
}),
|
|
12625
|
+
dragId ? /* @__PURE__ */ jsx(Box, {
|
|
12037
12626
|
padding: 2,
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
style: {
|
|
12042
|
-
textAlign: "left",
|
|
12043
|
-
cursor: "pointer",
|
|
12044
|
-
border: 0,
|
|
12045
|
-
width: "100%"
|
|
12627
|
+
onDragOver: (event) => event.preventDefault(),
|
|
12628
|
+
onDrop: (event) => {
|
|
12629
|
+
event.preventDefault(), onReorder(null);
|
|
12046
12630
|
},
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
children: /* @__PURE__ */
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
children:
|
|
12055
|
-
gap: 1,
|
|
12056
|
-
flex: 1,
|
|
12057
|
-
style: { minWidth: 0 },
|
|
12058
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
12059
|
-
size: 1,
|
|
12060
|
-
weight: selected ? "semibold" : "regular",
|
|
12061
|
-
textOverflow: "ellipsis",
|
|
12062
|
-
children: row.title || row.path
|
|
12063
|
-
}), /* @__PURE__ */ jsx(Text, {
|
|
12064
|
-
size: 0,
|
|
12065
|
-
muted: !0,
|
|
12066
|
-
textOverflow: "ellipsis",
|
|
12067
|
-
children: row.path
|
|
12068
|
-
})]
|
|
12069
|
-
}), row.status !== "published" && /* @__PURE__ */ jsx(StatusBadge, { status: row.status })]
|
|
12631
|
+
style: { height: 24 }
|
|
12632
|
+
}) : null,
|
|
12633
|
+
!visible.length && /* @__PURE__ */ jsx(Box, {
|
|
12634
|
+
padding: 3,
|
|
12635
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
12636
|
+
size: 1,
|
|
12637
|
+
muted: !0,
|
|
12638
|
+
children: "No page."
|
|
12070
12639
|
})
|
|
12071
|
-
}, row.id);
|
|
12072
|
-
}), !visible.length && /* @__PURE__ */ jsx(Box, {
|
|
12073
|
-
padding: 3,
|
|
12074
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
12075
|
-
size: 1,
|
|
12076
|
-
muted: !0,
|
|
12077
|
-
children: "No page."
|
|
12078
12640
|
})
|
|
12079
|
-
|
|
12641
|
+
]
|
|
12080
12642
|
})
|
|
12081
12643
|
})]
|
|
12082
12644
|
});
|
|
@@ -12096,7 +12658,7 @@ function ncfPresentationComponents(options) {
|
|
|
12096
12658
|
return /* @__PURE__ */ jsx(KitProvider, {
|
|
12097
12659
|
config,
|
|
12098
12660
|
issues,
|
|
12099
|
-
children: /* @__PURE__ */ jsx(PagesNavigator, {})
|
|
12661
|
+
children: /* @__PURE__ */ jsx(BoardLayoutProvider, { children: /* @__PURE__ */ jsx(PagesNavigator, {}) })
|
|
12100
12662
|
});
|
|
12101
12663
|
}
|
|
12102
12664
|
return {
|
|
@@ -12174,7 +12736,12 @@ function ncfMainDocuments(options, extra = {}) {
|
|
|
12174
12736
|
* pas le Studio de démarrer : l'onglet concerné affiche le détail à corriger.
|
|
12175
12737
|
*/
|
|
12176
12738
|
/** Noms des outils dans la barre du Studio. Exportés pour filtrer `tools`. */
|
|
12177
|
-
const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_HISTORY_TOOL = "ncf-history", NCF_DESIGN_SYSTEM_TOOL = "ncf-design-system", NCF_ASSETS_TOOL = "ncf-assets",
|
|
12739
|
+
const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_HISTORY_TOOL = "ncf-history", NCF_DESIGN_SYSTEM_TOOL = "ncf-design-system", NCF_ASSETS_TOOL = "ncf-assets", ncfAssetSource = {
|
|
12740
|
+
name: "ncf-media",
|
|
12741
|
+
title: "NCF Médias",
|
|
12742
|
+
icon: ImagesIcon,
|
|
12743
|
+
component: AssetSourceBrowser
|
|
12744
|
+
}, NCF_TOOL_NAMES = [
|
|
12178
12745
|
NCF_PAGES_TOOL,
|
|
12179
12746
|
NCF_COMPONENTS_TOOL,
|
|
12180
12747
|
NCF_HISTORY_TOOL,
|
|
@@ -12280,14 +12847,20 @@ const ncfKit = definePlugin((options) => {
|
|
|
12280
12847
|
templates: (prev) => prev.filter((template) => !isKitType(template.schemaType))
|
|
12281
12848
|
},
|
|
12282
12849
|
document: {
|
|
12283
|
-
newDocumentOptions: (prev) => prev.filter((option) => option.templateId !== BOARD_LAYOUT_TYPE),
|
|
12850
|
+
newDocumentOptions: (prev) => dropRedundantLanguageTemplates(prev.filter((option) => option.templateId !== BOARD_LAYOUT_TYPE)),
|
|
12284
12851
|
actions: (prev, context) => config.pageTypeNames.includes(context.schemaType) ? prev.map((action) => action.action === "unpublish" ? config.i18n ? createRemoveFromSite(config) : RemoveFromSiteAction : action.action === "publish" ? addJsonLd(config.i18n ? withTranslationRedirects(withPropagation(action, config, void 0, { allowCreate: !0 }), config) : action) : action.action === "delete" && config.i18n ? withTranslationDelete(action, config) : action) : context.schemaType === config.componentPreview.defaultsType && config.i18n ? prev.map((action) => action.action === "publish" ? withPropagation(action, config, config.i18n?.defaultsSourceLocale) : action.action === "delete" ? withTranslationDelete(action, config, config.i18n?.defaultsSourceLocale) : action) : config.i18n && !isKitType(context.schemaType) && hasLanguageField(context.schema.get(context.schemaType), config.i18n.field) ? prev.map((action) => action.action === "publish" ? withPropagation(action, config, void 0, { allowCreate: !0 }) : action.action === "delete" ? withTranslationDelete(action, config) : action.action === "unpublish" ? createRemoveFromSite(config) : action) : prev
|
|
12285
12852
|
},
|
|
12286
12853
|
studio: { components: {
|
|
12287
12854
|
toolMenu: createPreviewLauncher(config, issues),
|
|
12288
12855
|
layout: HelpTextStyle
|
|
12289
12856
|
} },
|
|
12290
|
-
form: {
|
|
12857
|
+
form: {
|
|
12858
|
+
components: { input: createKitInput(config, issues) },
|
|
12859
|
+
...config.tools.assets ? {
|
|
12860
|
+
image: { assetSources: (prev) => [ncfAssetSource, ...prev] },
|
|
12861
|
+
file: { assetSources: (prev) => [ncfAssetSource, ...prev] }
|
|
12862
|
+
} : {}
|
|
12863
|
+
}
|
|
12291
12864
|
};
|
|
12292
12865
|
});
|
|
12293
12866
|
/** Le type de document porte-t-il le champ de langue (traduit document par document) ? */
|
|
@@ -12295,6 +12868,6 @@ function hasLanguageField(schemaType, field) {
|
|
|
12295
12868
|
let fields = schemaType?.fields;
|
|
12296
12869
|
return Array.isArray(fields) && fields.some((f) => f?.name === field);
|
|
12297
12870
|
}
|
|
12298
|
-
export { ANNOTATION_TYPE, ActorName, AssetsTool, BOARD_LAYOUT_ID, BOARD_LAYOUT_TYPE, BRAIN_NODE_SIZE, BoardLayoutProvider, COLUMN_TYPE, CONTENT_SCAN_LIMIT, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, CUSTOM_ENVIRONMENT_ID, CodeEditorInput, CodeEmbedInput, DATA_PREFIX, DEFAULT_BOARD_TAGS, DEFAULT_COMPONENT_DEFAULTS_TYPE, DEFAULT_COMPONENT_PREVIEW, DEFAULT_I18N, DEFAULT_INTERNAL_FIELDS, DEFAULT_MORE_TOOLS, DEFAULT_PAGE_BUILDER_FIELD, DEFAULT_SLUG_FIELD, DEFAULT_TITLE_FIELD, HelpTextStyle, KIT_API_VERSION, KIT_VERSION, NCF_ASSETS_TOOL, NCF_COMPONENTS_TOOL, NCF_DESIGN_SYSTEM_TOOL, NCF_HIDDEN_TYPES, NCF_HISTORY_TOOL, NCF_MORE_TOOL, NCF_PAGES_TOOL, NCF_TOOL_NAMES, NODE_FIELD_TYPE, NODE_HEIGHT, NODE_WIDTH, NcfKitUpdate, NcfPreviewHeader, NcfPreviewLauncher, PERSPECTIVES, PROJECTION, SECTION_NODE_TYPE, STATUS_COLORS, STATUS_LABELS, SharePreview, UNSET_LABEL, addColumn, addColumnOption, announce, applySavedPositions, assetName, assetsInFolder, assignmentMap, baseId, blockName, blockTypesFromSchema, buildContentsQuery, buildLinkGraph, buildPageRows, buildPagesQuery, codeEditorInput, collectLinks, collectOccurrences, colorForRow, colorFromString, columnId, compareVersions, componentDefaultsMainDocument, componentDefaultsMainDocuments, countByFolder, createPreviewLauncher, customEnvironment, defaultNodeSize, defaultsFieldName, defineCodeEmbedType, defineComponentDefaults, depth, deriveDocumentColumns, detectPageBuilderField, diffDocuments, diffWords, editIntentPath, explainGrantError, fallbackLayout, fetchDetail, fetchTimeline, fillTemplate, filterAssets, filterRows, fixCrossLanguageReferences, flatten, formatBytes, formatDocumentValue, groupComponents, groupMap, groupPageRows, groupValue, hasBlockingIssue, humanizeBlockName, isDraftId, isImageAsset, isKitType, isPrerelease, isSafeColumnKey, isSafeFieldPath, isTextChange, isVersionId, issuesForTool, keyForPath, kitSchemaTypes, layoutGraph, layoutSectionsMap, localesInRows, mergeVersions, missingPageTypes, moveColumn, nameMap, ncfAllowedOrigins, ncfKit, ncfMainDocuments, ncfPresentationComponents, ncfPreviewComponents, normalizeInternalPath, normalizePath, occurrencesForTypes, pageThumbnailUrl, pageTypeFor, pageTypesFromSiteRoutes, pageTypesWithoutBuilder, parentPath, presentationPath, pruneSavedPositions, releaseId, removeColumn, renameColumn, requestPreviewGrant, requiredUnlessDefault, requiredUnlessDefaultFor, resolveColorBy, resolveConfig, resolvePageBuilderField, sectionNamesFromDefaults, segments, slugKey, sortAssets, sortRows, summarize, thumbnailUrl, toKebabCase, toPath, toUrl, topLevelBlockCount, uniqueColumnId, upsertLayout, urlOn, useAnnotations, useAssetMeta, useAssets, useBoardLayout, useComponentNames, useDocumentColumns, useHistory, useInternalColumns, useKitClient, useKitConfig, useKitContext, useKitUpdate, useOccurrences, useOptionalKitConfig, useOptionalKitContext, usePageBuilder, usePageContents, usePages, usePreviewTarget, useRegistration, validateConfig, withAlpha, withCustomNames, withMoreTool, withSameLanguageReferences };
|
|
12871
|
+
export { ANNOTATION_TYPE, ActorName, AssetSourceBrowser, AssetsTool, BOARD_LAYOUT_ID, BOARD_LAYOUT_TYPE, BRAIN_NODE_SIZE, BoardLayoutProvider, COLUMN_TYPE, CONTENT_SCAN_LIMIT, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, CUSTOM_ENVIRONMENT_ID, CodeEditorInput, CodeEmbedInput, DATA_PREFIX, DEFAULT_BOARD_TAGS, DEFAULT_COMPONENT_DEFAULTS_TYPE, DEFAULT_COMPONENT_PREVIEW, DEFAULT_I18N, DEFAULT_INTERNAL_FIELDS, DEFAULT_MORE_TOOLS, DEFAULT_PAGE_BUILDER_FIELD, DEFAULT_SLUG_FIELD, DEFAULT_TITLE_FIELD, HelpTextStyle, KIT_API_VERSION, KIT_VERSION, NCF_ASSETS_TOOL, NCF_COMPONENTS_TOOL, NCF_DESIGN_SYSTEM_TOOL, NCF_HIDDEN_TYPES, NCF_HISTORY_TOOL, NCF_MORE_TOOL, NCF_PAGES_TOOL, NCF_TOOL_NAMES, NODE_FIELD_TYPE, NODE_HEIGHT, NODE_WIDTH, NcfKitUpdate, NcfPreviewHeader, NcfPreviewLauncher, PERSPECTIVES, PROJECTION, SECTION_NODE_TYPE, STATUS_COLORS, STATUS_LABELS, SharePreview, UNSET_LABEL, addColumn, addColumnOption, announce, applySavedPositions, assetName, assetsInFolder, assignmentMap, baseId, blockName, blockTypesFromSchema, buildContentsQuery, buildLinkGraph, buildPageRows, buildPagesQuery, codeEditorInput, collectLinks, collectOccurrences, colorForRow, colorFromString, columnId, compareVersions, componentDefaultsMainDocument, componentDefaultsMainDocuments, countByFolder, createPreviewLauncher, customEnvironment, defaultNodeSize, defaultsFieldName, defineCodeEmbedType, defineComponentDefaults, depth, deriveDocumentColumns, detectPageBuilderField, diffDocuments, diffWords, editIntentPath, explainGrantError, fallbackLayout, fetchDetail, fetchTimeline, fillTemplate, filterAssets, filterRows, fixCrossLanguageReferences, flatten, formatBytes, formatDocumentValue, groupComponents, groupMap, groupPageRows, groupValue, hasBlockingIssue, humanizeBlockName, isDraftId, isImageAsset, isKitType, isPrerelease, isSafeColumnKey, isSafeFieldPath, isTextChange, isVersionId, issuesForTool, keyForPath, kitSchemaTypes, layoutGraph, layoutSectionsMap, localesInRows, mergeVersions, missingPageTypes, moveColumn, nameMap, ncfAllowedOrigins, ncfKit, ncfMainDocuments, ncfPresentationComponents, ncfPreviewComponents, normalizeInternalPath, normalizePath, occurrencesForTypes, pageThumbnailUrl, pageTypeFor, pageTypesFromSiteRoutes, pageTypesWithoutBuilder, parentPath, presentationPath, pruneSavedPositions, releaseId, removeColumn, renameColumn, requestPreviewGrant, requiredUnlessDefault, requiredUnlessDefaultFor, resolveColorBy, resolveConfig, resolvePageBuilderField, sectionNamesFromDefaults, segments, slugKey, sortAssets, sortRows, summarize, thumbnailUrl, toKebabCase, toPath, toUrl, topLevelBlockCount, uniqueColumnId, upsertLayout, urlOn, useAnnotations, useAssetMeta, useAssetUpload, useAssets, useBoardLayout, useComponentNames, useDocumentColumns, useHistory, useInternalColumns, useKitClient, useKitConfig, useKitContext, useKitUpdate, useOccurrences, useOptionalKitConfig, useOptionalKitContext, usePageBuilder, usePageContents, usePages, usePreviewTarget, useRegistration, validateConfig, withAlpha, withCustomNames, withMoreTool, withSameLanguageReferences };
|
|
12299
12872
|
|
|
12300
12873
|
//# sourceMappingURL=index.js.map
|