@contentful/field-editor-reference 6.19.1 → 6.19.2-canary.7

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.
@@ -41,6 +41,7 @@ _export(exports, {
41
41
  }
42
42
  });
43
43
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
44
+ const _fieldeditorshared = require("@contentful/field-editor-shared");
44
45
  const _constate = /*#__PURE__*/ _interop_require_default(require("constate"));
45
46
  const _contentfulmanagement = require("contentful-management");
46
47
  const _lodash = require("lodash");
@@ -162,18 +163,10 @@ async function fetchContentfulEntry({ urn, fetch, options }) {
162
163
  const environmentId = resourceIdMatch?.groups?.environmentId || 'master';
163
164
  const entryId = resourceIdMatch.groups.entityId;
164
165
  const [space, entry] = await Promise.all([
165
- fetch([
166
- 'space',
167
- spaceId
168
- ], ({ cmaClient })=>cmaClient.space.get({
166
+ fetch((0, _fieldeditorshared.createGetSpaceKey)(spaceId), ({ cmaClient })=>cmaClient.space.get({
169
167
  spaceId
170
168
  }), options),
171
- fetch([
172
- 'entry',
173
- spaceId,
174
- environmentId,
175
- entryId
176
- ], ({ cmaClient })=>cmaClient.entry.get({
169
+ fetch((0, _fieldeditorshared.createGetEntryKey)(spaceId, environmentId, entryId), ({ cmaClient })=>cmaClient.entry.get({
177
170
  spaceId,
178
171
  environmentId,
179
172
  entryId
@@ -181,12 +174,7 @@ async function fetchContentfulEntry({ urn, fetch, options }) {
181
174
  ]);
182
175
  const contentTypeId = entry.sys.contentType.sys.id;
183
176
  const [contentType, defaultLocaleCode] = await Promise.all([
184
- fetch([
185
- 'contentType',
186
- spaceId,
187
- environmentId,
188
- contentTypeId
189
- ], ({ cmaClient })=>cmaClient.contentType.get({
177
+ fetch((0, _fieldeditorshared.createGetContentTypeKey)(spaceId, environmentId, contentTypeId), ({ cmaClient })=>cmaClient.contentType.get({
190
178
  contentTypeId,
191
179
  spaceId,
192
180
  environmentId
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "MultipleReferenceEditor", {
9
9
  }
10
10
  });
11
11
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _fieldeditorshared = require("@contentful/field-editor-shared");
12
13
  const _sortable = require("@dnd-kit/sortable");
13
14
  const _components = require("../components");
14
15
  const _LinkEntityActions = require("../components/LinkActions/LinkEntityActions");
@@ -145,7 +146,7 @@ function Editor(props) {
145
146
  }));
146
147
  }
147
148
  function MultipleReferenceEditor(props) {
148
- const allContentTypes = props.sdk.space.getCachedContentTypes();
149
+ const { contentTypes: allContentTypes } = (0, _fieldeditorshared.useContentTypes)(props.sdk);
149
150
  return /*#__PURE__*/ _react.createElement(_ReferenceEditor.ReferenceEditor, props, ({ value, disabled, setValue, externalReset })=>{
150
151
  return /*#__PURE__*/ _react.createElement(Editor, {
151
152
  ...props,
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "SingleReferenceEditor", {
9
9
  }
10
10
  });
11
11
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _fieldeditorshared = require("@contentful/field-editor-shared");
12
13
  const _components = require("../components");
13
14
  const _LinkEntityActions = require("../components/LinkActions/LinkEntityActions");
14
15
  const _ReferenceEditor = require("./ReferenceEditor");
@@ -102,7 +103,7 @@ function Editor(props) {
102
103
  });
103
104
  }
104
105
  function SingleReferenceEditor(props) {
105
- const allContentTypes = props.sdk.space.getCachedContentTypes();
106
+ const { contentTypes: allContentTypes } = (0, _fieldeditorshared.useContentTypes)(props.sdk);
106
107
  return /*#__PURE__*/ _react.createElement(_ReferenceEditor.ReferenceEditor, props, ({ value, setValue, disabled, externalReset })=>{
107
108
  return /*#__PURE__*/ _react.createElement(Editor, {
108
109
  ...props,
@@ -10,100 +10,13 @@ function _export(target, all) {
10
10
  }
11
11
  _export(exports, {
12
12
  SharedQueryClientProvider: function() {
13
- return SharedQueryClientProvider;
13
+ return _fieldeditorshared.SharedQueryClientProvider;
14
14
  },
15
15
  useQuery: function() {
16
- return useQuery;
16
+ return _fieldeditorshared.useQuery;
17
17
  },
18
18
  useQueryClient: function() {
19
- return useQueryClient;
19
+ return _fieldeditorshared.useQueryClient;
20
20
  }
21
21
  });
22
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
23
- const _reactquery = require("@tanstack/react-query");
24
- function _getRequireWildcardCache(nodeInterop) {
25
- if (typeof WeakMap !== "function") return null;
26
- var cacheBabelInterop = new WeakMap();
27
- var cacheNodeInterop = new WeakMap();
28
- return (_getRequireWildcardCache = function(nodeInterop) {
29
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
30
- })(nodeInterop);
31
- }
32
- function _interop_require_wildcard(obj, nodeInterop) {
33
- if (!nodeInterop && obj && obj.__esModule) {
34
- return obj;
35
- }
36
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
37
- return {
38
- default: obj
39
- };
40
- }
41
- var cache = _getRequireWildcardCache(nodeInterop);
42
- if (cache && cache.has(obj)) {
43
- return cache.get(obj);
44
- }
45
- var newObj = {
46
- __proto__: null
47
- };
48
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
49
- for(var key in obj){
50
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
51
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
52
- if (desc && (desc.get || desc.set)) {
53
- Object.defineProperty(newObj, key, desc);
54
- } else {
55
- newObj[key] = obj[key];
56
- }
57
- }
58
- }
59
- newObj.default = obj;
60
- if (cache) {
61
- cache.set(obj, newObj);
62
- }
63
- return newObj;
64
- }
65
- const clientContext = /*#__PURE__*/ _react.createContext(undefined);
66
- function useMaybeHostQueryClient() {
67
- try {
68
- return (0, _reactquery.useQueryClient)();
69
- } catch {
70
- return undefined;
71
- }
72
- }
73
- function useQueryClient() {
74
- const client = _react.useContext(clientContext);
75
- const hostClient = useMaybeHostQueryClient();
76
- return _react.useMemo(()=>{
77
- if (client) {
78
- return client;
79
- }
80
- if (hostClient) return hostClient;
81
- return new _reactquery.QueryClient({
82
- defaultOptions: {
83
- queries: {
84
- useErrorBoundary: false,
85
- refetchOnWindowFocus: false,
86
- refetchOnReconnect: true,
87
- refetchOnMount: false,
88
- staleTime: Infinity,
89
- retry: false
90
- }
91
- }
92
- });
93
- }, [
94
- client,
95
- hostClient
96
- ]);
97
- }
98
- const useQuery = (key, fn, opt)=>{
99
- return (0, _reactquery.useQuery)(key, fn, {
100
- ...opt,
101
- context: clientContext
102
- });
103
- };
104
- function SharedQueryClientProvider({ children }) {
105
- const client = useQueryClient();
106
- return /*#__PURE__*/ _react.createElement(clientContext.Provider, {
107
- value: client
108
- }, children);
109
- }
22
+ const _fieldeditorshared = require("@contentful/field-editor-shared");
@@ -12,6 +12,7 @@ function _define_property(obj, key, value) {
12
12
  return obj;
13
13
  }
14
14
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
15
+ import { createGetContentTypeKey, createGetEntryKey, createGetSpaceKey } from '@contentful/field-editor-shared';
15
16
  import constate from 'constate';
16
17
  import { fetchAll } from 'contentful-management';
17
18
  import { get } from 'lodash';
@@ -74,18 +75,10 @@ async function fetchContentfulEntry({ urn, fetch, options }) {
74
75
  const environmentId = resourceIdMatch?.groups?.environmentId || 'master';
75
76
  const entryId = resourceIdMatch.groups.entityId;
76
77
  const [space, entry] = await Promise.all([
77
- fetch([
78
- 'space',
79
- spaceId
80
- ], ({ cmaClient })=>cmaClient.space.get({
78
+ fetch(createGetSpaceKey(spaceId), ({ cmaClient })=>cmaClient.space.get({
81
79
  spaceId
82
80
  }), options),
83
- fetch([
84
- 'entry',
85
- spaceId,
86
- environmentId,
87
- entryId
88
- ], ({ cmaClient })=>cmaClient.entry.get({
81
+ fetch(createGetEntryKey(spaceId, environmentId, entryId), ({ cmaClient })=>cmaClient.entry.get({
89
82
  spaceId,
90
83
  environmentId,
91
84
  entryId
@@ -93,12 +86,7 @@ async function fetchContentfulEntry({ urn, fetch, options }) {
93
86
  ]);
94
87
  const contentTypeId = entry.sys.contentType.sys.id;
95
88
  const [contentType, defaultLocaleCode] = await Promise.all([
96
- fetch([
97
- 'contentType',
98
- spaceId,
99
- environmentId,
100
- contentTypeId
101
- ], ({ cmaClient })=>cmaClient.contentType.get({
89
+ fetch(createGetContentTypeKey(spaceId, environmentId, contentTypeId), ({ cmaClient })=>cmaClient.contentType.get({
102
90
  contentTypeId,
103
91
  spaceId,
104
92
  environmentId
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useCallback } from 'react';
3
+ import { useContentTypes } from '@contentful/field-editor-shared';
3
4
  import { arrayMove } from '@dnd-kit/sortable';
4
5
  import { LinkEntityActions } from '../components';
5
6
  import { useLinkActionsProps } from '../components/LinkActions/LinkEntityActions';
@@ -95,7 +96,7 @@ function Editor(props) {
95
96
  }));
96
97
  }
97
98
  export function MultipleReferenceEditor(props) {
98
- const allContentTypes = props.sdk.space.getCachedContentTypes();
99
+ const { contentTypes: allContentTypes } = useContentTypes(props.sdk);
99
100
  return /*#__PURE__*/ React.createElement(ReferenceEditor, props, ({ value, disabled, setValue, externalReset })=>{
100
101
  return /*#__PURE__*/ React.createElement(Editor, {
101
102
  ...props,
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useCallback } from 'react';
3
+ import { useContentTypes } from '@contentful/field-editor-shared';
3
4
  import { LinkEntityActions } from '../components';
4
5
  import { useLinkActionsProps } from '../components/LinkActions/LinkEntityActions';
5
6
  import { ReferenceEditor } from './ReferenceEditor';
@@ -52,7 +53,7 @@ function Editor(props) {
52
53
  });
53
54
  }
54
55
  export function SingleReferenceEditor(props) {
55
- const allContentTypes = props.sdk.space.getCachedContentTypes();
56
+ const { contentTypes: allContentTypes } = useContentTypes(props.sdk);
56
57
  return /*#__PURE__*/ React.createElement(ReferenceEditor, props, ({ value, setValue, disabled, externalReset })=>{
57
58
  return /*#__PURE__*/ React.createElement(Editor, {
58
59
  ...props,
@@ -1,47 +1 @@
1
- import * as React from 'react';
2
- import { QueryClient, useQuery as useRQ, useQueryClient as useHostQueryClient } from '@tanstack/react-query';
3
- const clientContext = /*#__PURE__*/ React.createContext(undefined);
4
- function useMaybeHostQueryClient() {
5
- try {
6
- return useHostQueryClient();
7
- } catch {
8
- return undefined;
9
- }
10
- }
11
- export function useQueryClient() {
12
- const client = React.useContext(clientContext);
13
- const hostClient = useMaybeHostQueryClient();
14
- return React.useMemo(()=>{
15
- if (client) {
16
- return client;
17
- }
18
- if (hostClient) return hostClient;
19
- return new QueryClient({
20
- defaultOptions: {
21
- queries: {
22
- useErrorBoundary: false,
23
- refetchOnWindowFocus: false,
24
- refetchOnReconnect: true,
25
- refetchOnMount: false,
26
- staleTime: Infinity,
27
- retry: false
28
- }
29
- }
30
- });
31
- }, [
32
- client,
33
- hostClient
34
- ]);
35
- }
36
- export const useQuery = (key, fn, opt)=>{
37
- return useRQ(key, fn, {
38
- ...opt,
39
- context: clientContext
40
- });
41
- };
42
- export function SharedQueryClientProvider({ children }) {
43
- const client = useQueryClient();
44
- return /*#__PURE__*/ React.createElement(clientContext.Provider, {
45
- value: client
46
- }, children);
47
- }
1
+ export { SharedQueryClientProvider, useQueryClient, useQuery } from '@contentful/field-editor-shared';
@@ -88,12 +88,12 @@ declare const useEntityLoader: () => {
88
88
  };
89
89
  export declare function useEntity<E extends FetchableEntity>(entityType: FetchableEntityType, entityId: string, options?: Omit<UseEntityOptions, 'releaseId'>): UseEntityResult<E>;
90
90
  export declare function useResource<R extends Resource = Resource>(resourceType: string, urn: string, { locale, referencingEntryId, ...options }?: UseResourceOptions): {
91
- status: "error" | "success" | "loading";
91
+ status: "loading" | "error" | "success";
92
92
  data: ResourceInfo<R> | undefined;
93
93
  error: unknown;
94
94
  };
95
95
  export declare function useResourceProvider(organizationId: string, appDefinitionId: string): {
96
- status: "error" | "success" | "loading";
96
+ status: "loading" | "error" | "success";
97
97
  data: ResourceProvider | undefined;
98
98
  error: unknown;
99
99
  };
@@ -1,9 +1,5 @@
1
- import * as React from 'react';
2
- import { QueryClient, useQuery as useRQ } from '@tanstack/react-query';
3
- export declare function useQueryClient(): QueryClient;
4
- export declare const useQuery: typeof useRQ;
5
1
  /**
6
- * Provides access to a query client either by sharing an existing client or
7
- * creating a new one.
2
+ * Re-export query client utilities from shared package.
3
+ * This maintains backwards compatibility while using the shared implementation.
8
4
  */
9
- export declare function SharedQueryClientProvider({ children }: React.PropsWithChildren<{}>): React.JSX.Element;
5
+ export { SharedQueryClientProvider, useQueryClient, useQuery, } from '@contentful/field-editor-shared';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-reference",
3
- "version": "6.19.1",
3
+ "version": "6.19.2-canary.7+54b401aa",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "@contentful/f36-components": "^5.8.1",
40
40
  "@contentful/f36-icons": "^5.8.1",
41
41
  "@contentful/f36-tokens": "^5.1.0",
42
- "@contentful/field-editor-shared": "^2.17.0",
42
+ "@contentful/field-editor-shared": "^2.17.1-canary.59+54b401aa",
43
43
  "@contentful/mimetype": "^2.2.29",
44
44
  "@dnd-kit/core": "^6.0.8",
45
45
  "@dnd-kit/sortable": "^8.0.0",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "registry": "https://npm.pkg.github.com/"
70
70
  },
71
- "gitHead": "df62d5fb562de590a6de09e86d2e72913c64ac93"
71
+ "gitHead": "54b401aa9908c8380c3801bf25fa38e23dff72d2"
72
72
  }