@sanity/sdk-react 0.0.2 → 1.0.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 +3 -3
- package/dist/index.d.ts +302 -273
- package/dist/index.js +14 -7
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/_exports/sdk-react.ts +8 -8
- package/src/hooks/document/useApplyDocumentActions.ts +4 -4
- package/src/hooks/document/useDocument.test.ts +8 -10
- package/src/hooks/document/useDocument.ts +50 -33
- package/src/hooks/document/useDocumentEvent.ts +2 -2
- package/src/hooks/document/useDocumentSyncStatus.ts +1 -1
- package/src/hooks/document/useEditDocument.ts +15 -15
- package/src/hooks/documents/useDocuments.ts +5 -5
- package/src/hooks/paginatedDocuments/usePaginatedDocuments.ts +5 -5
- package/src/hooks/preview/{usePreview.test.tsx → useDocumentPreview.test.tsx} +5 -5
- package/src/hooks/preview/{usePreview.tsx → useDocumentPreview.tsx} +11 -8
- package/src/hooks/projection/{useProjection.test.tsx → useDocumentProjection.test.tsx} +5 -5
- package/src/hooks/projection/{useProjection.ts → useDocumentProjection.ts} +22 -17
- package/src/hooks/query/useQuery.ts +5 -5
package/dist/index.js
CHANGED
|
@@ -589,7 +589,7 @@ const useDatasets = createStateSourceHook({
|
|
|
589
589
|
),
|
|
590
590
|
suspender: resolveDatasets,
|
|
591
591
|
getConfig: identity
|
|
592
|
-
}), useApplyDocumentActions = createCallbackHook(applyDocumentActions),
|
|
592
|
+
}), useApplyDocumentActions = createCallbackHook(applyDocumentActions), useDocumentValue = createStateSourceHook({
|
|
593
593
|
// Pass options directly to getDocumentState
|
|
594
594
|
getState: (instance, options) => getDocumentState(instance, options),
|
|
595
595
|
// Pass options directly to getDocumentState for checking current value
|
|
@@ -600,7 +600,14 @@ const useDatasets = createStateSourceHook({
|
|
|
600
600
|
// Extract handle part for resolveDocument
|
|
601
601
|
suspender: (instance, options) => resolveDocument(instance, options),
|
|
602
602
|
getConfig: identity
|
|
603
|
-
})
|
|
603
|
+
}), wrapHookWithData = (useValue) => {
|
|
604
|
+
function useHook(...params) {
|
|
605
|
+
return {
|
|
606
|
+
data: useValue(...params)
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
return useHook;
|
|
610
|
+
}, useDocument = wrapHookWithData(useDocumentValue);
|
|
604
611
|
function useDocumentEvent(options) {
|
|
605
612
|
const $ = c(9);
|
|
606
613
|
let datasetHandle, onEvent;
|
|
@@ -911,7 +918,7 @@ function _temp2(str) {
|
|
|
911
918
|
function _temp(i) {
|
|
912
919
|
return typeof i == "string";
|
|
913
920
|
}
|
|
914
|
-
function
|
|
921
|
+
function useDocumentPreview(t0) {
|
|
915
922
|
const $ = c(13);
|
|
916
923
|
let docHandle, ref;
|
|
917
924
|
$[0] !== t0 ? ({
|
|
@@ -951,7 +958,7 @@ function usePreview(t0) {
|
|
|
951
958
|
return currentState;
|
|
952
959
|
}, $[9] = docHandle, $[10] = instance, $[11] = stateSource, $[12] = t3) : t3 = $[12], useSyncExternalStore(subscribe, t3);
|
|
953
960
|
}
|
|
954
|
-
function
|
|
961
|
+
function useDocumentProjection(t0) {
|
|
955
962
|
const $ = c(12);
|
|
956
963
|
let docHandle, projection, ref;
|
|
957
964
|
$[0] !== t0 ? ({
|
|
@@ -1039,7 +1046,7 @@ function useUsers(options) {
|
|
|
1039
1046
|
loadMore
|
|
1040
1047
|
};
|
|
1041
1048
|
}
|
|
1042
|
-
var version = "0.0
|
|
1049
|
+
var version = "1.0.0";
|
|
1043
1050
|
function getEnv(key) {
|
|
1044
1051
|
if (typeof import.meta < "u" && import.meta.env)
|
|
1045
1052
|
return import.meta.env[key];
|
|
@@ -1066,6 +1073,8 @@ export {
|
|
|
1066
1073
|
useDocument,
|
|
1067
1074
|
useDocumentEvent,
|
|
1068
1075
|
useDocumentPermissions,
|
|
1076
|
+
useDocumentPreview,
|
|
1077
|
+
useDocumentProjection,
|
|
1069
1078
|
useDocumentSyncStatus,
|
|
1070
1079
|
useDocuments,
|
|
1071
1080
|
useEditDocument,
|
|
@@ -1077,9 +1086,7 @@ export {
|
|
|
1077
1086
|
useNavigateToStudioDocument,
|
|
1078
1087
|
usePaginatedDocuments,
|
|
1079
1088
|
usePerspective,
|
|
1080
|
-
usePreview,
|
|
1081
1089
|
useProject,
|
|
1082
|
-
useProjection,
|
|
1083
1090
|
useProjects,
|
|
1084
1091
|
useQuery,
|
|
1085
1092
|
useRecordDocumentHistoryEvent,
|