@contentful/field-editor-shared 3.0.1-canary.1 → 3.0.2-canary.12
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/dist/cjs/CharCounter.js +3 -3
- package/dist/cjs/LocalePublishingEntityStatusBadge/LocalePublishingPopover.js +6 -6
- package/dist/cjs/ReleaseEntityStatusBadge/ReleaseEntityStatusPopover.js +7 -7
- package/dist/cjs/utils/entityHelpers.js +14 -7
- package/dist/esm/CharCounter.js +1 -1
- package/dist/esm/LocalePublishingEntityStatusBadge/LocalePublishingPopover.js +1 -1
- package/dist/esm/ReleaseEntityStatusBadge/ReleaseEntityStatusPopover.js +1 -1
- package/dist/esm/utils/entityHelpers.js +14 -7
- package/dist/types/LocalePublishingEntityStatusBadge/LocalePublishingPopover.d.ts +1 -1
- package/dist/types/hooks/useReleaseStatus.d.ts +2 -2
- package/dist/types/utils/entityHelpers.d.ts +1 -1
- package/package.json +4 -4
package/dist/cjs/CharCounter.js
CHANGED
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "CharCounter", {
|
|
|
10
10
|
});
|
|
11
11
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
13
|
-
const
|
|
13
|
+
const _css = require("@emotion/css");
|
|
14
14
|
function _interop_require_default(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : {
|
|
16
16
|
default: obj
|
|
@@ -58,7 +58,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
58
58
|
return newObj;
|
|
59
59
|
}
|
|
60
60
|
const styles = {
|
|
61
|
-
invalid: (0,
|
|
61
|
+
invalid: (0, _css.css)({
|
|
62
62
|
color: _f36tokens.default.red600
|
|
63
63
|
})
|
|
64
64
|
};
|
|
@@ -70,7 +70,7 @@ function CharCounter(props) {
|
|
|
70
70
|
const valid = count === 0 || props.checkConstraint(count);
|
|
71
71
|
return /*#__PURE__*/ _react.createElement("span", {
|
|
72
72
|
"data-status-code": valid ? null : 'invalid-size',
|
|
73
|
-
className: (0,
|
|
73
|
+
className: (0, _css.cx)({
|
|
74
74
|
[styles.invalid]: !valid
|
|
75
75
|
})
|
|
76
76
|
}, count, " characters");
|
|
@@ -12,7 +12,7 @@ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
13
|
const _f36icons = require("@contentful/f36-icons");
|
|
14
14
|
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
15
|
-
const
|
|
15
|
+
const _css = require("@emotion/css");
|
|
16
16
|
const _entityHelpers = /*#__PURE__*/ _interop_require_wildcard(require("../utils/entityHelpers"));
|
|
17
17
|
const _LocalePublishingStatusList = require("./LocalePublishingStatusList");
|
|
18
18
|
const _ScheduledBanner = require("./ScheduledBanner");
|
|
@@ -99,7 +99,7 @@ const getColor = ({ secondary, tertiary, isHover })=>{
|
|
|
99
99
|
return isHover ? colors[status]?.hover : colors[status]?.default;
|
|
100
100
|
};
|
|
101
101
|
const generateDynamicStyles = (status)=>{
|
|
102
|
-
const wrapperClass = (0,
|
|
102
|
+
const wrapperClass = (0, _css.css)({
|
|
103
103
|
'& svg[data-status="secondary"]': {
|
|
104
104
|
fill: getColor({
|
|
105
105
|
secondary: status?.secondary,
|
|
@@ -131,13 +131,13 @@ const generateDynamicStyles = (status)=>{
|
|
|
131
131
|
};
|
|
132
132
|
const getIconColor = (status)=>colors[status].icon;
|
|
133
133
|
const styles = {
|
|
134
|
-
badge: (0,
|
|
134
|
+
badge: (0, _css.css)({
|
|
135
135
|
'&:focus': {
|
|
136
136
|
outline: 'none',
|
|
137
137
|
boxShadow: `inset ${_f36tokens.default.glowPrimary}`
|
|
138
138
|
}
|
|
139
139
|
}),
|
|
140
|
-
wrapper: (0,
|
|
140
|
+
wrapper: (0, _css.css)({
|
|
141
141
|
'& svg': {
|
|
142
142
|
transition: 'fill 0.2s ease-in-out'
|
|
143
143
|
},
|
|
@@ -145,7 +145,7 @@ const styles = {
|
|
|
145
145
|
marginLeft: '-1px'
|
|
146
146
|
}
|
|
147
147
|
}),
|
|
148
|
-
popoverContent: (0,
|
|
148
|
+
popoverContent: (0, _css.css)({
|
|
149
149
|
maxWidth: '336px',
|
|
150
150
|
maxHeight: '368px',
|
|
151
151
|
overflowY: 'auto',
|
|
@@ -256,7 +256,7 @@ function LocalePublishingPopover({ entity, jobs, isScheduled, localesStatusMap,
|
|
|
256
256
|
}, /*#__PURE__*/ _react.default.createElement(_f36components.Popover.Trigger, null, /*#__PURE__*/ _react.default.createElement(_f36components.Flex, {
|
|
257
257
|
"aria-label": ariaLabel,
|
|
258
258
|
alignItems: "center",
|
|
259
|
-
className: (0,
|
|
259
|
+
className: (0, _css.cx)(styles.wrapper, wrapperClass)
|
|
260
260
|
}, /*#__PURE__*/ _react.default.createElement(_f36components.EntityStatusBadge, {
|
|
261
261
|
className: styles.badge,
|
|
262
262
|
testId: "entity-state",
|
|
@@ -12,7 +12,7 @@ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
13
|
const _f36icons = require("@contentful/f36-icons");
|
|
14
14
|
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
15
|
-
const
|
|
15
|
+
const _css = require("@emotion/css");
|
|
16
16
|
const _getReleaseStatusBadgeConfig = require("../utils/getReleaseStatusBadgeConfig");
|
|
17
17
|
const _ReleaseEntityStatusLocalesList = require("./ReleaseEntityStatusLocalesList");
|
|
18
18
|
function _interop_require_default(obj) {
|
|
@@ -69,7 +69,7 @@ const getColor = ({ secondary, tertiary, isHover })=>{
|
|
|
69
69
|
return isHover ? (0, _getReleaseStatusBadgeConfig.getReleaseStatusBadgeConfig)(status).hover : (0, _getReleaseStatusBadgeConfig.getReleaseStatusBadgeConfig)(status).default;
|
|
70
70
|
};
|
|
71
71
|
const generateDynamicStyles = (status)=>{
|
|
72
|
-
const wrapperClass = (0,
|
|
72
|
+
const wrapperClass = (0, _css.css)({
|
|
73
73
|
...status?.secondary && {
|
|
74
74
|
'& svg[data-status="secondary"]': {
|
|
75
75
|
fill: getColor({
|
|
@@ -102,13 +102,13 @@ const generateDynamicStyles = (status)=>{
|
|
|
102
102
|
return wrapperClass;
|
|
103
103
|
};
|
|
104
104
|
const styles = {
|
|
105
|
-
badge: (0,
|
|
105
|
+
badge: (0, _css.css)({
|
|
106
106
|
'&:focus': {
|
|
107
107
|
outline: 'none',
|
|
108
108
|
boxShadow: `inset ${_f36tokens.default.glowPrimary}`
|
|
109
109
|
}
|
|
110
110
|
}),
|
|
111
|
-
wrapper: (0,
|
|
111
|
+
wrapper: (0, _css.css)({
|
|
112
112
|
'& svg': {
|
|
113
113
|
transition: 'fill 0.2s ease-in-out'
|
|
114
114
|
},
|
|
@@ -116,13 +116,13 @@ const styles = {
|
|
|
116
116
|
marginLeft: '-1px'
|
|
117
117
|
}
|
|
118
118
|
}),
|
|
119
|
-
popoverContent: (0,
|
|
119
|
+
popoverContent: (0, _css.css)({
|
|
120
120
|
maxWidth: '336px',
|
|
121
121
|
maxHeight: '368px',
|
|
122
122
|
overflowY: 'auto',
|
|
123
123
|
padding: `${_f36tokens.default.spacing2Xs} 0`
|
|
124
124
|
}),
|
|
125
|
-
skeletonBadge: (0,
|
|
125
|
+
skeletonBadge: (0, _css.css)({
|
|
126
126
|
flexShrink: 0,
|
|
127
127
|
display: 'block',
|
|
128
128
|
height: '20px',
|
|
@@ -226,7 +226,7 @@ function ReleaseEntityStatusPopover({ releaseStatusMap, activeLocales }) {
|
|
|
226
226
|
}, /*#__PURE__*/ _react.default.createElement(_f36components.Popover.Trigger, null, /*#__PURE__*/ _react.default.createElement(_f36components.Flex, {
|
|
227
227
|
"aria-label": ariaLabel,
|
|
228
228
|
alignItems: "center",
|
|
229
|
-
className: (0,
|
|
229
|
+
className: (0, _css.cx)(styles.wrapper, wrapperClass)
|
|
230
230
|
}, /*#__PURE__*/ _react.default.createElement(_f36components.Badge, {
|
|
231
231
|
tabIndex: 0,
|
|
232
232
|
variant: variant,
|
|
@@ -166,8 +166,14 @@ function getEntryTitle({ entry, contentType, localeCode, defaultLocaleCode, defa
|
|
|
166
166
|
}
|
|
167
167
|
return titleOrDefault(title, defaultTitle);
|
|
168
168
|
}
|
|
169
|
+
function getLocaleStatusObject(sys) {
|
|
170
|
+
if ('localeStatus' in sys) {
|
|
171
|
+
return sys.localeStatus;
|
|
172
|
+
}
|
|
173
|
+
return sys.fieldStatus?.['*'];
|
|
174
|
+
}
|
|
169
175
|
function getEntityStatus(sys, localeCodes) {
|
|
170
|
-
if (!sys
|
|
176
|
+
if (!sys) {
|
|
171
177
|
throw new TypeError('Invalid entity metadata object');
|
|
172
178
|
}
|
|
173
179
|
if (sys.deletedVersion) {
|
|
@@ -176,19 +182,20 @@ function getEntityStatus(sys, localeCodes) {
|
|
|
176
182
|
if (sys.archivedVersion) {
|
|
177
183
|
return 'archived';
|
|
178
184
|
}
|
|
179
|
-
|
|
185
|
+
const localeStatus = getLocaleStatusObject(sys);
|
|
186
|
+
if (localeStatus && localeCodes) {
|
|
180
187
|
let status = 'draft';
|
|
181
188
|
const locales = Array.isArray(localeCodes) ? localeCodes : [
|
|
182
189
|
localeCodes
|
|
183
190
|
];
|
|
184
|
-
for (const [localeCode,
|
|
191
|
+
for (const [localeCode, localeStatusValue] of Object.entries(localeStatus)){
|
|
185
192
|
if (!locales || locales.includes(localeCode)) {
|
|
186
|
-
if (
|
|
187
|
-
status =
|
|
193
|
+
if (localeStatusValue === 'changed') {
|
|
194
|
+
status = localeStatusValue;
|
|
188
195
|
break;
|
|
189
196
|
}
|
|
190
|
-
if (
|
|
191
|
-
status =
|
|
197
|
+
if (localeStatusValue === 'published') {
|
|
198
|
+
status = localeStatusValue;
|
|
192
199
|
}
|
|
193
200
|
}
|
|
194
201
|
}
|
package/dist/esm/CharCounter.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useCallback, useRef, useState } from 'react';
|
|
|
2
2
|
import { EntityStatusBadge, Flex, Popover } from '@contentful/f36-components';
|
|
3
3
|
import { CaretDownIcon } from '@contentful/f36-icons';
|
|
4
4
|
import tokens from '@contentful/f36-tokens';
|
|
5
|
-
import { cx, css } from 'emotion';
|
|
5
|
+
import { cx, css } from '@emotion/css';
|
|
6
6
|
import * as entityHelpers from '../utils/entityHelpers';
|
|
7
7
|
import { LocalePublishingStatusList } from './LocalePublishingStatusList';
|
|
8
8
|
import { ScheduledBanner } from './ScheduledBanner';
|
|
@@ -2,7 +2,7 @@ import React, { useCallback, useRef, useState } from 'react';
|
|
|
2
2
|
import { Badge, Flex, Popover } from '@contentful/f36-components';
|
|
3
3
|
import { CaretDownIcon } from '@contentful/f36-icons';
|
|
4
4
|
import tokens from '@contentful/f36-tokens';
|
|
5
|
-
import { css, cx } from 'emotion';
|
|
5
|
+
import { css, cx } from '@emotion/css';
|
|
6
6
|
import { getReleaseStatusBadgeConfig } from '../utils/getReleaseStatusBadgeConfig';
|
|
7
7
|
import { ReleaseEntityStatusLocalesList } from './ReleaseEntityStatusLocalesList';
|
|
8
8
|
const getColor = ({ secondary, tertiary, isHover })=>{
|
|
@@ -116,8 +116,14 @@ export function getEntryTitle({ entry, contentType, localeCode, defaultLocaleCod
|
|
|
116
116
|
}
|
|
117
117
|
return titleOrDefault(title, defaultTitle);
|
|
118
118
|
}
|
|
119
|
+
function getLocaleStatusObject(sys) {
|
|
120
|
+
if ('localeStatus' in sys) {
|
|
121
|
+
return sys.localeStatus;
|
|
122
|
+
}
|
|
123
|
+
return sys.fieldStatus?.['*'];
|
|
124
|
+
}
|
|
119
125
|
export function getEntityStatus(sys, localeCodes) {
|
|
120
|
-
if (!sys
|
|
126
|
+
if (!sys) {
|
|
121
127
|
throw new TypeError('Invalid entity metadata object');
|
|
122
128
|
}
|
|
123
129
|
if (sys.deletedVersion) {
|
|
@@ -126,19 +132,20 @@ export function getEntityStatus(sys, localeCodes) {
|
|
|
126
132
|
if (sys.archivedVersion) {
|
|
127
133
|
return 'archived';
|
|
128
134
|
}
|
|
129
|
-
|
|
135
|
+
const localeStatus = getLocaleStatusObject(sys);
|
|
136
|
+
if (localeStatus && localeCodes) {
|
|
130
137
|
let status = 'draft';
|
|
131
138
|
const locales = Array.isArray(localeCodes) ? localeCodes : [
|
|
132
139
|
localeCodes
|
|
133
140
|
];
|
|
134
|
-
for (const [localeCode,
|
|
141
|
+
for (const [localeCode, localeStatusValue] of Object.entries(localeStatus)){
|
|
135
142
|
if (!locales || locales.includes(localeCode)) {
|
|
136
|
-
if (
|
|
137
|
-
status =
|
|
143
|
+
if (localeStatusValue === 'changed') {
|
|
144
|
+
status = localeStatusValue;
|
|
138
145
|
break;
|
|
139
146
|
}
|
|
140
|
-
if (
|
|
141
|
-
status =
|
|
147
|
+
if (localeStatusValue === 'published') {
|
|
148
|
+
status = localeStatusValue;
|
|
142
149
|
}
|
|
143
150
|
}
|
|
144
151
|
}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { LocaleProps, EntryProps, AssetProps, ScheduledActionProps } from 'contentful-management';
|
|
3
3
|
import { LocalePublishStatusMap } from '../hooks/useLocalePublishStatus';
|
|
4
4
|
type LocalePublishingPopoverProps = {
|
|
5
|
-
entity: EntryProps | AssetProps
|
|
5
|
+
entity: Pick<EntryProps | AssetProps, 'sys'>;
|
|
6
6
|
jobs: ScheduledActionProps[];
|
|
7
7
|
isScheduled: boolean;
|
|
8
8
|
activeLocales?: Pick<LocaleProps, 'code'>[];
|
|
@@ -2,10 +2,10 @@ import type { LocalesAPI } from '@contentful/app-sdk';
|
|
|
2
2
|
import type { AssetProps, EntryProps, LocaleProps, ReleaseProps } from 'contentful-management/types';
|
|
3
3
|
import type { ReleaseEntityStatus, ReleaseStatusMap, ReleaseV2Props } from '../types';
|
|
4
4
|
type UseActiveReleaseLocalesStatuses = {
|
|
5
|
-
entity?: EntryProps | AssetProps
|
|
5
|
+
entity?: Pick<EntryProps | AssetProps, 'sys'>;
|
|
6
6
|
locales: LocaleProps[] | LocalesAPI;
|
|
7
7
|
release?: ReleaseProps | ReleaseV2Props;
|
|
8
|
-
previousEntityOnTimeline?: EntryProps | AssetProps
|
|
8
|
+
previousEntityOnTimeline?: Pick<EntryProps | AssetProps, 'sys'>;
|
|
9
9
|
isReference?: boolean;
|
|
10
10
|
};
|
|
11
11
|
type UseRelaseStatus = {
|
|
@@ -56,8 +56,8 @@ export declare function getEntryTitle({ entry, contentType, localeCode, defaultL
|
|
|
56
56
|
defaultLocaleCode: string;
|
|
57
57
|
defaultTitle: string;
|
|
58
58
|
}): string;
|
|
59
|
-
type FieldStatus = 'draft' | 'published' | 'changed';
|
|
60
59
|
export type EntitySys = Entry['sys'] | Asset['sys'];
|
|
60
|
+
type FieldStatus = 'draft' | 'published' | 'changed';
|
|
61
61
|
/**
|
|
62
62
|
* Returns the status of the entry/asset
|
|
63
63
|
* If a locale code(s) is provided it will pick up the most advanced state for these locale(s)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-shared",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2-canary.12+a033ba5a",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@contentful/app-sdk": "^4.42.0",
|
|
46
|
-
"@contentful/field-editor-test-utils": "^
|
|
46
|
+
"@contentful/field-editor-test-utils": "^2.0.0",
|
|
47
47
|
"@lingui/core": "5.3.0",
|
|
48
48
|
"@tanstack/react-query": "^4.3.9",
|
|
49
49
|
"@testing-library/react": "16.3.0"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@contentful/f36-components": "^6.7.1",
|
|
53
53
|
"@contentful/f36-icons": "^6.7.1",
|
|
54
|
-
"@contentful/f36-note": "^
|
|
54
|
+
"@contentful/f36-note": "^6.7.1",
|
|
55
55
|
"@contentful/f36-tokens": "^6.1.2",
|
|
56
56
|
"@emotion/css": "^11.13.5",
|
|
57
57
|
"contentful-management": "^11.60.4",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"registry": "https://npm.pkg.github.com/"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "a033ba5aa402ff68a0ee2da3dc1ca39c46795eed"
|
|
77
77
|
}
|