@ht-sdks/consent-manager 0.1.0 → 0.2.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/commonjs/__tests__/consent-manager/dialog.test.js +33 -0
- package/commonjs/__tests__/consent-manager-builder/analytics.test.js +135 -46
- package/commonjs/__tests__/consent-manager-builder/index.todo.js +48 -87
- package/commonjs/__tests__/consent-manager-builder/preferences.test.js +136 -55
- package/commonjs/__tests__/index.test.js +12 -12
- package/commonjs/consent-manager/banner.js +35 -19
- package/commonjs/consent-manager/buttons.js +5 -5
- package/commonjs/consent-manager/cancel-dialog.js +26 -10
- package/commonjs/consent-manager/categories.js +2 -2
- package/commonjs/consent-manager/container.js +2 -3
- package/commonjs/consent-manager/dialog.js +39 -23
- package/commonjs/consent-manager/font-styles.js +2 -2
- package/commonjs/consent-manager/index.js +41 -25
- package/commonjs/consent-manager/preference-dialog.js +36 -20
- package/commonjs/consent-manager-builder/analytics.js +19 -7
- package/commonjs/consent-manager-builder/index.js +31 -30
- package/commonjs/consent-manager-builder/preferences.js +100 -24
- package/commonjs/index.js +5 -4
- package/commonjs/standalone.js +25 -11
- package/esm/__tests__/consent-manager/dialog.test.js +28 -0
- package/esm/__tests__/consent-manager-builder/analytics.test.js +123 -34
- package/esm/__tests__/consent-manager-builder/index.todo.js +34 -73
- package/esm/__tests__/consent-manager-builder/preferences.test.js +135 -54
- package/esm/consent-manager/banner.js +5 -3
- package/esm/consent-manager/buttons.js +4 -4
- package/esm/consent-manager/cancel-dialog.js +4 -2
- package/esm/consent-manager/categories.js +2 -2
- package/esm/consent-manager/container.js +1 -1
- package/esm/consent-manager/dialog.js +7 -5
- package/esm/consent-manager/font-styles.js +2 -2
- package/esm/consent-manager/index.js +19 -17
- package/esm/consent-manager/preference-dialog.js +7 -5
- package/esm/consent-manager-builder/analytics.js +18 -6
- package/esm/consent-manager-builder/index.js +28 -27
- package/esm/consent-manager-builder/preferences.js +96 -20
- package/esm/index.js +4 -3
- package/esm/standalone.js +3 -3
- package/esm/types.js +1 -0
- package/package.json +62 -67
- package/src/__tests__/consent-manager/dialog.test.tsx +42 -0
- package/src/__tests__/consent-manager-builder/analytics.test.ts +75 -33
- package/src/__tests__/consent-manager-builder/index.todo.js +52 -95
- package/src/__tests__/consent-manager-builder/preferences.test.ts +43 -27
- package/src/consent-manager/banner.tsx +11 -11
- package/src/consent-manager/buttons.tsx +26 -10
- package/src/consent-manager/cancel-dialog.tsx +1 -1
- package/src/consent-manager/categories.ts +2 -2
- package/src/consent-manager/container.tsx +14 -17
- package/src/consent-manager/dialog.tsx +4 -4
- package/src/consent-manager/font-styles.tsx +12 -2
- package/src/consent-manager/index.tsx +27 -29
- package/src/consent-manager/preference-dialog.tsx +13 -11
- package/src/consent-manager-builder/analytics.ts +20 -6
- package/src/consent-manager-builder/index.tsx +30 -29
- package/src/consent-manager-builder/preferences.ts +59 -30
- package/src/index.ts +8 -4
- package/src/standalone.tsx +1 -1
- package/src/types.ts +9 -3
- package/standalone/consent-manager.js +5 -10
- package/standalone/consent-manager.js.map +1 -1
- package/types/consent-manager/banner.d.ts +1 -1
- package/types/consent-manager/buttons.d.ts +6 -7
- package/types/consent-manager/cancel-dialog.d.ts +1 -1
- package/types/consent-manager/index.d.ts +3 -3
- package/types/consent-manager/preference-dialog.d.ts +1 -1
- package/types/consent-manager-builder/analytics.d.ts +2 -1
- package/types/consent-manager-builder/index.d.ts +7 -8
- package/types/consent-manager-builder/preferences.d.ts +4 -6
- package/types/index.d.ts +1 -1
- package/types/types.d.ts +15 -11
- package/commonjs/__tests__/consent-manager-builder/fetch-destinations.test.js +0 -155
- package/commonjs/consent-manager-builder/fetch-destinations.js +0 -104
- package/esm/__tests__/consent-manager-builder/fetch-destinations.test.js +0 -150
- package/esm/consent-manager-builder/fetch-destinations.js +0 -98
- package/src/__tests__/consent-manager-builder/fetch-destinations.test.ts +0 -89
- package/src/consent-manager-builder/fetch-destinations.ts +0 -50
- package/types/consent-manager-builder/fetch-destinations.d.ts +0 -2
- package/types/src/__tests__/consent-manager-builder/analytics.test.d.ts +0 -1
- package/types/src/__tests__/consent-manager-builder/fetch-destinations.test.d.ts +0 -1
- package/types/src/__tests__/consent-manager-builder/preferences.test.d.ts +0 -1
- package/types/src/__tests__/index.test.d.ts +0 -1
- package/types/src/consent-manager/banner.d.ts +0 -21
- package/types/src/consent-manager/buttons.d.ts +0 -13
- package/types/src/consent-manager/cancel-dialog.d.ts +0 -19
- package/types/src/consent-manager/categories.d.ts +0 -3
- package/types/src/consent-manager/container.d.ts +0 -35
- package/types/src/consent-manager/dialog.d.ts +0 -29
- package/types/src/consent-manager/font-styles.d.ts +0 -2
- package/types/src/consent-manager/index.d.ts +0 -35
- package/types/src/consent-manager/preference-dialog.d.ts +0 -32
- package/types/src/consent-manager-builder/analytics.d.ts +0 -14
- package/types/src/consent-manager-builder/fetch-destinations.d.ts +0 -2
- package/types/src/consent-manager-builder/index.d.ts +0 -126
- package/types/src/consent-manager-builder/preferences.d.ts +0 -26
- package/types/src/index.d.ts +0 -7
- package/types/src/standalone.d.ts +0 -5
- package/types/src/types.d.ts +0 -130
- /package/types/__tests__/{consent-manager-builder/fetch-destinations.test.d.ts → consent-manager/dialog.test.d.ts} +0 -0
|
@@ -3,7 +3,7 @@ import sinon from 'sinon'
|
|
|
3
3
|
import {
|
|
4
4
|
loadPreferences,
|
|
5
5
|
savePreferences,
|
|
6
|
-
DEFAULT_COOKIE_NAME
|
|
6
|
+
DEFAULT_COOKIE_NAME,
|
|
7
7
|
} from '../../consent-manager-builder/preferences'
|
|
8
8
|
import { HtEventsBrowser } from '../../types'
|
|
9
9
|
|
|
@@ -15,21 +15,21 @@ describe('preferences', () => {
|
|
|
15
15
|
expect(htevents.track.args[0][0]).toBe('Consent Updated')
|
|
16
16
|
expect(htevents.track.args[0][1]).toMatchObject({
|
|
17
17
|
destinationPreferences: destinationPreferences,
|
|
18
|
-
categoryPreferences: customPreferences
|
|
18
|
+
categoryPreferences: customPreferences,
|
|
19
19
|
})
|
|
20
20
|
expect(htevents.track.args[0][2]).toMatchObject({
|
|
21
21
|
consent: {
|
|
22
22
|
destinationPreferences: destinationPreferences,
|
|
23
|
-
categoryPreferences: customPreferences
|
|
24
|
-
}
|
|
23
|
+
categoryPreferences: customPreferences,
|
|
24
|
+
},
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
beforeEach(() => {
|
|
29
29
|
window = {
|
|
30
30
|
location: {
|
|
31
|
-
href: 'http://localhost/'
|
|
32
|
-
}
|
|
31
|
+
href: 'http://localhost/',
|
|
32
|
+
},
|
|
33
33
|
} as Window & typeof globalThis
|
|
34
34
|
|
|
35
35
|
document = {
|
|
@@ -39,7 +39,7 @@ describe('preferences', () => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return
|
|
42
|
-
}
|
|
42
|
+
},
|
|
43
43
|
} as Document
|
|
44
44
|
document.cookie = ''
|
|
45
45
|
|
|
@@ -47,16 +47,26 @@ describe('preferences', () => {
|
|
|
47
47
|
;(window as any).htevents = htevents
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
+
test('loadPreferences() returns empty preferences when cookie is missing', () => {
|
|
51
|
+
expect(loadPreferences()).toEqual({})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('loadPreferences() returns empty preferences when cookie is invalid JSON', () => {
|
|
55
|
+
document.cookie = `${DEFAULT_COOKIE_NAME}=not-json`
|
|
56
|
+
|
|
57
|
+
expect(loadPreferences()).toEqual({})
|
|
58
|
+
})
|
|
59
|
+
|
|
50
60
|
test('loadPreferences() returns preferences when cookie exists', () => {
|
|
51
61
|
document.cookie = `${DEFAULT_COOKIE_NAME}={%22version%22:1%2C%22destination%22:{%22Amplitude%22:true}%2C%22custom%22:{%22functional%22:true}}`
|
|
52
62
|
|
|
53
63
|
expect(loadPreferences()).toMatchObject({
|
|
54
64
|
destinationPreferences: {
|
|
55
|
-
Amplitude: true
|
|
65
|
+
Amplitude: true,
|
|
56
66
|
},
|
|
57
67
|
customPreferences: {
|
|
58
|
-
functional: true
|
|
59
|
-
}
|
|
68
|
+
functional: true,
|
|
69
|
+
},
|
|
60
70
|
})
|
|
61
71
|
})
|
|
62
72
|
|
|
@@ -66,47 +76,53 @@ describe('preferences', () => {
|
|
|
66
76
|
|
|
67
77
|
expect(loadPreferences('custom-tracking-preferences')).toMatchObject({
|
|
68
78
|
destinationPreferences: {
|
|
69
|
-
Amplitude: true
|
|
79
|
+
Amplitude: true,
|
|
70
80
|
},
|
|
71
81
|
customPreferences: {
|
|
72
|
-
functional: true
|
|
73
|
-
}
|
|
82
|
+
functional: true,
|
|
83
|
+
},
|
|
74
84
|
})
|
|
75
85
|
})
|
|
76
86
|
|
|
77
|
-
test('savePreferences() saves the preferences', () => {
|
|
87
|
+
test('savePreferences() saves the preferences', async () => {
|
|
78
88
|
const destinationPreferences = {
|
|
79
|
-
Amplitude: true
|
|
89
|
+
Amplitude: true,
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
const customPreferences = {
|
|
83
|
-
functional: true
|
|
93
|
+
functional: true,
|
|
84
94
|
}
|
|
85
95
|
|
|
86
|
-
savePreferences({
|
|
96
|
+
await savePreferences({
|
|
87
97
|
destinationPreferences,
|
|
88
98
|
customPreferences,
|
|
89
|
-
cookieDomain: undefined
|
|
99
|
+
cookieDomain: undefined,
|
|
90
100
|
})
|
|
91
101
|
|
|
92
102
|
expectConsentUpdatedEvent({ destinationPreferences, customPreferences })
|
|
93
103
|
|
|
94
104
|
expect(document.cookie).toContain(
|
|
95
|
-
`${DEFAULT_COOKIE_NAME}={%22version%22:1%2C%22destination%22:{%22Amplitude%22:true}%2C%22custom%22:{%22functional%22:true}}
|
|
105
|
+
`${DEFAULT_COOKIE_NAME}={%22version%22:1%2C%22destination%22:{%22Amplitude%22:true}%2C%22custom%22:{%22functional%22:true}}`,
|
|
96
106
|
)
|
|
97
107
|
})
|
|
98
108
|
|
|
99
|
-
test('
|
|
109
|
+
test('saves an opt-out without sending a consent update', async () => {
|
|
110
|
+
await savePreferences({ destinationPreferences: { Amplitude: false } })
|
|
111
|
+
expect(loadPreferences().destinationPreferences).toEqual({ Amplitude: false })
|
|
112
|
+
expect(htevents.track.notCalled).toBe(true)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test('savePreferences() sets the cookie domain', async () => {
|
|
100
116
|
const destinationPreferences = {
|
|
101
|
-
Amplitude: true
|
|
117
|
+
Amplitude: true,
|
|
102
118
|
}
|
|
103
119
|
|
|
104
120
|
const customPreferences = undefined
|
|
105
121
|
|
|
106
|
-
savePreferences({
|
|
122
|
+
await savePreferences({
|
|
107
123
|
destinationPreferences,
|
|
108
124
|
customPreferences,
|
|
109
|
-
cookieDomain: 'example.com'
|
|
125
|
+
cookieDomain: 'example.com',
|
|
110
126
|
})
|
|
111
127
|
|
|
112
128
|
expectConsentUpdatedEvent({ destinationPreferences, customPreferences })
|
|
@@ -114,18 +130,18 @@ describe('preferences', () => {
|
|
|
114
130
|
// ToDo: verify cookie domain is set (would need to mock js-cookie since document.cookie doesn't have domain info)
|
|
115
131
|
})
|
|
116
132
|
|
|
117
|
-
test('savePreferences() sets the cookie with custom key', () => {
|
|
133
|
+
test('savePreferences() sets the cookie with custom key', async () => {
|
|
118
134
|
const destinationPreferences = {
|
|
119
|
-
Amplitude: true
|
|
135
|
+
Amplitude: true,
|
|
120
136
|
}
|
|
121
137
|
|
|
122
138
|
const customPreferences = undefined
|
|
123
139
|
|
|
124
|
-
savePreferences({
|
|
140
|
+
await savePreferences({
|
|
125
141
|
destinationPreferences,
|
|
126
142
|
customPreferences,
|
|
127
143
|
cookieDomain: undefined,
|
|
128
|
-
cookieName: 'custom-tracking-preferences'
|
|
144
|
+
cookieName: 'custom-tracking-preferences',
|
|
129
145
|
})
|
|
130
146
|
|
|
131
147
|
expectConsentUpdatedEvent({ destinationPreferences, customPreferences })
|
|
@@ -40,9 +40,9 @@ const RootCentered = styled('div')<RootProps>`
|
|
|
40
40
|
position: relative;
|
|
41
41
|
max-width: 500px;
|
|
42
42
|
padding: 18px;
|
|
43
|
-
padding-right: ${props => (props.hideCloseButton ? '18px' : '40px')};
|
|
44
|
-
background: ${props => props.backgroundColor};
|
|
45
|
-
color: ${props => props.textColor};
|
|
43
|
+
padding-right: ${(props) => (props.hideCloseButton ? '18px' : '40px')};
|
|
44
|
+
background: ${(props) => props.backgroundColor};
|
|
45
|
+
color: ${(props) => props.textColor};
|
|
46
46
|
text-align: center;
|
|
47
47
|
font-size: 14px;
|
|
48
48
|
line-height: 1.3;
|
|
@@ -52,9 +52,9 @@ const Root = styled('div')<RootProps>`
|
|
|
52
52
|
${fontStyles};
|
|
53
53
|
position: relative;
|
|
54
54
|
padding: 8px;
|
|
55
|
-
padding-right: ${props => (props.hideCloseButton ? '8px' : '40px')};
|
|
56
|
-
background: ${props => props.backgroundColor};
|
|
57
|
-
color: ${props => props.textColor};
|
|
55
|
+
padding-right: ${(props) => (props.hideCloseButton ? '8px' : '40px')};
|
|
56
|
+
background: ${(props) => props.backgroundColor};
|
|
57
|
+
color: ${(props) => props.textColor};
|
|
58
58
|
text-align: center;
|
|
59
59
|
font-size: 12px;
|
|
60
60
|
line-height: 1.3;
|
|
@@ -65,10 +65,10 @@ const Root = styled('div')<RootProps>`
|
|
|
65
65
|
`
|
|
66
66
|
|
|
67
67
|
const Content = styled('div')<ContentProps>`
|
|
68
|
-
margin-bottom: ${props => (props.asModal ? '20px' : '8px')};
|
|
68
|
+
margin-bottom: ${(props) => (props.asModal ? '20px' : '8px')};
|
|
69
69
|
@media (min-width: 768px) {
|
|
70
70
|
flex: auto;
|
|
71
|
-
margin-bottom: ${props => (props.asModal ? '20px' : '0')};
|
|
71
|
+
margin-bottom: ${(props) => (props.asModal ? '20px' : '0')};
|
|
72
72
|
}
|
|
73
73
|
a,
|
|
74
74
|
button {
|
|
@@ -109,7 +109,7 @@ interface CloseButtonProps {
|
|
|
109
109
|
const CloseButton = styled('button')<CloseButtonProps>`
|
|
110
110
|
position: absolute;
|
|
111
111
|
right: 8px;
|
|
112
|
-
top: ${props => (props.isTop ? '20px' : '50%')};
|
|
112
|
+
top: ${(props) => (props.isTop ? '20px' : '50%')};
|
|
113
113
|
transform: translateY(-50%);
|
|
114
114
|
padding: 8px;
|
|
115
115
|
border: none;
|
|
@@ -152,7 +152,7 @@ export default class Banner extends PureComponent<BannerProps> {
|
|
|
152
152
|
onAcceptAll,
|
|
153
153
|
onDenyAll,
|
|
154
154
|
hideCloseButton,
|
|
155
|
-
asModal
|
|
155
|
+
asModal,
|
|
156
156
|
} = this.props
|
|
157
157
|
|
|
158
158
|
const RootContent = (
|
|
@@ -169,7 +169,7 @@ export default class Banner extends PureComponent<BannerProps> {
|
|
|
169
169
|
actionsBlock({
|
|
170
170
|
acceptAll: onAcceptAll,
|
|
171
171
|
denyAll: onDenyAll,
|
|
172
|
-
changePreferences: onChangePreferences
|
|
172
|
+
changePreferences: onChangePreferences,
|
|
173
173
|
})}
|
|
174
174
|
{actionsBlock === true && (
|
|
175
175
|
<ActionsBlock id="hightouchio_actionBlock">
|
|
@@ -20,19 +20,25 @@ export const DefaultButton = styled('button')`
|
|
|
20
20
|
margin-right: 8px;
|
|
21
21
|
background-color: #fff;
|
|
22
22
|
background-image: linear-gradient(to top, rgba(67, 90, 111, 0.041), rgba(255, 255, 255, 0.041));
|
|
23
|
-
box-shadow:
|
|
23
|
+
box-shadow:
|
|
24
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.146),
|
|
25
|
+
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.079);
|
|
24
26
|
&:hover {
|
|
25
27
|
background-image: linear-gradient(to top, rgba(67, 90, 111, 0.057), rgba(67, 90, 111, 0.025));
|
|
26
|
-
box-shadow:
|
|
28
|
+
box-shadow:
|
|
29
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.255),
|
|
27
30
|
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.114);
|
|
28
31
|
}
|
|
29
32
|
&:focus {
|
|
30
|
-
box-shadow:
|
|
33
|
+
box-shadow:
|
|
34
|
+
0 0 0 3px rgba(1, 108, 209, 0.146),
|
|
35
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.38),
|
|
31
36
|
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.079);
|
|
32
37
|
}
|
|
33
38
|
&:active {
|
|
34
39
|
background: rgba(1, 108, 209, 0.079);
|
|
35
|
-
box-shadow:
|
|
40
|
+
box-shadow:
|
|
41
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.146),
|
|
36
42
|
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.079);
|
|
37
43
|
}
|
|
38
44
|
`
|
|
@@ -41,18 +47,23 @@ export const GreenButton = styled('button')`
|
|
|
41
47
|
${baseStyles};
|
|
42
48
|
background-color: #47b881;
|
|
43
49
|
background-image: linear-gradient(to top, #3faf77, #47b881);
|
|
44
|
-
box-shadow:
|
|
50
|
+
box-shadow:
|
|
51
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.204),
|
|
52
|
+
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.204);
|
|
45
53
|
color: #fff;
|
|
46
54
|
&:hover {
|
|
47
55
|
background-image: linear-gradient(to top, #37a56d, #3faf77);
|
|
48
56
|
}
|
|
49
57
|
&:focus {
|
|
50
|
-
box-shadow:
|
|
58
|
+
box-shadow:
|
|
59
|
+
0 0 0 3px rgba(71, 184, 129, 0.477),
|
|
60
|
+
inset 0 0 0 1px rgba(71, 184, 129, 0.204),
|
|
51
61
|
inset 0 -1px 1px 0 rgba(71, 184, 129, 0.204);
|
|
52
62
|
}
|
|
53
63
|
&:active {
|
|
54
64
|
background-image: linear-gradient(to top, #2d9760, #248953);
|
|
55
|
-
box-shadow:
|
|
65
|
+
box-shadow:
|
|
66
|
+
inset 0 0 0 1px rgba(71, 184, 129, 0.204),
|
|
56
67
|
inset 0 -1px 1px 0 rgba(71, 184, 129, 0.204);
|
|
57
68
|
}
|
|
58
69
|
`
|
|
@@ -61,18 +72,23 @@ export const RedButton = styled('button')`
|
|
|
61
72
|
${baseStyles};
|
|
62
73
|
background-color: #f36331;
|
|
63
74
|
background-image: linear-gradient(to top, #f4541d, #f36331);
|
|
64
|
-
box-shadow:
|
|
75
|
+
box-shadow:
|
|
76
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.204),
|
|
77
|
+
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.204);
|
|
65
78
|
color: #fff;
|
|
66
79
|
&:hover {
|
|
67
80
|
background-image: linear-gradient(to top, #f4450a, #f4541d);
|
|
68
81
|
}
|
|
69
82
|
&:focus {
|
|
70
|
-
box-shadow:
|
|
83
|
+
box-shadow:
|
|
84
|
+
0 0 0 3px rgba(243, 99, 49, 0.477),
|
|
85
|
+
inset 0 0 0 1px rgba(243, 99, 49, 0.204),
|
|
71
86
|
inset 0 -1px 1px 0 rgba(243, 99, 49, 0.204);
|
|
72
87
|
}
|
|
73
88
|
&:active {
|
|
74
89
|
background-image: linear-gradient(to top, #dd3c06, #c63403);
|
|
75
|
-
box-shadow:
|
|
90
|
+
box-shadow:
|
|
91
|
+
inset 0 0 0 1px rgba(67, 90, 111, 0.204),
|
|
76
92
|
inset 0 -1px 1px 0 rgba(67, 90, 111, 0.204);
|
|
77
93
|
}
|
|
78
94
|
`
|
|
@@ -9,7 +9,7 @@ export const MARKETING_AND_ANALYTICS_CATEGORIES = [
|
|
|
9
9
|
'Realtime Dashboards',
|
|
10
10
|
'Referrals',
|
|
11
11
|
'Surveys',
|
|
12
|
-
'Video'
|
|
12
|
+
'Video',
|
|
13
13
|
]
|
|
14
14
|
|
|
15
15
|
export const ADVERTISING_CATEGORIES = ['Advertising', 'Tag Managers']
|
|
@@ -23,5 +23,5 @@ export const FUNCTIONAL_CATEGORIES = [
|
|
|
23
23
|
'Performance Monitoring',
|
|
24
24
|
'Personalization',
|
|
25
25
|
'SMS & Push Notifications',
|
|
26
|
-
'Security & Fraud'
|
|
26
|
+
'Security & Fraud',
|
|
27
27
|
]
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
DefaultDestinationBehavior,
|
|
12
12
|
ActionsBlockProps,
|
|
13
13
|
PreferenceDialogTemplate,
|
|
14
|
-
CloseBehavior
|
|
14
|
+
CloseBehavior,
|
|
15
15
|
} from '../types'
|
|
16
16
|
|
|
17
17
|
const emitter = new EventEmitter()
|
|
@@ -28,7 +28,7 @@ interface ContainerProps {
|
|
|
28
28
|
saveConsent: (
|
|
29
29
|
newPreferences?: CategoryPreferences,
|
|
30
30
|
shouldReload?: boolean,
|
|
31
|
-
devMode?: boolean
|
|
31
|
+
devMode?: boolean,
|
|
32
32
|
) => void
|
|
33
33
|
resetPreferences: () => void
|
|
34
34
|
closeBehavior?: CloseBehavior | CloseBehaviorFunction
|
|
@@ -61,9 +61,9 @@ function normalizeDestinations(destinations: Destination[]) {
|
|
|
61
61
|
const functionalDestinations: Destination[] = []
|
|
62
62
|
|
|
63
63
|
for (const destination of destinations) {
|
|
64
|
-
if (ADVERTISING_CATEGORIES.find(c => c === destination.category)) {
|
|
64
|
+
if (ADVERTISING_CATEGORIES.find((c) => c === destination.category)) {
|
|
65
65
|
advertisingDestinations.push(destination)
|
|
66
|
-
} else if (FUNCTIONAL_CATEGORIES.find(c => c === destination.category)) {
|
|
66
|
+
} else if (FUNCTIONAL_CATEGORIES.find((c) => c === destination.category)) {
|
|
67
67
|
functionalDestinations.push(destination)
|
|
68
68
|
} else {
|
|
69
69
|
// Fallback to marketing
|
|
@@ -74,25 +74,22 @@ function normalizeDestinations(destinations: Destination[]) {
|
|
|
74
74
|
return { marketingDestinations, advertisingDestinations, functionalDestinations }
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const Container: React.FC<ContainerProps> = props => {
|
|
77
|
+
const Container: React.FC<ContainerProps> = (props) => {
|
|
78
78
|
const [isDialogOpen, toggleDialog] = React.useState(
|
|
79
|
-
false || (props.workspaceAddedNewDestinations && props.defaultDestinationBehavior === 'ask')
|
|
79
|
+
false || (props.workspaceAddedNewDestinations && props.defaultDestinationBehavior === 'ask'),
|
|
80
80
|
)
|
|
81
81
|
const [showBanner, toggleBanner] = React.useState(true)
|
|
82
82
|
const [isCancelling, toggleCancel] = React.useState(false)
|
|
83
83
|
|
|
84
84
|
// check if all preferences are empty, in which case we should show the banner
|
|
85
|
-
const emptyPreferences = Object.values(props.preferences || {}).every(v => v == null)
|
|
85
|
+
const emptyPreferences = Object.values(props.preferences || {}).every((v) => v == null)
|
|
86
86
|
|
|
87
87
|
let banner = React.useRef<HTMLElement>(null)
|
|
88
88
|
let preferenceDialog = React.useRef<HTMLElement>(null)
|
|
89
89
|
let cancelDialog = React.useRef<HTMLElement>(null)
|
|
90
90
|
|
|
91
|
-
const {
|
|
92
|
-
|
|
93
|
-
advertisingDestinations,
|
|
94
|
-
functionalDestinations
|
|
95
|
-
} = normalizeDestinations(props.destinations)
|
|
91
|
+
const { marketingDestinations, advertisingDestinations, functionalDestinations } =
|
|
92
|
+
normalizeDestinations(props.destinations)
|
|
96
93
|
|
|
97
94
|
const onAcceptAll = () => {
|
|
98
95
|
const truePreferences: CategoryPreferences = props.preferences
|
|
@@ -148,7 +145,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
148
145
|
|
|
149
146
|
const showDialog = () => toggleDialog(true)
|
|
150
147
|
|
|
151
|
-
const handleBodyClick = e => {
|
|
148
|
+
const handleBodyClick = (e) => {
|
|
152
149
|
// Do nothing if no new implicit consent needs to be saved
|
|
153
150
|
if (
|
|
154
151
|
!props.isConsentRequired ||
|
|
@@ -194,7 +191,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
194
191
|
|
|
195
192
|
const handleCategoryChange = (category: string, value: boolean) => {
|
|
196
193
|
props.setPreferences({
|
|
197
|
-
[category]: value
|
|
194
|
+
[category]: value,
|
|
198
195
|
})
|
|
199
196
|
}
|
|
200
197
|
|
|
@@ -229,7 +226,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
229
226
|
props.isConsentRequired &&
|
|
230
227
|
(props.newDestinations.length > 0 || emptyPreferences) && (
|
|
231
228
|
<Banner
|
|
232
|
-
innerRef={current => (banner = { current })}
|
|
229
|
+
innerRef={(current) => (banner = { current })}
|
|
233
230
|
onClose={onClose}
|
|
234
231
|
onChangePreferences={() => toggleDialog(true)}
|
|
235
232
|
content={props.bannerContent}
|
|
@@ -249,7 +246,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
249
246
|
customCategories={props.customCategories}
|
|
250
247
|
destinations={props.destinations}
|
|
251
248
|
preferences={props.preferences}
|
|
252
|
-
innerRef={current => (preferenceDialog = { current })}
|
|
249
|
+
innerRef={(current) => (preferenceDialog = { current })}
|
|
253
250
|
onCancel={handleCancel}
|
|
254
251
|
onSave={handleSave}
|
|
255
252
|
onChange={handleCategoryChange}
|
|
@@ -267,7 +264,7 @@ const Container: React.FC<ContainerProps> = props => {
|
|
|
267
264
|
|
|
268
265
|
{isCancelling && (
|
|
269
266
|
<CancelDialog
|
|
270
|
-
innerRef={current => (cancelDialog = { current })}
|
|
267
|
+
innerRef={(current) => (cancelDialog = { current })}
|
|
271
268
|
onBack={handleCancelBack}
|
|
272
269
|
onConfirm={handleCancelConfirm}
|
|
273
270
|
title={props.cancelDialogTitle}
|
|
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'
|
|
|
3
3
|
import styled from '@emotion/styled'
|
|
4
4
|
import { keyframes } from '@emotion/react'
|
|
5
5
|
|
|
6
|
-
import nanoid from 'nanoid'
|
|
6
|
+
import { nanoid } from 'nanoid'
|
|
7
7
|
import fontStyles from './font-styles'
|
|
8
8
|
|
|
9
9
|
const ANIMATION_DURATION = '200ms'
|
|
@@ -43,7 +43,7 @@ const Root = styled('section')<RootProps>`
|
|
|
43
43
|
flex-direction: column;
|
|
44
44
|
max-width: calc(100vw - 16px);
|
|
45
45
|
max-height: calc(100% - 16px);
|
|
46
|
-
width: ${props => props.width};
|
|
46
|
+
width: ${(props) => props.width};
|
|
47
47
|
margin: 8px;
|
|
48
48
|
background: #fff;
|
|
49
49
|
border-radius: 8px;
|
|
@@ -133,7 +133,7 @@ export default class Dialog extends PureComponent<DialogProps, {}> {
|
|
|
133
133
|
|
|
134
134
|
static defaultProps = {
|
|
135
135
|
onCancel: undefined,
|
|
136
|
-
width: '750px'
|
|
136
|
+
width: '750px',
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
constructor(props: DialogProps) {
|
|
@@ -218,7 +218,7 @@ export default class Dialog extends PureComponent<DialogProps, {}> {
|
|
|
218
218
|
this.form = node
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
handleOverlayClick = e => {
|
|
221
|
+
handleOverlayClick = (e) => {
|
|
222
222
|
const { onCancel } = this.props
|
|
223
223
|
// Ignore propogated clicks from inside the dialog
|
|
224
224
|
if (onCancel && this.root && !this.root.contains(e.target)) {
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { css } from '@emotion/react'
|
|
2
2
|
|
|
3
3
|
export default css`
|
|
4
|
-
font-family:
|
|
5
|
-
|
|
4
|
+
font-family:
|
|
5
|
+
system-ui,
|
|
6
|
+
-apple-system,
|
|
7
|
+
BlinkMacSystemFont,
|
|
8
|
+
'Segoe UI',
|
|
9
|
+
Roboto,
|
|
10
|
+
Helvetica,
|
|
11
|
+
Arial,
|
|
12
|
+
sans-serif,
|
|
13
|
+
'Apple Color Emoji',
|
|
14
|
+
'Segoe UI Emoji',
|
|
15
|
+
'Segoe UI Symbol';
|
|
6
16
|
-moz-osx-font-smoothing: grayscale;
|
|
7
17
|
-webkit-font-smoothing: antialiased;
|
|
8
18
|
font-smoothing: antialiased;
|