@contentful/field-editor-tags 1.4.34 → 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/TagsEditor.js +5 -4
- package/dist/cjs/TagsEditorConstraints.js +1 -1
- package/dist/cjs/TagsEditorContainer.js +11 -10
- package/dist/cjs/TagsEditorContainer.spec.js +1 -1
- package/dist/esm/TagsEditor.js +2 -1
- package/dist/esm/TagsEditorContainer.js +9 -8
- package/dist/types/TagsEditor.d.ts +2 -1
- package/dist/types/TagsEditorContainer.d.ts +6 -2
- package/package.json +3 -3
package/dist/cjs/TagsEditor.js
CHANGED
|
@@ -8,15 +8,15 @@ Object.defineProperty(exports, "TagsEditor", {
|
|
|
8
8
|
return TagsEditor;
|
|
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
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
13
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
14
14
|
const _core = require("@dnd-kit/core");
|
|
15
15
|
const _modifiers = require("@dnd-kit/modifiers");
|
|
16
16
|
const _sortable = require("@dnd-kit/sortable");
|
|
17
17
|
const _utilities = require("@dnd-kit/utilities");
|
|
18
18
|
const _emotion = require("emotion");
|
|
19
|
-
const _noop = _interop_require_default(require("lodash/noop"));
|
|
19
|
+
const _noop = /*#__PURE__*/ _interop_require_default(require("lodash/noop"));
|
|
20
20
|
const _TagsEditorConstraints = require("./TagsEditorConstraints");
|
|
21
21
|
function _interop_require_default(obj) {
|
|
22
22
|
return obj && obj.__esModule ? obj : {
|
|
@@ -117,7 +117,7 @@ const SortablePill = ({ id, label, index, disabled, onRemove })=>{
|
|
|
117
117
|
};
|
|
118
118
|
function TagsEditor(props) {
|
|
119
119
|
const [pendingValue, setPendingValue] = (0, _react.useState)('');
|
|
120
|
-
const { isDisabled, items, constraints, constraintsType, hasError, onUpdate } = props;
|
|
120
|
+
const { isDisabled, items, constraints, constraintsType, hasError, onUpdate, id } = props;
|
|
121
121
|
const itemsMap = _react.default.useMemo(()=>items.map((item, index)=>({
|
|
122
122
|
id: item + index,
|
|
123
123
|
value: item
|
|
@@ -147,6 +147,7 @@ function TagsEditor(props) {
|
|
|
147
147
|
"data-test-id": "tag-editor-container"
|
|
148
148
|
}, _react.default.createElement(_f36components.TextInput, {
|
|
149
149
|
testId: "tag-editor-input",
|
|
150
|
+
id: id,
|
|
150
151
|
className: styles.input,
|
|
151
152
|
isDisabled: isDisabled,
|
|
152
153
|
isInvalid: hasError,
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "TagsEditorConstraints", {
|
|
|
8
8
|
return TagsEditorConstraints;
|
|
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 _emotion = require("emotion");
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) {
|
|
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "TagsEditorContainer", {
|
|
|
8
8
|
return TagsEditorContainer;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _fieldeditorshared = require("@contentful/field-editor-shared");
|
|
13
|
-
const _isNumber = _interop_require_default(require("lodash/isNumber"));
|
|
13
|
+
const _isNumber = /*#__PURE__*/ _interop_require_default(require("lodash/isNumber"));
|
|
14
14
|
const _TagsEditor = require("./TagsEditor");
|
|
15
15
|
function _interop_require_default(obj) {
|
|
16
16
|
return obj && obj.__esModule ? obj : {
|
|
@@ -62,33 +62,34 @@ function isEmptyTagsValue(value) {
|
|
|
62
62
|
return value === null || value.length === 0;
|
|
63
63
|
}
|
|
64
64
|
function getConstraintsType(sizeConstraints) {
|
|
65
|
-
if (!sizeConstraints) {
|
|
65
|
+
if (!sizeConstraints || !(0, _isNumber.default)(sizeConstraints.min) && !(0, _isNumber.default)(sizeConstraints.max)) {
|
|
66
66
|
return undefined;
|
|
67
67
|
}
|
|
68
68
|
if ((0, _isNumber.default)(sizeConstraints.min) && (0, _isNumber.default)(sizeConstraints.max)) {
|
|
69
69
|
return 'min-max';
|
|
70
|
-
}
|
|
70
|
+
}
|
|
71
|
+
if ((0, _isNumber.default)(sizeConstraints.min)) {
|
|
71
72
|
return 'min';
|
|
72
|
-
}
|
|
73
|
+
}
|
|
74
|
+
if ((0, _isNumber.default)(sizeConstraints.max)) {
|
|
73
75
|
return 'max';
|
|
74
|
-
} else {
|
|
75
|
-
return undefined;
|
|
76
76
|
}
|
|
77
|
+
return undefined;
|
|
77
78
|
}
|
|
78
|
-
function TagsEditorContainer(
|
|
79
|
-
const field = props.field;
|
|
79
|
+
function TagsEditorContainer({ isInitiallyDisabled, field, id }) {
|
|
80
80
|
const validations = field.validations || [];
|
|
81
81
|
const sizeValidations = validations.filter((validation)=>validation.size).map((validation)=>validation.size);
|
|
82
82
|
const constraints = sizeValidations.length > 0 ? sizeValidations[0] : {};
|
|
83
83
|
const constraintsType = getConstraintsType(constraints);
|
|
84
84
|
return _react.createElement(_fieldeditorshared.FieldConnector, {
|
|
85
85
|
field: field,
|
|
86
|
-
isInitiallyDisabled:
|
|
86
|
+
isInitiallyDisabled: isInitiallyDisabled,
|
|
87
87
|
isEmptyValue: isEmptyTagsValue,
|
|
88
88
|
debounce: 0
|
|
89
89
|
}, ({ disabled, value, errors, setValue })=>{
|
|
90
90
|
const items = value || [];
|
|
91
91
|
return _react.createElement(_TagsEditor.TagsEditor, {
|
|
92
|
+
id: id,
|
|
92
93
|
constraints: constraints,
|
|
93
94
|
constraintsType: constraintsType,
|
|
94
95
|
isDisabled: disabled,
|
|
@@ -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/TagsEditor.js
CHANGED
|
@@ -61,7 +61,7 @@ const SortablePill = ({ id, label, index, disabled, onRemove })=>{
|
|
|
61
61
|
};
|
|
62
62
|
export function TagsEditor(props) {
|
|
63
63
|
const [pendingValue, setPendingValue] = useState('');
|
|
64
|
-
const { isDisabled, items, constraints, constraintsType, hasError, onUpdate } = props;
|
|
64
|
+
const { isDisabled, items, constraints, constraintsType, hasError, onUpdate, id } = props;
|
|
65
65
|
const itemsMap = React.useMemo(()=>items.map((item, index)=>({
|
|
66
66
|
id: item + index,
|
|
67
67
|
value: item
|
|
@@ -91,6 +91,7 @@ export function TagsEditor(props) {
|
|
|
91
91
|
"data-test-id": "tag-editor-container"
|
|
92
92
|
}, React.createElement(TextInput, {
|
|
93
93
|
testId: "tag-editor-input",
|
|
94
|
+
id: id,
|
|
94
95
|
className: styles.input,
|
|
95
96
|
isDisabled: isDisabled,
|
|
96
97
|
isInvalid: hasError,
|
|
@@ -6,33 +6,34 @@ function isEmptyTagsValue(value) {
|
|
|
6
6
|
return value === null || value.length === 0;
|
|
7
7
|
}
|
|
8
8
|
function getConstraintsType(sizeConstraints) {
|
|
9
|
-
if (!sizeConstraints) {
|
|
9
|
+
if (!sizeConstraints || !isNumber(sizeConstraints.min) && !isNumber(sizeConstraints.max)) {
|
|
10
10
|
return undefined;
|
|
11
11
|
}
|
|
12
12
|
if (isNumber(sizeConstraints.min) && isNumber(sizeConstraints.max)) {
|
|
13
13
|
return 'min-max';
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
|
+
if (isNumber(sizeConstraints.min)) {
|
|
15
16
|
return 'min';
|
|
16
|
-
}
|
|
17
|
+
}
|
|
18
|
+
if (isNumber(sizeConstraints.max)) {
|
|
17
19
|
return 'max';
|
|
18
|
-
} else {
|
|
19
|
-
return undefined;
|
|
20
20
|
}
|
|
21
|
+
return undefined;
|
|
21
22
|
}
|
|
22
|
-
export function TagsEditorContainer(
|
|
23
|
-
const field = props.field;
|
|
23
|
+
export function TagsEditorContainer({ isInitiallyDisabled, field, id }) {
|
|
24
24
|
const validations = field.validations || [];
|
|
25
25
|
const sizeValidations = validations.filter((validation)=>validation.size).map((validation)=>validation.size);
|
|
26
26
|
const constraints = sizeValidations.length > 0 ? sizeValidations[0] : {};
|
|
27
27
|
const constraintsType = getConstraintsType(constraints);
|
|
28
28
|
return React.createElement(FieldConnector, {
|
|
29
29
|
field: field,
|
|
30
|
-
isInitiallyDisabled:
|
|
30
|
+
isInitiallyDisabled: isInitiallyDisabled,
|
|
31
31
|
isEmptyValue: isEmptyTagsValue,
|
|
32
32
|
debounce: 0
|
|
33
33
|
}, ({ disabled, value, errors, setValue })=>{
|
|
34
34
|
const items = value || [];
|
|
35
35
|
return React.createElement(TagsEditor, {
|
|
36
|
+
id: id,
|
|
36
37
|
constraints: constraints,
|
|
37
38
|
constraintsType: constraintsType,
|
|
38
39
|
isDisabled: disabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Constraint, ConstraintsType } from './types';
|
|
2
|
+
import type { Constraint, ConstraintsType } from './types';
|
|
3
3
|
export interface TagsEditorProps {
|
|
4
4
|
items: string[];
|
|
5
5
|
isDisabled: boolean;
|
|
@@ -7,5 +7,6 @@ export interface TagsEditorProps {
|
|
|
7
7
|
constraintsType?: ConstraintsType;
|
|
8
8
|
constraints?: Constraint;
|
|
9
9
|
onUpdate: (items: string[]) => void;
|
|
10
|
+
id?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare function TagsEditor(props: TagsEditorProps): React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FieldAPI } from '@contentful/field-editor-shared';
|
|
2
|
+
import { type FieldAPI } from '@contentful/field-editor-shared';
|
|
3
3
|
export interface TagsEditorContainerProps {
|
|
4
4
|
/**
|
|
5
5
|
* is the field disabled initially
|
|
@@ -9,8 +9,12 @@ export interface TagsEditorContainerProps {
|
|
|
9
9
|
* sdk.field
|
|
10
10
|
*/
|
|
11
11
|
field: FieldAPI;
|
|
12
|
+
/**
|
|
13
|
+
* id used for associating the input field with its label
|
|
14
|
+
*/
|
|
15
|
+
id?: string;
|
|
12
16
|
}
|
|
13
|
-
export declare function TagsEditorContainer(
|
|
17
|
+
export declare function TagsEditorContainer({ isInitiallyDisabled, field, id }: TagsEditorContainerProps): React.JSX.Element;
|
|
14
18
|
export declare namespace TagsEditorContainer {
|
|
15
19
|
var defaultProps: {
|
|
16
20
|
isInitiallyDisabled: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-tags",
|
|
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",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@contentful/f36-components": "^4.70.0",
|
|
39
39
|
"@contentful/f36-icons": "^4.29.0",
|
|
40
40
|
"@contentful/f36-tokens": "^4.0.5",
|
|
41
|
-
"@contentful/field-editor-shared": "^2.4.
|
|
41
|
+
"@contentful/field-editor-shared": "^2.4.1",
|
|
42
42
|
"@dnd-kit/core": "^6.0.8",
|
|
43
43
|
"@dnd-kit/modifiers": "^7.0.0",
|
|
44
44
|
"@dnd-kit/sortable": "^8.0.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"registry": "https://npm.pkg.github.com/"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "7ec565308c8d4da384b8fec6f5d840bdf6d4927d"
|
|
58
58
|
}
|