@contentful/field-editor-list 1.4.32 → 1.5.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/dist/cjs/ListEditor.js
CHANGED
|
@@ -8,11 +8,11 @@ Object.defineProperty(exports, "ListEditor", {
|
|
|
8
8
|
return ListEditor;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
13
|
const _fieldeditorshared = require("@contentful/field-editor-shared");
|
|
14
|
-
const _isEqual = _interop_require_default(require("lodash/isEqual"));
|
|
15
|
-
const _styles = _interop_require_wildcard(require("./styles"));
|
|
14
|
+
const _isEqual = /*#__PURE__*/ _interop_require_default(require("lodash/isEqual"));
|
|
15
|
+
const _styles = /*#__PURE__*/ _interop_require_wildcard(require("./styles"));
|
|
16
16
|
function _interop_require_default(obj) {
|
|
17
17
|
return obj && obj.__esModule ? obj : {
|
|
18
18
|
default: obj
|
|
@@ -63,7 +63,7 @@ function isEmptyListValue(value) {
|
|
|
63
63
|
return value === null || value.length === 0;
|
|
64
64
|
}
|
|
65
65
|
function ListEditor(props) {
|
|
66
|
-
const { field, locales } = props;
|
|
66
|
+
const { field, locales, id } = props;
|
|
67
67
|
const direction = locales.direction[field.locale] || 'ltr';
|
|
68
68
|
return _react.createElement(_fieldeditorshared.FieldConnector, {
|
|
69
69
|
debounce: 0,
|
|
@@ -73,10 +73,11 @@ function ListEditor(props) {
|
|
|
73
73
|
}, (childProps)=>_react.createElement(ListEditorInternal, {
|
|
74
74
|
...childProps,
|
|
75
75
|
direction: direction,
|
|
76
|
-
isRequired: field.required
|
|
76
|
+
isRequired: field.required,
|
|
77
|
+
id: id
|
|
77
78
|
}));
|
|
78
79
|
}
|
|
79
|
-
function ListEditorInternal({ setValue, value, errors, disabled, direction, isRequired }) {
|
|
80
|
+
function ListEditorInternal({ setValue, value, errors, disabled, direction, isRequired, id }) {
|
|
80
81
|
const [valueState, setValueState] = _react.useState(()=>(value || []).join(', '));
|
|
81
82
|
const onChange = (e)=>{
|
|
82
83
|
const valueAsArray = e.target.value.split(',').map((item)=>item.trim()).filter((item)=>item);
|
|
@@ -86,6 +87,7 @@ function ListEditorInternal({ setValue, value, errors, disabled, direction, isRe
|
|
|
86
87
|
setValueState(changed ? valueAsString : e.target.value);
|
|
87
88
|
};
|
|
88
89
|
return _react.createElement(_f36components.TextInput, {
|
|
90
|
+
id: id,
|
|
89
91
|
testId: "list-editor-input",
|
|
90
92
|
className: direction === 'rtl' ? _styles.rightToLeft : '',
|
|
91
93
|
isRequired: isRequired,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
5
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
6
|
const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
|
|
7
7
|
require("@testing-library/jest-dom/extend-expect");
|
|
8
8
|
const _react1 = require("@testing-library/react");
|
package/dist/esm/ListEditor.js
CHANGED
|
@@ -7,7 +7,7 @@ function isEmptyListValue(value) {
|
|
|
7
7
|
return value === null || value.length === 0;
|
|
8
8
|
}
|
|
9
9
|
export function ListEditor(props) {
|
|
10
|
-
const { field, locales } = props;
|
|
10
|
+
const { field, locales, id } = props;
|
|
11
11
|
const direction = locales.direction[field.locale] || 'ltr';
|
|
12
12
|
return React.createElement(FieldConnector, {
|
|
13
13
|
debounce: 0,
|
|
@@ -17,10 +17,11 @@ export function ListEditor(props) {
|
|
|
17
17
|
}, (childProps)=>React.createElement(ListEditorInternal, {
|
|
18
18
|
...childProps,
|
|
19
19
|
direction: direction,
|
|
20
|
-
isRequired: field.required
|
|
20
|
+
isRequired: field.required,
|
|
21
|
+
id: id
|
|
21
22
|
}));
|
|
22
23
|
}
|
|
23
|
-
function ListEditorInternal({ setValue, value, errors, disabled, direction, isRequired }) {
|
|
24
|
+
function ListEditorInternal({ setValue, value, errors, disabled, direction, isRequired, id }) {
|
|
24
25
|
const [valueState, setValueState] = React.useState(()=>(value || []).join(', '));
|
|
25
26
|
const onChange = (e)=>{
|
|
26
27
|
const valueAsArray = e.target.value.split(',').map((item)=>item.trim()).filter((item)=>item);
|
|
@@ -30,6 +31,7 @@ function ListEditorInternal({ setValue, value, errors, disabled, direction, isRe
|
|
|
30
31
|
setValueState(changed ? valueAsString : e.target.value);
|
|
31
32
|
};
|
|
32
33
|
return React.createElement(TextInput, {
|
|
34
|
+
id: id,
|
|
33
35
|
testId: "list-editor-input",
|
|
34
36
|
className: direction === 'rtl' ? styles.rightToLeft : '',
|
|
35
37
|
isRequired: isRequired,
|
|
@@ -13,6 +13,10 @@ export interface ListEditorProps {
|
|
|
13
13
|
* sdk.locales
|
|
14
14
|
*/
|
|
15
15
|
locales: LocalesAPI;
|
|
16
|
+
/**
|
|
17
|
+
* id used for associating the input field with its label
|
|
18
|
+
*/
|
|
19
|
+
id?: string;
|
|
16
20
|
}
|
|
17
21
|
export declare function ListEditor(props: ListEditorProps): React.JSX.Element;
|
|
18
22
|
export declare namespace ListEditor {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-list",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@contentful/f36-components": "^4.70.0",
|
|
39
39
|
"@contentful/f36-tokens": "^4.0.5",
|
|
40
|
-
"@contentful/field-editor-shared": "^2.4.
|
|
40
|
+
"@contentful/field-editor-shared": "^2.4.1",
|
|
41
41
|
"emotion": "^10.0.17",
|
|
42
42
|
"lodash": "^4.17.15"
|
|
43
43
|
},
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"registry": "https://npm.pkg.github.com/"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "7ec565308c8d4da384b8fec6f5d840bdf6d4927d"
|
|
54
54
|
}
|