@contentful/field-editor-validation-errors 0.6.4 → 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/CHANGELOG.md +21 -90
- package/README.md +0 -1
- package/dist/ValidationErrors.d.ts +0 -9
- package/dist/field-editor-validation-errors.cjs.development.js +21 -17
- package/dist/field-editor-validation-errors.cjs.development.js.map +1 -1
- package/dist/field-editor-validation-errors.cjs.production.min.js +1 -1
- package/dist/field-editor-validation-errors.cjs.production.min.js.map +1 -1
- package/dist/field-editor-validation-errors.esm.js +17 -13
- package/dist/field-editor-validation-errors.esm.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,197 +3,128 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# [1.0.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.8.0...@contentful/field-editor-validation-errors@1.0.0) (2021-11-04)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
9
9
|
|
|
10
|
+
# [0.8.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.7.1...@contentful/field-editor-validation-errors@0.8.0) (2021-11-04)
|
|
10
11
|
|
|
12
|
+
### Features
|
|
11
13
|
|
|
14
|
+
- Forma v4 components adoption ([#805](https://github.com/contentful/field-editors/issues/805)) ([526bde6](https://github.com/contentful/field-editors/commit/526bde6e10e0ee3789705ec10fb31489af7ca59e))
|
|
12
15
|
|
|
16
|
+
### BREAKING CHANGES
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
- adopts a new Forma v4 beta
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
## [0.7.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.7.0...@contentful/field-editor-validation-errors@0.7.1) (2021-10-14)
|
|
17
21
|
|
|
22
|
+
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
18
23
|
|
|
24
|
+
# [0.7.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.6.4...@contentful/field-editor-validation-errors@0.7.0) (2021-10-06)
|
|
19
25
|
|
|
26
|
+
### Features
|
|
20
27
|
|
|
28
|
+
- [EXT-3161] bump app sdk to v4 ([#881](https://github.com/contentful/field-editors/issues/881)) ([9c4a2af](https://github.com/contentful/field-editors/commit/9c4a2af07da203d59fb5f15c3a5188ecc64b1d44))
|
|
21
29
|
|
|
22
|
-
## [0.6.
|
|
30
|
+
## [0.6.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.6.3...@contentful/field-editor-validation-errors@0.6.4) (2021-09-17)
|
|
23
31
|
|
|
24
32
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
25
33
|
|
|
34
|
+
## [0.6.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.6.2...@contentful/field-editor-validation-errors@0.6.3) (2021-09-16)
|
|
26
35
|
|
|
36
|
+
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
27
37
|
|
|
38
|
+
## [0.6.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.6.1...@contentful/field-editor-validation-errors@0.6.2) (2021-08-19)
|
|
28
39
|
|
|
40
|
+
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
29
41
|
|
|
30
42
|
## [0.6.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.6.0...@contentful/field-editor-validation-errors@0.6.1) (2021-07-29)
|
|
31
43
|
|
|
32
44
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
33
45
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
46
|
# [0.6.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.5.6...@contentful/field-editor-validation-errors@0.6.0) (2021-07-23)
|
|
39
47
|
|
|
40
|
-
|
|
41
48
|
### Features
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
- 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
|
|
48
51
|
|
|
49
52
|
## [0.5.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.5.3...@contentful/field-editor-validation-errors@0.5.6) (2021-07-06)
|
|
50
53
|
|
|
51
54
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
56
|
## [0.5.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.5.3...@contentful/field-editor-validation-errors@0.5.5) (2021-07-06)
|
|
58
57
|
|
|
59
58
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
60
|
## [0.5.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.5.3...@contentful/field-editor-validation-errors@0.5.4) (2021-06-23)
|
|
66
61
|
|
|
67
62
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
64
|
## [0.5.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.5.2...@contentful/field-editor-validation-errors@0.5.3) (2021-06-23)
|
|
74
65
|
|
|
75
66
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
76
67
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
68
|
## [0.5.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.5.1...@contentful/field-editor-validation-errors@0.5.2) (2021-06-22)
|
|
82
69
|
|
|
83
70
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
72
|
## [0.5.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.5.0...@contentful/field-editor-validation-errors@0.5.1) (2021-03-05)
|
|
90
73
|
|
|
91
74
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
92
75
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
76
|
# [0.5.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.4.2...@contentful/field-editor-validation-errors@0.5.0) (2021-02-19)
|
|
98
77
|
|
|
99
|
-
|
|
100
78
|
### Features
|
|
101
79
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
80
|
+
- bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
|
|
107
81
|
|
|
108
82
|
## [0.4.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.4.1...@contentful/field-editor-validation-errors@0.4.2) (2021-02-09)
|
|
109
83
|
|
|
110
84
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
111
85
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
86
|
## [0.4.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.4.0...@contentful/field-editor-validation-errors@0.4.1) (2021-02-01)
|
|
117
87
|
|
|
118
88
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
119
89
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
90
|
# [0.4.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.3.0...@contentful/field-editor-validation-errors@0.4.0) (2021-01-20)
|
|
125
91
|
|
|
126
|
-
|
|
127
92
|
### Features
|
|
128
93
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
94
|
+
- update minimal forma-36 versions to use updated design ([#565](https://github.com/contentful/field-editors/issues/565)) ([332c734](https://github.com/contentful/field-editors/commit/332c734bfaf54f0e9773fcbb460d743b1f5459ec))
|
|
134
95
|
|
|
135
96
|
# [0.3.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.2.7...@contentful/field-editor-validation-errors@0.3.0) (2021-01-12)
|
|
136
97
|
|
|
137
|
-
|
|
138
98
|
### Features
|
|
139
99
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
100
|
+
- update minimal required Forma version to the 3.73.12 ([#552](https://github.com/contentful/field-editors/issues/552)) ([2816fd9](https://github.com/contentful/field-editors/commit/2816fd960c28815faebf49a9ef8f4c4c0d91fc36))
|
|
145
101
|
|
|
146
102
|
## [0.2.7](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.2.6...@contentful/field-editor-validation-errors@0.2.7) (2020-12-16)
|
|
147
103
|
|
|
148
104
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
149
105
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
106
|
## [0.2.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.2.5...@contentful/field-editor-validation-errors@0.2.6) (2020-11-06)
|
|
155
107
|
|
|
156
108
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
157
109
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
110
|
## [0.2.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.2.4...@contentful/field-editor-validation-errors@0.2.5) (2020-11-06)
|
|
163
111
|
|
|
164
112
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
165
113
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
114
|
## [0.2.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.2.3...@contentful/field-editor-validation-errors@0.2.4) (2020-10-28)
|
|
171
115
|
|
|
172
116
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
173
117
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
118
|
## [0.2.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.2.2...@contentful/field-editor-validation-errors@0.2.3) (2020-09-08)
|
|
179
119
|
|
|
180
|
-
|
|
181
120
|
### Bug Fixes
|
|
182
121
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
122
|
+
- center vertical align of error items ([#396](https://github.com/contentful/field-editors/issues/396)) ([28de452](https://github.com/contentful/field-editors/commit/28de452c63a2d445549f78edce609c1e2266f96d))
|
|
188
123
|
|
|
189
124
|
## [0.2.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.2.1...@contentful/field-editor-validation-errors@0.2.2) (2020-08-24)
|
|
190
125
|
|
|
191
126
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
|
192
127
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
128
|
## [0.2.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-validation-errors@0.2.0...@contentful/field-editor-validation-errors@0.2.1) (2020-08-17)
|
|
198
129
|
|
|
199
130
|
**Note:** Version bump only for package @contentful/field-editor-validation-errors
|
package/README.md
CHANGED
|
@@ -7,6 +7,5 @@ npm install @contentful/field-editor-validation-errors
|
|
|
7
7
|
This package contains a React `ValidationErrors` component that is used render validation errors in the Contentful web application.
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
|
-
import '@contentful/forma-36-react-components/dist/styles.css';
|
|
11
10
|
import { ValidationErrors } from '@contentful/field-editor-validation-errors';
|
|
12
11
|
```
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { SpaceAPI, Entry, FieldAPI, LocalesAPI } from '@contentful/field-editor-shared';
|
|
3
|
-
export declare type ValidationError = {
|
|
4
|
-
name: string;
|
|
5
|
-
message: string;
|
|
6
|
-
conflicting?: Array<{
|
|
7
|
-
sys: {
|
|
8
|
-
id: string;
|
|
9
|
-
};
|
|
10
|
-
}>;
|
|
11
|
-
};
|
|
12
3
|
export interface ValidationErrorsProps {
|
|
13
4
|
field: FieldAPI;
|
|
14
5
|
space: SpaceAPI;
|
|
@@ -6,9 +6,10 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
6
6
|
|
|
7
7
|
var React = _interopDefault(require('react'));
|
|
8
8
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
9
|
-
var forma36ReactComponents = require('@contentful/forma-36-react-components');
|
|
10
9
|
var emotion = require('emotion');
|
|
11
|
-
var tokens = _interopDefault(require('@contentful/
|
|
10
|
+
var tokens = _interopDefault(require('@contentful/f36-tokens'));
|
|
11
|
+
var f36Components = require('@contentful/f36-components');
|
|
12
|
+
var f36Icons = require('@contentful/f36-icons');
|
|
12
13
|
|
|
13
14
|
function _extends() {
|
|
14
15
|
_extends = Object.assign || function (target) {
|
|
@@ -74,15 +75,19 @@ function UniquenessError(props) {
|
|
|
74
75
|
contentType: contentTypesById[entry.sys.contentType.sys.id]
|
|
75
76
|
});
|
|
76
77
|
}, [props.localeCode, props.defaultLocaleCode, contentTypesById]);
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
var conflicting = [];
|
|
79
|
+
|
|
80
|
+
if ('conflicting' in props.error) {
|
|
81
|
+
conflicting = props.error.conflicting;
|
|
82
|
+
}
|
|
79
83
|
|
|
84
|
+
React.useEffect(function () {
|
|
80
85
|
var entryIds = state.entries.map(function (entry) {
|
|
81
86
|
return entry.id;
|
|
82
87
|
});
|
|
83
|
-
var conflictIds =
|
|
88
|
+
var conflictIds = conflicting.map(function (entry) {
|
|
84
89
|
return entry.sys.id;
|
|
85
|
-
})
|
|
90
|
+
}); // Avoid unnecessary refetching
|
|
86
91
|
|
|
87
92
|
if (conflictIds.every(function (id) {
|
|
88
93
|
return entryIds.includes(id);
|
|
@@ -112,19 +117,19 @@ function UniquenessError(props) {
|
|
|
112
117
|
entries: entries
|
|
113
118
|
});
|
|
114
119
|
});
|
|
115
|
-
}, [getTitle, state.entries,
|
|
116
|
-
return React.createElement(
|
|
120
|
+
}, [getTitle, state.entries, conflicting, props.space.getEntries, props.getEntryURL]);
|
|
121
|
+
return React.createElement(f36Components.List, {
|
|
117
122
|
className: errorList,
|
|
118
123
|
testId: "validation-errors-uniqueness"
|
|
119
|
-
}, React.createElement(
|
|
124
|
+
}, React.createElement(f36Components.ListItem, {
|
|
120
125
|
className: entryLink
|
|
121
126
|
}, state.loading ? React.createElement("div", null, "Loading title for conflicting entry\u2026") : state.entries.map(function (entry) {
|
|
122
|
-
return React.createElement(
|
|
127
|
+
return React.createElement(f36Components.TextLink, {
|
|
123
128
|
key: entry.id,
|
|
124
129
|
href: entry.href,
|
|
125
|
-
icon:
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
icon: React.createElement(f36Icons.ExternalLinkIcon, null),
|
|
131
|
+
alignIcon: "end",
|
|
132
|
+
variant: "negative",
|
|
128
133
|
target: "_blank",
|
|
129
134
|
rel: "noopener noreferrer"
|
|
130
135
|
}, entry.title);
|
|
@@ -148,7 +153,7 @@ function ValidationErrors(props) {
|
|
|
148
153
|
return null;
|
|
149
154
|
}
|
|
150
155
|
|
|
151
|
-
return React.createElement(
|
|
156
|
+
return React.createElement(f36Components.List, {
|
|
152
157
|
className: errorList,
|
|
153
158
|
testId: "validation-errors"
|
|
154
159
|
}, errors.map(function (error, index) {
|
|
@@ -158,9 +163,8 @@ function ValidationErrors(props) {
|
|
|
158
163
|
"aria-roledescription": "field-locale-schema",
|
|
159
164
|
"data-error-code": "entry.schema." + error.name,
|
|
160
165
|
className: errorItem
|
|
161
|
-
}, React.createElement(
|
|
162
|
-
|
|
163
|
-
color: "negative"
|
|
166
|
+
}, React.createElement(f36Icons.InfoCircleIcon, {
|
|
167
|
+
variant: "negative"
|
|
164
168
|
}), React.createElement("div", {
|
|
165
169
|
className: errorMessage
|
|
166
170
|
}, error.message, error.name === 'unique' && React.createElement(UniquenessError, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-validation-errors.cjs.development.js","sources":["../src/styles.ts","../src/ValidationErrors.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/forma-36-tokens';\n\nexport const errorList = css({\n padding: 0,\n wordWrap: 'break-word',\n marginTop: tokens.spacingS,\n color: tokens.red500,\n listStyleType: 'none',\n});\n\nexport const errorMessage = css({\n display: 'inline-flex',\n flexDirection: 'column',\n marginLeft: tokens.spacingXs,\n});\n\nexport const errorItem = css({\n display: 'flex',\n alignItems: 'center',\n});\n\nexport const entryLink = css({\n fontWeight: Number(tokens.fontWeightDemiBold),\n});\n","import React from 'react';\nimport type {\n SpaceAPI,\n Entry,\n ContentType,\n FieldAPI,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport { entityHelpers } from '@contentful/field-editor-shared';\nimport { TextLink, List, ListItem, Icon } from '@contentful/forma-36-react-components';\n\nimport * as styles from './styles';\n\nexport type ValidationError = {\n name: string;\n message: string;\n conflicting?: Array<{ sys: { id: string } }>;\n};\n\ntype UniquenessErrorProps = {\n error: ValidationError;\n space: SpaceAPI;\n localeCode: string;\n defaultLocaleCode: string;\n getEntryURL: (entry: Entry) => string;\n};\n\nfunction UniquenessError(props: UniquenessErrorProps) {\n const [state, setState] = React.useState<{\n loading: boolean;\n entries: { id: string; title: string; href: string }[];\n }>({\n loading: true,\n entries: [],\n });\n\n const contentTypesById = React.useMemo(\n (): Record<string, ContentType> =>\n // Maps ID => Content Type\n props.space.getCachedContentTypes().reduce(\n (prev, ct) => ({\n ...prev,\n [ct.sys.id]: ct,\n }),\n {}\n ),\n [props.space]\n );\n\n const getTitle = React.useCallback(\n (entry: Entry) =>\n entityHelpers.getEntryTitle({\n entry,\n defaultTitle: 'Untitled',\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n contentType: contentTypesById[entry.sys.contentType.sys.id],\n }),\n [props.localeCode, props.defaultLocaleCode, contentTypesById]\n );\n\n React.useEffect(() => {\n const entryIds = state.entries.map((entry) => entry.id);\n const conflictIds = props.error.conflicting?.map((entry) => entry.sys.id) || [];\n\n // Avoid unnecessary refetching\n if (conflictIds.every((id) => entryIds.includes(id))) {\n return;\n }\n\n setState((state) => ({ ...state, loading: true }));\n\n const query = {\n 'sys.id[in]': conflictIds.join(','),\n };\n\n props.space.getEntries<Entry>(query).then(({ items }) => {\n const entries = items.map((entry) => ({\n id: entry.sys.id,\n title: getTitle(entry),\n href: props.getEntryURL(entry),\n }));\n\n setState({\n loading: false,\n entries,\n });\n });\n }, [getTitle, state.entries, props.error.conflicting, props.space.getEntries, props.getEntryURL]);\n\n return (\n <List className={styles.errorList} testId=\"validation-errors-uniqueness\">\n <ListItem className={styles.entryLink}>\n {state.loading ? (\n <div>Loading title for conflicting entry…</div>\n ) : (\n state.entries.map((entry) => (\n <TextLink\n key={entry.id}\n href={entry.href}\n icon=\"ExternalLink\"\n iconPosition=\"right\"\n linkType=\"negative\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {entry.title}\n </TextLink>\n ))\n )}\n </ListItem>\n </List>\n );\n}\n\nexport interface ValidationErrorsProps {\n field: FieldAPI;\n space: SpaceAPI;\n locales: LocalesAPI;\n getEntryURL: (entry: Entry) => string;\n}\n\nexport function ValidationErrors(props: ValidationErrorsProps) {\n const [errors, setErrors] = React.useState<ValidationError[]>([]);\n\n React.useEffect(() => {\n const onErrors = (errors?: ValidationError[]) => {\n setErrors(errors || []);\n };\n\n return props.field.onSchemaErrorsChanged(onErrors);\n }, [props.field]);\n\n if (errors.length === 0) {\n return null;\n }\n\n return (\n <List className={styles.errorList} testId=\"validation-errors\">\n {errors.map((error, index) => {\n return (\n <li\n key={index}\n role=\"status\"\n aria-roledescription=\"field-locale-schema\"\n data-error-code={`entry.schema.${error.name}`}\n className={styles.errorItem}>\n <Icon icon=\"InfoCircle\" color=\"negative\" />\n <div className={styles.errorMessage}>\n {error.message}\n {error.name === 'unique' && (\n <UniquenessError\n error={error}\n space={props.space}\n localeCode={props.field.locale}\n defaultLocaleCode={props.locales.default}\n getEntryURL={props.getEntryURL}\n />\n )}\n </div>\n </li>\n );\n })}\n </List>\n );\n}\n"],"names":["errorList","css","padding","wordWrap","marginTop","tokens","spacingS","color","red500","listStyleType","errorMessage","display","flexDirection","marginLeft","spacingXs","errorItem","alignItems","entryLink","fontWeight","Number","fontWeightDemiBold","UniquenessError","props","React","useState","loading","entries","state","setState","contentTypesById","useMemo","space","getCachedContentTypes","reduce","prev","ct","sys","id","getTitle","useCallback","entry","entityHelpers","getEntryTitle","defaultTitle","localeCode","defaultLocaleCode","contentType","useEffect","entryIds","map","conflictIds","error","conflicting","every","includes","query","join","getEntries","then","items","title","href","getEntryURL","List","className","styles","testId","ListItem","TextLink","key","icon","iconPosition","linkType","target","rel","ValidationErrors","errors","setErrors","onErrors","field","onSchemaErrorsChanged","length","index","role","name","Icon","message","locale","locales"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,SAAS,gBAAGC,WAAG,CAAC;AAC3BC,EAAAA,OAAO,EAAE,CADkB;AAE3BC,EAAAA,QAAQ,EAAE,YAFiB;AAG3BC,EAAAA,SAAS,EAAEC,MAAM,CAACC,QAHS;AAI3BC,EAAAA,KAAK,EAAEF,MAAM,CAACG,MAJa;AAK3BC,EAAAA,aAAa,EAAE;AALY,CAAD,CAArB;AAQA,IAAMC,YAAY,g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AACyD,KAAN,CAAYC,qBAAZ,CAAkCF,QAAlC,CAAP;AACD,GAND,EAMG,CAACxD,KAAK,CAACyD,KAAP,CANH;;AAQA,MAAIH,MAAM,CAACK,MAAP,KAAkB,CAAtB,EAAyB;AACvB,WAAO,IAAP;AACD;;AAED,SACE1D,mBAAA,CAACwC,2BAAD;AAAMC,IAAAA,SAAS,EAAEC;AAAkBC,IAAAA,MAAM,EAAC;GAA1C,EACGU,MAAM,CAAC3B,GAAP,CAAW,UAACE,KAAD,EAAQ+B,KAAR;AACV,WACE3D,mBAAA,KAAA;AACE8C,MAAAA,GAAG,EAAEa;AACLC,MAAAA,IAAI,EAAC;8BACgB;2CACYhC,KAAK,CAACiC;AACvCpB,MAAAA,SAAS,EAAEC;KALb,EAME1C,mBAAA,CAAC8D,2BAAD;AAAMf,MAAAA,IAAI,EAAC;AAAa/D,MAAAA,KAAK,EAAC;KAA9B,CANF,EAOEgB,mBAAA,MAAA;AAAKyC,MAAAA,SAAS,EAAEC;KAAhB,EACGd,KAAK,CAACmC,OADT,EAEGnC,KAAK,CAACiC,IAAN,KAAe,QAAf,IACC7D,mBAAA,CAACF,eAAD;AACE8B,MAAAA,KAAK,EAAEA;AACPpB,MAAAA,KAAK,EAAET,KAAK,CAACS;AACba,MAAAA,UAAU,EAAEtB,KAAK,CAACyD,KAAN,CAAYQ;AACxB1C,MAAAA,iBAAiB,EAAEvB,KAAK,CAACkE,OAAN;AACnB1B,MAAAA,WAAW,EAAExC,KAAK,CAACwC;KALrB,CAHJ,CAPF,CADF;AAsBD,GAvBA,CADH,CADF;AA4BD;;;;"}
|
|
1
|
+
{"version":3,"file":"field-editor-validation-errors.cjs.development.js","sources":["../src/styles.ts","../src/ValidationErrors.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const errorList = css({\n padding: 0,\n wordWrap: 'break-word',\n marginTop: tokens.spacingS,\n color: tokens.red500,\n listStyleType: 'none',\n});\n\nexport const errorMessage = css({\n display: 'inline-flex',\n flexDirection: 'column',\n marginLeft: tokens.spacingXs,\n});\n\nexport const errorItem = css({\n display: 'flex',\n alignItems: 'center',\n});\n\nexport const entryLink = css({\n fontWeight: Number(tokens.fontWeightDemiBold),\n});\n","import React from 'react';\nimport { ValidationError, Link } from '@contentful/app-sdk';\nimport type {\n SpaceAPI,\n Entry,\n ContentType,\n FieldAPI,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport { entityHelpers } from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\nimport { TextLink, List, ListItem } from '@contentful/f36-components';\n\nimport { ExternalLinkIcon, InfoCircleIcon } from '@contentful/f36-icons';\n\ntype UniquenessErrorProps = {\n error: ValidationError;\n space: SpaceAPI;\n localeCode: string;\n defaultLocaleCode: string;\n getEntryURL: (entry: Entry) => string;\n};\n\nfunction UniquenessError(props: UniquenessErrorProps) {\n const [state, setState] = React.useState<{\n loading: boolean;\n entries: { id: string; title: string; href: string }[];\n }>({\n loading: true,\n entries: [],\n });\n\n const contentTypesById = React.useMemo(\n (): Record<string, ContentType> =>\n // Maps ID => Content Type\n props.space.getCachedContentTypes().reduce(\n (prev, ct) => ({\n ...prev,\n [ct.sys.id]: ct,\n }),\n {}\n ),\n [props.space]\n );\n\n const getTitle = React.useCallback(\n (entry: Entry) =>\n entityHelpers.getEntryTitle({\n entry,\n defaultTitle: 'Untitled',\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n contentType: contentTypesById[entry.sys.contentType.sys.id],\n }),\n [props.localeCode, props.defaultLocaleCode, contentTypesById]\n );\n\n let conflicting: Link<'Entry', 'Link'>[] = [];\n if ('conflicting' in props.error) {\n conflicting = props.error.conflicting;\n }\n React.useEffect(() => {\n const entryIds = state.entries.map((entry) => entry.id);\n const conflictIds = conflicting.map((entry) => entry.sys.id);\n\n // Avoid unnecessary refetching\n if (conflictIds.every((id) => entryIds.includes(id))) {\n return;\n }\n\n setState((state) => ({ ...state, loading: true }));\n\n const query = {\n 'sys.id[in]': conflictIds.join(','),\n };\n\n props.space.getEntries<Entry>(query).then(({ items }) => {\n const entries = items.map((entry) => ({\n id: entry.sys.id,\n title: getTitle(entry),\n href: props.getEntryURL(entry),\n }));\n\n setState({\n loading: false,\n entries,\n });\n });\n }, [getTitle, state.entries, conflicting, props.space.getEntries, props.getEntryURL]);\n\n return (\n <List className={styles.errorList} testId=\"validation-errors-uniqueness\">\n <ListItem className={styles.entryLink}>\n {state.loading ? (\n <div>Loading title for conflicting entry…</div>\n ) : (\n state.entries.map((entry) => (\n <TextLink\n key={entry.id}\n href={entry.href}\n icon={<ExternalLinkIcon />}\n alignIcon=\"end\"\n variant=\"negative\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {entry.title}\n </TextLink>\n ))\n )}\n </ListItem>\n </List>\n );\n}\n\nexport interface ValidationErrorsProps {\n field: FieldAPI;\n space: SpaceAPI;\n locales: LocalesAPI;\n getEntryURL: (entry: Entry) => string;\n}\n\nexport function ValidationErrors(props: ValidationErrorsProps) {\n const [errors, setErrors] = React.useState<ValidationError[]>([]);\n\n React.useEffect(() => {\n const onErrors = (errors?: ValidationError[]) => {\n setErrors(errors || []);\n };\n\n return props.field.onSchemaErrorsChanged(onErrors);\n }, [props.field]);\n\n if (errors.length === 0) {\n return null;\n }\n\n return (\n <List className={styles.errorList} testId=\"validation-errors\">\n {errors.map((error, index) => {\n return (\n <li\n key={index}\n role=\"status\"\n aria-roledescription=\"field-locale-schema\"\n data-error-code={`entry.schema.${error.name}`}\n className={styles.errorItem}>\n <InfoCircleIcon variant=\"negative\" />\n <div className={styles.errorMessage}>\n {error.message}\n {error.name === 'unique' && (\n <UniquenessError\n error={error}\n space={props.space}\n localeCode={props.field.locale}\n defaultLocaleCode={props.locales.default}\n getEntryURL={props.getEntryURL}\n />\n )}\n </div>\n </li>\n );\n })}\n </List>\n );\n}\n"],"names":["errorList","css","padding","wordWrap","marginTop","tokens","spacingS","color","red500","listStyleType","errorMessage","display","flexDirection","marginLeft","spacingXs","errorItem","alignItems","entryLink","fontWeight","Number","fontWeightDemiBold","UniquenessError","props","React","useState","loading","entries","state","setState","contentTypesById","useMemo","space","getCachedContentTypes","reduce","prev","ct","sys","id","getTitle","useCallback","entry","entityHelpers","getEntryTitle","defaultTitle","localeCode","defaultLocaleCode","contentType","conflicting","error","useEffect","entryIds","map","conflictIds","every","includes","query","join","getEntries","then","items","title","href","getEntryURL","List","className","styles","testId","ListItem","TextLink","key","icon","ExternalLinkIcon","alignIcon","variant","target","rel","ValidationErrors","errors","setErrors","onErrors","field","onSchemaErrorsChanged","length","index","role","name","InfoCircleIcon","message","locale","locales"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,SAAS,gBAAGC,WAAG,CAAC;AAC3BC,EAAAA,OAAO,EAAE,CADkB;AAE3BC,EAAAA,QAAQ,EAAE,YAFiB;AAG3BC,EAAAA,SAAS,EAAEC,MAAM,CAACC,QAHS;AAI3BC,EAAAA,KAAK,EAAEF,MAAM,CAACG,MAJa;AAK3BC,EAAAA,aAAa,EAAE;AALY,CAAD,CAArB;AAQA,IAAMC,YAAY,gBAAGT,WAAG,CAAC;AAC9BU,EAAAA,OAAO,EAAE,aADqB;AAE9BC,EAAAA,aAAa,EAAE,QAFe;AAG9BC,EAAAA,UAAU,EAAER,MAAM,CAACS;AAHW,CAAD,CAAxB;AAMA,IAAMC,SAAS,gBAAGd,WAAG,CAAC;AAC3BU,EAAAA,OAAO,EAAE,MADkB;AAE3BK,EAAAA,UAAU,EAAE;AAFe,CAAD,CAArB;AAKA,IAAMC,SAAS,gBAAGhB,WAAG,CAAC;AAC3BiB,EAAAA,UAAU,eAAEC,MAAM,CAACd,MAAM,CAACe,kBAAR;AADS,CAAD,CAArB;;ACGP,SAASC,eAAT,CAAyBC,KAAzB;AACE,wBAA0BC,KAAK,CAACC,QAAN,CAGvB;AACDC,IAAAA,OAAO,EAAE,IADR;AAEDC,IAAAA,OAAO,EAAE;AA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;8BACgB;2CACYpC,KAAK,CAACqC;AACvCrB,MAAAA,SAAS,EAAEC;KALb,EAME1C,mBAAA,CAAC+D,uBAAD;AAAgBb,MAAAA,OAAO,EAAC;KAAxB,CANF,EAOElD,mBAAA,MAAA;AAAKyC,MAAAA,SAAS,EAAEC;KAAhB,EACGjB,KAAK,CAACuC,OADT,EAEGvC,KAAK,CAACqC,IAAN,KAAe,QAAf,IACC9D,mBAAA,CAACF,eAAD;AACE2B,MAAAA,KAAK,EAAEA;AACPjB,MAAAA,KAAK,EAAET,KAAK,CAACS;AACba,MAAAA,UAAU,EAAEtB,KAAK,CAAC0D,KAAN,CAAYQ;AACxB3C,MAAAA,iBAAiB,EAAEvB,KAAK,CAACmE,OAAN;AACnB3B,MAAAA,WAAW,EAAExC,KAAK,CAACwC;KALrB,CAHJ,CAPF,CADF;AAsBD,GAvBA,CADH,CADF;AA4BD;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),n=require("@contentful/field-editor-shared"),r=require("@contentful/
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),n=require("@contentful/field-editor-shared"),r=require("emotion"),i=e(require("@contentful/f36-tokens")),a=require("@contentful/f36-components"),o=require("@contentful/f36-icons");function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var c=r.css({padding:0,wordWrap:"break-word",marginTop:i.spacingS,color:i.red500,listStyleType:"none"}),s=r.css({display:"inline-flex",flexDirection:"column",marginLeft:i.spacingXs}),u=r.css({display:"flex",alignItems:"center"}),f=r.css({fontWeight:Number(i.fontWeightDemiBold)});function d(e){var r=t.useState({loading:!0,entries:[]}),i=r[0],s=r[1],u=t.useMemo((function(){return e.space.getCachedContentTypes().reduce((function(e,t){var n;return l({},e,((n={})[t.sys.id]=t,n))}),{})}),[e.space]),d=t.useCallback((function(t){return n.entityHelpers.getEntryTitle({entry:t,defaultTitle:"Untitled",localeCode:e.localeCode,defaultLocaleCode:e.defaultLocaleCode,contentType:u[t.sys.contentType.sys.id]})}),[e.localeCode,e.defaultLocaleCode,u]),m=[];return"conflicting"in e.error&&(m=e.error.conflicting),t.useEffect((function(){var t=i.entries.map((function(e){return e.id})),n=m.map((function(e){return e.sys.id}));if(!n.every((function(e){return t.includes(e)}))){s((function(e){return l({},e,{loading:!0})}));var r={"sys.id[in]":n.join(",")};e.space.getEntries(r).then((function(t){var n=t.items.map((function(t){return{id:t.sys.id,title:d(t),href:e.getEntryURL(t)}}));s({loading:!1,entries:n})}))}}),[d,i.entries,m,e.space.getEntries,e.getEntryURL]),t.createElement(a.List,{className:c,testId:"validation-errors-uniqueness"},t.createElement(a.ListItem,{className:f},i.loading?t.createElement("div",null,"Loading title for conflicting entry…"):i.entries.map((function(e){return t.createElement(a.TextLink,{key:e.id,href:e.href,icon:t.createElement(o.ExternalLinkIcon,null),alignIcon:"end",variant:"negative",target:"_blank",rel:"noopener noreferrer"},e.title)}))))}exports.ValidationErrors=function(e){var n=t.useState([]),r=n[0],i=n[1];return t.useEffect((function(){return e.field.onSchemaErrorsChanged((function(e){i(e||[])}))}),[e.field]),0===r.length?null:t.createElement(a.List,{className:c,testId:"validation-errors"},r.map((function(n,r){return t.createElement("li",{key:r,role:"status","aria-roledescription":"field-locale-schema","data-error-code":"entry.schema."+n.name,className:u},t.createElement(o.InfoCircleIcon,{variant:"negative"}),t.createElement("div",{className:s},n.message,"unique"===n.name&&t.createElement(d,{error:n,space:e.space,localeCode:e.field.locale,defaultLocaleCode:e.locales.default,getEntryURL:e.getEntryURL})))})))};
|
|
2
2
|
//# sourceMappingURL=field-editor-validation-errors.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-validation-errors.cjs.production.min.js","sources":["../src/styles.ts","../src/ValidationErrors.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/
|
|
1
|
+
{"version":3,"file":"field-editor-validation-errors.cjs.production.min.js","sources":["../src/styles.ts","../src/ValidationErrors.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const errorList = css({\n padding: 0,\n wordWrap: 'break-word',\n marginTop: tokens.spacingS,\n color: tokens.red500,\n listStyleType: 'none',\n});\n\nexport const errorMessage = css({\n display: 'inline-flex',\n flexDirection: 'column',\n marginLeft: tokens.spacingXs,\n});\n\nexport const errorItem = css({\n display: 'flex',\n alignItems: 'center',\n});\n\nexport const entryLink = css({\n fontWeight: Number(tokens.fontWeightDemiBold),\n});\n","import React from 'react';\nimport { ValidationError, Link } from '@contentful/app-sdk';\nimport type {\n SpaceAPI,\n Entry,\n ContentType,\n FieldAPI,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport { entityHelpers } from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\nimport { TextLink, List, ListItem } from '@contentful/f36-components';\n\nimport { ExternalLinkIcon, InfoCircleIcon } from '@contentful/f36-icons';\n\ntype UniquenessErrorProps = {\n error: ValidationError;\n space: SpaceAPI;\n localeCode: string;\n defaultLocaleCode: string;\n getEntryURL: (entry: Entry) => string;\n};\n\nfunction UniquenessError(props: UniquenessErrorProps) {\n const [state, setState] = React.useState<{\n loading: boolean;\n entries: { id: string; title: string; href: string }[];\n }>({\n loading: true,\n entries: [],\n });\n\n const contentTypesById = React.useMemo(\n (): Record<string, ContentType> =>\n // Maps ID => Content Type\n props.space.getCachedContentTypes().reduce(\n (prev, ct) => ({\n ...prev,\n [ct.sys.id]: ct,\n }),\n {}\n ),\n [props.space]\n );\n\n const getTitle = React.useCallback(\n (entry: Entry) =>\n entityHelpers.getEntryTitle({\n entry,\n defaultTitle: 'Untitled',\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n contentType: contentTypesById[entry.sys.contentType.sys.id],\n }),\n [props.localeCode, props.defaultLocaleCode, contentTypesById]\n );\n\n let conflicting: Link<'Entry', 'Link'>[] = [];\n if ('conflicting' in props.error) {\n conflicting = props.error.conflicting;\n }\n React.useEffect(() => {\n const entryIds = state.entries.map((entry) => entry.id);\n const conflictIds = conflicting.map((entry) => entry.sys.id);\n\n // Avoid unnecessary refetching\n if (conflictIds.every((id) => entryIds.includes(id))) {\n return;\n }\n\n setState((state) => ({ ...state, loading: true }));\n\n const query = {\n 'sys.id[in]': conflictIds.join(','),\n };\n\n props.space.getEntries<Entry>(query).then(({ items }) => {\n const entries = items.map((entry) => ({\n id: entry.sys.id,\n title: getTitle(entry),\n href: props.getEntryURL(entry),\n }));\n\n setState({\n loading: false,\n entries,\n });\n });\n }, [getTitle, state.entries, conflicting, props.space.getEntries, props.getEntryURL]);\n\n return (\n <List className={styles.errorList} testId=\"validation-errors-uniqueness\">\n <ListItem className={styles.entryLink}>\n {state.loading ? (\n <div>Loading title for conflicting entry…</div>\n ) : (\n state.entries.map((entry) => (\n <TextLink\n key={entry.id}\n href={entry.href}\n icon={<ExternalLinkIcon />}\n alignIcon=\"end\"\n variant=\"negative\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {entry.title}\n </TextLink>\n ))\n )}\n </ListItem>\n </List>\n );\n}\n\nexport interface ValidationErrorsProps {\n field: FieldAPI;\n space: SpaceAPI;\n locales: LocalesAPI;\n getEntryURL: (entry: Entry) => string;\n}\n\nexport function ValidationErrors(props: ValidationErrorsProps) {\n const [errors, setErrors] = React.useState<ValidationError[]>([]);\n\n React.useEffect(() => {\n const onErrors = (errors?: ValidationError[]) => {\n setErrors(errors || []);\n };\n\n return props.field.onSchemaErrorsChanged(onErrors);\n }, [props.field]);\n\n if (errors.length === 0) {\n return null;\n }\n\n return (\n <List className={styles.errorList} testId=\"validation-errors\">\n {errors.map((error, index) => {\n return (\n <li\n key={index}\n role=\"status\"\n aria-roledescription=\"field-locale-schema\"\n data-error-code={`entry.schema.${error.name}`}\n className={styles.errorItem}>\n <InfoCircleIcon variant=\"negative\" />\n <div className={styles.errorMessage}>\n {error.message}\n {error.name === 'unique' && (\n <UniquenessError\n error={error}\n space={props.space}\n localeCode={props.field.locale}\n defaultLocaleCode={props.locales.default}\n getEntryURL={props.getEntryURL}\n />\n )}\n </div>\n </li>\n );\n })}\n </List>\n );\n}\n"],"names":["errorList","css","padding","wordWrap","marginTop","tokens","spacingS","color","red500","listStyleType","errorMessage","display","flexDirection","marginLeft","spacingXs","errorItem","alignItems","entryLink","fontWeight","Number","fontWeightDemiBold","UniquenessError","props","React","useState","loading","entries","state","setState","contentTypesById","useMemo","space","getCachedContentTypes","reduce","prev","ct","sys","id","getTitle","useCallback","entry","entityHelpers","getEntryTitle","defaultTitle","localeCode","defaultLocaleCode","contentType","conflicting","error","useEffect","entryIds","map","conflictIds","every","includes","query","join","getEntries","then","items","title","href","getEntryURL","List","className","styles","testId","ListItem","TextLink","key","icon","ExternalLinkIcon","alignIcon","variant","target","rel","errors","setErrors","field","onSchemaErrorsChanged","length","index","role","name","InfoCircleIcon","message","locale","locales"],"mappings":"uiBAGO,IAAMA,EAAYC,MAAI,CAC3BC,QAAS,EACTC,SAAU,aACVC,UAAWC,EAAOC,SAClBC,MAAOF,EAAOG,OACdC,cAAe,SAGJC,EAAeT,MAAI,CAC9BU,QAAS,cACTC,cAAe,SACfC,WAAYR,EAAOS,YAGRC,EAAYd,MAAI,CAC3BU,QAAS,OACTK,WAAY,WAGDC,EAAYhB,MAAI,CAC3BiB,WAAYC,OAAOd,EAAOe,sBCE5B,SAASC,EAAgBC,SACGC,EAAMC,SAG7B,CACDC,SAAS,EACTC,QAAS,KALJC,OAAOC,OAQRC,EAAmBN,EAAMO,SAC7B,kBAEER,EAAMS,MAAMC,wBAAwBC,QAClC,SAACC,EAAMC,qBACFD,UACFC,EAAGC,IAAIC,IAA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AEftD,EAAM0B,WAAU,kBAKP3B,EAAMwD,MAAMC,uBAJF,SAACH,GAChBC,EAAUD,GAAU,SAIrB,CAACtD,EAAMwD,QAEY,IAAlBF,EAAOI,OACF,KAIPzD,gBAACwC,QAAKC,UAAWC,EAAkBC,OAAO,qBACvCU,EAAOzB,KAAI,SAACH,EAAOiC,UAEhB1D,sBACE8C,IAAKY,EACLC,KAAK,gCACgB,wDACYlC,EAAMmC,KACvCnB,UAAWC,GACX1C,gBAAC6D,kBAAeX,QAAQ,aACxBlD,uBAAKyC,UAAWC,GACbjB,EAAMqC,QACS,WAAfrC,EAAMmC,MACL5D,gBAACF,GACC2B,MAAOA,EACPjB,MAAOT,EAAMS,MACba,WAAYtB,EAAMwD,MAAMQ,OACxBzC,kBAAmBvB,EAAMiE,gBACzBzB,YAAaxC,EAAMwC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { entityHelpers } from '@contentful/field-editor-shared';
|
|
3
|
-
import { List, Icon, ListItem, TextLink } from '@contentful/forma-36-react-components';
|
|
4
3
|
import { css } from 'emotion';
|
|
5
|
-
import tokens from '@contentful/
|
|
4
|
+
import tokens from '@contentful/f36-tokens';
|
|
5
|
+
import { List, ListItem, TextLink } from '@contentful/f36-components';
|
|
6
|
+
import { InfoCircleIcon, ExternalLinkIcon } from '@contentful/f36-icons';
|
|
6
7
|
|
|
7
8
|
function _extends() {
|
|
8
9
|
_extends = Object.assign || function (target) {
|
|
@@ -68,15 +69,19 @@ function UniquenessError(props) {
|
|
|
68
69
|
contentType: contentTypesById[entry.sys.contentType.sys.id]
|
|
69
70
|
});
|
|
70
71
|
}, [props.localeCode, props.defaultLocaleCode, contentTypesById]);
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
var conflicting = [];
|
|
73
|
+
|
|
74
|
+
if ('conflicting' in props.error) {
|
|
75
|
+
conflicting = props.error.conflicting;
|
|
76
|
+
}
|
|
73
77
|
|
|
78
|
+
React.useEffect(function () {
|
|
74
79
|
var entryIds = state.entries.map(function (entry) {
|
|
75
80
|
return entry.id;
|
|
76
81
|
});
|
|
77
|
-
var conflictIds =
|
|
82
|
+
var conflictIds = conflicting.map(function (entry) {
|
|
78
83
|
return entry.sys.id;
|
|
79
|
-
})
|
|
84
|
+
}); // Avoid unnecessary refetching
|
|
80
85
|
|
|
81
86
|
if (conflictIds.every(function (id) {
|
|
82
87
|
return entryIds.includes(id);
|
|
@@ -106,7 +111,7 @@ function UniquenessError(props) {
|
|
|
106
111
|
entries: entries
|
|
107
112
|
});
|
|
108
113
|
});
|
|
109
|
-
}, [getTitle, state.entries,
|
|
114
|
+
}, [getTitle, state.entries, conflicting, props.space.getEntries, props.getEntryURL]);
|
|
110
115
|
return React.createElement(List, {
|
|
111
116
|
className: errorList,
|
|
112
117
|
testId: "validation-errors-uniqueness"
|
|
@@ -116,9 +121,9 @@ function UniquenessError(props) {
|
|
|
116
121
|
return React.createElement(TextLink, {
|
|
117
122
|
key: entry.id,
|
|
118
123
|
href: entry.href,
|
|
119
|
-
icon:
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
icon: React.createElement(ExternalLinkIcon, null),
|
|
125
|
+
alignIcon: "end",
|
|
126
|
+
variant: "negative",
|
|
122
127
|
target: "_blank",
|
|
123
128
|
rel: "noopener noreferrer"
|
|
124
129
|
}, entry.title);
|
|
@@ -152,9 +157,8 @@ function ValidationErrors(props) {
|
|
|
152
157
|
"aria-roledescription": "field-locale-schema",
|
|
153
158
|
"data-error-code": "entry.schema." + error.name,
|
|
154
159
|
className: errorItem
|
|
155
|
-
}, React.createElement(
|
|
156
|
-
|
|
157
|
-
color: "negative"
|
|
160
|
+
}, React.createElement(InfoCircleIcon, {
|
|
161
|
+
variant: "negative"
|
|
158
162
|
}), React.createElement("div", {
|
|
159
163
|
className: errorMessage
|
|
160
164
|
}, error.message, error.name === 'unique' && React.createElement(UniquenessError, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-validation-errors.esm.js","sources":["../src/styles.ts","../src/ValidationErrors.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/forma-36-tokens';\n\nexport const errorList = css({\n padding: 0,\n wordWrap: 'break-word',\n marginTop: tokens.spacingS,\n color: tokens.red500,\n listStyleType: 'none',\n});\n\nexport const errorMessage = css({\n display: 'inline-flex',\n flexDirection: 'column',\n marginLeft: tokens.spacingXs,\n});\n\nexport const errorItem = css({\n display: 'flex',\n alignItems: 'center',\n});\n\nexport const entryLink = css({\n fontWeight: Number(tokens.fontWeightDemiBold),\n});\n","import React from 'react';\nimport type {\n SpaceAPI,\n Entry,\n ContentType,\n FieldAPI,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport { entityHelpers } from '@contentful/field-editor-shared';\nimport { TextLink, List, ListItem, Icon } from '@contentful/forma-36-react-components';\n\nimport * as styles from './styles';\n\nexport type ValidationError = {\n name: string;\n message: string;\n conflicting?: Array<{ sys: { id: string } }>;\n};\n\ntype UniquenessErrorProps = {\n error: ValidationError;\n space: SpaceAPI;\n localeCode: string;\n defaultLocaleCode: string;\n getEntryURL: (entry: Entry) => string;\n};\n\nfunction UniquenessError(props: UniquenessErrorProps) {\n const [state, setState] = React.useState<{\n loading: boolean;\n entries: { id: string; title: string; href: string }[];\n }>({\n loading: true,\n entries: [],\n });\n\n const contentTypesById = React.useMemo(\n (): Record<string, ContentType> =>\n // Maps ID => Content Type\n props.space.getCachedContentTypes().reduce(\n (prev, ct) => ({\n ...prev,\n [ct.sys.id]: ct,\n }),\n {}\n ),\n [props.space]\n );\n\n const getTitle = React.useCallback(\n (entry: Entry) =>\n entityHelpers.getEntryTitle({\n entry,\n defaultTitle: 'Untitled',\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n contentType: contentTypesById[entry.sys.contentType.sys.id],\n }),\n [props.localeCode, props.defaultLocaleCode, contentTypesById]\n );\n\n React.useEffect(() => {\n const entryIds = state.entries.map((entry) => entry.id);\n const conflictIds = props.error.conflicting?.map((entry) => entry.sys.id) || [];\n\n // Avoid unnecessary refetching\n if (conflictIds.every((id) => entryIds.includes(id))) {\n return;\n }\n\n setState((state) => ({ ...state, loading: true }));\n\n const query = {\n 'sys.id[in]': conflictIds.join(','),\n };\n\n props.space.getEntries<Entry>(query).then(({ items }) => {\n const entries = items.map((entry) => ({\n id: entry.sys.id,\n title: getTitle(entry),\n href: props.getEntryURL(entry),\n }));\n\n setState({\n loading: false,\n entries,\n });\n });\n }, [getTitle, state.entries, props.error.conflicting, props.space.getEntries, props.getEntryURL]);\n\n return (\n <List className={styles.errorList} testId=\"validation-errors-uniqueness\">\n <ListItem className={styles.entryLink}>\n {state.loading ? (\n <div>Loading title for conflicting entry…</div>\n ) : (\n state.entries.map((entry) => (\n <TextLink\n key={entry.id}\n href={entry.href}\n icon=\"ExternalLink\"\n iconPosition=\"right\"\n linkType=\"negative\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {entry.title}\n </TextLink>\n ))\n )}\n </ListItem>\n </List>\n );\n}\n\nexport interface ValidationErrorsProps {\n field: FieldAPI;\n space: SpaceAPI;\n locales: LocalesAPI;\n getEntryURL: (entry: Entry) => string;\n}\n\nexport function ValidationErrors(props: ValidationErrorsProps) {\n const [errors, setErrors] = React.useState<ValidationError[]>([]);\n\n React.useEffect(() => {\n const onErrors = (errors?: ValidationError[]) => {\n setErrors(errors || []);\n };\n\n return props.field.onSchemaErrorsChanged(onErrors);\n }, [props.field]);\n\n if (errors.length === 0) {\n return null;\n }\n\n return (\n <List className={styles.errorList} testId=\"validation-errors\">\n {errors.map((error, index) => {\n return (\n <li\n key={index}\n role=\"status\"\n aria-roledescription=\"field-locale-schema\"\n data-error-code={`entry.schema.${error.name}`}\n className={styles.errorItem}>\n <Icon icon=\"InfoCircle\" color=\"negative\" />\n <div className={styles.errorMessage}>\n {error.message}\n {error.name === 'unique' && (\n <UniquenessError\n error={error}\n space={props.space}\n localeCode={props.field.locale}\n defaultLocaleCode={props.locales.default}\n getEntryURL={props.getEntryURL}\n />\n )}\n </div>\n </li>\n );\n })}\n </List>\n );\n}\n"],"names":["errorList","css","padding","wordWrap","marginTop","tokens","spacingS","color","red500","listStyleType","errorMessage","display","flexDirection","marginLeft","spacingXs","errorItem","alignItems","entryLink","fontWeight","Number","fontWeightDemiBold","UniquenessError","props","React","useState","loading","entries","state","setState","contentTypesById","useMemo","space","getCachedContentTypes","reduce","prev","ct","sys","id","getTitle","useCallback","entry","entityHelpers","getEntryTitle","defaultTitle","localeCode","defaultLocaleCode","contentType","useEffect","entryIds","map","conflictIds","error","conflicting","every","includes","query","join","getEntries","then","items","title","href","getEntryURL","List","className","styles","testId","ListItem","TextLink","key","icon","iconPosition","linkType","target","rel","ValidationErrors","errors","setErrors","onErrors","field","onSchemaErrorsChanged","length","index","role","name","Icon","message","locale","locales"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,SAAS,gBAAGC,GAAG,CAAC;AAC3BC,EAAAA,OAAO,EAAE,CADkB;AAE3BC,EAAAA,QAAQ,EAAE,YAFiB;AAG3BC,EAAAA,SAAS,EAAEC,MAAM,CAACC,QAHS;AAI3BC,EAAAA,KAAK,EAAEF,MAAM,CAACG,MAJa;AAK3BC,EAAAA,aAAa,EAAE;AALY,CAAD,CAArB;AAQA,IAAMC,YAAY,gBAAGT,GAAG,CAAC;AAC9BU,EAAAA,OAAO,EAAE,aADqB;AAE9BC,EAAAA,aAAa,EAAE,QAFe;AAG9BC,EAAAA,UAAU,EAAER,MAAM,CAACS;AAHW,CAAD,CAAxB;AAMA,IAAMC,SAAS,gBAAGd,GAAG,CAAC;AAC3BU,EAAAA,OAAO,EAAE,MADkB;AAE3BK,EAAAA,UAAU,EAAE;AAFe,CAAD,CAArB;AAKA,IAAMC,SAAS,gBAAGhB,GAAG,CAAC;AAC3BiB,EAAAA,UAAU,eAAEC,MAAM,CAACd,MAAM,CAACe,kBAAR;AADS,CAAD,CAArB;;ACKP,SAASC,e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AAC;8BACgB;2CACYhC,KAAK,CAACiC;AACvCpB,MAAAA,SAAS,EAAEC;KALb,EAME1C,mBAAA,CAAC8D,IAAD;AAAMf,MAAAA,IAAI,EAAC;AAAa/D,MAAAA,KAAK,EAAC;KAA9B,CANF,EAOEgB,mBAAA,MAAA;AAAKyC,MAAAA,SAAS,EAAEC;KAAhB,EACGd,KAAK,CAACmC,OADT,EAEGnC,KAAK,CAACiC,IAAN,KAAe,QAAf,IACC7D,mBAAA,CAACF,eAAD;AACE8B,MAAAA,KAAK,EAAEA;AACPpB,MAAAA,KAAK,EAAET,KAAK,CAACS;AACba,MAAAA,UAAU,EAAEtB,KAAK,CAACyD,KAAN,CAAYQ;AACxB1C,MAAAA,iBAAiB,EAAEvB,KAAK,CAACkE,OAAN;AACnB1B,MAAAA,WAAW,EAAExC,KAAK,CAACwC;KALrB,CAHJ,CAPF,CADF;AAsBD,GAvBA,CADH,CADF;AA4BD;;;;"}
|
|
1
|
+
{"version":3,"file":"field-editor-validation-errors.esm.js","sources":["../src/styles.ts","../src/ValidationErrors.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-tokens';\n\nexport const errorList = css({\n padding: 0,\n wordWrap: 'break-word',\n marginTop: tokens.spacingS,\n color: tokens.red500,\n listStyleType: 'none',\n});\n\nexport const errorMessage = css({\n display: 'inline-flex',\n flexDirection: 'column',\n marginLeft: tokens.spacingXs,\n});\n\nexport const errorItem = css({\n display: 'flex',\n alignItems: 'center',\n});\n\nexport const entryLink = css({\n fontWeight: Number(tokens.fontWeightDemiBold),\n});\n","import React from 'react';\nimport { ValidationError, Link } from '@contentful/app-sdk';\nimport type {\n SpaceAPI,\n Entry,\n ContentType,\n FieldAPI,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport { entityHelpers } from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\nimport { TextLink, List, ListItem } from '@contentful/f36-components';\n\nimport { ExternalLinkIcon, InfoCircleIcon } from '@contentful/f36-icons';\n\ntype UniquenessErrorProps = {\n error: ValidationError;\n space: SpaceAPI;\n localeCode: string;\n defaultLocaleCode: string;\n getEntryURL: (entry: Entry) => string;\n};\n\nfunction UniquenessError(props: UniquenessErrorProps) {\n const [state, setState] = React.useState<{\n loading: boolean;\n entries: { id: string; title: string; href: string }[];\n }>({\n loading: true,\n entries: [],\n });\n\n const contentTypesById = React.useMemo(\n (): Record<string, ContentType> =>\n // Maps ID => Content Type\n props.space.getCachedContentTypes().reduce(\n (prev, ct) => ({\n ...prev,\n [ct.sys.id]: ct,\n }),\n {}\n ),\n [props.space]\n );\n\n const getTitle = React.useCallback(\n (entry: Entry) =>\n entityHelpers.getEntryTitle({\n entry,\n defaultTitle: 'Untitled',\n localeCode: props.localeCode,\n defaultLocaleCode: props.defaultLocaleCode,\n contentType: contentTypesById[entry.sys.contentType.sys.id],\n }),\n [props.localeCode, props.defaultLocaleCode, contentTypesById]\n );\n\n let conflicting: Link<'Entry', 'Link'>[] = [];\n if ('conflicting' in props.error) {\n conflicting = props.error.conflicting;\n }\n React.useEffect(() => {\n const entryIds = state.entries.map((entry) => entry.id);\n const conflictIds = conflicting.map((entry) => entry.sys.id);\n\n // Avoid unnecessary refetching\n if (conflictIds.every((id) => entryIds.includes(id))) {\n return;\n }\n\n setState((state) => ({ ...state, loading: true }));\n\n const query = {\n 'sys.id[in]': conflictIds.join(','),\n };\n\n props.space.getEntries<Entry>(query).then(({ items }) => {\n const entries = items.map((entry) => ({\n id: entry.sys.id,\n title: getTitle(entry),\n href: props.getEntryURL(entry),\n }));\n\n setState({\n loading: false,\n entries,\n });\n });\n }, [getTitle, state.entries, conflicting, props.space.getEntries, props.getEntryURL]);\n\n return (\n <List className={styles.errorList} testId=\"validation-errors-uniqueness\">\n <ListItem className={styles.entryLink}>\n {state.loading ? (\n <div>Loading title for conflicting entry…</div>\n ) : (\n state.entries.map((entry) => (\n <TextLink\n key={entry.id}\n href={entry.href}\n icon={<ExternalLinkIcon />}\n alignIcon=\"end\"\n variant=\"negative\"\n target=\"_blank\"\n rel=\"noopener noreferrer\">\n {entry.title}\n </TextLink>\n ))\n )}\n </ListItem>\n </List>\n );\n}\n\nexport interface ValidationErrorsProps {\n field: FieldAPI;\n space: SpaceAPI;\n locales: LocalesAPI;\n getEntryURL: (entry: Entry) => string;\n}\n\nexport function ValidationErrors(props: ValidationErrorsProps) {\n const [errors, setErrors] = React.useState<ValidationError[]>([]);\n\n React.useEffect(() => {\n const onErrors = (errors?: ValidationError[]) => {\n setErrors(errors || []);\n };\n\n return props.field.onSchemaErrorsChanged(onErrors);\n }, [props.field]);\n\n if (errors.length === 0) {\n return null;\n }\n\n return (\n <List className={styles.errorList} testId=\"validation-errors\">\n {errors.map((error, index) => {\n return (\n <li\n key={index}\n role=\"status\"\n aria-roledescription=\"field-locale-schema\"\n data-error-code={`entry.schema.${error.name}`}\n className={styles.errorItem}>\n <InfoCircleIcon variant=\"negative\" />\n <div className={styles.errorMessage}>\n {error.message}\n {error.name === 'unique' && (\n <UniquenessError\n error={error}\n space={props.space}\n localeCode={props.field.locale}\n defaultLocaleCode={props.locales.default}\n getEntryURL={props.getEntryURL}\n />\n )}\n </div>\n </li>\n );\n })}\n </List>\n );\n}\n"],"names":["errorList","css","padding","wordWrap","marginTop","tokens","spacingS","color","red500","listStyleType","errorMessage","display","flexDirection","marginLeft","spacingXs","errorItem","alignItems","entryLink","fontWeight","Number","fontWeightDemiBold","UniquenessError","props","React","useState","loading","entries","state","setState","contentTypesById","useMemo","space","getCachedContentTypes","reduce","prev","ct","sys","id","getTitle","useCallback","entry","entityHelpers","getEntryTitle","defaultTitle","localeCode","defaultLocaleCode","contentType","conflicting","error","useEffect","entryIds","map","conflictIds","every","includes","query","join","getEntries","then","items","title","href","getEntryURL","List","className","styles","testId","ListItem","TextLink","key","icon","ExternalLinkIcon","alignIcon","variant","target","rel","ValidationErrors","errors","setErrors","onErrors","field","onSchemaErrorsChanged","length","index","role","name","InfoCircleIcon","message","locale","locales"],"mappings":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iB,EAAEvB,KAAK,CAACmE,OAAN;AACnB3B,MAAAA,WAAW,EAAExC,KAAK,CAACwC;KALrB,CAHJ,CAPF,CADF;AAsBD,GAvBA,CADH,CADF;AA4BD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-validation-errors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/field-editor-validation-errors.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
"tsc": "tsc -p ./ --noEmit"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@contentful/
|
|
25
|
-
"@contentful/
|
|
26
|
-
"@contentful/
|
|
24
|
+
"@contentful/f36-components": "beta",
|
|
25
|
+
"@contentful/f36-icons": "beta",
|
|
26
|
+
"@contentful/f36-tokens": "beta",
|
|
27
|
+
"@contentful/field-editor-shared": "^1.0.0",
|
|
27
28
|
"emotion": "^10.0.17"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@contentful/field-editor-test-utils": "^0.
|
|
31
|
+
"@contentful/field-editor-test-utils": "^1.0.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"react": ">=16.8.0"
|
|
@@ -42,5 +43,5 @@
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "538c2239a48991e4bb281d4d07d8ede3413492a5"
|
|
46
47
|
}
|