@nocode-factory/sanity-kit 2.4.0 → 2.5.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 +1 -1
- package/dist/index.js +74 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/studioLinks.ts +20 -0
- package/src/tools/navbar/PreviewLauncher.tsx +56 -27
- package/src/version.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1270,7 +1270,7 @@ export declare function ActorName(props: {
|
|
|
1270
1270
|
* Version du kit, rapportée au service pour savoir quels projets tournent sur
|
|
1271
1271
|
* quelle version. Tenue à jour avec `package.json`.
|
|
1272
1272
|
*/
|
|
1273
|
-
export declare const KIT_VERSION = "2.
|
|
1273
|
+
export declare const KIT_VERSION = "2.5.0";
|
|
1274
1274
|
/**
|
|
1275
1275
|
* Données de la page proposées comme colonnes.
|
|
1276
1276
|
*
|
package/dist/index.js
CHANGED
|
@@ -996,6 +996,19 @@ function urlOn(environment, path) {
|
|
|
996
996
|
return environment?.url ? path ? `${trimEnd(environment.url)}${path.startsWith("/") ? path : `/${path}`}` : trimEnd(environment.url) : null;
|
|
997
997
|
}
|
|
998
998
|
/**
|
|
999
|
+
* URL du vrai site, en ligne, pour un environnement et un état de contenu.
|
|
1000
|
+
*
|
|
1001
|
+
* Les brouillons passent par la route de bascule du site, qui pose le cookie
|
|
1002
|
+
* de mode brouillon puis renvoie à l'accueil. La production ne montre jamais
|
|
1003
|
+
* de brouillons : on y retombe sur l'URL simple, et la route refuserait de
|
|
1004
|
+
* toute façon.
|
|
1005
|
+
*/
|
|
1006
|
+
function onlineUrl(environment, perspective) {
|
|
1007
|
+
if (!environment?.url) return null;
|
|
1008
|
+
let base = environment.url.replace(/\/+$/, "");
|
|
1009
|
+
return perspective === "drafts" && environment.id !== "production" ? `${base}/api/draft-mode/toggle?enable=true&redirect=/` : base;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
999
1012
|
* Liens internes au Studio.
|
|
1000
1013
|
*
|
|
1001
1014
|
* Ouvrir une page doit mener à **Presentation**, pas à la structure : on veut
|
|
@@ -1274,7 +1287,7 @@ function explainGrantError(error) {
|
|
|
1274
1287
|
* Version du kit, rapportée au service pour savoir quels projets tournent sur
|
|
1275
1288
|
* quelle version. Tenue à jour avec `package.json`.
|
|
1276
1289
|
*/
|
|
1277
|
-
const KIT_VERSION = "2.
|
|
1290
|
+
const KIT_VERSION = "2.5.0";
|
|
1278
1291
|
/**
|
|
1279
1292
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1280
1293
|
*
|
|
@@ -1526,7 +1539,7 @@ function useKitUpdate() {
|
|
|
1526
1539
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1527
1540
|
}).catch(() => {}), () => controller.abort();
|
|
1528
1541
|
}, []);
|
|
1529
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.
|
|
1542
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.5.0") > 0);
|
|
1530
1543
|
return {
|
|
1531
1544
|
current: KIT_VERSION,
|
|
1532
1545
|
latest,
|
|
@@ -1669,12 +1682,15 @@ function NcfPreviewLauncher(props) {
|
|
|
1669
1682
|
gap: 2,
|
|
1670
1683
|
children: [props.renderDefault(props), /* @__PURE__ */ jsx(NcfKitUpdate, { inline: props.context === "topbar" })]
|
|
1671
1684
|
});
|
|
1672
|
-
let
|
|
1685
|
+
let openInStudio = (environment, perspective) => {
|
|
1673
1686
|
let path = presentationPath(environment.url, {
|
|
1674
1687
|
environment,
|
|
1675
1688
|
perspective
|
|
1676
1689
|
});
|
|
1677
1690
|
path && router.navigateUrl({ path });
|
|
1691
|
+
}, openOnline = (environment, perspective) => {
|
|
1692
|
+
let target = onlineUrl(environment, perspective);
|
|
1693
|
+
target && window.open(target, "_blank", "noopener");
|
|
1678
1694
|
}, inline = props.context === "topbar";
|
|
1679
1695
|
return /* @__PURE__ */ jsxs(Flex, {
|
|
1680
1696
|
align: inline ? "center" : "stretch",
|
|
@@ -1695,9 +1711,18 @@ function NcfPreviewLauncher(props) {
|
|
|
1695
1711
|
justify: inline ? void 0 : "flex-start",
|
|
1696
1712
|
onClick: toggle
|
|
1697
1713
|
}),
|
|
1698
|
-
children: ({ close }) => /* @__PURE__ */
|
|
1714
|
+
children: ({ close }) => /* @__PURE__ */ jsxs(Stack, {
|
|
1699
1715
|
gap: 1,
|
|
1700
|
-
children:
|
|
1716
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
1717
|
+
paddingX: 2,
|
|
1718
|
+
paddingTop: 1,
|
|
1719
|
+
paddingBottom: 2,
|
|
1720
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
1721
|
+
size: 0,
|
|
1722
|
+
muted: !0,
|
|
1723
|
+
children: "Cliquer : ouvre dans le Studio. L'icône ↗ : ouvre le site en ligne."
|
|
1724
|
+
})
|
|
1725
|
+
}), environments.map((environment, index) => /* @__PURE__ */ jsxs(Box, {
|
|
1701
1726
|
paddingTop: index === 0 ? 1 : 3,
|
|
1702
1727
|
style: index === 0 ? void 0 : {
|
|
1703
1728
|
borderTop: `1px solid ${BORDER}`,
|
|
@@ -1715,41 +1740,52 @@ function NcfPreviewLauncher(props) {
|
|
|
1715
1740
|
})
|
|
1716
1741
|
}), PERSPECTIVES.map((option) => /* @__PURE__ */ jsxs(Flex, {
|
|
1717
1742
|
align: "center",
|
|
1718
|
-
gap:
|
|
1719
|
-
|
|
1720
|
-
|
|
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,
|
|
1743
|
+
gap: 1,
|
|
1744
|
+
children: [/* @__PURE__ */ jsx(Flex, {
|
|
1745
|
+
align: "center",
|
|
1735
1746
|
flex: 1,
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1747
|
+
padding: 2,
|
|
1748
|
+
onClick: () => {
|
|
1749
|
+
openInStudio(environment, option.id), close();
|
|
1750
|
+
},
|
|
1751
|
+
style: {
|
|
1752
|
+
cursor: "pointer",
|
|
1753
|
+
borderRadius: 3,
|
|
1754
|
+
minWidth: 0
|
|
1755
|
+
},
|
|
1756
|
+
title: "Ouvrir dans le Studio (Presentation)",
|
|
1757
|
+
onMouseEnter: (event) => {
|
|
1758
|
+
event.currentTarget.style.background = "var(--card-muted-bg-color, rgba(127,127,127,0.12))";
|
|
1759
|
+
},
|
|
1760
|
+
onMouseLeave: (event) => {
|
|
1761
|
+
event.currentTarget.style.background = "transparent";
|
|
1762
|
+
},
|
|
1763
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1764
|
+
gap: 1,
|
|
1765
|
+
style: { minWidth: 0 },
|
|
1766
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
1767
|
+
size: 1,
|
|
1768
|
+
children: option.label
|
|
1769
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
1770
|
+
size: 0,
|
|
1771
|
+
muted: !0,
|
|
1772
|
+
textOverflow: "ellipsis",
|
|
1773
|
+
children: option.hint
|
|
1774
|
+
})]
|
|
1775
|
+
})
|
|
1776
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1777
|
+
mode: "bleed",
|
|
1778
|
+
padding: 2,
|
|
1779
|
+
fontSize: 1,
|
|
1780
|
+
icon: LaunchIcon,
|
|
1781
|
+
title: "Ouvrir le site en ligne, dans un nouvel onglet",
|
|
1782
|
+
"aria-label": `Ouvrir ${environment.label} en ligne (${option.label})`,
|
|
1783
|
+
onClick: () => {
|
|
1784
|
+
openOnline(environment, option.id), close();
|
|
1785
|
+
}
|
|
1786
|
+
})]
|
|
1751
1787
|
}, option.id))]
|
|
1752
|
-
}, environment.id))
|
|
1788
|
+
}, environment.id))]
|
|
1753
1789
|
})
|
|
1754
1790
|
})
|
|
1755
1791
|
]
|