@nocode-factory/sanity-kit 2.10.1 → 2.10.2
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 +23 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/form/OverrideInput.tsx +5 -0
- package/src/hooks/useInPresentation.ts +26 -0
- package/src/version.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1302,7 +1302,7 @@ export declare function ActorName(props: {
|
|
|
1302
1302
|
* Version du kit, rapportée au service pour savoir quels projets tournent sur
|
|
1303
1303
|
* quelle version. Tenue à jour avec `package.json`.
|
|
1304
1304
|
*/
|
|
1305
|
-
export declare const KIT_VERSION = "2.10.
|
|
1305
|
+
export declare const KIT_VERSION = "2.10.2";
|
|
1306
1306
|
/**
|
|
1307
1307
|
* Données de la page proposées comme colonnes.
|
|
1308
1308
|
*
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ColorWheelIcon } from "@sanity/icons/ColorWheel";
|
|
|
7
7
|
import { Badge, Box, Button, Card, Container, Flex, Grid, Select, Spinner, Stack, Tab, TabList, TabPanel, Text, TextArea, TextInput } from "@sanity/ui";
|
|
8
8
|
import { createContext, forwardRef, memo, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { IntentLink, useRouter } from "sanity/router";
|
|
10
|
+
import { IntentLink, useRouter, useRouterState } from "sanity/router";
|
|
11
11
|
import { EyeOpenIcon } from "@sanity/icons/EyeOpen";
|
|
12
12
|
import { LaunchIcon } from "@sanity/icons/Launch";
|
|
13
13
|
import { ArrowUpIcon } from "@sanity/icons/ArrowUp";
|
|
@@ -1334,7 +1334,7 @@ function explainGrantError(error) {
|
|
|
1334
1334
|
* Version du kit, rapportée au service pour savoir quels projets tournent sur
|
|
1335
1335
|
* quelle version. Tenue à jour avec `package.json`.
|
|
1336
1336
|
*/
|
|
1337
|
-
const KIT_VERSION = "2.10.
|
|
1337
|
+
const KIT_VERSION = "2.10.2";
|
|
1338
1338
|
/**
|
|
1339
1339
|
* Signale ce Studio au service du kit, une fois par montage.
|
|
1340
1340
|
*
|
|
@@ -1688,7 +1688,7 @@ function useKitUpdate() {
|
|
|
1688
1688
|
!controller.signal.aborted && body?.version && setLatest(body.version);
|
|
1689
1689
|
}).catch(() => {}), () => controller.abort();
|
|
1690
1690
|
}, []);
|
|
1691
|
-
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.10.
|
|
1691
|
+
let available = !!(latest && !isPrerelease(latest) && compareVersions(latest, "2.10.2") > 0);
|
|
1692
1692
|
return {
|
|
1693
1693
|
current: KIT_VERSION,
|
|
1694
1694
|
latest,
|
|
@@ -7418,6 +7418,23 @@ function useComponentDefaults(client, type, languageField, language) {
|
|
|
7418
7418
|
entry.listeners.size === 0 && entry.stop && (entry.stop(), entry.stop = null);
|
|
7419
7419
|
}, [entry]), value;
|
|
7420
7420
|
}
|
|
7421
|
+
/** Noms des outils Presentation du workspace (le nom est configurable). */
|
|
7422
|
+
function presentationToolNames(tools) {
|
|
7423
|
+
return tools.filter((t) => t.__internalApplicationType === "sanity/presentation" || t.name === "presentation").map((t) => t.name);
|
|
7424
|
+
}
|
|
7425
|
+
/** Vrai si l'adresse du Studio est dans un de ces outils (premier segment après la base). */
|
|
7426
|
+
function isInTool(pathname, names) {
|
|
7427
|
+
return pathname.split("/").some((segment) => names.includes(segment));
|
|
7428
|
+
}
|
|
7429
|
+
/**
|
|
7430
|
+
* Le formulaire est-il affiché dans Presentation ? Le routeur sert à se mettre à jour
|
|
7431
|
+
* quand on change d'outil ; l'adresse dit lequel (le formulaire de Presentation est rendu
|
|
7432
|
+
* dans la portée de son outil, qui ne porte pas le nom de l'outil).
|
|
7433
|
+
*/
|
|
7434
|
+
function useInPresentation() {
|
|
7435
|
+
let { tools } = useWorkspace();
|
|
7436
|
+
return useRouterState(), typeof window > "u" ? !1 : isInTool(window.location.pathname, presentationToolNames(tools));
|
|
7437
|
+
}
|
|
7421
7438
|
const LINK_TARGET_FIELDS = [
|
|
7422
7439
|
"page",
|
|
7423
7440
|
"fixedPath",
|
|
@@ -7592,7 +7609,9 @@ function createOverrideInput(config) {
|
|
|
7592
7609
|
});
|
|
7593
7610
|
}
|
|
7594
7611
|
function WithMainInstance(props) {
|
|
7595
|
-
let { type, ...inputProps } = props, client = useKitClient(), router = useRouter()
|
|
7612
|
+
let { type, ...inputProps } = props, client = useKitClient(), router = useRouter();
|
|
7613
|
+
if (useInPresentation()) return inputProps.renderDefault(inputProps);
|
|
7614
|
+
let open = () => void openComponentDefaults({
|
|
7596
7615
|
type,
|
|
7597
7616
|
config,
|
|
7598
7617
|
hasDefaults: !0,
|