@contentful/field-editor-single-line 0.15.5 → 1.0.1
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 +22 -91
- 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,196 +3,127 @@
|
|
|
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.
|
|
6
|
+
## [1.0.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-single-line@1.0.0...@contentful/field-editor-single-line@1.0.1) (2021-11-17)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
### Bug Fixes
|
|
9
9
|
|
|
10
|
+
- **card-actions:** update forma 36 to fix card actions click issue ([#927](https://github.com/contentful/field-editors/issues/927)) ([3dfdef2](https://github.com/contentful/field-editors/commit/3dfdef2c2b0045f12ea94ddafca89a8e9f25e7d0))
|
|
10
11
|
|
|
12
|
+
# [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)
|
|
11
13
|
|
|
14
|
+
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
12
15
|
|
|
16
|
+
# [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)
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
### Features
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
- Forma v4 components adoption ([#805](https://github.com/contentful/field-editors/issues/805)) ([526bde6](https://github.com/contentful/field-editors/commit/526bde6e10e0ee3789705ec10fb31489af7ca59e))
|
|
17
21
|
|
|
22
|
+
### BREAKING CHANGES
|
|
18
23
|
|
|
24
|
+
- adopts a new Forma v4 beta
|
|
19
25
|
|
|
26
|
+
## [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)
|
|
20
27
|
|
|
28
|
+
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
21
29
|
|
|
22
|
-
## [0.15.
|
|
30
|
+
## [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)
|
|
23
31
|
|
|
24
32
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
25
33
|
|
|
34
|
+
## [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)
|
|
26
35
|
|
|
36
|
+
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
27
37
|
|
|
38
|
+
## [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)
|
|
28
39
|
|
|
40
|
+
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
29
41
|
|
|
30
42
|
## [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)
|
|
31
43
|
|
|
32
44
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
33
45
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
46
|
## [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)
|
|
39
47
|
|
|
40
48
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
50
|
# [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)
|
|
47
51
|
|
|
48
|
-
|
|
49
52
|
### Features
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
- 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
|
|
56
55
|
|
|
57
56
|
## [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)
|
|
58
57
|
|
|
59
58
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
60
|
## [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)
|
|
66
61
|
|
|
67
62
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
64
|
## [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)
|
|
74
65
|
|
|
75
66
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
76
67
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
68
|
## [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)
|
|
82
69
|
|
|
83
70
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
84
71
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
72
|
## [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)
|
|
90
73
|
|
|
91
74
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
92
75
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
76
|
## [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)
|
|
98
77
|
|
|
99
78
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
100
79
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
80
|
# [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)
|
|
106
81
|
|
|
107
|
-
|
|
108
82
|
### Features
|
|
109
83
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
84
|
+
- bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
|
|
115
85
|
|
|
116
86
|
## [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)
|
|
117
87
|
|
|
118
88
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
119
89
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
90
|
## [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)
|
|
125
91
|
|
|
126
92
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
127
93
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
94
|
# [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)
|
|
133
95
|
|
|
134
|
-
|
|
135
96
|
### Features
|
|
136
97
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
98
|
+
- 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))
|
|
142
99
|
|
|
143
100
|
# [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)
|
|
144
101
|
|
|
145
|
-
|
|
146
102
|
### Features
|
|
147
103
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
104
|
+
- 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))
|
|
153
105
|
|
|
154
106
|
## [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)
|
|
155
107
|
|
|
156
108
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
157
109
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
110
|
## [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)
|
|
163
111
|
|
|
164
112
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
165
113
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
114
|
## [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)
|
|
171
115
|
|
|
172
116
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
173
117
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
118
|
## [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)
|
|
179
119
|
|
|
180
120
|
**Note:** Version bump only for package @contentful/field-editor-single-line
|
|
181
121
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
122
|
# [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)
|
|
187
123
|
|
|
188
|
-
|
|
189
124
|
### Features
|
|
190
125
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
126
|
+
- 🎸 add withCharValidation property to hide validation ([#390](https://github.com/contentful/field-editors/issues/390)) ([9da6700](https://github.com/contentful/field-editors/commit/9da67005f83c1cebdabb67edfed73f7d1dcbfc04))
|
|
196
127
|
|
|
197
128
|
## [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)
|
|
198
129
|
|
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,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,kCAAgB,CAACI,WAAjB,CAA6BL,WAA7B,CAAxB;AACA,MAAMT,SAAS,GAAGM,OAAO,CAACN,SAAR,CAAkBK,KAAK,CAACU,MAAxB,KAAmC,KAArD;AAEA,SACEC,mBAAA,CAACC,g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@ -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,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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;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": "1.0.1",
|
|
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": "^4.0.1-beta.2527",
|
|
25
|
+
"@contentful/f36-tokens": "^4.0.1-beta.2527",
|
|
26
|
+
"@contentful/field-editor-shared": "^1.0.1",
|
|
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": "^1.0.1"
|
|
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": "3dc7130a751de690903c572edfcdfdf3587b57bf"
|
|
48
48
|
}
|