@washingtonpost/subs-de-inputs 0.4.2-canary.0 → 0.5.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DEDisclosure/hooks/useOnetrustAlertBoxClosedPromise.d.ts +23 -0
- package/dist/components/DEDisclosure/index.d.ts +12 -0
- package/dist/components/DEDisclosure/utils/checkCookie.d.ts +1 -0
- package/dist/components/DEDisclosure/utils/getConfig.d.ts +2 -0
- package/dist/components/DESelect/index.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/interfaces/disclosure.d.ts +8 -0
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/subs-de-inputs.cjs.development.js +183 -0
- package/dist/subs-de-inputs.cjs.development.js.map +1 -1
- package/dist/subs-de-inputs.cjs.production.min.js +1 -1
- package/dist/subs-de-inputs.cjs.production.min.js.map +1 -1
- package/dist/subs-de-inputs.esm.js +184 -2
- package/dist/subs-de-inputs.esm.js.map +1 -1
- package/dist/utils/isAnonymousWebview.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ICookieStore } from '@washingtonpost/subs-sdk';
|
|
2
|
+
declare type TCData = {
|
|
3
|
+
eventStatus: 'tcloaded' | 'cmpuishown' | 'useractioncomplete';
|
|
4
|
+
listenerId: number;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
declare type TCFAPIAddListener = (command: 'addEventListener', version: number, callback: (tcData: TCData, success: boolean) => void) => void;
|
|
8
|
+
declare type TCFAPIRmListener = (command: 'removeEventListener', version: number, callback: (success: boolean) => void, listenerId: number) => void;
|
|
9
|
+
declare type TCFAPIPing = (command: 'ping', version: number, callback: (pingReturn: any, success: boolean) => void) => void;
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
cookieStore?: ICookieStore;
|
|
13
|
+
__tcfapi?: TCFAPIAddListener & TCFAPIRmListener & TCFAPIPing;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare const useOneTrustAlertBoxClosed: ({ allowCookieStore, }: {
|
|
17
|
+
allowCookieStore: boolean;
|
|
18
|
+
}) => {
|
|
19
|
+
alertBoxClosed: boolean | undefined;
|
|
20
|
+
listenToCookieStore: boolean;
|
|
21
|
+
listenToTcfApi: boolean;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DisclosureProps {
|
|
3
|
+
/** callback function to be called when the disclosure is finished loading */
|
|
4
|
+
onFinished?: ({ isFinished, isError, }: {
|
|
5
|
+
isFinished: boolean;
|
|
6
|
+
isError: boolean;
|
|
7
|
+
}) => void;
|
|
8
|
+
/** ability to turn off cookiestore listener, primarily for testing purposes */
|
|
9
|
+
allowCookieStore?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEDisclosure: React.FC<DisclosureProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const checkCookie: () => boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare type DisclosureConfigValue = {
|
|
2
|
+
disclosure: JSX.Element;
|
|
3
|
+
} & {
|
|
4
|
+
checkBannerStatus: boolean;
|
|
5
|
+
disclosure_beforebanner: JSX.Element;
|
|
6
|
+
disclosure_afterbanner: JSX.Element;
|
|
7
|
+
};
|
|
8
|
+
export declare type DisclosureConfig = Record<string, DisclosureConfigValue>;
|
|
@@ -18,7 +18,7 @@ export declare type Attribute = {
|
|
|
18
18
|
multiple_value: boolean;
|
|
19
19
|
last_modified_date: Number;
|
|
20
20
|
date_created: Number;
|
|
21
|
-
values:
|
|
21
|
+
values: AttributeValue[] | Readonly<AttributeValue[]>;
|
|
22
22
|
};
|
|
23
23
|
export declare const AttributesState: {
|
|
24
24
|
readonly SUCCESS: "100";
|
|
@@ -150,6 +150,14 @@ const ingest = async _ref => {
|
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
+
const isAnonymousWebview = () => {
|
|
154
|
+
if (typeof window === 'undefined') {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const wp_wv = subsSdk.getCookie('wp_wv');
|
|
158
|
+
return !!(wp_wv && !subsSdk.isLoggedIn());
|
|
159
|
+
};
|
|
160
|
+
|
|
153
161
|
const push = async _ref => {
|
|
154
162
|
let {
|
|
155
163
|
submitData,
|
|
@@ -158,6 +166,9 @@ const push = async _ref => {
|
|
|
158
166
|
if (!hasRequiredPrivacyCookies()) {
|
|
159
167
|
throw new Error('does not satisfy cookie check');
|
|
160
168
|
}
|
|
169
|
+
if (isAnonymousWebview()) {
|
|
170
|
+
throw new Error('does not satisfy cookie check');
|
|
171
|
+
}
|
|
161
172
|
const {
|
|
162
173
|
fieldName
|
|
163
174
|
} = submitData;
|
|
@@ -390,6 +401,7 @@ const DESelect = _ref => {
|
|
|
390
401
|
disabled: true
|
|
391
402
|
} : {};
|
|
392
403
|
// sort and filter out archived values
|
|
404
|
+
// Note: config.values may be readonly
|
|
393
405
|
const values = config ? [...config.values].sort((a, b) => a.order - b.order).filter(value => value.archived !== true).filter(valuesFilter) : [];
|
|
394
406
|
return React__default.createElement(SelectWrapper, null, children && React__default.createElement(wpdsUiKit.Select.Root, {
|
|
395
407
|
onValueChange: e => {
|
|
@@ -432,8 +444,179 @@ const SelectWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
|
|
|
432
444
|
}
|
|
433
445
|
});
|
|
434
446
|
|
|
447
|
+
// const configSrc = `${
|
|
448
|
+
// ENDPOINTS.base === 'https://subscribe.washingtonpost.com'
|
|
449
|
+
// ? 'https://www.washingtonpost.com/subscribe'
|
|
450
|
+
// : ENDPOINTS.base
|
|
451
|
+
// }/config/de/disclosure.json`;
|
|
452
|
+
// revert-me-before-prod
|
|
453
|
+
const configSrc = 'https://subscribe.digitalink.com/config/de/disclosure.json';
|
|
454
|
+
const getConfig = async () => {
|
|
455
|
+
// step 1: fetch config
|
|
456
|
+
const response = await fetch(configSrc);
|
|
457
|
+
const remoteConfig = await response.json();
|
|
458
|
+
// step 2: figure out which part of the config to use
|
|
459
|
+
// if country-specific config found, use that
|
|
460
|
+
const countryCode = subsSdk.WPGeo().country_code;
|
|
461
|
+
const eea = subsSdk.WPGeo().intl_region === 'EEA';
|
|
462
|
+
const configs = Object.keys(remoteConfig);
|
|
463
|
+
let myConfig = undefined;
|
|
464
|
+
configs.forEach(config => {
|
|
465
|
+
if (countryCode && config.split('|').includes(countryCode.toLowerCase())) {
|
|
466
|
+
myConfig = remoteConfig[config];
|
|
467
|
+
} else if (eea && config === 'eea') {
|
|
468
|
+
myConfig = remoteConfig[config];
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
// TODO: Check for billing country also
|
|
472
|
+
// else if no country-specific config, use the default config
|
|
473
|
+
if (typeof myConfig === 'undefined' && remoteConfig['_']) {
|
|
474
|
+
myConfig = remoteConfig['_'];
|
|
475
|
+
}
|
|
476
|
+
return myConfig;
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
const COOKIE = 'OptanonAlertBoxClosed';
|
|
480
|
+
const checkCookie = () => {
|
|
481
|
+
const value = subsSdk.getCookie(COOKIE) || '';
|
|
482
|
+
// Wed May 15 2024 06:29:23 GMT-0500 (Central Daylight Time)
|
|
483
|
+
// "Invalid date" is 12 characters long
|
|
484
|
+
return value.length > 12;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
const COOKIE$1 = 'OptanonAlertBoxClosed';
|
|
488
|
+
const useOneTrustAlertBoxClosed = _ref => {
|
|
489
|
+
let {
|
|
490
|
+
allowCookieStore
|
|
491
|
+
} = _ref;
|
|
492
|
+
const [alertBoxClosed, setAlertBoxClosed] = React.useState();
|
|
493
|
+
const [listenToCookieStore, setListenToCookieStore] = React.useState(false);
|
|
494
|
+
const [listenToTcfApi, setListenToTcfApi] = React.useState(false);
|
|
495
|
+
React.useEffect(() => {
|
|
496
|
+
if (checkCookie()) {
|
|
497
|
+
setAlertBoxClosed(true);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
if (!window.__tcfapi) {
|
|
501
|
+
console.warn('warning: __tcfapi not found');
|
|
502
|
+
}
|
|
503
|
+
if (window.cookieStore && allowCookieStore) {
|
|
504
|
+
setListenToCookieStore(true);
|
|
505
|
+
} else if (window.__tcfapi) {
|
|
506
|
+
setListenToTcfApi(true);
|
|
507
|
+
} else {
|
|
508
|
+
console.warn('warning: neither cookieStore nor __tcfapi found');
|
|
509
|
+
}
|
|
510
|
+
}, []);
|
|
511
|
+
React.useEffect(() => {
|
|
512
|
+
if (listenToCookieStore && window.cookieStore) {
|
|
513
|
+
const cleanupFn = subsSdk.listenToCookieStore(COOKIE$1, () => {
|
|
514
|
+
if (checkCookie()) {
|
|
515
|
+
setAlertBoxClosed(true);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
// cleanup fn
|
|
519
|
+
return () => {
|
|
520
|
+
if (cleanupFn) cleanupFn();
|
|
521
|
+
};
|
|
522
|
+
} else {
|
|
523
|
+
return () => {};
|
|
524
|
+
}
|
|
525
|
+
}, [listenToCookieStore]);
|
|
526
|
+
React.useEffect(() => {
|
|
527
|
+
if (listenToTcfApi && window.__tcfapi) {
|
|
528
|
+
let listenerId;
|
|
529
|
+
const callback = (_tcData, success) => {
|
|
530
|
+
if (success) {
|
|
531
|
+
listenerId = _tcData.listenerId;
|
|
532
|
+
// tcData.eventStatus can be:
|
|
533
|
+
// tcloaded means user has made a choice and we’re ready to check it
|
|
534
|
+
// cmpuishown means the banner is shown
|
|
535
|
+
// useractioncomplete means the user has interacted with the banner
|
|
536
|
+
// but actually if the result for any of these is true, we just use the value of the cookie
|
|
537
|
+
if (checkCookie()) {
|
|
538
|
+
setAlertBoxClosed(true);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
window.__tcfapi('addEventListener', 2, callback);
|
|
543
|
+
// cleanup fn
|
|
544
|
+
return () => {
|
|
545
|
+
if (window.__tcfapi && listenerId) window.__tcfapi('removeEventListener', 2, success => {
|
|
546
|
+
console.debug(success);
|
|
547
|
+
}, listenerId);
|
|
548
|
+
};
|
|
549
|
+
} else {
|
|
550
|
+
return () => {};
|
|
551
|
+
}
|
|
552
|
+
}, [listenToTcfApi]);
|
|
553
|
+
return {
|
|
554
|
+
alertBoxClosed,
|
|
555
|
+
listenToCookieStore,
|
|
556
|
+
listenToTcfApi
|
|
557
|
+
};
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
const DEDisclosure = _ref => {
|
|
561
|
+
let {
|
|
562
|
+
onFinished = () => {},
|
|
563
|
+
allowCookieStore = true
|
|
564
|
+
} = _ref;
|
|
565
|
+
const [disclosure, setDisclosure] = React.useState(null);
|
|
566
|
+
const [myConfig, setMyConfig] = React.useState();
|
|
567
|
+
const {
|
|
568
|
+
alertBoxClosed
|
|
569
|
+
} = useOneTrustAlertBoxClosed({
|
|
570
|
+
allowCookieStore
|
|
571
|
+
});
|
|
572
|
+
React.useEffect(() => {
|
|
573
|
+
(async () => {
|
|
574
|
+
const config = await getConfig();
|
|
575
|
+
setMyConfig(config);
|
|
576
|
+
if (!config) {
|
|
577
|
+
console.error('No config found');
|
|
578
|
+
}
|
|
579
|
+
})();
|
|
580
|
+
}, []);
|
|
581
|
+
React.useEffect(() => {
|
|
582
|
+
if (myConfig) {
|
|
583
|
+
// step 3: set disclosure based on config
|
|
584
|
+
// if config says to check onetrust, check onetrust
|
|
585
|
+
if ('checkBannerStatus' in myConfig && myConfig.checkBannerStatus) {
|
|
586
|
+
// check if onetrust is closed
|
|
587
|
+
// if it is, show the after banner disclosure
|
|
588
|
+
// if it is not, show the before banner disclosure
|
|
589
|
+
if (alertBoxClosed) {
|
|
590
|
+
setDisclosure(myConfig.disclosure_afterbanner);
|
|
591
|
+
} else {
|
|
592
|
+
setDisclosure(myConfig.disclosure_beforebanner);
|
|
593
|
+
}
|
|
594
|
+
} else if ('disclosure' in myConfig) {
|
|
595
|
+
setDisclosure(myConfig.disclosure);
|
|
596
|
+
} else {
|
|
597
|
+
console.error('Invalid config');
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}, [myConfig, alertBoxClosed]);
|
|
601
|
+
React.useEffect(() => {
|
|
602
|
+
if (disclosure) {
|
|
603
|
+
// Is it ok to fire `onFinished` if still waiting for onetrust to load on the page?
|
|
604
|
+
onFinished({
|
|
605
|
+
isFinished: true,
|
|
606
|
+
isError: false
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
}, [disclosure]);
|
|
610
|
+
return disclosure === null ? React__default.createElement("div", {
|
|
611
|
+
"data-test-id": "de-disclosure-loading"
|
|
612
|
+
}) : React__default.createElement("div", {
|
|
613
|
+
"data-test-id": "de-disclosure"
|
|
614
|
+
}, disclosure);
|
|
615
|
+
};
|
|
616
|
+
|
|
435
617
|
exports.AttributesState = AttributesState;
|
|
436
618
|
exports.CollectionBehaviors = CollectionBehaviors;
|
|
619
|
+
exports.DEDisclosure = DEDisclosure;
|
|
437
620
|
exports.DESelect = DESelect;
|
|
438
621
|
exports.IngestResponseState = IngestResponseState;
|
|
439
622
|
exports.IngestType = IngestType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subs-de-inputs.cjs.development.js","sources":["../src/interfaces/index.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/getAttributes.ts","../src/services/sendToGA.ts","../src/services/ingest.ts","../src/utils/push.ts","../src/components/DESelect/Dropdown.tsx","../src/components/DESelect/index.tsx"],"sourcesContent":["export type AttributeValue = {\n name: string;\n date_created: Number;\n last_modified_date: Number;\n archived: boolean;\n order: number;\n};\n\nexport const CollectionBehaviors = {\n COLLECT: 'COLLECT',\n DO_NOT_COLLECT: 'DO_NOT_COLLECT',\n} as const;\n\nexport type Attribute = {\n name: string;\n approved_for_use?: boolean;\n collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];\n datatype: string;\n explicit: boolean;\n multiple_value: boolean;\n last_modified_date: Number;\n date_created: Number;\n values: Array<AttributeValue>;\n};\n\nexport const AttributesState = {\n SUCCESS: '100',\n} as const;\n\nexport const IngestType = {\n EXPLICIT: 'explicit',\n IMPLICIT: 'implicit',\n} as const;\n\nexport const IngestResponseState = {\n SUCCESS: '100',\n SYSTEM_ERROR: '101',\n INVALID_TYPE: '102',\n INVALID_IDENTIFIER: '103',\n INVALID_DATA: '104',\n INVALID_ATTRIBUTE_DEFINITION: '105',\n INVALID_META_DEFINITION: '106',\n UNAUTHENTICATED: '107',\n MISMATCHED_IDENTIFIER: '108',\n DISABLED_ATTRIBUTE_DEFINITION: '109',\n DO_NOT_COLLECT: '110',\n} as const;\n","import { WPGeo, getCookie } from '@washingtonpost/subs-sdk';\n\nexport const hasRequiredPrivacyCookies = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_usp = getCookie('wp_usp');\n\n const countryCode = WPGeo()?.country_code;\n\n return !!(wp_usp && countryCode === 'US');\n};\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n} from '@washingtonpost/subs-sdk';\nimport { Attribute } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nconst attributesCache: Record<string, any> = {};\nexport const getAttributes: GetAttributesType = async ({\n fieldName,\n}: {\n fieldName: string;\n}) => {\n if (attributesCache[fieldName]) {\n return attributesCache[fieldName];\n }\n\n const fieldNames = [fieldName];\n\n try {\n const url = new URL(`${base}/attributes`);\n url.searchParams.set('attributes', fieldNames.join(','));\n\n const data = await fetch(url.toString(), {\n credentials: 'include',\n headers: JSON_HEADERS,\n });\n const json = await data.json();\n\n if (data.ok && json.status === ResponseStatus.SUCCESS) {\n const attributes = json.attributes || [];\n attributesCache[fieldName] = attributes;\n return attributes;\n } else {\n return [];\n }\n } catch (e) {\n console.debug(e);\n return [];\n }\n};\n\ntype GetAttributesType = ({\n fieldName,\n}: {\n fieldName: string;\n}) => Promise<Attribute[]>;\n","const sendGAEvent = (props: {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}): void => {\n if (typeof window === 'undefined') {\n if (__DEV__) console.warn('NO WINDOW');\n return;\n }\n // Initialize dataLayer if needed\n window.dataLayer = window.dataLayer || [];\n\n const eventData: Record<string, any> = {\n ...props,\n };\n window.dataLayer.push(eventData);\n};\n\nexport const sendToGA: SendToGaType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n sendGAEvent({\n event: 'site-onpage-click',\n action: 'site-onpage-click',\n category: 'profile',\n\n label: fieldName,\n 'de-label': fieldName,\n [fieldName]: value,\n\n section: 'profile',\n subsection: source,\n });\n\n return true;\n};\n\ntype SendToGaType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<true>;\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n getCookie,\n} from '@washingtonpost/subs-sdk';\nimport { IngestResponseState, IngestType } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n const jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type: IngestType.EXPLICIT,\n wapo_login_id, // TODO: move this to BE to read from cookie headers\n data: {\n [fieldName]: [value],\n },\n metadata: { source },\n };\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n credentials: 'include',\n headers: JSON_HEADERS,\n body: JSON.stringify(payload),\n });\n\n const json = await response.json();\n\n return json;\n } catch (e) {\n console.debug(e);\n return null;\n }\n};\n\ntype IngestType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<{\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n} | null>;\n","import {\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { getAttributes } from '../services/getAttributes';\nimport { sendToGA } from '../services/sendToGA';\nimport { hasRequiredPrivacyCookies } from './hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from '../services/ingest';\n\nexport const push: PushType = async ({ submitData, source }) => {\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n const { fieldName } = submitData;\n\n const attributeInfo = await getAttributes({\n fieldName,\n });\n\n if (\n attributeInfo[0] &&\n attributeInfo[0].name === fieldName &&\n attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT\n ) {\n throw new Error('do not collect');\n }\n\n const type =\n attributeInfo[0] && attributeInfo[0].explicit === true\n ? IngestType.EXPLICIT\n : IngestType.IMPLICIT;\n\n if (!attributeInfo[0] && __DEV__) {\n console.warn(`no attribute info found for ${fieldName}, assuming implicit`);\n }\n\n if (type === IngestType.EXPLICIT) {\n return ingest({ submitData, source });\n } else {\n return sendToGA({ submitData, source });\n }\n};\n\ntype PushType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<\n | {\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n }\n | null\n | true\n>;\n","import React, { useEffect, useState } from 'react';\nimport { Icon, Select, styled, theme } from '@washingtonpost/wpds-ui-kit';\nimport { useWindowSize } from '@washingtonpost/subs-hooks';\nimport { ChevronDown } from '@washingtonpost/wpds-assets';\n\ninterface IDropdownProps {\n id: string;\n label: string;\n values: Array<string>;\n required?: boolean;\n defaultValue?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n}\n\nconst StyledMobileSelect = styled('select', {\n padding: '12px 16px 12px 6px',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n backgroundColor: '$secondary',\n color: '$primary',\n fontFamily: '$meta',\n fontSize: '$100',\n fontWeight: '$light',\n lineHeight: '$125',\n paddingBlockRight: '$125',\n textOverflow: 'ellipsis',\n position: 'relative',\n borderColor: 'transparent',\n borderRightWidth: '10px',\n borderRightColor: 'transparent',\n appearance: 'none',\n '-webkit-appearance': 'none',\n '&:disabled': {\n backgroundColor: theme.colors.disabled,\n borderColor: theme.colors.disabled,\n color: theme.colors.onDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst StyledSelectWrapper = styled('div', {\n width: '100%',\n maxWidth: '380px',\n borderRadius: '$012',\n borderColor: '$subtle',\n borderStyle: 'solid',\n borderWidth: '1px',\n backgroundColor: '$secondary',\n position: 'relative',\n});\n\nconst StyledMobileOption = styled('option', {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n color: 'inherit',\n});\n\n/**\n * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.\n * @param {IDropdownProps} props The props.\n * @returns {React.ReactElement} The dropdown.\n */\nexport const Dropdown = ({\n id,\n label,\n values,\n required = false,\n defaultValue,\n onChange = () => {},\n disabled = false,\n}: IDropdownProps) => {\n const [answer, setAnswer] = useState<string>();\n const { isMobileSize } = useWindowSize();\n\n useEffect(() => {\n if (answer) onChange(answer);\n }, [answer]);\n\n const disabledProp = disabled ? { disabled: true } : {};\n\n // helps maintain state between WPDS and native dropdowns\n const defaultValueProp = answer\n ? { defaultValue: answer }\n : defaultValue\n ? { defaultValue }\n : {};\n\n const defaultValuePropMobile = (value: string) => {\n if (answer) {\n return value === answer ? { selected: true } : {};\n }\n return value === defaultValue ? { selected: true } : {};\n };\n\n return isMobileSize ? (\n <StyledSelectWrapper>\n <StyledMobileSelect\n id=\"\"\n required={required}\n onChange={(e) => setAnswer(e.target.value)}\n placeholder={label}\n {...disabledProp}\n >\n <label>{label}</label>\n <StyledMobileOption\n value=\"\"\n disabled\n selected\n style={{ color: '#666666' }}\n >\n {label}\n </StyledMobileOption>\n {values.map((value) => (\n <StyledMobileOption\n value={value}\n key={value}\n {...defaultValuePropMobile(value)}\n >\n {value}\n </StyledMobileOption>\n ))}\n </StyledMobileSelect>\n <Icon\n label=\"\"\n size=\"100\"\n fill={theme.colors['gray80']}\n style={{\n pointerEvents: 'none',\n position: 'absolute',\n right: '10px',\n top: '50%',\n transform: 'translateY(-50%)',\n }}\n >\n <ChevronDown style={{ position: 'absolute', right: '10px' }} />\n </Icon>\n </StyledSelectWrapper>\n ) : (\n <Select.Root\n onValueChange={(e) => setAnswer(e)}\n required={required}\n {...defaultValueProp}\n {...disabledProp}\n >\n <Select.Trigger data-test-id={`${id}-select-trigger`}>\n <Select.Label>{label}</Select.Label>\n <Select.Value />\n </Select.Trigger>\n <Select.Content\n css={{ zIndex: theme.zIndices.page }}\n data-test-id={`${id}-select-content`}\n >\n {values.map((value) => (\n <Select.Item value={value} key={value}>\n {value}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","import React, { useState, useEffect } from 'react';\nimport { Select, styled } from '@washingtonpost/wpds-ui-kit';\nimport { Attribute, AttributeValue } from '../../interfaces';\nimport { ENDPOINTS, ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { useScript, ScriptStatus } from '@washingtonpost/subs-hooks';\nimport { Dropdown } from './Dropdown';\n\ninterface DESelectProps {\n source: string;\n fieldName: string;\n label?: string;\n dataDictionaryConfig?: Attribute;\n defaultValue?: string;\n disabled?: boolean;\n submit: boolean;\n onChange?: ({ value }: { value: string }) => void;\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n valuesFilter?: (value: AttributeValue) => boolean;\n selectProps?: {\n root?: any;\n trigger?: any;\n label?: any;\n value?: any;\n content?: any;\n item?: any;\n };\n children?: React.ReactNode;\n}\n\nconst scriptSrc = `${\n ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static'\n ? 'https://www.washingtonpost.com/subscribe/static/'\n : ENDPOINTS.staticAssets\n}/de-utils/twpdeu.min.js`;\n\nexport const DESelect: React.FC<DESelectProps> = ({\n source,\n fieldName,\n label,\n dataDictionaryConfig,\n defaultValue,\n disabled,\n submit,\n onChange = () => {},\n onFinished = () => {},\n valuesFilter = () => true,\n children,\n}) => {\n const [config, setConfig] = useState(dataDictionaryConfig);\n\n const [selected, setSelected] = useState('');\n\n const scriptStatus = useScript(scriptSrc);\n\n useEffect(() => {\n const fetchConfig = async () => {\n try {\n const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });\n if (config) {\n setConfig(config[0]);\n } else {\n console.error('unable to get config', fieldName);\n }\n } catch (e) {\n console.warn('unable to get config', fieldName, e);\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && !(children || config)) {\n fetchConfig();\n }\n }, [scriptStatus]);\n\n useEffect(() => {\n const submitSelected = async () => {\n try {\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n source,\n });\n\n const isError =\n result === true\n ? false\n : result\n ? result.status !== ResponseStatus.SUCCESS\n : true;\n\n onFinished({\n isFinished: true,\n isError,\n });\n } catch (e) {\n onFinished({\n isFinished: false,\n isError: true,\n });\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && submit && selected) {\n submitSelected();\n }\n }, [scriptStatus, submit]);\n\n const defaultValueProp = defaultValue && config ? { defaultValue } : {};\n\n const isLoading = !(children || config);\n\n const disabledProp = disabled || isLoading ? { disabled: true } : {};\n\n // sort and filter out archived values\n const values = config\n ? [...config.values]\n .sort((a, b) => a.order - b.order)\n .filter((value) => value.archived !== true)\n .filter(valuesFilter)\n : [];\n\n return (\n <SelectWrapper>\n {children && (\n <Select.Root\n onValueChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n {...defaultValueProp}\n {...disabledProp}\n >\n {children}\n </Select.Root>\n )}\n {!children && !config && (\n <Dropdown\n id={'loading'}\n label={'Loading...'}\n values={[]}\n disabled={true}\n />\n )}\n {!children && config && (\n <Dropdown\n id={config.name}\n label={label || config.name}\n onChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n values={values.map((value) => value.name)}\n defaultValue={defaultValue}\n disabled={disabled}\n />\n )}\n </SelectWrapper>\n );\n};\n\nconst SelectWrapper = styled('div', {\n boxSizing: 'border-box',\n display: 'flex',\n marginBottom: '$100',\n flexDirection: 'column',\n '& button': {\n padding: '1px 6px',\n },\n '& *': { boxSizing: 'border-box' },\n});\n"],"names":["CollectionBehaviors","COLLECT","DO_NOT_COLLECT","AttributesState","SUCCESS","IngestType","EXPLICIT","IMPLICIT","IngestResponseState","SYSTEM_ERROR","INVALID_TYPE","INVALID_IDENTIFIER","INVALID_DATA","INVALID_ATTRIBUTE_DEFINITION","INVALID_META_DEFINITION","UNAUTHENTICATED","MISMATCHED_IDENTIFIER","DISABLED_ATTRIBUTE_DEFINITION","hasRequiredPrivacyCookies","window","wp_usp","getCookie","countryCode","_WPGeo","WPGeo","country_code","base","ENDPOINTS","attributesCache","getAttributes","_ref","fieldName","fieldNames","url","URL","searchParams","set","join","data","fetch","toString","credentials","headers","JSON_HEADERS","json","ok","status","ResponseStatus","attributes","e","console","debug","sendGAEvent","props","process","env","NODE_ENV","warn","dataLayer","eventData","push","sendToGA","submitData","value","source","event","action","category","label","section","subsection","ingest","wapo_login_id","jucid","localStorage","getItem","ga","payload","type","metadata","response","method","body","JSON","stringify","Error","attributeInfo","name","collection_behavior","explicit","StyledMobileSelect","styled","padding","display","justifyContent","width","backgroundColor","color","fontFamily","fontSize","fontWeight","lineHeight","paddingBlockRight","textOverflow","position","borderColor","borderRightWidth","borderRightColor","appearance","theme","colors","disabled","onDisabled","cursor","StyledSelectWrapper","maxWidth","borderRadius","borderStyle","borderWidth","StyledMobileOption","Dropdown","id","values","required","defaultValue","onChange","answer","setAnswer","useState","isMobileSize","useWindowSize","useEffect","disabledProp","defaultValueProp","defaultValuePropMobile","selected","React","target","placeholder","style","map","key","Icon","size","fill","pointerEvents","right","top","transform","ChevronDown","Select","Root","onValueChange","Trigger","Label","Value","Content","css","zIndex","zIndices","page","Item","scriptSrc","staticAssets","DESelect","dataDictionaryConfig","submit","onFinished","valuesFilter","children","config","setConfig","setSelected","scriptStatus","useScript","fetchConfig","_window","__twpdeu","getFieldConfigs","error","ScriptStatus","READY","submitSelected","_window2","result","isError","isFinished","isLoading","sort","a","b","order","filter","archived","SelectWrapper","boxSizing","marginBottom","flexDirection"],"mappings":";;;;;;;;;;;;;MAQaA,mBAAmB,GAAG;EACjCC,OAAO,EAAE,SAAS;EAClBC,cAAc,EAAE;;MAeLC,eAAe,GAAG;EAC7BC,OAAO,EAAE;;MAGEC,UAAU,GAAG;EACxBC,QAAQ,EAAE,UAAU;EACpBC,QAAQ,EAAE;;MAGCC,mBAAmB,GAAG;EACjCJ,OAAO,EAAE,KAAK;EACdK,YAAY,EAAE,KAAK;EACnBC,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE,KAAK;EACzBC,YAAY,EAAE,KAAK;EACnBC,4BAA4B,EAAE,KAAK;EACnCC,uBAAuB,EAAE,KAAK;EAC9BC,eAAe,EAAE,KAAK;EACtBC,qBAAqB,EAAE,KAAK;EAC5BC,6BAA6B,EAAE,KAAK;EACpCf,cAAc,EAAE;;;MC3CLgB,yBAAyB,GAAGA;;EACvC,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACjC,OAAO,KAAK;;EAGd,MAAMC,MAAM,GAAGC,iBAAS,CAAC,QAAQ,CAAC;EAElC,MAAMC,WAAW,IAAAC,MAAA,GAAGC,aAAK,EAAE,cAAAD,MAAA,uBAAPA,MAAA,CAASE,YAAY;EAEzC,OAAO,CAAC,EAAEL,MAAM,IAAIE,WAAW,KAAK,IAAI,CAAC;AAC3C,CAAC;;ACLD,MAAMI,IAAI,MAAMC,iBAAS,CAACD,YAAY;AAEtC,MAAME,eAAe,GAAwB,EAAE;AAC/C,MAAaC,aAAa,GAAsB,MAAAC,IAAA;MAAO;IACrDC;GAGD,GAAAD,IAAA;EACC,IAAIF,eAAe,CAACG,SAAS,CAAC,EAAE;I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E,QAAQ,CAAC;QAAE9D,KAAK,EAAEd;OAAG,CAAC;KACvB;OACGoF,gBAAgB;OAChBD;KAEHqC,QAAQ,CAEZ,EACA,CAACA,QAAQ,IAAI,CAACC,MAAM,IACnBlC,6BAAChB,QAAQ;IACPC,EAAE,EAAE,SAAS;IACbrD,KAAK,EAAE,YAAY;IACnBsD,MAAM,EAAE,EAAE;IACVX,QAAQ,EAAE;IAEb,EACA,CAAC0D,QAAQ,IAAIC,MAAM,IAClBlC,6BAAChB,QAAQ;IACPC,EAAE,EAAEiD,MAAM,CAACnF,IAAI;IACfnB,KAAK,EAAEA,KAAK,IAAIsG,MAAM,CAACnF,IAAI;IAC3BsC,QAAQ,EAAG5E,CAAC;MACV2H,WAAW,CAAC3H,CAAC,CAAC;MACd4E,QAAQ,CAAC;QAAE9D,KAAK,EAAEd;OAAG,CAAC;KACvB;IACDyE,MAAM,EAAEA,MAAM,CAACkB,GAAG,CAAE7E,KAAK,IAAKA,KAAK,CAACwB,IAAI,CAAC;IACzCqC,YAAY,EAAEA,YAAY;IAC1Bb,QAAQ,EAAEA;IAEb,CACa;AAEpB,CAAC;AAED,MAAMmF,aAAa,gBAAGvG,gBAAM,CAAC,KAAK,EAAE;EAClCwG,SAAS,EAAE,YAAY;EACvBtG,OAAO,EAAE,MAAM;EACfuG,YAAY,EAAE,MAAM;EACpBC,aAAa,EAAE,QAAQ;EACvB,UAAU,EAAE;IACVzG,OAAO,EAAE;GACV;EACD,KAAK,EAAE;IAAEuG,SAAS,EAAE;;CACrB,CAAC;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"subs-de-inputs.cjs.development.js","sources":["../src/interfaces/index.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/getAttributes.ts","../src/services/sendToGA.ts","../src/services/ingest.ts","../src/utils/isAnonymousWebview.ts","../src/utils/push.ts","../src/components/DESelect/Dropdown.tsx","../src/components/DESelect/index.tsx","../src/components/DEDisclosure/utils/getConfig.ts","../src/components/DEDisclosure/utils/checkCookie.ts","../src/components/DEDisclosure/hooks/useOnetrustAlertBoxClosedPromise.ts","../src/components/DEDisclosure/index.tsx"],"sourcesContent":["export type AttributeValue = {\n name: string;\n date_created: Number;\n last_modified_date: Number;\n archived: boolean;\n order: number;\n};\n\nexport const CollectionBehaviors = {\n COLLECT: 'COLLECT',\n DO_NOT_COLLECT: 'DO_NOT_COLLECT',\n} as const;\n\nexport type Attribute = {\n name: string;\n approved_for_use?: boolean;\n collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];\n datatype: string;\n explicit: boolean;\n multiple_value: boolean;\n last_modified_date: Number;\n date_created: Number;\n values: AttributeValue[] | Readonly<AttributeValue[]>;\n};\n\nexport const AttributesState = {\n SUCCESS: '100',\n} as const;\n\nexport const IngestType = {\n EXPLICIT: 'explicit',\n IMPLICIT: 'implicit',\n} as const;\n\nexport const IngestResponseState = {\n SUCCESS: '100',\n SYSTEM_ERROR: '101',\n INVALID_TYPE: '102',\n INVALID_IDENTIFIER: '103',\n INVALID_DATA: '104',\n INVALID_ATTRIBUTE_DEFINITION: '105',\n INVALID_META_DEFINITION: '106',\n UNAUTHENTICATED: '107',\n MISMATCHED_IDENTIFIER: '108',\n DISABLED_ATTRIBUTE_DEFINITION: '109',\n DO_NOT_COLLECT: '110',\n} as const;\n","import { WPGeo, getCookie } from '@washingtonpost/subs-sdk';\n\nexport const hasRequiredPrivacyCookies = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_usp = getCookie('wp_usp');\n\n const countryCode = WPGeo()?.country_code;\n\n return !!(wp_usp && countryCode === 'US');\n};\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n} from '@washingtonpost/subs-sdk';\nimport { Attribute } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nconst attributesCache: Record<string, any> = {};\nexport const getAttributes: GetAttributesType = async ({\n fieldName,\n}: {\n fieldName: string;\n}) => {\n if (attributesCache[fieldName]) {\n return attributesCache[fieldName];\n }\n\n const fieldNames = [fieldName];\n\n try {\n const url = new URL(`${base}/attributes`);\n url.searchParams.set('attributes', fieldNames.join(','));\n\n const data = await fetch(url.toString(), {\n credentials: 'include',\n headers: JSON_HEADERS,\n });\n const json = await data.json();\n\n if (data.ok && json.status === ResponseStatus.SUCCESS) {\n const attributes = json.attributes || [];\n attributesCache[fieldName] = attributes;\n return attributes;\n } else {\n return [];\n }\n } catch (e) {\n console.debug(e);\n return [];\n }\n};\n\ntype GetAttributesType = ({\n fieldName,\n}: {\n fieldName: string;\n}) => Promise<Attribute[]>;\n","const sendGAEvent = (props: {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}): void => {\n if (typeof window === 'undefined') {\n if (__DEV__) console.warn('NO WINDOW');\n return;\n }\n // Initialize dataLayer if needed\n window.dataLayer = window.dataLayer || [];\n\n const eventData: Record<string, any> = {\n ...props,\n };\n window.dataLayer.push(eventData);\n};\n\nexport const sendToGA: SendToGaType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n sendGAEvent({\n event: 'site-onpage-click',\n action: 'site-onpage-click',\n category: 'profile',\n\n label: fieldName,\n 'de-label': fieldName,\n [fieldName]: value,\n\n section: 'profile',\n subsection: source,\n });\n\n return true;\n};\n\ntype SendToGaType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<true>;\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n getCookie,\n} from '@washingtonpost/subs-sdk';\nimport { IngestResponseState, IngestType } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n const jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type: IngestType.EXPLICIT,\n wapo_login_id, // TODO: move this to BE to read from cookie headers\n data: {\n [fieldName]: [value],\n },\n metadata: { source },\n };\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n credentials: 'include',\n headers: JSON_HEADERS,\n body: JSON.stringify(payload),\n });\n\n const json = await response.json();\n\n return json;\n } catch (e) {\n console.debug(e);\n return null;\n }\n};\n\ntype IngestType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<{\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n} | null>;\n","import { getCookie, isLoggedIn } from '@washingtonpost/subs-sdk';\n\nexport const isAnonymousWebview = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_wv = getCookie('wp_wv');\n\n return !!(wp_wv && !isLoggedIn());\n};\n","import {\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { getAttributes } from '../services/getAttributes';\nimport { sendToGA } from '../services/sendToGA';\nimport { hasRequiredPrivacyCookies } from './hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from '../services/ingest';\nimport { isAnonymousWebview } from './isAnonymousWebview';\n\nexport const push: PushType = async ({ submitData, source }) => {\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n if (isAnonymousWebview()) {\n throw new Error('does not satisfy cookie check');\n }\n\n const { fieldName } = submitData;\n\n const attributeInfo = await getAttributes({\n fieldName,\n });\n\n if (\n attributeInfo[0] &&\n attributeInfo[0].name === fieldName &&\n attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT\n ) {\n throw new Error('do not collect');\n }\n\n const type =\n attributeInfo[0] && attributeInfo[0].explicit === true\n ? IngestType.EXPLICIT\n : IngestType.IMPLICIT;\n\n if (!attributeInfo[0] && __DEV__) {\n console.warn(`no attribute info found for ${fieldName}, assuming implicit`);\n }\n\n if (type === IngestType.EXPLICIT) {\n return ingest({ submitData, source });\n } else {\n return sendToGA({ submitData, source });\n }\n};\n\ntype PushType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<\n | {\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n }\n | null\n | true\n>;\n","import React, { useEffect, useState } from 'react';\nimport { Icon, Select, styled, theme } from '@washingtonpost/wpds-ui-kit';\nimport { useWindowSize } from '@washingtonpost/subs-hooks';\nimport { ChevronDown } from '@washingtonpost/wpds-assets';\n\ninterface IDropdownProps {\n id: string;\n label: string;\n values: Array<string>;\n required?: boolean;\n defaultValue?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n}\n\nconst StyledMobileSelect = styled('select', {\n padding: '12px 16px 12px 6px',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n backgroundColor: '$secondary',\n color: '$primary',\n fontFamily: '$meta',\n fontSize: '$100',\n fontWeight: '$light',\n lineHeight: '$125',\n paddingBlockRight: '$125',\n textOverflow: 'ellipsis',\n position: 'relative',\n borderColor: 'transparent',\n borderRightWidth: '10px',\n borderRightColor: 'transparent',\n appearance: 'none',\n '-webkit-appearance': 'none',\n '&:disabled': {\n backgroundColor: theme.colors.disabled,\n borderColor: theme.colors.disabled,\n color: theme.colors.onDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst StyledSelectWrapper = styled('div', {\n width: '100%',\n maxWidth: '380px',\n borderRadius: '$012',\n borderColor: '$subtle',\n borderStyle: 'solid',\n borderWidth: '1px',\n backgroundColor: '$secondary',\n position: 'relative',\n});\n\nconst StyledMobileOption = styled('option', {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n color: 'inherit',\n});\n\n/**\n * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.\n * @param {IDropdownProps} props The props.\n * @returns {React.ReactElement} The dropdown.\n */\nexport const Dropdown = ({\n id,\n label,\n values,\n required = false,\n defaultValue,\n onChange = () => {},\n disabled = false,\n}: IDropdownProps) => {\n const [answer, setAnswer] = useState<string>();\n const { isMobileSize } = useWindowSize();\n\n useEffect(() => {\n if (answer) onChange(answer);\n }, [answer]);\n\n const disabledProp = disabled ? { disabled: true } : {};\n\n // helps maintain state between WPDS and native dropdowns\n const defaultValueProp = answer\n ? { defaultValue: answer }\n : defaultValue\n ? { defaultValue }\n : {};\n\n const defaultValuePropMobile = (value: string) => {\n if (answer) {\n return value === answer ? { selected: true } : {};\n }\n return value === defaultValue ? { selected: true } : {};\n };\n\n return isMobileSize ? (\n <StyledSelectWrapper>\n <StyledMobileSelect\n id=\"\"\n required={required}\n onChange={(e) => setAnswer(e.target.value)}\n placeholder={label}\n {...disabledProp}\n >\n <label>{label}</label>\n <StyledMobileOption\n value=\"\"\n disabled\n selected\n style={{ color: '#666666' }}\n >\n {label}\n </StyledMobileOption>\n {values.map((value) => (\n <StyledMobileOption\n value={value}\n key={value}\n {...defaultValuePropMobile(value)}\n >\n {value}\n </StyledMobileOption>\n ))}\n </StyledMobileSelect>\n <Icon\n label=\"\"\n size=\"100\"\n fill={theme.colors['gray80']}\n style={{\n pointerEvents: 'none',\n position: 'absolute',\n right: '10px',\n top: '50%',\n transform: 'translateY(-50%)',\n }}\n >\n <ChevronDown style={{ position: 'absolute', right: '10px' }} />\n </Icon>\n </StyledSelectWrapper>\n ) : (\n <Select.Root\n onValueChange={(e) => setAnswer(e)}\n required={required}\n {...defaultValueProp}\n {...disabledProp}\n >\n <Select.Trigger data-test-id={`${id}-select-trigger`}>\n <Select.Label>{label}</Select.Label>\n <Select.Value />\n </Select.Trigger>\n <Select.Content\n css={{ zIndex: theme.zIndices.page }}\n data-test-id={`${id}-select-content`}\n >\n {values.map((value) => (\n <Select.Item value={value} key={value}>\n {value}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","import React, { useState, useEffect } from 'react';\nimport { Select, styled } from '@washingtonpost/wpds-ui-kit';\nimport { Attribute, AttributeValue } from '../../interfaces';\nimport { ENDPOINTS, ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { useScript, ScriptStatus } from '@washingtonpost/subs-hooks';\nimport { Dropdown } from './Dropdown';\n\ninterface DESelectProps {\n source: string;\n fieldName: string;\n label?: string;\n dataDictionaryConfig?: Attribute | Readonly<Attribute>;\n defaultValue?: string;\n disabled?: boolean;\n submit: boolean;\n onChange?: ({ value }: { value: string }) => void;\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n valuesFilter?: (value: AttributeValue) => boolean;\n selectProps?: {\n root?: any;\n trigger?: any;\n label?: any;\n value?: any;\n content?: any;\n item?: any;\n };\n children?: React.ReactNode;\n}\n\nconst scriptSrc = `${\n ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static'\n ? 'https://www.washingtonpost.com/subscribe/static/'\n : ENDPOINTS.staticAssets\n}/de-utils/twpdeu.min.js`;\n\nexport const DESelect: React.FC<DESelectProps> = ({\n source,\n fieldName,\n label,\n dataDictionaryConfig,\n defaultValue,\n disabled,\n submit,\n onChange = () => {},\n onFinished = () => {},\n valuesFilter = () => true,\n children,\n}) => {\n const [config, setConfig] = useState(dataDictionaryConfig);\n\n const [selected, setSelected] = useState('');\n\n const scriptStatus = useScript(scriptSrc);\n\n useEffect(() => {\n const fetchConfig = async () => {\n try {\n const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });\n if (config) {\n setConfig(config[0]);\n } else {\n console.error('unable to get config', fieldName);\n }\n } catch (e) {\n console.warn('unable to get config', fieldName, e);\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && !(children || config)) {\n fetchConfig();\n }\n }, [scriptStatus]);\n\n useEffect(() => {\n const submitSelected = async () => {\n try {\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n source,\n });\n\n const isError =\n result === true\n ? false\n : result\n ? result.status !== ResponseStatus.SUCCESS\n : true;\n\n onFinished({\n isFinished: true,\n isError,\n });\n } catch (e) {\n onFinished({\n isFinished: false,\n isError: true,\n });\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && submit && selected) {\n submitSelected();\n }\n }, [scriptStatus, submit]);\n\n const defaultValueProp = defaultValue && config ? { defaultValue } : {};\n\n const isLoading = !(children || config);\n\n const disabledProp = disabled || isLoading ? { disabled: true } : {};\n\n // sort and filter out archived values\n // Note: config.values may be readonly\n const values = config\n ? [...config.values]\n .sort((a, b) => a.order - b.order)\n .filter((value) => value.archived !== true)\n .filter(valuesFilter)\n : [];\n\n return (\n <SelectWrapper>\n {children && (\n <Select.Root\n onValueChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n {...defaultValueProp}\n {...disabledProp}\n >\n {children}\n </Select.Root>\n )}\n {!children && !config && (\n <Dropdown\n id={'loading'}\n label={'Loading...'}\n values={[]}\n disabled={true}\n />\n )}\n {!children && config && (\n <Dropdown\n id={config.name}\n label={label || config.name}\n onChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n values={values.map((value) => value.name)}\n defaultValue={defaultValue}\n disabled={disabled}\n />\n )}\n </SelectWrapper>\n );\n};\n\nconst SelectWrapper = styled('div', {\n boxSizing: 'border-box',\n display: 'flex',\n marginBottom: '$100',\n flexDirection: 'column',\n '& button': {\n padding: '1px 6px',\n },\n '& *': { boxSizing: 'border-box' },\n});\n","import { WPGeo } from '@washingtonpost/subs-sdk';\nimport {\n DisclosureConfig,\n DisclosureConfigValue,\n} from '../../../interfaces/disclosure';\n\n// const configSrc = `${\n// ENDPOINTS.base === 'https://subscribe.washingtonpost.com'\n// ? 'https://www.washingtonpost.com/subscribe'\n// : ENDPOINTS.base\n// }/config/de/disclosure.json`;\n// revert-me-before-prod\nconst configSrc = 'https://subscribe.digitalink.com/config/de/disclosure.json';\n\nexport const getConfig = async () => {\n // step 1: fetch config\n const response = await fetch(configSrc);\n const remoteConfig: DisclosureConfig = await response.json();\n\n // step 2: figure out which part of the config to use\n\n // if country-specific config found, use that\n const countryCode = WPGeo().country_code;\n const eea = WPGeo().intl_region === 'EEA';\n const configs = Object.keys(remoteConfig);\n let myConfig: DisclosureConfigValue | undefined = undefined;\n configs.forEach((config) => {\n if (countryCode && config.split('|').includes(countryCode.toLowerCase())) {\n myConfig = remoteConfig[config];\n } else if (eea && config === 'eea') {\n myConfig = remoteConfig[config];\n }\n });\n\n // TODO: Check for billing country also\n\n // else if no country-specific config, use the default config\n if (typeof myConfig === 'undefined' && remoteConfig['_']) {\n myConfig = remoteConfig['_'];\n }\n\n return myConfig;\n};\n","import { getCookie } from '@washingtonpost/subs-sdk';\n\nconst COOKIE = 'OptanonAlertBoxClosed';\n\nexport const checkCookie = () => {\n const value = getCookie(COOKIE) || '';\n // Wed May 15 2024 06:29:23 GMT-0500 (Central Daylight Time)\n // \"Invalid date\" is 12 characters long\n return value.length > 12;\n};\n","import { useState, useEffect } from 'react';\nimport {\n listenToCookieStore as listenToCookieStoreUtil,\n ICookieStore,\n} from '@washingtonpost/subs-sdk';\nimport { checkCookie } from '../utils/checkCookie';\n\nconst COOKIE = 'OptanonAlertBoxClosed';\n\ntype TCData = {\n eventStatus: 'tcloaded' | 'cmpuishown' | 'useractioncomplete';\n listenerId: number;\n [key: string]: any;\n};\n\ntype TCFAPIAddListener = (\n command: 'addEventListener',\n version: number,\n callback: (tcData: TCData, success: boolean) => void\n) => void;\n\ntype TCFAPIRmListener = (\n command: 'removeEventListener',\n version: number,\n callback: (success: boolean) => void,\n listenerId: number\n) => void;\n\ntype TCFAPIPing = (\n command: 'ping',\n version: number,\n callback: (pingReturn: any, success: boolean) => void\n) => void;\n\ndeclare global {\n interface Window {\n cookieStore?: ICookieStore;\n __tcfapi?: TCFAPIAddListener & TCFAPIRmListener & TCFAPIPing;\n }\n}\n\nexport const useOneTrustAlertBoxClosed = ({\n allowCookieStore,\n}: {\n allowCookieStore: boolean;\n}) => {\n const [alertBoxClosed, setAlertBoxClosed] = useState<boolean | undefined>();\n\n const [listenToCookieStore, setListenToCookieStore] = useState(false);\n const [listenToTcfApi, setListenToTcfApi] = useState(false);\n\n useEffect(() => {\n if (checkCookie()) {\n setAlertBoxClosed(true);\n return;\n }\n\n if (!window.__tcfapi) {\n console.warn('warning: __tcfapi not found');\n }\n\n if (window.cookieStore && allowCookieStore) {\n setListenToCookieStore(true);\n } else if (window.__tcfapi) {\n setListenToTcfApi(true);\n } else {\n console.warn('warning: neither cookieStore nor __tcfapi found');\n }\n }, []);\n\n useEffect(() => {\n if (listenToCookieStore && window.cookieStore) {\n const cleanupFn = listenToCookieStoreUtil(COOKIE, () => {\n if (checkCookie()) {\n setAlertBoxClosed(true);\n }\n });\n\n // cleanup fn\n return () => {\n if (cleanupFn) cleanupFn();\n };\n } else {\n return () => {};\n }\n }, [listenToCookieStore]);\n\n useEffect(() => {\n if (listenToTcfApi && window.__tcfapi) {\n let listenerId: number;\n\n const callback = (_tcData: TCData, success: boolean) => {\n if (success) {\n listenerId = _tcData.listenerId;\n\n // tcData.eventStatus can be:\n // tcloaded means user has made a choice and we’re ready to check it\n // cmpuishown means the banner is shown\n // useractioncomplete means the user has interacted with the banner\n\n // but actually if the result for any of these is true, we just use the value of the cookie\n if (checkCookie()) {\n setAlertBoxClosed(true);\n }\n }\n };\n\n window.__tcfapi('addEventListener', 2, callback);\n\n // cleanup fn\n return () => {\n if (window.__tcfapi && listenerId)\n window.__tcfapi(\n 'removeEventListener',\n 2,\n (success) => {\n console.debug(success);\n },\n listenerId\n );\n };\n } else {\n return () => {};\n }\n }, [listenToTcfApi]);\n\n return { alertBoxClosed, listenToCookieStore, listenToTcfApi };\n};\n","import React, { useState, useEffect } from 'react';\nimport { DisclosureConfigValue } from '../../interfaces/disclosure';\nimport { getConfig } from './utils/getConfig';\nimport { useOneTrustAlertBoxClosed } from './hooks/useOnetrustAlertBoxClosedPromise';\n\ninterface DisclosureProps {\n /** callback function to be called when the disclosure is finished loading */\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n\n /** ability to turn off cookiestore listener, primarily for testing purposes */\n allowCookieStore?: boolean;\n}\n\nexport const DEDisclosure: React.FC<DisclosureProps> = ({\n onFinished = () => {},\n allowCookieStore = true,\n}) => {\n const [disclosure, setDisclosure] = useState<JSX.Element | null>(null);\n const [myConfig, setMyConfig] = useState<DisclosureConfigValue>();\n const { alertBoxClosed } = useOneTrustAlertBoxClosed({ allowCookieStore });\n\n useEffect(() => {\n (async () => {\n const config = await getConfig();\n setMyConfig(config);\n\n if (!config) {\n console.error('No config found');\n }\n })();\n }, []);\n\n useEffect(() => {\n if (myConfig) {\n // step 3: set disclosure based on config\n\n // if config says to check onetrust, check onetrust\n if ('checkBannerStatus' in myConfig && myConfig.checkBannerStatus) {\n // check if onetrust is closed\n // if it is, show the after banner disclosure\n // if it is not, show the before banner disclosure\n if (alertBoxClosed) {\n setDisclosure(myConfig.disclosure_afterbanner);\n } else {\n setDisclosure(myConfig.disclosure_beforebanner);\n }\n } else if ('disclosure' in myConfig) {\n setDisclosure(myConfig.disclosure);\n } else {\n console.error('Invalid config');\n }\n }\n }, [myConfig, alertBoxClosed]);\n\n useEffect(() => {\n if (disclosure) {\n // Is it ok to fire `onFinished` if still waiting for onetrust to load on the page?\n onFinished({\n isFinished: true,\n isError: false,\n });\n }\n }, [disclosure]);\n\n return disclosure === null ? (\n <div data-test-id=\"de-disclosure-loading\"></div>\n ) : (\n <div data-test-id=\"de-disclosure\">{disclosure}</div>\n );\n};\n"],"names":["CollectionBehaviors","COLLECT","DO_NOT_COLLECT","AttributesState","SUCCESS","IngestType","EXPLICIT","IMPLICIT","IngestResponseState","SYSTEM_ERROR","INVALID_TYPE","INVALID_IDENTIFIER","INVALID_DATA","INVALID_ATTRIBUTE_DEFINITION","INVALID_META_DEFINITION","UNAUTHENTICATED","MISMATCHED_IDENTIFIER","DISABLED_ATTRIBUTE_DEFINITION","hasRequiredPrivacyCookies","window","wp_usp","getCookie","countryCode","_WPGeo","WPGeo","country_code","base","ENDPOINTS","attributesCache","getAttributes","_ref","fieldName","fieldNames","url","URL","searchParams","set","join","data","fetch","toString","credentials","headers","JSON_HEADERS","json","ok","status","ResponseStatus","attributes","e","console","debug","sendGAEvent","props","process","env","NODE_ENV","warn","dataLayer","eventData","push","sendToGA","submitData","value","source","event","action","category","label","section","subsection","ingest","wapo_login_id","jucid","localStorage","getItem","ga","payload","type","metadata","response","method","body","JSON","stringify","isAnonymousWebview","wp_wv","isLoggedIn","Error","attributeInfo","name","collection_behavior","explicit","StyledMobileSelect","styled","padding","display","justifyContent","width","backgroundColor","color","fontFamily","fontSize","fontWeight","lineHeight","paddingBlockRight","textOverflow","position","borderColor","borderRightWidth","borderRightColor","appearance","theme","colors","disabled","onDisabled","cursor","StyledSelectWrapper","maxWidth","borderRadius","borderStyle","borderWidth","StyledMobileOption","Dropdown","id","values","required","defaultValue","onChange","answer","setAnswer","useState","isMobileSize","useWindowSize","useEffect","disabledProp","defaultValueProp","defaultValuePropMobile","selected","React","target","placeholder","style","map","key","Icon","size","fill","pointerEvents","right","top","transform","ChevronDown","Select","Root","onValueChange","Trigger","Label","Value","Content","css","zIndex","zIndices","page","Item","scriptSrc","staticAssets","DESelect","dataDictionaryConfig","submit","onFinished","valuesFilter","children","config","setConfig","setSelected","scriptStatus","useScript","fetchConfig","_window","__twpdeu","getFieldConfigs","error","ScriptStatus","READY","submitSelected","_window2","result","isError","isFinished","isLoading","sort","a","b","order","filter","archived","SelectWrapper","boxSizing","marginBottom","flexDirection","configSrc","getConfig","remoteConfig","eea","intl_region","configs","Object","keys","myConfig","undefined","forEach","split","includes","toLowerCase","COOKIE","checkCookie","length","useOneTrustAlertBoxClosed","allowCookieStore","alertBoxClosed","setAlertBoxClosed","listenToCookieStore","setListenToCookieStore","listenToTcfApi","setListenToTcfApi","__tcfapi","cookieStore","cleanupFn","listenToCookieStoreUtil","listenerId","callback","_tcData","success","DEDisclosure","disclosure","setDisclosure","setMyConfig","checkBannerStatus","disclosure_afterbanner","disclosure_beforebanner"],"mappings":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,CAAC0B,UAAU,CAAC;OACnC,MAAM;QACLzL,OAAO,CAACoI,KAAK,CAAC,gBAAgB,CAAC;;;GAGpC,EAAE,CAAC2B,QAAQ,EAAEW,cAAc,CAAC,CAAC;EAE9BtF,eAAS,CAAC;IACR,IAAIqG,UAAU,EAAE;;MAEdjE,UAAU,CAAC;QACTmB,UAAU,EAAE,IAAI;QAChBD,OAAO,EAAE;OACV,CAAC;;GAEL,EAAE,CAAC+C,UAAU,CAAC,CAAC;EAEhB,OAAOA,UAAU,KAAK,IAAI,GACxBhG;oBAAkB;IAA8B,GAEhDA;oBAAkB;KAAiBgG,UAAU,CAC9C;AACH,CAAC;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@washingtonpost/subs-sdk"),o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@washingtonpost/subs-sdk"),o=require("react"),i=(e=o)&&"object"==typeof e&&"default"in e?e.default:e,n=require("@washingtonpost/wpds-ui-kit"),a=require("@washingtonpost/subs-hooks"),s=require("@washingtonpost/wpds-assets");const r={COLLECT:"COLLECT",DO_NOT_COLLECT:"DO_NOT_COLLECT"},l={EXPLICIT:"explicit",IMPLICIT:"implicit"},c=()=>{var e;if("undefined"==typeof window)return!1;const o=t.getCookie("wp_usp"),i=null===(e=t.WPGeo())||void 0===e?void 0:e.country_code;return!(!o||"US"!==i)},d=t.ENDPOINTS.base+"/de/v1",u={},p=async e=>{let{fieldName:o}=e;if(u[o])return u[o];const i=[o];try{const e=new URL(d+"/attributes");e.searchParams.set("attributes",i.join(","));const n=await fetch(e.toString(),{credentials:"include",headers:t.JSON_HEADERS}),a=await n.json();if(n.ok&&a.status===t.ResponseStatus.SUCCESS){const e=a.attributes||[];return u[o]=e,e}return[]}catch(e){return console.debug(e),[]}},f=t.ENDPOINTS.base+"/de/v1",w=n.styled("select",{padding:"12px 16px 12px 6px",display:"flex",justifyContent:"space-between",width:"100%",backgroundColor:"$secondary",color:"$primary",fontFamily:"$meta",fontSize:"$100",fontWeight:"$light",lineHeight:"$125",paddingBlockRight:"$125",textOverflow:"ellipsis",position:"relative",borderColor:"transparent",borderRightWidth:"10px",borderRightColor:"transparent",appearance:"none","-webkit-appearance":"none","&:disabled":{backgroundColor:n.theme.colors.disabled,borderColor:n.theme.colors.disabled,color:n.theme.colors.onDisabled,cursor:"not-allowed"}}),E=n.styled("div",{width:"100%",maxWidth:"380px",borderRadius:"$012",borderColor:"$subtle",borderStyle:"solid",borderWidth:"1px",backgroundColor:"$secondary",position:"relative"}),b=n.styled("option",{fontFamily:"inherit",fontSize:"inherit",color:"inherit"}),g=e=>{let{id:t,label:r,values:l,required:c=!1,defaultValue:d,onChange:u=(()=>{}),disabled:p=!1}=e;const[f,g]=o.useState(),{isMobileSize:h}=a.useWindowSize();o.useEffect(()=>{f&&u(f)},[f]);const S=p?{disabled:!0}:{},m=f?{defaultValue:f}:d?{defaultValue:d}:{},C=e=>f?e===f?{selected:!0}:{}:e===d?{selected:!0}:{};return h?i.createElement(E,null,i.createElement(w,{id:"",required:c,onChange:e=>g(e.target.value),placeholder:r,...S},i.createElement("label",null,r),i.createElement(b,{value:"",disabled:!0,selected:!0,style:{color:"#666666"}},r),l.map(e=>i.createElement(b,{value:e,key:e,...C(e)},e))),i.createElement(n.Icon,{label:"",size:"100",fill:n.theme.colors.gray80,style:{pointerEvents:"none",position:"absolute",right:"10px",top:"50%",transform:"translateY(-50%)"}},i.createElement(s.ChevronDown,{style:{position:"absolute",right:"10px"}}))):i.createElement(n.Select.Root,{onValueChange:e=>g(e),required:c,...m,...S},i.createElement(n.Select.Trigger,{"data-test-id":t+"-select-trigger"},i.createElement(n.Select.Label,null,r),i.createElement(n.Select.Value,null)),i.createElement(n.Select.Content,{css:{zIndex:n.theme.zIndices.page},"data-test-id":t+"-select-content"},l.map(e=>i.createElement(n.Select.Item,{value:e,key:e},e))))},h=("https://subscribe.washingtonpost.com/static"===t.ENDPOINTS.staticAssets?"https://www.washingtonpost.com/subscribe/static/":t.ENDPOINTS.staticAssets)+"/de-utils/twpdeu.min.js",S=n.styled("div",{boxSizing:"border-box",display:"flex",marginBottom:"$100",flexDirection:"column","& button":{padding:"1px 6px"},"& *":{boxSizing:"border-box"}}),m=()=>(t.getCookie("OptanonAlertBoxClosed")||"").length>12;exports.AttributesState={SUCCESS:"100"},exports.CollectionBehaviors=r,exports.DEDisclosure=e=>{let{onFinished:n=(()=>{}),allowCookieStore:a=!0}=e;const[s,r]=o.useState(null),[l,c]=o.useState(),{alertBoxClosed:d}=(e=>{let{allowCookieStore:i}=e;const[n,a]=o.useState(),[s,r]=o.useState(!1),[l,c]=o.useState(!1);return o.useEffect(()=>{m()?a(!0):(window.__tcfapi||console.warn("warning: __tcfapi not found"),window.cookieStore&&i?r(!0):window.__tcfapi?c(!0):console.warn("warning: neither cookieStore nor __tcfapi found"))},[]),o.useEffect(()=>{if(s&&window.cookieStore){const e=t.listenToCookieStore("OptanonAlertBoxClosed",()=>{m()&&a(!0)});return()=>{e&&e()}}return()=>{}},[s]),o.useEffect(()=>{if(l&&window.__tcfapi){let e;return window.__tcfapi("addEventListener",2,(t,o)=>{o&&(e=t.listenerId,m()&&a(!0))}),()=>{window.__tcfapi&&e&&window.__tcfapi("removeEventListener",2,e=>{console.debug(e)},e)}}return()=>{}},[l]),{alertBoxClosed:n,listenToCookieStore:s,listenToTcfApi:l}})({allowCookieStore:a});return o.useEffect(()=>{(async()=>{const e=await(async()=>{const e=await fetch("https://subscribe.digitalink.com/config/de/disclosure.json"),o=await e.json(),i=t.WPGeo().country_code,n="EEA"===t.WPGeo().intl_region,a=Object.keys(o);let s=void 0;return a.forEach(e=>{(i&&e.split("|").includes(i.toLowerCase())||n&&"eea"===e)&&(s=o[e])}),void 0===s&&o._&&(s=o._),s})();c(e),e||console.error("No config found")})()},[]),o.useEffect(()=>{l&&("checkBannerStatus"in l&&l.checkBannerStatus?r(d?l.disclosure_afterbanner:l.disclosure_beforebanner):"disclosure"in l?r(l.disclosure):console.error("Invalid config"))},[l,d]),o.useEffect(()=>{s&&n({isFinished:!0,isError:!1})},[s]),null===s?i.createElement("div",{"data-test-id":"de-disclosure-loading"}):i.createElement("div",{"data-test-id":"de-disclosure"},s)},exports.DESelect=e=>{let{source:s,fieldName:r,label:l,dataDictionaryConfig:c,defaultValue:d,disabled:u,submit:p,onChange:f=(()=>{}),onFinished:w=(()=>{}),valuesFilter:E=(()=>!0),children:b}=e;const[m,C]=o.useState(c),[_,I]=o.useState(""),v=a.useScript(h);o.useEffect(()=>{v!==a.ScriptStatus.READY||b||m||(async()=>{try{var e;const t=await(null===(e=window)||void 0===e||null===(e=e.__twpdeu)||void 0===e?void 0:e.getFieldConfigs({fieldName:r}));t?C(t[0]):console.error("unable to get config",r)}catch(e){console.warn("unable to get config",r,e)}})()},[v]),o.useEffect(()=>{v===a.ScriptStatus.READY&&p&&_&&(async()=>{try{var e;const o=await(null===(e=window)||void 0===e||null===(e=e.__twpdeu)||void 0===e?void 0:e.push({submitData:{fieldName:r,value:_},source:s}));w({isFinished:!0,isError:!0!==o&&(!o||o.status!==t.ResponseStatus.SUCCESS)})}catch(e){w({isFinished:!1,isError:!0})}})()},[v,p]);const y=d&&m?{defaultValue:d}:{},T=u||!b&&!m?{disabled:!0}:{},N=m?[...m.values].sort((e,t)=>e.order-t.order).filter(e=>!0!==e.archived).filter(E):[];return i.createElement(S,null,b&&i.createElement(n.Select.Root,{onValueChange:e=>{I(e),f({value:e})},...y,...T},b),!b&&!m&&i.createElement(g,{id:"loading",label:"Loading...",values:[],disabled:!0}),!b&&m&&i.createElement(g,{id:m.name,label:l||m.name,onChange:e=>{I(e),f({value:e})},values:N.map(e=>e.name),defaultValue:d,disabled:u}))},exports.IngestResponseState={SUCCESS:"100",SYSTEM_ERROR:"101",INVALID_TYPE:"102",INVALID_IDENTIFIER:"103",INVALID_DATA:"104",INVALID_ATTRIBUTE_DEFINITION:"105",INVALID_META_DEFINITION:"106",UNAUTHENTICATED:"107",MISMATCHED_IDENTIFIER:"108",DISABLED_ATTRIBUTE_DEFINITION:"109",DO_NOT_COLLECT:"110"},exports.IngestType=l,exports.getAttributes=p,exports.hasRequiredPrivacyCookies=c,exports.push=async e=>{let{submitData:o,source:i}=e;if(!c())throw new Error("does not satisfy cookie check");if("undefined"!=typeof window&&t.getCookie("wp_wv")&&!t.isLoggedIn())throw new Error("does not satisfy cookie check");const{fieldName:n}=o,a=await p({fieldName:n});if(a[0]&&a[0].name===n&&a[0].collection_behavior===r.DO_NOT_COLLECT)throw new Error("do not collect");const s=a[0]&&!0===a[0].explicit?l.EXPLICIT:l.IMPLICIT;return a[0]||"production"===process.env.NODE_ENV||console.warn(`no attribute info found for ${n}, assuming implicit`),s===l.EXPLICIT?(async e=>{let{submitData:{fieldName:o,value:i},source:n}=e;const a=f+"/ingest",s=t.getCookie("wapo_login_id"),r={jucid:localStorage.getItem("uuid"),ga:t.getCookie("_ga"),type:l.EXPLICIT,wapo_login_id:s,data:{[o]:[i]},metadata:{source:n}};try{const e=await fetch(a,{method:"POST",credentials:"include",headers:t.JSON_HEADERS,body:JSON.stringify(r)});return await e.json()}catch(e){return console.debug(e),null}})({submitData:o,source:i}):(async e=>{let{submitData:{fieldName:t,value:o},source:i}=e;return(e=>{if("undefined"==typeof window)return void("production"!==process.env.NODE_ENV&&console.warn("NO WINDOW"));window.dataLayer=window.dataLayer||[];const t={...e};window.dataLayer.push(t)})({event:"site-onpage-click",action:"site-onpage-click",category:"profile",label:t,"de-label":t,[t]:o,section:"profile",subsection:i}),!0})({submitData:o,source:i})};
|
|
2
2
|
//# sourceMappingURL=subs-de-inputs.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subs-de-inputs.cjs.production.min.js","sources":["../src/interfaces/index.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/getAttributes.ts","../src/services/ingest.ts","../src/components/DESelect/Dropdown.tsx","../src/components/DESelect/index.tsx","../src/utils/push.ts","../src/services/sendToGA.ts"],"sourcesContent":["export type AttributeValue = {\n name: string;\n date_created: Number;\n last_modified_date: Number;\n archived: boolean;\n order: number;\n};\n\nexport const CollectionBehaviors = {\n COLLECT: 'COLLECT',\n DO_NOT_COLLECT: 'DO_NOT_COLLECT',\n} as const;\n\nexport type Attribute = {\n name: string;\n approved_for_use?: boolean;\n collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];\n datatype: string;\n explicit: boolean;\n multiple_value: boolean;\n last_modified_date: Number;\n date_created: Number;\n values: Array<AttributeValue>;\n};\n\nexport const AttributesState = {\n SUCCESS: '100',\n} as const;\n\nexport const IngestType = {\n EXPLICIT: 'explicit',\n IMPLICIT: 'implicit',\n} as const;\n\nexport const IngestResponseState = {\n SUCCESS: '100',\n SYSTEM_ERROR: '101',\n INVALID_TYPE: '102',\n INVALID_IDENTIFIER: '103',\n INVALID_DATA: '104',\n INVALID_ATTRIBUTE_DEFINITION: '105',\n INVALID_META_DEFINITION: '106',\n UNAUTHENTICATED: '107',\n MISMATCHED_IDENTIFIER: '108',\n DISABLED_ATTRIBUTE_DEFINITION: '109',\n DO_NOT_COLLECT: '110',\n} as const;\n","import { WPGeo, getCookie } from '@washingtonpost/subs-sdk';\n\nexport const hasRequiredPrivacyCookies = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_usp = getCookie('wp_usp');\n\n const countryCode = WPGeo()?.country_code;\n\n return !!(wp_usp && countryCode === 'US');\n};\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n} from '@washingtonpost/subs-sdk';\nimport { Attribute } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nconst attributesCache: Record<string, any> = {};\nexport const getAttributes: GetAttributesType = async ({\n fieldName,\n}: {\n fieldName: string;\n}) => {\n if (attributesCache[fieldName]) {\n return attributesCache[fieldName];\n }\n\n const fieldNames = [fieldName];\n\n try {\n const url = new URL(`${base}/attributes`);\n url.searchParams.set('attributes', fieldNames.join(','));\n\n const data = await fetch(url.toString(), {\n credentials: 'include',\n headers: JSON_HEADERS,\n });\n const json = await data.json();\n\n if (data.ok && json.status === ResponseStatus.SUCCESS) {\n const attributes = json.attributes || [];\n attributesCache[fieldName] = attributes;\n return attributes;\n } else {\n return [];\n }\n } catch (e) {\n console.debug(e);\n return [];\n }\n};\n\ntype GetAttributesType = ({\n fieldName,\n}: {\n fieldName: string;\n}) => Promise<Attribute[]>;\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n getCookie,\n} from '@washingtonpost/subs-sdk';\nimport { IngestResponseState, IngestType } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n const jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type: IngestType.EXPLICIT,\n wapo_login_id, // TODO: move this to BE to read from cookie headers\n data: {\n [fieldName]: [value],\n },\n metadata: { source },\n };\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n credentials: 'include',\n headers: JSON_HEADERS,\n body: JSON.stringify(payload),\n });\n\n const json = await response.json();\n\n return json;\n } catch (e) {\n console.debug(e);\n return null;\n }\n};\n\ntype IngestType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<{\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n} | null>;\n","import React, { useEffect, useState } from 'react';\nimport { Icon, Select, styled, theme } from '@washingtonpost/wpds-ui-kit';\nimport { useWindowSize } from '@washingtonpost/subs-hooks';\nimport { ChevronDown } from '@washingtonpost/wpds-assets';\n\ninterface IDropdownProps {\n id: string;\n label: string;\n values: Array<string>;\n required?: boolean;\n defaultValue?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n}\n\nconst StyledMobileSelect = styled('select', {\n padding: '12px 16px 12px 6px',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n backgroundColor: '$secondary',\n color: '$primary',\n fontFamily: '$meta',\n fontSize: '$100',\n fontWeight: '$light',\n lineHeight: '$125',\n paddingBlockRight: '$125',\n textOverflow: 'ellipsis',\n position: 'relative',\n borderColor: 'transparent',\n borderRightWidth: '10px',\n borderRightColor: 'transparent',\n appearance: 'none',\n '-webkit-appearance': 'none',\n '&:disabled': {\n backgroundColor: theme.colors.disabled,\n borderColor: theme.colors.disabled,\n color: theme.colors.onDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst StyledSelectWrapper = styled('div', {\n width: '100%',\n maxWidth: '380px',\n borderRadius: '$012',\n borderColor: '$subtle',\n borderStyle: 'solid',\n borderWidth: '1px',\n backgroundColor: '$secondary',\n position: 'relative',\n});\n\nconst StyledMobileOption = styled('option', {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n color: 'inherit',\n});\n\n/**\n * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.\n * @param {IDropdownProps} props The props.\n * @returns {React.ReactElement} The dropdown.\n */\nexport const Dropdown = ({\n id,\n label,\n values,\n required = false,\n defaultValue,\n onChange = () => {},\n disabled = false,\n}: IDropdownProps) => {\n const [answer, setAnswer] = useState<string>();\n const { isMobileSize } = useWindowSize();\n\n useEffect(() => {\n if (answer) onChange(answer);\n }, [answer]);\n\n const disabledProp = disabled ? { disabled: true } : {};\n\n // helps maintain state between WPDS and native dropdowns\n const defaultValueProp = answer\n ? { defaultValue: answer }\n : defaultValue\n ? { defaultValue }\n : {};\n\n const defaultValuePropMobile = (value: string) => {\n if (answer) {\n return value === answer ? { selected: true } : {};\n }\n return value === defaultValue ? { selected: true } : {};\n };\n\n return isMobileSize ? (\n <StyledSelectWrapper>\n <StyledMobileSelect\n id=\"\"\n required={required}\n onChange={(e) => setAnswer(e.target.value)}\n placeholder={label}\n {...disabledProp}\n >\n <label>{label}</label>\n <StyledMobileOption\n value=\"\"\n disabled\n selected\n style={{ color: '#666666' }}\n >\n {label}\n </StyledMobileOption>\n {values.map((value) => (\n <StyledMobileOption\n value={value}\n key={value}\n {...defaultValuePropMobile(value)}\n >\n {value}\n </StyledMobileOption>\n ))}\n </StyledMobileSelect>\n <Icon\n label=\"\"\n size=\"100\"\n fill={theme.colors['gray80']}\n style={{\n pointerEvents: 'none',\n position: 'absolute',\n right: '10px',\n top: '50%',\n transform: 'translateY(-50%)',\n }}\n >\n <ChevronDown style={{ position: 'absolute', right: '10px' }} />\n </Icon>\n </StyledSelectWrapper>\n ) : (\n <Select.Root\n onValueChange={(e) => setAnswer(e)}\n required={required}\n {...defaultValueProp}\n {...disabledProp}\n >\n <Select.Trigger data-test-id={`${id}-select-trigger`}>\n <Select.Label>{label}</Select.Label>\n <Select.Value />\n </Select.Trigger>\n <Select.Content\n css={{ zIndex: theme.zIndices.page }}\n data-test-id={`${id}-select-content`}\n >\n {values.map((value) => (\n <Select.Item value={value} key={value}>\n {value}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","import React, { useState, useEffect } from 'react';\nimport { Select, styled } from '@washingtonpost/wpds-ui-kit';\nimport { Attribute, AttributeValue } from '../../interfaces';\nimport { ENDPOINTS, ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { useScript, ScriptStatus } from '@washingtonpost/subs-hooks';\nimport { Dropdown } from './Dropdown';\n\ninterface DESelectProps {\n source: string;\n fieldName: string;\n label?: string;\n dataDictionaryConfig?: Attribute;\n defaultValue?: string;\n disabled?: boolean;\n submit: boolean;\n onChange?: ({ value }: { value: string }) => void;\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n valuesFilter?: (value: AttributeValue) => boolean;\n selectProps?: {\n root?: any;\n trigger?: any;\n label?: any;\n value?: any;\n content?: any;\n item?: any;\n };\n children?: React.ReactNode;\n}\n\nconst scriptSrc = `${\n ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static'\n ? 'https://www.washingtonpost.com/subscribe/static/'\n : ENDPOINTS.staticAssets\n}/de-utils/twpdeu.min.js`;\n\nexport const DESelect: React.FC<DESelectProps> = ({\n source,\n fieldName,\n label,\n dataDictionaryConfig,\n defaultValue,\n disabled,\n submit,\n onChange = () => {},\n onFinished = () => {},\n valuesFilter = () => true,\n children,\n}) => {\n const [config, setConfig] = useState(dataDictionaryConfig);\n\n const [selected, setSelected] = useState('');\n\n const scriptStatus = useScript(scriptSrc);\n\n useEffect(() => {\n const fetchConfig = async () => {\n try {\n const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });\n if (config) {\n setConfig(config[0]);\n } else {\n console.error('unable to get config', fieldName);\n }\n } catch (e) {\n console.warn('unable to get config', fieldName, e);\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && !(children || config)) {\n fetchConfig();\n }\n }, [scriptStatus]);\n\n useEffect(() => {\n const submitSelected = async () => {\n try {\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n source,\n });\n\n const isError =\n result === true\n ? false\n : result\n ? result.status !== ResponseStatus.SUCCESS\n : true;\n\n onFinished({\n isFinished: true,\n isError,\n });\n } catch (e) {\n onFinished({\n isFinished: false,\n isError: true,\n });\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && submit && selected) {\n submitSelected();\n }\n }, [scriptStatus, submit]);\n\n const defaultValueProp = defaultValue && config ? { defaultValue } : {};\n\n const isLoading = !(children || config);\n\n const disabledProp = disabled || isLoading ? { disabled: true } : {};\n\n // sort and filter out archived values\n const values = config\n ? [...config.values]\n .sort((a, b) => a.order - b.order)\n .filter((value) => value.archived !== true)\n .filter(valuesFilter)\n : [];\n\n return (\n <SelectWrapper>\n {children && (\n <Select.Root\n onValueChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n {...defaultValueProp}\n {...disabledProp}\n >\n {children}\n </Select.Root>\n )}\n {!children && !config && (\n <Dropdown\n id={'loading'}\n label={'Loading...'}\n values={[]}\n disabled={true}\n />\n )}\n {!children && config && (\n <Dropdown\n id={config.name}\n label={label || config.name}\n onChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n values={values.map((value) => value.name)}\n defaultValue={defaultValue}\n disabled={disabled}\n />\n )}\n </SelectWrapper>\n );\n};\n\nconst SelectWrapper = styled('div', {\n boxSizing: 'border-box',\n display: 'flex',\n marginBottom: '$100',\n flexDirection: 'column',\n '& button': {\n padding: '1px 6px',\n },\n '& *': { boxSizing: 'border-box' },\n});\n","import {\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { getAttributes } from '../services/getAttributes';\nimport { sendToGA } from '../services/sendToGA';\nimport { hasRequiredPrivacyCookies } from './hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from '../services/ingest';\n\nexport const push: PushType = async ({ submitData, source }) => {\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n const { fieldName } = submitData;\n\n const attributeInfo = await getAttributes({\n fieldName,\n });\n\n if (\n attributeInfo[0] &&\n attributeInfo[0].name === fieldName &&\n attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT\n ) {\n throw new Error('do not collect');\n }\n\n const type =\n attributeInfo[0] && attributeInfo[0].explicit === true\n ? IngestType.EXPLICIT\n : IngestType.IMPLICIT;\n\n if (!attributeInfo[0] && __DEV__) {\n console.warn(`no attribute info found for ${fieldName}, assuming implicit`);\n }\n\n if (type === IngestType.EXPLICIT) {\n return ingest({ submitData, source });\n } else {\n return sendToGA({ submitData, source });\n }\n};\n\ntype PushType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<\n | {\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n }\n | null\n | true\n>;\n","const sendGAEvent = (props: {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}): void => {\n if (typeof window === 'undefined') {\n if (__DEV__) console.warn('NO WINDOW');\n return;\n }\n // Initialize dataLayer if needed\n window.dataLayer = window.dataLayer || [];\n\n const eventData: Record<string, any> = {\n ...props,\n };\n window.dataLayer.push(eventData);\n};\n\nexport const sendToGA: SendToGaType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n sendGAEvent({\n event: 'site-onpage-click',\n action: 'site-onpage-click',\n category: 'profile',\n\n label: fieldName,\n 'de-label': fieldName,\n [fieldName]: value,\n\n section: 'profile',\n subsection: source,\n });\n\n return true;\n};\n\ntype SendToGaType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<true>;\n"],"names":["CollectionBehaviors","COLLECT","DO_NOT_COLLECT","IngestType","EXPLICIT","IMPLICIT","hasRequiredPrivacyCookies","window","wp_usp","getCookie","countryCode","_WPGeo","WPGeo","country_code","base","ENDPOINTS","attributesCache","getAttributes","async","fieldName","_ref","fieldNames","url","URL","searchParams","set","join","data","fetch","toString","credentials","headers","JSON_HEADERS","json","ok","status","ResponseStatus","SUCCESS","attributes","e","console","debug","StyledMobileSelect","styled","padding","display","justifyContent","width","backgroundColor","color","fontFamily","fontSize","fontWeight","lineHeight","paddingBlockRight","textOverflow","position","borderColor","borderRightWidth","borderRightColor","appearance","-webkit-appearance","&:disabled","theme","colors","disabled","onDisabled","cursor","StyledSelectWrapper","maxWidth","borderRadius","borderStyle","borderWidth","StyledMobileOption","Dropdown","id","label","values","required","defaultValue","onChange","answer","setAnswer","useState","isMobileSize","useWindowSize","useEffect","disabledProp","defaultValueProp","defaultValuePropMobile","value","selected","React","target","placeholder","style","map","key","Icon","size","fill","pointerEvents","right","top","transform","ChevronDown","Select","Root","onValueChange","Trigger","Label","Value","Content","css","zIndex","zIndices","page","Item","scriptSrc","staticAssets","SelectWrapper","boxSizing","marginBottom","flexDirection","& button","& *","source","dataDictionaryConfig","submit","onFinished","valuesFilter","children","config","setConfig","setSelected","scriptStatus","useScript","ScriptStatus","READY","_window","__twpdeu","getFieldConfigs","error","warn","fetchConfig","_window2","result","push","submitData","isFinished","isError","submitSelected","sort","a","b","order","filter","archived","name","SYSTEM_ERROR","INVALID_TYPE","INVALID_IDENTIFIER","INVALID_DATA","INVALID_ATTRIBUTE_DEFINITION","INVALID_META_DEFINITION","UNAUTHENTICATED","MISMATCHED_IDENTIFIER","DISABLED_ATTRIBUTE_DEFINITION","Error","attributeInfo","collection_behavior","type","explicit","process","env","NODE_ENV","wapo_login_id","payload","jucid","localStorage","getItem","ga","[object Object]","metadata","response","method","body","JSON","stringify","ingest","props","dataLayer","eventData","sendGAEvent","event","action","category","de-label","section","subsection","sendToGA"],"mappings":"0TAQaA,EAAsB,CACjCC,QAAS,UACTC,eAAgB,kBAmBLC,EAAa,CACxBC,SAAU,WACVC,SAAU,YC7BCC,EAA4BA,WACvC,GAAsB,oBAAXC,OACT,OAAO,EAGT,MAAMC,EAASC,YAAU,UAEnBC,UAAWC,EAAGC,qBAAOD,SAAPA,EAASE,aAE7B,SAAUL,GAA0B,OAAhBE,ICJhBI,EAAUC,YAAUD,cAEpBE,EAAuC,GAChCC,EAAmCC,MAAAA,QAAOC,UACrDA,GAGDC,EACC,GAAIJ,EAAgBG,GAClB,OAAOH,EAAgBG,GAGzB,MAAME,EAAa,CAACF,GAEpB,IACE,MAAMG,EAAM,IAAIC,IAAOT,iBACvBQ,EAAIE,aAAaC,IAAI,aAAcJ,EAAWK,KAAK,MAEnD,MAAMC,QAAaC,MAAMN,EAAIO,WAAY,CACvCC,YAAa,UACbC,QAASC,iBAELC,QAAaN,EAAKM,OAExB,GAAIN,EAAKO,IAAMD,EAAKE,SAAWC,iBAAeC,QAAS,CACrD,MAAMC,EAAaL,EAAKK,YAAc,GAEtC,OADAtB,EAAgBG,GAAamB,EACtBA,EAEP,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Q,OACR3J,YAAa,UACbC,QAASC,eACT0J,KAAMC,KAAKC,UAAUX,KAKvB,aAFmBO,EAASvJ,OAG5B,MAAOM,GAEP,OADAC,QAAQC,MAAMF,GACP,OGLAsJ,CAAO,CAAEzC,WAAAA,EAAYtB,OAAAA,ICnBM5G,OAAAA,QACpCkI,YAAYjI,UAAEA,EAASuE,MAAEA,GAAOoC,OAChCA,GACD1G,EAcC,MAtCmB0K,CAAAA,IAQnB,GAAsB,oBAAXvL,OAET,2BADAsK,QAAAC,IAAAC,UAAavI,QAAQuG,KAAK,cAI5BxI,OAAOwL,UAAYxL,OAAOwL,WAAa,GAEvC,MAAMC,EAAiC,IAClCF,GAELvL,OAAOwL,UAAU5C,KAAK6C,IAOtBC,CAAY,CACVC,MAAO,oBACPC,OAAQ,oBACRC,SAAU,UAEVxH,MAAOzD,EACPkL,WAAYlL,EACZmK,CAACnK,GAAYuE,EAEb4G,QAAS,UACTC,WAAYzE,KAGP,GDIE0E,CAAS,CAAEpD,WAAAA,EAAYtB,OAAAA"}
|
|
1
|
+
{"version":3,"file":"subs-de-inputs.cjs.production.min.js","sources":["../src/interfaces/index.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/getAttributes.ts","../src/services/ingest.ts","../src/components/DESelect/Dropdown.tsx","../src/components/DESelect/index.tsx","../src/components/DEDisclosure/utils/checkCookie.ts","../src/components/DEDisclosure/index.tsx","../src/components/DEDisclosure/hooks/useOnetrustAlertBoxClosedPromise.ts","../src/components/DEDisclosure/utils/getConfig.ts","../src/utils/push.ts","../src/utils/isAnonymousWebview.ts","../src/services/sendToGA.ts"],"sourcesContent":["export type AttributeValue = {\n name: string;\n date_created: Number;\n last_modified_date: Number;\n archived: boolean;\n order: number;\n};\n\nexport const CollectionBehaviors = {\n COLLECT: 'COLLECT',\n DO_NOT_COLLECT: 'DO_NOT_COLLECT',\n} as const;\n\nexport type Attribute = {\n name: string;\n approved_for_use?: boolean;\n collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];\n datatype: string;\n explicit: boolean;\n multiple_value: boolean;\n last_modified_date: Number;\n date_created: Number;\n values: AttributeValue[] | Readonly<AttributeValue[]>;\n};\n\nexport const AttributesState = {\n SUCCESS: '100',\n} as const;\n\nexport const IngestType = {\n EXPLICIT: 'explicit',\n IMPLICIT: 'implicit',\n} as const;\n\nexport const IngestResponseState = {\n SUCCESS: '100',\n SYSTEM_ERROR: '101',\n INVALID_TYPE: '102',\n INVALID_IDENTIFIER: '103',\n INVALID_DATA: '104',\n INVALID_ATTRIBUTE_DEFINITION: '105',\n INVALID_META_DEFINITION: '106',\n UNAUTHENTICATED: '107',\n MISMATCHED_IDENTIFIER: '108',\n DISABLED_ATTRIBUTE_DEFINITION: '109',\n DO_NOT_COLLECT: '110',\n} as const;\n","import { WPGeo, getCookie } from '@washingtonpost/subs-sdk';\n\nexport const hasRequiredPrivacyCookies = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_usp = getCookie('wp_usp');\n\n const countryCode = WPGeo()?.country_code;\n\n return !!(wp_usp && countryCode === 'US');\n};\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n} from '@washingtonpost/subs-sdk';\nimport { Attribute } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nconst attributesCache: Record<string, any> = {};\nexport const getAttributes: GetAttributesType = async ({\n fieldName,\n}: {\n fieldName: string;\n}) => {\n if (attributesCache[fieldName]) {\n return attributesCache[fieldName];\n }\n\n const fieldNames = [fieldName];\n\n try {\n const url = new URL(`${base}/attributes`);\n url.searchParams.set('attributes', fieldNames.join(','));\n\n const data = await fetch(url.toString(), {\n credentials: 'include',\n headers: JSON_HEADERS,\n });\n const json = await data.json();\n\n if (data.ok && json.status === ResponseStatus.SUCCESS) {\n const attributes = json.attributes || [];\n attributesCache[fieldName] = attributes;\n return attributes;\n } else {\n return [];\n }\n } catch (e) {\n console.debug(e);\n return [];\n }\n};\n\ntype GetAttributesType = ({\n fieldName,\n}: {\n fieldName: string;\n}) => Promise<Attribute[]>;\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n getCookie,\n} from '@washingtonpost/subs-sdk';\nimport { IngestResponseState, IngestType } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n const jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type: IngestType.EXPLICIT,\n wapo_login_id, // TODO: move this to BE to read from cookie headers\n data: {\n [fieldName]: [value],\n },\n metadata: { source },\n };\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n credentials: 'include',\n headers: JSON_HEADERS,\n body: JSON.stringify(payload),\n });\n\n const json = await response.json();\n\n return json;\n } catch (e) {\n console.debug(e);\n return null;\n }\n};\n\ntype IngestType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<{\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n} | null>;\n","import React, { useEffect, useState } from 'react';\nimport { Icon, Select, styled, theme } from '@washingtonpost/wpds-ui-kit';\nimport { useWindowSize } from '@washingtonpost/subs-hooks';\nimport { ChevronDown } from '@washingtonpost/wpds-assets';\n\ninterface IDropdownProps {\n id: string;\n label: string;\n values: Array<string>;\n required?: boolean;\n defaultValue?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n}\n\nconst StyledMobileSelect = styled('select', {\n padding: '12px 16px 12px 6px',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n backgroundColor: '$secondary',\n color: '$primary',\n fontFamily: '$meta',\n fontSize: '$100',\n fontWeight: '$light',\n lineHeight: '$125',\n paddingBlockRight: '$125',\n textOverflow: 'ellipsis',\n position: 'relative',\n borderColor: 'transparent',\n borderRightWidth: '10px',\n borderRightColor: 'transparent',\n appearance: 'none',\n '-webkit-appearance': 'none',\n '&:disabled': {\n backgroundColor: theme.colors.disabled,\n borderColor: theme.colors.disabled,\n color: theme.colors.onDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst StyledSelectWrapper = styled('div', {\n width: '100%',\n maxWidth: '380px',\n borderRadius: '$012',\n borderColor: '$subtle',\n borderStyle: 'solid',\n borderWidth: '1px',\n backgroundColor: '$secondary',\n position: 'relative',\n});\n\nconst StyledMobileOption = styled('option', {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n color: 'inherit',\n});\n\n/**\n * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.\n * @param {IDropdownProps} props The props.\n * @returns {React.ReactElement} The dropdown.\n */\nexport const Dropdown = ({\n id,\n label,\n values,\n required = false,\n defaultValue,\n onChange = () => {},\n disabled = false,\n}: IDropdownProps) => {\n const [answer, setAnswer] = useState<string>();\n const { isMobileSize } = useWindowSize();\n\n useEffect(() => {\n if (answer) onChange(answer);\n }, [answer]);\n\n const disabledProp = disabled ? { disabled: true } : {};\n\n // helps maintain state between WPDS and native dropdowns\n const defaultValueProp = answer\n ? { defaultValue: answer }\n : defaultValue\n ? { defaultValue }\n : {};\n\n const defaultValuePropMobile = (value: string) => {\n if (answer) {\n return value === answer ? { selected: true } : {};\n }\n return value === defaultValue ? { selected: true } : {};\n };\n\n return isMobileSize ? (\n <StyledSelectWrapper>\n <StyledMobileSelect\n id=\"\"\n required={required}\n onChange={(e) => setAnswer(e.target.value)}\n placeholder={label}\n {...disabledProp}\n >\n <label>{label}</label>\n <StyledMobileOption\n value=\"\"\n disabled\n selected\n style={{ color: '#666666' }}\n >\n {label}\n </StyledMobileOption>\n {values.map((value) => (\n <StyledMobileOption\n value={value}\n key={value}\n {...defaultValuePropMobile(value)}\n >\n {value}\n </StyledMobileOption>\n ))}\n </StyledMobileSelect>\n <Icon\n label=\"\"\n size=\"100\"\n fill={theme.colors['gray80']}\n style={{\n pointerEvents: 'none',\n position: 'absolute',\n right: '10px',\n top: '50%',\n transform: 'translateY(-50%)',\n }}\n >\n <ChevronDown style={{ position: 'absolute', right: '10px' }} />\n </Icon>\n </StyledSelectWrapper>\n ) : (\n <Select.Root\n onValueChange={(e) => setAnswer(e)}\n required={required}\n {...defaultValueProp}\n {...disabledProp}\n >\n <Select.Trigger data-test-id={`${id}-select-trigger`}>\n <Select.Label>{label}</Select.Label>\n <Select.Value />\n </Select.Trigger>\n <Select.Content\n css={{ zIndex: theme.zIndices.page }}\n data-test-id={`${id}-select-content`}\n >\n {values.map((value) => (\n <Select.Item value={value} key={value}>\n {value}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","import React, { useState, useEffect } from 'react';\nimport { Select, styled } from '@washingtonpost/wpds-ui-kit';\nimport { Attribute, AttributeValue } from '../../interfaces';\nimport { ENDPOINTS, ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { useScript, ScriptStatus } from '@washingtonpost/subs-hooks';\nimport { Dropdown } from './Dropdown';\n\ninterface DESelectProps {\n source: string;\n fieldName: string;\n label?: string;\n dataDictionaryConfig?: Attribute | Readonly<Attribute>;\n defaultValue?: string;\n disabled?: boolean;\n submit: boolean;\n onChange?: ({ value }: { value: string }) => void;\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n valuesFilter?: (value: AttributeValue) => boolean;\n selectProps?: {\n root?: any;\n trigger?: any;\n label?: any;\n value?: any;\n content?: any;\n item?: any;\n };\n children?: React.ReactNode;\n}\n\nconst scriptSrc = `${\n ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static'\n ? 'https://www.washingtonpost.com/subscribe/static/'\n : ENDPOINTS.staticAssets\n}/de-utils/twpdeu.min.js`;\n\nexport const DESelect: React.FC<DESelectProps> = ({\n source,\n fieldName,\n label,\n dataDictionaryConfig,\n defaultValue,\n disabled,\n submit,\n onChange = () => {},\n onFinished = () => {},\n valuesFilter = () => true,\n children,\n}) => {\n const [config, setConfig] = useState(dataDictionaryConfig);\n\n const [selected, setSelected] = useState('');\n\n const scriptStatus = useScript(scriptSrc);\n\n useEffect(() => {\n const fetchConfig = async () => {\n try {\n const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });\n if (config) {\n setConfig(config[0]);\n } else {\n console.error('unable to get config', fieldName);\n }\n } catch (e) {\n console.warn('unable to get config', fieldName, e);\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && !(children || config)) {\n fetchConfig();\n }\n }, [scriptStatus]);\n\n useEffect(() => {\n const submitSelected = async () => {\n try {\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n source,\n });\n\n const isError =\n result === true\n ? false\n : result\n ? result.status !== ResponseStatus.SUCCESS\n : true;\n\n onFinished({\n isFinished: true,\n isError,\n });\n } catch (e) {\n onFinished({\n isFinished: false,\n isError: true,\n });\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && submit && selected) {\n submitSelected();\n }\n }, [scriptStatus, submit]);\n\n const defaultValueProp = defaultValue && config ? { defaultValue } : {};\n\n const isLoading = !(children || config);\n\n const disabledProp = disabled || isLoading ? { disabled: true } : {};\n\n // sort and filter out archived values\n // Note: config.values may be readonly\n const values = config\n ? [...config.values]\n .sort((a, b) => a.order - b.order)\n .filter((value) => value.archived !== true)\n .filter(valuesFilter)\n : [];\n\n return (\n <SelectWrapper>\n {children && (\n <Select.Root\n onValueChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n {...defaultValueProp}\n {...disabledProp}\n >\n {children}\n </Select.Root>\n )}\n {!children && !config && (\n <Dropdown\n id={'loading'}\n label={'Loading...'}\n values={[]}\n disabled={true}\n />\n )}\n {!children && config && (\n <Dropdown\n id={config.name}\n label={label || config.name}\n onChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n values={values.map((value) => value.name)}\n defaultValue={defaultValue}\n disabled={disabled}\n />\n )}\n </SelectWrapper>\n );\n};\n\nconst SelectWrapper = styled('div', {\n boxSizing: 'border-box',\n display: 'flex',\n marginBottom: '$100',\n flexDirection: 'column',\n '& button': {\n padding: '1px 6px',\n },\n '& *': { boxSizing: 'border-box' },\n});\n","import { getCookie } from '@washingtonpost/subs-sdk';\n\nconst COOKIE = 'OptanonAlertBoxClosed';\n\nexport const checkCookie = () => {\n const value = getCookie(COOKIE) || '';\n // Wed May 15 2024 06:29:23 GMT-0500 (Central Daylight Time)\n // \"Invalid date\" is 12 characters long\n return value.length > 12;\n};\n","import React, { useState, useEffect } from 'react';\nimport { DisclosureConfigValue } from '../../interfaces/disclosure';\nimport { getConfig } from './utils/getConfig';\nimport { useOneTrustAlertBoxClosed } from './hooks/useOnetrustAlertBoxClosedPromise';\n\ninterface DisclosureProps {\n /** callback function to be called when the disclosure is finished loading */\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n\n /** ability to turn off cookiestore listener, primarily for testing purposes */\n allowCookieStore?: boolean;\n}\n\nexport const DEDisclosure: React.FC<DisclosureProps> = ({\n onFinished = () => {},\n allowCookieStore = true,\n}) => {\n const [disclosure, setDisclosure] = useState<JSX.Element | null>(null);\n const [myConfig, setMyConfig] = useState<DisclosureConfigValue>();\n const { alertBoxClosed } = useOneTrustAlertBoxClosed({ allowCookieStore });\n\n useEffect(() => {\n (async () => {\n const config = await getConfig();\n setMyConfig(config);\n\n if (!config) {\n console.error('No config found');\n }\n })();\n }, []);\n\n useEffect(() => {\n if (myConfig) {\n // step 3: set disclosure based on config\n\n // if config says to check onetrust, check onetrust\n if ('checkBannerStatus' in myConfig && myConfig.checkBannerStatus) {\n // check if onetrust is closed\n // if it is, show the after banner disclosure\n // if it is not, show the before banner disclosure\n if (alertBoxClosed) {\n setDisclosure(myConfig.disclosure_afterbanner);\n } else {\n setDisclosure(myConfig.disclosure_beforebanner);\n }\n } else if ('disclosure' in myConfig) {\n setDisclosure(myConfig.disclosure);\n } else {\n console.error('Invalid config');\n }\n }\n }, [myConfig, alertBoxClosed]);\n\n useEffect(() => {\n if (disclosure) {\n // Is it ok to fire `onFinished` if still waiting for onetrust to load on the page?\n onFinished({\n isFinished: true,\n isError: false,\n });\n }\n }, [disclosure]);\n\n return disclosure === null ? (\n <div data-test-id=\"de-disclosure-loading\"></div>\n ) : (\n <div data-test-id=\"de-disclosure\">{disclosure}</div>\n );\n};\n","import { useState, useEffect } from 'react';\nimport {\n listenToCookieStore as listenToCookieStoreUtil,\n ICookieStore,\n} from '@washingtonpost/subs-sdk';\nimport { checkCookie } from '../utils/checkCookie';\n\nconst COOKIE = 'OptanonAlertBoxClosed';\n\ntype TCData = {\n eventStatus: 'tcloaded' | 'cmpuishown' | 'useractioncomplete';\n listenerId: number;\n [key: string]: any;\n};\n\ntype TCFAPIAddListener = (\n command: 'addEventListener',\n version: number,\n callback: (tcData: TCData, success: boolean) => void\n) => void;\n\ntype TCFAPIRmListener = (\n command: 'removeEventListener',\n version: number,\n callback: (success: boolean) => void,\n listenerId: number\n) => void;\n\ntype TCFAPIPing = (\n command: 'ping',\n version: number,\n callback: (pingReturn: any, success: boolean) => void\n) => void;\n\ndeclare global {\n interface Window {\n cookieStore?: ICookieStore;\n __tcfapi?: TCFAPIAddListener & TCFAPIRmListener & TCFAPIPing;\n }\n}\n\nexport const useOneTrustAlertBoxClosed = ({\n allowCookieStore,\n}: {\n allowCookieStore: boolean;\n}) => {\n const [alertBoxClosed, setAlertBoxClosed] = useState<boolean | undefined>();\n\n const [listenToCookieStore, setListenToCookieStore] = useState(false);\n const [listenToTcfApi, setListenToTcfApi] = useState(false);\n\n useEffect(() => {\n if (checkCookie()) {\n setAlertBoxClosed(true);\n return;\n }\n\n if (!window.__tcfapi) {\n console.warn('warning: __tcfapi not found');\n }\n\n if (window.cookieStore && allowCookieStore) {\n setListenToCookieStore(true);\n } else if (window.__tcfapi) {\n setListenToTcfApi(true);\n } else {\n console.warn('warning: neither cookieStore nor __tcfapi found');\n }\n }, []);\n\n useEffect(() => {\n if (listenToCookieStore && window.cookieStore) {\n const cleanupFn = listenToCookieStoreUtil(COOKIE, () => {\n if (checkCookie()) {\n setAlertBoxClosed(true);\n }\n });\n\n // cleanup fn\n return () => {\n if (cleanupFn) cleanupFn();\n };\n } else {\n return () => {};\n }\n }, [listenToCookieStore]);\n\n useEffect(() => {\n if (listenToTcfApi && window.__tcfapi) {\n let listenerId: number;\n\n const callback = (_tcData: TCData, success: boolean) => {\n if (success) {\n listenerId = _tcData.listenerId;\n\n // tcData.eventStatus can be:\n // tcloaded means user has made a choice and we’re ready to check it\n // cmpuishown means the banner is shown\n // useractioncomplete means the user has interacted with the banner\n\n // but actually if the result for any of these is true, we just use the value of the cookie\n if (checkCookie()) {\n setAlertBoxClosed(true);\n }\n }\n };\n\n window.__tcfapi('addEventListener', 2, callback);\n\n // cleanup fn\n return () => {\n if (window.__tcfapi && listenerId)\n window.__tcfapi(\n 'removeEventListener',\n 2,\n (success) => {\n console.debug(success);\n },\n listenerId\n );\n };\n } else {\n return () => {};\n }\n }, [listenToTcfApi]);\n\n return { alertBoxClosed, listenToCookieStore, listenToTcfApi };\n};\n","import { WPGeo } from '@washingtonpost/subs-sdk';\nimport {\n DisclosureConfig,\n DisclosureConfigValue,\n} from '../../../interfaces/disclosure';\n\n// const configSrc = `${\n// ENDPOINTS.base === 'https://subscribe.washingtonpost.com'\n// ? 'https://www.washingtonpost.com/subscribe'\n// : ENDPOINTS.base\n// }/config/de/disclosure.json`;\n// revert-me-before-prod\nconst configSrc = 'https://subscribe.digitalink.com/config/de/disclosure.json';\n\nexport const getConfig = async () => {\n // step 1: fetch config\n const response = await fetch(configSrc);\n const remoteConfig: DisclosureConfig = await response.json();\n\n // step 2: figure out which part of the config to use\n\n // if country-specific config found, use that\n const countryCode = WPGeo().country_code;\n const eea = WPGeo().intl_region === 'EEA';\n const configs = Object.keys(remoteConfig);\n let myConfig: DisclosureConfigValue | undefined = undefined;\n configs.forEach((config) => {\n if (countryCode && config.split('|').includes(countryCode.toLowerCase())) {\n myConfig = remoteConfig[config];\n } else if (eea && config === 'eea') {\n myConfig = remoteConfig[config];\n }\n });\n\n // TODO: Check for billing country also\n\n // else if no country-specific config, use the default config\n if (typeof myConfig === 'undefined' && remoteConfig['_']) {\n myConfig = remoteConfig['_'];\n }\n\n return myConfig;\n};\n","import {\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { getAttributes } from '../services/getAttributes';\nimport { sendToGA } from '../services/sendToGA';\nimport { hasRequiredPrivacyCookies } from './hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from '../services/ingest';\nimport { isAnonymousWebview } from './isAnonymousWebview';\n\nexport const push: PushType = async ({ submitData, source }) => {\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n if (isAnonymousWebview()) {\n throw new Error('does not satisfy cookie check');\n }\n\n const { fieldName } = submitData;\n\n const attributeInfo = await getAttributes({\n fieldName,\n });\n\n if (\n attributeInfo[0] &&\n attributeInfo[0].name === fieldName &&\n attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT\n ) {\n throw new Error('do not collect');\n }\n\n const type =\n attributeInfo[0] && attributeInfo[0].explicit === true\n ? IngestType.EXPLICIT\n : IngestType.IMPLICIT;\n\n if (!attributeInfo[0] && __DEV__) {\n console.warn(`no attribute info found for ${fieldName}, assuming implicit`);\n }\n\n if (type === IngestType.EXPLICIT) {\n return ingest({ submitData, source });\n } else {\n return sendToGA({ submitData, source });\n }\n};\n\ntype PushType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<\n | {\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n }\n | null\n | true\n>;\n","import { getCookie, isLoggedIn } from '@washingtonpost/subs-sdk';\n\nexport const isAnonymousWebview = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_wv = getCookie('wp_wv');\n\n return !!(wp_wv && !isLoggedIn());\n};\n","const sendGAEvent = (props: {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}): void => {\n if (typeof window === 'undefined') {\n if (__DEV__) console.warn('NO WINDOW');\n return;\n }\n // Initialize dataLayer if needed\n window.dataLayer = window.dataLayer || [];\n\n const eventData: Record<string, any> = {\n ...props,\n };\n window.dataLayer.push(eventData);\n};\n\nexport const sendToGA: SendToGaType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n sendGAEvent({\n event: 'site-onpage-click',\n action: 'site-onpage-click',\n category: 'profile',\n\n label: fieldName,\n 'de-label': fieldName,\n [fieldName]: value,\n\n section: 'profile',\n subsection: source,\n });\n\n return true;\n};\n\ntype SendToGaType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<true>;\n"],"names":["CollectionBehaviors","COLLECT","DO_NOT_COLLECT","IngestType","EXPLICIT","IMPLICIT","hasRequiredPrivacyCookies","window","wp_usp","getCookie","countryCode","_WPGeo","WPGeo","country_code","base","ENDPOINTS","attributesCache","getAttributes","async","fieldName","_ref","fieldNames","url","URL","searchParams","set","join","data","fetch","toString","credentials","headers","JSON_HEADERS","json","ok","status","ResponseStatus","SUCCESS","attributes","e","console","debug","StyledMobileSelect","styled","padding","display","justifyContent","width","backgroundColor","color","fontFamily","fontSize","fontWeight","lineHeight","paddingBlockRight","textOverflow","position","borderColor","borderRightWidth","borderRightColor","appearance","-webkit-appearance","&:disabled","theme","colors","disabled","onDisabled","cursor","StyledSelectWrapper","maxWidth","borderRadius","borderStyle","borderWidth","StyledMobileOption","Dropdown","id","label","values","required","defaultValue","onChange","answer","setAnswer","useState","isMobileSize","useWindowSize","useEffect","disabledProp","defaultValueProp","defaultValuePropMobile","value","selected","React","target","placeholder","style","map","key","Icon","size","fill","pointerEvents","right","top","transform","ChevronDown","Select","Root","onValueChange","Trigger","Label","Value","Content","css","zIndex","zIndices","page","Item","scriptSrc","staticAssets","SelectWrapper","boxSizing","marginBottom","flexDirection","& button","& *","checkCookie","length","onFinished","allowCookieStore","disclosure","setDisclosure","myConfig","setMyConfig","alertBoxClosed","setAlertBoxClosed","listenToCookieStore","setListenToCookieStore","listenToTcfApi","setListenToTcfApi","__tcfapi","warn","cookieStore","cleanupFn","listenToCookieStoreUtil","listenerId","callback","_tcData","success","useOneTrustAlertBoxClosed","config","response","remoteConfig","eea","intl_region","configs","Object","keys","undefined","forEach","split","includes","toLowerCase","getConfig","error","checkBannerStatus","disclosure_afterbanner","disclosure_beforebanner","isFinished","isError","source","dataDictionaryConfig","submit","valuesFilter","children","setConfig","setSelected","scriptStatus","useScript","ScriptStatus","READY","_window","__twpdeu","getFieldConfigs","fetchConfig","_window2","result","push","submitData","submitSelected","sort","a","b","order","filter","archived","name","SYSTEM_ERROR","INVALID_TYPE","INVALID_IDENTIFIER","INVALID_DATA","INVALID_ATTRIBUTE_DEFINITION","INVALID_META_DEFINITION","UNAUTHENTICATED","MISMATCHED_IDENTIFIER","DISABLED_ATTRIBUTE_DEFINITION","Error","isLoggedIn","attributeInfo","collection_behavior","type","explicit","process","env","NODE_ENV","wapo_login_id","payload","jucid","localStorage","getItem","ga","[object Object]","metadata","method","body","JSON","stringify","ingest","props","dataLayer","eventData","sendGAEvent","event","action","category","de-label","section","subsection","sendToGA"],"mappings":"0TAQaA,EAAsB,CACjCC,QAAS,UACTC,eAAgB,kBAmBLC,EAAa,CACxBC,SAAU,WACVC,SAAU,YC7BCC,EAA4BA,WACvC,GAAsB,oBAAXC,OACT,OAAO,EAGT,MAAMC,EAASC,YAAU,UAEnBC,UAAWC,EAAGC,qBAAOD,SAAPA,EAASE,aAE7B,SAAUL,GAA0B,OAAhBE,ICJhBI,EAAUC,YAAUD,cAEpBE,EAAuC,GAChCC,EAAmCC,MAAAA,QAAOC,UACrDA,GAGDC,EACC,GAAIJ,EAAgBG,GAClB,OAAOH,E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CAAEvC,WAAAA,EAAYlB,OAAAA,IExBMxJ,OAAAA,QACpC0K,YAAYzK,UAAEA,EAASuE,MAAEA,GAAOgF,OAChCA,GACDtJ,EAcC,MAtCmBgN,CAAAA,IAQnB,GAAsB,oBAAX7N,OAET,2BADA6M,QAAAC,IAAAC,UAAa9K,QAAQqG,KAAK,cAI5BtI,OAAO8N,UAAY9N,OAAO8N,WAAa,GAEvC,MAAMC,EAAiC,IAClCF,GAEL7N,OAAO8N,UAAU1C,KAAK2C,IAOtBC,CAAY,CACVC,MAAO,oBACPC,OAAQ,oBACRC,SAAU,UAEV9J,MAAOzD,EACPwN,WAAYxN,EACZ0M,CAAC1M,GAAYuE,EAEbkJ,QAAS,UACTC,WAAYnE,KAGP,GFSEoE,CAAS,CAAElD,WAAAA,EAAYlB,OAAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCookie, WPGeo, JSON_HEADERS, ResponseStatus, ENDPOINTS } from '@washingtonpost/subs-sdk';
|
|
1
|
+
import { getCookie, WPGeo, JSON_HEADERS, ResponseStatus, ENDPOINTS, isLoggedIn, listenToCookieStore } from '@washingtonpost/subs-sdk';
|
|
2
2
|
import React, { useState, useEffect } from 'react';
|
|
3
3
|
import { Icon, theme, Select, styled } from '@washingtonpost/wpds-ui-kit';
|
|
4
4
|
import { useWindowSize, useScript, ScriptStatus } from '@washingtonpost/subs-hooks';
|
|
@@ -143,6 +143,14 @@ const ingest = async _ref => {
|
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
|
|
146
|
+
const isAnonymousWebview = () => {
|
|
147
|
+
if (typeof window === 'undefined') {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
const wp_wv = getCookie('wp_wv');
|
|
151
|
+
return !!(wp_wv && !isLoggedIn());
|
|
152
|
+
};
|
|
153
|
+
|
|
146
154
|
const push = async _ref => {
|
|
147
155
|
let {
|
|
148
156
|
submitData,
|
|
@@ -151,6 +159,9 @@ const push = async _ref => {
|
|
|
151
159
|
if (!hasRequiredPrivacyCookies()) {
|
|
152
160
|
throw new Error('does not satisfy cookie check');
|
|
153
161
|
}
|
|
162
|
+
if (isAnonymousWebview()) {
|
|
163
|
+
throw new Error('does not satisfy cookie check');
|
|
164
|
+
}
|
|
154
165
|
const {
|
|
155
166
|
fieldName
|
|
156
167
|
} = submitData;
|
|
@@ -383,6 +394,7 @@ const DESelect = _ref => {
|
|
|
383
394
|
disabled: true
|
|
384
395
|
} : {};
|
|
385
396
|
// sort and filter out archived values
|
|
397
|
+
// Note: config.values may be readonly
|
|
386
398
|
const values = config ? [...config.values].sort((a, b) => a.order - b.order).filter(value => value.archived !== true).filter(valuesFilter) : [];
|
|
387
399
|
return React.createElement(SelectWrapper, null, children && React.createElement(Select.Root, {
|
|
388
400
|
onValueChange: e => {
|
|
@@ -425,5 +437,175 @@ const SelectWrapper = /*#__PURE__*/styled('div', {
|
|
|
425
437
|
}
|
|
426
438
|
});
|
|
427
439
|
|
|
428
|
-
|
|
440
|
+
// const configSrc = `${
|
|
441
|
+
// ENDPOINTS.base === 'https://subscribe.washingtonpost.com'
|
|
442
|
+
// ? 'https://www.washingtonpost.com/subscribe'
|
|
443
|
+
// : ENDPOINTS.base
|
|
444
|
+
// }/config/de/disclosure.json`;
|
|
445
|
+
// revert-me-before-prod
|
|
446
|
+
const configSrc = 'https://subscribe.digitalink.com/config/de/disclosure.json';
|
|
447
|
+
const getConfig = async () => {
|
|
448
|
+
// step 1: fetch config
|
|
449
|
+
const response = await fetch(configSrc);
|
|
450
|
+
const remoteConfig = await response.json();
|
|
451
|
+
// step 2: figure out which part of the config to use
|
|
452
|
+
// if country-specific config found, use that
|
|
453
|
+
const countryCode = WPGeo().country_code;
|
|
454
|
+
const eea = WPGeo().intl_region === 'EEA';
|
|
455
|
+
const configs = Object.keys(remoteConfig);
|
|
456
|
+
let myConfig = undefined;
|
|
457
|
+
configs.forEach(config => {
|
|
458
|
+
if (countryCode && config.split('|').includes(countryCode.toLowerCase())) {
|
|
459
|
+
myConfig = remoteConfig[config];
|
|
460
|
+
} else if (eea && config === 'eea') {
|
|
461
|
+
myConfig = remoteConfig[config];
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
// TODO: Check for billing country also
|
|
465
|
+
// else if no country-specific config, use the default config
|
|
466
|
+
if (typeof myConfig === 'undefined' && remoteConfig['_']) {
|
|
467
|
+
myConfig = remoteConfig['_'];
|
|
468
|
+
}
|
|
469
|
+
return myConfig;
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
const COOKIE = 'OptanonAlertBoxClosed';
|
|
473
|
+
const checkCookie = () => {
|
|
474
|
+
const value = getCookie(COOKIE) || '';
|
|
475
|
+
// Wed May 15 2024 06:29:23 GMT-0500 (Central Daylight Time)
|
|
476
|
+
// "Invalid date" is 12 characters long
|
|
477
|
+
return value.length > 12;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
const COOKIE$1 = 'OptanonAlertBoxClosed';
|
|
481
|
+
const useOneTrustAlertBoxClosed = _ref => {
|
|
482
|
+
let {
|
|
483
|
+
allowCookieStore
|
|
484
|
+
} = _ref;
|
|
485
|
+
const [alertBoxClosed, setAlertBoxClosed] = useState();
|
|
486
|
+
const [listenToCookieStore$1, setListenToCookieStore] = useState(false);
|
|
487
|
+
const [listenToTcfApi, setListenToTcfApi] = useState(false);
|
|
488
|
+
useEffect(() => {
|
|
489
|
+
if (checkCookie()) {
|
|
490
|
+
setAlertBoxClosed(true);
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (!window.__tcfapi) {
|
|
494
|
+
console.warn('warning: __tcfapi not found');
|
|
495
|
+
}
|
|
496
|
+
if (window.cookieStore && allowCookieStore) {
|
|
497
|
+
setListenToCookieStore(true);
|
|
498
|
+
} else if (window.__tcfapi) {
|
|
499
|
+
setListenToTcfApi(true);
|
|
500
|
+
} else {
|
|
501
|
+
console.warn('warning: neither cookieStore nor __tcfapi found');
|
|
502
|
+
}
|
|
503
|
+
}, []);
|
|
504
|
+
useEffect(() => {
|
|
505
|
+
if (listenToCookieStore$1 && window.cookieStore) {
|
|
506
|
+
const cleanupFn = listenToCookieStore(COOKIE$1, () => {
|
|
507
|
+
if (checkCookie()) {
|
|
508
|
+
setAlertBoxClosed(true);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
// cleanup fn
|
|
512
|
+
return () => {
|
|
513
|
+
if (cleanupFn) cleanupFn();
|
|
514
|
+
};
|
|
515
|
+
} else {
|
|
516
|
+
return () => {};
|
|
517
|
+
}
|
|
518
|
+
}, [listenToCookieStore$1]);
|
|
519
|
+
useEffect(() => {
|
|
520
|
+
if (listenToTcfApi && window.__tcfapi) {
|
|
521
|
+
let listenerId;
|
|
522
|
+
const callback = (_tcData, success) => {
|
|
523
|
+
if (success) {
|
|
524
|
+
listenerId = _tcData.listenerId;
|
|
525
|
+
// tcData.eventStatus can be:
|
|
526
|
+
// tcloaded means user has made a choice and we’re ready to check it
|
|
527
|
+
// cmpuishown means the banner is shown
|
|
528
|
+
// useractioncomplete means the user has interacted with the banner
|
|
529
|
+
// but actually if the result for any of these is true, we just use the value of the cookie
|
|
530
|
+
if (checkCookie()) {
|
|
531
|
+
setAlertBoxClosed(true);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
window.__tcfapi('addEventListener', 2, callback);
|
|
536
|
+
// cleanup fn
|
|
537
|
+
return () => {
|
|
538
|
+
if (window.__tcfapi && listenerId) window.__tcfapi('removeEventListener', 2, success => {
|
|
539
|
+
console.debug(success);
|
|
540
|
+
}, listenerId);
|
|
541
|
+
};
|
|
542
|
+
} else {
|
|
543
|
+
return () => {};
|
|
544
|
+
}
|
|
545
|
+
}, [listenToTcfApi]);
|
|
546
|
+
return {
|
|
547
|
+
alertBoxClosed,
|
|
548
|
+
listenToCookieStore: listenToCookieStore$1,
|
|
549
|
+
listenToTcfApi
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
const DEDisclosure = _ref => {
|
|
554
|
+
let {
|
|
555
|
+
onFinished = () => {},
|
|
556
|
+
allowCookieStore = true
|
|
557
|
+
} = _ref;
|
|
558
|
+
const [disclosure, setDisclosure] = useState(null);
|
|
559
|
+
const [myConfig, setMyConfig] = useState();
|
|
560
|
+
const {
|
|
561
|
+
alertBoxClosed
|
|
562
|
+
} = useOneTrustAlertBoxClosed({
|
|
563
|
+
allowCookieStore
|
|
564
|
+
});
|
|
565
|
+
useEffect(() => {
|
|
566
|
+
(async () => {
|
|
567
|
+
const config = await getConfig();
|
|
568
|
+
setMyConfig(config);
|
|
569
|
+
if (!config) {
|
|
570
|
+
console.error('No config found');
|
|
571
|
+
}
|
|
572
|
+
})();
|
|
573
|
+
}, []);
|
|
574
|
+
useEffect(() => {
|
|
575
|
+
if (myConfig) {
|
|
576
|
+
// step 3: set disclosure based on config
|
|
577
|
+
// if config says to check onetrust, check onetrust
|
|
578
|
+
if ('checkBannerStatus' in myConfig && myConfig.checkBannerStatus) {
|
|
579
|
+
// check if onetrust is closed
|
|
580
|
+
// if it is, show the after banner disclosure
|
|
581
|
+
// if it is not, show the before banner disclosure
|
|
582
|
+
if (alertBoxClosed) {
|
|
583
|
+
setDisclosure(myConfig.disclosure_afterbanner);
|
|
584
|
+
} else {
|
|
585
|
+
setDisclosure(myConfig.disclosure_beforebanner);
|
|
586
|
+
}
|
|
587
|
+
} else if ('disclosure' in myConfig) {
|
|
588
|
+
setDisclosure(myConfig.disclosure);
|
|
589
|
+
} else {
|
|
590
|
+
console.error('Invalid config');
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}, [myConfig, alertBoxClosed]);
|
|
594
|
+
useEffect(() => {
|
|
595
|
+
if (disclosure) {
|
|
596
|
+
// Is it ok to fire `onFinished` if still waiting for onetrust to load on the page?
|
|
597
|
+
onFinished({
|
|
598
|
+
isFinished: true,
|
|
599
|
+
isError: false
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
}, [disclosure]);
|
|
603
|
+
return disclosure === null ? React.createElement("div", {
|
|
604
|
+
"data-test-id": "de-disclosure-loading"
|
|
605
|
+
}) : React.createElement("div", {
|
|
606
|
+
"data-test-id": "de-disclosure"
|
|
607
|
+
}, disclosure);
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
export { AttributesState, CollectionBehaviors, DEDisclosure, DESelect, IngestResponseState, IngestType, getAttributes, hasRequiredPrivacyCookies, push };
|
|
429
611
|
//# sourceMappingURL=subs-de-inputs.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subs-de-inputs.esm.js","sources":["../src/interfaces/index.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/getAttributes.ts","../src/services/sendToGA.ts","../src/services/ingest.ts","../src/utils/push.ts","../src/components/DESelect/Dropdown.tsx","../src/components/DESelect/index.tsx"],"sourcesContent":["export type AttributeValue = {\n name: string;\n date_created: Number;\n last_modified_date: Number;\n archived: boolean;\n order: number;\n};\n\nexport const CollectionBehaviors = {\n COLLECT: 'COLLECT',\n DO_NOT_COLLECT: 'DO_NOT_COLLECT',\n} as const;\n\nexport type Attribute = {\n name: string;\n approved_for_use?: boolean;\n collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];\n datatype: string;\n explicit: boolean;\n multiple_value: boolean;\n last_modified_date: Number;\n date_created: Number;\n values: Array<AttributeValue>;\n};\n\nexport const AttributesState = {\n SUCCESS: '100',\n} as const;\n\nexport const IngestType = {\n EXPLICIT: 'explicit',\n IMPLICIT: 'implicit',\n} as const;\n\nexport const IngestResponseState = {\n SUCCESS: '100',\n SYSTEM_ERROR: '101',\n INVALID_TYPE: '102',\n INVALID_IDENTIFIER: '103',\n INVALID_DATA: '104',\n INVALID_ATTRIBUTE_DEFINITION: '105',\n INVALID_META_DEFINITION: '106',\n UNAUTHENTICATED: '107',\n MISMATCHED_IDENTIFIER: '108',\n DISABLED_ATTRIBUTE_DEFINITION: '109',\n DO_NOT_COLLECT: '110',\n} as const;\n","import { WPGeo, getCookie } from '@washingtonpost/subs-sdk';\n\nexport const hasRequiredPrivacyCookies = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_usp = getCookie('wp_usp');\n\n const countryCode = WPGeo()?.country_code;\n\n return !!(wp_usp && countryCode === 'US');\n};\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n} from '@washingtonpost/subs-sdk';\nimport { Attribute } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nconst attributesCache: Record<string, any> = {};\nexport const getAttributes: GetAttributesType = async ({\n fieldName,\n}: {\n fieldName: string;\n}) => {\n if (attributesCache[fieldName]) {\n return attributesCache[fieldName];\n }\n\n const fieldNames = [fieldName];\n\n try {\n const url = new URL(`${base}/attributes`);\n url.searchParams.set('attributes', fieldNames.join(','));\n\n const data = await fetch(url.toString(), {\n credentials: 'include',\n headers: JSON_HEADERS,\n });\n const json = await data.json();\n\n if (data.ok && json.status === ResponseStatus.SUCCESS) {\n const attributes = json.attributes || [];\n attributesCache[fieldName] = attributes;\n return attributes;\n } else {\n return [];\n }\n } catch (e) {\n console.debug(e);\n return [];\n }\n};\n\ntype GetAttributesType = ({\n fieldName,\n}: {\n fieldName: string;\n}) => Promise<Attribute[]>;\n","const sendGAEvent = (props: {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}): void => {\n if (typeof window === 'undefined') {\n if (__DEV__) console.warn('NO WINDOW');\n return;\n }\n // Initialize dataLayer if needed\n window.dataLayer = window.dataLayer || [];\n\n const eventData: Record<string, any> = {\n ...props,\n };\n window.dataLayer.push(eventData);\n};\n\nexport const sendToGA: SendToGaType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n sendGAEvent({\n event: 'site-onpage-click',\n action: 'site-onpage-click',\n category: 'profile',\n\n label: fieldName,\n 'de-label': fieldName,\n [fieldName]: value,\n\n section: 'profile',\n subsection: source,\n });\n\n return true;\n};\n\ntype SendToGaType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<true>;\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n getCookie,\n} from '@washingtonpost/subs-sdk';\nimport { IngestResponseState, IngestType } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n const jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type: IngestType.EXPLICIT,\n wapo_login_id, // TODO: move this to BE to read from cookie headers\n data: {\n [fieldName]: [value],\n },\n metadata: { source },\n };\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n credentials: 'include',\n headers: JSON_HEADERS,\n body: JSON.stringify(payload),\n });\n\n const json = await response.json();\n\n return json;\n } catch (e) {\n console.debug(e);\n return null;\n }\n};\n\ntype IngestType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<{\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n} | null>;\n","import {\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { getAttributes } from '../services/getAttributes';\nimport { sendToGA } from '../services/sendToGA';\nimport { hasRequiredPrivacyCookies } from './hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from '../services/ingest';\n\nexport const push: PushType = async ({ submitData, source }) => {\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n const { fieldName } = submitData;\n\n const attributeInfo = await getAttributes({\n fieldName,\n });\n\n if (\n attributeInfo[0] &&\n attributeInfo[0].name === fieldName &&\n attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT\n ) {\n throw new Error('do not collect');\n }\n\n const type =\n attributeInfo[0] && attributeInfo[0].explicit === true\n ? IngestType.EXPLICIT\n : IngestType.IMPLICIT;\n\n if (!attributeInfo[0] && __DEV__) {\n console.warn(`no attribute info found for ${fieldName}, assuming implicit`);\n }\n\n if (type === IngestType.EXPLICIT) {\n return ingest({ submitData, source });\n } else {\n return sendToGA({ submitData, source });\n }\n};\n\ntype PushType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<\n | {\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n }\n | null\n | true\n>;\n","import React, { useEffect, useState } from 'react';\nimport { Icon, Select, styled, theme } from '@washingtonpost/wpds-ui-kit';\nimport { useWindowSize } from '@washingtonpost/subs-hooks';\nimport { ChevronDown } from '@washingtonpost/wpds-assets';\n\ninterface IDropdownProps {\n id: string;\n label: string;\n values: Array<string>;\n required?: boolean;\n defaultValue?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n}\n\nconst StyledMobileSelect = styled('select', {\n padding: '12px 16px 12px 6px',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n backgroundColor: '$secondary',\n color: '$primary',\n fontFamily: '$meta',\n fontSize: '$100',\n fontWeight: '$light',\n lineHeight: '$125',\n paddingBlockRight: '$125',\n textOverflow: 'ellipsis',\n position: 'relative',\n borderColor: 'transparent',\n borderRightWidth: '10px',\n borderRightColor: 'transparent',\n appearance: 'none',\n '-webkit-appearance': 'none',\n '&:disabled': {\n backgroundColor: theme.colors.disabled,\n borderColor: theme.colors.disabled,\n color: theme.colors.onDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst StyledSelectWrapper = styled('div', {\n width: '100%',\n maxWidth: '380px',\n borderRadius: '$012',\n borderColor: '$subtle',\n borderStyle: 'solid',\n borderWidth: '1px',\n backgroundColor: '$secondary',\n position: 'relative',\n});\n\nconst StyledMobileOption = styled('option', {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n color: 'inherit',\n});\n\n/**\n * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.\n * @param {IDropdownProps} props The props.\n * @returns {React.ReactElement} The dropdown.\n */\nexport const Dropdown = ({\n id,\n label,\n values,\n required = false,\n defaultValue,\n onChange = () => {},\n disabled = false,\n}: IDropdownProps) => {\n const [answer, setAnswer] = useState<string>();\n const { isMobileSize } = useWindowSize();\n\n useEffect(() => {\n if (answer) onChange(answer);\n }, [answer]);\n\n const disabledProp = disabled ? { disabled: true } : {};\n\n // helps maintain state between WPDS and native dropdowns\n const defaultValueProp = answer\n ? { defaultValue: answer }\n : defaultValue\n ? { defaultValue }\n : {};\n\n const defaultValuePropMobile = (value: string) => {\n if (answer) {\n return value === answer ? { selected: true } : {};\n }\n return value === defaultValue ? { selected: true } : {};\n };\n\n return isMobileSize ? (\n <StyledSelectWrapper>\n <StyledMobileSelect\n id=\"\"\n required={required}\n onChange={(e) => setAnswer(e.target.value)}\n placeholder={label}\n {...disabledProp}\n >\n <label>{label}</label>\n <StyledMobileOption\n value=\"\"\n disabled\n selected\n style={{ color: '#666666' }}\n >\n {label}\n </StyledMobileOption>\n {values.map((value) => (\n <StyledMobileOption\n value={value}\n key={value}\n {...defaultValuePropMobile(value)}\n >\n {value}\n </StyledMobileOption>\n ))}\n </StyledMobileSelect>\n <Icon\n label=\"\"\n size=\"100\"\n fill={theme.colors['gray80']}\n style={{\n pointerEvents: 'none',\n position: 'absolute',\n right: '10px',\n top: '50%',\n transform: 'translateY(-50%)',\n }}\n >\n <ChevronDown style={{ position: 'absolute', right: '10px' }} />\n </Icon>\n </StyledSelectWrapper>\n ) : (\n <Select.Root\n onValueChange={(e) => setAnswer(e)}\n required={required}\n {...defaultValueProp}\n {...disabledProp}\n >\n <Select.Trigger data-test-id={`${id}-select-trigger`}>\n <Select.Label>{label}</Select.Label>\n <Select.Value />\n </Select.Trigger>\n <Select.Content\n css={{ zIndex: theme.zIndices.page }}\n data-test-id={`${id}-select-content`}\n >\n {values.map((value) => (\n <Select.Item value={value} key={value}>\n {value}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","import React, { useState, useEffect } from 'react';\nimport { Select, styled } from '@washingtonpost/wpds-ui-kit';\nimport { Attribute, AttributeValue } from '../../interfaces';\nimport { ENDPOINTS, ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { useScript, ScriptStatus } from '@washingtonpost/subs-hooks';\nimport { Dropdown } from './Dropdown';\n\ninterface DESelectProps {\n source: string;\n fieldName: string;\n label?: string;\n dataDictionaryConfig?: Attribute;\n defaultValue?: string;\n disabled?: boolean;\n submit: boolean;\n onChange?: ({ value }: { value: string }) => void;\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n valuesFilter?: (value: AttributeValue) => boolean;\n selectProps?: {\n root?: any;\n trigger?: any;\n label?: any;\n value?: any;\n content?: any;\n item?: any;\n };\n children?: React.ReactNode;\n}\n\nconst scriptSrc = `${\n ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static'\n ? 'https://www.washingtonpost.com/subscribe/static/'\n : ENDPOINTS.staticAssets\n}/de-utils/twpdeu.min.js`;\n\nexport const DESelect: React.FC<DESelectProps> = ({\n source,\n fieldName,\n label,\n dataDictionaryConfig,\n defaultValue,\n disabled,\n submit,\n onChange = () => {},\n onFinished = () => {},\n valuesFilter = () => true,\n children,\n}) => {\n const [config, setConfig] = useState(dataDictionaryConfig);\n\n const [selected, setSelected] = useState('');\n\n const scriptStatus = useScript(scriptSrc);\n\n useEffect(() => {\n const fetchConfig = async () => {\n try {\n const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });\n if (config) {\n setConfig(config[0]);\n } else {\n console.error('unable to get config', fieldName);\n }\n } catch (e) {\n console.warn('unable to get config', fieldName, e);\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && !(children || config)) {\n fetchConfig();\n }\n }, [scriptStatus]);\n\n useEffect(() => {\n const submitSelected = async () => {\n try {\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n source,\n });\n\n const isError =\n result === true\n ? false\n : result\n ? result.status !== ResponseStatus.SUCCESS\n : true;\n\n onFinished({\n isFinished: true,\n isError,\n });\n } catch (e) {\n onFinished({\n isFinished: false,\n isError: true,\n });\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && submit && selected) {\n submitSelected();\n }\n }, [scriptStatus, submit]);\n\n const defaultValueProp = defaultValue && config ? { defaultValue } : {};\n\n const isLoading = !(children || config);\n\n const disabledProp = disabled || isLoading ? { disabled: true } : {};\n\n // sort and filter out archived values\n const values = config\n ? [...config.values]\n .sort((a, b) => a.order - b.order)\n .filter((value) => value.archived !== true)\n .filter(valuesFilter)\n : [];\n\n return (\n <SelectWrapper>\n {children && (\n <Select.Root\n onValueChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n {...defaultValueProp}\n {...disabledProp}\n >\n {children}\n </Select.Root>\n )}\n {!children && !config && (\n <Dropdown\n id={'loading'}\n label={'Loading...'}\n values={[]}\n disabled={true}\n />\n )}\n {!children && config && (\n <Dropdown\n id={config.name}\n label={label || config.name}\n onChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n values={values.map((value) => value.name)}\n defaultValue={defaultValue}\n disabled={disabled}\n />\n )}\n </SelectWrapper>\n );\n};\n\nconst SelectWrapper = styled('div', {\n boxSizing: 'border-box',\n display: 'flex',\n marginBottom: '$100',\n flexDirection: 'column',\n '& button': {\n padding: '1px 6px',\n },\n '& *': { boxSizing: 'border-box' },\n});\n"],"names":["CollectionBehaviors","COLLECT","DO_NOT_COLLECT","AttributesState","SUCCESS","IngestType","EXPLICIT","IMPLICIT","IngestResponseState","SYSTEM_ERROR","INVALID_TYPE","INVALID_IDENTIFIER","INVALID_DATA","INVALID_ATTRIBUTE_DEFINITION","INVALID_META_DEFINITION","UNAUTHENTICATED","MISMATCHED_IDENTIFIER","DISABLED_ATTRIBUTE_DEFINITION","hasRequiredPrivacyCookies","window","wp_usp","getCookie","countryCode","_WPGeo","WPGeo","country_code","base","ENDPOINTS","attributesCache","getAttributes","_ref","fieldName","fieldNames","url","URL","searchParams","set","join","data","fetch","toString","credentials","headers","JSON_HEADERS","json","ok","status","ResponseStatus","attributes","e","console","debug","sendGAEvent","props","process","env","NODE_ENV","warn","dataLayer","eventData","push","sendToGA","submitData","value","source","event","action","category","label","section","subsection","ingest","wapo_login_id","jucid","localStorage","getItem","ga","payload","type","metadata","response","method","body","JSON","stringify","Error","attributeInfo","name","collection_behavior","explicit","StyledMobileSelect","styled","padding","display","justifyContent","width","backgroundColor","color","fontFamily","fontSize","fontWeight","lineHeight","paddingBlockRight","textOverflow","position","borderColor","borderRightWidth","borderRightColor","appearance","theme","colors","disabled","onDisabled","cursor","StyledSelectWrapper","maxWidth","borderRadius","borderStyle","borderWidth","StyledMobileOption","Dropdown","id","values","required","defaultValue","onChange","answer","setAnswer","useState","isMobileSize","useWindowSize","useEffect","disabledProp","defaultValueProp","defaultValuePropMobile","selected","React","target","placeholder","style","map","key","Icon","size","fill","pointerEvents","right","top","transform","ChevronDown","Select","Root","onValueChange","Trigger","Label","Value","Content","css","zIndex","zIndices","page","Item","scriptSrc","staticAssets","DESelect","dataDictionaryConfig","submit","onFinished","valuesFilter","children","config","setConfig","setSelected","scriptStatus","useScript","fetchConfig","_window","__twpdeu","getFieldConfigs","error","ScriptStatus","READY","submitSelected","_window2","result","isError","isFinished","isLoading","sort","a","b","order","filter","archived","SelectWrapper","boxSizing","marginBottom","flexDirection"],"mappings":";;;;;;MAQaA,mBAAmB,GAAG;EACjCC,OAAO,EAAE,SAAS;EAClBC,cAAc,EAAE;;MAeLC,eAAe,GAAG;EAC7BC,OAAO,EAAE;;MAGEC,UAAU,GAAG;EACxBC,QAAQ,EAAE,UAAU;EACpBC,QAAQ,EAAE;;MAGCC,mBAAmB,GAAG;EACjCJ,OAAO,EAAE,KAAK;EACdK,YAAY,EA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KAAK,EAAEd;OAAG,CAAC;KACvB;IACDyE,MAAM,EAAEA,MAAM,CAACkB,GAAG,CAAE7E,KAAK,IAAKA,KAAK,CAACwB,IAAI,CAAC;IACzCqC,YAAY,EAAEA,YAAY;IAC1Bb,QAAQ,EAAEA;IAEb,CACa;AAEpB,CAAC;AAED,MAAMmF,aAAa,gBAAGvG,MAAM,CAAC,KAAK,EAAE;EAClCwG,SAAS,EAAE,YAAY;EACvBtG,OAAO,EAAE,MAAM;EACfuG,YAAY,EAAE,MAAM;EACpBC,aAAa,EAAE,QAAQ;EACvB,UAAU,EAAE;IACVzG,OAAO,EAAE;GACV;EACD,KAAK,EAAE;IAAEuG,SAAS,EAAE;;CACrB,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"subs-de-inputs.esm.js","sources":["../src/interfaces/index.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/getAttributes.ts","../src/services/sendToGA.ts","../src/services/ingest.ts","../src/utils/isAnonymousWebview.ts","../src/utils/push.ts","../src/components/DESelect/Dropdown.tsx","../src/components/DESelect/index.tsx","../src/components/DEDisclosure/utils/getConfig.ts","../src/components/DEDisclosure/utils/checkCookie.ts","../src/components/DEDisclosure/hooks/useOnetrustAlertBoxClosedPromise.ts","../src/components/DEDisclosure/index.tsx"],"sourcesContent":["export type AttributeValue = {\n name: string;\n date_created: Number;\n last_modified_date: Number;\n archived: boolean;\n order: number;\n};\n\nexport const CollectionBehaviors = {\n COLLECT: 'COLLECT',\n DO_NOT_COLLECT: 'DO_NOT_COLLECT',\n} as const;\n\nexport type Attribute = {\n name: string;\n approved_for_use?: boolean;\n collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];\n datatype: string;\n explicit: boolean;\n multiple_value: boolean;\n last_modified_date: Number;\n date_created: Number;\n values: AttributeValue[] | Readonly<AttributeValue[]>;\n};\n\nexport const AttributesState = {\n SUCCESS: '100',\n} as const;\n\nexport const IngestType = {\n EXPLICIT: 'explicit',\n IMPLICIT: 'implicit',\n} as const;\n\nexport const IngestResponseState = {\n SUCCESS: '100',\n SYSTEM_ERROR: '101',\n INVALID_TYPE: '102',\n INVALID_IDENTIFIER: '103',\n INVALID_DATA: '104',\n INVALID_ATTRIBUTE_DEFINITION: '105',\n INVALID_META_DEFINITION: '106',\n UNAUTHENTICATED: '107',\n MISMATCHED_IDENTIFIER: '108',\n DISABLED_ATTRIBUTE_DEFINITION: '109',\n DO_NOT_COLLECT: '110',\n} as const;\n","import { WPGeo, getCookie } from '@washingtonpost/subs-sdk';\n\nexport const hasRequiredPrivacyCookies = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_usp = getCookie('wp_usp');\n\n const countryCode = WPGeo()?.country_code;\n\n return !!(wp_usp && countryCode === 'US');\n};\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n} from '@washingtonpost/subs-sdk';\nimport { Attribute } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nconst attributesCache: Record<string, any> = {};\nexport const getAttributes: GetAttributesType = async ({\n fieldName,\n}: {\n fieldName: string;\n}) => {\n if (attributesCache[fieldName]) {\n return attributesCache[fieldName];\n }\n\n const fieldNames = [fieldName];\n\n try {\n const url = new URL(`${base}/attributes`);\n url.searchParams.set('attributes', fieldNames.join(','));\n\n const data = await fetch(url.toString(), {\n credentials: 'include',\n headers: JSON_HEADERS,\n });\n const json = await data.json();\n\n if (data.ok && json.status === ResponseStatus.SUCCESS) {\n const attributes = json.attributes || [];\n attributesCache[fieldName] = attributes;\n return attributes;\n } else {\n return [];\n }\n } catch (e) {\n console.debug(e);\n return [];\n }\n};\n\ntype GetAttributesType = ({\n fieldName,\n}: {\n fieldName: string;\n}) => Promise<Attribute[]>;\n","const sendGAEvent = (props: {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}): void => {\n if (typeof window === 'undefined') {\n if (__DEV__) console.warn('NO WINDOW');\n return;\n }\n // Initialize dataLayer if needed\n window.dataLayer = window.dataLayer || [];\n\n const eventData: Record<string, any> = {\n ...props,\n };\n window.dataLayer.push(eventData);\n};\n\nexport const sendToGA: SendToGaType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n sendGAEvent({\n event: 'site-onpage-click',\n action: 'site-onpage-click',\n category: 'profile',\n\n label: fieldName,\n 'de-label': fieldName,\n [fieldName]: value,\n\n section: 'profile',\n subsection: source,\n });\n\n return true;\n};\n\ntype SendToGaType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<true>;\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n getCookie,\n} from '@washingtonpost/subs-sdk';\nimport { IngestResponseState, IngestType } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n const jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type: IngestType.EXPLICIT,\n wapo_login_id, // TODO: move this to BE to read from cookie headers\n data: {\n [fieldName]: [value],\n },\n metadata: { source },\n };\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n credentials: 'include',\n headers: JSON_HEADERS,\n body: JSON.stringify(payload),\n });\n\n const json = await response.json();\n\n return json;\n } catch (e) {\n console.debug(e);\n return null;\n }\n};\n\ntype IngestType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<{\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n} | null>;\n","import { getCookie, isLoggedIn } from '@washingtonpost/subs-sdk';\n\nexport const isAnonymousWebview = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_wv = getCookie('wp_wv');\n\n return !!(wp_wv && !isLoggedIn());\n};\n","import {\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { getAttributes } from '../services/getAttributes';\nimport { sendToGA } from '../services/sendToGA';\nimport { hasRequiredPrivacyCookies } from './hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from '../services/ingest';\nimport { isAnonymousWebview } from './isAnonymousWebview';\n\nexport const push: PushType = async ({ submitData, source }) => {\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n if (isAnonymousWebview()) {\n throw new Error('does not satisfy cookie check');\n }\n\n const { fieldName } = submitData;\n\n const attributeInfo = await getAttributes({\n fieldName,\n });\n\n if (\n attributeInfo[0] &&\n attributeInfo[0].name === fieldName &&\n attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT\n ) {\n throw new Error('do not collect');\n }\n\n const type =\n attributeInfo[0] && attributeInfo[0].explicit === true\n ? IngestType.EXPLICIT\n : IngestType.IMPLICIT;\n\n if (!attributeInfo[0] && __DEV__) {\n console.warn(`no attribute info found for ${fieldName}, assuming implicit`);\n }\n\n if (type === IngestType.EXPLICIT) {\n return ingest({ submitData, source });\n } else {\n return sendToGA({ submitData, source });\n }\n};\n\ntype PushType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<\n | {\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n }\n | null\n | true\n>;\n","import React, { useEffect, useState } from 'react';\nimport { Icon, Select, styled, theme } from '@washingtonpost/wpds-ui-kit';\nimport { useWindowSize } from '@washingtonpost/subs-hooks';\nimport { ChevronDown } from '@washingtonpost/wpds-assets';\n\ninterface IDropdownProps {\n id: string;\n label: string;\n values: Array<string>;\n required?: boolean;\n defaultValue?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n}\n\nconst StyledMobileSelect = styled('select', {\n padding: '12px 16px 12px 6px',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n backgroundColor: '$secondary',\n color: '$primary',\n fontFamily: '$meta',\n fontSize: '$100',\n fontWeight: '$light',\n lineHeight: '$125',\n paddingBlockRight: '$125',\n textOverflow: 'ellipsis',\n position: 'relative',\n borderColor: 'transparent',\n borderRightWidth: '10px',\n borderRightColor: 'transparent',\n appearance: 'none',\n '-webkit-appearance': 'none',\n '&:disabled': {\n backgroundColor: theme.colors.disabled,\n borderColor: theme.colors.disabled,\n color: theme.colors.onDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst StyledSelectWrapper = styled('div', {\n width: '100%',\n maxWidth: '380px',\n borderRadius: '$012',\n borderColor: '$subtle',\n borderStyle: 'solid',\n borderWidth: '1px',\n backgroundColor: '$secondary',\n position: 'relative',\n});\n\nconst StyledMobileOption = styled('option', {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n color: 'inherit',\n});\n\n/**\n * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.\n * @param {IDropdownProps} props The props.\n * @returns {React.ReactElement} The dropdown.\n */\nexport const Dropdown = ({\n id,\n label,\n values,\n required = false,\n defaultValue,\n onChange = () => {},\n disabled = false,\n}: IDropdownProps) => {\n const [answer, setAnswer] = useState<string>();\n const { isMobileSize } = useWindowSize();\n\n useEffect(() => {\n if (answer) onChange(answer);\n }, [answer]);\n\n const disabledProp = disabled ? { disabled: true } : {};\n\n // helps maintain state between WPDS and native dropdowns\n const defaultValueProp = answer\n ? { defaultValue: answer }\n : defaultValue\n ? { defaultValue }\n : {};\n\n const defaultValuePropMobile = (value: string) => {\n if (answer) {\n return value === answer ? { selected: true } : {};\n }\n return value === defaultValue ? { selected: true } : {};\n };\n\n return isMobileSize ? (\n <StyledSelectWrapper>\n <StyledMobileSelect\n id=\"\"\n required={required}\n onChange={(e) => setAnswer(e.target.value)}\n placeholder={label}\n {...disabledProp}\n >\n <label>{label}</label>\n <StyledMobileOption\n value=\"\"\n disabled\n selected\n style={{ color: '#666666' }}\n >\n {label}\n </StyledMobileOption>\n {values.map((value) => (\n <StyledMobileOption\n value={value}\n key={value}\n {...defaultValuePropMobile(value)}\n >\n {value}\n </StyledMobileOption>\n ))}\n </StyledMobileSelect>\n <Icon\n label=\"\"\n size=\"100\"\n fill={theme.colors['gray80']}\n style={{\n pointerEvents: 'none',\n position: 'absolute',\n right: '10px',\n top: '50%',\n transform: 'translateY(-50%)',\n }}\n >\n <ChevronDown style={{ position: 'absolute', right: '10px' }} />\n </Icon>\n </StyledSelectWrapper>\n ) : (\n <Select.Root\n onValueChange={(e) => setAnswer(e)}\n required={required}\n {...defaultValueProp}\n {...disabledProp}\n >\n <Select.Trigger data-test-id={`${id}-select-trigger`}>\n <Select.Label>{label}</Select.Label>\n <Select.Value />\n </Select.Trigger>\n <Select.Content\n css={{ zIndex: theme.zIndices.page }}\n data-test-id={`${id}-select-content`}\n >\n {values.map((value) => (\n <Select.Item value={value} key={value}>\n {value}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","import React, { useState, useEffect } from 'react';\nimport { Select, styled } from '@washingtonpost/wpds-ui-kit';\nimport { Attribute, AttributeValue } from '../../interfaces';\nimport { ENDPOINTS, ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { useScript, ScriptStatus } from '@washingtonpost/subs-hooks';\nimport { Dropdown } from './Dropdown';\n\ninterface DESelectProps {\n source: string;\n fieldName: string;\n label?: string;\n dataDictionaryConfig?: Attribute | Readonly<Attribute>;\n defaultValue?: string;\n disabled?: boolean;\n submit: boolean;\n onChange?: ({ value }: { value: string }) => void;\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n valuesFilter?: (value: AttributeValue) => boolean;\n selectProps?: {\n root?: any;\n trigger?: any;\n label?: any;\n value?: any;\n content?: any;\n item?: any;\n };\n children?: React.ReactNode;\n}\n\nconst scriptSrc = `${\n ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static'\n ? 'https://www.washingtonpost.com/subscribe/static/'\n : ENDPOINTS.staticAssets\n}/de-utils/twpdeu.min.js`;\n\nexport const DESelect: React.FC<DESelectProps> = ({\n source,\n fieldName,\n label,\n dataDictionaryConfig,\n defaultValue,\n disabled,\n submit,\n onChange = () => {},\n onFinished = () => {},\n valuesFilter = () => true,\n children,\n}) => {\n const [config, setConfig] = useState(dataDictionaryConfig);\n\n const [selected, setSelected] = useState('');\n\n const scriptStatus = useScript(scriptSrc);\n\n useEffect(() => {\n const fetchConfig = async () => {\n try {\n const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });\n if (config) {\n setConfig(config[0]);\n } else {\n console.error('unable to get config', fieldName);\n }\n } catch (e) {\n console.warn('unable to get config', fieldName, e);\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && !(children || config)) {\n fetchConfig();\n }\n }, [scriptStatus]);\n\n useEffect(() => {\n const submitSelected = async () => {\n try {\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n source,\n });\n\n const isError =\n result === true\n ? false\n : result\n ? result.status !== ResponseStatus.SUCCESS\n : true;\n\n onFinished({\n isFinished: true,\n isError,\n });\n } catch (e) {\n onFinished({\n isFinished: false,\n isError: true,\n });\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && submit && selected) {\n submitSelected();\n }\n }, [scriptStatus, submit]);\n\n const defaultValueProp = defaultValue && config ? { defaultValue } : {};\n\n const isLoading = !(children || config);\n\n const disabledProp = disabled || isLoading ? { disabled: true } : {};\n\n // sort and filter out archived values\n // Note: config.values may be readonly\n const values = config\n ? [...config.values]\n .sort((a, b) => a.order - b.order)\n .filter((value) => value.archived !== true)\n .filter(valuesFilter)\n : [];\n\n return (\n <SelectWrapper>\n {children && (\n <Select.Root\n onValueChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n {...defaultValueProp}\n {...disabledProp}\n >\n {children}\n </Select.Root>\n )}\n {!children && !config && (\n <Dropdown\n id={'loading'}\n label={'Loading...'}\n values={[]}\n disabled={true}\n />\n )}\n {!children && config && (\n <Dropdown\n id={config.name}\n label={label || config.name}\n onChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n values={values.map((value) => value.name)}\n defaultValue={defaultValue}\n disabled={disabled}\n />\n )}\n </SelectWrapper>\n );\n};\n\nconst SelectWrapper = styled('div', {\n boxSizing: 'border-box',\n display: 'flex',\n marginBottom: '$100',\n flexDirection: 'column',\n '& button': {\n padding: '1px 6px',\n },\n '& *': { boxSizing: 'border-box' },\n});\n","import { WPGeo } from '@washingtonpost/subs-sdk';\nimport {\n DisclosureConfig,\n DisclosureConfigValue,\n} from '../../../interfaces/disclosure';\n\n// const configSrc = `${\n// ENDPOINTS.base === 'https://subscribe.washingtonpost.com'\n// ? 'https://www.washingtonpost.com/subscribe'\n// : ENDPOINTS.base\n// }/config/de/disclosure.json`;\n// revert-me-before-prod\nconst configSrc = 'https://subscribe.digitalink.com/config/de/disclosure.json';\n\nexport const getConfig = async () => {\n // step 1: fetch config\n const response = await fetch(configSrc);\n const remoteConfig: DisclosureConfig = await response.json();\n\n // step 2: figure out which part of the config to use\n\n // if country-specific config found, use that\n const countryCode = WPGeo().country_code;\n const eea = WPGeo().intl_region === 'EEA';\n const configs = Object.keys(remoteConfig);\n let myConfig: DisclosureConfigValue | undefined = undefined;\n configs.forEach((config) => {\n if (countryCode && config.split('|').includes(countryCode.toLowerCase())) {\n myConfig = remoteConfig[config];\n } else if (eea && config === 'eea') {\n myConfig = remoteConfig[config];\n }\n });\n\n // TODO: Check for billing country also\n\n // else if no country-specific config, use the default config\n if (typeof myConfig === 'undefined' && remoteConfig['_']) {\n myConfig = remoteConfig['_'];\n }\n\n return myConfig;\n};\n","import { getCookie } from '@washingtonpost/subs-sdk';\n\nconst COOKIE = 'OptanonAlertBoxClosed';\n\nexport const checkCookie = () => {\n const value = getCookie(COOKIE) || '';\n // Wed May 15 2024 06:29:23 GMT-0500 (Central Daylight Time)\n // \"Invalid date\" is 12 characters long\n return value.length > 12;\n};\n","import { useState, useEffect } from 'react';\nimport {\n listenToCookieStore as listenToCookieStoreUtil,\n ICookieStore,\n} from '@washingtonpost/subs-sdk';\nimport { checkCookie } from '../utils/checkCookie';\n\nconst COOKIE = 'OptanonAlertBoxClosed';\n\ntype TCData = {\n eventStatus: 'tcloaded' | 'cmpuishown' | 'useractioncomplete';\n listenerId: number;\n [key: string]: any;\n};\n\ntype TCFAPIAddListener = (\n command: 'addEventListener',\n version: number,\n callback: (tcData: TCData, success: boolean) => void\n) => void;\n\ntype TCFAPIRmListener = (\n command: 'removeEventListener',\n version: number,\n callback: (success: boolean) => void,\n listenerId: number\n) => void;\n\ntype TCFAPIPing = (\n command: 'ping',\n version: number,\n callback: (pingReturn: any, success: boolean) => void\n) => void;\n\ndeclare global {\n interface Window {\n cookieStore?: ICookieStore;\n __tcfapi?: TCFAPIAddListener & TCFAPIRmListener & TCFAPIPing;\n }\n}\n\nexport const useOneTrustAlertBoxClosed = ({\n allowCookieStore,\n}: {\n allowCookieStore: boolean;\n}) => {\n const [alertBoxClosed, setAlertBoxClosed] = useState<boolean | undefined>();\n\n const [listenToCookieStore, setListenToCookieStore] = useState(false);\n const [listenToTcfApi, setListenToTcfApi] = useState(false);\n\n useEffect(() => {\n if (checkCookie()) {\n setAlertBoxClosed(true);\n return;\n }\n\n if (!window.__tcfapi) {\n console.warn('warning: __tcfapi not found');\n }\n\n if (window.cookieStore && allowCookieStore) {\n setListenToCookieStore(true);\n } else if (window.__tcfapi) {\n setListenToTcfApi(true);\n } else {\n console.warn('warning: neither cookieStore nor __tcfapi found');\n }\n }, []);\n\n useEffect(() => {\n if (listenToCookieStore && window.cookieStore) {\n const cleanupFn = listenToCookieStoreUtil(COOKIE, () => {\n if (checkCookie()) {\n setAlertBoxClosed(true);\n }\n });\n\n // cleanup fn\n return () => {\n if (cleanupFn) cleanupFn();\n };\n } else {\n return () => {};\n }\n }, [listenToCookieStore]);\n\n useEffect(() => {\n if (listenToTcfApi && window.__tcfapi) {\n let listenerId: number;\n\n const callback = (_tcData: TCData, success: boolean) => {\n if (success) {\n listenerId = _tcData.listenerId;\n\n // tcData.eventStatus can be:\n // tcloaded means user has made a choice and we’re ready to check it\n // cmpuishown means the banner is shown\n // useractioncomplete means the user has interacted with the banner\n\n // but actually if the result for any of these is true, we just use the value of the cookie\n if (checkCookie()) {\n setAlertBoxClosed(true);\n }\n }\n };\n\n window.__tcfapi('addEventListener', 2, callback);\n\n // cleanup fn\n return () => {\n if (window.__tcfapi && listenerId)\n window.__tcfapi(\n 'removeEventListener',\n 2,\n (success) => {\n console.debug(success);\n },\n listenerId\n );\n };\n } else {\n return () => {};\n }\n }, [listenToTcfApi]);\n\n return { alertBoxClosed, listenToCookieStore, listenToTcfApi };\n};\n","import React, { useState, useEffect } from 'react';\nimport { DisclosureConfigValue } from '../../interfaces/disclosure';\nimport { getConfig } from './utils/getConfig';\nimport { useOneTrustAlertBoxClosed } from './hooks/useOnetrustAlertBoxClosedPromise';\n\ninterface DisclosureProps {\n /** callback function to be called when the disclosure is finished loading */\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n\n /** ability to turn off cookiestore listener, primarily for testing purposes */\n allowCookieStore?: boolean;\n}\n\nexport const DEDisclosure: React.FC<DisclosureProps> = ({\n onFinished = () => {},\n allowCookieStore = true,\n}) => {\n const [disclosure, setDisclosure] = useState<JSX.Element | null>(null);\n const [myConfig, setMyConfig] = useState<DisclosureConfigValue>();\n const { alertBoxClosed } = useOneTrustAlertBoxClosed({ allowCookieStore });\n\n useEffect(() => {\n (async () => {\n const config = await getConfig();\n setMyConfig(config);\n\n if (!config) {\n console.error('No config found');\n }\n })();\n }, []);\n\n useEffect(() => {\n if (myConfig) {\n // step 3: set disclosure based on config\n\n // if config says to check onetrust, check onetrust\n if ('checkBannerStatus' in myConfig && myConfig.checkBannerStatus) {\n // check if onetrust is closed\n // if it is, show the after banner disclosure\n // if it is not, show the before banner disclosure\n if (alertBoxClosed) {\n setDisclosure(myConfig.disclosure_afterbanner);\n } else {\n setDisclosure(myConfig.disclosure_beforebanner);\n }\n } else if ('disclosure' in myConfig) {\n setDisclosure(myConfig.disclosure);\n } else {\n console.error('Invalid config');\n }\n }\n }, [myConfig, alertBoxClosed]);\n\n useEffect(() => {\n if (disclosure) {\n // Is it ok to fire `onFinished` if still waiting for onetrust to load on the page?\n onFinished({\n isFinished: true,\n isError: false,\n });\n }\n }, [disclosure]);\n\n return disclosure === null ? (\n <div data-test-id=\"de-disclosure-loading\"></div>\n ) : (\n <div data-test-id=\"de-disclosure\">{disclosure}</div>\n );\n};\n"],"names":["CollectionBehaviors","COLLECT","DO_NOT_COLLECT","AttributesState","SUCCESS","IngestType","EXPLICIT","IMPLICIT","IngestResponseState","SYSTEM_ERROR","INVALID_TYPE","INVALID_IDENTIFIER","INVALID_DATA","INVALID_ATTRIBUTE_DEFINITION","INVALID_META_DEFINITION","UNAUTHENTICATED","MISMATCHED_IDENTIFIER","DISABLED_ATTRIBUTE_DEFINITION","hasRequiredPrivacyCookies","window","wp_usp","getCookie","countryCode","_WPGeo","WPGeo","country_code","base","ENDPOINTS","attributesCache","getAttributes","_ref","fieldName","fieldNames","url","URL","searchParams","set","join","data","fetch","toString","credentials","headers","JSON_HEADERS","json","ok","status","ResponseStatus","attributes","e","console","debug","sendGAEvent","props","process","env","NODE_ENV","warn","dataLayer","eventData","push","sendToGA","submitData","value","source","event","action","category","label","section","subsection","ingest","wapo_login_id","jucid","localStorage","getItem","ga","payload","type","metadata","response","method","body","JSON","stringify","isAnonymousWebview","wp_wv","isLoggedIn","Error","attributeInfo","name","collection_behavior","explicit","StyledMobileSelect","styled","padding","display","justifyContent","width","backgroundColor","color","fontFamily","fontSize","fontWeight","lineHeight","paddingBlockRight","textOverflow","position","borderColor","borderRightWidth","borderRightColor","appearance","theme","colors","disabled","onDisabled","cursor","StyledSelectWrapper","maxWidth","borderRadius","borderStyle","borderWidth","StyledMobileOption","Dropdown","id","values","required","defaultValue","onChange","answer","setAnswer","useState","isMobileSize","useWindowSize","useEffect","disabledProp","defaultValueProp","defaultValuePropMobile","selected","React","target","placeholder","style","map","key","Icon","size","fill","pointerEvents","right","top","transform","ChevronDown","Select","Root","onValueChange","Trigger","Label","Value","Content","css","zIndex","zIndices","page","Item","scriptSrc","staticAssets","DESelect","dataDictionaryConfig","submit","onFinished","valuesFilter","children","config","setConfig","setSelected","scriptStatus","useScript","fetchConfig","_window","__twpdeu","getFieldConfigs","error","ScriptStatus","READY","submitSelected","_window2","result","isError","isFinished","isLoading","sort","a","b","order","filter","archived","SelectWrapper","boxSizing","marginBottom","flexDirection","configSrc","getConfig","remoteConfig","eea","intl_region","configs","Object","keys","myConfig","undefined","forEach","split","includes","toLowerCase","COOKIE","checkCookie","length","useOneTrustAlertBoxClosed","allowCookieStore","alertBoxClosed","setAlertBoxClosed","listenToCookieStore","setListenToCookieStore","listenToTcfApi","setListenToTcfApi","__tcfapi","cookieStore","cleanupFn","listenToCookieStoreUtil","listenerId","callback","_tcData","success","DEDisclosure","disclosure","setDisclosure","setMyConfig","checkBannerStatus","disclosure_afterbanner","disclosure_beforebanner"],"mappings":";;;;;;MAQaA,mBAAmB,GAAG;EACjCC,OAAO,EAAE,SAAS;EAClBC,cAAc,EAAE;;MAeLC,eAAe,GAAG;EAC7BC,OAAO,EAAE;;MAGEC,UAAU,GAAG;EACxBC,QAAQ,EAAE,UAAU;EACpBC,QAAQ,EAAE;;MAGCC,mBAAmB,GAAG;EACjCJ,OAAO,EAAE,KAAK;EACdK,YAAY,EAAE,KAAK;EACnBC,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE,KAAK;EACzBC,YAAY,EAAE,KAAK;EACnBC,4BAA4B,EAAE,KAAK;EACnCC,uBAAuB,EAAE,KAAK;EAC9BC,eAAe,EAAE,KAAK;EACtBC,qBAAqB,EAAE,KAAK;EAC5BC,6BAA6B,EAAE,KAAK;EACpCf,cAAc,EAAE;;;MC3CLgB,yBAAyB,GAAGA;;E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