@contentful/field-editor-shared 1.4.5 → 1.4.7
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 -1
- package/dist/cjs/CharValidation.js +5 -2
- package/dist/cjs/utils/constraints.js +2 -1
- package/dist/esm/CharCounter.js +3 -1
- package/dist/esm/CharValidation.js +5 -2
- package/dist/esm/utils/constraints.js +2 -1
- package/dist/types/CharCounter.d.ts +2 -0
- package/dist/types/CharValidation.d.ts +2 -1
- package/dist/types/types.d.ts +1 -0
- package/package.json +3 -3
package/dist/cjs/CharCounter.js
CHANGED
|
@@ -63,6 +63,7 @@ const styles = {
|
|
|
63
63
|
})
|
|
64
64
|
};
|
|
65
65
|
function CharCounter(props) {
|
|
66
|
+
const { constraints } = props;
|
|
66
67
|
let count = 0;
|
|
67
68
|
if (props.value) {
|
|
68
69
|
count = props.value.length;
|
|
@@ -70,8 +71,9 @@ function CharCounter(props) {
|
|
|
70
71
|
const valid = count === 0 || props.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
|
}
|
|
@@ -51,9 +51,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
51
51
|
return newObj;
|
|
52
52
|
}
|
|
53
53
|
function CharValidation(props) {
|
|
54
|
-
const { constraints } = props;
|
|
54
|
+
const { constraints, enabled } = props;
|
|
55
|
+
if (!enabled) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
55
58
|
if (constraints.type === 'max') {
|
|
56
|
-
return _react.createElement("span", null,
|
|
59
|
+
return _react.createElement("span", null, constraints.isDefaultConstraint ? '' : `Max. ${constraints.max} characters`);
|
|
57
60
|
} else if (constraints.type === 'min') {
|
|
58
61
|
return _react.createElement("span", null, "Requires at least ", constraints.min, " characters");
|
|
59
62
|
} else {
|
package/dist/esm/CharCounter.js
CHANGED
|
@@ -7,6 +7,7 @@ const styles = {
|
|
|
7
7
|
})
|
|
8
8
|
};
|
|
9
9
|
export function CharCounter(props) {
|
|
10
|
+
const { constraints } = props;
|
|
10
11
|
let count = 0;
|
|
11
12
|
if (props.value) {
|
|
12
13
|
count = props.value.length;
|
|
@@ -14,8 +15,9 @@ export function CharCounter(props) {
|
|
|
14
15
|
const valid = count === 0 || props.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
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export function CharValidation(props) {
|
|
3
|
-
const { constraints } = props;
|
|
3
|
+
const { constraints, enabled } = props;
|
|
4
|
+
if (!enabled) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
4
7
|
if (constraints.type === 'max') {
|
|
5
|
-
return React.createElement("span", null,
|
|
8
|
+
return React.createElement("span", null, constraints.isDefaultConstraint ? '' : `Max. ${constraints.max} characters`);
|
|
6
9
|
} else if (constraints.type === 'min') {
|
|
7
10
|
return React.createElement("span", null, "Requires at least ", constraints.min, " characters");
|
|
8
11
|
} else {
|
|
@@ -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 {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ValidationType } from './types';
|
|
3
3
|
interface CharValidationProps {
|
|
4
4
|
constraints: ValidationType;
|
|
5
|
+
enabled: boolean;
|
|
5
6
|
}
|
|
6
|
-
export declare function CharValidation(props: CharValidationProps): JSX.Element;
|
|
7
|
+
export declare function CharValidation(props: CharValidationProps): JSX.Element | null;
|
|
7
8
|
export {};
|
package/dist/types/types.d.ts
CHANGED
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.7",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@contentful/app-sdk": "^4.17.1",
|
|
39
|
-
"@contentful/field-editor-test-utils": "^1.4.
|
|
39
|
+
"@contentful/field-editor-test-utils": "^1.4.7"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@contentful/f36-note": "^4.2.8",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"registry": "https://npm.pkg.github.com/"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "129510a558258ae7eb0c53e7845868048a465ca7"
|
|
55
55
|
}
|