@contentful/field-editor-single-line 0.15.4 → 1.0.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 CHANGED
@@ -3,188 +3,121 @@
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)
6
+ # [1.0.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.16.0...@contentful/field-editor-single-line@1.0.0) (2021-11-04)
7
7
 
8
8
  **Note:** Version bump only for package @contentful/field-editor-single-line
9
9
 
10
+ # [0.16.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.15.6...@contentful/field-editor-single-line@0.16.0) (2021-11-04)
10
11
 
12
+ ### Features
11
13
 
14
+ - Forma v4 components adoption ([#805](https://github.com/contentful/field-editors/issues/805)) ([526bde6](https://github.com/contentful/field-editors/commit/526bde6e10e0ee3789705ec10fb31489af7ca59e))
12
15
 
16
+ ### BREAKING CHANGES
13
17
 
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
18
+ - adopts a new Forma v4 beta
17
19
 
20
+ ## [0.15.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.15.5...@contentful/field-editor-single-line@0.15.6) (2021-10-14)
18
21
 
22
+ **Note:** Version bump only for package @contentful/field-editor-single-line
19
23
 
24
+ ## [0.15.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.15.4...@contentful/field-editor-single-line@0.15.5) (2021-10-06)
20
25
 
26
+ **Note:** Version bump only for package @contentful/field-editor-single-line
21
27
 
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)
28
+ ## [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)
23
29
 
24
30
  **Note:** Version bump only for package @contentful/field-editor-single-line
25
31
 
32
+ ## [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)
26
33
 
34
+ **Note:** Version bump only for package @contentful/field-editor-single-line
27
35
 
36
+ ## [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)
28
37
 
38
+ **Note:** Version bump only for package @contentful/field-editor-single-line
29
39
 
30
40
  ## [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
41
 
32
42
  **Note:** Version bump only for package @contentful/field-editor-single-line
33
43
 
34
-
35
-
36
-
37
-
38
44
  # [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)
39
45
 
40
-
41
46
  ### Features
42
47
 
43
- * 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
44
-
45
-
46
-
47
-
48
+ - 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
48
49
 
49
50
  ## [0.14.6](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.14.3...@contentful/field-editor-single-line@0.14.6) (2021-07-06)
50
51
 
51
52
  **Note:** Version bump only for package @contentful/field-editor-single-line
52
53
 
53
-
54
-
55
-
56
-
57
54
  ## [0.14.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.14.3...@contentful/field-editor-single-line@0.14.5) (2021-07-06)
58
55
 
59
56
  **Note:** Version bump only for package @contentful/field-editor-single-line
60
57
 
61
-
62
-
63
-
64
-
65
58
  ## [0.14.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.14.3...@contentful/field-editor-single-line@0.14.4) (2021-06-23)
66
59
 
67
60
  **Note:** Version bump only for package @contentful/field-editor-single-line
68
61
 
69
-
70
-
71
-
72
-
73
62
  ## [0.14.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.14.2...@contentful/field-editor-single-line@0.14.3) (2021-06-23)
74
63
 
75
64
  **Note:** Version bump only for package @contentful/field-editor-single-line
76
65
 
77
-
78
-
79
-
80
-
81
66
  ## [0.14.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.14.1...@contentful/field-editor-single-line@0.14.2) (2021-06-22)
82
67
 
83
68
  **Note:** Version bump only for package @contentful/field-editor-single-line
84
69
 
85
-
86
-
87
-
88
-
89
70
  ## [0.14.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.14.0...@contentful/field-editor-single-line@0.14.1) (2021-03-05)
90
71
 
91
72
  **Note:** Version bump only for package @contentful/field-editor-single-line
92
73
 
93
-
94
-
95
-
96
-
97
74
  # [0.14.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.13.2...@contentful/field-editor-single-line@0.14.0) (2021-02-19)
98
75
 
99
-
100
76
  ### Features
101
77
 
102
- * bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
103
-
104
-
105
-
106
-
78
+ - bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
107
79
 
108
80
  ## [0.13.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.13.1...@contentful/field-editor-single-line@0.13.2) (2021-02-09)
109
81
 
110
82
  **Note:** Version bump only for package @contentful/field-editor-single-line
111
83
 
112
-
113
-
114
-
115
-
116
84
  ## [0.13.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.13.0...@contentful/field-editor-single-line@0.13.1) (2021-02-01)
117
85
 
118
86
  **Note:** Version bump only for package @contentful/field-editor-single-line
119
87
 
120
-
121
-
122
-
123
-
124
88
  # [0.13.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.12.0...@contentful/field-editor-single-line@0.13.0) (2021-01-20)
125
89
 
126
-
127
90
  ### Features
128
91
 
129
- * update minimal forma-36 versions to use updated design ([#565](https://github.com/contentful/field-editors/issues/565)) ([332c734](https://github.com/contentful/field-editors/commit/332c734bfaf54f0e9773fcbb460d743b1f5459ec))
130
-
131
-
132
-
133
-
92
+ - update minimal forma-36 versions to use updated design ([#565](https://github.com/contentful/field-editors/issues/565)) ([332c734](https://github.com/contentful/field-editors/commit/332c734bfaf54f0e9773fcbb460d743b1f5459ec))
134
93
 
135
94
  # [0.12.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.11.4...@contentful/field-editor-single-line@0.12.0) (2021-01-12)
136
95
 
137
-
138
96
  ### Features
139
97
 
140
- * update minimal required Forma version to the 3.73.12 ([#552](https://github.com/contentful/field-editors/issues/552)) ([2816fd9](https://github.com/contentful/field-editors/commit/2816fd960c28815faebf49a9ef8f4c4c0d91fc36))
141
-
142
-
143
-
144
-
98
+ - update minimal required Forma version to the 3.73.12 ([#552](https://github.com/contentful/field-editors/issues/552)) ([2816fd9](https://github.com/contentful/field-editors/commit/2816fd960c28815faebf49a9ef8f4c4c0d91fc36))
145
99
 
146
100
  ## [0.11.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.11.3...@contentful/field-editor-single-line@0.11.4) (2020-12-16)
147
101
 
148
102
  **Note:** Version bump only for package @contentful/field-editor-single-line
149
103
 
150
-
151
-
152
-
153
-
154
104
  ## [0.11.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.11.2...@contentful/field-editor-single-line@0.11.3) (2020-11-06)
155
105
 
156
106
  **Note:** Version bump only for package @contentful/field-editor-single-line
157
107
 
158
-
159
-
160
-
161
-
162
108
  ## [0.11.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.11.1...@contentful/field-editor-single-line@0.11.2) (2020-11-06)
163
109
 
164
110
  **Note:** Version bump only for package @contentful/field-editor-single-line
165
111
 
166
-
167
-
168
-
169
-
170
112
  ## [0.11.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.11.0...@contentful/field-editor-single-line@0.11.1) (2020-10-28)
171
113
 
172
114
  **Note:** Version bump only for package @contentful/field-editor-single-line
173
115
 
174
-
175
-
176
-
177
-
178
116
  # [0.11.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.10.1...@contentful/field-editor-single-line@0.11.0) (2020-09-03)
179
117
 
180
-
181
118
  ### Features
182
119
 
183
- * 🎸 add withCharValidation property to hide validation ([#390](https://github.com/contentful/field-editors/issues/390)) ([9da6700](https://github.com/contentful/field-editors/commit/9da67005f83c1cebdabb67edfed73f7d1dcbfc04))
184
-
185
-
186
-
187
-
120
+ - 🎸 add withCharValidation property to hide validation ([#390](https://github.com/contentful/field-editors/issues/390)) ([9da6700](https://github.com/contentful/field-editors/commit/9da67005f83c1cebdabb67edfed73f7d1dcbfc04))
188
121
 
189
122
  ## [0.10.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@0.10.0...@contentful/field-editor-single-line@0.10.1) (2020-08-24)
190
123
 
package/README.md CHANGED
@@ -7,6 +7,5 @@ npm install @contentful/field-editor-single-line
7
7
  This package contains a React `SingleLineEditor` component that is used as a default for the `Symbol` and `Text` field types in the Contentful web application.
8
8
 
9
9
  ```js
10
- import '@contentful/forma-36-react-components/dist/styles.css';
11
10
  import { SingleLineEditor } from '@contentful/field-editor-single-line';
12
11
  ```
@@ -5,10 +5,10 @@ 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 forma36ReactComponents = require('@contentful/forma-36-react-components');
9
8
  var fieldEditorShared = require('@contentful/field-editor-shared');
10
9
  var emotion = require('emotion');
11
- var tokens = _interopDefault(require('@contentful/forma-36-tokens'));
10
+ var tokens = _interopDefault(require('@contentful/f36-tokens'));
11
+ var f36Components = require('@contentful/f36-components');
12
12
 
13
13
  var validationRow = /*#__PURE__*/emotion.css({
14
14
  display: 'flex',
@@ -47,11 +47,11 @@ function SingleLineEditor(props) {
47
47
  setValue = _ref.setValue;
48
48
  return React.createElement("div", {
49
49
  "data-test-id": "single-line-editor"
50
- }, React.createElement(forma36ReactComponents.TextInput, {
50
+ }, React.createElement(f36Components.TextInput, {
51
51
  className: direction === 'rtl' ? rightToLeft : '',
52
- required: field.required,
53
- error: errors.length > 0,
54
- disabled: disabled,
52
+ isRequired: field.required,
53
+ isInvalid: errors.length > 0,
54
+ isDisabled: disabled,
55
55
  value: value || '',
56
56
  onChange: function onChange(e) {
57
57
  setValue(e.target.value);
@@ -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;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,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,gCAAD;AAAwBZ,IAAAA,KAAK,EAAEA;AAAOa,IAAAA,mBAAmB,EAAEd,KAAK,CAACc;GAAjE,EACG;QAAGC,aAAAA;QAAOC,cAAAA;QAAQC,gBAAAA;QAAUC,gBAAAA;AAC3B,WACEN,mBAAA,MAAA;sBAAkB;KAAlB,EACEA,mBAAA,CAACO,gCAAD;AACEC,MAAAA,SAAS,EAAExB,SAAS,KAAK,KAAd,GAAsByB,WAAtB,GAA2C;AACtDC,MAAAA,QAAQ,EAAErB,KAAK,CAACqB;AAChBC,MAAAA,KAAK,EAAEP,MAAM,CAACQ,MAAP,GAAgB;AACvBP,MAAAA,QAAQ,EAAEA;AACVF,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBU,MAAAA,QAAQ,EAAE,kBAACC,CAAD;AACRR,QAAAA,QAAQ,CAACQ,CAAC,CAACC,MAAF,CAASZ,KAAV,CAAR;AACD;KARH,CADF,EAWGf,KAAK,CAAC4B,kBAAN,IACChB,mBAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,mBAAA,CAACiB,6BAAD;AAAad,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,mBAAA,CAACkB,gCAAD;AAAgBzB,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAZJ,EAiBGL,KAAK,CAAC4B,kBAAN,KAA6B,KAA7B,IACChB,mBAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,mBAAA,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
+ {"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/f36-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 {\n FieldAPI,\n FieldConnector,\n ConstraintsUtils,\n CharCounter,\n CharValidation,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nimport { TextInput } from '@contentful/f36-components';\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 isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={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","isRequired","required","isInvalid","length","isDisabled","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;;ACuBP,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,MAAME,WAAW,GAAGC,kCAAgB,CAACC,oBAAjB,CAAsCN,KAAK,CAACO,WAA5C,EAAyDP,KAAK,CAACE,IAA/D,CAApB;AACA,MAAMM,eAAe,GAAGH,kCAA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GA3BH,CADF;AA+BD;AAEDV,gBAAgB,CAACkC,YAAjB,GAAgC;AAC9BnB,EAAAA,mBAAmB,EAAE,IADS;AAE9BgB,EAAAA,kBAAkB,EAAE;AAFU,CAAhC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),i=require("@contentful/forma-36-react-components"),r=require("@contentful/field-editor-shared"),a=require("emotion"),n=(e=require("@contentful/forma-36-tokens"))&&"object"==typeof e&&"default"in e?e.default:e,l=a.css({display:"flex",justifyContent:"space-between",fontSize:n.fontSizeM,marginTop:n.spacingXs,color:n.gray700}),o=a.css({direction:"rtl"});function s(e){var a,n=e.field,s=e.locales;if("Symbol"!==(a=n.type)&&"Text"!==a)throw new Error('"'+n.type+'" field type is not supported by SingleLineEditor');var c=r.ConstraintsUtils.fromFieldValidations(n.validations,n.type),d=r.ConstraintsUtils.makeChecker(c),u=s.direction[n.locale]||"ltr";return t.createElement(r.FieldConnector,{field:n,isInitiallyDisabled:e.isInitiallyDisabled},(function(a){var s=a.value,f=a.setValue;return t.createElement("div",{"data-test-id":"single-line-editor"},t.createElement(i.TextInput,{className:"rtl"===u?o:"",required:n.required,error:a.errors.length>0,disabled:a.disabled,value:s||"",onChange:function(e){f(e.target.value)}}),e.withCharValidation&&t.createElement("div",{className:l},t.createElement(r.CharCounter,{value:s||"",checkConstraint:d}),t.createElement(r.CharValidation,{constraints:c})),!1===e.withCharValidation&&t.createElement("div",{className:l},t.createElement(r.CharCounter,{value:s||"",checkConstraint:function(){return!0}})))}))}s.defaultProps={isInitiallyDisabled:!0,withCharValidation:!0},exports.SingleLineEditor=s;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),i=require("@contentful/field-editor-shared"),n=require("emotion"),r=(e=require("@contentful/f36-tokens"))&&"object"==typeof e&&"default"in e?e.default:e,a=require("@contentful/f36-components"),l=n.css({display:"flex",justifyContent:"space-between",fontSize:r.fontSizeM,marginTop:r.spacingXs,color:r.gray700}),o=n.css({direction:"rtl"});function s(e){var n,r=e.field,s=e.locales;if("Symbol"!==(n=r.type)&&"Text"!==n)throw new Error('"'+r.type+'" field type is not supported by SingleLineEditor');var d=i.ConstraintsUtils.fromFieldValidations(r.validations,r.type),c=i.ConstraintsUtils.makeChecker(d),u=s.direction[r.locale]||"ltr";return t.createElement(i.FieldConnector,{field:r,isInitiallyDisabled:e.isInitiallyDisabled},(function(n){var s=n.value,f=n.setValue;return t.createElement("div",{"data-test-id":"single-line-editor"},t.createElement(a.TextInput,{className:"rtl"===u?o:"",isRequired:r.required,isInvalid:n.errors.length>0,isDisabled:n.disabled,value:s||"",onChange:function(e){f(e.target.value)}}),e.withCharValidation&&t.createElement("div",{className:l},t.createElement(i.CharCounter,{value:s||"",checkConstraint:c}),t.createElement(i.CharValidation,{constraints:d})),!1===e.withCharValidation&&t.createElement("div",{className:l},t.createElement(i.CharCounter,{value:s||"",checkConstraint:function(){return!0}})))}))}s.defaultProps={isInitiallyDisabled:!0,withCharValidation:!0},exports.SingleLineEditor=s;
2
2
  //# sourceMappingURL=field-editor-single-line.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field-editor-single-line.cjs.production.min.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","SingleLineEditor","props","val","field","locales","type","Error","constraints","ConstraintsUtils","fromFieldValidations","validations","checkConstraint","makeChecker","locale","React","FieldConnector","isInitiallyDisabled","value","setValue","TextInput","className","styles","required","error","errors","length","disabled","onChange","e","target","withCharValidation","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,iBCyBGC,EAAiBC,OAJFC,EAKrBC,EAAmBF,EAAnBE,MAAOC,EAAYH,EAAZG,WAJA,YADcF,EAOFC,EAAME,OANE,SAARH,QAOnB,IAAII,UAAUH,EAAME,8DAItBE,EAAcC,mBAAiBC,qBAAqBN,EAAMO,YAAaP,EAAME,MAC7EM,EAAkBH,mBAAiBI,YAAYL,GAC/CR,EAAYK,EAAQL,UAAUI,EAAMU,SAAW,aAGnDC,gBAACC,kBAAuBZ,MAAOA,EAAOa,oBAAqBf,EAAMe,sBAC9D,gBAAGC,IAAAA,MAAyBC,IAAAA,gBAEzBJ,sCAAkB,sBAChBA,gBAACK,aACCC,UAAyB,QAAdrB,EAAsBsB,EAAqB,GACtDC,SAAUnB,EAAMmB,SAChBC,QANGC,OAMWC,OAAS,EACvBC,WAPWA,SAQXT,MAAOA,GAAS,GAChBU,SAAU,SAACC,GACTV,EAASU,EAAEC,OAAOZ,UAGrBhB,EAAM6B,oBACLhB,uBAAKM,UAAWC,GACdP,gBAACiB,eAAYd,MAAOA,GAAS,GAAIN,gBAAiBA,IAClDG,gBAACkB,kBAAezB,YAAaA,MAGH,IAA7BN,EAAM6B,oBACLhB,uBAAKM,UAAWC,GACdP,gBAACiB,eAAYd,MAAOA,GAAS,GAAIN,gBAAiB,kBAAM,UAUxEX,EAAiBiC,aAAe,CAC9BjB,qBAAqB,EACrBc,oBAAoB"}
1
+ {"version":3,"file":"field-editor-single-line.cjs.production.min.js","sources":["../src/styles.ts","../src/SingleLineEditor.tsx"],"sourcesContent":["import { css } from 'emotion';\nimport tokens from '@contentful/f36-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 {\n FieldAPI,\n FieldConnector,\n ConstraintsUtils,\n CharCounter,\n CharValidation,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nimport { TextInput } from '@contentful/f36-components';\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 isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={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","SingleLineEditor","props","val","field","locales","type","Error","constraints","ConstraintsUtils","fromFieldValidations","validations","checkConstraint","makeChecker","locale","React","FieldConnector","isInitiallyDisabled","value","setValue","TextInput","className","styles","isRequired","required","isInvalid","errors","length","isDisabled","disabled","onChange","e","target","withCharValidation","CharCounter","CharValidation","defaultProps"],"mappings":"8RAGaA,EAAgBC,MAAI,CAC/BC,QAAS,OACTC,eAAgB,gBAChBC,SAAUC,EAAOC,UACjBC,UAAWF,EAAOG,UAClBC,MAAOJ,EAAOK,UAGHC,EAAcV,MAAI,CAC7BW,UAAW,iBC0BGC,EAAiBC,OAJFC,EAKrBC,EAAmBF,EAAnBE,MAAOC,EAAYH,EAAZG,WAJA,YADcF,EAOFC,EAAME,OANE,SAARH,QAOnB,IAAII,UAAUH,EAAME,8DAItBE,EAAcC,mBAAiBC,qBAAqBN,EAAMO,YAAaP,EAAME,MAC7EM,EAAkBH,mBAAiBI,YAAYL,GAC/CR,EAAYK,EAAQL,UAAUI,EAAMU,SAAW,aAGnDC,gBAACC,kBAAuBZ,MAAOA,EAAOa,oBAAqBf,EAAMe,sBAC9D,gBAAGC,IAAAA,MAAyBC,IAAAA,gBAEzBJ,sCAAkB,sBAChBA,gBAACK,aACCC,UAAyB,QAAdrB,EAAsBsB,EAAqB,GACtDC,WAAYnB,EAAMoB,SAClBC,YANGC,OAMeC,OAAS,EAC3BC,aAPWC,SAQXX,MAAOA,GAAS,GAChBY,SAAU,SAACC,GACTZ,EAASY,EAAEC,OAAOd,UAGrBhB,EAAM+B,oBACLlB,uBAAKM,UAAWC,GACdP,gBAACmB,eAAYhB,MAAOA,GAAS,GAAIN,gBAAiBA,IAClDG,gBAACoB,kBAAe3B,YAAaA,MAGH,IAA7BN,EAAM+B,oBACLlB,uBAAKM,UAAWC,GACdP,gBAACmB,eAAYhB,MAAOA,GAAS,GAAIN,gBAAiB,kBAAM,UAUxEX,EAAiBmC,aAAe,CAC9BnB,qBAAqB,EACrBgB,oBAAoB"}
@@ -1,8 +1,8 @@
1
1
  import { createElement } from 'react';
2
- import { TextInput } from '@contentful/forma-36-react-components';
3
2
  import { ConstraintsUtils, FieldConnector, CharCounter, CharValidation } from '@contentful/field-editor-shared';
4
3
  import { css } from 'emotion';
5
- import tokens from '@contentful/forma-36-tokens';
4
+ import tokens from '@contentful/f36-tokens';
5
+ import { TextInput } from '@contentful/f36-components';
6
6
 
7
7
  var validationRow = /*#__PURE__*/css({
8
8
  display: 'flex',
@@ -43,9 +43,9 @@ function SingleLineEditor(props) {
43
43
  "data-test-id": "single-line-editor"
44
44
  }, createElement(TextInput, {
45
45
  className: direction === 'rtl' ? rightToLeft : '',
46
- required: field.required,
47
- error: errors.length > 0,
48
- disabled: disabled,
46
+ isRequired: field.required,
47
+ isInvalid: errors.length > 0,
48
+ isDisabled: disabled,
49
49
  value: value || '',
50
50
  onChange: function onChange(e) {
51
51
  setValue(e.target.value);
@@ -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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AErB,KAAK,CAACqB;AAChBC,MAAAA,KAAK,EAAEP,MAAM,CAACQ,MAAP,GAAgB;AACvBP,MAAAA,QAAQ,EAAEA;AACVF,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBU,MAAAA,QAAQ,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;;;;"}
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/f36-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 {\n FieldAPI,\n FieldConnector,\n ConstraintsUtils,\n CharCounter,\n CharValidation,\n LocalesAPI,\n} from '@contentful/field-editor-shared';\nimport * as styles from './styles';\n\nimport { TextInput } from '@contentful/f36-components';\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 isRequired={field.required}\n isInvalid={errors.length > 0}\n isDisabled={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","isRequired","required","isInvalid","length","isDisabled","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;;ACuBP,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,MAAME,WAAW,GAAGC,gBAAgB,CAACC,oBAAjB,CAAsCN,KAAK,CAACO,WAA5C,EAAyDP,KAAK,CAACE,IAA/D,CAApB;AACA,MAAMM,eAAe,GAAGH,gBAAgB,CAACI,WAAjB,CAA6BL,WAA7B,CAAxB;AACA,MAAMT,SAAS,GAAGM,OAAO,CAACN,SAAR,CAAkBK,KAAK,CAACU,MAAxB,KAAmC,KAArD;AAEA,SACEC,aAAA,CAACC,cAAD;AAAwBZ,IAAAA,KAA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  "name": "@contentful/field-editor-single-line",
3
- "version": "0.15.4",
3
+ "version": "1.0.0",
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.24.0",
25
- "@contentful/forma-36-react-components": "^3.93.4",
26
- "@contentful/forma-36-tokens": "^0.11.0",
24
+ "@contentful/f36-components": "beta",
25
+ "@contentful/f36-tokens": "beta",
26
+ "@contentful/field-editor-shared": "^1.0.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.3"
32
+ "@contentful/field-editor-test-utils": "^1.0.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=16.8.0"
@@ -44,5 +44,5 @@
44
44
  }
45
45
  }
46
46
  },
47
- "gitHead": "f5450f62e92802984fb32a4dd28f266aabbdd5d7"
47
+ "gitHead": "538c2239a48991e4bb281d4d07d8ede3413492a5"
48
48
  }