@contentful/field-editor-shared 1.4.6 → 1.4.8
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 +6 -4
- package/dist/cjs/index.js +0 -4
- package/dist/esm/CharCounter.js +6 -4
- package/dist/esm/index.js +0 -1
- package/dist/types/CharCounter.d.ts +2 -0
- package/dist/types/index.d.ts +0 -1
- package/package.json +2 -2
- package/dist/cjs/CharValidation.js +0 -62
- package/dist/esm/CharValidation.js +0 -11
- package/dist/types/CharValidation.d.ts +0 -7
package/dist/cjs/CharCounter.js
CHANGED
|
@@ -63,15 +63,17 @@ const styles = {
|
|
|
63
63
|
})
|
|
64
64
|
};
|
|
65
65
|
function CharCounter(props) {
|
|
66
|
+
const { constraints, value, checkConstraint } = props;
|
|
66
67
|
let count = 0;
|
|
67
|
-
if (
|
|
68
|
-
count =
|
|
68
|
+
if (value) {
|
|
69
|
+
count = value.length;
|
|
69
70
|
}
|
|
70
|
-
const valid = count === 0 ||
|
|
71
|
+
const valid = count === 0 || checkConstraint(count);
|
|
71
72
|
return _react.createElement("span", {
|
|
72
73
|
"data-status-code": valid ? null : 'invalid-size',
|
|
74
|
+
"data-test-id": "cf-ui-char-counter",
|
|
73
75
|
className: (0, _emotion.cx)({
|
|
74
76
|
[styles.invalid]: !valid
|
|
75
77
|
})
|
|
76
|
-
}, count
|
|
78
|
+
}, constraints.type === 'min' ? `${count}` : `${count} / ${constraints.max}`);
|
|
77
79
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,9 +24,6 @@ _export(exports, {
|
|
|
24
24
|
CharCounter: function() {
|
|
25
25
|
return _CharCounter.CharCounter;
|
|
26
26
|
},
|
|
27
|
-
CharValidation: function() {
|
|
28
|
-
return _CharValidation.CharValidation;
|
|
29
|
-
},
|
|
30
27
|
ConstraintsUtils: function() {
|
|
31
28
|
return _constraints;
|
|
32
29
|
},
|
|
@@ -105,7 +102,6 @@ _export(exports, {
|
|
|
105
102
|
});
|
|
106
103
|
const _appsdk = require("@contentful/app-sdk");
|
|
107
104
|
const _CharCounter = require("./CharCounter");
|
|
108
|
-
const _CharValidation = require("./CharValidation");
|
|
109
105
|
const _FieldConnector = require("./FieldConnector");
|
|
110
106
|
const _PredefinedValuesError = require("./PredefinedValuesError");
|
|
111
107
|
const _typesEntity = require("./typesEntity");
|
package/dist/esm/CharCounter.js
CHANGED
|
@@ -7,15 +7,17 @@ const styles = {
|
|
|
7
7
|
})
|
|
8
8
|
};
|
|
9
9
|
export function CharCounter(props) {
|
|
10
|
+
const { constraints, value, checkConstraint } = props;
|
|
10
11
|
let count = 0;
|
|
11
|
-
if (
|
|
12
|
-
count =
|
|
12
|
+
if (value) {
|
|
13
|
+
count = value.length;
|
|
13
14
|
}
|
|
14
|
-
const valid = count === 0 ||
|
|
15
|
+
const valid = count === 0 || checkConstraint(count);
|
|
15
16
|
return React.createElement("span", {
|
|
16
17
|
"data-status-code": valid ? null : 'invalid-size',
|
|
18
|
+
"data-test-id": "cf-ui-char-counter",
|
|
17
19
|
className: cx({
|
|
18
20
|
[styles.invalid]: !valid
|
|
19
21
|
})
|
|
20
|
-
}, count
|
|
22
|
+
}, constraints.type === 'min' ? `${count}` : `${count} / ${constraints.max}`);
|
|
21
23
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { AccessAPI, AppConfigAPI, BaseAppSDK, ContentType, DialogsAPI, EntryAPI, EntryFieldAPI, FieldAPI, FieldAppSDK, IdsAPI, LocalesAPI, LocationAPI, NavigatorAPI, NotifierAPI, OpenCustomWidgetOptions, ParametersAPI, SpaceAPI, WindowAPI } from '@contentful/app-sdk';
|
|
2
2
|
export { CharCounter } from './CharCounter';
|
|
3
|
-
export { CharValidation } from './CharValidation';
|
|
4
3
|
export { FieldConnector } from './FieldConnector';
|
|
5
4
|
export { PredefinedValuesError } from './PredefinedValuesError';
|
|
6
5
|
export { Asset, Entry, File } from './typesEntity';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ValidationType } from 'types';
|
|
2
3
|
interface CharCounterProps {
|
|
3
4
|
value?: string;
|
|
4
5
|
checkConstraint: (n: number) => boolean;
|
|
6
|
+
constraints: ValidationType;
|
|
5
7
|
}
|
|
6
8
|
export declare function CharCounter(props: CharCounterProps): JSX.Element;
|
|
7
9
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { AccessAPI, AppConfigAPI, BaseAppSDK, ContentType, DialogsAPI, EntryAPI, EntryFieldAPI, FieldAPI, FieldAppSDK, IdsAPI, LocalesAPI, LocationAPI, NavigatorAPI, NotifierAPI, OpenCustomWidgetOptions, ParametersAPI, SpaceAPI, WindowAPI, } from '@contentful/app-sdk';
|
|
2
2
|
export { CharCounter } from './CharCounter';
|
|
3
|
-
export { CharValidation } from './CharValidation';
|
|
4
3
|
export { FieldConnector } from './FieldConnector';
|
|
5
4
|
export type { FieldConnectorChildProps } from './FieldConnector';
|
|
6
5
|
export { PredefinedValuesError } from './PredefinedValuesError';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-shared",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.8",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"registry": "https://npm.pkg.github.com/"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "1d7d630fe6f9576ee4cf35feed8badc8440acbf1"
|
|
55
55
|
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "CharValidation", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return CharValidation;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
13
|
-
if (typeof WeakMap !== "function") return null;
|
|
14
|
-
var cacheBabelInterop = new WeakMap();
|
|
15
|
-
var cacheNodeInterop = new WeakMap();
|
|
16
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
17
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
18
|
-
})(nodeInterop);
|
|
19
|
-
}
|
|
20
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
21
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
25
|
-
return {
|
|
26
|
-
default: obj
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
30
|
-
if (cache && cache.has(obj)) {
|
|
31
|
-
return cache.get(obj);
|
|
32
|
-
}
|
|
33
|
-
var newObj = {
|
|
34
|
-
__proto__: null
|
|
35
|
-
};
|
|
36
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
37
|
-
for(var key in obj){
|
|
38
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
39
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
40
|
-
if (desc && (desc.get || desc.set)) {
|
|
41
|
-
Object.defineProperty(newObj, key, desc);
|
|
42
|
-
} else {
|
|
43
|
-
newObj[key] = obj[key];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
newObj.default = obj;
|
|
48
|
-
if (cache) {
|
|
49
|
-
cache.set(obj, newObj);
|
|
50
|
-
}
|
|
51
|
-
return newObj;
|
|
52
|
-
}
|
|
53
|
-
function CharValidation(props) {
|
|
54
|
-
const { constraints } = props;
|
|
55
|
-
if (constraints.type === 'max') {
|
|
56
|
-
return _react.createElement("span", null, "Maximum ", constraints.max, " characters");
|
|
57
|
-
} else if (constraints.type === 'min') {
|
|
58
|
-
return _react.createElement("span", null, "Requires at least ", constraints.min, " characters");
|
|
59
|
-
} else {
|
|
60
|
-
return _react.createElement("span", null, "Requires between ", constraints.min, " and ", constraints.max, " characters");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export function CharValidation(props) {
|
|
3
|
-
const { constraints } = props;
|
|
4
|
-
if (constraints.type === 'max') {
|
|
5
|
-
return React.createElement("span", null, "Maximum ", constraints.max, " characters");
|
|
6
|
-
} else if (constraints.type === 'min') {
|
|
7
|
-
return React.createElement("span", null, "Requires at least ", constraints.min, " characters");
|
|
8
|
-
} else {
|
|
9
|
-
return React.createElement("span", null, "Requires between ", constraints.min, " and ", constraints.max, " characters");
|
|
10
|
-
}
|
|
11
|
-
}
|