@contentful/field-editor-multiple-line 1.3.8 → 1.3.9

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.
@@ -74,18 +74,15 @@ function MultipleLineEditor(props) {
74
74
  onChange: (e)=>{
75
75
  setValue(e.target.value);
76
76
  }
77
- }), withCharValidation && _react.createElement("div", {
78
- className: _styles.validationRow
79
- }, _react.createElement(_fieldeditorshared.CharCounter, {
77
+ }), _react.createElement("div", {
78
+ className: _styles.validationRow(withCharValidation)
79
+ }, _react.createElement(_fieldeditorshared.CharValidation, {
80
+ constraints: constraints,
81
+ enabled: withCharValidation
82
+ }), _react.createElement(_fieldeditorshared.CharCounter, {
80
83
  value: value || '',
81
- checkConstraint: checkConstraint
82
- }), _react.createElement(_fieldeditorshared.CharValidation, {
84
+ checkConstraint: checkConstraint,
83
85
  constraints: constraints
84
- })), !withCharValidation && _react.createElement("div", {
85
- className: _styles.validationRow
86
- }, _react.createElement(_fieldeditorshared.CharCounter, {
87
- value: value || '',
88
- checkConstraint: ()=>true
89
86
  })));
90
87
  });
91
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)=>{
@@ -23,13 +23,13 @@ function _interop_require_default(obj) {
23
23
  default: obj
24
24
  };
25
25
  }
26
- const validationRow = (0, _emotion.css)({
27
- display: 'flex',
28
- justifyContent: 'space-between',
29
- fontSize: _f36tokens.default.fontSizeM,
30
- marginTop: _f36tokens.default.spacingXs,
31
- color: _f36tokens.default.gray700
32
- });
26
+ const validationRow = (withValidation)=>(0, _emotion.css)({
27
+ display: 'flex',
28
+ justifyContent: withValidation ? 'space-between' : 'flex-end',
29
+ fontSize: _f36tokens.default.fontSizeM,
30
+ marginTop: _f36tokens.default.spacingXs,
31
+ color: _f36tokens.default.gray500
32
+ });
33
33
  const rightToLeft = (0, _emotion.css)({
34
34
  direction: 'rtl'
35
35
  });
@@ -23,18 +23,15 @@ export function MultipleLineEditor(props) {
23
23
  onChange: (e)=>{
24
24
  setValue(e.target.value);
25
25
  }
26
- }), withCharValidation && React.createElement("div", {
27
- className: styles.validationRow
28
- }, React.createElement(CharCounter, {
26
+ }), React.createElement("div", {
27
+ className: styles.validationRow(withCharValidation)
28
+ }, React.createElement(CharValidation, {
29
+ constraints: constraints,
30
+ enabled: withCharValidation
31
+ }), React.createElement(CharCounter, {
29
32
  value: value || '',
30
- checkConstraint: checkConstraint
31
- }), React.createElement(CharValidation, {
33
+ checkConstraint: checkConstraint,
32
34
  constraints: constraints
33
- })), !withCharValidation && React.createElement("div", {
34
- className: styles.validationRow
35
- }, React.createElement(CharCounter, {
36
- value: value || '',
37
- checkConstraint: ()=>true
38
35
  })));
39
36
  });
40
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)=>{
@@ -1,12 +1,12 @@
1
1
  import tokens from '@contentful/f36-tokens';
2
2
  import { css } from 'emotion';
3
- export const validationRow = css({
4
- display: 'flex',
5
- justifyContent: 'space-between',
6
- fontSize: tokens.fontSizeM,
7
- marginTop: tokens.spacingXs,
8
- color: tokens.gray700
9
- });
3
+ export const validationRow = (withValidation)=>css({
4
+ display: 'flex',
5
+ justifyContent: withValidation ? 'space-between' : 'flex-end',
6
+ fontSize: tokens.fontSizeM,
7
+ marginTop: tokens.spacingXs,
8
+ color: tokens.gray500
9
+ });
10
10
  export const rightToLeft = css({
11
11
  direction: 'rtl'
12
12
  });
@@ -1,2 +1,2 @@
1
- export declare const validationRow: string;
1
+ export declare const validationRow: (withValidation: boolean) => 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.8",
3
+ "version": "1.3.9",
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.6",
40
+ "@contentful/field-editor-shared": "^1.4.7",
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": "894934e9a2888aeb0a894cfebea3e034ba830f2a"
53
+ "gitHead": "129510a558258ae7eb0c53e7845868048a465ca7"
54
54
  }