@contentful/field-editor-list 1.4.33 → 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.
@@ -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,
@@ -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.4.33",
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",
@@ -50,5 +50,5 @@
50
50
  "publishConfig": {
51
51
  "registry": "https://npm.pkg.github.com/"
52
52
  },
53
- "gitHead": "1d0dc6dc10cf4ad43aa48b04fa67d29ab7edaee8"
53
+ "gitHead": "7ec565308c8d4da384b8fec6f5d840bdf6d4927d"
54
54
  }