@nocode-factory/sanity-kit 2.49.1 → 2.51.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 +2 -1
- package/dist/{finalUrl-C1kzYMzQ.js → finalUrl-CaFXmYvm.js} +3 -2
- package/dist/finalUrl-CaFXmYvm.js.map +1 -0
- package/dist/{fixCrossLanguageReferences-BZk9CkdI.js → fixCrossLanguageReferences-BeXywAAU.js} +2 -2
- package/dist/{fixCrossLanguageReferences-BZk9CkdI.js.map → fixCrossLanguageReferences-BeXywAAU.js.map} +1 -1
- package/dist/{fixCrossLanguageReferences-CjL_Xy0U.d.ts → fixCrossLanguageReferences-w3whO9xM.d.ts} +4 -2
- package/dist/index.d.ts +287 -5
- package/dist/index.js +2119 -181
- package/dist/index.js.map +1 -1
- package/dist/jsonld.js +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +2 -2
- package/package.json +3 -1
- package/src/config/defaults.ts +1 -0
- package/src/config/types.ts +3 -1
- package/src/context/ComponentMetaContext.tsx +23 -0
- package/src/form/ArrayNamesInput.tsx +25 -0
- package/src/form/renameArrayMembers.ts +25 -0
- package/src/hooks/useAssetMeta.ts +166 -0
- package/src/hooks/useAssets.ts +23 -0
- package/src/hooks/useComponentMeta.ts +159 -0
- package/src/hooks/useComponentNames.ts +39 -0
- package/src/index.ts +56 -1
- package/src/lib/assets.ts +161 -0
- package/src/lib/componentMeta.ts +70 -0
- package/src/schema/assetMeta.ts +65 -0
- package/src/schema/boardLayout.ts +5 -1
- package/src/schema/componentMeta.ts +54 -0
- package/src/tools/assets/AssetCard.tsx +86 -0
- package/src/tools/assets/AssetDetail.tsx +150 -0
- package/src/tools/assets/AssetTable.tsx +122 -0
- package/src/tools/assets/AssetsTool.tsx +212 -0
- package/src/tools/assets/AssetsToolbar.tsx +98 -0
- package/src/tools/assets/FolderSidebar.tsx +177 -0
- package/src/tools/components/BlockCard.tsx +20 -12
- package/src/tools/components/ComponentEditDialog.tsx +83 -0
- package/src/tools/components/ComponentsTool.tsx +190 -84
- package/src/version.ts +1 -1
- package/dist/finalUrl-C1kzYMzQ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as DEFAULT_PAGE_BUILDER_FIELD, a as depth, c as segments, d as normalizePath, f as resolveConfig, g as DEFAULT_INTERNAL_FIELDS, h as DEFAULT_I18N, i as redirectMapOf, l as toPath, m as DEFAULT_COMPONENT_PREVIEW, o as pageTypeFor, p as DEFAULT_BOARD_TAGS, s as parentPath, t as finalPath, u as toUrl, v as DEFAULT_SLUG_FIELD, y as DEFAULT_TITLE_FIELD } from "./finalUrl-
|
|
1
|
+
import { _ as DEFAULT_PAGE_BUILDER_FIELD, a as depth, c as segments, d as normalizePath, f as resolveConfig, g as DEFAULT_INTERNAL_FIELDS, h as DEFAULT_I18N, i as redirectMapOf, l as toPath, m as DEFAULT_COMPONENT_PREVIEW, o as pageTypeFor, p as DEFAULT_BOARD_TAGS, s as parentPath, t as finalPath, u as toUrl, v as DEFAULT_SLUG_FIELD, y as DEFAULT_TITLE_FIELD } from "./finalUrl-CaFXmYvm.js";
|
|
2
2
|
import { a as collectTexts$1, c as valueAtKey, d as useKitContext, f as useOptionalKitConfig, i as guessDocumentTitle, l as KitProvider, o as replaceTexts, p as useOptionalKitContext, r as collectDocumentText, s as setAtKey, t as generateJsonLd, u as useKitConfig } from "./aiJsonLd-BFyxgYen.js";
|
|
3
|
-
import { a as componentDefaultsMainDocument, c as defineComponentDefaults, d as syncTranslationRedirects, f as translationRedirectId, i as DEFAULT_COMPONENT_DEFAULTS_TYPE, l as requiredUnlessDefault, n as withSameLanguageReferences, o as componentDefaultsMainDocuments, p as translationRedirectOptions, r as pageTypesFromSiteRoutes, s as defaultsFieldName, t as fixCrossLanguageReferences, u as requiredUnlessDefaultFor } from "./fixCrossLanguageReferences-
|
|
3
|
+
import { a as componentDefaultsMainDocument, c as defineComponentDefaults, d as syncTranslationRedirects, f as translationRedirectId, i as DEFAULT_COMPONENT_DEFAULTS_TYPE, l as requiredUnlessDefault, n as withSameLanguageReferences, o as componentDefaultsMainDocuments, p as translationRedirectOptions, r as pageTypesFromSiteRoutes, s as defaultsFieldName, t as fixCrossLanguageReferences, u as requiredUnlessDefaultFor } from "./fixCrossLanguageReferences-BeXywAAU.js";
|
|
4
4
|
import { i as codeEditorInput, n as CodeEmbedInput, r as CodeEditorInput, t as defineCodeEmbedType } from "./codeEmbedType-1bEOTxBT.js";
|
|
5
5
|
import { createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import { ToolLink, defineField, definePlugin, defineType, pathToString, set, unset, useClient, useCurrentUser, useFormValue, usePerspective, useSchema, useSetPerspective, useUser, useWorkspace } from "sanity";
|
|
@@ -8,7 +8,8 @@ import { ClockIcon } from "@sanity/icons/Clock";
|
|
|
8
8
|
import { ComponentIcon } from "@sanity/icons/Component";
|
|
9
9
|
import { DocumentsIcon } from "@sanity/icons/Documents";
|
|
10
10
|
import { ColorWheelIcon } from "@sanity/icons/ColorWheel";
|
|
11
|
-
import {
|
|
11
|
+
import { ImagesIcon } from "@sanity/icons/Images";
|
|
12
|
+
import { Badge, Box, Button, Card, Checkbox, Container, Dialog, Flex, Grid, Label, Select, Spinner, Stack, Tab, TabList, TabPanel, Text, TextArea, TextInput } from "@sanity/ui";
|
|
12
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
import { IntentLink, useRouter } from "sanity/router";
|
|
14
15
|
import { EyeOpenIcon } from "@sanity/icons/EyeOpen";
|
|
@@ -36,9 +37,14 @@ import { ControlsIcon } from "@sanity/icons/Controls";
|
|
|
36
37
|
import { Background, Controls, Handle, MarkerType, MiniMap, NodeResizer, Position, ReactFlow, ReactFlowProvider, useEdgesState, useNodesState, useReactFlow, useViewport } from "@xyflow/react";
|
|
37
38
|
import "@xyflow/react/dist/style.css";
|
|
38
39
|
import { TrashIcon } from "@sanity/icons/Trash";
|
|
40
|
+
import { EditIcon } from "@sanity/icons/Edit";
|
|
39
41
|
import { RefreshIcon } from "@sanity/icons/Refresh";
|
|
40
42
|
import { RestoreIcon } from "@sanity/icons/Restore";
|
|
41
43
|
import { UndoIcon } from "@sanity/icons/Undo";
|
|
44
|
+
import { FolderIcon } from "@sanity/icons/Folder";
|
|
45
|
+
import { ThLargeIcon } from "@sanity/icons/ThLarge";
|
|
46
|
+
import { ThListIcon } from "@sanity/icons/ThList";
|
|
47
|
+
import { DocumentIcon } from "@sanity/icons/Document";
|
|
42
48
|
import { Tooltip } from "@sanity/ui/tooltip";
|
|
43
49
|
import { EyeClosedIcon } from "@sanity/icons/EyeClosed";
|
|
44
50
|
import { usePresentationNavigate, usePresentationParams } from "sanity/presentation";
|
|
@@ -162,7 +168,139 @@ const TRANSLATION_TODO_TYPE = "ncfTranslationTodo", translationTodoId = (documen
|
|
|
162
168
|
select: { title: "documentId" },
|
|
163
169
|
prepare: ({ title }) => ({ title: `To translate: ${title}` })
|
|
164
170
|
}
|
|
165
|
-
}),
|
|
171
|
+
}), ASSET_META_TYPE = "ncfAssetMeta", ASSET_META_ID = "ncfAssetMeta", ASSET_FOLDER_TYPE = "ncfAssetFolder", ASSET_ASSIGNMENT_TYPE = "ncfAssetAssignment", assetFolderType = defineType({
|
|
172
|
+
name: ASSET_FOLDER_TYPE,
|
|
173
|
+
title: "Asset folder",
|
|
174
|
+
type: "object",
|
|
175
|
+
fields: [
|
|
176
|
+
defineField({
|
|
177
|
+
name: "id",
|
|
178
|
+
title: "Id",
|
|
179
|
+
type: "string"
|
|
180
|
+
}),
|
|
181
|
+
defineField({
|
|
182
|
+
name: "name",
|
|
183
|
+
title: "Name",
|
|
184
|
+
type: "string"
|
|
185
|
+
}),
|
|
186
|
+
defineField({
|
|
187
|
+
name: "parent",
|
|
188
|
+
title: "Parent",
|
|
189
|
+
type: "string"
|
|
190
|
+
})
|
|
191
|
+
],
|
|
192
|
+
preview: { select: {
|
|
193
|
+
title: "name",
|
|
194
|
+
subtitle: "id"
|
|
195
|
+
} }
|
|
196
|
+
}), assetAssignmentType = defineType({
|
|
197
|
+
name: ASSET_ASSIGNMENT_TYPE,
|
|
198
|
+
title: "Asset folder assignment",
|
|
199
|
+
type: "object",
|
|
200
|
+
fields: [defineField({
|
|
201
|
+
name: "folder",
|
|
202
|
+
title: "Folder",
|
|
203
|
+
type: "string"
|
|
204
|
+
})],
|
|
205
|
+
preview: { select: { title: "folder" } }
|
|
206
|
+
}), assetMetaSchemaTypes = [
|
|
207
|
+
defineType({
|
|
208
|
+
name: ASSET_META_TYPE,
|
|
209
|
+
title: "Asset organization (NCF)",
|
|
210
|
+
type: "document",
|
|
211
|
+
fields: [
|
|
212
|
+
defineField({
|
|
213
|
+
name: "folders",
|
|
214
|
+
title: "Folders",
|
|
215
|
+
type: "array",
|
|
216
|
+
of: [{ type: ASSET_FOLDER_TYPE }]
|
|
217
|
+
}),
|
|
218
|
+
defineField({
|
|
219
|
+
name: "assignments",
|
|
220
|
+
title: "Folder assignments",
|
|
221
|
+
type: "array",
|
|
222
|
+
of: [{ type: ASSET_ASSIGNMENT_TYPE }]
|
|
223
|
+
}),
|
|
224
|
+
defineField({
|
|
225
|
+
name: "updatedBy",
|
|
226
|
+
title: "Modified by",
|
|
227
|
+
type: "string",
|
|
228
|
+
readOnly: !0
|
|
229
|
+
})
|
|
230
|
+
],
|
|
231
|
+
preview: { prepare: () => ({ title: "Asset organization (NCF)" }) }
|
|
232
|
+
}),
|
|
233
|
+
assetFolderType,
|
|
234
|
+
assetAssignmentType
|
|
235
|
+
], COMPONENT_META_TYPE = "ncfComponentMeta", COMPONENT_META_ID = "ncfComponentMeta", COMPONENT_GROUP_TYPE = "ncfComponentGroup", COMPONENT_ENTRY_TYPE = "ncfComponentEntry", componentGroupType = defineType({
|
|
236
|
+
name: COMPONENT_GROUP_TYPE,
|
|
237
|
+
title: "Component group",
|
|
238
|
+
type: "object",
|
|
239
|
+
fields: [defineField({
|
|
240
|
+
name: "id",
|
|
241
|
+
title: "Id",
|
|
242
|
+
type: "string"
|
|
243
|
+
}), defineField({
|
|
244
|
+
name: "name",
|
|
245
|
+
title: "Name",
|
|
246
|
+
type: "string"
|
|
247
|
+
})],
|
|
248
|
+
preview: { select: {
|
|
249
|
+
title: "name",
|
|
250
|
+
subtitle: "id"
|
|
251
|
+
} }
|
|
252
|
+
}), componentEntryType = defineType({
|
|
253
|
+
name: COMPONENT_ENTRY_TYPE,
|
|
254
|
+
title: "Component organization",
|
|
255
|
+
type: "object",
|
|
256
|
+
fields: [defineField({
|
|
257
|
+
name: "name",
|
|
258
|
+
title: "Custom name",
|
|
259
|
+
type: "string"
|
|
260
|
+
}), defineField({
|
|
261
|
+
name: "group",
|
|
262
|
+
title: "Group",
|
|
263
|
+
type: "string"
|
|
264
|
+
})],
|
|
265
|
+
preview: { select: {
|
|
266
|
+
title: "name",
|
|
267
|
+
subtitle: "group"
|
|
268
|
+
} }
|
|
269
|
+
}), componentMetaSchemaTypes = [
|
|
270
|
+
defineType({
|
|
271
|
+
name: COMPONENT_META_TYPE,
|
|
272
|
+
title: "Component organization (NCF)",
|
|
273
|
+
type: "document",
|
|
274
|
+
fields: [
|
|
275
|
+
defineField({
|
|
276
|
+
name: "groups",
|
|
277
|
+
title: "Groups",
|
|
278
|
+
type: "array",
|
|
279
|
+
of: [{ type: COMPONENT_GROUP_TYPE }]
|
|
280
|
+
}),
|
|
281
|
+
defineField({
|
|
282
|
+
name: "components",
|
|
283
|
+
title: "Components",
|
|
284
|
+
type: "array",
|
|
285
|
+
of: [{ type: COMPONENT_ENTRY_TYPE }]
|
|
286
|
+
}),
|
|
287
|
+
defineField({
|
|
288
|
+
name: "updatedBy",
|
|
289
|
+
title: "Modified by",
|
|
290
|
+
type: "string",
|
|
291
|
+
readOnly: !0
|
|
292
|
+
})
|
|
293
|
+
],
|
|
294
|
+
preview: { prepare: () => ({ title: "Component organization (NCF)" }) }
|
|
295
|
+
}),
|
|
296
|
+
componentGroupType,
|
|
297
|
+
componentEntryType
|
|
298
|
+
], BOARD_LAYOUT_TYPE = "ncfBoardLayout", BOARD_LAYOUT_ID = "ncfBoardLayout", BOARD_NODE_TYPE = "ncfBoardNode", SECTION_NODE_TYPE = "ncfSectionNode", NODE_FIELD_TYPE = "ncfNodeField", COLUMN_TYPE = "ncfColumn", COLUMN_OPTION_TYPE = "ncfColumnOption", ANNOTATION_TYPE = "ncfAnnotation", NCF_HIDDEN_TYPES = [
|
|
299
|
+
BOARD_LAYOUT_TYPE,
|
|
300
|
+
TRANSLATION_TODO_TYPE,
|
|
301
|
+
ASSET_META_TYPE,
|
|
302
|
+
COMPONENT_META_TYPE
|
|
303
|
+
], boardNodeType = defineType({
|
|
166
304
|
name: BOARD_NODE_TYPE,
|
|
167
305
|
title: "Page position",
|
|
168
306
|
type: "object",
|
|
@@ -442,7 +580,9 @@ const TRANSLATION_TODO_TYPE = "ncfTranslationTodo", translationTodoId = (documen
|
|
|
442
580
|
nodeFieldType,
|
|
443
581
|
columnType,
|
|
444
582
|
columnOptionType,
|
|
445
|
-
annotationType
|
|
583
|
+
annotationType,
|
|
584
|
+
...assetMetaSchemaTypes,
|
|
585
|
+
...componentMetaSchemaTypes
|
|
446
586
|
], isKitType = (typeName) => NCF_HIDDEN_TYPES.includes(typeName), IGNORED_PREFIXES = [
|
|
447
587
|
"//",
|
|
448
588
|
"http://",
|
|
@@ -1266,7 +1406,7 @@ function explainGrantError(error) {
|
|
|
1266
1406
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1267
1407
|
* le vérifie.
|
|
1268
1408
|
*/
|
|
1269
|
-
const KIT_VERSION = "2.
|
|
1409
|
+
const KIT_VERSION = "2.51.0";
|
|
1270
1410
|
/**
|
|
1271
1411
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1272
1412
|
*
|
|
@@ -1764,7 +1904,7 @@ function useKitUpdate() {
|
|
|
1764
1904
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1765
1905
|
}).catch(() => {}), () => controller.abort();
|
|
1766
1906
|
}, []);
|
|
1767
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.
|
|
1907
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.51.0") > 0);
|
|
1768
1908
|
return {
|
|
1769
1909
|
current: KIT_VERSION,
|
|
1770
1910
|
latest,
|
|
@@ -4995,7 +5135,7 @@ function ColumnVisibility(props) {
|
|
|
4995
5135
|
})
|
|
4996
5136
|
});
|
|
4997
5137
|
}
|
|
4998
|
-
function Row(props) {
|
|
5138
|
+
function Row$1(props) {
|
|
4999
5139
|
return /* @__PURE__ */ jsxs(Flex, {
|
|
5000
5140
|
align: "center",
|
|
5001
5141
|
gap: 2,
|
|
@@ -5040,7 +5180,7 @@ function DataColumnList(props) {
|
|
|
5040
5180
|
}, [dataColumns, filter]);
|
|
5041
5181
|
return /* @__PURE__ */ jsxs(Stack, {
|
|
5042
5182
|
gap: 0,
|
|
5043
|
-
children: [HIDEABLE.map((column) => /* @__PURE__ */ jsx(Row, {
|
|
5183
|
+
children: [HIDEABLE.map((column) => /* @__PURE__ */ jsx(Row$1, {
|
|
5044
5184
|
label: column.label,
|
|
5045
5185
|
checked: !hidden.has(column.key),
|
|
5046
5186
|
onClick: () => onToggle(column.key)
|
|
@@ -5077,7 +5217,7 @@ function DataColumnList(props) {
|
|
|
5077
5217
|
}
|
|
5078
5218
|
})
|
|
5079
5219
|
}),
|
|
5080
|
-
matches.map((column) => /* @__PURE__ */ jsx(Row, {
|
|
5220
|
+
matches.map((column) => /* @__PURE__ */ jsx(Row$1, {
|
|
5081
5221
|
label: column.label,
|
|
5082
5222
|
checked: shownData.has(column.key),
|
|
5083
5223
|
onClick: () => onToggleData(column.key)
|
|
@@ -6686,6 +6826,43 @@ function componentIntentParams(type, namespace, preview, documentId) {
|
|
|
6686
6826
|
preview: fillTemplate(preview.live, type, namespace)
|
|
6687
6827
|
};
|
|
6688
6828
|
}
|
|
6829
|
+
/** Map type -> nom personnalisé (ignore les vides). */
|
|
6830
|
+
function nameMap(entries) {
|
|
6831
|
+
let map = /* @__PURE__ */ new Map();
|
|
6832
|
+
for (let entry of entries) entry.name?.trim() && map.set(entry.type, entry.name.trim());
|
|
6833
|
+
return map;
|
|
6834
|
+
}
|
|
6835
|
+
/** Map type -> id de groupe (ignore les vides). */
|
|
6836
|
+
function groupMap(entries) {
|
|
6837
|
+
let map = /* @__PURE__ */ new Map();
|
|
6838
|
+
for (let entry of entries) entry.group && map.set(entry.type, entry.group);
|
|
6839
|
+
return map;
|
|
6840
|
+
}
|
|
6841
|
+
/** Applique le nom marketing au `title` d'un composant (garde `name`/type). */
|
|
6842
|
+
function withCustomNames(blocks, names) {
|
|
6843
|
+
return blocks.map((block) => names.has(block.name) ? {
|
|
6844
|
+
...block,
|
|
6845
|
+
title: names.get(block.name)
|
|
6846
|
+
} : block);
|
|
6847
|
+
}
|
|
6848
|
+
/** Répartit les composants par groupe (ordre des groupes préservé). */
|
|
6849
|
+
function groupComponents(blocks, groupOf, groups) {
|
|
6850
|
+
let byGroup = /* @__PURE__ */ new Map(), ungrouped = [];
|
|
6851
|
+
for (let block of blocks) {
|
|
6852
|
+
let group = groupOf.get(block.name);
|
|
6853
|
+
if (group && groups.some((g) => g.id === group)) {
|
|
6854
|
+
let list = byGroup.get(group) ?? [];
|
|
6855
|
+
list.push(block), byGroup.set(group, list);
|
|
6856
|
+
} else ungrouped.push(block);
|
|
6857
|
+
}
|
|
6858
|
+
return {
|
|
6859
|
+
grouped: groups.map((group) => ({
|
|
6860
|
+
group,
|
|
6861
|
+
blocks: byGroup.get(group.id) ?? []
|
|
6862
|
+
})),
|
|
6863
|
+
ungrouped
|
|
6864
|
+
};
|
|
6865
|
+
}
|
|
6689
6866
|
/**
|
|
6690
6867
|
* Ouvre un composant : Presentation avec son rendu réel et ses valeurs par
|
|
6691
6868
|
* défaut côte à côte (le document des valeurs par défaut, champ du composant).
|
|
@@ -6752,6 +6929,126 @@ function useOpenComponent() {
|
|
|
6752
6929
|
]);
|
|
6753
6930
|
return !hasDefaults && !config.previewUrl ? null : (type) => void open(type);
|
|
6754
6931
|
}
|
|
6932
|
+
const newId$1 = () => `g${Math.random().toString(36).slice(2, 10)}`;
|
|
6933
|
+
/**
|
|
6934
|
+
* Lit et écrit l'organisation des composants (groupes + noms marketing) dans le
|
|
6935
|
+
* singleton du kit `ncfComponentMeta`. Même principe que l'organisation des
|
|
6936
|
+
* assets : document unique réécrit en entier, écriture débouncée, optimiste.
|
|
6937
|
+
* À appeler UNE fois (via `ComponentMetaProvider`).
|
|
6938
|
+
*/
|
|
6939
|
+
function useComponentMetaState() {
|
|
6940
|
+
let client = useKitClient(), user = useCurrentUser(), [groups, setGroups] = useState([]), [entries, setEntries] = useState([]), [loading, setLoading] = useState(!0), [saveError, setSaveError] = useState(null);
|
|
6941
|
+
useEffect(() => {
|
|
6942
|
+
let cancelled = !1;
|
|
6943
|
+
return client.fetch("*[_id == $id][0]{groups, components}", { id: COMPONENT_META_ID }).then((doc) => {
|
|
6944
|
+
cancelled || (setGroups((doc?.groups ?? []).filter((g) => g.id && g.name).map((g) => ({
|
|
6945
|
+
id: g.id,
|
|
6946
|
+
name: g.name
|
|
6947
|
+
}))), setEntries((doc?.components ?? []).filter((c) => !!c._key).map((c) => ({
|
|
6948
|
+
type: c._key,
|
|
6949
|
+
...c.name ? { name: c.name } : {},
|
|
6950
|
+
...c.group ? { group: c.group } : {}
|
|
6951
|
+
}))));
|
|
6952
|
+
}).catch(() => {
|
|
6953
|
+
cancelled || (setGroups([]), setEntries([]));
|
|
6954
|
+
}).finally(() => {
|
|
6955
|
+
cancelled || setLoading(!1);
|
|
6956
|
+
}), () => {
|
|
6957
|
+
cancelled = !0;
|
|
6958
|
+
};
|
|
6959
|
+
}, [client]);
|
|
6960
|
+
let timer = useRef(void 0);
|
|
6961
|
+
useEffect(() => () => {
|
|
6962
|
+
timer.current && clearTimeout(timer.current);
|
|
6963
|
+
}, []);
|
|
6964
|
+
let groupsRef = useRef([]), entriesRef = useRef([]);
|
|
6965
|
+
groupsRef.current = groups, entriesRef.current = entries;
|
|
6966
|
+
let write = useCallback((next) => {
|
|
6967
|
+
let nextGroups = next?.groups ?? groupsRef.current, nextEntries = next?.entries ?? entriesRef.current;
|
|
6968
|
+
timer.current && clearTimeout(timer.current), timer.current = setTimeout(() => {
|
|
6969
|
+
client.createOrReplace({
|
|
6970
|
+
_id: COMPONENT_META_ID,
|
|
6971
|
+
_type: COMPONENT_META_TYPE,
|
|
6972
|
+
groups: nextGroups.map((group) => ({
|
|
6973
|
+
_key: group.id,
|
|
6974
|
+
_type: COMPONENT_GROUP_TYPE,
|
|
6975
|
+
id: group.id,
|
|
6976
|
+
name: group.name
|
|
6977
|
+
})),
|
|
6978
|
+
components: nextEntries.filter((entry) => entry.name || entry.group).map((entry) => ({
|
|
6979
|
+
_key: entry.type,
|
|
6980
|
+
_type: COMPONENT_ENTRY_TYPE,
|
|
6981
|
+
...entry.name ? { name: entry.name } : {},
|
|
6982
|
+
...entry.group ? { group: entry.group } : {}
|
|
6983
|
+
})),
|
|
6984
|
+
updatedBy: user?.id ?? null
|
|
6985
|
+
}).then(() => setSaveError(null)).catch((cause) => setSaveError(cause instanceof Error ? cause : Error(String(cause))));
|
|
6986
|
+
}, 800);
|
|
6987
|
+
}, [client, user?.id]), patchEntry = useCallback((type, patch) => {
|
|
6988
|
+
let merged = {
|
|
6989
|
+
...entriesRef.current.find((entry) => entry.type === type) ?? { type },
|
|
6990
|
+
...patch
|
|
6991
|
+
}, cleaned = {
|
|
6992
|
+
type,
|
|
6993
|
+
...merged.name ? { name: merged.name } : {},
|
|
6994
|
+
...merged.group ? { group: merged.group } : {}
|
|
6995
|
+
}, others = entriesRef.current.filter((entry) => entry.type !== type), next = cleaned.name || cleaned.group ? [...others, cleaned] : others;
|
|
6996
|
+
setEntries(next), write({ entries: next });
|
|
6997
|
+
}, [write]), createGroup = useCallback((name) => {
|
|
6998
|
+
let id = newId$1(), next = [...groupsRef.current, {
|
|
6999
|
+
id,
|
|
7000
|
+
name: name.trim() || "Groupe"
|
|
7001
|
+
}];
|
|
7002
|
+
return setGroups(next), write({ groups: next }), id;
|
|
7003
|
+
}, [write]), renameGroup = useCallback((id, name) => {
|
|
7004
|
+
let next = groupsRef.current.map((group) => group.id === id ? {
|
|
7005
|
+
...group,
|
|
7006
|
+
name: name.trim() || group.name
|
|
7007
|
+
} : group);
|
|
7008
|
+
setGroups(next), write({ groups: next });
|
|
7009
|
+
}, [write]), deleteGroup = useCallback((id) => {
|
|
7010
|
+
let nextGroups = groupsRef.current.filter((group) => group.id !== id), nextEntries = entriesRef.current.map((entry) => entry.group === id ? {
|
|
7011
|
+
...entry,
|
|
7012
|
+
group: void 0
|
|
7013
|
+
} : entry).filter((entry) => entry.name || entry.group);
|
|
7014
|
+
setGroups(nextGroups), setEntries(nextEntries), write({
|
|
7015
|
+
groups: nextGroups,
|
|
7016
|
+
entries: nextEntries
|
|
7017
|
+
});
|
|
7018
|
+
}, [write]), renameComponent = useCallback((type, name) => patchEntry(type, { name: name?.trim() || void 0 }), [patchEntry]), setGroup = useCallback((type, group) => patchEntry(type, { group: group ?? void 0 }), [patchEntry]);
|
|
7019
|
+
return {
|
|
7020
|
+
groups,
|
|
7021
|
+
entries,
|
|
7022
|
+
names: useMemo(() => nameMap(entries), [entries]),
|
|
7023
|
+
groupOf: useMemo(() => groupMap(entries), [entries]),
|
|
7024
|
+
loading,
|
|
7025
|
+
saveError,
|
|
7026
|
+
createGroup,
|
|
7027
|
+
renameGroup,
|
|
7028
|
+
deleteGroup,
|
|
7029
|
+
renameComponent,
|
|
7030
|
+
setGroup
|
|
7031
|
+
};
|
|
7032
|
+
}
|
|
7033
|
+
const ComponentMetaContext = createContext(null);
|
|
7034
|
+
/**
|
|
7035
|
+
* Une seule instance de l'organisation des composants dans l'onglet.
|
|
7036
|
+
*
|
|
7037
|
+
* Le document `ncfComponentMeta` est réécrit en entier à chaque enregistrement :
|
|
7038
|
+
* deux instances s'écraseraient (renommer effacerait un groupe, etc.).
|
|
7039
|
+
*/
|
|
7040
|
+
function ComponentMetaProvider(props) {
|
|
7041
|
+
let value = useComponentMetaState();
|
|
7042
|
+
return /* @__PURE__ */ jsx(ComponentMetaContext.Provider, {
|
|
7043
|
+
value,
|
|
7044
|
+
children: props.children
|
|
7045
|
+
});
|
|
7046
|
+
}
|
|
7047
|
+
function useComponentMeta() {
|
|
7048
|
+
let value = useContext(ComponentMetaContext);
|
|
7049
|
+
if (!value) throw Error("useComponentMeta must be called inside ComponentMetaProvider.");
|
|
7050
|
+
return value;
|
|
7051
|
+
}
|
|
6755
7052
|
/**
|
|
6756
7053
|
* Tuile d'un bloc dans la grille.
|
|
6757
7054
|
*
|
|
@@ -6761,24 +7058,51 @@ function useOpenComponent() {
|
|
|
6761
7058
|
* à le lire.
|
|
6762
7059
|
*/
|
|
6763
7060
|
function BlockCard(props) {
|
|
6764
|
-
let { block, occurrence, namespace, thumbnailUrl, onOpen } = props, [failed, setFailed] = useState(!1), unused = occurrence.count === 0;
|
|
6765
|
-
return /* @__PURE__ */
|
|
7061
|
+
let { block, occurrence, namespace, thumbnailUrl, onOpen, onEdit } = props, [failed, setFailed] = useState(!1), unused = occurrence.count === 0;
|
|
7062
|
+
return /* @__PURE__ */ jsxs(Card, {
|
|
6766
7063
|
radius: 3,
|
|
6767
7064
|
shadow: 1,
|
|
6768
7065
|
padding: 0,
|
|
6769
|
-
as: onOpen ? "button" : void 0,
|
|
6770
|
-
onClick: onOpen,
|
|
6771
|
-
title: onOpen ? "See the real component and set its default values" : void 0,
|
|
6772
7066
|
style: {
|
|
6773
7067
|
height: "100%",
|
|
6774
7068
|
overflow: "hidden",
|
|
6775
|
-
|
|
6776
|
-
textAlign: "left",
|
|
6777
|
-
cursor: onOpen ? "pointer" : void 0
|
|
7069
|
+
position: "relative"
|
|
6778
7070
|
},
|
|
6779
|
-
children: /* @__PURE__ */
|
|
7071
|
+
children: [onEdit ? /* @__PURE__ */ jsx(Box, {
|
|
7072
|
+
style: {
|
|
7073
|
+
position: "absolute",
|
|
7074
|
+
top: 6,
|
|
7075
|
+
right: 6,
|
|
7076
|
+
zIndex: 1
|
|
7077
|
+
},
|
|
7078
|
+
onClick: (event) => event.stopPropagation(),
|
|
7079
|
+
children: /* @__PURE__ */ jsx(Card, {
|
|
7080
|
+
radius: 2,
|
|
7081
|
+
shadow: 1,
|
|
7082
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
7083
|
+
icon: EditIcon,
|
|
7084
|
+
mode: "bleed",
|
|
7085
|
+
padding: 2,
|
|
7086
|
+
fontSize: 1,
|
|
7087
|
+
title: "Renommer / ranger",
|
|
7088
|
+
"aria-label": "Renommer / ranger",
|
|
7089
|
+
onClick: onEdit
|
|
7090
|
+
})
|
|
7091
|
+
})
|
|
7092
|
+
}) : null, /* @__PURE__ */ jsxs(Stack, {
|
|
6780
7093
|
gap: 0,
|
|
6781
|
-
|
|
7094
|
+
as: onOpen ? "button" : void 0,
|
|
7095
|
+
onClick: onOpen,
|
|
7096
|
+
title: onOpen ? "See the real component and set its default values" : void 0,
|
|
7097
|
+
style: {
|
|
7098
|
+
height: "100%",
|
|
7099
|
+
width: "100%",
|
|
7100
|
+
textAlign: "left",
|
|
7101
|
+
cursor: onOpen ? "pointer" : void 0,
|
|
7102
|
+
background: "transparent",
|
|
7103
|
+
border: 0,
|
|
7104
|
+
padding: 0
|
|
7105
|
+
},
|
|
6782
7106
|
children: [/* @__PURE__ */ jsx(Box, {
|
|
6783
7107
|
style: {
|
|
6784
7108
|
aspectRatio: "16 / 10",
|
|
@@ -6843,6 +7167,88 @@ function BlockCard(props) {
|
|
|
6843
7167
|
})]
|
|
6844
7168
|
})
|
|
6845
7169
|
})]
|
|
7170
|
+
})]
|
|
7171
|
+
});
|
|
7172
|
+
}
|
|
7173
|
+
/** Renommer un composant (nom marketing) et le ranger dans un groupe. */
|
|
7174
|
+
function ComponentEditDialog(props) {
|
|
7175
|
+
let { block, namespace, currentName, currentGroup, groups, onSave, onClose } = props, [name, setName] = useState(currentName), [group, setGroup] = useState(currentGroup ?? ""), save = () => {
|
|
7176
|
+
onSave(name.trim() || null, group || null), onClose();
|
|
7177
|
+
};
|
|
7178
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
7179
|
+
id: "component-edit",
|
|
7180
|
+
header: "Renommer / ranger le composant",
|
|
7181
|
+
onClose,
|
|
7182
|
+
width: 0,
|
|
7183
|
+
footer: /* @__PURE__ */ jsxs(Flex, {
|
|
7184
|
+
justify: "flex-end",
|
|
7185
|
+
gap: 2,
|
|
7186
|
+
padding: 2,
|
|
7187
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
7188
|
+
text: "Annuler",
|
|
7189
|
+
mode: "bleed",
|
|
7190
|
+
onClick: onClose
|
|
7191
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
7192
|
+
text: "Enregistrer",
|
|
7193
|
+
tone: "primary",
|
|
7194
|
+
onClick: save
|
|
7195
|
+
})]
|
|
7196
|
+
}),
|
|
7197
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
7198
|
+
padding: 4,
|
|
7199
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
7200
|
+
gap: 4,
|
|
7201
|
+
children: [
|
|
7202
|
+
/* @__PURE__ */ jsx(Text, {
|
|
7203
|
+
size: 0,
|
|
7204
|
+
muted: !0,
|
|
7205
|
+
style: MONO,
|
|
7206
|
+
children: blockName(block.name, namespace)
|
|
7207
|
+
}),
|
|
7208
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
7209
|
+
gap: 2,
|
|
7210
|
+
children: [
|
|
7211
|
+
/* @__PURE__ */ jsx(Label, {
|
|
7212
|
+
size: 0,
|
|
7213
|
+
muted: !0,
|
|
7214
|
+
children: "Nom affiché"
|
|
7215
|
+
}),
|
|
7216
|
+
/* @__PURE__ */ jsx(TextInput, {
|
|
7217
|
+
value: name,
|
|
7218
|
+
autoFocus: !0,
|
|
7219
|
+
placeholder: humanizeBlockName(block.name, namespace),
|
|
7220
|
+
onChange: (event) => setName(event.currentTarget.value),
|
|
7221
|
+
onKeyDown: (event) => {
|
|
7222
|
+
event.key === "Enter" && save();
|
|
7223
|
+
}
|
|
7224
|
+
}),
|
|
7225
|
+
/* @__PURE__ */ jsx(Text, {
|
|
7226
|
+
size: 0,
|
|
7227
|
+
muted: !0,
|
|
7228
|
+
children: "Ce nom remplace le titre partout (onglet, board, menu d'insertion). Vide = titre d'origine."
|
|
7229
|
+
})
|
|
7230
|
+
]
|
|
7231
|
+
}),
|
|
7232
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
7233
|
+
gap: 2,
|
|
7234
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
7235
|
+
size: 0,
|
|
7236
|
+
muted: !0,
|
|
7237
|
+
children: "Groupe"
|
|
7238
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
7239
|
+
value: group,
|
|
7240
|
+
onChange: (event) => setGroup(event.currentTarget.value),
|
|
7241
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
7242
|
+
value: "",
|
|
7243
|
+
children: "Non groupé"
|
|
7244
|
+
}), groups.map((g) => /* @__PURE__ */ jsx("option", {
|
|
7245
|
+
value: g.id,
|
|
7246
|
+
children: g.name
|
|
7247
|
+
}, g.id))]
|
|
7248
|
+
})]
|
|
7249
|
+
})
|
|
7250
|
+
]
|
|
7251
|
+
})
|
|
6846
7252
|
})
|
|
6847
7253
|
});
|
|
6848
7254
|
}
|
|
@@ -7308,22 +7714,34 @@ const ORDERS = [
|
|
|
7308
7714
|
label: "Schema order"
|
|
7309
7715
|
}
|
|
7310
7716
|
];
|
|
7717
|
+
/** Outil Composants, sous son provider d'organisation (groupes + noms). */
|
|
7311
7718
|
function ComponentsTool() {
|
|
7312
|
-
|
|
7313
|
-
|
|
7719
|
+
return /* @__PURE__ */ jsx(ComponentMetaProvider, { children: /* @__PURE__ */ jsx(ComponentsToolInner, {}) });
|
|
7720
|
+
}
|
|
7721
|
+
function ComponentsToolInner() {
|
|
7722
|
+
let config = useKitConfig(), meta = useComponentMeta(), { blockTypes, occurrences, pagesById, truncated, scanned, loading, error, refresh } = useOccurrences(), [order, setOrder] = useState("type"), [view, setView] = useState("grid"), [grouped, setGrouped] = useState(!1), [editing, setEditing] = useState(null), [groupDialog, setGroupDialog] = useState(null), [deletingGroup, setDeletingGroup] = useState(null), preview = config.componentPreview, canPreview = preview.provider === "designSystemPage" && !!config.previewUrl, openComponent = useOpenComponent(), named = useMemo(() => withCustomNames(blockTypes, meta.names), [blockTypes, meta.names]), cards = useMemo(() => {
|
|
7723
|
+
let byName = new Map(named.map((b) => [b.name, b])), rows = occurrences.map((occurrence) => ({
|
|
7314
7724
|
occurrence,
|
|
7315
7725
|
block: byName.get(occurrence.type)
|
|
7316
7726
|
})).filter((row) => !!row.block);
|
|
7317
|
-
return order === "schema" ? rows : order === "type" ? [...rows].sort((a, b) => a.block.
|
|
7727
|
+
return order === "schema" ? rows : order === "type" ? [...rows].sort((a, b) => a.block.title.localeCompare(b.block.title, "fr", { sensitivity: "base" })) : order === "unused" ? [...rows].sort((a, b) => a.occurrence.count - b.occurrence.count) : [...rows].sort((a, b) => b.occurrence.count - a.occurrence.count);
|
|
7318
7728
|
}, [
|
|
7319
7729
|
occurrences,
|
|
7320
|
-
|
|
7730
|
+
named,
|
|
7321
7731
|
order
|
|
7322
|
-
]), unusedCount = occurrences.filter((o) => o.count === 0).length
|
|
7323
|
-
|
|
7732
|
+
]), unusedCount = occurrences.filter((o) => o.count === 0).length, editingBlock = editing ? named.find((b) => b.name === editing) : void 0, renderCard = (card) => /* @__PURE__ */ jsx(BlockCard, {
|
|
7733
|
+
block: card.block,
|
|
7734
|
+
occurrence: card.occurrence,
|
|
7735
|
+
namespace: config.blockNamespace,
|
|
7736
|
+
thumbnailUrl: canPreview ? `${config.previewUrl}${fillTemplate(preview.thumbnail, card.block.name, config.blockNamespace)}` : null,
|
|
7737
|
+
onOpen: openComponent ? () => openComponent(card.block.name) : void 0,
|
|
7738
|
+
onEdit: () => setEditing(card.block.name)
|
|
7739
|
+
}, card.block.name);
|
|
7740
|
+
if (error) return /* @__PURE__ */ jsx(QueryError, {
|
|
7324
7741
|
error,
|
|
7325
7742
|
onRetry: refresh
|
|
7326
|
-
})
|
|
7743
|
+
});
|
|
7744
|
+
if (loading && blockTypes.length === 0) return /* @__PURE__ */ jsxs(Flex, {
|
|
7327
7745
|
align: "center",
|
|
7328
7746
|
justify: "center",
|
|
7329
7747
|
padding: 5,
|
|
@@ -7333,7 +7751,8 @@ function ComponentsTool() {
|
|
|
7333
7751
|
muted: !0,
|
|
7334
7752
|
children: "Analyzing the page builder…"
|
|
7335
7753
|
})]
|
|
7336
|
-
})
|
|
7754
|
+
});
|
|
7755
|
+
if (blockTypes.length === 0) return /* @__PURE__ */ jsx(Card, {
|
|
7337
7756
|
padding: 4,
|
|
7338
7757
|
radius: 3,
|
|
7339
7758
|
shadow: 1,
|
|
@@ -7348,31 +7767,55 @@ function ComponentsTool() {
|
|
|
7348
7767
|
children: [
|
|
7349
7768
|
"The field \"",
|
|
7350
7769
|
config.pageBuilderField,
|
|
7351
|
-
"\" does not exist on any of the types",
|
|
7352
|
-
" ",
|
|
7770
|
+
"\" does not exist on any of the types ",
|
|
7353
7771
|
config.pageTypeNames.join(", "),
|
|
7354
|
-
", or it is not an array.
|
|
7772
|
+
", or it is not an array."
|
|
7355
7773
|
]
|
|
7356
7774
|
})]
|
|
7357
7775
|
})
|
|
7358
|
-
})
|
|
7776
|
+
});
|
|
7777
|
+
let grouping = grouped ? groupComponents(cards.map((c) => c.block), meta.groupOf, meta.groups) : null, cardByName = new Map(cards.map((c) => [c.block.name, c]));
|
|
7778
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
7359
7779
|
gap: 4,
|
|
7360
7780
|
children: [
|
|
7361
7781
|
/* @__PURE__ */ jsxs(Flex, {
|
|
7362
7782
|
gap: 2,
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7783
|
+
align: "center",
|
|
7784
|
+
wrap: "wrap",
|
|
7785
|
+
children: [
|
|
7786
|
+
/* @__PURE__ */ jsx(Button, {
|
|
7787
|
+
text: "Grid",
|
|
7788
|
+
mode: view === "grid" ? "default" : "ghost",
|
|
7789
|
+
fontSize: 1,
|
|
7790
|
+
padding: 2,
|
|
7791
|
+
onClick: () => setView("grid")
|
|
7792
|
+
}),
|
|
7793
|
+
/* @__PURE__ */ jsx(Button, {
|
|
7794
|
+
text: "Map",
|
|
7795
|
+
mode: view === "map" ? "default" : "ghost",
|
|
7796
|
+
fontSize: 1,
|
|
7797
|
+
padding: 2,
|
|
7798
|
+
onClick: () => setView("map")
|
|
7799
|
+
}),
|
|
7800
|
+
view === "grid" ? /* @__PURE__ */ jsx(Button, {
|
|
7801
|
+
text: "By group",
|
|
7802
|
+
mode: grouped ? "default" : "ghost",
|
|
7803
|
+
tone: grouped ? "primary" : "default",
|
|
7804
|
+
fontSize: 1,
|
|
7805
|
+
padding: 2,
|
|
7806
|
+
onClick: () => setGrouped((value) => !value)
|
|
7807
|
+
}) : null,
|
|
7808
|
+
grouped && view === "grid" ? /* @__PURE__ */ jsx(Button, {
|
|
7809
|
+
text: "New group",
|
|
7810
|
+
mode: "ghost",
|
|
7811
|
+
fontSize: 1,
|
|
7812
|
+
padding: 2,
|
|
7813
|
+
onClick: () => setGroupDialog({
|
|
7814
|
+
mode: "create",
|
|
7815
|
+
name: ""
|
|
7816
|
+
})
|
|
7817
|
+
}) : null
|
|
7818
|
+
]
|
|
7376
7819
|
}),
|
|
7377
7820
|
/* @__PURE__ */ jsxs(Flex, {
|
|
7378
7821
|
align: "center",
|
|
@@ -7433,10 +7876,85 @@ function ComponentsTool() {
|
|
|
7433
7876
|
})
|
|
7434
7877
|
}),
|
|
7435
7878
|
view === "map" ? /* @__PURE__ */ jsx(SectionsMap, {
|
|
7436
|
-
blockTypes,
|
|
7879
|
+
blockTypes: named,
|
|
7437
7880
|
occurrences,
|
|
7438
7881
|
pagesById,
|
|
7439
7882
|
order: order === "schema" ? "type" : order
|
|
7883
|
+
}) : grouping ? /* @__PURE__ */ jsxs(Stack, {
|
|
7884
|
+
gap: 5,
|
|
7885
|
+
children: [grouping.grouped.map(({ group, blocks }) => /* @__PURE__ */ jsxs(Stack, {
|
|
7886
|
+
gap: 3,
|
|
7887
|
+
children: [/* @__PURE__ */ jsxs(Flex, {
|
|
7888
|
+
align: "center",
|
|
7889
|
+
gap: 2,
|
|
7890
|
+
children: [
|
|
7891
|
+
/* @__PURE__ */ jsx(Text, {
|
|
7892
|
+
size: 2,
|
|
7893
|
+
weight: "semibold",
|
|
7894
|
+
children: group.name
|
|
7895
|
+
}),
|
|
7896
|
+
/* @__PURE__ */ jsx(Text, {
|
|
7897
|
+
size: 1,
|
|
7898
|
+
muted: !0,
|
|
7899
|
+
children: blocks.length
|
|
7900
|
+
}),
|
|
7901
|
+
/* @__PURE__ */ jsx(Box, { flex: 1 }),
|
|
7902
|
+
/* @__PURE__ */ jsx(Button, {
|
|
7903
|
+
icon: EditIcon,
|
|
7904
|
+
mode: "bleed",
|
|
7905
|
+
fontSize: 1,
|
|
7906
|
+
padding: 2,
|
|
7907
|
+
title: "Renommer le groupe",
|
|
7908
|
+
"aria-label": "Renommer le groupe",
|
|
7909
|
+
onClick: () => setGroupDialog({
|
|
7910
|
+
mode: "rename",
|
|
7911
|
+
id: group.id,
|
|
7912
|
+
name: group.name
|
|
7913
|
+
})
|
|
7914
|
+
}),
|
|
7915
|
+
/* @__PURE__ */ jsx(Button, {
|
|
7916
|
+
icon: TrashIcon,
|
|
7917
|
+
mode: "bleed",
|
|
7918
|
+
tone: "critical",
|
|
7919
|
+
fontSize: 1,
|
|
7920
|
+
padding: 2,
|
|
7921
|
+
title: "Supprimer le groupe",
|
|
7922
|
+
"aria-label": "Supprimer le groupe",
|
|
7923
|
+
onClick: () => setDeletingGroup(group)
|
|
7924
|
+
})
|
|
7925
|
+
]
|
|
7926
|
+
}), blocks.length ? /* @__PURE__ */ jsx(Grid, {
|
|
7927
|
+
gridTemplateColumns: [
|
|
7928
|
+
1,
|
|
7929
|
+
2,
|
|
7930
|
+
3,
|
|
7931
|
+
4
|
|
7932
|
+
],
|
|
7933
|
+
gap: 3,
|
|
7934
|
+
children: blocks.map((block) => cardByName.get(block.name)).filter((c) => !!c).map(renderCard)
|
|
7935
|
+
}) : /* @__PURE__ */ jsx(Text, {
|
|
7936
|
+
size: 1,
|
|
7937
|
+
muted: !0,
|
|
7938
|
+
children: "Aucun composant dans ce groupe."
|
|
7939
|
+
})]
|
|
7940
|
+
}, group.id)), /* @__PURE__ */ jsxs(Stack, {
|
|
7941
|
+
gap: 3,
|
|
7942
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
7943
|
+
size: 2,
|
|
7944
|
+
weight: "semibold",
|
|
7945
|
+
muted: !0,
|
|
7946
|
+
children: "Sans groupe"
|
|
7947
|
+
}), /* @__PURE__ */ jsx(Grid, {
|
|
7948
|
+
gridTemplateColumns: [
|
|
7949
|
+
1,
|
|
7950
|
+
2,
|
|
7951
|
+
3,
|
|
7952
|
+
4
|
|
7953
|
+
],
|
|
7954
|
+
gap: 3,
|
|
7955
|
+
children: grouping.ungrouped.map((block) => cardByName.get(block.name)).filter((c) => !!c).map(renderCard)
|
|
7956
|
+
})]
|
|
7957
|
+
})]
|
|
7440
7958
|
}) : /* @__PURE__ */ jsx(Grid, {
|
|
7441
7959
|
gridTemplateColumns: [
|
|
7442
7960
|
1,
|
|
@@ -7445,29 +7963,105 @@ function ComponentsTool() {
|
|
|
7445
7963
|
4
|
|
7446
7964
|
],
|
|
7447
7965
|
gap: 3,
|
|
7448
|
-
children: cards.map(
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
}
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7966
|
+
children: cards.map(renderCard)
|
|
7967
|
+
}),
|
|
7968
|
+
editingBlock ? /* @__PURE__ */ jsx(ComponentEditDialog, {
|
|
7969
|
+
block: editingBlock,
|
|
7970
|
+
namespace: config.blockNamespace,
|
|
7971
|
+
currentName: meta.names.get(editingBlock.name) ?? "",
|
|
7972
|
+
currentGroup: meta.groupOf.get(editingBlock.name) ?? null,
|
|
7973
|
+
groups: meta.groups,
|
|
7974
|
+
onSave: (name, group) => {
|
|
7975
|
+
meta.renameComponent(editingBlock.name, name), meta.setGroup(editingBlock.name, group);
|
|
7976
|
+
},
|
|
7977
|
+
onClose: () => setEditing(null)
|
|
7978
|
+
}) : null,
|
|
7979
|
+
groupDialog ? /* @__PURE__ */ jsx(Dialog, {
|
|
7980
|
+
id: "component-group-dialog",
|
|
7981
|
+
header: groupDialog.mode === "rename" ? "Renommer le groupe" : "Nouveau groupe",
|
|
7982
|
+
onClose: () => setGroupDialog(null),
|
|
7983
|
+
width: 0,
|
|
7984
|
+
footer: /* @__PURE__ */ jsxs(Flex, {
|
|
7985
|
+
justify: "flex-end",
|
|
7986
|
+
gap: 2,
|
|
7987
|
+
padding: 2,
|
|
7988
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
7989
|
+
text: "Annuler",
|
|
7990
|
+
mode: "bleed",
|
|
7991
|
+
onClick: () => setGroupDialog(null)
|
|
7992
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
7993
|
+
text: groupDialog.mode === "rename" ? "Renommer" : "Créer",
|
|
7994
|
+
tone: "primary",
|
|
7995
|
+
disabled: !groupDialog.name.trim(),
|
|
7996
|
+
onClick: () => {
|
|
7997
|
+
groupDialog.mode === "rename" && groupDialog.id ? meta.renameGroup(groupDialog.id, groupDialog.name) : meta.createGroup(groupDialog.name), setGroupDialog(null);
|
|
7998
|
+
}
|
|
7999
|
+
})]
|
|
8000
|
+
}),
|
|
8001
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
8002
|
+
padding: 4,
|
|
8003
|
+
children: /* @__PURE__ */ jsx(TextInput, {
|
|
8004
|
+
value: groupDialog.name,
|
|
8005
|
+
autoFocus: !0,
|
|
8006
|
+
placeholder: "Nom du groupe",
|
|
8007
|
+
onChange: (event) => setGroupDialog((d) => d && {
|
|
8008
|
+
...d,
|
|
8009
|
+
name: event.currentTarget.value
|
|
8010
|
+
}),
|
|
8011
|
+
onKeyDown: (event) => {
|
|
8012
|
+
event.key === "Enter" && groupDialog.name.trim() && (groupDialog.mode === "rename" && groupDialog.id ? meta.renameGroup(groupDialog.id, groupDialog.name) : meta.createGroup(groupDialog.name), setGroupDialog(null));
|
|
8013
|
+
}
|
|
8014
|
+
})
|
|
8015
|
+
})
|
|
8016
|
+
}) : null,
|
|
8017
|
+
deletingGroup ? /* @__PURE__ */ jsx(Dialog, {
|
|
8018
|
+
id: "component-group-delete",
|
|
8019
|
+
header: "Supprimer le groupe",
|
|
8020
|
+
onClose: () => setDeletingGroup(null),
|
|
8021
|
+
width: 0,
|
|
8022
|
+
footer: /* @__PURE__ */ jsxs(Flex, {
|
|
8023
|
+
justify: "flex-end",
|
|
8024
|
+
gap: 2,
|
|
8025
|
+
padding: 2,
|
|
8026
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
8027
|
+
text: "Annuler",
|
|
8028
|
+
mode: "bleed",
|
|
8029
|
+
onClick: () => setDeletingGroup(null)
|
|
8030
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
8031
|
+
text: "Supprimer",
|
|
8032
|
+
tone: "critical",
|
|
8033
|
+
onClick: () => {
|
|
8034
|
+
meta.deleteGroup(deletingGroup.id), setDeletingGroup(null);
|
|
8035
|
+
}
|
|
8036
|
+
})]
|
|
8037
|
+
}),
|
|
8038
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
8039
|
+
padding: 4,
|
|
8040
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
8041
|
+
size: 1,
|
|
8042
|
+
children: [
|
|
8043
|
+
"Supprimer « ",
|
|
8044
|
+
deletingGroup.name,
|
|
8045
|
+
" » ? Les composants ne sont pas supprimés : ils repassent « Sans groupe »."
|
|
8046
|
+
]
|
|
8047
|
+
})
|
|
8048
|
+
})
|
|
8049
|
+
}) : null
|
|
8050
|
+
]
|
|
8051
|
+
});
|
|
8052
|
+
}
|
|
8053
|
+
/** Messages du service, rendus lisibles pour un éditeur. */
|
|
8054
|
+
function explain(error) {
|
|
8055
|
+
let code = error instanceof Error ? error.message : String(error);
|
|
8056
|
+
return code === "bad_key" ? "The read key is not recognized: run `npx ncf-kit setup` again in the studio folder, then redeploy it." : code === "project_inactive" ? "The log is not enabled for this project at NoCode Factory: `npx ncf-kit setup` enables it, or contact NoCode Factory." : code === "missing_key" ? "No read key configured." : "The log could not be loaded.";
|
|
8057
|
+
}
|
|
8058
|
+
/**
|
|
8059
|
+
* Frise du journal, la plus récente d'abord.
|
|
8060
|
+
*
|
|
8061
|
+
* Paginée par curseur et non par décalage : des événements arrivent pendant
|
|
8062
|
+
* qu'on lit, et un décalage ferait sauter des lignes.
|
|
8063
|
+
*/
|
|
8064
|
+
function useHistory(documentId) {
|
|
7471
8065
|
let history = useKitConfig().history, [events, setEvents] = useState([]), [loading, setLoading] = useState(!1), [error, setError] = useState(null), [hasMore, setHasMore] = useState(!1), [before, setBefore] = useState(void 0), [nonce, setNonce] = useState(0);
|
|
7472
8066
|
return useEffect(() => {
|
|
7473
8067
|
if (!history) {
|
|
@@ -8222,126 +8816,1400 @@ function HistoryTool() {
|
|
|
8222
8816
|
children: /* @__PURE__ */ jsx(Button, {
|
|
8223
8817
|
mode: "ghost",
|
|
8224
8818
|
fontSize: 1,
|
|
8225
|
-
padding: 3,
|
|
8226
|
-
text: loading ? "Loading…" : "Load more",
|
|
8227
|
-
disabled: loading,
|
|
8228
|
-
onClick: loadMore
|
|
8229
|
-
})
|
|
8819
|
+
padding: 3,
|
|
8820
|
+
text: loading ? "Loading…" : "Load more",
|
|
8821
|
+
disabled: loading,
|
|
8822
|
+
onClick: loadMore
|
|
8823
|
+
})
|
|
8824
|
+
}),
|
|
8825
|
+
search && visible.length === 0 && events.length > 0 && /* @__PURE__ */ jsx(Text, {
|
|
8826
|
+
size: 1,
|
|
8827
|
+
muted: !0,
|
|
8828
|
+
children: "No matching events. The filter only applies to events already loaded."
|
|
8829
|
+
})
|
|
8830
|
+
]
|
|
8831
|
+
}), selected && /* @__PURE__ */ jsx(DiffPanel, {
|
|
8832
|
+
event: selected,
|
|
8833
|
+
onClose: () => setSelected(null)
|
|
8834
|
+
})]
|
|
8835
|
+
}) : /* @__PURE__ */ jsx(Box, {
|
|
8836
|
+
padding: 4,
|
|
8837
|
+
children: /* @__PURE__ */ jsx(Card, {
|
|
8838
|
+
padding: 4,
|
|
8839
|
+
radius: 3,
|
|
8840
|
+
tone: "caution",
|
|
8841
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
8842
|
+
gap: 3,
|
|
8843
|
+
children: [
|
|
8844
|
+
/* @__PURE__ */ jsx(Text, {
|
|
8845
|
+
size: 1,
|
|
8846
|
+
weight: "semibold",
|
|
8847
|
+
children: "History not configured"
|
|
8848
|
+
}),
|
|
8849
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
8850
|
+
size: 1,
|
|
8851
|
+
children: [
|
|
8852
|
+
"No read key. In the studio folder, the following command enables the project, writes the key to ",
|
|
8853
|
+
/* @__PURE__ */ jsx("code", { children: ".env" }),
|
|
8854
|
+
" and creates the log webhook:"
|
|
8855
|
+
]
|
|
8856
|
+
}),
|
|
8857
|
+
/* @__PURE__ */ jsx(Text, {
|
|
8858
|
+
size: 0,
|
|
8859
|
+
style: MONO,
|
|
8860
|
+
children: "npx ncf-kit setup --types page,homePage"
|
|
8861
|
+
}),
|
|
8862
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
8863
|
+
size: 0,
|
|
8864
|
+
muted: !0,
|
|
8865
|
+
children: [
|
|
8866
|
+
"Then add ",
|
|
8867
|
+
/* @__PURE__ */ jsxs("code", { children: [
|
|
8868
|
+
"history: ",
|
|
8869
|
+
"{",
|
|
8870
|
+
"projectKey: process.env.SANITY_STUDIO_NCF_PROJECT_KEY",
|
|
8871
|
+
"}"
|
|
8872
|
+
] }),
|
|
8873
|
+
" to sanity.config.ts and redeploy the studio. Or hide this tab with",
|
|
8874
|
+
" ",
|
|
8875
|
+
/* @__PURE__ */ jsxs("code", { children: [
|
|
8876
|
+
"tools: ",
|
|
8877
|
+
"{",
|
|
8878
|
+
"history: false",
|
|
8879
|
+
"}"
|
|
8880
|
+
] }),
|
|
8881
|
+
"."
|
|
8882
|
+
]
|
|
8883
|
+
})
|
|
8884
|
+
]
|
|
8885
|
+
})
|
|
8886
|
+
})
|
|
8887
|
+
});
|
|
8888
|
+
}
|
|
8889
|
+
/**
|
|
8890
|
+
* Onglet « Design system » : un raccourci, pas un écran. Il ouvre aussitôt la page
|
|
8891
|
+
* `/design-system` du site dans Presentation, avec le document des valeurs par
|
|
8892
|
+
* défaut des composants à côté. Cliquer un composant sur la page ouvre ses
|
|
8893
|
+
* réglages globaux : un style changé ici change le composant partout où il n'est
|
|
8894
|
+
* pas surchargé.
|
|
8895
|
+
*/
|
|
8896
|
+
function DesignSystemTool() {
|
|
8897
|
+
let config = useKitConfig(), schema = useSchema(), router = useRouter(), client = useKitClient(), hasDefaults = !!schema.get(config.componentPreview.defaultsType), opened = useRef(!1), open = useCallback(() => void openDesignSystem({
|
|
8898
|
+
config,
|
|
8899
|
+
hasDefaults,
|
|
8900
|
+
client,
|
|
8901
|
+
navigateIntent: (intent, params) => router.navigateIntent(intent, params),
|
|
8902
|
+
navigateUrl: (path) => router.navigateUrl({ path })
|
|
8903
|
+
}), [
|
|
8904
|
+
config,
|
|
8905
|
+
hasDefaults,
|
|
8906
|
+
client,
|
|
8907
|
+
router
|
|
8908
|
+
]);
|
|
8909
|
+
useEffect(() => {
|
|
8910
|
+
opened.current || (opened.current = !0, open());
|
|
8911
|
+
}, [open]);
|
|
8912
|
+
let available = hasDefaults || !!config.previewUrl;
|
|
8913
|
+
return /* @__PURE__ */ jsx(Card, {
|
|
8914
|
+
padding: 4,
|
|
8915
|
+
radius: 2,
|
|
8916
|
+
tone: available ? "default" : "caution",
|
|
8917
|
+
border: !0,
|
|
8918
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
8919
|
+
gap: 3,
|
|
8920
|
+
children: [
|
|
8921
|
+
/* @__PURE__ */ jsx(Text, {
|
|
8922
|
+
size: 1,
|
|
8923
|
+
weight: "semibold",
|
|
8924
|
+
children: "Design system"
|
|
8925
|
+
}),
|
|
8926
|
+
/* @__PURE__ */ jsx(Text, {
|
|
8927
|
+
size: 1,
|
|
8928
|
+
muted: !0,
|
|
8929
|
+
children: available ? `Opens the ${config.componentPreview.path} page in Presentation, with the component default values. A style changed here changes the component everywhere it is not overridden.` : "No component default values document and no previewUrl: nothing to open. See the kit checklist (README)."
|
|
8930
|
+
}),
|
|
8931
|
+
available && /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(Button, {
|
|
8932
|
+
text: "Open design system",
|
|
8933
|
+
tone: "primary",
|
|
8934
|
+
fontSize: 1,
|
|
8935
|
+
onClick: open
|
|
8936
|
+
}) })
|
|
8937
|
+
]
|
|
8938
|
+
})
|
|
8939
|
+
});
|
|
8940
|
+
}
|
|
8941
|
+
const ASSET_TYPES = ["sanity.imageAsset", "sanity.fileAsset"];
|
|
8942
|
+
/**
|
|
8943
|
+
* Tous les assets du dataset (images et fichiers), en direct. `uses` compte les
|
|
8944
|
+
* documents qui référencent l'asset (utilisé / inutilisé) : il suit les
|
|
8945
|
+
* mutations d'assets ; un changement de contenu qui (dé)référence un asset est
|
|
8946
|
+
* pris au prochain rafraîchissement.
|
|
8947
|
+
*/
|
|
8948
|
+
function useAssets() {
|
|
8949
|
+
return useQueryData("*[_type in $types]{\n _id, _type, _createdAt, _updatedAt, originalFilename, extension, mimeType, size, url,\n title, altText, description,\n \"dimensions\": metadata.dimensions, \"lqip\": metadata.lqip,\n \"uses\": count(*[references(^._id)])\n } | order(_createdAt desc)", { types: ASSET_TYPES }, { listenTypes: ASSET_TYPES });
|
|
8950
|
+
}
|
|
8951
|
+
const newId = () => `f${Math.random().toString(36).slice(2, 10)}`;
|
|
8952
|
+
/**
|
|
8953
|
+
* Lit et écrit l'organisation des assets (dossiers + affectations) dans le
|
|
8954
|
+
* singleton du kit `ncfAssetMeta`. Même principe que la disposition du board :
|
|
8955
|
+
* document unique réécrit en entier, écriture directe (pas de brouillon),
|
|
8956
|
+
* débouncée. À appeler UNE fois (outil Assets) : deux instances s'écraseraient.
|
|
8957
|
+
*/
|
|
8958
|
+
function useAssetMeta() {
|
|
8959
|
+
let client = useKitClient(), user = useCurrentUser(), [folders, setFolders] = useState([]), [assignments, setAssignments] = useState([]), [loading, setLoading] = useState(!0), [saveError, setSaveError] = useState(null);
|
|
8960
|
+
useEffect(() => {
|
|
8961
|
+
let cancelled = !1;
|
|
8962
|
+
return client.fetch("*[_id == $id][0]{folders, assignments}", { id: ASSET_META_ID }).then((doc) => {
|
|
8963
|
+
cancelled || (setFolders((doc?.folders ?? []).filter((f) => !!(f.id && f.name)).map((f) => ({
|
|
8964
|
+
id: f.id,
|
|
8965
|
+
name: f.name,
|
|
8966
|
+
...f.parent ? { parent: f.parent } : {}
|
|
8967
|
+
}))), setAssignments((doc?.assignments ?? []).filter((a) => !!(a._key && a.folder)).map((a) => ({
|
|
8968
|
+
assetId: a._key,
|
|
8969
|
+
folder: a.folder
|
|
8970
|
+
}))));
|
|
8971
|
+
}).catch(() => {
|
|
8972
|
+
cancelled || (setFolders([]), setAssignments([]));
|
|
8973
|
+
}).finally(() => {
|
|
8974
|
+
cancelled || setLoading(!1);
|
|
8975
|
+
}), () => {
|
|
8976
|
+
cancelled = !0;
|
|
8977
|
+
};
|
|
8978
|
+
}, [client]);
|
|
8979
|
+
let timer = useRef(void 0);
|
|
8980
|
+
useEffect(() => () => {
|
|
8981
|
+
timer.current && clearTimeout(timer.current);
|
|
8982
|
+
}, []);
|
|
8983
|
+
let foldersRef = useRef([]), assignmentsRef = useRef([]);
|
|
8984
|
+
foldersRef.current = folders, assignmentsRef.current = assignments;
|
|
8985
|
+
let write = useCallback((next) => {
|
|
8986
|
+
let nextFolders = next?.folders ?? foldersRef.current, nextAssignments = next?.assignments ?? assignmentsRef.current;
|
|
8987
|
+
timer.current && clearTimeout(timer.current), timer.current = setTimeout(() => {
|
|
8988
|
+
client.createOrReplace({
|
|
8989
|
+
_id: ASSET_META_ID,
|
|
8990
|
+
_type: ASSET_META_TYPE,
|
|
8991
|
+
folders: nextFolders.map((folder) => ({
|
|
8992
|
+
_key: folder.id,
|
|
8993
|
+
_type: ASSET_FOLDER_TYPE,
|
|
8994
|
+
id: folder.id,
|
|
8995
|
+
name: folder.name,
|
|
8996
|
+
...folder.parent ? { parent: folder.parent } : {}
|
|
8997
|
+
})),
|
|
8998
|
+
assignments: nextAssignments.filter((assignment) => assignment.folder).map((assignment) => ({
|
|
8999
|
+
_key: assignment.assetId,
|
|
9000
|
+
_type: ASSET_ASSIGNMENT_TYPE,
|
|
9001
|
+
folder: assignment.folder
|
|
9002
|
+
})),
|
|
9003
|
+
updatedBy: user?.id ?? null
|
|
9004
|
+
}).then(() => setSaveError(null)).catch((cause) => setSaveError(cause instanceof Error ? cause : Error(String(cause))));
|
|
9005
|
+
}, 800);
|
|
9006
|
+
}, [client, user?.id]), createFolder = useCallback((name) => {
|
|
9007
|
+
let id = newId(), next = [...foldersRef.current, {
|
|
9008
|
+
id,
|
|
9009
|
+
name: name.trim() || "Dossier"
|
|
9010
|
+
}];
|
|
9011
|
+
return setFolders(next), write({ folders: next }), id;
|
|
9012
|
+
}, [write]), renameFolder = useCallback((id, name) => {
|
|
9013
|
+
let next = foldersRef.current.map((folder) => folder.id === id ? {
|
|
9014
|
+
...folder,
|
|
9015
|
+
name: name.trim() || folder.name
|
|
9016
|
+
} : folder);
|
|
9017
|
+
setFolders(next), write({ folders: next });
|
|
9018
|
+
}, [write]), deleteFolder = useCallback((id) => {
|
|
9019
|
+
let nextFolders = foldersRef.current.filter((folder) => folder.id !== id), nextAssignments = assignmentsRef.current.filter((assignment) => assignment.folder !== id);
|
|
9020
|
+
setFolders(nextFolders), setAssignments(nextAssignments), write({
|
|
9021
|
+
folders: nextFolders,
|
|
9022
|
+
assignments: nextAssignments
|
|
9023
|
+
});
|
|
9024
|
+
}, [write]), moveAssets = useCallback((assetIds, folder) => {
|
|
9025
|
+
let ids = new Set(assetIds), kept = assignmentsRef.current.filter((assignment) => !ids.has(assignment.assetId)), added = folder ? assetIds.map((assetId) => ({
|
|
9026
|
+
assetId,
|
|
9027
|
+
folder
|
|
9028
|
+
})) : [], next = [...kept, ...added];
|
|
9029
|
+
setAssignments(next), write({ assignments: next });
|
|
9030
|
+
}, [write]);
|
|
9031
|
+
return {
|
|
9032
|
+
folders,
|
|
9033
|
+
assignments,
|
|
9034
|
+
loading,
|
|
9035
|
+
saveError,
|
|
9036
|
+
createFolder,
|
|
9037
|
+
renameFolder,
|
|
9038
|
+
deleteFolder,
|
|
9039
|
+
moveAsset: useCallback((assetId, folder) => moveAssets([assetId], folder), [moveAssets]),
|
|
9040
|
+
moveAssets
|
|
9041
|
+
};
|
|
9042
|
+
}
|
|
9043
|
+
const isImageAsset = (asset) => asset._type === "sanity.imageAsset";
|
|
9044
|
+
/** Nom affiché : titre saisi, sinon nom de fichier, sinon id. */
|
|
9045
|
+
function assetName(asset) {
|
|
9046
|
+
return asset.title?.trim() || asset.originalFilename || asset._id;
|
|
9047
|
+
}
|
|
9048
|
+
/** Taille lisible (o / Ko / Mo / Go). */
|
|
9049
|
+
function formatBytes(size) {
|
|
9050
|
+
if (!size || size <= 0) return "—";
|
|
9051
|
+
let units = [
|
|
9052
|
+
"o",
|
|
9053
|
+
"Ko",
|
|
9054
|
+
"Mo",
|
|
9055
|
+
"Go",
|
|
9056
|
+
"To"
|
|
9057
|
+
], value = size, unit = 0;
|
|
9058
|
+
for (; value >= 1024 && unit < units.length - 1;) value /= 1024, unit += 1;
|
|
9059
|
+
return `${unit === 0 ? value : value < 10 ? Math.round(value * 10) / 10 : Math.round(value)} ${units[unit]}`;
|
|
9060
|
+
}
|
|
9061
|
+
/**
|
|
9062
|
+
* URL de vignette depuis l'URL CDN de l'asset (paramètres de transformation
|
|
9063
|
+
* Sanity). Renvoie `undefined` pour un non-image (pas de rendu).
|
|
9064
|
+
*/
|
|
9065
|
+
function thumbnailUrl(asset, opts = {}) {
|
|
9066
|
+
if (!asset.url || !isImageAsset(asset)) return;
|
|
9067
|
+
let params = new URLSearchParams();
|
|
9068
|
+
return opts.w && params.set("w", String(opts.w)), opts.h && params.set("h", String(opts.h)), params.set("fit", "crop"), params.set("auto", "format"), `${asset.url}?${params.toString()}`;
|
|
9069
|
+
}
|
|
9070
|
+
function matchesSearch(asset, query) {
|
|
9071
|
+
return [
|
|
9072
|
+
asset.title,
|
|
9073
|
+
asset.originalFilename,
|
|
9074
|
+
asset.altText,
|
|
9075
|
+
asset.description,
|
|
9076
|
+
asset.extension
|
|
9077
|
+
].filter(Boolean).join(" ").toLowerCase().includes(query);
|
|
9078
|
+
}
|
|
9079
|
+
/** Filtre par recherche, type (image/fichier) et usage. */
|
|
9080
|
+
function filterAssets(assets, filter = {}) {
|
|
9081
|
+
let query = filter.search?.trim().toLowerCase() ?? "", type = filter.type ?? "all", usage = filter.usage ?? "all";
|
|
9082
|
+
return assets.filter((asset) => !(query && !matchesSearch(asset, query) || type === "image" && !isImageAsset(asset) || type === "file" && isImageAsset(asset) || usage === "used" && !(asset.uses && asset.uses > 0) || usage === "unused" && asset.uses && asset.uses > 0));
|
|
9083
|
+
}
|
|
9084
|
+
/** Tri stable par date / nom / taille / type. */
|
|
9085
|
+
function sortAssets(assets, key, direction = "desc") {
|
|
9086
|
+
let factor = direction === "asc" ? 1 : -1, compare = (a, b) => {
|
|
9087
|
+
switch (key) {
|
|
9088
|
+
case "name": return assetName(a).localeCompare(assetName(b), "fr", { numeric: !0 });
|
|
9089
|
+
case "size": return (a.size ?? 0) - (b.size ?? 0);
|
|
9090
|
+
case "type": return (a.extension ?? a._type).localeCompare(b.extension ?? b._type);
|
|
9091
|
+
default: return a._createdAt < b._createdAt ? -1 : +(a._createdAt > b._createdAt);
|
|
9092
|
+
}
|
|
9093
|
+
};
|
|
9094
|
+
return [...assets].sort((a, b) => factor * compare(a, b));
|
|
9095
|
+
}
|
|
9096
|
+
/** Map assetId -> id de dossier, à partir des affectations stockées. */
|
|
9097
|
+
function assignmentMap(assignments) {
|
|
9098
|
+
let map = /* @__PURE__ */ new Map();
|
|
9099
|
+
for (let { assetId, folder } of assignments) folder && map.set(assetId, folder);
|
|
9100
|
+
return map;
|
|
9101
|
+
}
|
|
9102
|
+
/** Assets du dossier sélectionné (`null` = tous, `''` = sans dossier). */
|
|
9103
|
+
function assetsInFolder(assets, folders, selection) {
|
|
9104
|
+
return selection === null ? [...assets] : selection === "" ? assets.filter((asset) => !folders.has(asset._id)) : assets.filter((asset) => folders.get(asset._id) === selection);
|
|
9105
|
+
}
|
|
9106
|
+
/** Nombre d'assets par dossier (+ `''` pour les non classés). */
|
|
9107
|
+
function countByFolder(assets, folders) {
|
|
9108
|
+
let counts = /* @__PURE__ */ new Map();
|
|
9109
|
+
for (let asset of assets) {
|
|
9110
|
+
let folder = folders.get(asset._id) ?? "";
|
|
9111
|
+
counts.set(folder, (counts.get(folder) ?? 0) + 1);
|
|
9112
|
+
}
|
|
9113
|
+
return counts;
|
|
9114
|
+
}
|
|
9115
|
+
function Row(props) {
|
|
9116
|
+
return /* @__PURE__ */ jsxs(Flex, {
|
|
9117
|
+
align: "center",
|
|
9118
|
+
gap: 1,
|
|
9119
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
9120
|
+
mode: props.active ? "default" : "bleed",
|
|
9121
|
+
tone: props.active ? "primary" : "default",
|
|
9122
|
+
onClick: props.onClick,
|
|
9123
|
+
justify: "flex-start",
|
|
9124
|
+
style: {
|
|
9125
|
+
flex: 1,
|
|
9126
|
+
minWidth: 0
|
|
9127
|
+
},
|
|
9128
|
+
padding: 2,
|
|
9129
|
+
fontSize: 1,
|
|
9130
|
+
children: /* @__PURE__ */ jsxs(Flex, {
|
|
9131
|
+
align: "center",
|
|
9132
|
+
gap: 2,
|
|
9133
|
+
style: { width: "100%" },
|
|
9134
|
+
children: [
|
|
9135
|
+
props.icon ? /* @__PURE__ */ jsx(Text, {
|
|
9136
|
+
size: 1,
|
|
9137
|
+
children: props.icon
|
|
9138
|
+
}) : null,
|
|
9139
|
+
/* @__PURE__ */ jsx(Text, {
|
|
9140
|
+
size: 1,
|
|
9141
|
+
textOverflow: "ellipsis",
|
|
9142
|
+
style: {
|
|
9143
|
+
flex: 1,
|
|
9144
|
+
textAlign: "left"
|
|
9145
|
+
},
|
|
9146
|
+
children: props.label
|
|
9147
|
+
}),
|
|
9148
|
+
typeof props.count == "number" ? /* @__PURE__ */ jsx(Text, {
|
|
9149
|
+
size: 0,
|
|
9150
|
+
muted: !0,
|
|
9151
|
+
style: {
|
|
9152
|
+
...TABULAR,
|
|
9153
|
+
flex: "none"
|
|
9154
|
+
},
|
|
9155
|
+
children: props.count
|
|
9156
|
+
}) : null
|
|
9157
|
+
]
|
|
9158
|
+
})
|
|
9159
|
+
}), props.actions ? /* @__PURE__ */ jsx(Box, {
|
|
9160
|
+
style: { flex: "none" },
|
|
9161
|
+
children: props.actions
|
|
9162
|
+
}) : null]
|
|
9163
|
+
});
|
|
9164
|
+
}
|
|
9165
|
+
function FolderSidebar(props) {
|
|
9166
|
+
let { folders, counts, total, selection, onSelect, onCreate, onRename, onDelete } = props, [creating, setCreating] = useState(!1), [renaming, setRenaming] = useState(null), [deleting, setDeleting] = useState(null), [name, setName] = useState(""), openCreate = () => {
|
|
9167
|
+
setName(""), setCreating(!0);
|
|
9168
|
+
}, openRename = (folder) => {
|
|
9169
|
+
setName(folder.name), setRenaming(folder);
|
|
9170
|
+
};
|
|
9171
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
9172
|
+
gap: 2,
|
|
9173
|
+
children: [
|
|
9174
|
+
/* @__PURE__ */ jsxs(Flex, {
|
|
9175
|
+
align: "center",
|
|
9176
|
+
justify: "space-between",
|
|
9177
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
9178
|
+
size: 1,
|
|
9179
|
+
weight: "semibold",
|
|
9180
|
+
muted: !0,
|
|
9181
|
+
children: "Dossiers"
|
|
9182
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
9183
|
+
icon: AddIcon,
|
|
9184
|
+
mode: "bleed",
|
|
9185
|
+
fontSize: 1,
|
|
9186
|
+
padding: 2,
|
|
9187
|
+
title: "Nouveau dossier",
|
|
9188
|
+
"aria-label": "Nouveau dossier",
|
|
9189
|
+
onClick: openCreate
|
|
9190
|
+
})]
|
|
9191
|
+
}),
|
|
9192
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
9193
|
+
gap: 1,
|
|
9194
|
+
children: [
|
|
9195
|
+
/* @__PURE__ */ jsx(Row, {
|
|
9196
|
+
label: "Tous les médias",
|
|
9197
|
+
count: total,
|
|
9198
|
+
active: selection === null,
|
|
9199
|
+
onClick: () => onSelect(null)
|
|
9200
|
+
}),
|
|
9201
|
+
/* @__PURE__ */ jsx(Row, {
|
|
9202
|
+
label: "Non classés",
|
|
9203
|
+
count: counts.get("") ?? 0,
|
|
9204
|
+
active: selection === "",
|
|
9205
|
+
onClick: () => onSelect("")
|
|
9206
|
+
}),
|
|
9207
|
+
folders.map((folder) => /* @__PURE__ */ jsx(Row, {
|
|
9208
|
+
label: folder.name,
|
|
9209
|
+
count: counts.get(folder.id) ?? 0,
|
|
9210
|
+
active: selection === folder.id,
|
|
9211
|
+
onClick: () => onSelect(folder.id),
|
|
9212
|
+
icon: /* @__PURE__ */ jsx(FolderIcon, {}),
|
|
9213
|
+
actions: /* @__PURE__ */ jsxs(Flex, {
|
|
9214
|
+
gap: 1,
|
|
9215
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
9216
|
+
icon: EditIcon,
|
|
9217
|
+
mode: "bleed",
|
|
9218
|
+
fontSize: 0,
|
|
9219
|
+
padding: 2,
|
|
9220
|
+
title: "Renommer",
|
|
9221
|
+
"aria-label": "Renommer",
|
|
9222
|
+
onClick: () => openRename(folder)
|
|
9223
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
9224
|
+
icon: TrashIcon,
|
|
9225
|
+
mode: "bleed",
|
|
9226
|
+
tone: "critical",
|
|
9227
|
+
fontSize: 0,
|
|
9228
|
+
padding: 2,
|
|
9229
|
+
title: "Supprimer",
|
|
9230
|
+
"aria-label": "Supprimer",
|
|
9231
|
+
onClick: () => setDeleting(folder)
|
|
9232
|
+
})]
|
|
9233
|
+
})
|
|
9234
|
+
}, folder.id))
|
|
9235
|
+
]
|
|
9236
|
+
}),
|
|
9237
|
+
creating || renaming ? /* @__PURE__ */ jsx(Dialog, {
|
|
9238
|
+
id: "asset-folder-dialog",
|
|
9239
|
+
header: renaming ? "Renommer le dossier" : "Nouveau dossier",
|
|
9240
|
+
onClose: () => {
|
|
9241
|
+
setCreating(!1), setRenaming(null);
|
|
9242
|
+
},
|
|
9243
|
+
width: 0,
|
|
9244
|
+
footer: /* @__PURE__ */ jsxs(Flex, {
|
|
9245
|
+
justify: "flex-end",
|
|
9246
|
+
gap: 2,
|
|
9247
|
+
padding: 2,
|
|
9248
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
9249
|
+
text: "Annuler",
|
|
9250
|
+
mode: "bleed",
|
|
9251
|
+
onClick: () => {
|
|
9252
|
+
setCreating(!1), setRenaming(null);
|
|
9253
|
+
}
|
|
9254
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
9255
|
+
text: renaming ? "Renommer" : "Créer",
|
|
9256
|
+
tone: "primary",
|
|
9257
|
+
disabled: !name.trim(),
|
|
9258
|
+
onClick: () => {
|
|
9259
|
+
renaming ? onRename(renaming.id, name) : onCreate(name), setCreating(!1), setRenaming(null);
|
|
9260
|
+
}
|
|
9261
|
+
})]
|
|
9262
|
+
}),
|
|
9263
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
9264
|
+
padding: 4,
|
|
9265
|
+
children: /* @__PURE__ */ jsx(TextInput, {
|
|
9266
|
+
value: name,
|
|
9267
|
+
autoFocus: !0,
|
|
9268
|
+
placeholder: "Nom du dossier",
|
|
9269
|
+
onChange: (event) => setName(event.currentTarget.value),
|
|
9270
|
+
onKeyDown: (event) => {
|
|
9271
|
+
event.key === "Enter" && name.trim() && (renaming ? onRename(renaming.id, name) : onCreate(name), setCreating(!1), setRenaming(null));
|
|
9272
|
+
}
|
|
9273
|
+
})
|
|
9274
|
+
})
|
|
9275
|
+
}) : null,
|
|
9276
|
+
deleting ? /* @__PURE__ */ jsx(Dialog, {
|
|
9277
|
+
id: "asset-folder-delete",
|
|
9278
|
+
header: "Supprimer le dossier",
|
|
9279
|
+
onClose: () => setDeleting(null),
|
|
9280
|
+
width: 0,
|
|
9281
|
+
footer: /* @__PURE__ */ jsxs(Flex, {
|
|
9282
|
+
justify: "flex-end",
|
|
9283
|
+
gap: 2,
|
|
9284
|
+
padding: 2,
|
|
9285
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
9286
|
+
text: "Annuler",
|
|
9287
|
+
mode: "bleed",
|
|
9288
|
+
onClick: () => setDeleting(null)
|
|
9289
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
9290
|
+
text: "Supprimer",
|
|
9291
|
+
tone: "critical",
|
|
9292
|
+
onClick: () => {
|
|
9293
|
+
onDelete(deleting.id), setDeleting(null);
|
|
9294
|
+
}
|
|
9295
|
+
})]
|
|
9296
|
+
}),
|
|
9297
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
9298
|
+
padding: 4,
|
|
9299
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
9300
|
+
size: 1,
|
|
9301
|
+
children: [
|
|
9302
|
+
"Supprimer « ",
|
|
9303
|
+
deleting.name,
|
|
9304
|
+
" » ? Les médias qu'il contient ne sont pas supprimés : ils redeviennent « Non classés »."
|
|
9305
|
+
]
|
|
9306
|
+
})
|
|
9307
|
+
})
|
|
9308
|
+
}) : null
|
|
9309
|
+
]
|
|
9310
|
+
});
|
|
9311
|
+
}
|
|
9312
|
+
function AssetsToolbar(props) {
|
|
9313
|
+
return /* @__PURE__ */ jsxs(Flex, {
|
|
9314
|
+
gap: 2,
|
|
9315
|
+
align: "center",
|
|
9316
|
+
wrap: "wrap",
|
|
9317
|
+
children: [
|
|
9318
|
+
/* @__PURE__ */ jsx(Box, {
|
|
9319
|
+
flex: 1,
|
|
9320
|
+
style: { minWidth: 180 },
|
|
9321
|
+
children: /* @__PURE__ */ jsx(TextInput, {
|
|
9322
|
+
value: props.search,
|
|
9323
|
+
onChange: (event) => props.onSearch(event.currentTarget.value),
|
|
9324
|
+
placeholder: "Rechercher un média",
|
|
9325
|
+
icon: SearchIcon,
|
|
9326
|
+
clearButton: props.search.length > 0,
|
|
9327
|
+
onClear: () => props.onSearch(""),
|
|
9328
|
+
fontSize: 1,
|
|
9329
|
+
radius: 2
|
|
9330
|
+
})
|
|
9331
|
+
}),
|
|
9332
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
9333
|
+
fontSize: 1,
|
|
9334
|
+
value: props.type,
|
|
9335
|
+
onChange: (e) => props.onType(e.currentTarget.value),
|
|
9336
|
+
style: {
|
|
9337
|
+
flex: "none",
|
|
9338
|
+
width: 120
|
|
9339
|
+
},
|
|
9340
|
+
children: [
|
|
9341
|
+
/* @__PURE__ */ jsx("option", {
|
|
9342
|
+
value: "all",
|
|
9343
|
+
children: "Tous types"
|
|
9344
|
+
}),
|
|
9345
|
+
/* @__PURE__ */ jsx("option", {
|
|
9346
|
+
value: "image",
|
|
9347
|
+
children: "Images"
|
|
9348
|
+
}),
|
|
9349
|
+
/* @__PURE__ */ jsx("option", {
|
|
9350
|
+
value: "file",
|
|
9351
|
+
children: "Fichiers"
|
|
9352
|
+
})
|
|
9353
|
+
]
|
|
9354
|
+
}),
|
|
9355
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
9356
|
+
fontSize: 1,
|
|
9357
|
+
value: props.usage,
|
|
9358
|
+
onChange: (e) => props.onUsage(e.currentTarget.value),
|
|
9359
|
+
style: {
|
|
9360
|
+
flex: "none",
|
|
9361
|
+
width: 130
|
|
9362
|
+
},
|
|
9363
|
+
children: [
|
|
9364
|
+
/* @__PURE__ */ jsx("option", {
|
|
9365
|
+
value: "all",
|
|
9366
|
+
children: "Tout usage"
|
|
9367
|
+
}),
|
|
9368
|
+
/* @__PURE__ */ jsx("option", {
|
|
9369
|
+
value: "used",
|
|
9370
|
+
children: "Utilisés"
|
|
9371
|
+
}),
|
|
9372
|
+
/* @__PURE__ */ jsx("option", {
|
|
9373
|
+
value: "unused",
|
|
9374
|
+
children: "Inutilisés"
|
|
9375
|
+
})
|
|
9376
|
+
]
|
|
9377
|
+
}),
|
|
9378
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
9379
|
+
fontSize: 1,
|
|
9380
|
+
value: `${props.sort}:${props.direction}`,
|
|
9381
|
+
onChange: (e) => {
|
|
9382
|
+
let [key, dir] = e.currentTarget.value.split(":");
|
|
9383
|
+
props.onSort(key, dir);
|
|
9384
|
+
},
|
|
9385
|
+
style: {
|
|
9386
|
+
flex: "none",
|
|
9387
|
+
width: 170
|
|
9388
|
+
},
|
|
9389
|
+
children: [
|
|
9390
|
+
/* @__PURE__ */ jsx("option", {
|
|
9391
|
+
value: "date:desc",
|
|
9392
|
+
children: "Plus récents"
|
|
9393
|
+
}),
|
|
9394
|
+
/* @__PURE__ */ jsx("option", {
|
|
9395
|
+
value: "date:asc",
|
|
9396
|
+
children: "Plus anciens"
|
|
9397
|
+
}),
|
|
9398
|
+
/* @__PURE__ */ jsx("option", {
|
|
9399
|
+
value: "name:asc",
|
|
9400
|
+
children: "Nom (A→Z)"
|
|
9401
|
+
}),
|
|
9402
|
+
/* @__PURE__ */ jsx("option", {
|
|
9403
|
+
value: "name:desc",
|
|
9404
|
+
children: "Nom (Z→A)"
|
|
9405
|
+
}),
|
|
9406
|
+
/* @__PURE__ */ jsx("option", {
|
|
9407
|
+
value: "size:desc",
|
|
9408
|
+
children: "Plus lourds"
|
|
9409
|
+
}),
|
|
9410
|
+
/* @__PURE__ */ jsx("option", {
|
|
9411
|
+
value: "size:asc",
|
|
9412
|
+
children: "Plus légers"
|
|
9413
|
+
}),
|
|
9414
|
+
/* @__PURE__ */ jsx("option", {
|
|
9415
|
+
value: "type:asc",
|
|
9416
|
+
children: "Type"
|
|
9417
|
+
})
|
|
9418
|
+
]
|
|
9419
|
+
}),
|
|
9420
|
+
/* @__PURE__ */ jsxs(Flex, {
|
|
9421
|
+
style: { flex: "none" },
|
|
9422
|
+
gap: 1,
|
|
9423
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
9424
|
+
icon: ThLargeIcon,
|
|
9425
|
+
mode: props.view === "grid" ? "default" : "bleed",
|
|
9426
|
+
tone: props.view === "grid" ? "primary" : "default",
|
|
9427
|
+
padding: 2,
|
|
9428
|
+
fontSize: 1,
|
|
9429
|
+
title: "Grille",
|
|
9430
|
+
"aria-label": "Grille",
|
|
9431
|
+
onClick: () => props.onView("grid")
|
|
9432
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
9433
|
+
icon: ThListIcon,
|
|
9434
|
+
mode: props.view === "table" ? "default" : "bleed",
|
|
9435
|
+
tone: props.view === "table" ? "primary" : "default",
|
|
9436
|
+
padding: 2,
|
|
9437
|
+
fontSize: 1,
|
|
9438
|
+
title: "Table",
|
|
9439
|
+
"aria-label": "Table",
|
|
9440
|
+
onClick: () => props.onView("table")
|
|
9441
|
+
})]
|
|
9442
|
+
}),
|
|
9443
|
+
/* @__PURE__ */ jsx(Button, {
|
|
9444
|
+
icon: SyncIcon,
|
|
9445
|
+
mode: "bleed",
|
|
9446
|
+
padding: 2,
|
|
9447
|
+
fontSize: 1,
|
|
9448
|
+
title: "Rafraîchir",
|
|
9449
|
+
"aria-label": "Rafraîchir",
|
|
9450
|
+
onClick: props.onRefresh,
|
|
9451
|
+
disabled: props.busy
|
|
9452
|
+
})
|
|
9453
|
+
]
|
|
9454
|
+
});
|
|
9455
|
+
}
|
|
9456
|
+
/** Tuile d'un asset dans la grille : aperçu, nom, taille, type, usage. */
|
|
9457
|
+
function AssetCard(props) {
|
|
9458
|
+
let { asset, selected, onToggleSelect, onOpen } = props, [failed, setFailed] = useState(!1), thumb = thumbnailUrl(asset, {
|
|
9459
|
+
w: 320,
|
|
9460
|
+
h: 220
|
|
9461
|
+
}), unused = asset.uses === 0, meta = [
|
|
9462
|
+
formatBytes(asset.size),
|
|
9463
|
+
asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : null,
|
|
9464
|
+
asset.extension?.toUpperCase()
|
|
9465
|
+
].filter(Boolean).join(" · ");
|
|
9466
|
+
return /* @__PURE__ */ jsxs(Card, {
|
|
9467
|
+
radius: 3,
|
|
9468
|
+
shadow: 1,
|
|
9469
|
+
padding: 0,
|
|
9470
|
+
tone: selected ? "primary" : "default",
|
|
9471
|
+
style: {
|
|
9472
|
+
height: "100%",
|
|
9473
|
+
overflow: "hidden",
|
|
9474
|
+
position: "relative"
|
|
9475
|
+
},
|
|
9476
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
9477
|
+
style: {
|
|
9478
|
+
position: "absolute",
|
|
9479
|
+
top: 8,
|
|
9480
|
+
left: 8,
|
|
9481
|
+
zIndex: 1
|
|
9482
|
+
},
|
|
9483
|
+
onClick: (e) => e.stopPropagation(),
|
|
9484
|
+
children: /* @__PURE__ */ jsx(Card, {
|
|
9485
|
+
radius: 2,
|
|
9486
|
+
padding: 1,
|
|
9487
|
+
tone: "default",
|
|
9488
|
+
style: { opacity: selected ? 1 : .85 },
|
|
9489
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
9490
|
+
checked: selected,
|
|
9491
|
+
onChange: onToggleSelect,
|
|
9492
|
+
"aria-label": "Sélectionner"
|
|
9493
|
+
})
|
|
9494
|
+
})
|
|
9495
|
+
}), /* @__PURE__ */ jsxs(Stack, {
|
|
9496
|
+
gap: 0,
|
|
9497
|
+
as: "button",
|
|
9498
|
+
onClick: onOpen,
|
|
9499
|
+
style: {
|
|
9500
|
+
height: "100%",
|
|
9501
|
+
width: "100%",
|
|
9502
|
+
textAlign: "left",
|
|
9503
|
+
cursor: "pointer",
|
|
9504
|
+
background: "transparent",
|
|
9505
|
+
border: 0,
|
|
9506
|
+
padding: 0
|
|
9507
|
+
},
|
|
9508
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
9509
|
+
style: {
|
|
9510
|
+
aspectRatio: "16 / 11",
|
|
9511
|
+
overflow: "hidden",
|
|
9512
|
+
background: "var(--card-muted-bg-color, rgba(127,127,127,0.08))"
|
|
9513
|
+
},
|
|
9514
|
+
children: thumb && !failed ? /* @__PURE__ */ jsx("img", {
|
|
9515
|
+
src: thumb,
|
|
9516
|
+
alt: "",
|
|
9517
|
+
loading: "lazy",
|
|
9518
|
+
onError: () => setFailed(!0),
|
|
9519
|
+
style: {
|
|
9520
|
+
width: "100%",
|
|
9521
|
+
height: "100%",
|
|
9522
|
+
objectFit: "cover",
|
|
9523
|
+
display: "block"
|
|
9524
|
+
}
|
|
9525
|
+
}) : /* @__PURE__ */ jsxs(Flex, {
|
|
9526
|
+
align: "center",
|
|
9527
|
+
justify: "center",
|
|
9528
|
+
direction: "column",
|
|
9529
|
+
gap: 2,
|
|
9530
|
+
style: { height: "100%" },
|
|
9531
|
+
padding: 3,
|
|
9532
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
9533
|
+
size: 3,
|
|
9534
|
+
muted: !0,
|
|
9535
|
+
children: /* @__PURE__ */ jsx(DocumentIcon, {})
|
|
9536
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
9537
|
+
size: 0,
|
|
9538
|
+
muted: !0,
|
|
9539
|
+
children: asset.extension?.toUpperCase() || (isImageAsset(asset) ? "IMAGE" : "FICHIER")
|
|
9540
|
+
})]
|
|
9541
|
+
})
|
|
9542
|
+
}), /* @__PURE__ */ jsx(Box, {
|
|
9543
|
+
padding: 3,
|
|
9544
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
9545
|
+
gap: 2,
|
|
9546
|
+
children: [/* @__PURE__ */ jsxs(Flex, {
|
|
9547
|
+
align: "center",
|
|
9548
|
+
gap: 2,
|
|
9549
|
+
justify: "space-between",
|
|
9550
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
9551
|
+
size: 1,
|
|
9552
|
+
weight: "medium",
|
|
9553
|
+
textOverflow: "ellipsis",
|
|
9554
|
+
style: { minWidth: 0 },
|
|
9555
|
+
children: assetName(asset)
|
|
9556
|
+
}), unused ? /* @__PURE__ */ jsx(Badge, {
|
|
9557
|
+
tone: "caution",
|
|
9558
|
+
fontSize: 0,
|
|
9559
|
+
style: { flex: "none" },
|
|
9560
|
+
title: "Aucun document ne l’utilise",
|
|
9561
|
+
children: "inutilisé"
|
|
9562
|
+
}) : null]
|
|
9563
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
9564
|
+
size: 0,
|
|
9565
|
+
muted: !0,
|
|
9566
|
+
textOverflow: "ellipsis",
|
|
9567
|
+
style: MONO,
|
|
9568
|
+
children: meta
|
|
9569
|
+
})]
|
|
9570
|
+
})
|
|
9571
|
+
})]
|
|
9572
|
+
})]
|
|
9573
|
+
});
|
|
9574
|
+
}
|
|
9575
|
+
const COLS = [
|
|
9576
|
+
{
|
|
9577
|
+
key: "name",
|
|
9578
|
+
label: "Nom"
|
|
9579
|
+
},
|
|
9580
|
+
{
|
|
9581
|
+
key: "type",
|
|
9582
|
+
label: "Type"
|
|
9583
|
+
},
|
|
9584
|
+
{
|
|
9585
|
+
key: "size",
|
|
9586
|
+
label: "Taille",
|
|
9587
|
+
align: "right"
|
|
9588
|
+
},
|
|
9589
|
+
{
|
|
9590
|
+
key: null,
|
|
9591
|
+
label: "Dimensions",
|
|
9592
|
+
align: "right"
|
|
9593
|
+
},
|
|
9594
|
+
{
|
|
9595
|
+
key: null,
|
|
9596
|
+
label: "Dossier"
|
|
9597
|
+
},
|
|
9598
|
+
{
|
|
9599
|
+
key: null,
|
|
9600
|
+
label: "Usage",
|
|
9601
|
+
align: "right"
|
|
9602
|
+
},
|
|
9603
|
+
{
|
|
9604
|
+
key: "date",
|
|
9605
|
+
label: "Ajouté",
|
|
9606
|
+
align: "right"
|
|
9607
|
+
}
|
|
9608
|
+
];
|
|
9609
|
+
function AssetTable(props) {
|
|
9610
|
+
let { assets, selected, onToggleSelect, onToggleAll, onOpen, folderName, folderOf, sortKey, sortDirection, onSort } = props, allSelected = assets.length > 0 && assets.every((a) => selected.has(a._id)), arrow = (key) => sortKey === key ? sortDirection === "asc" ? " ↑" : " ↓" : "";
|
|
9611
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
9612
|
+
overflow: "auto",
|
|
9613
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
9614
|
+
style: {
|
|
9615
|
+
width: "100%",
|
|
9616
|
+
borderCollapse: "collapse",
|
|
9617
|
+
fontSize: 13
|
|
9618
|
+
},
|
|
9619
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", {
|
|
9620
|
+
style: {
|
|
9621
|
+
textAlign: "left",
|
|
9622
|
+
borderBottom: "1px solid var(--card-border-color)"
|
|
9623
|
+
},
|
|
9624
|
+
children: [/* @__PURE__ */ jsx("th", {
|
|
9625
|
+
style: {
|
|
9626
|
+
padding: "8px 10px",
|
|
9627
|
+
width: 36
|
|
9628
|
+
},
|
|
9629
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
9630
|
+
checked: allSelected,
|
|
9631
|
+
indeterminate: !allSelected && assets.some((a) => selected.has(a._id)),
|
|
9632
|
+
onChange: onToggleAll,
|
|
9633
|
+
"aria-label": "Tout sélectionner"
|
|
9634
|
+
})
|
|
9635
|
+
}), COLS.map((col) => /* @__PURE__ */ jsx("th", {
|
|
9636
|
+
onClick: col.key ? () => onSort(col.key) : void 0,
|
|
9637
|
+
style: {
|
|
9638
|
+
padding: "8px 10px",
|
|
9639
|
+
whiteSpace: "nowrap",
|
|
9640
|
+
textAlign: col.align ?? "left",
|
|
9641
|
+
cursor: col.key ? "pointer" : "default",
|
|
9642
|
+
userSelect: "none"
|
|
9643
|
+
},
|
|
9644
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
9645
|
+
size: 1,
|
|
9646
|
+
weight: "medium",
|
|
9647
|
+
muted: !0,
|
|
9648
|
+
children: [col.label, col.key ? arrow(col.key) : ""]
|
|
9649
|
+
})
|
|
9650
|
+
}, col.label))]
|
|
9651
|
+
}) }), /* @__PURE__ */ jsx("tbody", { children: assets.map((asset) => {
|
|
9652
|
+
let thumb = thumbnailUrl(asset, {
|
|
9653
|
+
w: 64,
|
|
9654
|
+
h: 64
|
|
9655
|
+
}), folder = folderOf(asset._id);
|
|
9656
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
9657
|
+
onClick: () => onOpen(asset),
|
|
9658
|
+
style: {
|
|
9659
|
+
borderBottom: "1px solid var(--card-border-color)",
|
|
9660
|
+
cursor: "pointer",
|
|
9661
|
+
background: selected.has(asset._id) ? "var(--card-badge-primary-bg-color, rgba(45,114,225,0.08))" : void 0
|
|
9662
|
+
},
|
|
9663
|
+
children: [
|
|
9664
|
+
/* @__PURE__ */ jsx("td", {
|
|
9665
|
+
style: { padding: "6px 10px" },
|
|
9666
|
+
onClick: (e) => e.stopPropagation(),
|
|
9667
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
9668
|
+
checked: selected.has(asset._id),
|
|
9669
|
+
onChange: () => onToggleSelect(asset._id),
|
|
9670
|
+
"aria-label": "Sélectionner"
|
|
9671
|
+
})
|
|
9672
|
+
}),
|
|
9673
|
+
/* @__PURE__ */ jsx("td", {
|
|
9674
|
+
style: { padding: "6px 10px" },
|
|
9675
|
+
children: /* @__PURE__ */ jsxs(Flex, {
|
|
9676
|
+
align: "center",
|
|
9677
|
+
gap: 2,
|
|
9678
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
9679
|
+
style: {
|
|
9680
|
+
width: 32,
|
|
9681
|
+
height: 32,
|
|
9682
|
+
flex: "none",
|
|
9683
|
+
borderRadius: 4,
|
|
9684
|
+
overflow: "hidden",
|
|
9685
|
+
background: "var(--card-muted-bg-color, rgba(127,127,127,0.08))"
|
|
9686
|
+
},
|
|
9687
|
+
children: thumb ? /* @__PURE__ */ jsx("img", {
|
|
9688
|
+
src: thumb,
|
|
9689
|
+
alt: "",
|
|
9690
|
+
loading: "lazy",
|
|
9691
|
+
style: {
|
|
9692
|
+
width: "100%",
|
|
9693
|
+
height: "100%",
|
|
9694
|
+
objectFit: "cover"
|
|
9695
|
+
}
|
|
9696
|
+
}) : null
|
|
9697
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
9698
|
+
size: 1,
|
|
9699
|
+
textOverflow: "ellipsis",
|
|
9700
|
+
children: assetName(asset)
|
|
9701
|
+
})]
|
|
9702
|
+
})
|
|
9703
|
+
}),
|
|
9704
|
+
/* @__PURE__ */ jsx("td", {
|
|
9705
|
+
style: {
|
|
9706
|
+
padding: "6px 10px",
|
|
9707
|
+
whiteSpace: "nowrap"
|
|
9708
|
+
},
|
|
9709
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
9710
|
+
size: 1,
|
|
9711
|
+
muted: !0,
|
|
9712
|
+
style: MONO,
|
|
9713
|
+
children: asset.extension?.toUpperCase() || (isImageAsset(asset) ? "IMG" : "FICHIER")
|
|
9714
|
+
})
|
|
9715
|
+
}),
|
|
9716
|
+
/* @__PURE__ */ jsx("td", {
|
|
9717
|
+
style: {
|
|
9718
|
+
padding: "6px 10px",
|
|
9719
|
+
textAlign: "right",
|
|
9720
|
+
whiteSpace: "nowrap"
|
|
9721
|
+
},
|
|
9722
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
9723
|
+
size: 1,
|
|
9724
|
+
style: TABULAR,
|
|
9725
|
+
children: formatBytes(asset.size)
|
|
9726
|
+
})
|
|
9727
|
+
}),
|
|
9728
|
+
/* @__PURE__ */ jsx("td", {
|
|
9729
|
+
style: {
|
|
9730
|
+
padding: "6px 10px",
|
|
9731
|
+
textAlign: "right",
|
|
9732
|
+
whiteSpace: "nowrap"
|
|
9733
|
+
},
|
|
9734
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
9735
|
+
size: 1,
|
|
9736
|
+
muted: !0,
|
|
9737
|
+
style: TABULAR,
|
|
9738
|
+
children: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : "—"
|
|
9739
|
+
})
|
|
9740
|
+
}),
|
|
9741
|
+
/* @__PURE__ */ jsx("td", {
|
|
9742
|
+
style: {
|
|
9743
|
+
padding: "6px 10px",
|
|
9744
|
+
whiteSpace: "nowrap"
|
|
9745
|
+
},
|
|
9746
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
9747
|
+
size: 1,
|
|
9748
|
+
muted: !0,
|
|
9749
|
+
textOverflow: "ellipsis",
|
|
9750
|
+
children: folder ? folderName(folder) : "—"
|
|
9751
|
+
})
|
|
9752
|
+
}),
|
|
9753
|
+
/* @__PURE__ */ jsx("td", {
|
|
9754
|
+
style: {
|
|
9755
|
+
padding: "6px 10px",
|
|
9756
|
+
textAlign: "right",
|
|
9757
|
+
whiteSpace: "nowrap"
|
|
9758
|
+
},
|
|
9759
|
+
children: asset.uses === 0 ? /* @__PURE__ */ jsx(Badge, {
|
|
9760
|
+
tone: "caution",
|
|
9761
|
+
fontSize: 0,
|
|
9762
|
+
children: "0"
|
|
9763
|
+
}) : /* @__PURE__ */ jsx(Text, {
|
|
9764
|
+
size: 1,
|
|
9765
|
+
style: TABULAR,
|
|
9766
|
+
children: asset.uses ?? "—"
|
|
9767
|
+
})
|
|
9768
|
+
}),
|
|
9769
|
+
/* @__PURE__ */ jsx("td", {
|
|
9770
|
+
style: {
|
|
9771
|
+
padding: "6px 10px",
|
|
9772
|
+
textAlign: "right",
|
|
9773
|
+
whiteSpace: "nowrap"
|
|
9774
|
+
},
|
|
9775
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
9776
|
+
size: 1,
|
|
9777
|
+
muted: !0,
|
|
9778
|
+
style: TABULAR,
|
|
9779
|
+
children: formatDate(asset._createdAt)
|
|
9780
|
+
})
|
|
9781
|
+
})
|
|
9782
|
+
]
|
|
9783
|
+
}, asset._id);
|
|
9784
|
+
}) })]
|
|
9785
|
+
})
|
|
9786
|
+
});
|
|
9787
|
+
}
|
|
9788
|
+
function Metric(props) {
|
|
9789
|
+
return /* @__PURE__ */ jsxs(Stack, {
|
|
9790
|
+
gap: 2,
|
|
9791
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
9792
|
+
size: 0,
|
|
9793
|
+
muted: !0,
|
|
9794
|
+
children: props.label
|
|
9795
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
9796
|
+
size: 1,
|
|
9797
|
+
style: MONO,
|
|
9798
|
+
textOverflow: "ellipsis",
|
|
9799
|
+
children: props.value
|
|
9800
|
+
})]
|
|
9801
|
+
});
|
|
9802
|
+
}
|
|
9803
|
+
function AssetDetail(props) {
|
|
9804
|
+
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);
|
|
9805
|
+
useEffect(() => {
|
|
9806
|
+
setTitle(asset.title ?? ""), setAlt(asset.altText ?? ""), setDescription(asset.description ?? "");
|
|
9807
|
+
}, [
|
|
9808
|
+
asset._id,
|
|
9809
|
+
asset.title,
|
|
9810
|
+
asset.altText,
|
|
9811
|
+
asset.description
|
|
9812
|
+
]);
|
|
9813
|
+
let save = (patch) => {
|
|
9814
|
+
client.patch(asset._id).set(patch).commit().catch(() => {});
|
|
9815
|
+
}, commit = (field, value, original) => {
|
|
9816
|
+
let next = value.trim();
|
|
9817
|
+
next !== (original ?? "") && save({ [field]: next || void 0 });
|
|
9818
|
+
}, preview = thumbnailUrl(asset, { w: 640 }), copyUrl = () => {
|
|
9819
|
+
asset.url && navigator.clipboard?.writeText(asset.url).then(() => {
|
|
9820
|
+
setCopied(!0), setTimeout(() => setCopied(!1), 1500);
|
|
9821
|
+
});
|
|
9822
|
+
};
|
|
9823
|
+
return /* @__PURE__ */ jsx(Card, {
|
|
9824
|
+
borderLeft: !0,
|
|
9825
|
+
height: "fill",
|
|
9826
|
+
style: {
|
|
9827
|
+
width: 340,
|
|
9828
|
+
flex: "none"
|
|
9829
|
+
},
|
|
9830
|
+
overflow: "auto",
|
|
9831
|
+
tone: "transparent",
|
|
9832
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
9833
|
+
gap: 4,
|
|
9834
|
+
padding: 4,
|
|
9835
|
+
children: [
|
|
9836
|
+
/* @__PURE__ */ jsxs(Flex, {
|
|
9837
|
+
align: "center",
|
|
9838
|
+
justify: "space-between",
|
|
9839
|
+
gap: 2,
|
|
9840
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
9841
|
+
size: 1,
|
|
9842
|
+
weight: "semibold",
|
|
9843
|
+
textOverflow: "ellipsis",
|
|
9844
|
+
children: assetName(asset)
|
|
9845
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
9846
|
+
icon: CloseIcon,
|
|
9847
|
+
mode: "bleed",
|
|
9848
|
+
padding: 2,
|
|
9849
|
+
fontSize: 1,
|
|
9850
|
+
"aria-label": "Fermer",
|
|
9851
|
+
onClick: onClose
|
|
9852
|
+
})]
|
|
9853
|
+
}),
|
|
9854
|
+
/* @__PURE__ */ jsx(Card, {
|
|
9855
|
+
radius: 2,
|
|
9856
|
+
border: !0,
|
|
9857
|
+
overflow: "hidden",
|
|
9858
|
+
tone: "transparent",
|
|
9859
|
+
style: { background: "var(--card-muted-bg-color, rgba(127,127,127,0.08))" },
|
|
9860
|
+
children: preview ? /* @__PURE__ */ jsx("img", {
|
|
9861
|
+
src: preview,
|
|
9862
|
+
alt: asset.altText ?? "",
|
|
9863
|
+
style: {
|
|
9864
|
+
width: "100%",
|
|
9865
|
+
display: "block",
|
|
9866
|
+
maxHeight: 280,
|
|
9867
|
+
objectFit: "contain"
|
|
9868
|
+
}
|
|
9869
|
+
}) : /* @__PURE__ */ jsx(Flex, {
|
|
9870
|
+
align: "center",
|
|
9871
|
+
justify: "center",
|
|
9872
|
+
padding: 5,
|
|
9873
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
9874
|
+
size: 1,
|
|
9875
|
+
muted: !0,
|
|
9876
|
+
children: [asset.extension?.toUpperCase() || "Fichier", " — pas d'aperçu"]
|
|
9877
|
+
})
|
|
9878
|
+
})
|
|
9879
|
+
}),
|
|
9880
|
+
/* @__PURE__ */ jsxs(Flex, {
|
|
9881
|
+
gap: 2,
|
|
9882
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
9883
|
+
icon: CopyIcon,
|
|
9884
|
+
text: copied ? "Copié" : "Copier l'URL",
|
|
9885
|
+
mode: "ghost",
|
|
9886
|
+
fontSize: 1,
|
|
9887
|
+
onClick: copyUrl,
|
|
9888
|
+
disabled: !asset.url,
|
|
9889
|
+
style: { flex: 1 }
|
|
9890
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
9891
|
+
icon: LaunchIcon,
|
|
9892
|
+
text: "Ouvrir",
|
|
9893
|
+
mode: "ghost",
|
|
9894
|
+
fontSize: 1,
|
|
9895
|
+
onClick: () => asset.url && window.open(asset.url, "_blank", "noopener"),
|
|
9896
|
+
disabled: !asset.url,
|
|
9897
|
+
style: { flex: 1 }
|
|
9898
|
+
})]
|
|
8230
9899
|
}),
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
9900
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
9901
|
+
gap: 3,
|
|
9902
|
+
children: [
|
|
9903
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
9904
|
+
gap: 2,
|
|
9905
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
9906
|
+
size: 0,
|
|
9907
|
+
muted: !0,
|
|
9908
|
+
children: "Dossier"
|
|
9909
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
9910
|
+
fontSize: 1,
|
|
9911
|
+
value: folder ?? "",
|
|
9912
|
+
onChange: (event) => onMove(event.currentTarget.value || null),
|
|
9913
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
9914
|
+
value: "",
|
|
9915
|
+
children: "Non classé"
|
|
9916
|
+
}), folders.map((f) => /* @__PURE__ */ jsx("option", {
|
|
9917
|
+
value: f.id,
|
|
9918
|
+
children: f.name
|
|
9919
|
+
}, f.id))]
|
|
9920
|
+
})]
|
|
9921
|
+
}),
|
|
9922
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
9923
|
+
gap: 2,
|
|
9924
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
9925
|
+
size: 0,
|
|
9926
|
+
muted: !0,
|
|
9927
|
+
children: "Titre"
|
|
9928
|
+
}), /* @__PURE__ */ jsx(TextInput, {
|
|
9929
|
+
fontSize: 1,
|
|
9930
|
+
value: title,
|
|
9931
|
+
onChange: (e) => setTitle(e.currentTarget.value),
|
|
9932
|
+
onBlur: () => commit("title", title, asset.title),
|
|
9933
|
+
placeholder: "Titre du média"
|
|
9934
|
+
})]
|
|
9935
|
+
}),
|
|
9936
|
+
isImageAsset(asset) ? /* @__PURE__ */ jsxs(Stack, {
|
|
9937
|
+
gap: 2,
|
|
9938
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
9939
|
+
size: 0,
|
|
9940
|
+
muted: !0,
|
|
9941
|
+
children: "Texte alternatif (alt)"
|
|
9942
|
+
}), /* @__PURE__ */ jsx(TextInput, {
|
|
9943
|
+
fontSize: 1,
|
|
9944
|
+
value: alt,
|
|
9945
|
+
onChange: (e) => setAlt(e.currentTarget.value),
|
|
9946
|
+
onBlur: () => commit("altText", alt, asset.altText),
|
|
9947
|
+
placeholder: "Décrit l'image (SEO, accessibilité)"
|
|
9948
|
+
})]
|
|
9949
|
+
}) : null,
|
|
9950
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
9951
|
+
gap: 2,
|
|
9952
|
+
children: [/* @__PURE__ */ jsx(Label, {
|
|
9953
|
+
size: 0,
|
|
9954
|
+
muted: !0,
|
|
9955
|
+
children: "Description"
|
|
9956
|
+
}), /* @__PURE__ */ jsx(TextArea, {
|
|
9957
|
+
fontSize: 1,
|
|
9958
|
+
rows: 2,
|
|
9959
|
+
value: description,
|
|
9960
|
+
onChange: (e) => setDescription(e.currentTarget.value),
|
|
9961
|
+
onBlur: () => commit("description", description, asset.description)
|
|
9962
|
+
})]
|
|
9963
|
+
})
|
|
9964
|
+
]
|
|
9965
|
+
}),
|
|
9966
|
+
/* @__PURE__ */ jsxs(Grid, {
|
|
9967
|
+
gridTemplateColumns: [1, 2],
|
|
9968
|
+
gap: 3,
|
|
9969
|
+
children: [
|
|
9970
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
9971
|
+
label: "Fichier",
|
|
9972
|
+
value: asset.originalFilename ?? "—"
|
|
9973
|
+
}),
|
|
9974
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
9975
|
+
label: "Type",
|
|
9976
|
+
value: asset.extension?.toUpperCase() || asset._type.replace("sanity.", "")
|
|
9977
|
+
}),
|
|
9978
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
9979
|
+
label: "Taille",
|
|
9980
|
+
value: formatBytes(asset.size)
|
|
9981
|
+
}),
|
|
9982
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
9983
|
+
label: "Dimensions",
|
|
9984
|
+
value: asset.dimensions?.width ? `${asset.dimensions.width}×${asset.dimensions.height}` : "—"
|
|
9985
|
+
}),
|
|
9986
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
9987
|
+
label: "Usage",
|
|
9988
|
+
value: asset.uses === void 0 ? "—" : `${asset.uses}`
|
|
9989
|
+
}),
|
|
9990
|
+
/* @__PURE__ */ jsx(Metric, {
|
|
9991
|
+
label: "Ajouté",
|
|
9992
|
+
value: formatDate(asset._createdAt)
|
|
9993
|
+
})
|
|
9994
|
+
]
|
|
8235
9995
|
})
|
|
8236
9996
|
]
|
|
8237
|
-
})
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
})
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
9997
|
+
})
|
|
9998
|
+
});
|
|
9999
|
+
}
|
|
10000
|
+
function AssetsTool() {
|
|
10001
|
+
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), {
|
|
10002
|
+
search,
|
|
10003
|
+
type,
|
|
10004
|
+
usage
|
|
10005
|
+
}), sort, direction), [
|
|
10006
|
+
assets,
|
|
10007
|
+
folderMap,
|
|
10008
|
+
selection,
|
|
10009
|
+
search,
|
|
10010
|
+
type,
|
|
10011
|
+
usage,
|
|
10012
|
+
sort,
|
|
10013
|
+
direction
|
|
10014
|
+
]), opened = openedId ? assets.find((a) => a._id === openedId) ?? null : null, toggleSelect = useCallback((id) => {
|
|
10015
|
+
setSelectedIds((prev) => {
|
|
10016
|
+
let next = new Set(prev);
|
|
10017
|
+
return next.has(id) ? next.delete(id) : next.add(id), next;
|
|
10018
|
+
});
|
|
10019
|
+
}, []), toggleAll = useCallback(() => {
|
|
10020
|
+
setSelectedIds((prev) => {
|
|
10021
|
+
if (visible.every((a) => prev.has(a._id))) {
|
|
10022
|
+
let next = new Set(prev);
|
|
10023
|
+
for (let a of visible) next.delete(a._id);
|
|
10024
|
+
return next;
|
|
10025
|
+
}
|
|
10026
|
+
let next = new Set(prev);
|
|
10027
|
+
for (let a of visible) next.add(a._id);
|
|
10028
|
+
return next;
|
|
10029
|
+
});
|
|
10030
|
+
}, [visible]), clearSelection = useCallback(() => setSelectedIds(/* @__PURE__ */ new Set()), []), moveSelected = useCallback((folder) => {
|
|
10031
|
+
meta.moveAssets([...selectedIds], folder), clearSelection();
|
|
10032
|
+
}, [
|
|
10033
|
+
meta,
|
|
10034
|
+
selectedIds,
|
|
10035
|
+
clearSelection
|
|
10036
|
+
]);
|
|
10037
|
+
return loading && assets.length === 0 ? /* @__PURE__ */ jsx(Flex, {
|
|
10038
|
+
align: "center",
|
|
10039
|
+
justify: "center",
|
|
10040
|
+
padding: 6,
|
|
10041
|
+
children: /* @__PURE__ */ jsx(Spinner, { muted: !0 })
|
|
10042
|
+
}) : error ? /* @__PURE__ */ jsx(QueryError, {
|
|
10043
|
+
error,
|
|
10044
|
+
onRetry: refresh
|
|
10045
|
+
}) : /* @__PURE__ */ jsxs(Flex, {
|
|
10046
|
+
gap: 4,
|
|
10047
|
+
align: "stretch",
|
|
10048
|
+
style: { minHeight: 420 },
|
|
10049
|
+
children: [
|
|
10050
|
+
/* @__PURE__ */ jsx(Box, {
|
|
10051
|
+
style: {
|
|
10052
|
+
width: 220,
|
|
10053
|
+
flex: "none"
|
|
10054
|
+
},
|
|
10055
|
+
children: /* @__PURE__ */ jsx(FolderSidebar, {
|
|
10056
|
+
folders: meta.folders,
|
|
10057
|
+
counts,
|
|
10058
|
+
total: assets.length,
|
|
10059
|
+
selection,
|
|
10060
|
+
onSelect: setSelection,
|
|
10061
|
+
onCreate: meta.createFolder,
|
|
10062
|
+
onRename: meta.renameFolder,
|
|
10063
|
+
onDelete: (id) => {
|
|
10064
|
+
selection === id && setSelection(null), meta.deleteFolder(id);
|
|
10065
|
+
}
|
|
10066
|
+
})
|
|
10067
|
+
}),
|
|
10068
|
+
/* @__PURE__ */ jsxs(Stack, {
|
|
8248
10069
|
gap: 3,
|
|
10070
|
+
flex: 1,
|
|
10071
|
+
style: { minWidth: 0 },
|
|
8249
10072
|
children: [
|
|
8250
|
-
/* @__PURE__ */ jsx(
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
10073
|
+
/* @__PURE__ */ jsx(AssetsToolbar, {
|
|
10074
|
+
search,
|
|
10075
|
+
onSearch: setSearch,
|
|
10076
|
+
type,
|
|
10077
|
+
onType: setType,
|
|
10078
|
+
usage,
|
|
10079
|
+
onUsage: setUsage,
|
|
10080
|
+
sort,
|
|
10081
|
+
direction,
|
|
10082
|
+
onSort: (k, d) => {
|
|
10083
|
+
setSort(k), setDirection(d);
|
|
10084
|
+
},
|
|
10085
|
+
view,
|
|
10086
|
+
onView: setView,
|
|
10087
|
+
onRefresh: refresh,
|
|
10088
|
+
busy: loading
|
|
8254
10089
|
}),
|
|
10090
|
+
selectedIds.size > 0 ? /* @__PURE__ */ jsx(Card, {
|
|
10091
|
+
tone: "primary",
|
|
10092
|
+
border: !0,
|
|
10093
|
+
radius: 2,
|
|
10094
|
+
padding: 2,
|
|
10095
|
+
children: /* @__PURE__ */ jsxs(Flex, {
|
|
10096
|
+
align: "center",
|
|
10097
|
+
gap: 3,
|
|
10098
|
+
wrap: "wrap",
|
|
10099
|
+
children: [
|
|
10100
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
10101
|
+
size: 1,
|
|
10102
|
+
weight: "medium",
|
|
10103
|
+
children: [
|
|
10104
|
+
selectedIds.size,
|
|
10105
|
+
" sélectionné",
|
|
10106
|
+
selectedIds.size > 1 ? "s" : ""
|
|
10107
|
+
]
|
|
10108
|
+
}),
|
|
10109
|
+
/* @__PURE__ */ jsxs(Flex, {
|
|
10110
|
+
align: "center",
|
|
10111
|
+
gap: 2,
|
|
10112
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
10113
|
+
size: 1,
|
|
10114
|
+
muted: !0,
|
|
10115
|
+
children: "Déplacer vers"
|
|
10116
|
+
}), /* @__PURE__ */ jsxs(Select, {
|
|
10117
|
+
fontSize: 1,
|
|
10118
|
+
value: "",
|
|
10119
|
+
onChange: (e) => {
|
|
10120
|
+
let v = e.currentTarget.value;
|
|
10121
|
+
v === "__none" ? moveSelected(null) : v && moveSelected(v);
|
|
10122
|
+
},
|
|
10123
|
+
style: { width: 170 },
|
|
10124
|
+
children: [
|
|
10125
|
+
/* @__PURE__ */ jsx("option", {
|
|
10126
|
+
value: "",
|
|
10127
|
+
children: "Choisir…"
|
|
10128
|
+
}),
|
|
10129
|
+
/* @__PURE__ */ jsx("option", {
|
|
10130
|
+
value: "__none",
|
|
10131
|
+
children: "Non classé"
|
|
10132
|
+
}),
|
|
10133
|
+
meta.folders.map((f) => /* @__PURE__ */ jsx("option", {
|
|
10134
|
+
value: f.id,
|
|
10135
|
+
children: f.name
|
|
10136
|
+
}, f.id))
|
|
10137
|
+
]
|
|
10138
|
+
})]
|
|
10139
|
+
}),
|
|
10140
|
+
/* @__PURE__ */ jsx(Box, { flex: 1 }),
|
|
10141
|
+
/* @__PURE__ */ jsx(Button, {
|
|
10142
|
+
text: "Désélectionner",
|
|
10143
|
+
mode: "bleed",
|
|
10144
|
+
fontSize: 1,
|
|
10145
|
+
onClick: clearSelection
|
|
10146
|
+
})
|
|
10147
|
+
]
|
|
10148
|
+
})
|
|
10149
|
+
}) : null,
|
|
8255
10150
|
/* @__PURE__ */ jsxs(Text, {
|
|
8256
10151
|
size: 1,
|
|
8257
|
-
children: [
|
|
8258
|
-
"No read key. In the studio folder, the following command enables the project, writes the key to ",
|
|
8259
|
-
/* @__PURE__ */ jsx("code", { children: ".env" }),
|
|
8260
|
-
" and creates the log webhook:"
|
|
8261
|
-
]
|
|
8262
|
-
}),
|
|
8263
|
-
/* @__PURE__ */ jsx(Text, {
|
|
8264
|
-
size: 0,
|
|
8265
|
-
style: MONO,
|
|
8266
|
-
children: "npx ncf-kit setup --types page,homePage"
|
|
8267
|
-
}),
|
|
8268
|
-
/* @__PURE__ */ jsxs(Text, {
|
|
8269
|
-
size: 0,
|
|
8270
10152
|
muted: !0,
|
|
8271
10153
|
children: [
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
"projectKey: process.env.SANITY_STUDIO_NCF_PROJECT_KEY",
|
|
8277
|
-
"}"
|
|
8278
|
-
] }),
|
|
8279
|
-
" to sanity.config.ts and redeploy the studio. Or hide this tab with",
|
|
8280
|
-
" ",
|
|
8281
|
-
/* @__PURE__ */ jsxs("code", { children: [
|
|
8282
|
-
"tools: ",
|
|
8283
|
-
"{",
|
|
8284
|
-
"history: false",
|
|
8285
|
-
"}"
|
|
8286
|
-
] }),
|
|
8287
|
-
"."
|
|
10154
|
+
visible.length,
|
|
10155
|
+
" média",
|
|
10156
|
+
visible.length > 1 ? "s" : "",
|
|
10157
|
+
visible.length === assets.length ? "" : ` sur ${assets.length}`
|
|
8288
10158
|
]
|
|
10159
|
+
}),
|
|
10160
|
+
visible.length === 0 ? /* @__PURE__ */ jsx(Card, {
|
|
10161
|
+
border: !0,
|
|
10162
|
+
radius: 2,
|
|
10163
|
+
padding: 5,
|
|
10164
|
+
tone: "transparent",
|
|
10165
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
10166
|
+
size: 1,
|
|
10167
|
+
muted: !0,
|
|
10168
|
+
align: "center",
|
|
10169
|
+
children: [
|
|
10170
|
+
"Aucun média ",
|
|
10171
|
+
search || type !== "all" || usage !== "all" ? "ne correspond aux filtres" : selection ? "dans ce dossier" : "pour l’instant",
|
|
10172
|
+
"."
|
|
10173
|
+
]
|
|
10174
|
+
})
|
|
10175
|
+
}) : view === "grid" ? /* @__PURE__ */ jsx(Grid, {
|
|
10176
|
+
gridTemplateColumns: [
|
|
10177
|
+
2,
|
|
10178
|
+
3,
|
|
10179
|
+
4,
|
|
10180
|
+
5
|
|
10181
|
+
],
|
|
10182
|
+
gap: 3,
|
|
10183
|
+
children: visible.map((asset) => /* @__PURE__ */ jsx(AssetCard, {
|
|
10184
|
+
asset,
|
|
10185
|
+
selected: selectedIds.has(asset._id),
|
|
10186
|
+
onToggleSelect: () => toggleSelect(asset._id),
|
|
10187
|
+
onOpen: () => setOpenedId(asset._id)
|
|
10188
|
+
}, asset._id))
|
|
10189
|
+
}) : /* @__PURE__ */ jsx(AssetTable, {
|
|
10190
|
+
assets: visible,
|
|
10191
|
+
selected: selectedIds,
|
|
10192
|
+
onToggleSelect: toggleSelect,
|
|
10193
|
+
onToggleAll: toggleAll,
|
|
10194
|
+
onOpen: (asset) => setOpenedId(asset._id),
|
|
10195
|
+
folderName,
|
|
10196
|
+
folderOf,
|
|
10197
|
+
sortKey: sort,
|
|
10198
|
+
sortDirection: direction,
|
|
10199
|
+
onSort: (key) => {
|
|
10200
|
+
setSort(key), setDirection((d) => sort === key && d === "asc" ? "desc" : "asc");
|
|
10201
|
+
}
|
|
8289
10202
|
})
|
|
8290
10203
|
]
|
|
8291
|
-
})
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
* pas surchargé.
|
|
8301
|
-
*/
|
|
8302
|
-
function DesignSystemTool() {
|
|
8303
|
-
let config = useKitConfig(), schema = useSchema(), router = useRouter(), client = useKitClient(), hasDefaults = !!schema.get(config.componentPreview.defaultsType), opened = useRef(!1), open = useCallback(() => void openDesignSystem({
|
|
8304
|
-
config,
|
|
8305
|
-
hasDefaults,
|
|
8306
|
-
client,
|
|
8307
|
-
navigateIntent: (intent, params) => router.navigateIntent(intent, params),
|
|
8308
|
-
navigateUrl: (path) => router.navigateUrl({ path })
|
|
8309
|
-
}), [
|
|
8310
|
-
config,
|
|
8311
|
-
hasDefaults,
|
|
8312
|
-
client,
|
|
8313
|
-
router
|
|
8314
|
-
]);
|
|
8315
|
-
useEffect(() => {
|
|
8316
|
-
opened.current || (opened.current = !0, open());
|
|
8317
|
-
}, [open]);
|
|
8318
|
-
let available = hasDefaults || !!config.previewUrl;
|
|
8319
|
-
return /* @__PURE__ */ jsx(Card, {
|
|
8320
|
-
padding: 4,
|
|
8321
|
-
radius: 2,
|
|
8322
|
-
tone: available ? "default" : "caution",
|
|
8323
|
-
border: !0,
|
|
8324
|
-
children: /* @__PURE__ */ jsxs(Stack, {
|
|
8325
|
-
gap: 3,
|
|
8326
|
-
children: [
|
|
8327
|
-
/* @__PURE__ */ jsx(Text, {
|
|
8328
|
-
size: 1,
|
|
8329
|
-
weight: "semibold",
|
|
8330
|
-
children: "Design system"
|
|
8331
|
-
}),
|
|
8332
|
-
/* @__PURE__ */ jsx(Text, {
|
|
8333
|
-
size: 1,
|
|
8334
|
-
muted: !0,
|
|
8335
|
-
children: available ? `Opens the ${config.componentPreview.path} page in Presentation, with the component default values. A style changed here changes the component everywhere it is not overridden.` : "No component default values document and no previewUrl: nothing to open. See the kit checklist (README)."
|
|
8336
|
-
}),
|
|
8337
|
-
available && /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(Button, {
|
|
8338
|
-
text: "Open design system",
|
|
8339
|
-
tone: "primary",
|
|
8340
|
-
fontSize: 1,
|
|
8341
|
-
onClick: open
|
|
8342
|
-
}) })
|
|
8343
|
-
]
|
|
8344
|
-
})
|
|
10204
|
+
}),
|
|
10205
|
+
opened ? /* @__PURE__ */ jsx(AssetDetail, {
|
|
10206
|
+
asset: opened,
|
|
10207
|
+
folders: meta.folders,
|
|
10208
|
+
folder: folderOf(opened._id),
|
|
10209
|
+
onMove: (folder) => meta.moveAsset(opened._id, folder),
|
|
10210
|
+
onClose: () => setOpenedId(null)
|
|
10211
|
+
}) : null
|
|
10212
|
+
]
|
|
8345
10213
|
});
|
|
8346
10214
|
}
|
|
8347
10215
|
const store$1 = /* @__PURE__ */ new Map();
|
|
@@ -8897,6 +10765,60 @@ function isSlugInput(props) {
|
|
|
8897
10765
|
}
|
|
8898
10766
|
return !1;
|
|
8899
10767
|
}
|
|
10768
|
+
/**
|
|
10769
|
+
* Noms marketing des composants (type -> nom), en LECTURE SEULE et en direct.
|
|
10770
|
+
* Pour les surfaces hors onglet (ex. l'input du page builder qui réécrit les
|
|
10771
|
+
* libellés du menu d'insertion) : pas d'écriture, donc pas de provider unique.
|
|
10772
|
+
*/
|
|
10773
|
+
function useComponentNames() {
|
|
10774
|
+
let client = useKitClient(), [names, setNames] = useState(() => /* @__PURE__ */ new Map());
|
|
10775
|
+
return useEffect(() => {
|
|
10776
|
+
let cancelled = !1, load = () => client.fetch("*[_id == $id][0]{components}", { id: COMPONENT_META_ID }).then((doc) => {
|
|
10777
|
+
if (cancelled) return;
|
|
10778
|
+
let map = /* @__PURE__ */ new Map();
|
|
10779
|
+
for (let entry of doc?.components ?? []) entry._key && entry.name?.trim() && map.set(entry._key, entry.name.trim());
|
|
10780
|
+
setNames(map);
|
|
10781
|
+
}).catch(() => {});
|
|
10782
|
+
load();
|
|
10783
|
+
let subscription = client.listen("*[_id == $id]", { id: COMPONENT_META_ID }, {
|
|
10784
|
+
visibility: "query",
|
|
10785
|
+
events: ["mutation"]
|
|
10786
|
+
}).subscribe({
|
|
10787
|
+
next: () => void load(),
|
|
10788
|
+
error: () => {}
|
|
10789
|
+
});
|
|
10790
|
+
return () => {
|
|
10791
|
+
cancelled = !0, subscription.unsubscribe();
|
|
10792
|
+
};
|
|
10793
|
+
}, [client]), names;
|
|
10794
|
+
}
|
|
10795
|
+
function renameArrayMembers(schemaType, names) {
|
|
10796
|
+
let members = schemaType.of;
|
|
10797
|
+
if (names.size === 0 || !Array.isArray(members) || !members.some((member) => member?.name && names.has(member.name))) return schemaType;
|
|
10798
|
+
let of = members.map((member) => member?.name && names.has(member.name) ? Object.assign(Object.create(Object.getPrototypeOf(member)), member, { title: names.get(member.name) }) : member);
|
|
10799
|
+
return {
|
|
10800
|
+
...schemaType,
|
|
10801
|
+
of
|
|
10802
|
+
};
|
|
10803
|
+
}
|
|
10804
|
+
/**
|
|
10805
|
+
* Input d'un champ tableau : si ses membres portent un nom marketing (groupes /
|
|
10806
|
+
* renommage des composants), réécrit leurs titres pour que le menu d'insertion
|
|
10807
|
+
* les affiche. Sinon, délègue au comportement normal du kit (`Fallback`).
|
|
10808
|
+
*
|
|
10809
|
+
* Cible naturellement le page builder (et tout tableau qui accepte des sections
|
|
10810
|
+
* renommées) sans avoir à l'identifier : seuls les membres réellement renommés
|
|
10811
|
+
* changent.
|
|
10812
|
+
*/
|
|
10813
|
+
function createArrayNamesInput(Fallback) {
|
|
10814
|
+
return function ArrayNamesInput(props) {
|
|
10815
|
+
let names = useComponentNames(), schemaType = useMemo(() => renameArrayMembers(props.schemaType, names), [props.schemaType, names]);
|
|
10816
|
+
return schemaType === props.schemaType ? createElement(Fallback, props) : props.renderDefault({
|
|
10817
|
+
...props,
|
|
10818
|
+
schemaType
|
|
10819
|
+
});
|
|
10820
|
+
};
|
|
10821
|
+
}
|
|
8900
10822
|
const store = /* @__PURE__ */ new Map();
|
|
8901
10823
|
function entryFor(client, documentId) {
|
|
8902
10824
|
let { projectId, dataset } = client.config(), id = translationTodoId(documentId), key = `${projectId}:${dataset}:${id}`, entry = store.get(key);
|
|
@@ -10249,17 +12171,18 @@ function ncfMainDocuments(options, extra = {}) {
|
|
|
10249
12171
|
* pas le Studio de démarrer : l'onglet concerné affiche le détail à corriger.
|
|
10250
12172
|
*/
|
|
10251
12173
|
/** Noms des outils dans la barre du Studio. Exportés pour filtrer `tools`. */
|
|
10252
|
-
const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_HISTORY_TOOL = "ncf-history", NCF_DESIGN_SYSTEM_TOOL = "ncf-design-system", NCF_TOOL_NAMES = [
|
|
12174
|
+
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", NCF_TOOL_NAMES = [
|
|
10253
12175
|
NCF_PAGES_TOOL,
|
|
10254
12176
|
NCF_COMPONENTS_TOOL,
|
|
10255
12177
|
NCF_HISTORY_TOOL,
|
|
10256
|
-
NCF_DESIGN_SYSTEM_TOOL
|
|
12178
|
+
NCF_DESIGN_SYSTEM_TOOL,
|
|
12179
|
+
NCF_ASSETS_TOOL
|
|
10257
12180
|
];
|
|
10258
12181
|
/** Champs du formulaire : adresse sous le Slug d'une page, pastille sur les sections. */
|
|
10259
12182
|
function createKitInput(config, issues) {
|
|
10260
|
-
let Override = createOverrideInput(config), SlugUrl = createSlugUrlInput(config);
|
|
12183
|
+
let Override = createOverrideInput(config), SlugUrl = createSlugUrlInput(config), ArrayNames = createArrayNamesInput(Override);
|
|
10261
12184
|
function KitInput(props) {
|
|
10262
|
-
let children = isSlugInput(props) ? createElement(SlugUrl, props) : createElement(Override, props);
|
|
12185
|
+
let children = isSlugInput(props) ? createElement(SlugUrl, props) : props.schemaType.jsonType === "array" ? createElement(ArrayNames, props) : createElement(Override, props);
|
|
10263
12186
|
return createElement(KitProvider, {
|
|
10264
12187
|
config,
|
|
10265
12188
|
issues,
|
|
@@ -10332,6 +12255,21 @@ const ncfKit = definePlugin((options) => {
|
|
|
10332
12255
|
Component: DesignSystemTool
|
|
10333
12256
|
})
|
|
10334
12257
|
}
|
|
12258
|
+
},
|
|
12259
|
+
{
|
|
12260
|
+
name: "assets",
|
|
12261
|
+
tool: {
|
|
12262
|
+
name: NCF_ASSETS_TOOL,
|
|
12263
|
+
title: "Assets",
|
|
12264
|
+
icon: ImagesIcon,
|
|
12265
|
+
component: createToolComponent({
|
|
12266
|
+
name: "assets",
|
|
12267
|
+
title: "Assets",
|
|
12268
|
+
config,
|
|
12269
|
+
issues,
|
|
12270
|
+
Component: AssetsTool
|
|
12271
|
+
})
|
|
12272
|
+
}
|
|
10335
12273
|
}
|
|
10336
12274
|
].filter((d) => config.tools[d.name]).map((d) => d.tool),
|
|
10337
12275
|
schema: {
|
|
@@ -10354,6 +12292,6 @@ function hasLanguageField(schemaType, field) {
|
|
|
10354
12292
|
let fields = schemaType?.fields;
|
|
10355
12293
|
return Array.isArray(fields) && fields.some((f) => f?.name === field);
|
|
10356
12294
|
}
|
|
10357
|
-
export { ANNOTATION_TYPE, ActorName, 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_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, baseId, blockName, blockTypesFromSchema, buildContentsQuery, buildLinkGraph, buildPageRows, buildPagesQuery, codeEditorInput, collectLinks, collectOccurrences, colorForRow, colorFromString, columnId, compareVersions, componentDefaultsMainDocument, componentDefaultsMainDocuments, createPreviewLauncher, customEnvironment, defaultNodeSize, defaultsFieldName, defineCodeEmbedType, defineComponentDefaults, depth, deriveDocumentColumns, detectPageBuilderField, diffDocuments, diffWords, editIntentPath, explainGrantError, fallbackLayout, fetchDetail, fetchTimeline, fillTemplate, filterRows, fixCrossLanguageReferences, flatten, formatDocumentValue, groupPageRows, groupValue, hasBlockingIssue, humanizeBlockName, isDraftId, isKitType, isPrerelease, isSafeColumnKey, isSafeFieldPath, isTextChange, isVersionId, issuesForTool, keyForPath, kitSchemaTypes, layoutGraph, layoutSectionsMap, localesInRows, mergeVersions, missingPageTypes, moveColumn, 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, sortRows, summarize, toKebabCase, toPath, toUrl, topLevelBlockCount, uniqueColumnId, upsertLayout, urlOn, useAnnotations, useBoardLayout, useDocumentColumns, useHistory, useInternalColumns, useKitClient, useKitConfig, useKitContext, useKitUpdate, useOccurrences, useOptionalKitConfig, useOptionalKitContext, usePageBuilder, usePageContents, usePages, usePreviewTarget, useRegistration, validateConfig, withAlpha, withMoreTool, withSameLanguageReferences };
|
|
12295
|
+
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 };
|
|
10358
12296
|
|
|
10359
12297
|
//# sourceMappingURL=index.js.map
|