@contentful/field-editor-multiple-line 1.3.8 → 1.3.10
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/MultipleLineEditor.js +5 -12
- package/dist/cjs/MultipleLineEditor.test.js +2 -0
- package/dist/cjs/styles.js +7 -7
- package/dist/esm/MultipleLineEditor.js +6 -13
- package/dist/esm/MultipleLineEditor.test.js +2 -0
- package/dist/esm/styles.js +4 -4
- package/dist/types/MultipleLineEditor.d.ts +0 -5
- package/dist/types/styles.d.ts +1 -1
- package/package.json +3 -3
|
@@ -54,7 +54,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
54
54
|
return newObj;
|
|
55
55
|
}
|
|
56
56
|
function MultipleLineEditor(props) {
|
|
57
|
-
const { field, locales, isInitiallyDisabled
|
|
57
|
+
const { field, locales, isInitiallyDisabled } = props;
|
|
58
58
|
const constraints = _fieldeditorshared.ConstraintsUtils.fromFieldValidations(field.validations, field.type);
|
|
59
59
|
const checkConstraint = _fieldeditorshared.ConstraintsUtils.makeChecker(constraints);
|
|
60
60
|
const direction = locales.direction[field.locale] || 'ltr';
|
|
@@ -74,22 +74,15 @@ function MultipleLineEditor(props) {
|
|
|
74
74
|
onChange: (e)=>{
|
|
75
75
|
setValue(e.target.value);
|
|
76
76
|
}
|
|
77
|
-
}),
|
|
78
|
-
className: _styles.
|
|
77
|
+
}), _react.createElement("div", {
|
|
78
|
+
className: _styles.counterRow
|
|
79
79
|
}, _react.createElement(_fieldeditorshared.CharCounter, {
|
|
80
80
|
value: value || '',
|
|
81
|
-
checkConstraint: checkConstraint
|
|
82
|
-
}), _react.createElement(_fieldeditorshared.CharValidation, {
|
|
81
|
+
checkConstraint: checkConstraint,
|
|
83
82
|
constraints: constraints
|
|
84
|
-
})), !withCharValidation && _react.createElement("div", {
|
|
85
|
-
className: _styles.validationRow
|
|
86
|
-
}, _react.createElement(_fieldeditorshared.CharCounter, {
|
|
87
|
-
value: value || '',
|
|
88
|
-
checkConstraint: ()=>true
|
|
89
83
|
})));
|
|
90
84
|
});
|
|
91
85
|
}
|
|
92
86
|
MultipleLineEditor.defaultProps = {
|
|
93
|
-
isInitiallyDisabled: true
|
|
94
|
-
withCharValidation: true
|
|
87
|
+
isInitiallyDisabled: true
|
|
95
88
|
};
|
|
@@ -66,6 +66,7 @@ describe('MultipleLineEditor', ()=>{
|
|
|
66
66
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
67
67
|
return {
|
|
68
68
|
...field,
|
|
69
|
+
type: 'Text',
|
|
69
70
|
id: 'field-id',
|
|
70
71
|
getValue: ()=>{
|
|
71
72
|
return initialValue;
|
|
@@ -78,6 +79,7 @@ describe('MultipleLineEditor', ()=>{
|
|
|
78
79
|
isInitiallyDisabled: false
|
|
79
80
|
}));
|
|
80
81
|
expect(getByTestId('cf-ui-textarea')).toHaveValue(initialValue);
|
|
82
|
+
expect(getByTestId('cf-ui-char-counter')).toHaveTextContent(`${initialValue.length} / 50000`);
|
|
81
83
|
});
|
|
82
84
|
it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
83
85
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
package/dist/cjs/styles.js
CHANGED
|
@@ -9,11 +9,11 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
counterRow: function() {
|
|
13
|
+
return counterRow;
|
|
14
|
+
},
|
|
12
15
|
rightToLeft: function() {
|
|
13
16
|
return rightToLeft;
|
|
14
|
-
},
|
|
15
|
-
validationRow: function() {
|
|
16
|
-
return validationRow;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
@@ -23,12 +23,12 @@ function _interop_require_default(obj) {
|
|
|
23
23
|
default: obj
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
justifyContent: 'space-between',
|
|
26
|
+
const counterRow = (0, _emotion.css)({
|
|
27
|
+
float: 'right',
|
|
29
28
|
fontSize: _f36tokens.default.fontSizeM,
|
|
30
29
|
marginTop: _f36tokens.default.spacingXs,
|
|
31
|
-
|
|
30
|
+
marginLeft: _f36tokens.default.spacingS,
|
|
31
|
+
color: _f36tokens.default.gray500
|
|
32
32
|
});
|
|
33
33
|
const rightToLeft = (0, _emotion.css)({
|
|
34
34
|
direction: 'rtl'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Textarea } from '@contentful/f36-components';
|
|
3
|
-
import { FieldConnector, CharCounter,
|
|
3
|
+
import { FieldConnector, CharCounter, ConstraintsUtils } from '@contentful/field-editor-shared';
|
|
4
4
|
import * as styles from './styles';
|
|
5
5
|
export function MultipleLineEditor(props) {
|
|
6
|
-
const { field, locales, isInitiallyDisabled
|
|
6
|
+
const { field, locales, isInitiallyDisabled } = props;
|
|
7
7
|
const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);
|
|
8
8
|
const checkConstraint = ConstraintsUtils.makeChecker(constraints);
|
|
9
9
|
const direction = locales.direction[field.locale] || 'ltr';
|
|
@@ -23,22 +23,15 @@ export function MultipleLineEditor(props) {
|
|
|
23
23
|
onChange: (e)=>{
|
|
24
24
|
setValue(e.target.value);
|
|
25
25
|
}
|
|
26
|
-
}),
|
|
27
|
-
className: styles.
|
|
26
|
+
}), React.createElement("div", {
|
|
27
|
+
className: styles.counterRow
|
|
28
28
|
}, React.createElement(CharCounter, {
|
|
29
29
|
value: value || '',
|
|
30
|
-
checkConstraint: checkConstraint
|
|
31
|
-
}), React.createElement(CharValidation, {
|
|
30
|
+
checkConstraint: checkConstraint,
|
|
32
31
|
constraints: constraints
|
|
33
|
-
})), !withCharValidation && React.createElement("div", {
|
|
34
|
-
className: styles.validationRow
|
|
35
|
-
}, React.createElement(CharCounter, {
|
|
36
|
-
value: value || '',
|
|
37
|
-
checkConstraint: ()=>true
|
|
38
32
|
})));
|
|
39
33
|
});
|
|
40
34
|
}
|
|
41
35
|
MultipleLineEditor.defaultProps = {
|
|
42
|
-
isInitiallyDisabled: true
|
|
43
|
-
withCharValidation: true
|
|
36
|
+
isInitiallyDisabled: true
|
|
44
37
|
};
|
|
@@ -21,6 +21,7 @@ describe('MultipleLineEditor', ()=>{
|
|
|
21
21
|
const [field] = createFakeFieldAPI((field)=>{
|
|
22
22
|
return {
|
|
23
23
|
...field,
|
|
24
|
+
type: 'Text',
|
|
24
25
|
id: 'field-id',
|
|
25
26
|
getValue: ()=>{
|
|
26
27
|
return initialValue;
|
|
@@ -33,6 +34,7 @@ describe('MultipleLineEditor', ()=>{
|
|
|
33
34
|
isInitiallyDisabled: false
|
|
34
35
|
}));
|
|
35
36
|
expect(getByTestId('cf-ui-textarea')).toHaveValue(initialValue);
|
|
37
|
+
expect(getByTestId('cf-ui-char-counter')).toHaveTextContent(`${initialValue.length} / 50000`);
|
|
36
38
|
});
|
|
37
39
|
it('calls field.setValue when user types and calls field.removeValue when user clears the input', async ()=>{
|
|
38
40
|
const [field] = createFakeFieldAPI((field)=>{
|
package/dist/esm/styles.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import tokens from '@contentful/f36-tokens';
|
|
2
2
|
import { css } from 'emotion';
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
justifyContent: 'space-between',
|
|
3
|
+
export const counterRow = css({
|
|
4
|
+
float: 'right',
|
|
6
5
|
fontSize: tokens.fontSizeM,
|
|
7
6
|
marginTop: tokens.spacingXs,
|
|
8
|
-
|
|
7
|
+
marginLeft: tokens.spacingS,
|
|
8
|
+
color: tokens.gray500
|
|
9
9
|
});
|
|
10
10
|
export const rightToLeft = css({
|
|
11
11
|
direction: 'rtl'
|
|
@@ -5,10 +5,6 @@ export interface MultipleLineEditorProps {
|
|
|
5
5
|
* is the field disabled initially
|
|
6
6
|
*/
|
|
7
7
|
isInitiallyDisabled: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* whether char validation should be shown or not
|
|
10
|
-
*/
|
|
11
|
-
withCharValidation: boolean;
|
|
12
8
|
/**
|
|
13
9
|
* sdk.field
|
|
14
10
|
*/
|
|
@@ -22,6 +18,5 @@ export declare function MultipleLineEditor(props: MultipleLineEditorProps): JSX.
|
|
|
22
18
|
export declare namespace MultipleLineEditor {
|
|
23
19
|
var defaultProps: {
|
|
24
20
|
isInitiallyDisabled: boolean;
|
|
25
|
-
withCharValidation: boolean;
|
|
26
21
|
};
|
|
27
22
|
}
|
package/dist/types/styles.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const counterRow: string;
|
|
2
2
|
export declare const rightToLeft: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-multiple-line",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.10",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@contentful/f36-components": "^4.0.27",
|
|
39
39
|
"@contentful/f36-tokens": "^4.0.0",
|
|
40
|
-
"@contentful/field-editor-shared": "^1.4.
|
|
40
|
+
"@contentful/field-editor-shared": "^1.4.8",
|
|
41
41
|
"emotion": "^10.0.17",
|
|
42
42
|
"lodash": "^4.17.15"
|
|
43
43
|
},
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"registry": "https://npm.pkg.github.com/"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "1d7d630fe6f9576ee4cf35feed8badc8440acbf1"
|
|
54
54
|
}
|