@contentful/field-editor-single-line 0.15.3 → 0.16.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 +20 -83
- package/README.md +0 -1
- package/dist/field-editor-single-line.cjs.development.js +6 -6
- package/dist/field-editor-single-line.cjs.development.js.map +1 -1
- package/dist/field-editor-single-line.cjs.production.min.js +1 -1
- package/dist/field-editor-single-line.cjs.production.min.js.map +1 -1
- package/dist/field-editor-single-line.esm.js +5 -5
- package/dist/field-editor-single-line.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,180 +3,117 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
6
|
+
# [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)
|
|
9
7
|
|
|
8
|
+
### Features
|
|
10
9
|
|
|
10
|
+
- Forma v4 components adoption ([#805](https://github.com/contentful/field-editors/issues/805)) ([526bde6](https://github.com/contentful/field-editors/commit/526bde6e10e0ee3789705ec10fb31489af7ca59e))
|
|
11
11
|
|
|
12
|
+
### BREAKING CHANGES
|
|
12
13
|
|
|
14
|
+
- adopts a new Forma v4 beta
|
|
13
15
|
|
|
14
|
-
## [0.15.
|
|
16
|
+
## [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)
|
|
15
17
|
|
|
16
18
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
17
19
|
|
|
20
|
+
## [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)
|
|
18
21
|
|
|
22
|
+
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
19
23
|
|
|
24
|
+
## [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)
|
|
20
25
|
|
|
26
|
+
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
21
27
|
|
|
22
|
-
## [0.15.
|
|
28
|
+
## [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)
|
|
23
29
|
|
|
24
30
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
25
31
|
|
|
32
|
+
## [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)
|
|
26
33
|
|
|
34
|
+
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
27
35
|
|
|
36
|
+
## [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)
|
|
28
37
|
|
|
38
|
+
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
29
39
|
|
|
30
40
|
# [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)
|
|
31
41
|
|
|
32
|
-
|
|
33
42
|
### Features
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
- 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
|
|
40
45
|
|
|
41
46
|
## [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)
|
|
42
47
|
|
|
43
48
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
50
|
## [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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
90
71
|
|
|
91
|
-
|
|
92
72
|
### Features
|
|
93
73
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
- bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
|
|
99
75
|
|
|
100
76
|
## [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)
|
|
101
77
|
|
|
102
78
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
103
79
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
80
|
## [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)
|
|
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.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)
|
|
117
85
|
|
|
118
|
-
|
|
119
86
|
### Features
|
|
120
87
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
88
|
+
- 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))
|
|
126
89
|
|
|
127
90
|
# [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)
|
|
128
91
|
|
|
129
|
-
|
|
130
92
|
### Features
|
|
131
93
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
94
|
+
- 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))
|
|
137
95
|
|
|
138
96
|
## [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)
|
|
139
97
|
|
|
140
98
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
141
99
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
100
|
## [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)
|
|
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.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)
|
|
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.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)
|
|
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.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)
|
|
171
113
|
|
|
172
|
-
|
|
173
114
|
### Features
|
|
174
115
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
116
|
+
- 🎸 add withCharValidation property to hide validation ([#390](https://github.com/contentful/field-editors/issues/390)) ([9da6700](https://github.com/contentful/field-editors/commit/9da67005f83c1cebdabb67edfed73f7d1dcbfc04))
|
|
180
117
|
|
|
181
118
|
## [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)
|
|
182
119
|
|
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/
|
|
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(
|
|
50
|
+
}, React.createElement(f36Components.TextInput, {
|
|
51
51
|
className: direction === 'rtl' ? rightToLeft : '',
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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/
|
|
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,C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KAAV,CAAR;AACD;KARH,CADF,EAWGf,KAAK,CAAC8B,kBAAN,IACClB,mBAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,mBAAA,CAACmB,6BAAD;AAAahB,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,mBAAA,CAACoB,gCAAD;AAAgB3B,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAZJ,EAiBGL,KAAK,CAAC8B,kBAAN,KAA6B,KAA7B,IACClB,mBAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,mBAAA,CAACmB,6BAAD;AAAahB,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAlBJ,CADF;AAyBD,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/
|
|
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/
|
|
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/
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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/
|
|
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,S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UAAU,EAAET;AACZF,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAChBY,MAAAA,QAAQ,EAAE,kBAACC,CAAD;AACRV,QAAAA,QAAQ,CAACU,CAAC,CAACC,MAAF,CAASd,KAAV,CAAR;AACD;KARH,CADF,EAWGf,KAAK,CAAC8B,kBAAN,IACClB,aAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,aAAA,CAACmB,WAAD;AAAahB,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAEA;KAAlD,CADF,EAEEG,aAAA,CAACoB,cAAD;AAAgB3B,MAAAA,WAAW,EAAEA;KAA7B,CAFF,CAZJ,EAiBGL,KAAK,CAAC8B,kBAAN,KAA6B,KAA7B,IACClB,aAAA,MAAA;AAAKQ,MAAAA,SAAS,EAAEC;KAAhB,EACET,aAAA,CAACmB,WAAD;AAAahB,MAAAA,KAAK,EAAEA,KAAK,IAAI;AAAIN,MAAAA,eAAe,EAAE;AAAA,eAAM,IAAN;AAAA;KAAlD,CADF,CAlBJ,CADF;AAyBD,GA3BH,CADF;AA+BD;AAEDV,gBAAgB,CAACkC,YAAjB,GAAgC;AAC9BnB,EAAAA,mBAAmB,EAAE,IADS;AAE9BgB,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.
|
|
3
|
+
"version": "0.16.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/
|
|
25
|
-
"@contentful/
|
|
26
|
-
"@contentful/
|
|
24
|
+
"@contentful/f36-components": "beta",
|
|
25
|
+
"@contentful/f36-tokens": "beta",
|
|
26
|
+
"@contentful/field-editor-shared": "^0.26.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.
|
|
32
|
+
"@contentful/field-editor-test-utils": "^0.19.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=16.8.0"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "f86ba28db3f34cffc0dc2580bf21297542f331c9"
|
|
48
48
|
}
|