@pie-lib/text-select 1.12.8 → 1.13.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 +18 -70
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -1
- package/lib/token-select/index.js +3 -2
- package/lib/token-select/index.js.map +1 -1
- package/lib/token-select/token.js +12 -19
- package/lib/token-select/token.js.map +1 -1
- package/lib/tokenizer/controls.js +14 -0
- package/lib/tokenizer/controls.js.map +1 -1
- package/lib/tokenizer/token-text.js +11 -2
- package/lib/tokenizer/token-text.js.map +1 -1
- package/package.json +8 -6
- package/src/__tests__/__snapshots__/text-select.test.jsx.snap +21 -0
- package/src/__tests__/text-select.test.jsx +34 -0
- package/src/__tests__/utils.test.jsx +27 -0
- package/src/index.js +2 -1
- package/src/token-select/__tests__/__snapshots__/index.test.jsx.snap +49 -0
- package/src/token-select/__tests__/__snapshots__/token.test.jsx.snap +31 -0
- package/src/token-select/__tests__/index.test.jsx +257 -0
- package/src/token-select/__tests__/token.test.jsx +33 -0
- package/src/token-select/index.jsx +3 -1
- package/src/token-select/token.jsx +11 -20
- package/src/tokenizer/__tests__/__snapshots__/controls.test.jsx.snap +59 -0
- package/src/tokenizer/__tests__/__snapshots__/index.test.jsx.snap +31 -0
- package/src/tokenizer/__tests__/__snapshots__/token-text.test.jsx.snap +17 -0
- package/src/tokenizer/__tests__/builder.test.js +256 -0
- package/src/tokenizer/__tests__/controls.test.jsx +25 -0
- package/src/tokenizer/__tests__/index.test.jsx +140 -0
- package/src/tokenizer/__tests__/selection-utils.test.js +26 -0
- package/src/tokenizer/__tests__/token-text.test.jsx +136 -0
- package/src/tokenizer/controls.jsx +20 -1
- package/src/tokenizer/token-text.jsx +9 -0
- package/README.md +0 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import TextSelect from '../text-select';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import toJson from 'enzyme-to-json';
|
|
5
|
+
describe('text-select', () => {
|
|
6
|
+
describe('snapshot', () => {
|
|
7
|
+
it('renders', () => {
|
|
8
|
+
const w = shallow(
|
|
9
|
+
<TextSelect text="foo" tokens={[]} selectedTokens={[]} onChange={jest.fn()} maxNoOfSelections={4} />,
|
|
10
|
+
);
|
|
11
|
+
expect(w).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('logic', () => {
|
|
16
|
+
let w, onChange;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
onChange = jest.fn();
|
|
19
|
+
w = shallow(<TextSelect text="foo" tokens={[]} selectedTokens={[]} onChange={onChange} />);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('change', () => {
|
|
23
|
+
it('calls onChange', () => {
|
|
24
|
+
const changeArgs = [
|
|
25
|
+
{ start: 0, end: 1, selected: true },
|
|
26
|
+
{ start: 1, end: 2 },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
w.instance().change(changeArgs);
|
|
30
|
+
expect(onChange).toBeCalledWith([{ start: 0, end: 1 }]);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { prepareText } from '../utils';
|
|
2
|
+
|
|
3
|
+
describe('logic', () => {
|
|
4
|
+
it('returns text if no html elements', () => {
|
|
5
|
+
const formattedText = prepareText(`foo bar`);
|
|
6
|
+
|
|
7
|
+
expect(formattedText).toEqual('foo bar');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('replaces br with new lines', () => {
|
|
11
|
+
const formattedText = prepareText(`<p>foo<br>bar</p>`);
|
|
12
|
+
|
|
13
|
+
expect(formattedText).toEqual('foo\nbar');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('replaces p with 2 new lines', () => {
|
|
17
|
+
const formattedText = prepareText(`<p>foo<br>bar</p><p>bar<br>foo</p>`);
|
|
18
|
+
|
|
19
|
+
expect(formattedText).toEqual('foo\nbar\n\nbar\nfoo');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('adds p if there are no paragraphs', () => {
|
|
23
|
+
const formattedText = prepareText(`foo<br>bar<br>foo`);
|
|
24
|
+
|
|
25
|
+
expect(formattedText).toEqual('foo\nbar\nfoo');
|
|
26
|
+
});
|
|
27
|
+
});
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Controls from './tokenizer/controls';
|
|
1
2
|
import Tokenizer from './tokenizer';
|
|
2
3
|
import TokenSelect, { TokenTypes } from './token-select';
|
|
3
4
|
import TextSelect from './text-select';
|
|
@@ -5,4 +6,4 @@ import { Legend } from './legend';
|
|
|
5
6
|
import Token from './token-select/token';
|
|
6
7
|
import { prepareText } from './utils';
|
|
7
8
|
|
|
8
|
-
export { TextSelect, TokenTypes, Tokenizer, TokenSelect, Token, prepareText, Legend };
|
|
9
|
+
export { Controls, TextSelect, TokenTypes, Tokenizer, TokenSelect, Token, prepareText, Legend };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`token-select snapshot renders 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className=""
|
|
6
|
+
dangerouslySetInnerHTML={
|
|
7
|
+
Object {
|
|
8
|
+
"__html": "<p><span class=\\"tokenRootClass Token-token-1 Token-selectable-5\\" data-indexkey=\\"0\\" data-reactroot=\\"\\">foo bar</span></p>",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
onClick={[Function]}
|
|
12
|
+
/>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`token-select snapshot renders in view mode with selected tokens 1`] = `
|
|
16
|
+
<div
|
|
17
|
+
className=""
|
|
18
|
+
dangerouslySetInnerHTML={
|
|
19
|
+
Object {
|
|
20
|
+
"__html": "<p><span class=\\"Token-token-1 Token-selected-6 Token-disabledBlack-3\\" data-indexkey=\\"0\\" data-reactroot=\\"\\">foo,</span><br><span class=\\"Token-token-1 Token-selected-6 Token-disabledBlack-3\\" data-indexkey=\\"2\\" data-reactroot=\\"\\">bar</span></p>",
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
onClick={[Function]}
|
|
24
|
+
/>
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`token-select snapshot renders paragraphs properly 1`] = `
|
|
28
|
+
<div
|
|
29
|
+
className=""
|
|
30
|
+
dangerouslySetInnerHTML={
|
|
31
|
+
Object {
|
|
32
|
+
"__html": "<p><span class=\\"tokenRootClass Token-token-1 Token-selectable-5\\" data-indexkey=\\"0\\" data-reactroot=\\"\\">foo,</span></p><p><span class=\\"tokenRootClass Token-token-1 Token-selectable-5\\" data-indexkey=\\"2\\" data-reactroot=\\"\\">bar</span></p>",
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
onClick={[Function]}
|
|
36
|
+
/>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`token-select snapshot renders sentences properly 1`] = `
|
|
40
|
+
<div
|
|
41
|
+
className=""
|
|
42
|
+
dangerouslySetInnerHTML={
|
|
43
|
+
Object {
|
|
44
|
+
"__html": "<p><span class=\\"tokenRootClass Token-token-1 Token-selectable-5\\" data-indexkey=\\"0\\" data-reactroot=\\"\\">foo,</span><br><span class=\\"tokenRootClass Token-token-1 Token-selectable-5\\" data-indexkey=\\"2\\" data-reactroot=\\"\\">bar</span></p>",
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
onClick={[Function]}
|
|
48
|
+
/>
|
|
49
|
+
`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`token snapshot renders 1`] = `
|
|
4
|
+
<Wrapper
|
|
5
|
+
useWrapper={false}
|
|
6
|
+
>
|
|
7
|
+
<span
|
|
8
|
+
className="tokenRootClass token"
|
|
9
|
+
dangerouslySetInnerHTML={
|
|
10
|
+
Object {
|
|
11
|
+
"__html": "foo bar",
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/>
|
|
15
|
+
</Wrapper>
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
exports[`token snapshot renders with brs 1`] = `
|
|
19
|
+
<Wrapper
|
|
20
|
+
useWrapper={false}
|
|
21
|
+
>
|
|
22
|
+
<span
|
|
23
|
+
className="tokenRootClass token"
|
|
24
|
+
dangerouslySetInnerHTML={
|
|
25
|
+
Object {
|
|
26
|
+
"__html": "foo <br>bar",
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/>
|
|
30
|
+
</Wrapper>
|
|
31
|
+
`;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { TokenSelect } from '../index';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { shallow } from 'enzyme';
|
|
4
|
+
|
|
5
|
+
describe('token-select', () => {
|
|
6
|
+
describe('snapshot', () => {
|
|
7
|
+
it('renders', () => {
|
|
8
|
+
const w = shallow(
|
|
9
|
+
<TokenSelect
|
|
10
|
+
tokens={[
|
|
11
|
+
{
|
|
12
|
+
text: 'foo bar',
|
|
13
|
+
start: 0,
|
|
14
|
+
end: 7,
|
|
15
|
+
predefined: true,
|
|
16
|
+
selectable: true,
|
|
17
|
+
selected: false,
|
|
18
|
+
},
|
|
19
|
+
]}
|
|
20
|
+
classes={{}}
|
|
21
|
+
onChange={jest.fn()}
|
|
22
|
+
/>,
|
|
23
|
+
);
|
|
24
|
+
expect(w).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders sentences properly', () => {
|
|
28
|
+
const w = shallow(
|
|
29
|
+
<TokenSelect
|
|
30
|
+
tokens={[
|
|
31
|
+
{
|
|
32
|
+
text: 'foo,',
|
|
33
|
+
start: 0,
|
|
34
|
+
end: 4,
|
|
35
|
+
predefined: true,
|
|
36
|
+
selectable: true,
|
|
37
|
+
selected: false,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
text: '\n',
|
|
41
|
+
start: 4,
|
|
42
|
+
end: 5,
|
|
43
|
+
selected: false,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
text: 'bar',
|
|
47
|
+
start: 5,
|
|
48
|
+
end: 8,
|
|
49
|
+
predefined: true,
|
|
50
|
+
selectable: true,
|
|
51
|
+
selected: false,
|
|
52
|
+
},
|
|
53
|
+
]}
|
|
54
|
+
classes={{}}
|
|
55
|
+
onChange={jest.fn()}
|
|
56
|
+
/>,
|
|
57
|
+
);
|
|
58
|
+
expect(w).toMatchSnapshot();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('renders paragraphs properly', () => {
|
|
62
|
+
const w = shallow(
|
|
63
|
+
<TokenSelect
|
|
64
|
+
tokens={[
|
|
65
|
+
{
|
|
66
|
+
text: 'foo,',
|
|
67
|
+
start: 0,
|
|
68
|
+
end: 4,
|
|
69
|
+
predefined: true,
|
|
70
|
+
selectable: true,
|
|
71
|
+
selected: false,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
text: '\n\n',
|
|
75
|
+
start: 4,
|
|
76
|
+
end: 5,
|
|
77
|
+
selected: false,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
text: 'bar',
|
|
81
|
+
start: 5,
|
|
82
|
+
end: 8,
|
|
83
|
+
predefined: true,
|
|
84
|
+
selectable: true,
|
|
85
|
+
selected: false,
|
|
86
|
+
},
|
|
87
|
+
]}
|
|
88
|
+
classes={{}}
|
|
89
|
+
onChange={jest.fn()}
|
|
90
|
+
/>,
|
|
91
|
+
);
|
|
92
|
+
expect(w).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('renders in view mode with selected tokens', () => {
|
|
96
|
+
const w = shallow(
|
|
97
|
+
<TokenSelect
|
|
98
|
+
disabled
|
|
99
|
+
tokens={[
|
|
100
|
+
{
|
|
101
|
+
text: 'foo,',
|
|
102
|
+
start: 0,
|
|
103
|
+
end: 4,
|
|
104
|
+
predefined: true,
|
|
105
|
+
selectable: true,
|
|
106
|
+
selected: true,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
text: '\n',
|
|
110
|
+
start: 4,
|
|
111
|
+
end: 5,
|
|
112
|
+
selected: false,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
text: 'bar',
|
|
116
|
+
start: 5,
|
|
117
|
+
end: 8,
|
|
118
|
+
predefined: true,
|
|
119
|
+
selectable: true,
|
|
120
|
+
selected: true,
|
|
121
|
+
},
|
|
122
|
+
]}
|
|
123
|
+
classes={{}}
|
|
124
|
+
onChange={jest.fn()}
|
|
125
|
+
/>,
|
|
126
|
+
);
|
|
127
|
+
expect(w).toMatchSnapshot();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe('logic', () => {
|
|
132
|
+
let w, onChange;
|
|
133
|
+
beforeEach(() => {
|
|
134
|
+
onChange = jest.fn();
|
|
135
|
+
w = shallow(
|
|
136
|
+
<TokenSelect
|
|
137
|
+
tokens={[
|
|
138
|
+
{
|
|
139
|
+
text: 'foo',
|
|
140
|
+
start: 0,
|
|
141
|
+
end: 3,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
text: 'bar',
|
|
145
|
+
start: 4,
|
|
146
|
+
end: 7,
|
|
147
|
+
},
|
|
148
|
+
]}
|
|
149
|
+
classes={{}}
|
|
150
|
+
onChange={onChange}
|
|
151
|
+
/>,
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
describe('selectedCount', () => {
|
|
155
|
+
it('returns the correct count', () => {
|
|
156
|
+
expect(w.instance().selectedCount()).toEqual(0);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('returns the correct count for 1 selected', () => {
|
|
160
|
+
w.setProps({ tokens: [{ selected: true }] });
|
|
161
|
+
expect(w.instance().selectedCount()).toEqual(1);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe('canSelectMore', () => {
|
|
166
|
+
it('returns true for undefined max selections', () => {
|
|
167
|
+
w.setProps({ maxNoOfSelections: undefined });
|
|
168
|
+
expect(w.instance().canSelectMore(10)).toEqual(true);
|
|
169
|
+
});
|
|
170
|
+
it('returns true for 0 max selections', () => {
|
|
171
|
+
w.setProps({ maxNoOfSelections: 0 });
|
|
172
|
+
expect(w.instance().canSelectMore(10)).toEqual(true);
|
|
173
|
+
});
|
|
174
|
+
it('returns true for -1 max selections', () => {
|
|
175
|
+
w.setProps({ maxNoOfSelections: -1 });
|
|
176
|
+
expect(w.instance().canSelectMore(10)).toEqual(true);
|
|
177
|
+
});
|
|
178
|
+
it('returns true for 5 max selections and count 4', () => {
|
|
179
|
+
w.setProps({ maxNoOfSelections: 5 });
|
|
180
|
+
expect(w.instance().canSelectMore(4)).toEqual(true);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('returns true for 5 max selections and count 5', () => {
|
|
184
|
+
w.setProps({ maxNoOfSelections: 5 });
|
|
185
|
+
expect(w.instance().canSelectMore(5)).toEqual(false);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('returns false for 5 max selections and count 6', () => {
|
|
189
|
+
w.setProps({ maxNoOfSelections: 5 });
|
|
190
|
+
expect(w.instance().canSelectMore(6)).toEqual(false);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('returns true for 1 max selections and count 1', () => {
|
|
194
|
+
w.setProps({ maxNoOfSelections: 1 });
|
|
195
|
+
expect(w.instance().canSelectMore(1)).toEqual(true);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
describe('toggleToken', () => {
|
|
200
|
+
it('return if clicked target is not selectable', () => {
|
|
201
|
+
w.setProps({ maxNoOfSelections: 1, tokens: [{ selected: true }] });
|
|
202
|
+
|
|
203
|
+
const closest = jest.fn().mockReturnValue(null);
|
|
204
|
+
const mockedEvent = { target: { closest } };
|
|
205
|
+
|
|
206
|
+
w.instance().toggleToken(mockedEvent);
|
|
207
|
+
|
|
208
|
+
expect(onChange).not.toBeCalled();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('calls onChange', () => {
|
|
212
|
+
w.setProps({ maxNoOfSelections: 0, tokens: [{ selected: true }] });
|
|
213
|
+
|
|
214
|
+
const closest = jest.fn().mockReturnValue({
|
|
215
|
+
dataset: {
|
|
216
|
+
indexkey: '0',
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
const mockedEvent = { target: { closest } };
|
|
220
|
+
|
|
221
|
+
w.instance().toggleToken(mockedEvent);
|
|
222
|
+
|
|
223
|
+
expect(onChange).toBeCalled();
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('returns if max tokens have been selected', () => {
|
|
227
|
+
w.setProps({ maxNoOfSelections: 0, tokens: [{ selected: true }] });
|
|
228
|
+
|
|
229
|
+
const closest = jest.fn().mockReturnValue({
|
|
230
|
+
dataset: {
|
|
231
|
+
indexkey: '0',
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
const mockedEvent = { target: { closest } };
|
|
235
|
+
|
|
236
|
+
w.instance().toggleToken(mockedEvent);
|
|
237
|
+
|
|
238
|
+
expect(onChange).not.toBeCalledWith([{ selected: true }]);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('calls onChange if maxNoOfSelections is 1 and selectedCount is 1', () => {
|
|
242
|
+
w.setProps({ maxNoOfSelections: 1, tokens: [{ selected: true }] });
|
|
243
|
+
|
|
244
|
+
const closest = jest.fn().mockReturnValue({
|
|
245
|
+
dataset: {
|
|
246
|
+
indexkey: '0',
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
const mockedEvent = { target: { closest } };
|
|
250
|
+
|
|
251
|
+
w.instance().toggleToken(mockedEvent);
|
|
252
|
+
|
|
253
|
+
expect(onChange).toBeCalled();
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Token } from '../token';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
describe('token', () => {
|
|
6
|
+
describe('snapshot', () => {
|
|
7
|
+
it('renders', () => {
|
|
8
|
+
const w = shallow(
|
|
9
|
+
<Token
|
|
10
|
+
classes={{
|
|
11
|
+
token: 'token',
|
|
12
|
+
selectable: 'selectable',
|
|
13
|
+
}}
|
|
14
|
+
text={'foo bar'}
|
|
15
|
+
/>,
|
|
16
|
+
);
|
|
17
|
+
expect(w).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('renders with brs', () => {
|
|
21
|
+
const w = shallow(
|
|
22
|
+
<Token
|
|
23
|
+
classes={{
|
|
24
|
+
token: 'token',
|
|
25
|
+
selectable: 'selectable',
|
|
26
|
+
}}
|
|
27
|
+
text={'foo \nbar'}
|
|
28
|
+
/>,
|
|
29
|
+
);
|
|
30
|
+
expect(w).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -58,7 +58,9 @@ export class TokenSelect extends React.Component {
|
|
|
58
58
|
const targetedTokenIndex = targetSpanWrapper && targetSpanWrapper.dataset && targetSpanWrapper.dataset.indexkey;
|
|
59
59
|
const t = targetedTokenIndex && tokensCloned[targetedTokenIndex];
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// don't toggle if we are in print mode, token correctness is defined or if it's missing
|
|
62
|
+
// (missing means that it was evaluated as correct and not selected)
|
|
63
|
+
if (t && t.correct === undefined && !animationsDisabled && !t.isMissing) {
|
|
62
64
|
const { onChange, maxNoOfSelections } = this.props;
|
|
63
65
|
const selected = !t.selected;
|
|
64
66
|
|
|
@@ -115,10 +115,6 @@ export default withStyles((theme) => {
|
|
|
115
115
|
token: {
|
|
116
116
|
cursor: 'pointer',
|
|
117
117
|
textIndent: 0,
|
|
118
|
-
padding: theme.spacing.unit / 2,
|
|
119
|
-
paddingRight: 0,
|
|
120
|
-
paddingLeft: 0,
|
|
121
|
-
transition: 'background-color 100ms ease-in',
|
|
122
118
|
},
|
|
123
119
|
disabled: {
|
|
124
120
|
cursor: 'inherit',
|
|
@@ -134,6 +130,7 @@ export default withStyles((theme) => {
|
|
|
134
130
|
[theme.breakpoints.up(769)]: {
|
|
135
131
|
'&:hover': {
|
|
136
132
|
backgroundColor: color.primaryLight(),
|
|
133
|
+
color: theme.palette.common.black,
|
|
137
134
|
'& > *': {
|
|
138
135
|
backgroundColor: color.primaryLight(),
|
|
139
136
|
},
|
|
@@ -141,47 +138,42 @@ export default withStyles((theme) => {
|
|
|
141
138
|
},
|
|
142
139
|
},
|
|
143
140
|
selected: {
|
|
144
|
-
lineHeight: 2,
|
|
145
|
-
marginTop: theme.spacing.unit / 2,
|
|
146
141
|
backgroundColor: color.primaryLight(),
|
|
142
|
+
color: theme.palette.common.black,
|
|
143
|
+
lineHeight: `${theme.spacing.unit * 3}px`,
|
|
147
144
|
'& > *': {
|
|
148
145
|
backgroundColor: color.primaryLight(),
|
|
149
146
|
},
|
|
150
147
|
},
|
|
151
148
|
highlight: {
|
|
152
149
|
border: `dashed 2px ${color.disabled()}`,
|
|
153
|
-
lineHeight:
|
|
154
|
-
boxSizing: 'border-box',
|
|
155
|
-
marginTop: theme.spacing.unit / 2,
|
|
156
|
-
display: 'inline-block',
|
|
157
|
-
padding: theme.spacing.unit,
|
|
150
|
+
lineHeight: `${theme.spacing.unit * 3}px`,
|
|
158
151
|
},
|
|
159
152
|
print: {
|
|
160
153
|
border: `dashed 2px ${color.disabled()}`,
|
|
161
|
-
lineHeight:
|
|
162
|
-
boxSizing: 'border-box',
|
|
163
|
-
marginTop: theme.spacing.unit / 2,
|
|
164
|
-
display: 'inline-block',
|
|
165
|
-
padding: theme.spacing.unit,
|
|
154
|
+
lineHeight: `${theme.spacing.unit * 3}px`,
|
|
166
155
|
color: color.text(),
|
|
167
156
|
},
|
|
168
|
-
|
|
169
157
|
custom: {
|
|
170
158
|
display: 'initial',
|
|
171
159
|
},
|
|
172
160
|
correct: {
|
|
173
161
|
backgroundColor: color.correctSecondary(),
|
|
174
162
|
border: `${color.correct()} solid 2px`,
|
|
175
|
-
|
|
163
|
+
color: theme.palette.common.black,
|
|
164
|
+
lineHeight: `${theme.spacing.unit * 3}px`,
|
|
176
165
|
},
|
|
177
166
|
incorrect: {
|
|
178
167
|
backgroundColor: color.incorrectSecondary(),
|
|
179
168
|
border: `${color.missing()} solid 2px`,
|
|
180
|
-
|
|
169
|
+
color: theme.palette.common.black,
|
|
170
|
+
lineHeight: `${theme.spacing.unit * 3}px`,
|
|
181
171
|
},
|
|
182
172
|
missing: {
|
|
183
173
|
backgroundColor: color.incorrectSecondary(),
|
|
184
174
|
border: `${color.missing()} dashed 2px`,
|
|
175
|
+
color: theme.palette.common.black,
|
|
176
|
+
lineHeight: `${theme.spacing.unit * 3}px`,
|
|
185
177
|
textDecoration: `line-through ${color.missing()}`,
|
|
186
178
|
},
|
|
187
179
|
incorrectIcon: {
|
|
@@ -189,7 +181,6 @@ export default withStyles((theme) => {
|
|
|
189
181
|
fontSize: 'larger',
|
|
190
182
|
color: color.missing(),
|
|
191
183
|
},
|
|
192
|
-
|
|
193
184
|
correctIcon: {
|
|
194
185
|
verticalAlign: 'middle',
|
|
195
186
|
fontSize: 'larger',
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`controls snapshot renders 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div>
|
|
6
|
+
<WithStyles(Button)
|
|
7
|
+
className="button"
|
|
8
|
+
color="primary"
|
|
9
|
+
disabled={false}
|
|
10
|
+
onClick={[MockFunction]}
|
|
11
|
+
size="small"
|
|
12
|
+
>
|
|
13
|
+
Words
|
|
14
|
+
</WithStyles(Button)>
|
|
15
|
+
<WithStyles(Button)
|
|
16
|
+
className="button"
|
|
17
|
+
color="primary"
|
|
18
|
+
disabled={false}
|
|
19
|
+
onClick={[MockFunction]}
|
|
20
|
+
size="small"
|
|
21
|
+
>
|
|
22
|
+
Sentences
|
|
23
|
+
</WithStyles(Button)>
|
|
24
|
+
<WithStyles(Button)
|
|
25
|
+
className="button"
|
|
26
|
+
color="primary"
|
|
27
|
+
disabled={false}
|
|
28
|
+
onClick={[MockFunction]}
|
|
29
|
+
size="small"
|
|
30
|
+
>
|
|
31
|
+
Paragraphs
|
|
32
|
+
</WithStyles(Button)>
|
|
33
|
+
<WithStyles(Button)
|
|
34
|
+
className="button"
|
|
35
|
+
color="secondary"
|
|
36
|
+
disabled={false}
|
|
37
|
+
onClick={[MockFunction]}
|
|
38
|
+
size="small"
|
|
39
|
+
>
|
|
40
|
+
Clear
|
|
41
|
+
</WithStyles(Button)>
|
|
42
|
+
</div>
|
|
43
|
+
<WithStyles(WithFormControlContext(FormControlLabel))
|
|
44
|
+
control={
|
|
45
|
+
<WithStyles(Switch)
|
|
46
|
+
checked={false}
|
|
47
|
+
classes={
|
|
48
|
+
Object {
|
|
49
|
+
"bar": "",
|
|
50
|
+
"checked": undefined,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
onChange={[MockFunction]}
|
|
54
|
+
/>
|
|
55
|
+
}
|
|
56
|
+
label="Set correct answers"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
`;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`tokenizer snapshot renders 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className=""
|
|
6
|
+
>
|
|
7
|
+
<WithStyles(Controls)
|
|
8
|
+
onClear={[Function]}
|
|
9
|
+
onParagraphs={[Function]}
|
|
10
|
+
onSentences={[Function]}
|
|
11
|
+
onToggleCorrectMode={[Function]}
|
|
12
|
+
onWords={[Function]}
|
|
13
|
+
setCorrectMode={false}
|
|
14
|
+
/>
|
|
15
|
+
<TokenText
|
|
16
|
+
className=""
|
|
17
|
+
onSelectToken={[Function]}
|
|
18
|
+
onTokenClick={[Function]}
|
|
19
|
+
text="foo"
|
|
20
|
+
tokens={
|
|
21
|
+
Array [
|
|
22
|
+
Object {
|
|
23
|
+
"end": 1,
|
|
24
|
+
"start": 0,
|
|
25
|
+
"text": "f",
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`token-text snapshot renders 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
onClick={[Function]}
|
|
6
|
+
>
|
|
7
|
+
<WithStyles(Component)
|
|
8
|
+
end={13}
|
|
9
|
+
key="0"
|
|
10
|
+
onClick={[Function]}
|
|
11
|
+
predefined={true}
|
|
12
|
+
start={0}
|
|
13
|
+
text="lorem
|
|
14
|
+
foo bar"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
`;
|