bright-components 10.2.7 → 10.2.8
Sign up to get free protection for your applications and to get access to all the features.
- package/circle.yml +1 -2
- package/deploy.sh +6 -0
- package/dist/components/DayPicker/NewDayPicker/index.js +0 -28
- package/dist/components/DayPicker/index.js +2 -20
- package/dist/components/DayPickerPanel/HeaderDayPickerPanel/index.js +1 -18
- package/dist/components/DayPickerPanel/HeaderMonthPanel/index.js +0 -14
- package/dist/components/DayPickerPanel/HeaderYearPanel/index.js +2 -15
- package/dist/components/DayPickerPanel/Shortcuts/index.js +2 -16
- package/dist/components/DayPickerPanel/index.js +2 -74
- package/dist/components/EmployeeCard/index.js +1 -14
- package/dist/components/EmployeePicker/FilterBar/index.js +1 -28
- package/dist/components/EmployeePicker/Group/index.js +1 -41
- package/dist/components/FilterRadioGroup/index.js +2 -14
- package/dist/components/Form/index.js +4 -47
- package/dist/components/Modal/index.js +1 -23
- package/dist/components/RadioBlock/index.js +10 -41
- package/dist/components/Snackbar/index.js +1 -17
- package/dist/components/Time/OverlayBase/index.js +2 -25
- package/dist/components/Time/TimePicker/TimeOverlay/index.js +3 -26
- package/dist/components/TimePicker/Time/TimeOverlay/index.js +1 -58
- package/dist/setupTests.js +0 -7
- package/package.json +5 -7
- package/src/components/DayPicker/NewDayPicker/index.js +0 -21
- package/src/components/DayPicker/index.js +1 -16
- package/src/components/DayPicker/test.js +0 -85
- package/src/components/DayPickerPanel/HeaderDayPickerPanel/index.js +2 -22
- package/src/components/DayPickerPanel/HeaderDayPickerPanel/test.js +0 -34
- package/src/components/DayPickerPanel/HeaderMonthPanel/index.js +0 -10
- package/src/components/DayPickerPanel/HeaderMonthPanel/test.js +0 -25
- package/src/components/DayPickerPanel/HeaderYearPanel/index.js +3 -12
- package/src/components/DayPickerPanel/HeaderYearPanel/test.js +0 -17
- package/src/components/DayPickerPanel/Shortcuts/index.js +3 -17
- package/src/components/DayPickerPanel/Shortcuts/test.js +0 -39
- package/src/components/DayPickerPanel/index.js +1 -69
- package/src/components/DayPickerPanel/test.js +0 -177
- package/src/components/EmployeeCard/index.js +1 -15
- package/src/components/EmployeeCard/test.js +0 -20
- package/src/components/EmployeePicker/FilterBar/index.js +2 -26
- package/src/components/EmployeePicker/FilterBar/test.js +0 -29
- package/src/components/EmployeePicker/Group/index.js +1 -42
- package/src/components/EmployeePicker/Group/test.js +0 -21
- package/src/components/FilterRadioGroup/index.js +2 -14
- package/src/components/FilterRadioGroup/test.js +0 -13
- package/src/components/Form/index.js +1 -49
- package/src/components/Form/test.js +0 -73
- package/src/components/Modal/index.js +1 -22
- package/src/components/Modal/test.js +9 -9
- package/src/components/RadioBlock/index.js +14 -33
- package/src/components/RadioBlock/test.js +35 -155
- package/src/components/ResponsiveTabs/test.js +49 -86
- package/src/components/Snackbar/index.js +1 -16
- package/src/components/Time/OverlayBase/index.js +3 -21
- package/src/components/Time/OverlayBase/test.js +0 -50
- package/src/components/Time/TimePicker/TimeOverlay/index.js +4 -30
- package/src/components/Time/TimePicker/TimeOverlay/test.js +0 -24
- package/src/components/TimePicker/DayPart/test.js +1 -1
- package/src/components/TimePicker/Time/TimeOverlay/index.js +2 -50
- package/src/components/TimePicker/Time/TimeOverlay/test.js +1 -220
- package/src/index.js +1 -1
- package/src/setupTests.js +0 -2
- package/dist/components/TimePicker/utils/PickerGA/index.js +0 -24
- package/dist/utils/trackForm/index.js +0 -48
- package/src/components/TimePicker/utils/PickerGA/index.js +0 -6
- package/src/components/TimePicker/utils/PickerGA/test.js +0 -29
- package/src/utils/trackForm/index.js +0 -36
- package/src/utils/trackForm/test.js +0 -110
@@ -1,6 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import styled from 'styled-components';
|
3
|
-
import { event } from 'react-ga';
|
4
3
|
import {
|
5
4
|
arrayOf,
|
6
5
|
shape,
|
@@ -11,7 +10,6 @@ import {
|
|
11
10
|
oneOfType,
|
12
11
|
node
|
13
12
|
} from 'prop-types';
|
14
|
-
|
15
13
|
import H3 from 'components/Typography/H3';
|
16
14
|
import Chevron from 'components/Chevron/Chevron';
|
17
15
|
import ButtonGroup from 'components/ButtonGroup';
|
@@ -76,14 +74,7 @@ class Group extends React.Component {
|
|
76
74
|
}
|
77
75
|
|
78
76
|
render() {
|
79
|
-
const {
|
80
|
-
title,
|
81
|
-
users,
|
82
|
-
onClick,
|
83
|
-
hideButtons,
|
84
|
-
toggleUsers,
|
85
|
-
GA
|
86
|
-
} = this.props;
|
77
|
+
const { title, users, onClick, hideButtons, toggleUsers } = this.props;
|
87
78
|
const { show } = this.state;
|
88
79
|
const selectedUsers = getSelected(users);
|
89
80
|
const deselectedUsers = getNotSelected(users);
|
@@ -92,29 +83,6 @@ class Group extends React.Component {
|
|
92
83
|
<Bar>
|
93
84
|
<CH3
|
94
85
|
onClick={() => {
|
95
|
-
if (show) {
|
96
|
-
event({
|
97
|
-
action: 'Contract Selected Group',
|
98
|
-
category: GA.category
|
99
|
-
});
|
100
|
-
if (title === 'No group') {
|
101
|
-
event({
|
102
|
-
action: 'Contract No Group',
|
103
|
-
category: GA.category
|
104
|
-
});
|
105
|
-
}
|
106
|
-
} else {
|
107
|
-
event({
|
108
|
-
action: 'Expand Selected Group',
|
109
|
-
category: GA.category
|
110
|
-
});
|
111
|
-
if (title === 'No group') {
|
112
|
-
event({
|
113
|
-
action: 'Expand No Group',
|
114
|
-
category: GA.category
|
115
|
-
});
|
116
|
-
}
|
117
|
-
}
|
118
86
|
this.toggleShow();
|
119
87
|
}}
|
120
88
|
>
|
@@ -130,10 +98,6 @@ class Group extends React.Component {
|
|
130
98
|
<LinkButton
|
131
99
|
disabled={selectedUsers.length === users.length}
|
132
100
|
onClick={() => {
|
133
|
-
event({
|
134
|
-
action: 'Select Group',
|
135
|
-
category: GA.category
|
136
|
-
});
|
137
101
|
toggleUsers(
|
138
102
|
deselectedUsers
|
139
103
|
.filter(filterDisabled)
|
@@ -147,10 +111,6 @@ class Group extends React.Component {
|
|
147
111
|
<LinkButton
|
148
112
|
disabled={selectedUsers.length === 0}
|
149
113
|
onClick={() => {
|
150
|
-
event({
|
151
|
-
action: 'Deselect Group',
|
152
|
-
category: GA.category
|
153
|
-
});
|
154
114
|
toggleUsers(
|
155
115
|
selectedUsers
|
156
116
|
.filter(filterDisabled)
|
@@ -180,7 +140,6 @@ class Group extends React.Component {
|
|
180
140
|
Group.displayName = 'Group';
|
181
141
|
|
182
142
|
Group.propTypes = {
|
183
|
-
GA: shape({ category: string }).isRequired,
|
184
143
|
users: arrayOf(
|
185
144
|
shape({
|
186
145
|
id: oneOfType([number, string]).isRequired,
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { render, fireEvent } from '@testing-library/react';
|
3
|
-
import { event } from 'react-ga';
|
4
3
|
|
5
4
|
import Container from '.';
|
6
5
|
|
@@ -25,8 +24,6 @@ const users = [
|
|
25
24
|
}
|
26
25
|
];
|
27
26
|
|
28
|
-
jest.mock('react-ga');
|
29
|
-
|
30
27
|
describe('EmployeePickerContainer', () => {
|
31
28
|
let element;
|
32
29
|
let onClick;
|
@@ -37,7 +34,6 @@ describe('EmployeePickerContainer', () => {
|
|
37
34
|
toggleUsers = jest.fn();
|
38
35
|
element = render(
|
39
36
|
<Container
|
40
|
-
GA={{ category: 'category' }}
|
41
37
|
title="No group"
|
42
38
|
users={users}
|
43
39
|
onClick={onClick}
|
@@ -67,25 +63,16 @@ describe('EmployeePickerContainer', () => {
|
|
67
63
|
it('should allow the user to select the group', () => {
|
68
64
|
fireEvent.click(element.getByText('Select group'));
|
69
65
|
expect(toggleUsers).toHaveBeenCalledWith([1, 2]);
|
70
|
-
expect(event).toHaveBeenLastCalledWith({
|
71
|
-
action: 'Select Group',
|
72
|
-
category: 'category'
|
73
|
-
});
|
74
66
|
});
|
75
67
|
|
76
68
|
it('should allow the user to deselect the group', () => {
|
77
69
|
fireEvent.click(element.getByText('Deselect group'));
|
78
70
|
expect(toggleUsers).toHaveBeenCalledWith([3]);
|
79
|
-
expect(event).toHaveBeenLastCalledWith({
|
80
|
-
action: 'Deselect Group',
|
81
|
-
category: 'category'
|
82
|
-
});
|
83
71
|
});
|
84
72
|
|
85
73
|
it('should hide the button group if hideButtons is true', () => {
|
86
74
|
element.rerender(
|
87
75
|
<Container
|
88
|
-
GA={{ category: 'category' }}
|
89
76
|
title="No group"
|
90
77
|
users={users}
|
91
78
|
onClick={onClick}
|
@@ -108,19 +95,11 @@ describe('EmployeePickerContainer', () => {
|
|
108
95
|
expect(
|
109
96
|
element.container.querySelector('[data-e2e="Group-No group"]')
|
110
97
|
).not.toBeVisible();
|
111
|
-
expect(event).toHaveBeenLastCalledWith({
|
112
|
-
action: 'Contract No Group',
|
113
|
-
category: 'category'
|
114
|
-
});
|
115
98
|
|
116
99
|
fireEvent.click(element.getByText('No group (1)'));
|
117
100
|
|
118
101
|
expect(
|
119
102
|
element.container.querySelector('[data-e2e="Group-No group"]')
|
120
103
|
).toBeVisible();
|
121
|
-
expect(event).toHaveBeenLastCalledWith({
|
122
|
-
action: 'Expand No Group',
|
123
|
-
category: 'category'
|
124
|
-
});
|
125
104
|
});
|
126
105
|
});
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { arrayOf, string, func
|
3
|
-
|
2
|
+
import { arrayOf, string, func } from 'prop-types';
|
4
3
|
import styled from 'styled-components';
|
5
4
|
import Colors from 'constants/colors';
|
6
5
|
import Spacing from 'constants/spacing';
|
7
6
|
import Variables from 'constants/vars';
|
8
|
-
import { event } from 'react-ga';
|
9
7
|
|
10
8
|
const Option = styled.label`
|
11
9
|
display: inline-block;
|
@@ -47,7 +45,6 @@ const FilterRadioGroup = ({
|
|
47
45
|
options,
|
48
46
|
handleFilter,
|
49
47
|
selectedOption,
|
50
|
-
GA,
|
51
48
|
name,
|
52
49
|
...props
|
53
50
|
}) => {
|
@@ -63,11 +60,6 @@ const FilterRadioGroup = ({
|
|
63
60
|
data-testid="filter-buttons"
|
64
61
|
onChange={() => {
|
65
62
|
handleFilter(option);
|
66
|
-
event({
|
67
|
-
action: GA.action,
|
68
|
-
category: GA.category,
|
69
|
-
label: option
|
70
|
-
});
|
71
63
|
}}
|
72
64
|
type="radio"
|
73
65
|
name="filters"
|
@@ -83,11 +75,7 @@ FilterRadioGroup.propTypes = {
|
|
83
75
|
options: arrayOf(string).isRequired,
|
84
76
|
handleFilter: func.isRequired,
|
85
77
|
name: string.isRequired,
|
86
|
-
selectedOption: string
|
87
|
-
GA: shape({
|
88
|
-
category: string,
|
89
|
-
action: string
|
90
|
-
}).isRequired
|
78
|
+
selectedOption: string
|
91
79
|
};
|
92
80
|
|
93
81
|
FilterRadioGroup.defaultProps = {
|
@@ -1,12 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { render, fireEvent, getByTestId } from '@testing-library/react';
|
3
3
|
import Colors from 'constants/colors';
|
4
|
-
import { event } from 'react-ga';
|
5
|
-
|
6
4
|
import FilterRadioGroup from '.';
|
7
5
|
|
8
|
-
jest.mock('react-ga');
|
9
|
-
|
10
6
|
describe('FilterRadioGroup', () => {
|
11
7
|
it('should render filter buttons for each supplied string', () => {
|
12
8
|
const { getAllByTestId } = render(
|
@@ -14,7 +10,6 @@ describe('FilterRadioGroup', () => {
|
|
14
10
|
options={['string1', 'string2', 'string3']}
|
15
11
|
handleFilter={() => {}}
|
16
12
|
selected={undefined}
|
17
|
-
GA={{ category: 'category', action: 'action' }}
|
18
13
|
name="filters"
|
19
14
|
/>
|
20
15
|
);
|
@@ -29,18 +24,12 @@ describe('FilterRadioGroup', () => {
|
|
29
24
|
options={['string1', 'string2']}
|
30
25
|
handleFilter={handleFilter}
|
31
26
|
selected={undefined}
|
32
|
-
GA={{ category: 'category', action: 'action' }}
|
33
27
|
name="filters"
|
34
28
|
/>
|
35
29
|
);
|
36
30
|
|
37
31
|
fireEvent.click(getAllByTestId('filter-buttons')[1]);
|
38
32
|
expect(handleFilter).toHaveBeenCalledWith('string2');
|
39
|
-
expect(event).toHaveBeenCalledWith({
|
40
|
-
action: 'action',
|
41
|
-
category: 'category',
|
42
|
-
label: 'string2'
|
43
|
-
});
|
44
33
|
});
|
45
34
|
|
46
35
|
it('should default with a selected state', () => {
|
@@ -49,7 +38,6 @@ describe('FilterRadioGroup', () => {
|
|
49
38
|
options={['string1', 'string2', 'string3']}
|
50
39
|
handleFilter={() => {}}
|
51
40
|
selectedOption="string2"
|
52
|
-
GA={{ category: 'category', action: 'action' }}
|
53
41
|
name="filters"
|
54
42
|
/>
|
55
43
|
);
|
@@ -66,7 +54,6 @@ describe('FilterRadioGroup', () => {
|
|
66
54
|
name="filters"
|
67
55
|
handleFilter={() => {}}
|
68
56
|
selectedOption="string2"
|
69
|
-
GA={{ category: 'category', action: 'action' }}
|
70
57
|
/>
|
71
58
|
);
|
72
59
|
|
@@ -6,11 +6,8 @@ import set from 'lodash.set';
|
|
6
6
|
import get from 'lodash.get';
|
7
7
|
import cloneDeep from 'lodash.clonedeep';
|
8
8
|
import isEqual from 'fast-deep-equal';
|
9
|
-
|
10
9
|
import autoBind from 'react-autobind';
|
11
|
-
|
12
10
|
import Validation from 'components/Validation';
|
13
|
-
import trackForm from 'utils/trackForm';
|
14
11
|
import runFormValidation from './utils/runFormValidation';
|
15
12
|
|
16
13
|
const setData = (original, key, value) => {
|
@@ -45,9 +42,6 @@ class Form extends Component {
|
|
45
42
|
this.props.fieldValidation
|
46
43
|
);
|
47
44
|
|
48
|
-
const analyticsTracking = trackForm(props.name);
|
49
|
-
let currentValue;
|
50
|
-
|
51
45
|
this.state = {
|
52
46
|
error: false,
|
53
47
|
formData: initialData,
|
@@ -57,38 +51,6 @@ class Form extends Component {
|
|
57
51
|
|
58
52
|
this.initialState = cloneDeep(this.state);
|
59
53
|
|
60
|
-
this.gaChangeField = e => {
|
61
|
-
// special case for checkboxes because hidden so no blur event
|
62
|
-
if (e.target.type === 'checkbox') {
|
63
|
-
analyticsTracking(e);
|
64
|
-
}
|
65
|
-
};
|
66
|
-
|
67
|
-
this.gaButtonClick = e => {
|
68
|
-
if (e.target.type === 'button' || e.target.type === 'submit') {
|
69
|
-
analyticsTracking(e);
|
70
|
-
}
|
71
|
-
};
|
72
|
-
|
73
|
-
this.gaHover = e => {
|
74
|
-
const trackTooltip =
|
75
|
-
e.target && e.target.getAttribute('data-track-tooltip');
|
76
|
-
|
77
|
-
if (trackTooltip) {
|
78
|
-
analyticsTracking(e);
|
79
|
-
}
|
80
|
-
};
|
81
|
-
|
82
|
-
this.gaFocusField = e => {
|
83
|
-
currentValue = e.target.value;
|
84
|
-
};
|
85
|
-
|
86
|
-
this.trackEvent = e => {
|
87
|
-
if (currentValue !== e.target.value) {
|
88
|
-
analyticsTracking(e);
|
89
|
-
}
|
90
|
-
};
|
91
|
-
|
92
54
|
this.componentMounted = false;
|
93
55
|
}
|
94
56
|
|
@@ -355,17 +317,7 @@ class Form extends Component {
|
|
355
317
|
};
|
356
318
|
|
357
319
|
return (
|
358
|
-
|
359
|
-
<form
|
360
|
-
{...props}
|
361
|
-
onSubmit={this.onSubmit}
|
362
|
-
onReset={this.onReset}
|
363
|
-
onFocus={this.gaFocusField}
|
364
|
-
onChange={this.gaChangeField}
|
365
|
-
onBlur={this.trackEvent}
|
366
|
-
onClick={this.gaButtonClick}
|
367
|
-
onMouseOver={this.gaHover}
|
368
|
-
>
|
320
|
+
<form {...props} onSubmit={this.onSubmit} onReset={this.onReset}>
|
369
321
|
{children(formApi)}
|
370
322
|
</form>
|
371
323
|
);
|
@@ -3,17 +3,6 @@ import { shallow } from 'enzyme';
|
|
3
3
|
|
4
4
|
import Form from '.';
|
5
5
|
|
6
|
-
const mockTrackEvent = jest.fn();
|
7
|
-
|
8
|
-
jest.mock('utils/trackForm', () =>
|
9
|
-
jest.fn(name => e =>
|
10
|
-
mockTrackEvent({
|
11
|
-
name,
|
12
|
-
...e
|
13
|
-
})
|
14
|
-
)
|
15
|
-
);
|
16
|
-
|
17
6
|
const NOOP = () => {};
|
18
7
|
|
19
8
|
it('should render a form element', () => {
|
@@ -1109,13 +1098,6 @@ describe('FormApi', () => {
|
|
1109
1098
|
value: 'pass'
|
1110
1099
|
}
|
1111
1100
|
});
|
1112
|
-
|
1113
|
-
expect(mockTrackEvent).toHaveBeenCalledWith(
|
1114
|
-
expect.objectContaining({
|
1115
|
-
name: 'Form',
|
1116
|
-
target: { name: 'name', value: 'pass' }
|
1117
|
-
})
|
1118
|
-
);
|
1119
1101
|
});
|
1120
1102
|
|
1121
1103
|
it("should not track when a user focuses on a field but doesn't change it", () => {
|
@@ -1146,8 +1128,6 @@ describe('FormApi', () => {
|
|
1146
1128
|
value: 'pass'
|
1147
1129
|
}
|
1148
1130
|
});
|
1149
|
-
|
1150
|
-
expect(mockTrackEvent).not.toHaveBeenCalled();
|
1151
1131
|
});
|
1152
1132
|
|
1153
1133
|
it('should track when a user clicks a button', () => {
|
@@ -1171,17 +1151,6 @@ describe('FormApi', () => {
|
|
1171
1151
|
type: 'button'
|
1172
1152
|
}
|
1173
1153
|
});
|
1174
|
-
|
1175
|
-
expect(mockTrackEvent).toHaveBeenCalledWith(
|
1176
|
-
expect.objectContaining({
|
1177
|
-
name: 'Form',
|
1178
|
-
target: {
|
1179
|
-
name: 'name',
|
1180
|
-
value: 'pass',
|
1181
|
-
type: 'button'
|
1182
|
-
}
|
1183
|
-
})
|
1184
|
-
);
|
1185
1154
|
});
|
1186
1155
|
|
1187
1156
|
it('should track when a user clicks a submit button', () => {
|
@@ -1205,17 +1174,6 @@ describe('FormApi', () => {
|
|
1205
1174
|
type: 'submit'
|
1206
1175
|
}
|
1207
1176
|
});
|
1208
|
-
|
1209
|
-
expect(mockTrackEvent).toHaveBeenCalledWith(
|
1210
|
-
expect.objectContaining({
|
1211
|
-
name: 'Form',
|
1212
|
-
target: {
|
1213
|
-
name: 'name',
|
1214
|
-
value: 'pass',
|
1215
|
-
type: 'submit'
|
1216
|
-
}
|
1217
|
-
})
|
1218
|
-
);
|
1219
1177
|
});
|
1220
1178
|
|
1221
1179
|
it('should not track when a user clicks an input', () => {
|
@@ -1239,8 +1197,6 @@ describe('FormApi', () => {
|
|
1239
1197
|
type: 'input'
|
1240
1198
|
}
|
1241
1199
|
});
|
1242
|
-
|
1243
|
-
expect(mockTrackEvent).not.toHaveBeenCalled();
|
1244
1200
|
});
|
1245
1201
|
|
1246
1202
|
it('should track when a user hovers over a tooltip', () => {
|
@@ -1269,18 +1225,6 @@ describe('FormApi', () => {
|
|
1269
1225
|
type: 'submit'
|
1270
1226
|
}
|
1271
1227
|
});
|
1272
|
-
|
1273
|
-
expect(mockTrackEvent).toHaveBeenCalledWith(
|
1274
|
-
expect.objectContaining({
|
1275
|
-
name: 'Form',
|
1276
|
-
target: {
|
1277
|
-
getAttribute: expect.any(Function),
|
1278
|
-
name: 'name',
|
1279
|
-
value: 'pass',
|
1280
|
-
type: 'submit'
|
1281
|
-
}
|
1282
|
-
})
|
1283
|
-
);
|
1284
1228
|
});
|
1285
1229
|
|
1286
1230
|
it('should not track when a user hovers over anything other than a tooltip', () => {
|
@@ -1309,8 +1253,6 @@ describe('FormApi', () => {
|
|
1309
1253
|
type: 'submit'
|
1310
1254
|
}
|
1311
1255
|
});
|
1312
|
-
|
1313
|
-
expect(mockTrackEvent).not.toHaveBeenCalled();
|
1314
1256
|
});
|
1315
1257
|
|
1316
1258
|
it('should track when a user changes a checkbox', () => {
|
@@ -1334,17 +1276,6 @@ describe('FormApi', () => {
|
|
1334
1276
|
type: 'checkbox'
|
1335
1277
|
}
|
1336
1278
|
});
|
1337
|
-
|
1338
|
-
expect(mockTrackEvent).toHaveBeenCalledWith(
|
1339
|
-
expect.objectContaining({
|
1340
|
-
name: 'Form',
|
1341
|
-
target: {
|
1342
|
-
name: 'name',
|
1343
|
-
value: 'pass',
|
1344
|
-
type: 'checkbox'
|
1345
|
-
}
|
1346
|
-
})
|
1347
|
-
);
|
1348
1279
|
});
|
1349
1280
|
|
1350
1281
|
it('should not track when a user changes an input', () => {
|
@@ -1368,8 +1299,6 @@ describe('FormApi', () => {
|
|
1368
1299
|
type: 'input'
|
1369
1300
|
}
|
1370
1301
|
});
|
1371
|
-
|
1372
|
-
expect(mockTrackEvent).not.toHaveBeenCalled();
|
1373
1302
|
});
|
1374
1303
|
|
1375
1304
|
it('should not track when a user clicks a checkbox', () => {
|
@@ -1393,8 +1322,6 @@ describe('FormApi', () => {
|
|
1393
1322
|
type: 'checkbox'
|
1394
1323
|
}
|
1395
1324
|
});
|
1396
|
-
|
1397
|
-
expect(mockTrackEvent).not.toHaveBeenCalled();
|
1398
1325
|
});
|
1399
1326
|
});
|
1400
1327
|
|
@@ -6,7 +6,6 @@ import get from 'lodash.get';
|
|
6
6
|
import spacing from 'constants/spacing';
|
7
7
|
import vars from 'constants/vars';
|
8
8
|
import colors from 'constants/colors';
|
9
|
-
import autobind from 'react-autobind';
|
10
9
|
|
11
10
|
const MODAL_WIDTHS = vars.modalWidths;
|
12
11
|
|
@@ -60,12 +59,6 @@ ModalContainer.displayName = 'ModalContainer';
|
|
60
59
|
Background.displayName = 'Background';
|
61
60
|
|
62
61
|
class Modal extends React.Component {
|
63
|
-
constructor(props) {
|
64
|
-
super(props);
|
65
|
-
this.state = { createdElement: null };
|
66
|
-
autobind(this);
|
67
|
-
}
|
68
|
-
|
69
62
|
componentDidMount() {
|
70
63
|
/* istanbul ignore next */
|
71
64
|
if (this.props.version === '1') {
|
@@ -74,20 +67,10 @@ class Modal extends React.Component {
|
|
74
67
|
}
|
75
68
|
|
76
69
|
document.body.style.overflow = 'hidden';
|
77
|
-
|
78
|
-
const randomId = Math.random().toString();
|
79
|
-
const wrapperElement = document.createElement('div');
|
80
|
-
wrapperElement.setAttribute('id', `modal${randomId}`);
|
81
|
-
document.body.appendChild(wrapperElement);
|
82
|
-
this.setState({ createdElement: wrapperElement });
|
83
70
|
}
|
84
71
|
|
85
72
|
componentWillUnmount() {
|
86
73
|
document.body.style.overflow = 'auto';
|
87
|
-
|
88
|
-
this.state.createdElement.parentNode.removeChild(
|
89
|
-
this.state.createdElement
|
90
|
-
);
|
91
74
|
}
|
92
75
|
|
93
76
|
render() {
|
@@ -108,10 +91,6 @@ class Modal extends React.Component {
|
|
108
91
|
}
|
109
92
|
};
|
110
93
|
|
111
|
-
if (!this.state.createdElement) {
|
112
|
-
return null;
|
113
|
-
}
|
114
|
-
|
115
94
|
return createPortal(
|
116
95
|
<Background
|
117
96
|
onClick={dismiss}
|
@@ -138,7 +117,7 @@ class Modal extends React.Component {
|
|
138
117
|
})}
|
139
118
|
</ModalContainer>
|
140
119
|
</Background>,
|
141
|
-
|
120
|
+
document.body
|
142
121
|
);
|
143
122
|
}
|
144
123
|
}
|
@@ -11,7 +11,7 @@ describe('<Modal />', () => {
|
|
11
11
|
beforeEach(() => {
|
12
12
|
width = 'small';
|
13
13
|
wrapper = render(
|
14
|
-
<Modal close={closeFn} width={width}>
|
14
|
+
<Modal close={closeFn} width={width} version="2">
|
15
15
|
<Header>Modal Title</Header>
|
16
16
|
</Modal>
|
17
17
|
);
|
@@ -31,7 +31,7 @@ describe('<Modal />', () => {
|
|
31
31
|
closeFn = jest.fn(Modal.defaultProps.close);
|
32
32
|
Modal.defaultProps.close = closeFn;
|
33
33
|
wrapper.rerender(
|
34
|
-
<Modal close={closeFn}>
|
34
|
+
<Modal close={closeFn} version="2">
|
35
35
|
<Header>Modal Title</Header>
|
36
36
|
</Modal>
|
37
37
|
);
|
@@ -47,7 +47,7 @@ describe('<Modal />', () => {
|
|
47
47
|
it('should not call a function if bgDismiss is false', () => {
|
48
48
|
closeFn = jest.fn();
|
49
49
|
wrapper.rerender(
|
50
|
-
<Modal close={closeFn} bgDismiss={false}>
|
50
|
+
<Modal version="2" close={closeFn} bgDismiss={false}>
|
51
51
|
<Header>Modal Title</Header>
|
52
52
|
</Modal>
|
53
53
|
);
|
@@ -64,7 +64,7 @@ describe('<Modal />', () => {
|
|
64
64
|
|
65
65
|
width = 'medium';
|
66
66
|
wrapper.rerender(
|
67
|
-
<Modal close={closeFn} width={width}>
|
67
|
+
<Modal version="2" close={closeFn} width={width}>
|
68
68
|
<Header>Modal Title</Header>
|
69
69
|
</Modal>
|
70
70
|
);
|
@@ -81,7 +81,7 @@ describe('<Modal />', () => {
|
|
81
81
|
|
82
82
|
it('should call the correct function on the onClick event handler', () => {
|
83
83
|
wrapper.rerender(
|
84
|
-
<Modal close={closeFn} width={width}>
|
84
|
+
<Modal version="2" close={closeFn} width={width}>
|
85
85
|
<Header>Modal Title</Header>
|
86
86
|
</Modal>
|
87
87
|
);
|
@@ -95,7 +95,7 @@ describe('<Modal />', () => {
|
|
95
95
|
it('should call the close function on the onClick event handler if bgDismiss is true', () => {
|
96
96
|
const close = jest.fn();
|
97
97
|
wrapper.rerender(
|
98
|
-
<Modal close={close} width={width} bgDismiss>
|
98
|
+
<Modal version="2" close={close} width={width} bgDismiss>
|
99
99
|
<Header>Modal Title</Header>
|
100
100
|
</Modal>
|
101
101
|
);
|
@@ -113,7 +113,7 @@ describe('<Modal />', () => {
|
|
113
113
|
|
114
114
|
const createModalWithConditionallyRenderedChildren = () =>
|
115
115
|
render(
|
116
|
-
<Modal>
|
116
|
+
<Modal version="2">
|
117
117
|
<Header>Modal Title</Header>
|
118
118
|
{notTrue && <div>stuff</div>}
|
119
119
|
</Modal>
|
@@ -126,7 +126,7 @@ describe('<Modal />', () => {
|
|
126
126
|
|
127
127
|
it('assigns the correct overflow style to the wrapper if you pass the prop', () => {
|
128
128
|
wrapper.rerender(
|
129
|
-
<Modal close={closeFn} allowOverflow={false}>
|
129
|
+
<Modal version="2" close={closeFn} allowOverflow={false}>
|
130
130
|
<Header>Modal Title</Header>
|
131
131
|
</Modal>
|
132
132
|
);
|
@@ -135,7 +135,7 @@ describe('<Modal />', () => {
|
|
135
135
|
expect(modalContainer).toHaveStyleRule('overflow-x', 'hidden');
|
136
136
|
|
137
137
|
wrapper.rerender(
|
138
|
-
<Modal close={closeFn} allowOverflow>
|
138
|
+
<Modal version="2" close={closeFn} allowOverflow>
|
139
139
|
<Header>Modal Title</Header>
|
140
140
|
</Modal>
|
141
141
|
);
|