@nocode-factory/sanity-kit 2.2.2 → 2.4.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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SanityClient, Schema, Tool } from "sanity";
1
+ import { SanityClient, Schema, Tool, ToolMenuProps } from "sanity";
2
2
  import { ReactNode } from "react";
3
3
  import { PreviewHeaderProps } from "sanity/presentation";
4
4
  /**
@@ -1068,6 +1068,73 @@ export declare function ncfPreviewComponents(): {
1068
1068
  component: typeof NcfPreviewHeader;
1069
1069
  };
1070
1070
  };
1071
+ /**
1072
+ * Lanceur d'aperçu, posé dans la barre du haut à droite des outils.
1073
+ *
1074
+ * Deux questions, une seule poignée : **quelle version du site**, et **quel
1075
+ * état du contenu**. On choisit, on ouvre.
1076
+ *
1077
+ * Volontairement sans mémoire, contrairement au sélecteur de l'onglet Pages :
1078
+ * ici on lance une consultation, on ne règle pas un mode de travail. Un
1079
+ * bouton de barre qui retiendrait un état finirait par mentir sur ce qu'on
1080
+ * regarde ailleurs.
1081
+ */
1082
+ export declare function NcfPreviewLauncher(props: ToolMenuProps): import("react").JSX.Element;
1083
+ /**
1084
+ * Le lanceur, muni de la configuration du kit.
1085
+ *
1086
+ * Le menu des outils est rendu hors de l'arbre des outils : il n'hérite donc
1087
+ * d'aucun de leurs contextes, et doit porter le sien.
1088
+ */
1089
+ export declare function createPreviewLauncher(config: ResolvedKitConfig, issues: ConfigIssue[]): (props: ToolMenuProps) => import("react").JSX.Element;
1090
+ /**
1091
+ * Signale qu'une version plus récente du kit existe.
1092
+ *
1093
+ * **Il ne met pas à jour.** Un Studio tourne dans un navigateur : il ne peut
1094
+ * ni installer un paquet sur le poste d'un développeur, ni se redéployer. Ce
1095
+ * bouton dit ce qui manque et donne la commande — prétendre faire plus serait
1096
+ * mentir sur ce qui se passe.
1097
+ *
1098
+ * Invisible tant que le kit est à jour : un bouton permanent qui ne dit rien
1099
+ * finit par ne plus être lu.
1100
+ */
1101
+ export declare function NcfKitUpdate(props: {
1102
+ inline?: boolean;
1103
+ }): import("react").JSX.Element | null;
1104
+ interface KitUpdate {
1105
+ current: string;
1106
+ latest: string | null;
1107
+ /** Vrai seulement quand une version stable dépasse celle qui s'exécute. */
1108
+ available: boolean;
1109
+ /** Commande à lancer, prête à copier. */
1110
+ command: string;
1111
+ }
1112
+ /**
1113
+ * Compare la version exécutée à la dernière publiée.
1114
+ *
1115
+ * Un Studio tourne dans un navigateur : il ne peut ni installer un paquet ni
1116
+ * se redéployer. Il peut en revanche dire qu'il est en retard, et donner la
1117
+ * commande — c'est tout ce qu'un bouton peut honnêtement offrir ici.
1118
+ *
1119
+ * Le registre npm autorise les requêtes navigateur, et le paquet est public :
1120
+ * aucune authentification n'est nécessaire.
1121
+ *
1122
+ * Échoue en silence : ne pas savoir si une mise à jour existe ne doit gêner
1123
+ * personne.
1124
+ */
1125
+ export declare function useKitUpdate(): KitUpdate;
1126
+ /**
1127
+ * Comparaison de deux versions sémantiques.
1128
+ *
1129
+ * Suffisant pour ce qu'on en fait — savoir si une version publiée dépasse
1130
+ * celle qu'on exécute. Les mentions de pré-publication (`2.4.0-rc.1`) sont
1131
+ * ignorées : on ne propose jamais d'y passer.
1132
+ *
1133
+ * Rend 1 si `a` est postérieure, -1 si antérieure, 0 si égales.
1134
+ */
1135
+ export declare function compareVersions(a: string, b: string): number;
1136
+ /** Une version de pré-publication ne se propose pas. */
1137
+ export declare const isPrerelease: (version: string) => boolean;
1071
1138
  /**
1072
1139
  * Délivre un lien de préversion à partager.
1073
1140
  *
@@ -1203,7 +1270,7 @@ export declare function ActorName(props: {
1203
1270
  * Version du kit, rapportée au service pour savoir quels projets tournent sur
1204
1271
  * quelle version. Tenue à jour avec `package.json`.
1205
1272
  */
1206
- export declare const KIT_VERSION = "2.2.2";
1273
+ export declare const KIT_VERSION = "2.4.0";
1207
1274
  /**
1208
1275
  * Données de la page proposées comme colonnes.
1209
1276
  *
@@ -1683,5 +1750,5 @@ export declare const NCF_TOOL_NAMES: readonly ["ncf-pages", "ncf-components", "n
1683
1750
  * pas le Studio de démarrer : l'onglet concerné affiche le détail à corriger.
1684
1751
  */
1685
1752
  export declare const ncfKit: import("sanity").Plugin<NcfKitConfig>;
1686
- export { type AddColumnInput, type Annotation, type AnnotationsState, type BlockOccurrence, type BlockTypeInfo, type BoardEdge, type BoardGraph, type BoardLayoutState, type BoardNode, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, type Change, type ChangeKind, type CollectedLinks, type ColorBy, type ColorOptions, type ConfigIssue, type DeriveOptions, type GroupBy, type GroupOptions, type HistoryDetail, type HistoryEvent, type IssueLevel, type KitContextValue, type LayoutMode, type MergedDoc, type NcfBoardTag, type NcfComponentPreviewConfig, type NcfDocumentColumn, type NcfEnvironment, type NcfHistoryConfig, type NcfI18nConfig, type NcfInternalField, type NcfInternalFieldOption, type NcfKitConfig, type NcfPageTypeConfig, type NcfPageTypeInput, type NcfToolName, type NcfToolsConfig, type NodeLayout, type NodePosition, type OccurrenceInput, type OccurrencePage, type OccurrencesState, type PageContent, type PageContentsState, type PageDoc, type PageFilters, type PageRow, type PageStatus, type PagesState, type PathInput, type Positioned, type PresentationOptions, type PreviewGrant, type PreviewPerspective, type PreviewTargetState, type ProjectStatus, type Registration, type ResolvedComponentPreview, type ResolvedDocumentColumn, type ResolvedHistory, type ResolvedI18n, type ResolvedKitConfig, type ResolvedPageType, type RowColor, type RowGroup, type SchemaFieldLike, type SchemaTypeLike, type SectionLayout, type SectionMapNode, type SectionOrder, type SectionsMapOptions, type Segment, type SiteRoutesRegistry, type SortDirection, type SortKey, type ThumbnailInput, type VersionedDoc };
1753
+ export { type AddColumnInput, type Annotation, type AnnotationsState, type BlockOccurrence, type BlockTypeInfo, type BoardEdge, type BoardGraph, type BoardLayoutState, type BoardNode, CONTENT_SCAN_LIMIT as OCCURRENCE_SCAN_LIMIT, type Change, type ChangeKind, type CollectedLinks, type ColorBy, type ColorOptions, type ConfigIssue, type DeriveOptions, type GroupBy, type GroupOptions, type HistoryDetail, type HistoryEvent, type IssueLevel, type KitContextValue, type KitUpdate, type LayoutMode, type MergedDoc, type NcfBoardTag, type NcfComponentPreviewConfig, type NcfDocumentColumn, type NcfEnvironment, type NcfHistoryConfig, type NcfI18nConfig, type NcfInternalField, type NcfInternalFieldOption, type NcfKitConfig, type NcfPageTypeConfig, type NcfPageTypeInput, type NcfToolName, type NcfToolsConfig, type NodeLayout, type NodePosition, type OccurrenceInput, type OccurrencePage, type OccurrencesState, type PageContent, type PageContentsState, type PageDoc, type PageFilters, type PageRow, type PageStatus, type PagesState, type PathInput, type Positioned, type PresentationOptions, type PreviewGrant, type PreviewPerspective, type PreviewTargetState, type ProjectStatus, type Registration, type ResolvedComponentPreview, type ResolvedDocumentColumn, type ResolvedHistory, type ResolvedI18n, type ResolvedKitConfig, type ResolvedPageType, type RowColor, type RowGroup, type SchemaFieldLike, type SchemaTypeLike, type SectionLayout, type SectionMapNode, type SectionOrder, type SectionsMapOptions, type Segment, type SiteRoutesRegistry, type SortDirection, type SortKey, type ThumbnailInput, type VersionedDoc };
1687
1754
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -6,7 +6,11 @@ import { Badge, Box, Button, Card, Container, Flex, Grid, Select, Spinner, Stack
6
6
  import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { IntentLink, useRouter } from "sanity/router";
9
+ import { EyeOpenIcon } from "@sanity/icons/EyeOpen";
10
+ import { LaunchIcon } from "@sanity/icons/Launch";
11
+ import { ArrowUpIcon } from "@sanity/icons/ArrowUp";
9
12
  import { CheckmarkIcon } from "@sanity/icons/Checkmark";
13
+ import { CopyIcon } from "@sanity/icons/Copy";
10
14
  import { CloseIcon } from "@sanity/icons/Close";
11
15
  import { EarthGlobeIcon } from "@sanity/icons/EarthGlobe";
12
16
  import { ProjectsIcon } from "@sanity/icons/Projects";
@@ -23,7 +27,6 @@ import { SyncIcon } from "@sanity/icons/Sync";
23
27
  import { ControlsIcon } from "@sanity/icons/Controls";
24
28
  import { Background, Controls, Handle, MarkerType, MiniMap, NodeResizer, Position, ReactFlow, ReactFlowProvider, useEdgesState, useNodesState, useReactFlow, useViewport } from "@xyflow/react";
25
29
  import "@xyflow/react/dist/style.css";
26
- import { LaunchIcon } from "@sanity/icons/Launch";
27
30
  import { TrashIcon } from "@sanity/icons/Trash";
28
31
  import { RefreshIcon } from "@sanity/icons/Refresh";
29
32
  import { RestoreIcon } from "@sanity/icons/Restore";
@@ -1271,7 +1274,7 @@ function explainGrantError(error) {
1271
1274
  * Version du kit, rapportée au service pour savoir quels projets tournent sur
1272
1275
  * quelle version. Tenue à jour avec `package.json`.
1273
1276
  */
1274
- const KIT_VERSION = "2.2.2";
1277
+ const KIT_VERSION = "2.4.0";
1275
1278
  /**
1276
1279
  * Signale ce Studio au service du kit, une fois par montage.
1277
1280
  *
@@ -1395,6 +1398,379 @@ function createToolComponent(args) {
1395
1398
  };
1396
1399
  }
1397
1400
  /**
1401
+ * Petit panneau ancré à son déclencheur.
1402
+ *
1403
+ * Positionné en `fixed` et non en `absolute` : le tableau défile
1404
+ * horizontalement, et un panneau posé dans ce conteneur serait rogné.
1405
+ */
1406
+ function InlinePopover(props) {
1407
+ let { trigger, children, width = 200, onOpenChange } = props, [open, setOpen] = useState(!1), [at, setAt] = useState(null), anchor = useRef(null), panel = useRef(null), toggle = () => {
1408
+ let rect = anchor.current?.getBoundingClientRect();
1409
+ if (rect) {
1410
+ let below = window.innerHeight - rect.bottom;
1411
+ setAt({
1412
+ top: below > 240 ? rect.bottom + 4 : Math.max(8, rect.top - 244),
1413
+ left: Math.min(rect.left, window.innerWidth - width - 12)
1414
+ });
1415
+ }
1416
+ setOpen((value) => (onOpenChange?.(!value), !value));
1417
+ }, close = () => {
1418
+ setOpen(!1), onOpenChange?.(!1);
1419
+ };
1420
+ return useEffect(() => {
1421
+ if (!open) return;
1422
+ let onDown = (event) => {
1423
+ let target = event.target;
1424
+ panel.current?.contains(target) || anchor.current?.contains(target) || close();
1425
+ }, onKey = (event) => {
1426
+ event.key === "Escape" && close();
1427
+ };
1428
+ return document.addEventListener("mousedown", onDown), document.addEventListener("keydown", onKey), () => {
1429
+ document.removeEventListener("mousedown", onDown), document.removeEventListener("keydown", onKey);
1430
+ };
1431
+ }, [open]), /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
1432
+ ref: anchor,
1433
+ style: {
1434
+ display: "block",
1435
+ minWidth: 0
1436
+ },
1437
+ children: trigger({
1438
+ open,
1439
+ toggle
1440
+ })
1441
+ }), open && at && /* @__PURE__ */ jsx("div", {
1442
+ ref: panel,
1443
+ style: {
1444
+ position: "fixed",
1445
+ top: at.top,
1446
+ left: at.left,
1447
+ width,
1448
+ zIndex: 1e3
1449
+ },
1450
+ children: /* @__PURE__ */ jsx(Card, {
1451
+ radius: 3,
1452
+ shadow: 3,
1453
+ padding: 1,
1454
+ style: {
1455
+ maxHeight: 240,
1456
+ overflowY: "auto"
1457
+ },
1458
+ children: children({ close })
1459
+ })
1460
+ })] });
1461
+ }
1462
+ /**
1463
+ * Jetons partagés par les vues du kit.
1464
+ *
1465
+ * Mode Operate : la couleur sert l'état et la sélection, jamais la décoration.
1466
+ * Les fonds teintés restent sous le seuil où le texte du Studio perd son
1467
+ * contraste, dans les deux thèmes.
1468
+ */
1469
+ /** Teinte de fond d'une ligne ou d'une carte porteuse d'un critère. */
1470
+ const TABULAR = { fontVariantNumeric: "tabular-nums" }, MONO = {
1471
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
1472
+ fontVariantNumeric: "tabular-nums",
1473
+ letterSpacing: "-0.01em"
1474
+ }, CELL = { minWidth: 0 }, BORDER = "var(--card-border-color, rgba(127,127,127,0.22))", OPTION_COLORS = [
1475
+ "#f5a623",
1476
+ "#43d675",
1477
+ "#2276fc",
1478
+ "#f03e3e",
1479
+ "#a855f7",
1480
+ "#8a8a8a"
1481
+ ], DIFF = {
1482
+ removedLine: "color-mix(in srgb, #f03e3e 9%, transparent)",
1483
+ addedLine: "color-mix(in srgb, #2f9e44 11%, transparent)",
1484
+ removedWord: "color-mix(in srgb, #f03e3e 26%, transparent)",
1485
+ addedWord: "color-mix(in srgb, #2f9e44 30%, transparent)",
1486
+ removedMark: "#e03131",
1487
+ addedMark: "#2f9e44"
1488
+ };
1489
+ /**
1490
+ * Comparaison de deux versions sémantiques.
1491
+ *
1492
+ * Suffisant pour ce qu'on en fait — savoir si une version publiée dépasse
1493
+ * celle qu'on exécute. Les mentions de pré-publication (`2.4.0-rc.1`) sont
1494
+ * ignorées : on ne propose jamais d'y passer.
1495
+ *
1496
+ * Rend 1 si `a` est postérieure, -1 si antérieure, 0 si égales.
1497
+ */
1498
+ function compareVersions(a, b) {
1499
+ let parse = (v) => v.trim().replace(/^v/, "").split("-")[0].split(".").map((part) => Number.parseInt(part, 10) || 0), left = parse(a), right = parse(b);
1500
+ for (let i = 0; i < 3; i += 1) {
1501
+ let l = left[i] ?? 0, r = right[i] ?? 0;
1502
+ if (l !== r) return l > r ? 1 : -1;
1503
+ }
1504
+ return 0;
1505
+ }
1506
+ /** Une version de pré-publication ne se propose pas. */
1507
+ const isPrerelease = (version) => version.includes("-");
1508
+ /**
1509
+ * Compare la version exécutée à la dernière publiée.
1510
+ *
1511
+ * Un Studio tourne dans un navigateur : il ne peut ni installer un paquet ni
1512
+ * se redéployer. Il peut en revanche dire qu'il est en retard, et donner la
1513
+ * commande — c'est tout ce qu'un bouton peut honnêtement offrir ici.
1514
+ *
1515
+ * Le registre npm autorise les requêtes navigateur, et le paquet est public :
1516
+ * aucune authentification n'est nécessaire.
1517
+ *
1518
+ * Échoue en silence : ne pas savoir si une mise à jour existe ne doit gêner
1519
+ * personne.
1520
+ */
1521
+ function useKitUpdate() {
1522
+ let [latest, setLatest] = useState(null);
1523
+ useEffect(() => {
1524
+ let controller = new AbortController();
1525
+ return fetch("https://registry.npmjs.org/@nocode-factory/sanity-kit/latest", { signal: controller.signal }).then((response) => response.ok ? response.json() : null).then((body) => {
1526
+ !controller.signal.aborted && body?.version && setLatest(body.version);
1527
+ }).catch(() => {}), () => controller.abort();
1528
+ }, []);
1529
+ let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.4.0") > 0);
1530
+ return {
1531
+ current: KIT_VERSION,
1532
+ latest,
1533
+ available,
1534
+ command: `npm install @nocode-factory/sanity-kit@${latest ?? "latest"}`
1535
+ };
1536
+ }
1537
+ /**
1538
+ * Signale qu'une version plus récente du kit existe.
1539
+ *
1540
+ * **Il ne met pas à jour.** Un Studio tourne dans un navigateur : il ne peut
1541
+ * ni installer un paquet sur le poste d'un développeur, ni se redéployer. Ce
1542
+ * bouton dit ce qui manque et donne la commande — prétendre faire plus serait
1543
+ * mentir sur ce qui se passe.
1544
+ *
1545
+ * Invisible tant que le kit est à jour : un bouton permanent qui ne dit rien
1546
+ * finit par ne plus être lu.
1547
+ */
1548
+ function NcfKitUpdate(props) {
1549
+ let update = useKitUpdate(), [copied, setCopied] = useState(!1);
1550
+ if (!update.available) return null;
1551
+ let copy = async () => {
1552
+ try {
1553
+ await navigator.clipboard.writeText(update.command), setCopied(!0);
1554
+ } catch {
1555
+ setCopied(!1);
1556
+ }
1557
+ };
1558
+ return /* @__PURE__ */ jsx(InlinePopover, {
1559
+ width: 318,
1560
+ trigger: ({ toggle }) => /* @__PURE__ */ jsx(Button, {
1561
+ mode: "bleed",
1562
+ tone: "primary",
1563
+ fontSize: 1,
1564
+ padding: props.inline ? 2 : 3,
1565
+ icon: ArrowUpIcon,
1566
+ text: `Kit ${update.latest}`,
1567
+ title: `Une version plus récente du kit est disponible (vous exécutez la ${update.current})`,
1568
+ justify: props.inline ? void 0 : "flex-start",
1569
+ onClick: toggle
1570
+ }),
1571
+ children: () => /* @__PURE__ */ jsxs(Stack, {
1572
+ gap: 3,
1573
+ padding: 2,
1574
+ children: [
1575
+ /* @__PURE__ */ jsxs(Stack, {
1576
+ gap: 2,
1577
+ children: [/* @__PURE__ */ jsxs(Text, {
1578
+ size: 1,
1579
+ weight: "semibold",
1580
+ children: [
1581
+ "Kit ",
1582
+ update.latest,
1583
+ " disponible"
1584
+ ]
1585
+ }), /* @__PURE__ */ jsxs(Text, {
1586
+ size: 0,
1587
+ muted: !0,
1588
+ children: [
1589
+ "Vous exécutez la ",
1590
+ update.current,
1591
+ "."
1592
+ ]
1593
+ })]
1594
+ }),
1595
+ /* @__PURE__ */ jsx(Card, {
1596
+ padding: 2,
1597
+ radius: 2,
1598
+ style: { border: `1px solid ${BORDER}` },
1599
+ children: /* @__PURE__ */ jsx(Text, {
1600
+ size: 0,
1601
+ style: {
1602
+ ...MONO,
1603
+ wordBreak: "break-all"
1604
+ },
1605
+ children: update.command
1606
+ })
1607
+ }),
1608
+ /* @__PURE__ */ jsxs(Flex, {
1609
+ gap: 2,
1610
+ wrap: "wrap",
1611
+ children: [/* @__PURE__ */ jsx(Button, {
1612
+ mode: "default",
1613
+ tone: "primary",
1614
+ fontSize: 1,
1615
+ padding: 2,
1616
+ icon: copied ? CheckmarkIcon : CopyIcon,
1617
+ text: copied ? "Copié" : "Copier la commande",
1618
+ onClick: copy
1619
+ }), /* @__PURE__ */ jsx(Button, {
1620
+ as: "a",
1621
+ href: "https://github.com/nocode-factory/ncf-sanity-kit/blob/main/docs/CHANGELOG.md",
1622
+ target: "_blank",
1623
+ rel: "noreferrer",
1624
+ mode: "bleed",
1625
+ fontSize: 1,
1626
+ padding: 2,
1627
+ text: "Nouveautés"
1628
+ })]
1629
+ }),
1630
+ /* @__PURE__ */ jsx(Box, {
1631
+ style: {
1632
+ borderTop: `1px solid ${BORDER}`,
1633
+ paddingTop: 10
1634
+ },
1635
+ children: /* @__PURE__ */ jsxs(Text, {
1636
+ size: 0,
1637
+ muted: !0,
1638
+ children: [
1639
+ "À lancer dans ",
1640
+ /* @__PURE__ */ jsx("code", { children: "studio/" }),
1641
+ " puis ",
1642
+ /* @__PURE__ */ jsx("code", { children: "web/" }),
1643
+ ", suivi d'un",
1644
+ " ",
1645
+ /* @__PURE__ */ jsx("code", { children: "npx sanity deploy" }),
1646
+ ". Le Studio ne peut pas le faire lui-même : il s'exécute dans votre navigateur, pas sur la machine qui le construit."
1647
+ ]
1648
+ })
1649
+ })
1650
+ ]
1651
+ })
1652
+ });
1653
+ }
1654
+ /**
1655
+ * Lanceur d'aperçu, posé dans la barre du haut à droite des outils.
1656
+ *
1657
+ * Deux questions, une seule poignée : **quelle version du site**, et **quel
1658
+ * état du contenu**. On choisit, on ouvre.
1659
+ *
1660
+ * Volontairement sans mémoire, contrairement au sélecteur de l'onglet Pages :
1661
+ * ici on lance une consultation, on ne règle pas un mode de travail. Un
1662
+ * bouton de barre qui retiendrait un état finirait par mentir sur ce qu'on
1663
+ * regarde ailleurs.
1664
+ */
1665
+ function NcfPreviewLauncher(props) {
1666
+ let config = useKitConfig(), router = useRouter(), environments = config.environments;
1667
+ if (environments.length === 0) return /* @__PURE__ */ jsxs(Flex, {
1668
+ align: "center",
1669
+ gap: 2,
1670
+ children: [props.renderDefault(props), /* @__PURE__ */ jsx(NcfKitUpdate, { inline: props.context === "topbar" })]
1671
+ });
1672
+ let open = (environment, perspective) => {
1673
+ let path = presentationPath(environment.url, {
1674
+ environment,
1675
+ perspective
1676
+ });
1677
+ path && router.navigateUrl({ path });
1678
+ }, inline = props.context === "topbar";
1679
+ return /* @__PURE__ */ jsxs(Flex, {
1680
+ align: inline ? "center" : "stretch",
1681
+ direction: inline ? "row" : "column",
1682
+ gap: inline ? 2 : 1,
1683
+ children: [
1684
+ props.renderDefault(props),
1685
+ /* @__PURE__ */ jsx(NcfKitUpdate, { inline }),
1686
+ /* @__PURE__ */ jsx(InlinePopover, {
1687
+ width: 248,
1688
+ trigger: ({ toggle }) => /* @__PURE__ */ jsx(Button, {
1689
+ mode: "bleed",
1690
+ fontSize: 1,
1691
+ padding: inline ? 2 : 3,
1692
+ icon: EyeOpenIcon,
1693
+ text: "Prévisualiser",
1694
+ title: "Ouvrir le site dans l'aperçu",
1695
+ justify: inline ? void 0 : "flex-start",
1696
+ onClick: toggle
1697
+ }),
1698
+ children: ({ close }) => /* @__PURE__ */ jsx(Stack, {
1699
+ gap: 1,
1700
+ children: environments.map((environment, index) => /* @__PURE__ */ jsxs(Box, {
1701
+ paddingTop: index === 0 ? 1 : 3,
1702
+ style: index === 0 ? void 0 : {
1703
+ borderTop: `1px solid ${BORDER}`,
1704
+ marginTop: 4
1705
+ },
1706
+ children: [/* @__PURE__ */ jsx(Box, {
1707
+ paddingX: 2,
1708
+ paddingBottom: 1,
1709
+ children: /* @__PURE__ */ jsx(Text, {
1710
+ size: 0,
1711
+ weight: "semibold",
1712
+ muted: !0,
1713
+ textOverflow: "ellipsis",
1714
+ children: environment.label
1715
+ })
1716
+ }), PERSPECTIVES.map((option) => /* @__PURE__ */ jsxs(Flex, {
1717
+ align: "center",
1718
+ gap: 2,
1719
+ padding: 2,
1720
+ onClick: () => {
1721
+ open(environment, option.id), close();
1722
+ },
1723
+ style: {
1724
+ cursor: "pointer",
1725
+ borderRadius: 3
1726
+ },
1727
+ onMouseEnter: (event) => {
1728
+ event.currentTarget.style.background = "var(--card-muted-bg-color, rgba(127,127,127,0.12))";
1729
+ },
1730
+ onMouseLeave: (event) => {
1731
+ event.currentTarget.style.background = "transparent";
1732
+ },
1733
+ children: [/* @__PURE__ */ jsxs(Stack, {
1734
+ gap: 1,
1735
+ flex: 1,
1736
+ style: { minWidth: 0 },
1737
+ children: [/* @__PURE__ */ jsx(Text, {
1738
+ size: 1,
1739
+ children: option.label
1740
+ }), /* @__PURE__ */ jsx(Text, {
1741
+ size: 0,
1742
+ muted: !0,
1743
+ textOverflow: "ellipsis",
1744
+ children: option.hint
1745
+ })]
1746
+ }), /* @__PURE__ */ jsx(LaunchIcon, { style: {
1747
+ fontSize: 14,
1748
+ opacity: .5,
1749
+ flex: "none"
1750
+ } })]
1751
+ }, option.id))]
1752
+ }, environment.id))
1753
+ })
1754
+ })
1755
+ ]
1756
+ });
1757
+ }
1758
+ /**
1759
+ * Le lanceur, muni de la configuration du kit.
1760
+ *
1761
+ * Le menu des outils est rendu hors de l'arbre des outils : il n'hérite donc
1762
+ * d'aucun de leurs contextes, et doit porter le sien.
1763
+ */
1764
+ function createPreviewLauncher(config, issues) {
1765
+ return function NcfToolMenu(props) {
1766
+ return /* @__PURE__ */ jsx(KitProvider, {
1767
+ config,
1768
+ issues,
1769
+ children: /* @__PURE__ */ jsx(NcfPreviewLauncher, { ...props })
1770
+ });
1771
+ };
1772
+ }
1773
+ /**
1398
1774
  * Colonnes de gestion interne effectives.
1399
1775
  *
1400
1776
  * Tant que personne n'y a touché, la configuration fournit le jeu de départ.
@@ -1783,68 +2159,6 @@ function indexationColumn(noindexFields) {
1783
2159
  invert: !0
1784
2160
  }];
1785
2161
  }
1786
- /**
1787
- * Petit panneau ancré à son déclencheur.
1788
- *
1789
- * Positionné en `fixed` et non en `absolute` : le tableau défile
1790
- * horizontalement, et un panneau posé dans ce conteneur serait rogné.
1791
- */
1792
- function InlinePopover(props) {
1793
- let { trigger, children, width = 200, onOpenChange } = props, [open, setOpen] = useState(!1), [at, setAt] = useState(null), anchor = useRef(null), panel = useRef(null), toggle = () => {
1794
- let rect = anchor.current?.getBoundingClientRect();
1795
- if (rect) {
1796
- let below = window.innerHeight - rect.bottom;
1797
- setAt({
1798
- top: below > 240 ? rect.bottom + 4 : Math.max(8, rect.top - 244),
1799
- left: Math.min(rect.left, window.innerWidth - width - 12)
1800
- });
1801
- }
1802
- setOpen((value) => (onOpenChange?.(!value), !value));
1803
- }, close = () => {
1804
- setOpen(!1), onOpenChange?.(!1);
1805
- };
1806
- return useEffect(() => {
1807
- if (!open) return;
1808
- let onDown = (event) => {
1809
- let target = event.target;
1810
- panel.current?.contains(target) || anchor.current?.contains(target) || close();
1811
- }, onKey = (event) => {
1812
- event.key === "Escape" && close();
1813
- };
1814
- return document.addEventListener("mousedown", onDown), document.addEventListener("keydown", onKey), () => {
1815
- document.removeEventListener("mousedown", onDown), document.removeEventListener("keydown", onKey);
1816
- };
1817
- }, [open]), /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
1818
- ref: anchor,
1819
- style: {
1820
- display: "block",
1821
- minWidth: 0
1822
- },
1823
- children: trigger({
1824
- open,
1825
- toggle
1826
- })
1827
- }), open && at && /* @__PURE__ */ jsx("div", {
1828
- ref: panel,
1829
- style: {
1830
- position: "fixed",
1831
- top: at.top,
1832
- left: at.left,
1833
- width,
1834
- zIndex: 1e3
1835
- },
1836
- children: /* @__PURE__ */ jsx(Card, {
1837
- radius: 3,
1838
- shadow: 3,
1839
- padding: 1,
1840
- style: {
1841
- maxHeight: 240,
1842
- overflowY: "auto"
1843
- },
1844
- children: children({ close })
1845
- })
1846
- })] });
1847
- }
1848
2162
  const TABS = [
1849
2163
  {
1850
2164
  value: "list",
@@ -1901,33 +2215,6 @@ function FieldLabel(props) {
1901
2215
  });
1902
2216
  }
1903
2217
  /**
1904
- * Jetons partagés par les vues du kit.
1905
- *
1906
- * Mode Operate : la couleur sert l'état et la sélection, jamais la décoration.
1907
- * Les fonds teintés restent sous le seuil où le texte du Studio perd son
1908
- * contraste, dans les deux thèmes.
1909
- */
1910
- /** Teinte de fond d'une ligne ou d'une carte porteuse d'un critère. */
1911
- const TABULAR = { fontVariantNumeric: "tabular-nums" }, MONO = {
1912
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
1913
- fontVariantNumeric: "tabular-nums",
1914
- letterSpacing: "-0.01em"
1915
- }, CELL = { minWidth: 0 }, BORDER = "var(--card-border-color, rgba(127,127,127,0.22))", OPTION_COLORS = [
1916
- "#f5a623",
1917
- "#43d675",
1918
- "#2276fc",
1919
- "#f03e3e",
1920
- "#a855f7",
1921
- "#8a8a8a"
1922
- ], DIFF = {
1923
- removedLine: "color-mix(in srgb, #f03e3e 9%, transparent)",
1924
- addedLine: "color-mix(in srgb, #2f9e44 11%, transparent)",
1925
- removedWord: "color-mix(in srgb, #f03e3e 26%, transparent)",
1926
- addedWord: "color-mix(in srgb, #2f9e44 30%, transparent)",
1927
- removedMark: "#e03131",
1928
- addedMark: "#2f9e44"
1929
- };
1930
- /**
1931
2218
  * Ce que l'aperçu doit montrer : quelle version du site, et quel état du
1932
2219
  * contenu.
1933
2220
  *
@@ -6876,9 +7163,10 @@ const NCF_PAGES_TOOL = "ncf-pages", NCF_COMPONENTS_TOOL = "ncf-components", NCF_
6876
7163
  types: kitSchemaTypes,
6877
7164
  templates: (prev) => prev.filter((template) => !isKitType(template.schemaType))
6878
7165
  },
6879
- document: { newDocumentOptions: (prev) => prev.filter((option) => option.templateId !== BOARD_LAYOUT_TYPE) }
7166
+ document: { newDocumentOptions: (prev) => prev.filter((option) => option.templateId !== BOARD_LAYOUT_TYPE) },
7167
+ studio: { components: { toolMenu: createPreviewLauncher(config, issues) } }
6880
7168
  };
6881
7169
  });
6882
- 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, DATA_PREFIX, DEFAULT_BOARD_TAGS, DEFAULT_COMPONENT_PREVIEW, DEFAULT_I18N, DEFAULT_INTERNAL_FIELDS, DEFAULT_MORE_TOOLS, DEFAULT_PAGE_BUILDER_FIELD, DEFAULT_SLUG_FIELD, DEFAULT_TITLE_FIELD, KIT_API_VERSION, KIT_VERSION, NCF_COMPONENTS_TOOL, NCF_HIDDEN_TYPES, NCF_HISTORY_TOOL, NCF_MORE_TOOL, NCF_PAGES_TOOL, NCF_TOOL_NAMES, NODE_FIELD_TYPE, NODE_HEIGHT, NODE_WIDTH, NcfPreviewHeader, PERSPECTIVES, PROJECTION, SECTION_NODE_TYPE, STATUS_COLORS, STATUS_LABELS, SharePreview, UNSET_LABEL, addColumn, addColumnOption, announce, applySavedPositions, baseId, blockName, blockTypesFromSchema, buildContentsQuery, buildLinkGraph, buildPageRows, buildPagesQuery, collectLinks, collectOccurrences, colorForRow, colorFromString, columnId, customEnvironment, defaultNodeSize, depth, deriveDocumentColumns, diffDocuments, diffWords, editIntentPath, explainGrantError, fallbackLayout, fetchDetail, fetchTimeline, fillTemplate, filterRows, flatten, formatDocumentValue, groupPageRows, groupValue, hasBlockingIssue, humanizeBlockName, isDraftId, isKitType, isSafeColumnKey, isSafeFieldPath, isTextChange, isVersionId, issuesForTool, keyForPath, kitSchemaTypes, layoutGraph, layoutSectionsMap, localesInRows, mergeVersions, missingPageTypes, moveColumn, ncfAllowedOrigins, ncfKit, ncfPreviewComponents, normalizeInternalPath, normalizePath, occurrencesForTypes, pageThumbnailUrl, pageTypeFor, pageTypesFromSiteRoutes, pageTypesWithoutBuilder, parentPath, presentationPath, pruneSavedPositions, releaseId, removeColumn, renameColumn, requestPreviewGrant, resolveColorBy, resolveConfig, segments, slugKey, sortRows, summarize, toKebabCase, toPath, toUrl, topLevelBlockCount, uniqueColumnId, upsertLayout, urlOn, useAnnotations, useBoardLayout, useDocumentColumns, useHistory, useInternalColumns, useKitClient, useKitConfig, useKitContext, useOccurrences, usePageContents, usePages, usePreviewTarget, useRegistration, validateConfig, withAlpha, withMoreTool };
7170
+ 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, DATA_PREFIX, DEFAULT_BOARD_TAGS, DEFAULT_COMPONENT_PREVIEW, DEFAULT_I18N, DEFAULT_INTERNAL_FIELDS, DEFAULT_MORE_TOOLS, DEFAULT_PAGE_BUILDER_FIELD, DEFAULT_SLUG_FIELD, DEFAULT_TITLE_FIELD, KIT_API_VERSION, KIT_VERSION, NCF_COMPONENTS_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, collectLinks, collectOccurrences, colorForRow, colorFromString, columnId, compareVersions, createPreviewLauncher, customEnvironment, defaultNodeSize, depth, deriveDocumentColumns, diffDocuments, diffWords, editIntentPath, explainGrantError, fallbackLayout, fetchDetail, fetchTimeline, fillTemplate, filterRows, flatten, formatDocumentValue, groupPageRows, groupValue, hasBlockingIssue, humanizeBlockName, isDraftId, isKitType, isPrerelease, isSafeColumnKey, isSafeFieldPath, isTextChange, isVersionId, issuesForTool, keyForPath, kitSchemaTypes, layoutGraph, layoutSectionsMap, localesInRows, mergeVersions, missingPageTypes, moveColumn, ncfAllowedOrigins, ncfKit, ncfPreviewComponents, normalizeInternalPath, normalizePath, occurrencesForTypes, pageThumbnailUrl, pageTypeFor, pageTypesFromSiteRoutes, pageTypesWithoutBuilder, parentPath, presentationPath, pruneSavedPositions, releaseId, removeColumn, renameColumn, requestPreviewGrant, resolveColorBy, resolveConfig, segments, slugKey, sortRows, summarize, toKebabCase, toPath, toUrl, topLevelBlockCount, uniqueColumnId, upsertLayout, urlOn, useAnnotations, useBoardLayout, useDocumentColumns, useHistory, useInternalColumns, useKitClient, useKitConfig, useKitContext, useKitUpdate, useOccurrences, usePageContents, usePages, usePreviewTarget, useRegistration, validateConfig, withAlpha, withMoreTool };
6883
7171
 
6884
7172
  //# sourceMappingURL=index.js.map