@pie-lib/mask-markup 1.13.47-next.1 → 1.14.0-beta.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 +15 -56
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/choices/choice.js +80 -17
- package/lib/choices/choice.js.map +1 -1
- package/lib/choices/index.js +11 -3
- package/lib/choices/index.js.map +1 -1
- package/lib/components/blank.js +146 -34
- package/lib/components/blank.js.map +1 -1
- package/lib/components/correct-input.js +8 -3
- package/lib/components/correct-input.js.map +1 -1
- package/lib/components/dropdown.js +182 -49
- package/lib/components/dropdown.js.map +1 -1
- package/lib/constructed-response.js +87 -23
- package/lib/constructed-response.js.map +1 -1
- package/lib/customizable.js +48 -0
- package/lib/customizable.js.map +1 -0
- package/lib/drag-in-the-blank.js +34 -8
- package/lib/drag-in-the-blank.js.map +1 -1
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/inline-dropdown.js +3 -1
- package/lib/inline-dropdown.js.map +1 -1
- package/lib/mask.js +45 -6
- package/lib/mask.js.map +1 -1
- package/lib/with-mask.js +34 -2
- package/lib/with-mask.js.map +1 -1
- package/package.json +9 -5
- package/src/__tests__/__snapshots__/drag-in-the-blank.test.js.snap +316 -0
- package/src/__tests__/__snapshots__/mask.test.js.snap +55 -0
- package/src/__tests__/__snapshots__/with-mask.test.js.snap +62 -0
- package/src/__tests__/drag-in-the-blank.test.js +71 -0
- package/src/__tests__/index.test.js +39 -0
- package/src/__tests__/mask.test.js +152 -0
- package/src/__tests__/serialization.test.js +54 -0
- package/src/__tests__/utils.js +1 -0
- package/src/__tests__/with-mask.test.js +51 -0
- package/src/choices/__tests__/__snapshots__/index.test.js.snap +209 -0
- package/src/choices/__tests__/index.test.js +62 -0
- package/src/choices/choice.jsx +60 -6
- package/src/choices/index.jsx +2 -2
- package/src/components/__tests__/__snapshots__/blank.test.js.snap +111 -0
- package/src/components/__tests__/__snapshots__/correct-input.test.js.snap +64 -0
- package/src/components/__tests__/__snapshots__/dropdown.test.js.snap +133 -0
- package/src/components/__tests__/__snapshots__/input.test.js.snap +34 -0
- package/src/components/__tests__/blank.test.js +202 -0
- package/src/components/__tests__/correct-input.test.js +49 -0
- package/src/components/__tests__/dropdown.test.js +51 -0
- package/src/components/__tests__/input.test.js +50 -0
- package/src/components/blank.jsx +139 -28
- package/src/components/correct-input.jsx +6 -1
- package/src/components/dropdown.jsx +192 -71
- package/src/constructed-response.jsx +76 -18
- package/src/customizable.jsx +35 -0
- package/src/drag-in-the-blank.jsx +26 -3
- package/src/index.js +10 -1
- package/src/inline-dropdown.jsx +2 -0
- package/src/mask.jsx +30 -5
- package/src/with-mask.jsx +39 -2
- package/README.md +0 -14
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { deserialize } from '../serialization';
|
|
2
|
+
|
|
3
|
+
describe('serialization', () => {
|
|
4
|
+
it('ignores comments', () => {
|
|
5
|
+
const out = deserialize(`<!-- hi -->`);
|
|
6
|
+
expect(out.document.nodes[0]).toEqual(expect.objectContaining({ type: 'span' }));
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('ignores comments', () => {
|
|
10
|
+
const out = deserialize(`<!-- hi --><div>foo</div>`);
|
|
11
|
+
expect(out.document.nodes[0]).toEqual(
|
|
12
|
+
expect.objectContaining({
|
|
13
|
+
type: 'div',
|
|
14
|
+
nodes: [
|
|
15
|
+
expect.objectContaining({
|
|
16
|
+
object: 'text',
|
|
17
|
+
leaves: [{ text: 'foo' }],
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('deserializes an em', () => {
|
|
25
|
+
const out = deserialize(`<!-- hi --><div> <em>x</em> </div>`);
|
|
26
|
+
expect(out.document.nodes[0]).toEqual(
|
|
27
|
+
expect.objectContaining({
|
|
28
|
+
type: 'div',
|
|
29
|
+
nodes: [
|
|
30
|
+
expect.objectContaining({
|
|
31
|
+
object: 'text',
|
|
32
|
+
}),
|
|
33
|
+
expect.objectContaining({
|
|
34
|
+
leaves: [
|
|
35
|
+
{
|
|
36
|
+
marks: [
|
|
37
|
+
{
|
|
38
|
+
data: undefined,
|
|
39
|
+
type: 'italic',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
text: 'x',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
object: 'text',
|
|
46
|
+
}),
|
|
47
|
+
expect.objectContaining({
|
|
48
|
+
object: 'text',
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const choice = (v, id) => ({ label: v, value: v, id });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { withMask } from '../with-mask';
|
|
4
|
+
|
|
5
|
+
describe('WithMask', () => {
|
|
6
|
+
const onChange = jest.fn();
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
markup: '<p>Foo bar {{0}} over the moon;</p>',
|
|
9
|
+
value: {
|
|
10
|
+
0: 'blank',
|
|
11
|
+
},
|
|
12
|
+
onChange,
|
|
13
|
+
};
|
|
14
|
+
const Masked = withMask('foo', (props) => (node) => {
|
|
15
|
+
const dataset = node.data ? node.data.dataset || {} : {};
|
|
16
|
+
|
|
17
|
+
if (dataset.component === 'foo') {
|
|
18
|
+
return <input type="text" value="Foo" />;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
let wrapper;
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
wrapper = shallow(<Masked {...defaultProps} />);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('render', () => {
|
|
29
|
+
it('renders correctly with default props', () => {
|
|
30
|
+
expect(wrapper).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('onChange', () => {
|
|
35
|
+
const event = (value) => ({
|
|
36
|
+
target: { value },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should call the function', () => {
|
|
40
|
+
const e = event('ceva');
|
|
41
|
+
|
|
42
|
+
wrapper.simulate('change', e);
|
|
43
|
+
|
|
44
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
45
|
+
target: {
|
|
46
|
+
value: 'ceva',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`index Choice render renders correctly with default props 1`] = `
|
|
4
|
+
<BlankContentComp
|
|
5
|
+
classes={
|
|
6
|
+
Object {
|
|
7
|
+
"chip": "BlankContentComp-chip-2",
|
|
8
|
+
"chipLabel": "BlankContentComp-chipLabel-3",
|
|
9
|
+
"choice": "BlankContentComp-choice-1",
|
|
10
|
+
"disabled": "BlankContentComp-disabled-4",
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
disabled={false}
|
|
14
|
+
label="Label"
|
|
15
|
+
targetId="1"
|
|
16
|
+
value="1"
|
|
17
|
+
/>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`index Choice render renders correctly with disabled prop as true 1`] = `
|
|
21
|
+
<BlankContentComp
|
|
22
|
+
classes={
|
|
23
|
+
Object {
|
|
24
|
+
"chip": "BlankContentComp-chip-2",
|
|
25
|
+
"chipLabel": "BlankContentComp-chipLabel-3",
|
|
26
|
+
"choice": "BlankContentComp-choice-1",
|
|
27
|
+
"disabled": "BlankContentComp-disabled-4",
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
disabled={true}
|
|
31
|
+
label="Label"
|
|
32
|
+
targetId="1"
|
|
33
|
+
value="1"
|
|
34
|
+
/>
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
exports[`index Choices renders correctly with default props 1`] = `
|
|
38
|
+
<div
|
|
39
|
+
style={
|
|
40
|
+
Object {
|
|
41
|
+
"margin": "0 40px 0 0",
|
|
42
|
+
"minWidth": "100px",
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
<DropTarget(DroppablePlaceholder)
|
|
47
|
+
disabled={false}
|
|
48
|
+
>
|
|
49
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
50
|
+
choice={
|
|
51
|
+
Object {
|
|
52
|
+
"id": "0",
|
|
53
|
+
"label": "Jumped",
|
|
54
|
+
"value": "Jumped",
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
disabled={false}
|
|
58
|
+
key="Jumped-0"
|
|
59
|
+
/>
|
|
60
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
61
|
+
choice={
|
|
62
|
+
Object {
|
|
63
|
+
"id": "1",
|
|
64
|
+
"label": "Laughed",
|
|
65
|
+
"value": "Laughed",
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
disabled={false}
|
|
69
|
+
key="Laughed-1"
|
|
70
|
+
/>
|
|
71
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
72
|
+
choice={
|
|
73
|
+
Object {
|
|
74
|
+
"id": "2",
|
|
75
|
+
"label": "Spoon",
|
|
76
|
+
"value": "Spoon",
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
disabled={false}
|
|
80
|
+
key="Spoon-2"
|
|
81
|
+
/>
|
|
82
|
+
</DropTarget(DroppablePlaceholder)>
|
|
83
|
+
</div>
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`index Choices renders correctly with disabled prop as true 1`] = `
|
|
87
|
+
<div
|
|
88
|
+
style={
|
|
89
|
+
Object {
|
|
90
|
+
"margin": "0 40px 0 0",
|
|
91
|
+
"minWidth": "100px",
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
>
|
|
95
|
+
<DropTarget(DroppablePlaceholder)
|
|
96
|
+
disabled={true}
|
|
97
|
+
>
|
|
98
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
99
|
+
choice={
|
|
100
|
+
Object {
|
|
101
|
+
"id": "0",
|
|
102
|
+
"label": "Jumped",
|
|
103
|
+
"value": "Jumped",
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
disabled={true}
|
|
107
|
+
key="Jumped-0"
|
|
108
|
+
/>
|
|
109
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
110
|
+
choice={
|
|
111
|
+
Object {
|
|
112
|
+
"id": "1",
|
|
113
|
+
"label": "Laughed",
|
|
114
|
+
"value": "Laughed",
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
disabled={true}
|
|
118
|
+
key="Laughed-1"
|
|
119
|
+
/>
|
|
120
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
121
|
+
choice={
|
|
122
|
+
Object {
|
|
123
|
+
"id": "2",
|
|
124
|
+
"label": "Spoon",
|
|
125
|
+
"value": "Spoon",
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
disabled={true}
|
|
129
|
+
key="Spoon-2"
|
|
130
|
+
/>
|
|
131
|
+
</DropTarget(DroppablePlaceholder)>
|
|
132
|
+
</div>
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
exports[`index Choices renders with duplicates 1`] = `
|
|
136
|
+
<div
|
|
137
|
+
style={
|
|
138
|
+
Object {
|
|
139
|
+
"margin": "0 40px 0 0",
|
|
140
|
+
"minWidth": "100px",
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
>
|
|
144
|
+
<DropTarget(DroppablePlaceholder)
|
|
145
|
+
disabled={false}
|
|
146
|
+
>
|
|
147
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
148
|
+
choice={
|
|
149
|
+
Object {
|
|
150
|
+
"id": "0",
|
|
151
|
+
"label": "Jumped",
|
|
152
|
+
"value": "Jumped",
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
disabled={false}
|
|
156
|
+
key="Jumped-0"
|
|
157
|
+
/>
|
|
158
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
159
|
+
choice={
|
|
160
|
+
Object {
|
|
161
|
+
"id": "1",
|
|
162
|
+
"label": "Laughed",
|
|
163
|
+
"value": "Laughed",
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
disabled={false}
|
|
167
|
+
key="Laughed-1"
|
|
168
|
+
/>
|
|
169
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
170
|
+
choice={
|
|
171
|
+
Object {
|
|
172
|
+
"id": "2",
|
|
173
|
+
"label": "Spoon",
|
|
174
|
+
"value": "Spoon",
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
disabled={false}
|
|
178
|
+
key="Spoon-2"
|
|
179
|
+
/>
|
|
180
|
+
</DropTarget(DroppablePlaceholder)>
|
|
181
|
+
</div>
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
exports[`index Choices renders without duplicates 1`] = `
|
|
185
|
+
<div
|
|
186
|
+
style={
|
|
187
|
+
Object {
|
|
188
|
+
"margin": "0 40px 0 0",
|
|
189
|
+
"minWidth": "100px",
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
>
|
|
193
|
+
<DropTarget(DroppablePlaceholder)
|
|
194
|
+
disabled={false}
|
|
195
|
+
>
|
|
196
|
+
<DragSource(WithStyles(BlankContentComp))
|
|
197
|
+
choice={
|
|
198
|
+
Object {
|
|
199
|
+
"id": "2",
|
|
200
|
+
"label": "Spoon",
|
|
201
|
+
"value": "Spoon",
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
disabled={false}
|
|
205
|
+
key="Spoon-0"
|
|
206
|
+
/>
|
|
207
|
+
</DropTarget(DroppablePlaceholder)>
|
|
208
|
+
</div>
|
|
209
|
+
`;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { BlankContent as Choice } from '../choice';
|
|
4
|
+
import { choice } from '../../__tests__/utils';
|
|
5
|
+
import Choices from '../index';
|
|
6
|
+
|
|
7
|
+
describe('index', () => {
|
|
8
|
+
describe('Choices', () => {
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
disabled: false,
|
|
11
|
+
choices: [choice('Jumped', '0'), choice('Laughed', '1'), choice('Spoon', '2')],
|
|
12
|
+
};
|
|
13
|
+
let wrapper;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
wrapper = shallow(<Choices {...defaultProps} />);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('renders correctly with default props', () => {
|
|
20
|
+
expect(wrapper).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders correctly with disabled prop as true', () => {
|
|
24
|
+
wrapper.setProps({ disabled: true });
|
|
25
|
+
expect(wrapper).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
it('renders without duplicates', () => {
|
|
28
|
+
wrapper.setProps({ duplicates: undefined, value: { 0: '0', 1: '1' } });
|
|
29
|
+
expect(wrapper).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders with duplicates', () => {
|
|
33
|
+
wrapper.setProps({ duplicates: true, value: { 0: '0', 1: '1' } });
|
|
34
|
+
expect(wrapper).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('Choice', () => {
|
|
39
|
+
const defaultProps = {
|
|
40
|
+
disabled: false,
|
|
41
|
+
value: '1',
|
|
42
|
+
label: 'Label',
|
|
43
|
+
targetId: '1',
|
|
44
|
+
};
|
|
45
|
+
let wrapper;
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
wrapper = shallow(<Choice {...defaultProps} />);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('render', () => {
|
|
52
|
+
it('renders correctly with default props', () => {
|
|
53
|
+
expect(wrapper).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('renders correctly with disabled prop as true', () => {
|
|
57
|
+
wrapper.setProps({ disabled: true });
|
|
58
|
+
expect(wrapper).toMatchSnapshot();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
package/src/choices/choice.jsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { DragSource } from '@pie-lib/drag';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import Chip from '@material-ui/core/Chip';
|
|
6
6
|
import classnames from 'classnames';
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
9
9
|
import { color } from '@pie-lib/render-ui';
|
|
10
|
+
import { DragSource } from '@pie-lib/drag';
|
|
10
11
|
|
|
11
12
|
export const DRAG_TYPE = 'MaskBlank';
|
|
12
13
|
|
|
@@ -18,6 +19,45 @@ class BlankContentComp extends React.Component {
|
|
|
18
19
|
connectDragSource: PropTypes.func,
|
|
19
20
|
};
|
|
20
21
|
|
|
22
|
+
startDrag = () => {
|
|
23
|
+
const { connectDragSource, disabled } = this.props;
|
|
24
|
+
if (!disabled) {
|
|
25
|
+
connectDragSource(this.dragContainerRef);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// start drag after 500ms (touch and hold duration) for chromebooks and other touch devices PD-4888
|
|
30
|
+
handleTouchStart = (e) => {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
this.longPressTimer = setTimeout(() => {
|
|
33
|
+
this.startDrag(e);
|
|
34
|
+
}, 500);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
handleTouchEnd = () => {
|
|
38
|
+
clearTimeout(this.longPressTimer);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
handleTouchMove = () => {
|
|
42
|
+
clearTimeout(this.longPressTimer);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
componentDidMount() {
|
|
46
|
+
if (this.dragContainerRef) {
|
|
47
|
+
this.dragContainerRef.addEventListener('touchstart', this.handleTouchStart, { passive: false });
|
|
48
|
+
this.dragContainerRef.addEventListener('touchend', this.handleTouchEnd);
|
|
49
|
+
this.dragContainerRef.addEventListener('touchmove', this.handleTouchMove);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
componentWillUnmount() {
|
|
54
|
+
if (this.dragContainerRef) {
|
|
55
|
+
this.dragContainerRef.removeEventListener('touchstart', this.handleTouchStart);
|
|
56
|
+
this.dragContainerRef.removeEventListener('touchend', this.handleTouchEnd);
|
|
57
|
+
this.dragContainerRef.removeEventListener('touchmove', this.handleTouchMove);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
21
61
|
componentDidUpdate() {
|
|
22
62
|
renderMath(this.rootRef);
|
|
23
63
|
}
|
|
@@ -28,7 +68,13 @@ class BlankContentComp extends React.Component {
|
|
|
28
68
|
// TODO the Chip element is causing drag problems on touch devices. Avoid using Chip and consider refactoring the code. Keep in mind that Chip is a span with a button role, which interferes with seamless touch device dragging.
|
|
29
69
|
|
|
30
70
|
return connectDragSource(
|
|
31
|
-
<span
|
|
71
|
+
<span
|
|
72
|
+
className={classnames(classes.choice, disabled && classes.disabled)}
|
|
73
|
+
ref={(ref) => {
|
|
74
|
+
//eslint-disable-next-line
|
|
75
|
+
this.dragContainerRef = ReactDOM.findDOMNode(ref);
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
32
78
|
<Chip
|
|
33
79
|
clickable={false}
|
|
34
80
|
disabled={true}
|
|
@@ -65,7 +111,7 @@ export const BlankContent = withStyles((theme) => ({
|
|
|
65
111
|
transform: 'translate(0, 0)',
|
|
66
112
|
},
|
|
67
113
|
chip: {
|
|
68
|
-
backgroundColor: color.
|
|
114
|
+
backgroundColor: color.white(),
|
|
69
115
|
border: `1px solid ${color.text()}`,
|
|
70
116
|
color: color.text(),
|
|
71
117
|
alignItems: 'center',
|
|
@@ -79,15 +125,23 @@ export const BlankContent = withStyles((theme) => ({
|
|
|
79
125
|
// This will prevent the context menu from appearing and not allowing other interactions with the image.
|
|
80
126
|
// If interactions with the image in the token will be requested we should handle only the context Menu.
|
|
81
127
|
pointerEvents: 'none',
|
|
128
|
+
borderRadius: '3px',
|
|
129
|
+
paddingTop: '12px',
|
|
130
|
+
paddingBottom: '12px',
|
|
82
131
|
},
|
|
83
132
|
chipLabel: {
|
|
84
|
-
whiteSpace: '
|
|
133
|
+
whiteSpace: 'normal',
|
|
85
134
|
'& img': {
|
|
86
135
|
display: 'block',
|
|
87
136
|
padding: '2px 0',
|
|
88
137
|
},
|
|
138
|
+
'& mjx-frac': {
|
|
139
|
+
fontSize: '120% !important',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
disabled: {
|
|
143
|
+
opacity: 0.6,
|
|
89
144
|
},
|
|
90
|
-
disabled: {},
|
|
91
145
|
}))(BlankContentComp);
|
|
92
146
|
|
|
93
147
|
const tileSource = {
|
package/src/choices/index.jsx
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import findKey from 'lodash/findKey';
|
|
4
4
|
import Choice from './choice';
|
|
5
|
-
import DragDroppablePlaceholder from '@pie-lib/drag
|
|
5
|
+
import { DragDroppablePlaceholder } from '@pie-lib/drag';
|
|
6
6
|
|
|
7
7
|
export default class Choices extends React.Component {
|
|
8
8
|
static propTypes = {
|
|
@@ -48,7 +48,7 @@ export default class Choices extends React.Component {
|
|
|
48
48
|
const foundChoice = findKey(value, (v) => v === c.id);
|
|
49
49
|
return foundChoice === undefined;
|
|
50
50
|
});
|
|
51
|
-
const elementStyle = this.getStyleForWrapper();
|
|
51
|
+
const elementStyle = { ...this.getStyleForWrapper(), minWidth: '100px' };
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
54
|
<div style={elementStyle}>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Blank render renders correctly with default props 1`] = `
|
|
4
|
+
<WithStyles(Chip)
|
|
5
|
+
className="undefined"
|
|
6
|
+
clickable={false}
|
|
7
|
+
component="span"
|
|
8
|
+
disabled={true}
|
|
9
|
+
label={
|
|
10
|
+
<React.Fragment>
|
|
11
|
+
<span
|
|
12
|
+
className=""
|
|
13
|
+
>
|
|
14
|
+
|
|
15
|
+
</span>
|
|
16
|
+
</React.Fragment>
|
|
17
|
+
}
|
|
18
|
+
style={
|
|
19
|
+
Object {
|
|
20
|
+
"height": 0,
|
|
21
|
+
"minHeight": 32,
|
|
22
|
+
"minWidth": 90,
|
|
23
|
+
"width": 0,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`Blank render renders correctly with disabled prop as true 1`] = `
|
|
30
|
+
<WithStyles(Chip)
|
|
31
|
+
className="undefined"
|
|
32
|
+
clickable={false}
|
|
33
|
+
component="span"
|
|
34
|
+
disabled={true}
|
|
35
|
+
label={
|
|
36
|
+
<React.Fragment>
|
|
37
|
+
<span
|
|
38
|
+
className=""
|
|
39
|
+
>
|
|
40
|
+
|
|
41
|
+
</span>
|
|
42
|
+
</React.Fragment>
|
|
43
|
+
}
|
|
44
|
+
style={
|
|
45
|
+
Object {
|
|
46
|
+
"height": 0,
|
|
47
|
+
"minHeight": 32,
|
|
48
|
+
"minWidth": 90,
|
|
49
|
+
"width": 0,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
variant="outlined"
|
|
53
|
+
/>
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
exports[`Blank render renders correctly with draggedItem 1`] = `
|
|
57
|
+
<WithStyles(Chip)
|
|
58
|
+
className="undefined"
|
|
59
|
+
clickable={false}
|
|
60
|
+
component="span"
|
|
61
|
+
disabled={true}
|
|
62
|
+
label={
|
|
63
|
+
<React.Fragment>
|
|
64
|
+
<span
|
|
65
|
+
className=""
|
|
66
|
+
>
|
|
67
|
+
|
|
68
|
+
</span>
|
|
69
|
+
</React.Fragment>
|
|
70
|
+
}
|
|
71
|
+
style={
|
|
72
|
+
Object {
|
|
73
|
+
"height": 0,
|
|
74
|
+
"minHeight": 32,
|
|
75
|
+
"minWidth": 90,
|
|
76
|
+
"width": 0,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/>
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
exports[`Blank render renders correctly with draggedItem and isOver 1`] = `
|
|
83
|
+
<WithStyles(Chip)
|
|
84
|
+
className="undefined"
|
|
85
|
+
clickable={false}
|
|
86
|
+
component="span"
|
|
87
|
+
disabled={true}
|
|
88
|
+
label={
|
|
89
|
+
<React.Fragment>
|
|
90
|
+
<span
|
|
91
|
+
className="undefined"
|
|
92
|
+
>
|
|
93
|
+
|
|
94
|
+
</span>
|
|
95
|
+
<span
|
|
96
|
+
className=""
|
|
97
|
+
>
|
|
98
|
+
|
|
99
|
+
</span>
|
|
100
|
+
</React.Fragment>
|
|
101
|
+
}
|
|
102
|
+
style={
|
|
103
|
+
Object {
|
|
104
|
+
"height": 0,
|
|
105
|
+
"minHeight": 32,
|
|
106
|
+
"minWidth": 90,
|
|
107
|
+
"width": 0,
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
`;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`CorrectInput render renders correctly with correct as false 1`] = `
|
|
4
|
+
<Component
|
|
5
|
+
classes={
|
|
6
|
+
Object {
|
|
7
|
+
"box": "Component-box-5",
|
|
8
|
+
"correct": "Component-correct-3",
|
|
9
|
+
"crInput": "Component-crInput-2",
|
|
10
|
+
"incorrect": "Component-incorrect-4",
|
|
11
|
+
"input": "Component-input-1",
|
|
12
|
+
"notchedOutline": "Component-notchedOutline-7",
|
|
13
|
+
"outlinedInput": "Component-outlinedInput-6",
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
correct={false}
|
|
17
|
+
disabled={false}
|
|
18
|
+
onChange={[MockFunction]}
|
|
19
|
+
value="Cow"
|
|
20
|
+
variant="outlined"
|
|
21
|
+
/>
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
exports[`CorrectInput render renders correctly with default props 1`] = `
|
|
25
|
+
<Component
|
|
26
|
+
classes={
|
|
27
|
+
Object {
|
|
28
|
+
"box": "Component-box-5",
|
|
29
|
+
"correct": "Component-correct-3",
|
|
30
|
+
"crInput": "Component-crInput-2",
|
|
31
|
+
"incorrect": "Component-incorrect-4",
|
|
32
|
+
"input": "Component-input-1",
|
|
33
|
+
"notchedOutline": "Component-notchedOutline-7",
|
|
34
|
+
"outlinedInput": "Component-outlinedInput-6",
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
correct={false}
|
|
38
|
+
disabled={false}
|
|
39
|
+
onChange={[MockFunction]}
|
|
40
|
+
value="Cow"
|
|
41
|
+
variant="outlined"
|
|
42
|
+
/>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`CorrectInput render renders correctly with disabled prop as true 1`] = `
|
|
46
|
+
<Component
|
|
47
|
+
classes={
|
|
48
|
+
Object {
|
|
49
|
+
"box": "Component-box-5",
|
|
50
|
+
"correct": "Component-correct-3",
|
|
51
|
+
"crInput": "Component-crInput-2",
|
|
52
|
+
"incorrect": "Component-incorrect-4",
|
|
53
|
+
"input": "Component-input-1",
|
|
54
|
+
"notchedOutline": "Component-notchedOutline-7",
|
|
55
|
+
"outlinedInput": "Component-outlinedInput-6",
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
correct={false}
|
|
59
|
+
disabled={true}
|
|
60
|
+
onChange={[MockFunction]}
|
|
61
|
+
value="Cow"
|
|
62
|
+
variant="outlined"
|
|
63
|
+
/>
|
|
64
|
+
`;
|