@contentful/field-editor-multiple-line 0.13.0 → 0.14.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,41 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.14.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.14.1...@contentful/field-editor-multiple-line@0.14.2) (2021-09-16)
7
+
8
+ **Note:** Version bump only for package @contentful/field-editor-multiple-line
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.14.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.14.0...@contentful/field-editor-multiple-line@0.14.1) (2021-08-19)
15
+
16
+ **Note:** Version bump only for package @contentful/field-editor-multiple-line
17
+
18
+
19
+
20
+
21
+
22
+ # [0.14.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.13.1...@contentful/field-editor-multiple-line@0.14.0) (2021-08-05)
23
+
24
+
25
+ ### Features
26
+
27
+ * 🎸 add char counter ([#795](https://github.com/contentful/field-editors/issues/795)) ([3237f6c](https://github.com/contentful/field-editors/commit/3237f6ce51cf5d29880e641858a61ffcd9c61fa4)), closes [#491](https://github.com/contentful/field-editors/issues/491)
28
+
29
+
30
+
31
+
32
+
33
+ ## [0.13.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.13.0...@contentful/field-editor-multiple-line@0.13.1) (2021-07-29)
34
+
35
+ **Note:** Version bump only for package @contentful/field-editor-multiple-line
36
+
37
+
38
+
39
+
40
+
6
41
  # [0.13.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@0.12.6...@contentful/field-editor-multiple-line@0.13.0) (2021-07-23)
7
42
 
8
43
 
@@ -5,6 +5,10 @@ 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;
8
12
  /**
9
13
  * sdk.field
10
14
  */
@@ -18,5 +22,6 @@ export declare function MultipleLineEditor(props: MultipleLineEditorProps): JSX.
18
22
  export declare namespace MultipleLineEditor {
19
23
  var defaultProps: {
20
24
  isInitiallyDisabled: boolean;
25
+ withCharValidation: boolean;
21
26
  };
22
27
  }
@@ -2,22 +2,36 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
5
7
  var React = require('react');
6
8
  var forma36ReactComponents = require('@contentful/forma-36-react-components');
7
9
  var fieldEditorShared = require('@contentful/field-editor-shared');
8
10
  var emotion = require('emotion');
11
+ var tokens = _interopDefault(require('@contentful/forma-36-tokens'));
9
12
 
13
+ var validationRow = /*#__PURE__*/emotion.css({
14
+ display: 'flex',
15
+ justifyContent: 'space-between',
16
+ fontSize: tokens.fontSizeM,
17
+ marginTop: tokens.spacingXs,
18
+ color: tokens.gray700
19
+ });
10
20
  var rightToLeft = /*#__PURE__*/emotion.css({
11
21
  direction: 'rtl'
12
22
  });
13
23
 
14
24
  function MultipleLineEditor(props) {
15
25
  var field = props.field,
16
- locales = props.locales;
26
+ locales = props.locales,
27
+ isInitiallyDisabled = props.isInitiallyDisabled,
28
+ withCharValidation = props.withCharValidation;
29
+ var constraints = fieldEditorShared.ConstraintsUtils.fromFieldValidations(field.validations, field.type);
30
+ var checkConstraint = fieldEditorShared.ConstraintsUtils.makeChecker(constraints);
17
31
  var direction = locales.direction[field.locale] || 'ltr';
18
32
  return React.createElement(fieldEditorShared.FieldConnector, {
19
33
  field: field,
20
- isInitiallyDisabled: props.isInitiallyDisabled
34
+ isInitiallyDisabled: isInitiallyDisabled
21
35
  }, function (_ref) {
22
36
  var errors = _ref.errors,
23
37
  disabled = _ref.disabled,
@@ -35,11 +49,26 @@ function MultipleLineEditor(props) {
35
49
  onChange: function onChange(e) {
36
50
  setValue(e.target.value);
37
51
  }
38
- }));
52
+ }), withCharValidation && React.createElement("div", {
53
+ className: validationRow
54
+ }, React.createElement(fieldEditorShared.CharCounter, {
55
+ value: value || '',
56
+ checkConstraint: checkConstraint
57
+ }), React.createElement(fieldEditorShared.CharValidation, {
58
+ constraints: constraints
59
+ })), !withCharValidation && React.createElement("div", {
60
+ className: validationRow
61
+ }, React.createElement(fieldEditorShared.CharCounter, {
62
+ value: value || '',
63
+ checkConstraint: function checkConstraint() {
64
+ return true;
65
+ }
66
+ })));
39
67
  });
40
68
  }
41
69
  MultipleLineEditor.defaultProps = {
42
- isInitiallyDisabled: true
70
+ isInitiallyDisabled: true,
71
+ withCharValidation: true
43
72
  };
44
73
 
45
74
  exports.MultipleLineEditor = MultipleLineEditor;
@@ -1 +1 @@
1
- {"version":3,"file":"field-editor-multiple-line.cjs.development.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\n\nexport const rightToLeft = css({\n direction: 'rtl'\n});\n","import * as React from 'react';\nimport { Textarea } from '@contentful/forma-36-react-components';\nimport { FieldAPI, LocalesAPI, FieldConnector } from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales } = props;\n\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["rightToLeft","css","direction","MultipleLineEditor","props","field","locales","locale","React","FieldConnector","isInitiallyDisabled","errors","disabled","value","setValue","Textarea","className","styles","rows","required","error","length","onChange","e","target","defaultProps"],"mappings":";;;;;;;;;AAEO,IAAMA,WAAW,gBAAGC,WAAG,CAAC;AAC7BC,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SCoBSC,mBAAmBC;MACzBC,QAAmBD,MAAnBC;MAAOC,UAAYF,MAAZE;AAEf,MAAMJ,SAAS,GAAGI,OAAO,CAACJ,SAAR,CAAkBG,KAAK,CAACE,MAAxB,KAAmC,KAArD;AAEA,SACEC,mBAAA,CAACC,gCAAD;AAAwBJ,IAAAA,KAAK,EAAEA;AAAOK,IAAAA,mBAAmB,EAAEN,KAAK,CAACM;GAAjE,EACG;QAAGC,cAAAA;QAAQC,gBAAAA;QAAUC,aAAAA;QAAOC,gBAAAA;AAC3B,WACEN,mBAAA,MAAA;sBAAkB;KAAlB,EACEA,mBAAA,CAACO,+BAAD;AACEC,MAAAA,SAAS,EAAEd,SAAS,KAAK,KAAd,GAAsBe,WAAtB,GAA2C;AACtDC,MAAAA,IAAI,EAAE;AACNC,MAAAA,QAAQ,EAAEd,KAAK,CAACc;AAChBC,MAAAA,KAAK,EAAET,MAAM,CAACU,MAAP,GAAgB;AACvBT,MAAAA,QAAQ,EAAEA;AACVC,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBS,MAAAA,QAAQ,EAAE,kBAACC,CAAD;AACRT,QAAAA,QAAQ,CAACS,CAAC,CAACC,MAAF,CAASX,KAAV,CAAR;AACD;KATH,CADF,CADF;AAeD,GAjBH,CADF;AAqBD;AAEDV,kBAAkB,CAACsB,YAAnB,GAAkC;AAChCf,EAAAA,mBAAmB,EAAE;AADW,CAAlC;;;;"}
1
+ {"version":3,"file":"field-editor-multiple-line.cjs.development.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/forma-36-tokens';\n\nexport const validationRow = css({\n display: 'flex',\n justifyContent: 'space-between',\n fontSize: tokens.fontSizeM,\n marginTop: tokens.spacingXs,\n color: tokens.gray700\n});\n\nexport const rightToLeft = css({\n direction: 'rtl'\n});\n","import * as React from 'react';\nimport { Textarea } from '@contentful/forma-36-react-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * whether char validation should be shown or not\n */\n withCharValidation: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales, isInitiallyDisabled, withCharValidation } = props;\n\n const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type as 'Text');\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n {withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {!withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","MultipleLineEditor","props","field","locales","isInitiallyDisabled","withCharValidation","constraints","ConstraintsUtils","fromFieldValidations","validations","type","checkConstraint","makeChecker","locale","React","FieldConnector","errors","disabled","value","setValue","Textarea","className","styles","rows","required","error","length","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":";;;;;;;;;;;;AAGO,IAAMA,aAAa,gBAAGC,WAAG,CAAC;AAC/BC,EAAAA,OAAO,EAAE,MADsB;AAE/BC,EAAAA,cAAc,EAAE,eAFe;AAG/BC,EAAAA,QAAQ,EAAEC,MAAM,CAACC,SAHc;AAI/BC,EAAAA,SAAS,EAAEF,MAAM,CAACG,SAJa;AAK/BC,EAAAA,KAAK,EAAEJ,MAAM,CAACK;AALiB,CAAD,CAAzB;AAQA,IAAMC,WAAW,gBAAGV,WAAG,CAAC;AAC7BW,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SCuBSC,mBAAmBC;AACjC,MAAQC,KAAR,GAAoED,KAApE,CAAQC,KAAR;AAAA,MAAeC,OAAf,GAAoEF,KAApE,CAAeE,OAAf;AAAA,MAAwBC,mBAAxB,GAAoEH,KAApE,CAAwBG,mBAAxB;AAAA,MAA6CC,kBAA7C,GAAoEJ,KAApE,CAA6CI,kBAA7C;AAEA,MAAMC,WAAW,GAAGC,kCAAgB,CAACC,oBAAjB,CAAsCN,KAAK,CAACO,WAA5C,EAAyDP,KAAK,CAACQ,IAA/D,CAApB;AACA,MAAMC,eAAe,GAAGJ,kCAAgB,CAACK,WAAjB,CAA6BN,WAA7B,CAAxB;AACA,MAAMP,SAAS,GAAGI,OAAO,CAACJ,SAAR,CAAkBG,KAAK,CAACW,MAAxB,KAAmC,KAArD;AAEA,SACEC,mBAAA,CAACC,gCAAD;AAAwBb,IAAAA,KAAK,EAAEA;AAAOE,IAAAA,mBAAmB,EAAEA;GAA3D,EACG;QAAGY,cAAAA;QAAQC,gBAAAA;QAAUC,aAAAA;QAAOC,gBAAAA;AAC3B,WACEL,mBAAA,MAAA;sBAAkB;KAAlB,EACEA,mBAAA,CAACM,+BAAD;AACEC,MAAAA,SAAS,EAAEtB,SAAS,KAAK,KAAd,GAAsBuB,WAAtB,GAA2C;AACtDC,MAAAA,IAAI,EAAE;AACNC,MAAAA,QAAQ,EAAEtB,KAAK,CAACsB;AAChBC,MAAAA,KAAK,EAAET,MAAM,CAACU,MAAP,GAAgB;AACvBT,MAAAA,QAAQ,EAAEA;AACVC,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBS,MAAAA,QAAQ,EAAE,kBAACC,CAAD;AACRT,QAAAA,QAAQ,CAACS,CAAC,CAACC,MAAF,CAASX,KAAV,CAAR;AACD;KATH,CADF,EAYGb,kBAAkB,IACjBS,mBAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,mBAAA,CAACgB,6BAAD;AAAaZ,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,mBAAA,CAACiB,gCAAD;AAAgBzB,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAbJ,EAkBG,CAACD,kBAAD,IACCS,mBAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,mBAAA,CAACgB,6BAAD;AAAaZ,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAnBJ,CADF;AA0BD,GA5BH,CADF;AAgCD;AAEDX,kBAAkB,CAACgC,YAAnB,GAAkC;AAChC5B,EAAAA,mBAAmB,EAAE,IADW;AAEhCC,EAAAA,kBAAkB,EAAE;AAFY,CAAlC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@contentful/forma-36-react-components"),t=require("@contentful/field-editor-shared"),i=require("emotion").css({direction:"rtl"});function l(l){var a=l.field,n=l.locales.direction[a.locale]||"ltr";return e.createElement(t.FieldConnector,{field:a,isInitiallyDisabled:l.isInitiallyDisabled},(function(t){var l=t.setValue;return e.createElement("div",{"data-test-id":"multiple-line-editor"},e.createElement(r.Textarea,{className:"rtl"===n?i:"",rows:3,required:a.required,error:t.errors.length>0,disabled:t.disabled,value:t.value||"",onChange:function(e){l(e.target.value)}}))}))}l.defaultProps={isInitiallyDisabled:!0},exports.MultipleLineEditor=l;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),r=require("@contentful/forma-36-react-components"),a=require("@contentful/field-editor-shared"),i=require("emotion"),n=(e=require("@contentful/forma-36-tokens"))&&"object"==typeof e&&"default"in e?e.default:e,l=i.css({display:"flex",justifyContent:"space-between",fontSize:n.fontSizeM,marginTop:n.spacingXs,color:n.gray700}),o=i.css({direction:"rtl"});function s(e){var i=e.field,n=e.locales,s=e.isInitiallyDisabled,c=e.withCharValidation,d=a.ConstraintsUtils.fromFieldValidations(i.validations,i.type),u=a.ConstraintsUtils.makeChecker(d),f=n.direction[i.locale]||"ltr";return t.createElement(a.FieldConnector,{field:i,isInitiallyDisabled:s},(function(e){var n=e.value,s=e.setValue;return t.createElement("div",{"data-test-id":"multiple-line-editor"},t.createElement(r.Textarea,{className:"rtl"===f?o:"",rows:3,required:i.required,error:e.errors.length>0,disabled:e.disabled,value:n||"",onChange:function(e){s(e.target.value)}}),c&&t.createElement("div",{className:l},t.createElement(a.CharCounter,{value:n||"",checkConstraint:u}),t.createElement(a.CharValidation,{constraints:d})),!c&&t.createElement("div",{className:l},t.createElement(a.CharCounter,{value:n||"",checkConstraint:function(){return!0}})))}))}s.defaultProps={isInitiallyDisabled:!0,withCharValidation:!0},exports.MultipleLineEditor=s;
2
2
  //# sourceMappingURL=field-editor-multiple-line.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field-editor-multiple-line.cjs.production.min.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\n\nexport const rightToLeft = css({\n direction: 'rtl'\n});\n","import * as React from 'react';\nimport { Textarea } from '@contentful/forma-36-react-components';\nimport { FieldAPI, LocalesAPI, FieldConnector } from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales } = props;\n\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["rightToLeft","direction","MultipleLineEditor","props","field","locales","locale","React","FieldConnector","isInitiallyDisabled","setValue","Textarea","className","styles","rows","required","error","errors","length","disabled","value","onChange","e","target","defaultProps"],"mappings":"2LAEaA,yBAAkB,CAC7BC,UAAW,iBCmBGC,EAAmBC,OACzBC,EAAmBD,EAAnBC,MAEFH,EAFqBE,EAAZE,QAEWJ,UAAUG,EAAME,SAAW,aAGnDC,gBAACC,kBAAuBJ,MAAOA,EAAOK,oBAAqBN,EAAMM,sBAC9D,gBAA4BC,IAAAA,gBAEzBH,sCAAkB,wBAChBA,gBAACI,YACCC,UAAyB,QAAdX,EAAsBY,EAAqB,GACtDC,KAAM,EACNC,SAAUX,EAAMW,SAChBC,QAPJC,OAOkBC,OAAS,EACvBC,WARIA,SASJC,QATcA,OASE,GAChBC,SAAU,SAACC,GACTZ,EAASY,EAAEC,OAAOH,cAUlClB,EAAmBsB,aAAe,CAChCf,qBAAqB"}
1
+ {"version":3,"file":"field-editor-multiple-line.cjs.production.min.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/forma-36-tokens';\n\nexport const validationRow = css({\n display: 'flex',\n justifyContent: 'space-between',\n fontSize: tokens.fontSizeM,\n marginTop: tokens.spacingXs,\n color: tokens.gray700\n});\n\nexport const rightToLeft = css({\n direction: 'rtl'\n});\n","import * as React from 'react';\nimport { Textarea } from '@contentful/forma-36-react-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * whether char validation should be shown or not\n */\n withCharValidation: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales, isInitiallyDisabled, withCharValidation } = props;\n\n const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type as 'Text');\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n {withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {!withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","MultipleLineEditor","props","field","locales","isInitiallyDisabled","withCharValidation","constraints","ConstraintsUtils","fromFieldValidations","validations","type","checkConstraint","makeChecker","locale","React","FieldConnector","value","setValue","Textarea","className","styles","rows","required","error","errors","length","disabled","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":"8SAGaA,EAAgBC,MAAI,CAC/BC,QAAS,OACTC,eAAgB,gBAChBC,SAAUC,EAAOC,UACjBC,UAAWF,EAAOG,UAClBC,MAAOJ,EAAOK,UAGHC,EAAcV,MAAI,CAC7BW,UAAW,iBCsBGC,EAAmBC,OACzBC,EAA4DD,EAA5DC,MAAOC,EAAqDF,EAArDE,QAASC,EAA4CH,EAA5CG,oBAAqBC,EAAuBJ,EAAvBI,mBAEvCC,EAAcC,mBAAiBC,qBAAqBN,EAAMO,YAAaP,EAAMQ,MAC7EC,EAAkBJ,mBAAiBK,YAAYN,GAC/CP,EAAYI,EAAQJ,UAAUG,EAAMW,SAAW,aAGnDC,gBAACC,kBAAuBb,MAAOA,EAAOE,oBAAqBA,IACxD,gBAAqBY,IAAAA,MAAOC,IAAAA,gBAEzBH,sCAAkB,wBAChBA,gBAACI,YACCC,UAAyB,QAAdpB,EAAsBqB,EAAqB,GACtDC,KAAM,EACNC,SAAUpB,EAAMoB,SAChBC,QAPJC,OAOkBC,OAAS,EACvBC,WARIA,SASJV,MAAOA,GAAS,GAChBW,SAAU,SAACC,GACTX,EAASW,EAAEC,OAAOb,UAGrBX,GACCS,uBAAKK,UAAWC,GACdN,gBAACgB,eAAYd,MAAOA,GAAS,GAAIL,gBAAiBA,IAClDG,gBAACiB,kBAAezB,YAAaA,MAG/BD,GACAS,uBAAKK,UAAWC,GACdN,gBAACgB,eAAYd,MAAOA,GAAS,GAAIL,gBAAiB,kBAAM,UAUxEX,EAAmBgC,aAAe,CAChC5B,qBAAqB,EACrBC,oBAAoB"}
@@ -1,19 +1,31 @@
1
1
  import { createElement } from 'react';
2
2
  import { Textarea } from '@contentful/forma-36-react-components';
3
- import { FieldConnector } from '@contentful/field-editor-shared';
3
+ import { ConstraintsUtils, FieldConnector, CharCounter, CharValidation } from '@contentful/field-editor-shared';
4
4
  import { css } from 'emotion';
5
+ import tokens from '@contentful/forma-36-tokens';
5
6
 
7
+ var validationRow = /*#__PURE__*/css({
8
+ display: 'flex',
9
+ justifyContent: 'space-between',
10
+ fontSize: tokens.fontSizeM,
11
+ marginTop: tokens.spacingXs,
12
+ color: tokens.gray700
13
+ });
6
14
  var rightToLeft = /*#__PURE__*/css({
7
15
  direction: 'rtl'
8
16
  });
9
17
 
10
18
  function MultipleLineEditor(props) {
11
19
  var field = props.field,
12
- locales = props.locales;
20
+ locales = props.locales,
21
+ isInitiallyDisabled = props.isInitiallyDisabled,
22
+ withCharValidation = props.withCharValidation;
23
+ var constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);
24
+ var checkConstraint = ConstraintsUtils.makeChecker(constraints);
13
25
  var direction = locales.direction[field.locale] || 'ltr';
14
26
  return createElement(FieldConnector, {
15
27
  field: field,
16
- isInitiallyDisabled: props.isInitiallyDisabled
28
+ isInitiallyDisabled: isInitiallyDisabled
17
29
  }, function (_ref) {
18
30
  var errors = _ref.errors,
19
31
  disabled = _ref.disabled,
@@ -31,11 +43,26 @@ function MultipleLineEditor(props) {
31
43
  onChange: function onChange(e) {
32
44
  setValue(e.target.value);
33
45
  }
34
- }));
46
+ }), withCharValidation && createElement("div", {
47
+ className: validationRow
48
+ }, createElement(CharCounter, {
49
+ value: value || '',
50
+ checkConstraint: checkConstraint
51
+ }), createElement(CharValidation, {
52
+ constraints: constraints
53
+ })), !withCharValidation && createElement("div", {
54
+ className: validationRow
55
+ }, createElement(CharCounter, {
56
+ value: value || '',
57
+ checkConstraint: function checkConstraint() {
58
+ return true;
59
+ }
60
+ })));
35
61
  });
36
62
  }
37
63
  MultipleLineEditor.defaultProps = {
38
- isInitiallyDisabled: true
64
+ isInitiallyDisabled: true,
65
+ withCharValidation: true
39
66
  };
40
67
 
41
68
  export { MultipleLineEditor };
@@ -1 +1 @@
1
- {"version":3,"file":"field-editor-multiple-line.esm.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\n\nexport const rightToLeft = css({\n direction: 'rtl'\n});\n","import * as React from 'react';\nimport { Textarea } from '@contentful/forma-36-react-components';\nimport { FieldAPI, LocalesAPI, FieldConnector } from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales } = props;\n\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n};\n"],"names":["rightToLeft","css","direction","MultipleLineEditor","props","field","locales","locale","React","FieldConnector","isInitiallyDisabled","errors","disabled","value","setValue","Textarea","className","styles","rows","required","error","length","onChange","e","target","defaultProps"],"mappings":";;;;;AAEO,IAAMA,WAAW,gBAAGC,GAAG,CAAC;AAC7BC,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SCoBSC,mBAAmBC;MACzBC,QAAmBD,MAAnBC;MAAOC,UAAYF,MAAZE;AAEf,MAAMJ,SAAS,GAAGI,OAAO,CAACJ,SAAR,CAAkBG,KAAK,CAACE,MAAxB,KAAmC,KAArD;AAEA,SACEC,aAAA,CAACC,cAAD;AAAwBJ,IAAAA,KAAK,EAAEA;AAAOK,IAAAA,mBAAmB,EAAEN,KAAK,CAACM;GAAjE,EACG;QAAGC,cAAAA;QAAQC,gBAAAA;QAAUC,aAAAA;QAAOC,gBAAAA;AAC3B,WACEN,aAAA,MAAA;sBAAkB;KAAlB,EACEA,aAAA,CAACO,QAAD;AACEC,MAAAA,SAAS,EAAEd,SAAS,KAAK,KAAd,GAAsBe,WAAtB,GAA2C;AACtDC,MAAAA,IAAI,EAAE;AACNC,MAAAA,QAAQ,EAAEd,KAAK,CAACc;AAChBC,MAAAA,KAAK,EAAET,MAAM,CAACU,MAAP,GAAgB;AACvBT,MAAAA,QAAQ,EAAEA;AACVC,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBS,MAAAA,QAAQ,EAAE,kBAACC,CAAD;AACRT,QAAAA,QAAQ,CAACS,CAAC,CAACC,MAAF,CAASX,KAAV,CAAR;AACD;KATH,CADF,CADF;AAeD,GAjBH,CADF;AAqBD;AAEDV,kBAAkB,CAACsB,YAAnB,GAAkC;AAChCf,EAAAA,mBAAmB,EAAE;AADW,CAAlC;;;;"}
1
+ {"version":3,"file":"field-editor-multiple-line.esm.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/forma-36-tokens';\n\nexport const validationRow = css({\n display: 'flex',\n justifyContent: 'space-between',\n fontSize: tokens.fontSizeM,\n marginTop: tokens.spacingXs,\n color: tokens.gray700\n});\n\nexport const rightToLeft = css({\n direction: 'rtl'\n});\n","import * as React from 'react';\nimport { Textarea } from '@contentful/forma-36-react-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface MultipleLineEditorProps {\n /**\n * is the field disabled initially\n */\n isInitiallyDisabled: boolean;\n\n /**\n * whether char validation should be shown or not\n */\n withCharValidation: boolean;\n\n /**\n * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nexport function MultipleLineEditor(props: MultipleLineEditorProps) {\n const { field, locales, isInitiallyDisabled, withCharValidation } = props;\n\n const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type as 'Text');\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={isInitiallyDisabled}>\n {({ errors, disabled, value, setValue }) => {\n return (\n <div data-test-id=\"multiple-line-editor\">\n <Textarea\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n rows={3}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setValue(e.target.value);\n }}\n />\n {withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {!withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nMultipleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","MultipleLineEditor","props","field","locales","isInitiallyDisabled","withCharValidation","constraints","ConstraintsUtils","fromFieldValidations","validations","type","checkConstraint","makeChecker","locale","React","FieldConnector","errors","disabled","value","setValue","Textarea","className","styles","rows","required","error","length","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":";;;;;;AAGO,IAAMA,aAAa,gBAAGC,GAAG,CAAC;AAC/BC,EAAAA,OAAO,EAAE,MADsB;AAE/BC,EAAAA,cAAc,EAAE,eAFe;AAG/BC,EAAAA,QAAQ,EAAEC,MAAM,CAACC,SAHc;AAI/BC,EAAAA,SAAS,EAAEF,MAAM,CAACG,SAJa;AAK/BC,EAAAA,KAAK,EAAEJ,MAAM,CAACK;AALiB,CAAD,CAAzB;AAQA,IAAMC,WAAW,gBAAGV,GAAG,CAAC;AAC7BW,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SCuBSC,mBAAmBC;AACjC,MAAQC,KAAR,GAAoED,KAApE,CAAQC,KAAR;AAAA,MAAeC,OAAf,GAAoEF,KAApE,CAAeE,OAAf;AAAA,MAAwBC,mBAAxB,GAAoEH,KAApE,CAAwBG,mBAAxB;AAAA,MAA6CC,kBAA7C,GAAoEJ,KAApE,CAA6CI,kBAA7C;AAEA,MAAMC,WAAW,GAAGC,gBAAgB,CAACC,oBAAjB,CAAsCN,KAAK,CAACO,WAA5C,EAAyDP,KAAK,CAACQ,IAA/D,CAApB;AACA,MAAMC,eAAe,GAAGJ,gBAAgB,CAACK,WAAjB,CAA6BN,WAA7B,CAAxB;AACA,MAAMP,SAAS,GAAGI,OAAO,CAACJ,SAAR,CAAkBG,KAAK,CAACW,MAAxB,KAAmC,KAArD;AAEA,SACEC,aAAA,CAACC,cAAD;AAAwBb,IAAAA,KAAK,EAAEA;AAAOE,IAAAA,mBAAmB,EAAEA;GAA3D,EACG;QAAGY,cAAAA;QAAQC,gBAAAA;QAAUC,aAAAA;QAAOC,gBAAAA;AAC3B,WACEL,aAAA,MAAA;sBAAkB;KAAlB,EACEA,aAAA,CAACM,QAAD;AACEC,MAAAA,SAAS,EAAEtB,SAAS,KAAK,KAAd,GAAsBuB,WAAtB,GAA2C;AACtDC,MAAAA,IAAI,EAAE;AACNC,MAAAA,QAAQ,EAAEtB,KAAK,CAACsB;AAChBC,MAAAA,KAAK,EAAET,MAAM,CAACU,MAAP,GAAgB;AACvBT,MAAAA,QAAQ,EAAEA;AACVC,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBS,MAAAA,QAAQ,EAAE,kBAACC,CAAD;AACRT,QAAAA,QAAQ,CAACS,CAAC,CAACC,MAAF,CAASX,KAAV,CAAR;AACD;KATH,CADF,EAYGb,kBAAkB,IACjBS,aAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,aAAA,CAACgB,WAAD;AAAaZ,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,aAAA,CAACiB,cAAD;AAAgBzB,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAbJ,EAkBG,CAACD,kBAAD,IACCS,aAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,aAAA,CAACgB,WAAD;AAAaZ,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAnBJ,CADF;AA0BD,GA5BH,CADF;AAgCD;AAEDX,kBAAkB,CAACgC,YAAnB,GAAkC;AAChC5B,EAAAA,mBAAmB,EAAE,IADW;AAEhCC,EAAAA,kBAAkB,EAAE;AAFY,CAAlC;;;;"}
package/dist/styles.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export declare const validationRow: string;
1
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": "0.13.0",
3
+ "version": "0.14.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/field-editor-multiple-line.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -21,15 +21,15 @@
21
21
  "tsc": "tsc -p ./ --noEmit"
22
22
  },
23
23
  "dependencies": {
24
- "@contentful/field-editor-shared": "^0.22.0",
25
- "@contentful/forma-36-react-components": "^3.93.1",
24
+ "@contentful/field-editor-shared": "^0.23.0",
25
+ "@contentful/forma-36-react-components": "^3.93.4",
26
26
  "@contentful/forma-36-tokens": "^0.11.0",
27
27
  "emotion": "^10.0.17",
28
28
  "lodash": "^4.17.15",
29
29
  "lodash-es": "^4.17.15"
30
30
  },
31
31
  "devDependencies": {
32
- "@contentful/field-editor-test-utils": "^0.17.0"
32
+ "@contentful/field-editor-test-utils": "^0.17.2"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=16.8.0"
@@ -44,5 +44,5 @@
44
44
  }
45
45
  }
46
46
  },
47
- "gitHead": "35aa8358f3badc9a2ace48ceaff847800d6f766a"
47
+ "gitHead": "4020000939175ec415639fbc3b7b20e011c2a8a7"
48
48
  }