@contentful/react-apps-toolkit 1.2.15 → 1.2.21-alpha.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 CHANGED
@@ -67,6 +67,7 @@ function App() {
67
67
  ```
68
68
 
69
69
  ### useCMA
70
+ > :warning: **DEPRECATED** If you are using App SDK v4.20 or greater use `sdk.cma` instead.
70
71
 
71
72
  `useCMA` returns an initialized [client for the Contentful Management API](https://www.npmjs.com/package/contentful-management). This can be used immediately to communicate with the environment the app is rendered in. [Contentful Management API docs](/developers/docs/references/content-management-api/).
72
73
 
@@ -107,13 +108,33 @@ If used in the [entry sidebar location](/developers/docs/extensibility/app-frame
107
108
 
108
109
  Usage:
109
110
 
111
+ Field component:
112
+ ```tsx
113
+ import { SDKProvider, useFieldValue } from '@contentful/react-apps-toolkit';
114
+
115
+ function FieldComponentUsingFieldValue() {
116
+ const [localizedValue, setLocalizedValue] = useFieldValue(sdk.field.id, sdk.field.locale); // specifies the current field and locale
117
+
118
+ return <input value={localizedValue} onChange={(e) => setLocalizedValue(e.target.value)} />;
119
+ }
120
+
121
+ function App() {
122
+ return (
123
+ <SDKProvider>
124
+ <FieldComponentUsingFieldValue />
125
+ </SDKProvider>
126
+ );
127
+ }
128
+ ```
129
+
130
+ Sidebar or Entry Editor component:
110
131
  ```tsx
111
132
  import { SDKProvider, useFieldValue } from '@contentful/react-apps-toolkit';
112
133
 
113
134
  function ComponentUsingFieldValue() {
114
- const [value, setValue] = useFieldValue('slug', 'en-US');
135
+ const [defaultValue, setDefaultValue] = useFieldValue('slug', sdk.locales.default); // specifies the "slug" field and the environment's default locale
115
136
 
116
- return <input value={value} onChange={(e) => setValue(e.target.value)} />;
137
+ return <input value={defaultValue} onChange={(e) => setDefaultValue(e.target.value)} />;
117
138
  }
118
139
 
119
140
  function App() {
@@ -25,7 +25,7 @@ var SDKProvider = function (props) {
25
25
  var _a = (0, react_1.useState)(), sdk = _a[0], setSDK = _a[1];
26
26
  (0, react_1.useEffect)(function () {
27
27
  var timeout = window.setTimeout(function () {
28
- console.warn("Your app is taking longer than expected to initialize. If you think this is an error with Contentful's App SDK, let us know: https://github.com/contentful/ui-extensions-sdk/issues");
28
+ console.warn("Your app is taking longer than expected to initialize. If you think this is an error with Contentful's App SDK, let us know: https://github.com/contentful/ui-extensions-sdk/issues.");
29
29
  }, DELAY_TIMEOUT);
30
30
  (0, app_sdk_1.init)(function (sdk) {
31
31
  setSDK(sdk);
package/dist/useCMA.d.ts CHANGED
@@ -2,6 +2,8 @@ import { PlainClientAPI } from 'contentful-management';
2
2
  import type { CMAClient } from '@contentful/app-sdk';
3
3
  type UseCMAReturnValue = (CMAClient extends never ? true : false) extends false ? CMAClient : PlainClientAPI;
4
4
  /**
5
+ * @deprecated if on App SDK v4.20 or greater use `sdk.cma` instead.
6
+ *
5
7
  * React hook returning a CMA plain client instance.
6
8
  * Must be used in the `SDKProvider` component. Will throw error, if called outside of `SDKProvider`.
7
9
  */
package/dist/useCMA.js CHANGED
@@ -5,6 +5,8 @@ var contentful_management_1 = require("contentful-management");
5
5
  var react_1 = require("react");
6
6
  var useSDK_1 = require("./useSDK");
7
7
  /**
8
+ * @deprecated if on App SDK v4.20 or greater use `sdk.cma` instead.
9
+ *
8
10
  * React hook returning a CMA plain client instance.
9
11
  * Must be used in the `SDKProvider` component. Will throw error, if called outside of `SDKProvider`.
10
12
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/react-apps-toolkit",
3
- "version": "1.2.15",
3
+ "version": "1.2.21-alpha.0",
4
4
  "description": "Toolkit for building a Contentful app in React",
5
5
  "keywords": [],
6
6
  "author": "Contentful GmbH",
@@ -47,10 +47,11 @@
47
47
  "typescript": "4.9.5"
48
48
  },
49
49
  "publishConfig": {
50
- "access": "public"
50
+ "access": "public",
51
+ "registry": "https://npm.pkg.github.com/"
51
52
  },
52
53
  "dependencies": {
53
54
  "contentful-management": ">=7.30.0"
54
55
  },
55
- "gitHead": "d2dac61d0116ef9df6fc95e4a4cb14bafc679378"
56
+ "gitHead": "83eea204b666977602cb680d5e5913864aa6dcc1"
56
57
  }