@nocode-factory/sanity-kit 2.50.0 → 2.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +106 -3
- package/dist/index.js +628 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -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/useComponentMeta.ts +159 -0
- package/src/hooks/useComponentNames.ts +39 -0
- package/src/index.ts +12 -1
- package/src/lib/componentMeta.ts +70 -0
- package/src/schema/boardLayout.ts +3 -1
- package/src/schema/componentMeta.ts +54 -0
- package/src/tools/components/BlockCard.tsx +20 -12
- package/src/tools/components/ComponentEditDialog.tsx +83 -0
- package/src/tools/components/ComponentsTool.tsx +195 -84
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -37,11 +37,11 @@ import { ControlsIcon } from "@sanity/icons/Controls";
|
|
|
37
37
|
import { Background, Controls, Handle, MarkerType, MiniMap, NodeResizer, Position, ReactFlow, ReactFlowProvider, useEdgesState, useNodesState, useReactFlow, useViewport } from "@xyflow/react";
|
|
38
38
|
import "@xyflow/react/dist/style.css";
|
|
39
39
|
import { TrashIcon } from "@sanity/icons/Trash";
|
|
40
|
+
import { EditIcon } from "@sanity/icons/Edit";
|
|
40
41
|
import { RefreshIcon } from "@sanity/icons/Refresh";
|
|
41
42
|
import { RestoreIcon } from "@sanity/icons/Restore";
|
|
42
43
|
import { UndoIcon } from "@sanity/icons/Undo";
|
|
43
44
|
import { FolderIcon } from "@sanity/icons/Folder";
|
|
44
|
-
import { EditIcon } from "@sanity/icons/Edit";
|
|
45
45
|
import { ThLargeIcon } from "@sanity/icons/ThLarge";
|
|
46
46
|
import { ThListIcon } from "@sanity/icons/ThList";
|
|
47
47
|
import { DocumentIcon } from "@sanity/icons/Document";
|
|
@@ -232,10 +232,74 @@ const TRANSLATION_TODO_TYPE = "ncfTranslationTodo", translationTodoId = (documen
|
|
|
232
232
|
}),
|
|
233
233
|
assetFolderType,
|
|
234
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
|
|
235
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 = [
|
|
236
299
|
BOARD_LAYOUT_TYPE,
|
|
237
300
|
TRANSLATION_TODO_TYPE,
|
|
238
|
-
ASSET_META_TYPE
|
|
301
|
+
ASSET_META_TYPE,
|
|
302
|
+
COMPONENT_META_TYPE
|
|
239
303
|
], boardNodeType = defineType({
|
|
240
304
|
name: BOARD_NODE_TYPE,
|
|
241
305
|
title: "Page position",
|
|
@@ -517,7 +581,8 @@ const TRANSLATION_TODO_TYPE = "ncfTranslationTodo", translationTodoId = (documen
|
|
|
517
581
|
columnType,
|
|
518
582
|
columnOptionType,
|
|
519
583
|
annotationType,
|
|
520
|
-
...assetMetaSchemaTypes
|
|
584
|
+
...assetMetaSchemaTypes,
|
|
585
|
+
...componentMetaSchemaTypes
|
|
521
586
|
], isKitType = (typeName) => NCF_HIDDEN_TYPES.includes(typeName), IGNORED_PREFIXES = [
|
|
522
587
|
"//",
|
|
523
588
|
"http://",
|
|
@@ -1341,7 +1406,7 @@ function explainGrantError(error) {
|
|
|
1341
1406
|
* quelle version. Recopiée de `package.json` par `npm version` (scripts/sync-version.mjs) ; un test
|
|
1342
1407
|
* le vérifie.
|
|
1343
1408
|
*/
|
|
1344
|
-
const KIT_VERSION = "2.
|
|
1409
|
+
const KIT_VERSION = "2.51.1";
|
|
1345
1410
|
/**
|
|
1346
1411
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1347
1412
|
*
|
|
@@ -1839,7 +1904,7 @@ function useKitUpdate() {
|
|
|
1839
1904
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1840
1905
|
}).catch(() => {}), () => controller.abort();
|
|
1841
1906
|
}, []);
|
|
1842
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.
|
|
1907
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.51.1") > 0);
|
|
1843
1908
|
return {
|
|
1844
1909
|
current: KIT_VERSION,
|
|
1845
1910
|
latest,
|
|
@@ -6761,6 +6826,43 @@ function componentIntentParams(type, namespace, preview, documentId) {
|
|
|
6761
6826
|
preview: fillTemplate(preview.live, type, namespace)
|
|
6762
6827
|
};
|
|
6763
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
|
+
}
|
|
6764
6866
|
/**
|
|
6765
6867
|
* Ouvre un composant : Presentation avec son rendu réel et ses valeurs par
|
|
6766
6868
|
* défaut côte à côte (le document des valeurs par défaut, champ du composant).
|
|
@@ -6827,6 +6929,126 @@ function useOpenComponent() {
|
|
|
6827
6929
|
]);
|
|
6828
6930
|
return !hasDefaults && !config.previewUrl ? null : (type) => void open(type);
|
|
6829
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
|
+
}
|
|
6830
7052
|
/**
|
|
6831
7053
|
* Tuile d'un bloc dans la grille.
|
|
6832
7054
|
*
|
|
@@ -6836,24 +7058,51 @@ function useOpenComponent() {
|
|
|
6836
7058
|
* à le lire.
|
|
6837
7059
|
*/
|
|
6838
7060
|
function BlockCard(props) {
|
|
6839
|
-
let { block, occurrence, namespace, thumbnailUrl, onOpen } = props, [failed, setFailed] = useState(!1), unused = occurrence.count === 0;
|
|
6840
|
-
return /* @__PURE__ */
|
|
7061
|
+
let { block, occurrence, namespace, thumbnailUrl, onOpen, onEdit } = props, [failed, setFailed] = useState(!1), unused = occurrence.count === 0;
|
|
7062
|
+
return /* @__PURE__ */ jsxs(Card, {
|
|
6841
7063
|
radius: 3,
|
|
6842
7064
|
shadow: 1,
|
|
6843
7065
|
padding: 0,
|
|
6844
|
-
as: onOpen ? "button" : void 0,
|
|
6845
|
-
onClick: onOpen,
|
|
6846
|
-
title: onOpen ? "See the real component and set its default values" : void 0,
|
|
6847
7066
|
style: {
|
|
6848
7067
|
height: "100%",
|
|
6849
7068
|
overflow: "hidden",
|
|
6850
|
-
|
|
6851
|
-
textAlign: "left",
|
|
6852
|
-
cursor: onOpen ? "pointer" : void 0
|
|
7069
|
+
position: "relative"
|
|
6853
7070
|
},
|
|
6854
|
-
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, {
|
|
6855
7093
|
gap: 0,
|
|
6856
|
-
|
|
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
|
+
},
|
|
6857
7106
|
children: [/* @__PURE__ */ jsx(Box, {
|
|
6858
7107
|
style: {
|
|
6859
7108
|
aspectRatio: "16 / 10",
|
|
@@ -6918,6 +7167,88 @@ function BlockCard(props) {
|
|
|
6918
7167
|
})]
|
|
6919
7168
|
})
|
|
6920
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
|
+
})
|
|
6921
7252
|
})
|
|
6922
7253
|
});
|
|
6923
7254
|
}
|
|
@@ -7383,22 +7714,34 @@ const ORDERS = [
|
|
|
7383
7714
|
label: "Schema order"
|
|
7384
7715
|
}
|
|
7385
7716
|
];
|
|
7717
|
+
/** Outil Composants, sous son provider d'organisation (groupes + noms). */
|
|
7386
7718
|
function ComponentsTool() {
|
|
7387
|
-
|
|
7388
|
-
|
|
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) => ({
|
|
7389
7724
|
occurrence,
|
|
7390
7725
|
block: byName.get(occurrence.type)
|
|
7391
7726
|
})).filter((row) => !!row.block);
|
|
7392
|
-
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);
|
|
7393
7728
|
}, [
|
|
7394
7729
|
occurrences,
|
|
7395
|
-
|
|
7730
|
+
named,
|
|
7396
7731
|
order
|
|
7397
|
-
]), unusedCount = occurrences.filter((o) => o.count === 0).length
|
|
7398
|
-
|
|
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, {
|
|
7399
7741
|
error,
|
|
7400
7742
|
onRetry: refresh
|
|
7401
|
-
})
|
|
7743
|
+
});
|
|
7744
|
+
if (loading && blockTypes.length === 0) return /* @__PURE__ */ jsxs(Flex, {
|
|
7402
7745
|
align: "center",
|
|
7403
7746
|
justify: "center",
|
|
7404
7747
|
padding: 5,
|
|
@@ -7408,7 +7751,8 @@ function ComponentsTool() {
|
|
|
7408
7751
|
muted: !0,
|
|
7409
7752
|
children: "Analyzing the page builder…"
|
|
7410
7753
|
})]
|
|
7411
|
-
})
|
|
7754
|
+
});
|
|
7755
|
+
if (blockTypes.length === 0) return /* @__PURE__ */ jsx(Card, {
|
|
7412
7756
|
padding: 4,
|
|
7413
7757
|
radius: 3,
|
|
7414
7758
|
shadow: 1,
|
|
@@ -7423,31 +7767,55 @@ function ComponentsTool() {
|
|
|
7423
7767
|
children: [
|
|
7424
7768
|
"The field \"",
|
|
7425
7769
|
config.pageBuilderField,
|
|
7426
|
-
"\" does not exist on any of the types",
|
|
7427
|
-
" ",
|
|
7770
|
+
"\" does not exist on any of the types ",
|
|
7428
7771
|
config.pageTypeNames.join(", "),
|
|
7429
|
-
", or it is not an array.
|
|
7772
|
+
", or it is not an array."
|
|
7430
7773
|
]
|
|
7431
7774
|
})]
|
|
7432
7775
|
})
|
|
7433
|
-
})
|
|
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, {
|
|
7434
7779
|
gap: 4,
|
|
7435
7780
|
children: [
|
|
7436
7781
|
/* @__PURE__ */ jsxs(Flex, {
|
|
7437
7782
|
gap: 2,
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
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
|
+
]
|
|
7451
7819
|
}),
|
|
7452
7820
|
/* @__PURE__ */ jsxs(Flex, {
|
|
7453
7821
|
align: "center",
|
|
@@ -7508,10 +7876,85 @@ function ComponentsTool() {
|
|
|
7508
7876
|
})
|
|
7509
7877
|
}),
|
|
7510
7878
|
view === "map" ? /* @__PURE__ */ jsx(SectionsMap, {
|
|
7511
|
-
blockTypes,
|
|
7879
|
+
blockTypes: named,
|
|
7512
7880
|
occurrences,
|
|
7513
7881
|
pagesById,
|
|
7514
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
|
+
})]
|
|
7515
7958
|
}) : /* @__PURE__ */ jsx(Grid, {
|
|
7516
7959
|
gridTemplateColumns: [
|
|
7517
7960
|
1,
|
|
@@ -7520,14 +7963,93 @@ function ComponentsTool() {
|
|
|
7520
7963
|
4
|
|
7521
7964
|
],
|
|
7522
7965
|
gap: 3,
|
|
7523
|
-
children: cards.map(
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
|
|
7529
|
-
|
|
7530
|
-
|
|
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) => {
|
|
8008
|
+
let value = event.currentTarget.value;
|
|
8009
|
+
setGroupDialog((d) => d && {
|
|
8010
|
+
...d,
|
|
8011
|
+
name: value
|
|
8012
|
+
});
|
|
8013
|
+
},
|
|
8014
|
+
onKeyDown: (event) => {
|
|
8015
|
+
event.key === "Enter" && groupDialog.name.trim() && (groupDialog.mode === "rename" && groupDialog.id ? meta.renameGroup(groupDialog.id, groupDialog.name) : meta.createGroup(groupDialog.name), setGroupDialog(null));
|
|
8016
|
+
}
|
|
8017
|
+
})
|
|
8018
|
+
})
|
|
8019
|
+
}) : null,
|
|
8020
|
+
deletingGroup ? /* @__PURE__ */ jsx(Dialog, {
|
|
8021
|
+
id: "component-group-delete",
|
|
8022
|
+
header: "Supprimer le groupe",
|
|
8023
|
+
onClose: () => setDeletingGroup(null),
|
|
8024
|
+
width: 0,
|
|
8025
|
+
footer: /* @__PURE__ */ jsxs(Flex, {
|
|
8026
|
+
justify: "flex-end",
|
|
8027
|
+
gap: 2,
|
|
8028
|
+
padding: 2,
|
|
8029
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
8030
|
+
text: "Annuler",
|
|
8031
|
+
mode: "bleed",
|
|
8032
|
+
onClick: () => setDeletingGroup(null)
|
|
8033
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
8034
|
+
text: "Supprimer",
|
|
8035
|
+
tone: "critical",
|
|
8036
|
+
onClick: () => {
|
|
8037
|
+
meta.deleteGroup(deletingGroup.id), setDeletingGroup(null);
|
|
8038
|
+
}
|
|
8039
|
+
})]
|
|
8040
|
+
}),
|
|
8041
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
8042
|
+
padding: 4,
|
|
8043
|
+
children: /* @__PURE__ */ jsxs(Text, {
|
|
8044
|
+
size: 1,
|
|
8045
|
+
children: [
|
|
8046
|
+
"Supprimer « ",
|
|
8047
|
+
deletingGroup.name,
|
|
8048
|
+
" » ? Les composants ne sont pas supprimés : ils repassent « Sans groupe »."
|
|
8049
|
+
]
|
|
8050
|
+
})
|
|
8051
|
+
})
|
|
8052
|
+
}) : null
|
|
7531
8053
|
]
|
|
7532
8054
|
});
|
|
7533
8055
|
}
|
|
@@ -10246,6 +10768,60 @@ function isSlugInput(props) {
|
|
|
10246
10768
|
}
|
|
10247
10769
|
return !1;
|
|
10248
10770
|
}
|
|
10771
|
+
/**
|
|
10772
|
+
* Noms marketing des composants (type -> nom), en LECTURE SEULE et en direct.
|
|
10773
|
+
* Pour les surfaces hors onglet (ex. l'input du page builder qui réécrit les
|
|
10774
|
+
* libellés du menu d'insertion) : pas d'écriture, donc pas de provider unique.
|
|
10775
|
+
*/
|
|
10776
|
+
function useComponentNames() {
|
|
10777
|
+
let client = useKitClient(), [names, setNames] = useState(() => /* @__PURE__ */ new Map());
|
|
10778
|
+
return useEffect(() => {
|
|
10779
|
+
let cancelled = !1, load = () => client.fetch("*[_id == $id][0]{components}", { id: COMPONENT_META_ID }).then((doc) => {
|
|
10780
|
+
if (cancelled) return;
|
|
10781
|
+
let map = /* @__PURE__ */ new Map();
|
|
10782
|
+
for (let entry of doc?.components ?? []) entry._key && entry.name?.trim() && map.set(entry._key, entry.name.trim());
|
|
10783
|
+
setNames(map);
|
|
10784
|
+
}).catch(() => {});
|
|
10785
|
+
load();
|
|
10786
|
+
let subscription = client.listen("*[_id == $id]", { id: COMPONENT_META_ID }, {
|
|
10787
|
+
visibility: "query",
|
|
10788
|
+
events: ["mutation"]
|
|
10789
|
+
}).subscribe({
|
|
10790
|
+
next: () => void load(),
|
|
10791
|
+
error: () => {}
|
|
10792
|
+
});
|
|
10793
|
+
return () => {
|
|
10794
|
+
cancelled = !0, subscription.unsubscribe();
|
|
10795
|
+
};
|
|
10796
|
+
}, [client]), names;
|
|
10797
|
+
}
|
|
10798
|
+
function renameArrayMembers(schemaType, names) {
|
|
10799
|
+
let members = schemaType.of;
|
|
10800
|
+
if (names.size === 0 || !Array.isArray(members) || !members.some((member) => member?.name && names.has(member.name))) return schemaType;
|
|
10801
|
+
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);
|
|
10802
|
+
return {
|
|
10803
|
+
...schemaType,
|
|
10804
|
+
of
|
|
10805
|
+
};
|
|
10806
|
+
}
|
|
10807
|
+
/**
|
|
10808
|
+
* Input d'un champ tableau : si ses membres portent un nom marketing (groupes /
|
|
10809
|
+
* renommage des composants), réécrit leurs titres pour que le menu d'insertion
|
|
10810
|
+
* les affiche. Sinon, délègue au comportement normal du kit (`Fallback`).
|
|
10811
|
+
*
|
|
10812
|
+
* Cible naturellement le page builder (et tout tableau qui accepte des sections
|
|
10813
|
+
* renommées) sans avoir à l'identifier : seuls les membres réellement renommés
|
|
10814
|
+
* changent.
|
|
10815
|
+
*/
|
|
10816
|
+
function createArrayNamesInput(Fallback) {
|
|
10817
|
+
return function ArrayNamesInput(props) {
|
|
10818
|
+
let names = useComponentNames(), schemaType = useMemo(() => renameArrayMembers(props.schemaType, names), [props.schemaType, names]);
|
|
10819
|
+
return schemaType === props.schemaType ? createElement(Fallback, props) : props.renderDefault({
|
|
10820
|
+
...props,
|
|
10821
|
+
schemaType
|
|
10822
|
+
});
|
|
10823
|
+
};
|
|
10824
|
+
}
|
|
10249
10825
|
const store = /* @__PURE__ */ new Map();
|
|
10250
10826
|
function entryFor(client, documentId) {
|
|
10251
10827
|
let { projectId, dataset } = client.config(), id = translationTodoId(documentId), key = `${projectId}:${dataset}:${id}`, entry = store.get(key);
|
|
@@ -11607,9 +12183,9 @@ const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_
|
|
|
11607
12183
|
];
|
|
11608
12184
|
/** Champs du formulaire : adresse sous le Slug d'une page, pastille sur les sections. */
|
|
11609
12185
|
function createKitInput(config, issues) {
|
|
11610
|
-
let Override = createOverrideInput(config), SlugUrl = createSlugUrlInput(config);
|
|
12186
|
+
let Override = createOverrideInput(config), SlugUrl = createSlugUrlInput(config), ArrayNames = createArrayNamesInput(Override);
|
|
11611
12187
|
function KitInput(props) {
|
|
11612
|
-
let children = isSlugInput(props) ? createElement(SlugUrl, props) : createElement(Override, props);
|
|
12188
|
+
let children = isSlugInput(props) ? createElement(SlugUrl, props) : props.schemaType.jsonType === "array" ? createElement(ArrayNames, props) : createElement(Override, props);
|
|
11613
12189
|
return createElement(KitProvider, {
|
|
11614
12190
|
config,
|
|
11615
12191
|
issues,
|
|
@@ -11719,6 +12295,6 @@ function hasLanguageField(schemaType, field) {
|
|
|
11719
12295
|
let fields = schemaType?.fields;
|
|
11720
12296
|
return Array.isArray(fields) && fields.some((f) => f?.name === field);
|
|
11721
12297
|
}
|
|
11722
|
-
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, groupPageRows, groupValue, hasBlockingIssue, humanizeBlockName, isDraftId, isImageAsset, 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, sortAssets, sortRows, summarize, thumbnailUrl, toKebabCase, toPath, toUrl, topLevelBlockCount, uniqueColumnId, upsertLayout, urlOn, useAnnotations, useAssetMeta, useAssets, useBoardLayout, useDocumentColumns, useHistory, useInternalColumns, useKitClient, useKitConfig, useKitContext, useKitUpdate, useOccurrences, useOptionalKitConfig, useOptionalKitContext, usePageBuilder, usePageContents, usePages, usePreviewTarget, useRegistration, validateConfig, withAlpha, withMoreTool, withSameLanguageReferences };
|
|
12298
|
+
export { ANNOTATION_TYPE, ActorName, AssetsTool, BOARD_LAYOUT_ID, BOARD_LAYOUT_TYPE, BRAIN_NODE_SIZE, BoardLayoutProvider, COLUMN_TYPE, CONTENT_SCAN_LIMIT, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, CUSTOM_ENVIRONMENT_ID, CodeEditorInput, CodeEmbedInput, DATA_PREFIX, DEFAULT_BOARD_TAGS, DEFAULT_COMPONENT_DEFAULTS_TYPE, DEFAULT_COMPONENT_PREVIEW, DEFAULT_I18N, DEFAULT_INTERNAL_FIELDS, DEFAULT_MORE_TOOLS, DEFAULT_PAGE_BUILDER_FIELD, DEFAULT_SLUG_FIELD, DEFAULT_TITLE_FIELD, HelpTextStyle, KIT_API_VERSION, KIT_VERSION, NCF_ASSETS_TOOL, NCF_COMPONENTS_TOOL, NCF_DESIGN_SYSTEM_TOOL, NCF_HIDDEN_TYPES, NCF_HISTORY_TOOL, NCF_MORE_TOOL, NCF_PAGES_TOOL, NCF_TOOL_NAMES, NODE_FIELD_TYPE, NODE_HEIGHT, NODE_WIDTH, NcfKitUpdate, NcfPreviewHeader, NcfPreviewLauncher, PERSPECTIVES, PROJECTION, SECTION_NODE_TYPE, STATUS_COLORS, STATUS_LABELS, SharePreview, UNSET_LABEL, addColumn, addColumnOption, announce, applySavedPositions, assetName, assetsInFolder, assignmentMap, baseId, blockName, blockTypesFromSchema, buildContentsQuery, buildLinkGraph, buildPageRows, buildPagesQuery, codeEditorInput, collectLinks, collectOccurrences, colorForRow, colorFromString, columnId, compareVersions, componentDefaultsMainDocument, componentDefaultsMainDocuments, countByFolder, createPreviewLauncher, customEnvironment, defaultNodeSize, defaultsFieldName, defineCodeEmbedType, defineComponentDefaults, depth, deriveDocumentColumns, detectPageBuilderField, diffDocuments, diffWords, editIntentPath, explainGrantError, fallbackLayout, fetchDetail, fetchTimeline, fillTemplate, filterAssets, filterRows, fixCrossLanguageReferences, flatten, formatBytes, formatDocumentValue, groupComponents, groupMap, groupPageRows, groupValue, hasBlockingIssue, humanizeBlockName, isDraftId, isImageAsset, isKitType, isPrerelease, isSafeColumnKey, isSafeFieldPath, isTextChange, isVersionId, issuesForTool, keyForPath, kitSchemaTypes, layoutGraph, layoutSectionsMap, localesInRows, mergeVersions, missingPageTypes, moveColumn, nameMap, ncfAllowedOrigins, ncfKit, ncfMainDocuments, ncfPresentationComponents, ncfPreviewComponents, normalizeInternalPath, normalizePath, occurrencesForTypes, pageThumbnailUrl, pageTypeFor, pageTypesFromSiteRoutes, pageTypesWithoutBuilder, parentPath, presentationPath, pruneSavedPositions, releaseId, removeColumn, renameColumn, requestPreviewGrant, requiredUnlessDefault, requiredUnlessDefaultFor, resolveColorBy, resolveConfig, resolvePageBuilderField, sectionNamesFromDefaults, segments, slugKey, sortAssets, sortRows, summarize, thumbnailUrl, toKebabCase, toPath, toUrl, topLevelBlockCount, uniqueColumnId, upsertLayout, urlOn, useAnnotations, useAssetMeta, useAssets, useBoardLayout, useComponentNames, useDocumentColumns, useHistory, useInternalColumns, useKitClient, useKitConfig, useKitContext, useKitUpdate, useOccurrences, useOptionalKitConfig, useOptionalKitContext, usePageBuilder, usePageContents, usePages, usePreviewTarget, useRegistration, validateConfig, withAlpha, withCustomNames, withMoreTool, withSameLanguageReferences };
|
|
11723
12299
|
|
|
11724
12300
|
//# sourceMappingURL=index.js.map
|