@contentful/field-editor-rating 1.6.12 → 1.6.13
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/RatingEditor.js +3 -7
- package/dist/cjs/RatingEditor.spec.js +3 -3
- package/dist/cjs/RatingRibbon.js +4 -2
- package/dist/esm/RatingEditor.js +3 -7
- package/dist/esm/RatingEditor.spec.js +3 -3
- package/dist/esm/RatingRibbon.js +4 -2
- package/dist/types/RatingEditor.d.ts +1 -6
- package/package.json +2 -2
package/dist/cjs/RatingEditor.js
CHANGED
|
@@ -73,16 +73,15 @@ function getStarCount(count) {
|
|
|
73
73
|
return defaultValue;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
function RatingEditor(
|
|
77
|
-
const
|
|
78
|
-
const starsCount = getStarCount((0, _get.default)(props.parameters, [
|
|
76
|
+
function RatingEditor({ field, parameters, isInitiallyDisabled = true }) {
|
|
77
|
+
const starsCount = getStarCount((0, _get.default)(parameters, [
|
|
79
78
|
'instance',
|
|
80
79
|
'stars'
|
|
81
80
|
]));
|
|
82
81
|
return /*#__PURE__*/ _react.createElement(_fieldeditorshared.FieldConnector, {
|
|
83
82
|
debounce: 0,
|
|
84
83
|
field: field,
|
|
85
|
-
isInitiallyDisabled:
|
|
84
|
+
isInitiallyDisabled: isInitiallyDisabled
|
|
86
85
|
}, ({ disabled, value, setValue })=>{
|
|
87
86
|
const clearOption = ()=>{
|
|
88
87
|
setValue(null);
|
|
@@ -107,6 +106,3 @@ function RatingEditor(props) {
|
|
|
107
106
|
}, "Clear")));
|
|
108
107
|
});
|
|
109
108
|
}
|
|
110
|
-
RatingEditor.defaultProps = {
|
|
111
|
-
isInitiallyDisabled: true
|
|
112
|
-
};
|
|
@@ -76,7 +76,7 @@ describe('RatingEditor', ()=>{
|
|
|
76
76
|
}));
|
|
77
77
|
expect(getAllByTestId('rating-editor-star')).toHaveLength(20);
|
|
78
78
|
});
|
|
79
|
-
it('should
|
|
79
|
+
it('should setValue by clicking on a item and removeValue by clicking on clear', ()=>{
|
|
80
80
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
81
81
|
jest.spyOn(field, 'setValue');
|
|
82
82
|
jest.spyOn(field, 'removeValue');
|
|
@@ -92,11 +92,11 @@ describe('RatingEditor', ()=>{
|
|
|
92
92
|
expect(queryByTestId('rating-editor-clean')).not.toBeInTheDocument();
|
|
93
93
|
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(0);
|
|
94
94
|
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(5);
|
|
95
|
-
_react1.fireEvent.
|
|
95
|
+
_react1.fireEvent.mouseDown($stars[4]);
|
|
96
96
|
expect(field.setValue).toHaveBeenCalledWith(5);
|
|
97
97
|
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(5);
|
|
98
98
|
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(0);
|
|
99
|
-
_react1.fireEvent.
|
|
99
|
+
_react1.fireEvent.mouseDown($stars[0]);
|
|
100
100
|
expect(field.setValue).toHaveBeenCalledWith(1);
|
|
101
101
|
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(1);
|
|
102
102
|
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(4);
|
package/dist/cjs/RatingRibbon.js
CHANGED
|
@@ -92,8 +92,10 @@ class RatingRibbon extends _react.Component {
|
|
|
92
92
|
testId: "rating-editor-star",
|
|
93
93
|
isDisabled: this.props.disabled,
|
|
94
94
|
key: num,
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
onMouseDown: (e)=>{
|
|
96
|
+
if (e.button === 0) {
|
|
97
|
+
this.props.onSelect(num);
|
|
98
|
+
}
|
|
97
99
|
},
|
|
98
100
|
onKeyDown: (e)=>{
|
|
99
101
|
if (e.keyCode === 13) {
|
package/dist/esm/RatingEditor.js
CHANGED
|
@@ -17,16 +17,15 @@ function getStarCount(count) {
|
|
|
17
17
|
return defaultValue;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export function RatingEditor(
|
|
21
|
-
const
|
|
22
|
-
const starsCount = getStarCount(get(props.parameters, [
|
|
20
|
+
export function RatingEditor({ field, parameters, isInitiallyDisabled = true }) {
|
|
21
|
+
const starsCount = getStarCount(get(parameters, [
|
|
23
22
|
'instance',
|
|
24
23
|
'stars'
|
|
25
24
|
]));
|
|
26
25
|
return /*#__PURE__*/ React.createElement(FieldConnector, {
|
|
27
26
|
debounce: 0,
|
|
28
27
|
field: field,
|
|
29
|
-
isInitiallyDisabled:
|
|
28
|
+
isInitiallyDisabled: isInitiallyDisabled
|
|
30
29
|
}, ({ disabled, value, setValue })=>{
|
|
31
30
|
const clearOption = ()=>{
|
|
32
31
|
setValue(null);
|
|
@@ -51,6 +50,3 @@ export function RatingEditor(props) {
|
|
|
51
50
|
}, "Clear")));
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
|
-
RatingEditor.defaultProps = {
|
|
55
|
-
isInitiallyDisabled: true
|
|
56
|
-
};
|
|
@@ -31,7 +31,7 @@ describe('RatingEditor', ()=>{
|
|
|
31
31
|
}));
|
|
32
32
|
expect(getAllByTestId('rating-editor-star')).toHaveLength(20);
|
|
33
33
|
});
|
|
34
|
-
it('should
|
|
34
|
+
it('should setValue by clicking on a item and removeValue by clicking on clear', ()=>{
|
|
35
35
|
const [field] = createFakeFieldAPI((field)=>{
|
|
36
36
|
jest.spyOn(field, 'setValue');
|
|
37
37
|
jest.spyOn(field, 'removeValue');
|
|
@@ -47,11 +47,11 @@ describe('RatingEditor', ()=>{
|
|
|
47
47
|
expect(queryByTestId('rating-editor-clean')).not.toBeInTheDocument();
|
|
48
48
|
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(0);
|
|
49
49
|
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(5);
|
|
50
|
-
fireEvent.
|
|
50
|
+
fireEvent.mouseDown($stars[4]);
|
|
51
51
|
expect(field.setValue).toHaveBeenCalledWith(5);
|
|
52
52
|
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(5);
|
|
53
53
|
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(0);
|
|
54
|
-
fireEvent.
|
|
54
|
+
fireEvent.mouseDown($stars[0]);
|
|
55
55
|
expect(field.setValue).toHaveBeenCalledWith(1);
|
|
56
56
|
expect(container.querySelectorAll('[data-selected="true"]')).toHaveLength(1);
|
|
57
57
|
expect(container.querySelectorAll('[data-selected="false"]')).toHaveLength(4);
|
package/dist/esm/RatingRibbon.js
CHANGED
|
@@ -36,8 +36,10 @@ export class RatingRibbon extends React.Component {
|
|
|
36
36
|
testId: "rating-editor-star",
|
|
37
37
|
isDisabled: this.props.disabled,
|
|
38
38
|
key: num,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
onMouseDown: (e)=>{
|
|
40
|
+
if (e.button === 0) {
|
|
41
|
+
this.props.onSelect(num);
|
|
42
|
+
}
|
|
41
43
|
},
|
|
42
44
|
onKeyDown: (e)=>{
|
|
43
45
|
if (e.keyCode === 13) {
|
|
@@ -16,9 +16,4 @@ export interface RatingEditorProps {
|
|
|
16
16
|
stars?: number;
|
|
17
17
|
}, Record<string, any>>;
|
|
18
18
|
}
|
|
19
|
-
export declare function RatingEditor(
|
|
20
|
-
export declare namespace RatingEditor {
|
|
21
|
-
var defaultProps: {
|
|
22
|
-
isInitiallyDisabled: boolean;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
19
|
+
export declare function RatingEditor({ field, parameters, isInitiallyDisabled }: RatingEditorProps): React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rating",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.13",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"registry": "https://npm.pkg.github.com/"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "4a141050daf3f4a09adfe024e21bd7c30ad949c6"
|
|
57
57
|
}
|