@contentful/react-apps-toolkit 1.2.15 → 1.2.19

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() {
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.19",
4
4
  "description": "Toolkit for building a Contentful app in React",
5
5
  "keywords": [],
6
6
  "author": "Contentful GmbH",
@@ -43,7 +43,7 @@
43
43
  "jest": "27.5.0",
44
44
  "react": "17.0.2",
45
45
  "react-dom": "17.0.2",
46
- "ts-jest": "27.1.3",
46
+ "ts-jest": "29.4.6",
47
47
  "typescript": "4.9.5"
48
48
  },
49
49
  "publishConfig": {
@@ -52,5 +52,5 @@
52
52
  "dependencies": {
53
53
  "contentful-management": ">=7.30.0"
54
54
  },
55
- "gitHead": "d2dac61d0116ef9df6fc95e4a4cb14bafc679378"
55
+ "gitHead": "4c3506be3f52c7a8aae17deaa75acefc9a805b42"
56
56
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2020 Contentful
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.