@contentful/field-editor-single-line 0.15.0 → 0.15.4

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,38 @@
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.15.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.15.3...@contentful/field-editor-single-line@0.15.4) (2021-09-17)
7
+
8
+ **Note:** Version bump only for package @contentful/field-editor-single-line
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.15.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.15.2...@contentful/field-editor-single-line@0.15.3) (2021-09-16)
15
+
16
+ **Note:** Version bump only for package @contentful/field-editor-single-line
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.15.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.15.1...@contentful/field-editor-single-line@0.15.2) (2021-08-19)
23
+
24
+ **Note:** Version bump only for package @contentful/field-editor-single-line
25
+
26
+
27
+
28
+
29
+
30
+ ## [0.15.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.15.0...@contentful/field-editor-single-line@0.15.1) (2021-07-29)
31
+
32
+ **Note:** Version bump only for package @contentful/field-editor-single-line
33
+
34
+
35
+
36
+
37
+
6
38
  # [0.15.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.14.6...@contentful/field-editor-single-line@0.15.0) (2021-07-23)
7
39
 
8
40
 
@@ -1 +1 @@
1
- {"version":3,"file":"field-editor-single-line.cjs.development.js","sources":["../src/styles.ts","../src/SingleLineEditor.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 { TextInput } from '@contentful/forma-36-react-components';\nimport {\n FieldAPI,\n FieldConnector,\n ConstraintsUtils,\n CharCounter,\n CharValidation,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface SingleLineEditorProps {\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 * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nfunction isSupportedFieldTypes(val: string): val is 'Symbol' | 'Text' {\n return val === 'Symbol' || val === 'Text';\n}\n\nexport function SingleLineEditor(props: SingleLineEditorProps) {\n const { field, locales } = props;\n\n if (!isSupportedFieldTypes(field.type)) {\n throw new Error(`\"${field.type}\" field type is not supported by SingleLineEditor`);\n }\n\n // eslint-disable-next-line\n const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ value, errors, disabled, setValue }) => {\n return (\n <div data-test-id=\"single-line-editor\">\n <TextInput\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n }}\n />\n {props.withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {props.withCharValidation === false && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nSingleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","isSupportedFieldTypes","val","SingleLineEditor","props","field","locales","type","Error","constraints","ConstraintsUtils","fromFieldValidations","validations","checkConstraint","makeChecker","locale","React","FieldConnector","isInitiallyDisabled","value","errors","disabled","setValue","TextInput","className","styles","required","error","length","onChange","e","target","withCharValidation","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;;ACsBP,SAASC,qBAAT,CAA+BC,GAA/B;AACE,SAAOA,GAAG,KAAK,QAAR,IAAoBA,GAAG,KAAK,MAAnC;AACD;;AAED,SAAgBC,iBAAiBC;MACvBC,QAAmBD,MAAnBC;MAAOC,UAAYF,MAAZE;;AAEf,MAAI,CAACL,qBAAqB,CAACI,KAAK,CAACE,IAAP,CAA1B,EAAwC;AACtC,UAAM,IAAIC,KAAJ,QAAcH,KAAK,CAACE,IAApB,wDAAN;AACD;;;AAGD,MAAME,WAAW,GAAGC,kCAAgB,CAACC,oBAAjB,CAAsCN,KAAK,CAACO,WAA5C,EAAyDP,KAAK,CAACE,IAA/D,CAApB;AACA,MAAMM,eAAe,GAAGH,kCAAgB,CAACI,WAAjB,CAA6BL,WAA7B,CAAxB;AACA,MAAMT,SAAS,GAAGM,OAAO,CAACN,SAAR,CAAkBK,KAAK,CAACU,MAAxB,KAAmC,KAArD;AAEA,SACEC,mBAAA,CAACC,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1
+ {"version":3,"file":"field-editor-single-line.cjs.development.js","sources":["../src/styles.ts","../src/SingleLineEditor.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 { TextInput } from '@contentful/forma-36-react-components';\nimport {\n FieldAPI,\n FieldConnector,\n ConstraintsUtils,\n CharCounter,\n CharValidation,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface SingleLineEditorProps {\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 * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nfunction isSupportedFieldTypes(val: string): val is 'Symbol' | 'Text' {\n return val === 'Symbol' || val === 'Text';\n}\n\nexport function SingleLineEditor(props: SingleLineEditorProps) {\n const { field, locales } = props;\n\n if (!isSupportedFieldTypes(field.type)) {\n throw new Error(`\"${field.type}\" field type is not supported by SingleLineEditor`);\n }\n\n // eslint-disable-next-line\n const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ value, errors, disabled, setValue }) => {\n return (\n <div data-test-id=\"single-line-editor\">\n <TextInput\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n }}\n />\n {props.withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {props.withCharValidation === false && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nSingleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","isSupportedFieldTypes","val","SingleLineEditor","props","field","locales","type","Error","constraints","ConstraintsUtils","fromFieldValidations","validations","checkConstraint","makeChecker","locale","React","FieldConnector","isInitiallyDisabled","value","errors","disabled","setValue","TextInput","className","styles","required","error","length","onChange","e","target","withCharValidation","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;;ACsBP,SAASC,qBAAT,CAA+BC,GAA/B;AACE,SAAOA,GAAG,KAAK,QAAR,IAAoBA,GAAG,KAAK,MAAnC;AACD;;AAED,SAAgBC,iBAAiBC;AAC/B,MAAQC,KAAR,GAA2BD,KAA3B,CAAQC,KAAR;AAAA,MAAeC,OAAf,GAA2BF,KAA3B,CAAeE,OAAf;;AAEA,MAAI,CAACL,qBAAqB,CAACI,KAAK,CAACE,IAAP,CAA1B,EAAwC;AACtC,UAAM,IAAIC,KAAJ,QAAcH,KAAK,CAACE,IAApB,wDAAN;AACD;;;AAGD,M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,CAACiB,6BAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAlBJ,CADF;AAyBD,GA3BH,CADF;AA+BD;AAEDV,gBAAgB,CAACgC,YAAjB,GAAgC;AAC9BjB,EAAAA,mBAAmB,EAAE,IADS;AAE9Bc,EAAAA,kBAAkB,EAAE;AAFU,CAAhC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"field-editor-single-line.esm.js","sources":["../src/styles.ts","../src/SingleLineEditor.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 { TextInput } from '@contentful/forma-36-react-components';\nimport {\n FieldAPI,\n FieldConnector,\n ConstraintsUtils,\n CharCounter,\n CharValidation,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface SingleLineEditorProps {\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 * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nfunction isSupportedFieldTypes(val: string): val is 'Symbol' | 'Text' {\n return val === 'Symbol' || val === 'Text';\n}\n\nexport function SingleLineEditor(props: SingleLineEditorProps) {\n const { field, locales } = props;\n\n if (!isSupportedFieldTypes(field.type)) {\n throw new Error(`\"${field.type}\" field type is not supported by SingleLineEditor`);\n }\n\n // eslint-disable-next-line\n const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ value, errors, disabled, setValue }) => {\n return (\n <div data-test-id=\"single-line-editor\">\n <TextInput\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n }}\n />\n {props.withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {props.withCharValidation === false && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nSingleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","isSupportedFieldTypes","val","SingleLineEditor","props","field","locales","type","Error","constraints","ConstraintsUtils","fromFieldValidations","validations","checkConstraint","makeChecker","locale","React","FieldConnector","isInitiallyDisabled","value","errors","disabled","setValue","TextInput","className","styles","required","error","length","onChange","e","target","withCharValidation","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;;ACsBP,SAASC,qBAAT,CAA+BC,GAA/B;AACE,SAAOA,GAAG,KAAK,QAAR,IAAoBA,G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MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,aAAA,CAACkB,cAAD;AAAgBzB,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAZJ,EAiBGL,KAAK,CAAC4B,kBAAN,KAA6B,KAA7B,IACChB,aAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,aAAA,CAACiB,WAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAlBJ,CADF;AAyBD,GA3BH,CADF;AA+BD;AAEDV,gBAAgB,CAACgC,YAAjB,GAAgC;AAC9BjB,EAAAA,mBAAmB,EAAE,IADS;AAE9Bc,EAAAA,kBAAkB,EAAE;AAFU,CAAhC;;;;"}
1
+ {"version":3,"file":"field-editor-single-line.esm.js","sources":["../src/styles.ts","../src/SingleLineEditor.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 { TextInput } from '@contentful/forma-36-react-components';\nimport {\n FieldAPI,\n FieldConnector,\n ConstraintsUtils,\n CharCounter,\n CharValidation,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nexport interface SingleLineEditorProps {\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 * sdk.field\n */\n field: FieldAPI;\n\n /**\n * sdk.locales\n */\n locales: LocalesAPI;\n}\n\nfunction isSupportedFieldTypes(val: string): val is 'Symbol' | 'Text' {\n return val === 'Symbol' || val === 'Text';\n}\n\nexport function SingleLineEditor(props: SingleLineEditorProps) {\n const { field, locales } = props;\n\n if (!isSupportedFieldTypes(field.type)) {\n throw new Error(`\"${field.type}\" field type is not supported by SingleLineEditor`);\n }\n\n // eslint-disable-next-line\n const constraints = ConstraintsUtils.fromFieldValidations(field.validations, field.type);\n const checkConstraint = ConstraintsUtils.makeChecker(constraints);\n const direction = locales.direction[field.locale] || 'ltr';\n\n return (\n <FieldConnector<string> field={field} isInitiallyDisabled={props.isInitiallyDisabled}>\n {({ value, errors, disabled, setValue }) => {\n return (\n <div data-test-id=\"single-line-editor\">\n <TextInput\n className={direction === 'rtl' ? styles.rightToLeft : ''}\n required={field.required}\n error={errors.length > 0}\n disabled={disabled}\n value={value || ''}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n }}\n />\n {props.withCharValidation && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={checkConstraint} />\n <CharValidation constraints={constraints} />\n </div>\n )}\n {props.withCharValidation === false && (\n <div className={styles.validationRow}>\n <CharCounter value={value || ''} checkConstraint={() => true} />\n </div>\n )}\n </div>\n );\n }}\n </FieldConnector>\n );\n}\n\nSingleLineEditor.defaultProps = {\n isInitiallyDisabled: true,\n withCharValidation: true,\n};\n"],"names":["validationRow","css","display","justifyContent","fontSize","tokens","fontSizeM","marginTop","spacingXs","color","gray700","rightToLeft","direction","isSupportedFieldTypes","val","SingleLineEditor","props","field","locales","type","Error","constraints","ConstraintsUtils","fromFieldValidations","validations","checkConstraint","makeChecker","locale","React","FieldConnector","isInitiallyDisabled","value","errors","disabled","setValue","TextInput","className","styles","required","error","length","onChange","e","target","withCharValidation","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,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Q,EAAE,kBAACC,CAAD;AACRR,QAAAA,QAAQ,CAACQ,CAAC,CAACC,MAAF,CAASZ,KAAV,CAAR;AACD;KARH,CADF,EAWGf,KAAK,CAAC4B,kBAAN,IACChB,aAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,aAAA,CAACiB,WAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,aAAA,CAACkB,cAAD;AAAgBzB,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAZJ,EAiBGL,KAAK,CAAC4B,kBAAN,KAA6B,KAA7B,IACChB,aAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,aAAA,CAACiB,WAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAlBJ,CADF;AAyBD,GA3BH,CADF;AA+BD;AAEDV,gBAAgB,CAACgC,YAAjB,GAAgC;AAC9BjB,EAAAA,mBAAmB,EAAE,IADS;AAE9Bc,EAAAA,kBAAkB,EAAE;AAFU,CAAhC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-single-line",
3
- "version": "0.15.0",
3
+ "version": "0.15.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/field-editor-single-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.24.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.3"
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": "f5450f62e92802984fb32a4dd28f266aabbdd5d7"
48
48
  }