@contentful/field-editor-multiple-line 1.1.10 → 1.2.0
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 +10 -0
- package/dist/field-editor-multiple-line.cjs.development.js +21 -20
- package/dist/field-editor-multiple-line.cjs.development.js.map +1 -1
- package/dist/field-editor-multiple-line.cjs.production.min.js +1 -1
- package/dist/field-editor-multiple-line.cjs.production.min.js.map +1 -1
- package/dist/field-editor-multiple-line.esm.js +21 -20
- package/dist/field-editor-multiple-line.esm.js.map +1 -1
- package/package.json +4 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
# [1.2.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.11...@contentful/field-editor-multiple-line@1.2.0) (2023-04-19)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- upgrade cypress [TOL-1036] ([#1391](https://github.com/contentful/field-editors/issues/1391)) ([9c1aec9](https://github.com/contentful/field-editors/commit/9c1aec98aabbe464cdc3f1236c3bb1cc29b8208d))
|
|
11
|
+
|
|
12
|
+
## [1.1.11](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.10...@contentful/field-editor-multiple-line@1.1.11) (2023-03-14)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @contentful/field-editor-multiple-line
|
|
15
|
+
|
|
6
16
|
## [1.1.10](https://github.com/contentful/field-editors/compare/@contentful/field-editor-multiple-line@1.1.9...@contentful/field-editor-multiple-line@1.1.10) (2023-03-10)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @contentful/field-editor-multiple-line
|
|
@@ -5,38 +5,41 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
var React = require('react');
|
|
8
|
+
var f36Components = require('@contentful/f36-components');
|
|
8
9
|
var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
9
|
-
var emotion = require('emotion');
|
|
10
10
|
var tokens = _interopDefault(require('@contentful/f36-tokens'));
|
|
11
|
-
var
|
|
11
|
+
var emotion = require('emotion');
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const validationRow = /*#__PURE__*/emotion.css({
|
|
14
14
|
display: 'flex',
|
|
15
15
|
justifyContent: 'space-between',
|
|
16
16
|
fontSize: tokens.fontSizeM,
|
|
17
17
|
marginTop: tokens.spacingXs,
|
|
18
18
|
color: tokens.gray700
|
|
19
19
|
});
|
|
20
|
-
|
|
20
|
+
const rightToLeft = /*#__PURE__*/emotion.css({
|
|
21
21
|
direction: 'rtl'
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
function MultipleLineEditor(props) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
const {
|
|
26
|
+
field,
|
|
27
|
+
locales,
|
|
28
|
+
isInitiallyDisabled,
|
|
29
|
+
withCharValidation
|
|
30
|
+
} = props;
|
|
31
|
+
const constraints = fieldEditorShared.ConstraintsUtils.fromFieldValidations(field.validations, field.type);
|
|
32
|
+
const checkConstraint = fieldEditorShared.ConstraintsUtils.makeChecker(constraints);
|
|
33
|
+
const direction = locales.direction[field.locale] || 'ltr';
|
|
32
34
|
return React.createElement(fieldEditorShared.FieldConnector, {
|
|
33
35
|
field: field,
|
|
34
36
|
isInitiallyDisabled: isInitiallyDisabled
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
}, ({
|
|
38
|
+
errors,
|
|
39
|
+
disabled,
|
|
40
|
+
value,
|
|
41
|
+
setValue
|
|
42
|
+
}) => {
|
|
40
43
|
return React.createElement("div", {
|
|
41
44
|
"data-test-id": "multiple-line-editor"
|
|
42
45
|
}, React.createElement(f36Components.Textarea, {
|
|
@@ -46,7 +49,7 @@ function MultipleLineEditor(props) {
|
|
|
46
49
|
isInvalid: errors.length > 0,
|
|
47
50
|
isDisabled: disabled,
|
|
48
51
|
value: value || '',
|
|
49
|
-
onChange:
|
|
52
|
+
onChange: e => {
|
|
50
53
|
setValue(e.target.value);
|
|
51
54
|
}
|
|
52
55
|
}), withCharValidation && React.createElement("div", {
|
|
@@ -60,9 +63,7 @@ function MultipleLineEditor(props) {
|
|
|
60
63
|
className: validationRow
|
|
61
64
|
}, React.createElement(fieldEditorShared.CharCounter, {
|
|
62
65
|
value: value || '',
|
|
63
|
-
checkConstraint:
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
+
checkConstraint: () => true
|
|
66
67
|
})));
|
|
67
68
|
});
|
|
68
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-multiple-line.cjs.development.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"field-editor-multiple-line.cjs.development.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\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';\n\nimport { Textarea } from '@contentful/f36-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\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(\n field.validations,\n field.type as 'Text'\n );\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 isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={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","isRequired","required","isInvalid","length","isDisabled","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":";;;;;;;;;;;;AAGO,MAAMA,aAAa,gBAAGC,WAAG,CAAC;AAC/BC,EAAAA,OAAO,EAAE,MADsB;AAE/BC,EAAA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,QAAQ,CAACW,CAAC,CAACC,MAAF,CAASb,KAAV,CAAR;AACD;KATH,CADF,EAYGb,kBAAkB,IACjBS,mBAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,mBAAA,CAACkB,6BAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,mBAAA,CAACmB,gCAAD;AAAgB3B,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAbJ,EAkBG,CAACD,kBAAD,IACCS,mBAAA,MAAA;AAAKO,MAAAA,SAAS,EAAEC;KAAhB,EACER,mBAAA,CAACkB,6BAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIP,MAAAA,eAAe,EAAE,MAAM;KAAxD,CADF,CAnBJ,CADF;AA0BD,GA5BH,CADF;AAgCD;AAEDX,kBAAkB,CAACkC,YAAnB,GAAkC;AAChC9B,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,t=require("react"),i=require("@contentful/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),i=require("@contentful/f36-components"),a=require("@contentful/field-editor-shared"),l=(e=require("@contentful/f36-tokens"))&&"object"==typeof e&&"default"in e?e.default:e,r=require("emotion");const n=r.css({display:"flex",justifyContent:"space-between",fontSize:l.fontSizeM,marginTop:l.spacingXs,color:l.gray700}),s=r.css({direction:"rtl"});function o(e){const{field:l,locales:r,isInitiallyDisabled:o,withCharValidation:c}=e,d=a.ConstraintsUtils.fromFieldValidations(l.validations,l.type),u=a.ConstraintsUtils.makeChecker(d),f=r.direction[l.locale]||"ltr";return t.createElement(a.FieldConnector,{field:l,isInitiallyDisabled:o},({errors:e,disabled:r,value:o,setValue:m})=>t.createElement("div",{"data-test-id":"multiple-line-editor"},t.createElement(i.Textarea,{className:"rtl"===f?s:"",rows:3,isRequired:l.required,isInvalid:e.length>0,isDisabled:r,value:o||"",onChange:e=>{m(e.target.value)}}),c&&t.createElement("div",{className:n},t.createElement(a.CharCounter,{value:o||"",checkConstraint:u}),t.createElement(a.CharValidation,{constraints:d})),!c&&t.createElement("div",{className:n},t.createElement(a.CharCounter,{value:o||"",checkConstraint:()=>!0}))))}o.defaultProps={isInitiallyDisabled:!0,withCharValidation:!0},exports.MultipleLineEditor=o;
|
|
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
|
|
1
|
+
{"version":3,"file":"field-editor-multiple-line.cjs.production.min.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\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';\n\nimport { Textarea } from '@contentful/f36-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\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(\n field.validations,\n field.type as 'Text'\n );\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 isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={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","isRequired","required","isInvalid","length","isDisabled","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":"8RAGO,MAAMA,EAAgBC,MAAI,CAC/BC,QAAS,OACTC,eAAgB,gBAChBC,SAAUC,EAAOC,UACjBC,UAAWF,EAAOG,UAClBC,MAAOJ,EAAOK,UAGHC,EAAcV,MAAI,CAC7BW,UAAW,iBCyBGC,EAAmBC,SAC3BC,MAAEA,EAAFC,QAASA,EAATC,oBAAkBA,EAAlBC,mBAAuCA,GAAuBJ,EAE9DK,EAAcC,mBAAiBC,qBACnCN,EAAMO,YACNP,EAAMQ,MAEFC,EAAkBJ,mBAAiBK,YAAYN,GAC/CP,EAAYI,EAAQJ,UAAUG,EAAMW,SAAW,aAGnDC,gBAACC,kBAAuBb,MAAOA,EAAOE,oBAAqBA,GACxD,EAAGY,OAAAA,EAAQC,SAAAA,EAAUC,MAAAA,EAAOC,SAAAA,KAEzBL,sCAAkB,wBAChBA,gBAACM,YACCC,UAAyB,QAAdtB,EAAsBuB,EAAqB,GACtDC,KAAM,EACNC,WAAYtB,EAAMuB,SAClBC,UAAWV,EAAOW,OAAS,EAC3BC,WAAYX,EACZC,MAAOA,GAAS,GAChBW,SAAWC,IACTX,EAASW,EAAEC,OAAOb,UAGrBb,GACCS,uBAAKO,UAAWC,GACdR,gBAACkB,eAAYd,MAAOA,GAAS,GAAIP,gBAAiBA,IAClDG,gBAACmB,kBAAe3B,YAAaA,MAG/BD,GACAS,uBAAKO,UAAWC,GACdR,gBAACkB,eAAYd,MAAOA,GAAS,GAAIP,gBAAiB,KAAM,OAUxEX,EAAmBkC,aAAe,CAChC9B,qBAAqB,EACrBC,oBAAoB"}
|
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
|
+
import { Textarea } from '@contentful/f36-components';
|
|
2
3
|
import { ConstraintsUtils, FieldConnector, CharCounter, CharValidation } from '@contentful/field-editor-shared';
|
|
3
|
-
import { css } from 'emotion';
|
|
4
4
|
import tokens from '@contentful/f36-tokens';
|
|
5
|
-
import {
|
|
5
|
+
import { css } from 'emotion';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const validationRow = /*#__PURE__*/css({
|
|
8
8
|
display: 'flex',
|
|
9
9
|
justifyContent: 'space-between',
|
|
10
10
|
fontSize: tokens.fontSizeM,
|
|
11
11
|
marginTop: tokens.spacingXs,
|
|
12
12
|
color: tokens.gray700
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
const rightToLeft = /*#__PURE__*/css({
|
|
15
15
|
direction: 'rtl'
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
function MultipleLineEditor(props) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const {
|
|
20
|
+
field,
|
|
21
|
+
locales,
|
|
22
|
+
isInitiallyDisabled,
|
|
23
|
+
withCharValidation
|
|
24
|
+
} = props;
|
|
25
|
+
const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);
|
|
26
|
+
const checkConstraint = ConstraintsUtils.makeChecker(constraints);
|
|
27
|
+
const direction = locales.direction[field.locale] || 'ltr';
|
|
26
28
|
return createElement(FieldConnector, {
|
|
27
29
|
field: field,
|
|
28
30
|
isInitiallyDisabled: isInitiallyDisabled
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
}, ({
|
|
32
|
+
errors,
|
|
33
|
+
disabled,
|
|
34
|
+
value,
|
|
35
|
+
setValue
|
|
36
|
+
}) => {
|
|
34
37
|
return createElement("div", {
|
|
35
38
|
"data-test-id": "multiple-line-editor"
|
|
36
39
|
}, createElement(Textarea, {
|
|
@@ -40,7 +43,7 @@ function MultipleLineEditor(props) {
|
|
|
40
43
|
isInvalid: errors.length > 0,
|
|
41
44
|
isDisabled: disabled,
|
|
42
45
|
value: value || '',
|
|
43
|
-
onChange:
|
|
46
|
+
onChange: e => {
|
|
44
47
|
setValue(e.target.value);
|
|
45
48
|
}
|
|
46
49
|
}), withCharValidation && createElement("div", {
|
|
@@ -54,9 +57,7 @@ function MultipleLineEditor(props) {
|
|
|
54
57
|
className: validationRow
|
|
55
58
|
}, createElement(CharCounter, {
|
|
56
59
|
value: value || '',
|
|
57
|
-
checkConstraint:
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
+
checkConstraint: () => true
|
|
60
61
|
})));
|
|
61
62
|
});
|
|
62
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-editor-multiple-line.esm.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"field-editor-multiple-line.esm.js","sources":["../src/styles.ts","../src/MultipleLineEditor.tsx"],"sourcesContent":["import tokens from '@contentful/f36-tokens';\nimport { css } from 'emotion';\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';\n\nimport { Textarea } from '@contentful/f36-components';\nimport {\n FieldAPI,\n LocalesAPI,\n FieldConnector,\n CharCounter,\n CharValidation,\n ConstraintsUtils,\n} from '@contentful/field-editor-shared';\n\nimport * as styles from './styles';\n\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(\n field.validations,\n field.type as 'Text'\n );\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 isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={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","isRequired","required","isInvalid","length","isDisabled","onChange","e","target","CharCounter","CharValidation","defaultProps"],"mappings":";;;;;;AAGO,MAAMA,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,MAAMC,WAAW,gBAAGV,GAAG,CAAC;AAC7BW,EAAAA,SAAS,EAAE;AADkB,CAAD,CAAvB;;SC0BSC,mBAAmBC;AACjC,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA,OAAT;AAAkBC,IAAAA,mBAAlB;AAAuCC,IAAAA;AAAvC,MAA8DJ,KAApE;AAEA,QAAMK,WAAW,GAAGC,gBAAgB,CAACC,oBAAjB,CAClBN,KAAK,CAACO,WADY,EAElBP,KAAK,CAACQ,IAFY,CAApB;AAIA,QAAMC,eAAe,GAAGJ,gBAAgB,CAACK,WAAjB,CAA6BN,WAA7B,CAAxB;AACA,QAAMP,SAAS,GAAGI,OAAO,CAACJ,SAAR,CAAkBG,KAAK,CAACW,MAAxB,KAAmC,KAArD;AAEA,SACEC,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 -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-multiple-line",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/field-editor-multiple-line.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -23,26 +23,16 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@contentful/f36-components": "^4.0.27",
|
|
25
25
|
"@contentful/f36-tokens": "^4.0.0",
|
|
26
|
-
"@contentful/field-editor-shared": "^1.
|
|
26
|
+
"@contentful/field-editor-shared": "^1.2.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": "^1.
|
|
32
|
+
"@contentful/field-editor-test-utils": "^1.3.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=16.8.0"
|
|
36
36
|
},
|
|
37
|
-
"
|
|
38
|
-
"testMatch": [
|
|
39
|
-
"**/?(*.)+(spec|test).[jt]s?(x)"
|
|
40
|
-
],
|
|
41
|
-
"globals": {
|
|
42
|
-
"ts-jest": {
|
|
43
|
-
"diagnostics": false
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"gitHead": "1e4a7d92c48f0e1949f2b48b3c9974da1602fd5c"
|
|
37
|
+
"gitHead": "de7e74e3485dd69c240cfe9c545e6e50e41fb295"
|
|
48
38
|
}
|