@washingtonpost/subs-de-inputs 0.3.0 → 0.3.1-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './interfaces/index';
2
2
  export * from './interfaces/twpdeu';
3
3
  export * from './utils/hasRequiredPrivacyCookies';
4
- export * from './services/dataEnrichment';
4
+ export * from './services/getAttributes';
5
+ export * from './services/push';
5
6
  export * from './components/DESelect';
@@ -1,7 +1,8 @@
1
- import { getAttributes, ingest } from '../services/dataEnrichment';
1
+ import { getAttributes } from '../services/getAttributes';
2
+ import { push } from '../services/push';
2
3
  export declare type TWPDEU = {
3
4
  getFieldConfigs: typeof getAttributes;
4
- push: typeof ingest;
5
+ push: typeof push;
5
6
  version?: string;
6
7
  };
7
8
  declare global {
@@ -0,0 +1,6 @@
1
+ import { Attribute } from '../interfaces';
2
+ export declare const getAttributes: GetAttributesType;
3
+ declare type GetAttributesType = ({ fieldName, }: {
4
+ fieldName: string;
5
+ }) => Promise<Attribute[]>;
6
+ export {};
@@ -1,9 +1,5 @@
1
1
  import { ResponseStatus } from '@washingtonpost/subs-sdk';
2
- import { Attribute, IngestResponseState, IngestType } from '../interfaces';
3
- export declare const getAttributes: GetAttributesType;
4
- declare type GetAttributesType = ({ fieldName, }: {
5
- fieldName: string;
6
- }) => Promise<Attribute[]>;
2
+ import { IngestResponseState, IngestType } from '../interfaces';
7
3
  export declare const ingest: IngestType;
8
4
  declare type IngestType = ({ submitData: { fieldName, value }, source, }: {
9
5
  submitData: {
@@ -0,0 +1,14 @@
1
+ import { IngestResponseState } from '../interfaces';
2
+ import { ResponseStatus } from '@washingtonpost/subs-sdk';
3
+ export declare const push: PushType;
4
+ declare type PushType = ({ submitData: { fieldName, value }, source, }: {
5
+ submitData: {
6
+ fieldName: string;
7
+ value: string;
8
+ };
9
+ source: string;
10
+ }) => Promise<{
11
+ status: ResponseStatus;
12
+ state: (typeof IngestResponseState)[keyof typeof IngestResponseState];
13
+ } | null | true>;
14
+ export {};
@@ -0,0 +1,19 @@
1
+ import { IngestType } from '../interfaces';
2
+ export interface ISendGAEvent {
3
+ event: string;
4
+ category: string;
5
+ action: string;
6
+ label: string;
7
+ 'de-label': string;
8
+ [key: string]: undefined | string | string[];
9
+ }
10
+ export declare const sendToGA: SendToGaType;
11
+ declare type SendToGaType = ({ submitData: { fieldName, value }, source, }: {
12
+ submitData: {
13
+ fieldName: string;
14
+ value: string;
15
+ };
16
+ type?: (typeof IngestType)[keyof typeof IngestType];
17
+ source: string;
18
+ }) => Promise<true>;
19
+ export {};
@@ -76,7 +76,42 @@ const getAttributes = async _ref => {
76
76
  return [];
77
77
  }
78
78
  };
79
- const ingest = async _ref2 => {
79
+
80
+ const sendGAEvent = props => {
81
+ if (typeof window === 'undefined') {
82
+ if (process.env.NODE_ENV !== "production") console.warn('NO WINDOW');
83
+ return;
84
+ }
85
+ // Initialize dataLayer if needed
86
+ window.dataLayer = window.dataLayer || [];
87
+ const eventData = {
88
+ ...props
89
+ };
90
+ window.dataLayer.push(eventData);
91
+ };
92
+ const sendToGA = async _ref => {
93
+ let {
94
+ submitData: {
95
+ fieldName,
96
+ value
97
+ },
98
+ source
99
+ } = _ref;
100
+ sendGAEvent({
101
+ event: 'site-onpage-click',
102
+ action: 'site-onpage-click',
103
+ category: 'profile',
104
+ label: fieldName,
105
+ 'de-label': fieldName,
106
+ [fieldName]: value,
107
+ section: 'profile',
108
+ subsection: source
109
+ });
110
+ return true;
111
+ };
112
+
113
+ const base$1 = `${subsSdk.ENDPOINTS.base}/de/v1`;
114
+ const ingest = async _ref => {
80
115
  let {
81
116
  submitData: {
82
117
  fieldName,
@@ -84,21 +119,9 @@ const ingest = async _ref2 => {
84
119
  },
85
120
  type = IngestType.IMPLICIT,
86
121
  source
87
- } = _ref2;
88
- const url = `${base}/ingest`;
122
+ } = _ref;
123
+ const url = `${base$1}/ingest`;
89
124
  const wapo_login_id = subsSdk.getCookie('wapo_login_id');
90
- if (!hasRequiredPrivacyCookies()) {
91
- throw new Error('does not satisfy cookie check');
92
- }
93
- let attributeInfo = attributesCache[fieldName];
94
- if (!attributeInfo) {
95
- attributeInfo = await getAttributes({
96
- fieldName
97
- });
98
- }
99
- if (attributeInfo[0] && attributeInfo[0].name === fieldName && attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT) {
100
- throw new Error('do not collect');
101
- }
102
125
  const jucid = localStorage.getItem('uuid');
103
126
  const ga = subsSdk.getCookie('_ga');
104
127
  const payload = {
@@ -128,6 +151,42 @@ const ingest = async _ref2 => {
128
151
  }
129
152
  };
130
153
 
154
+ const push = async _ref => {
155
+ let {
156
+ submitData,
157
+ source
158
+ } = _ref;
159
+ if (!hasRequiredPrivacyCookies()) {
160
+ throw new Error('does not satisfy cookie check');
161
+ }
162
+ const {
163
+ fieldName
164
+ } = submitData;
165
+ const attributeInfo = await getAttributes({
166
+ fieldName
167
+ });
168
+ if (attributeInfo[0] && attributeInfo[0].name === fieldName && attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT) {
169
+ throw new Error('do not collect');
170
+ }
171
+ const type = attributeInfo[0] && attributeInfo[0].explicit === true ? IngestType.EXPLICIT : IngestType.IMPLICIT;
172
+ if (!attributeInfo[0] && process.env.NODE_ENV !== "production") {
173
+ console.warn(`no attribute info found for ${fieldName}, assuming implicit`);
174
+ }
175
+ if (type === IngestType.EXPLICIT) {
176
+ return ingest({
177
+ submitData,
178
+ type,
179
+ source
180
+ });
181
+ } else {
182
+ return sendToGA({
183
+ submitData,
184
+ type,
185
+ source
186
+ });
187
+ }
188
+ };
189
+
131
190
  const StyledMobileSelect = /*#__PURE__*/wpdsUiKit.styled('select', {
132
191
  padding: '12px 16px 12px 6px',
133
192
  display: 'flex',
@@ -303,16 +362,14 @@ const DESelect = _ref => {
303
362
  const submitSelected = async () => {
304
363
  try {
305
364
  var _window2;
306
- // TODO: Log to GA?
307
365
  const result = await ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.__twpdeu) === null || _window2 === void 0 ? void 0 : _window2.push({
308
366
  submitData: {
309
367
  fieldName,
310
368
  value: selected
311
369
  },
312
- type: config !== null && config !== void 0 && config.explicit ? IngestType.EXPLICIT : IngestType.IMPLICIT,
313
370
  source
314
371
  }));
315
- const isError = result ? result.status !== subsSdk.ResponseStatus.SUCCESS : true;
372
+ const isError = result === true ? false : result ? result.status !== subsSdk.ResponseStatus.SUCCESS : true;
316
373
  onFinished({
317
374
  isFinished: true,
318
375
  isError
@@ -385,5 +442,5 @@ exports.IngestResponseState = IngestResponseState;
385
442
  exports.IngestType = IngestType;
386
443
  exports.getAttributes = getAttributes;
387
444
  exports.hasRequiredPrivacyCookies = hasRequiredPrivacyCookies;
388
- exports.ingest = ingest;
445
+ exports.push = push;
389
446
  //# sourceMappingURL=subs-de-inputs.cjs.development.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subs-de-inputs.cjs.development.js","sources":["../src/interfaces/index.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/dataEnrichment.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 getCookie,\n} from '@washingtonpost/subs-sdk';\nimport {\n Attribute,\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { hasRequiredPrivacyCookies } from '../utils/hasRequiredPrivacyCookies';\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\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n type = IngestType.IMPLICIT,\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n let attributeInfo = attributesCache[fieldName];\n if (!attributeInfo) {\n attributeInfo = await getAttributes({ 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 jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type,\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 type?: (typeof IngestType)[keyof typeof IngestType];\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, IngestType } 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 // TODO: Log to GA?\n\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n type: config?.explicit ? IngestType.EXPLICIT : IngestType.IMPLICIT,\n source,\n });\n\n const isError = 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","ingest","_ref2","submitData","value","type","source","wapo_login_id","Error","attributeInfo","name","collection_behavior","jucid","localStorage","getItem","ga","payload","metadata","response","method","body","JSON","stringify","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","label","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","warn","ScriptStatus","READY","submitSelected","_window2","result","push","explicit","isError","isFinished","isLoading","sort","a","b","order","filter","archived","Sel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;IAEb,EACA,CAAC2D,QAAQ,IAAIC,MAAM,IAClBlC,6BAACjB,QAAQ;IACPC,EAAE,EAAEkD,MAAM,CAAC9F,IAAI;IACf6C,KAAK,EAAEA,KAAK,IAAIiD,MAAM,CAAC9F,IAAI;IAC3BiD,QAAQ,EAAG7D,CAAC;MACV4G,WAAW,CAAC5G,CAAC,CAAC;MACd6D,QAAQ,CAAC;QAAEvD,KAAK,EAAEN;OAAG,CAAC;KACvB;IACD0D,MAAM,EAAEA,MAAM,CAACkB,GAAG,CAAEtE,KAAK,IAAKA,KAAK,CAACM,IAAI,CAAC;IACzCgD,YAAY,EAAEA,YAAY;IAC1Bd,QAAQ,EAAEA;IAEb,CACa;AAEpB,CAAC;AAED,MAAMuF,aAAa,gBAAG3G,gBAAM,CAAC,KAAK,EAAE;EAClC4G,SAAS,EAAE,YAAY;EACvB1G,OAAO,EAAE,MAAM;EACf2G,YAAY,EAAE,MAAM;EACpBC,aAAa,EAAE,QAAQ;EACvB,UAAU,EAAE;IACV7G,OAAO,EAAE;GACV;EACD,KAAK,EAAE;IAAE2G,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/services/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","import { IngestType } from '../interfaces';\n\nexport interface ISendGAEvent {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}\n\nconst sendGAEvent = (props: ISendGAEvent): 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 type?: (typeof IngestType)[keyof typeof IngestType];\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 type = IngestType.IMPLICIT,\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,\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 type?: (typeof IngestType)[keyof typeof IngestType];\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 './getAttributes';\nimport { sendToGA } from './sendToGA';\nimport { hasRequiredPrivacyCookies } from '../utils/hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from './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, type, source });\n } else {\n return sendToGA({ submitData, type, 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","type","wapo_login_id","jucid","localStorage","getItem","ga","payload","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,CA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CAAC;MACf2H,WAAW,CAAC3H,CAAC,CAAC;MACd4E,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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@washingtonpost/subs-sdk"),o=require("react"),a=(e=o)&&"object"==typeof e&&"default"in e?e.default:e,i=require("@washingtonpost/wpds-ui-kit"),s=require("@washingtonpost/subs-hooks"),l=require("@washingtonpost/wpds-assets");const r={COLLECT:"COLLECT",DO_NOT_COLLECT:"DO_NOT_COLLECT"},n={EXPLICIT:"explicit",IMPLICIT:"implicit"},d=()=>{var e;if("undefined"==typeof window)return!1;const o=t.getCookie("wp_usp"),a=null===(e=t.WPGeo())||void 0===e?void 0:e.country_code;return!(!o||"US"!==a)},c=t.ENDPOINTS.base+"/de/v1",u={},p=async e=>{let{fieldName:o}=e;if(u[o])return u[o];const a=[o];try{const e=new URL(c+"/attributes");e.searchParams.set("attributes",a.join(","));const i=await fetch(e.toString(),{credentials:"include",headers:t.JSON_HEADERS}),s=await i.json();if(i.ok&&s.status===t.ResponseStatus.SUCCESS){const e=s.attributes||[];return u[o]=e,e}return[]}catch(e){return console.debug(e),[]}},b=i.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:i.theme.colors.disabled,borderColor:i.theme.colors.disabled,color:i.theme.colors.onDisabled,cursor:"not-allowed"}}),E=i.styled("div",{width:"100%",maxWidth:"380px",borderRadius:"$012",borderColor:"$subtle",borderStyle:"solid",borderWidth:"1px",backgroundColor:"$secondary",position:"relative"}),g=i.styled("option",{fontFamily:"inherit",fontSize:"inherit",color:"inherit"}),h=e=>{let{id:t,label:r,values:n,required:d=!1,defaultValue:c,onChange:u=(()=>{}),disabled:p=!1}=e;const[h,m]=o.useState(),{isMobileSize:S}=s.useWindowSize();o.useEffect(()=>{h&&u(h)},[h]);const I=p?{disabled:!0}:{},f=h?{defaultValue:h}:c?{defaultValue:c}:{},C=e=>h?e===h?{selected:!0}:{}:e===c?{selected:!0}:{};return S?a.createElement(E,null,a.createElement(b,{id:"",required:d,onChange:e=>m(e.target.value),placeholder:r,...I},a.createElement("label",null,r),a.createElement(g,{value:"",disabled:!0,selected:!0,style:{color:"#666666"}},r),n.map(e=>a.createElement(g,{value:e,key:e,...C(e)},e))),a.createElement(i.Icon,{label:"",size:"100",fill:i.theme.colors.gray80,style:{pointerEvents:"none",position:"absolute",right:"10px",top:"50%",transform:"translateY(-50%)"}},a.createElement(l.ChevronDown,{style:{position:"absolute",right:"10px"}}))):a.createElement(i.Select.Root,{onValueChange:e=>m(e),required:d,...f,...I},a.createElement(i.Select.Trigger,{"data-test-id":t+"-select-trigger"},a.createElement(i.Select.Label,null,r),a.createElement(i.Select.Value,null)),a.createElement(i.Select.Content,{css:{zIndex:i.theme.zIndices.page},"data-test-id":t+"-select-content"},n.map(e=>a.createElement(i.Select.Item,{value:e,key:e},e))))},m=("https://subscribe.washingtonpost.com/static"===t.ENDPOINTS.staticAssets?"https://www.washingtonpost.com/subscribe/static/":t.ENDPOINTS.staticAssets)+"/de-utils/twpdeu.min.js",S=i.styled("div",{boxSizing:"border-box",display:"flex",marginBottom:"$100",flexDirection:"column","& button":{padding:"1px 6px"},"& *":{boxSizing:"border-box"}});exports.AttributesState={SUCCESS:"100"},exports.CollectionBehaviors=r,exports.DESelect=e=>{let{source:l,fieldName:r,label:d,dataDictionaryConfig:c,defaultValue:u,disabled:p,submit:b,onChange:E=(()=>{}),onFinished:g=(()=>{}),valuesFilter:I=(()=>!0),children:f}=e;const[C,w]=o.useState(c),[y,T]=o.useState(""),v=s.useScript(m);o.useEffect(()=>{v!==s.ScriptStatus.READY||f||C||(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?w(t[0]):console.error("unable to get config",r)}catch(e){console.warn("unable to get config",r,e)}})()},[v]),o.useEffect(()=>{v===s.ScriptStatus.READY&&b&&y&&(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:y},type:null!=C&&C.explicit?n.EXPLICIT:n.IMPLICIT,source:l}));g({isFinished:!0,isError:!o||o.status!==t.ResponseStatus.SUCCESS})}catch(e){g({isFinished:!1,isError:!0})}})()},[v,b]);const _=u&&C?{defaultValue:u}:{},N=p||!f&&!C?{disabled:!0}:{},D=C?C.values.sort((e,t)=>e.order-t.order).filter(e=>!0!==e.archived).filter(I):[];return a.createElement(S,null,f&&a.createElement(i.Select.Root,{onValueChange:e=>{T(e),E({value:e})},..._,...N},f),!f&&!C&&a.createElement(h,{id:"loading",label:"Loading...",values:[],disabled:!0}),!f&&C&&a.createElement(h,{id:C.name,label:d||C.name,onChange:e=>{T(e),E({value:e})},values:D.map(e=>e.name),defaultValue:u,disabled:p}))},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=n,exports.getAttributes=p,exports.hasRequiredPrivacyCookies=d,exports.ingest=async e=>{let{submitData:{fieldName:o,value:a},type:i=n.IMPLICIT,source:s}=e;const l=c+"/ingest",b=t.getCookie("wapo_login_id");if(!d())throw new Error("does not satisfy cookie check");let E=u[o];if(E||(E=await p({fieldName:o})),E[0]&&E[0].name===o&&E[0].collection_behavior===r.DO_NOT_COLLECT)throw new Error("do not collect");const g={jucid:localStorage.getItem("uuid"),ga:t.getCookie("_ga"),type:i,wapo_login_id:b,data:{[o]:[a]},metadata:{source:s}};try{const e=await fetch(l,{method:"POST",credentials:"include",headers:t.JSON_HEADERS,body:JSON.stringify(g)});return await e.json()}catch(e){return console.debug(e),null}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@washingtonpost/subs-sdk"),o=require("react"),a=(e=o)&&"object"==typeof e&&"default"in e?e.default:e,i=require("@washingtonpost/wpds-ui-kit"),s=require("@washingtonpost/subs-hooks"),n=require("@washingtonpost/wpds-assets");const r={COLLECT:"COLLECT",DO_NOT_COLLECT:"DO_NOT_COLLECT"},l={EXPLICIT:"explicit",IMPLICIT:"implicit"},d=()=>{var e;if("undefined"==typeof window)return!1;const o=t.getCookie("wp_usp"),a=null===(e=t.WPGeo())||void 0===e?void 0:e.country_code;return!(!o||"US"!==a)},c=t.ENDPOINTS.base+"/de/v1",u={},p=async e=>{let{fieldName:o}=e;if(u[o])return u[o];const a=[o];try{const e=new URL(c+"/attributes");e.searchParams.set("attributes",a.join(","));const i=await fetch(e.toString(),{credentials:"include",headers:t.JSON_HEADERS}),s=await i.json();if(i.ok&&s.status===t.ResponseStatus.SUCCESS){const e=s.attributes||[];return u[o]=e,e}return[]}catch(e){return console.debug(e),[]}},b=t.ENDPOINTS.base+"/de/v1",E=i.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:i.theme.colors.disabled,borderColor:i.theme.colors.disabled,color:i.theme.colors.onDisabled,cursor:"not-allowed"}}),g=i.styled("div",{width:"100%",maxWidth:"380px",borderRadius:"$012",borderColor:"$subtle",borderStyle:"solid",borderWidth:"1px",backgroundColor:"$secondary",position:"relative"}),m=i.styled("option",{fontFamily:"inherit",fontSize:"inherit",color:"inherit"}),h=e=>{let{id:t,label:r,values:l,required:d=!1,defaultValue:c,onChange:u=(()=>{}),disabled:p=!1}=e;const[b,h]=o.useState(),{isMobileSize:f}=s.useWindowSize();o.useEffect(()=>{b&&u(b)},[b]);const I=p?{disabled:!0}:{},S=b?{defaultValue:b}:c?{defaultValue:c}:{},w=e=>b?e===b?{selected:!0}:{}:e===c?{selected:!0}:{};return f?a.createElement(g,null,a.createElement(E,{id:"",required:d,onChange:e=>h(e.target.value),placeholder:r,...I},a.createElement("label",null,r),a.createElement(m,{value:"",disabled:!0,selected:!0,style:{color:"#666666"}},r),l.map(e=>a.createElement(m,{value:e,key:e,...w(e)},e))),a.createElement(i.Icon,{label:"",size:"100",fill:i.theme.colors.gray80,style:{pointerEvents:"none",position:"absolute",right:"10px",top:"50%",transform:"translateY(-50%)"}},a.createElement(n.ChevronDown,{style:{position:"absolute",right:"10px"}}))):a.createElement(i.Select.Root,{onValueChange:e=>h(e),required:d,...S,...I},a.createElement(i.Select.Trigger,{"data-test-id":t+"-select-trigger"},a.createElement(i.Select.Label,null,r),a.createElement(i.Select.Value,null)),a.createElement(i.Select.Content,{css:{zIndex:i.theme.zIndices.page},"data-test-id":t+"-select-content"},l.map(e=>a.createElement(i.Select.Item,{value:e,key:e},e))))},f=("https://subscribe.washingtonpost.com/static"===t.ENDPOINTS.staticAssets?"https://www.washingtonpost.com/subscribe/static/":t.ENDPOINTS.staticAssets)+"/de-utils/twpdeu.min.js",I=i.styled("div",{boxSizing:"border-box",display:"flex",marginBottom:"$100",flexDirection:"column","& button":{padding:"1px 6px"},"& *":{boxSizing:"border-box"}});exports.AttributesState={SUCCESS:"100"},exports.CollectionBehaviors=r,exports.DESelect=e=>{let{source:n,fieldName:r,label:l,dataDictionaryConfig:d,defaultValue:c,disabled:u,submit:p,onChange:b=(()=>{}),onFinished:E=(()=>{}),valuesFilter:g=(()=>!0),children:m}=e;const[S,w]=o.useState(d),[C,y]=o.useState(""),v=s.useScript(f);o.useEffect(()=>{v!==s.ScriptStatus.READY||m||S||(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?w(t[0]):console.error("unable to get config",r)}catch(e){console.warn("unable to get config",r,e)}})()},[v]),o.useEffect(()=>{v===s.ScriptStatus.READY&&p&&C&&(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:C},source:n}));E({isFinished:!0,isError:!0!==o&&(!o||o.status!==t.ResponseStatus.SUCCESS)})}catch(e){E({isFinished:!1,isError:!0})}})()},[v,p]);const N=c&&S?{defaultValue:c}:{},T=u||!m&&!S?{disabled:!0}:{},D=S?S.values.sort((e,t)=>e.order-t.order).filter(e=>!0!==e.archived).filter(g):[];return a.createElement(I,null,m&&a.createElement(i.Select.Root,{onValueChange:e=>{y(e),b({value:e})},...N,...T},m),!m&&!S&&a.createElement(h,{id:"loading",label:"Loading...",values:[],disabled:!0}),!m&&S&&a.createElement(h,{id:S.name,label:l||S.name,onChange:e=>{y(e),b({value:e})},values:D.map(e=>e.name),defaultValue:c,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=d,exports.push=async e=>{let{submitData:o,source:a}=e;if(!d())throw new Error("does not satisfy cookie check");const{fieldName:i}=o,s=await p({fieldName:i});if(s[0]&&s[0].name===i&&s[0].collection_behavior===r.DO_NOT_COLLECT)throw new Error("do not collect");const n=s[0]&&!0===s[0].explicit?l.EXPLICIT:l.IMPLICIT;return s[0]||"production"===process.env.NODE_ENV||console.warn(`no attribute info found for ${i}, assuming implicit`),n===l.EXPLICIT?(async e=>{let{submitData:{fieldName:o,value:a},type:i=l.IMPLICIT,source:s}=e;const n=b+"/ingest",r=t.getCookie("wapo_login_id"),d={jucid:localStorage.getItem("uuid"),ga:t.getCookie("_ga"),type:i,wapo_login_id:r,data:{[o]:[a]},metadata:{source:s}};try{const e=await fetch(n,{method:"POST",credentials:"include",headers:t.JSON_HEADERS,body:JSON.stringify(d)});return await e.json()}catch(e){return console.debug(e),null}})({submitData:o,type:n,source:a}):(async e=>{let{submitData:{fieldName:t,value:o},source:a}=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:a}),!0})({submitData:o,type:n,source:a})};
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/dataEnrichment.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 getCookie,\n} from '@washingtonpost/subs-sdk';\nimport {\n Attribute,\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { hasRequiredPrivacyCookies } from '../utils/hasRequiredPrivacyCookies';\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\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n type = IngestType.IMPLICIT,\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n let attributeInfo = attributesCache[fieldName];\n if (!attributeInfo) {\n attributeInfo = await getAttributes({ 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 jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type,\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 type?: (typeof IngestType)[keyof typeof IngestType];\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, IngestType } 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 // TODO: Log to GA?\n\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n type: config?.explicit ? IngestType.EXPLICIT : IngestType.IMPLICIT,\n source,\n });\n\n const isError = 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","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","type","explicit","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","_ref2","wapo_login_id","Error","attributeInfo","collection_behavior","payload","jucid","localStorage","getItem","ga","[object Object]","metadata","response","method","body","JSON","stringify"],"mappings":"0TAQaA,EAAsB,CACjCC,QAAS,UACTC,eAAgB,kBAmBLC,EAAa,CACxBC,SAAU,WACVC,SAAU,YC7BCC,EAA4BA,WACvC,GAAsB,oBAAXC,OACT,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EAAgBG,GAKpC,GAJK0J,IACHA,QAAsB5J,EAAc,CAAEE,UAAAA,KAItC0J,EAAc,IACdA,EAAc,GAAGb,OAAS7I,GAC1B0J,EAAc,GAAGC,sBAAwB9K,EAAoBE,eAE7D,MAAM,IAAI0K,MAAM,kBAGlB,MAGMG,EAAU,CACdC,MAJYC,aAAaC,QAAQ,QAKjCC,GAJS1K,YAAU,OAKnB4I,KAAAA,EACAsB,cAAAA,EACAhJ,KAAM,CACJyJ,CAACjK,GAAY,CAACuE,IAEhB2F,SAAU,CAAEvD,OAAAA,IAGd,IACE,MAAMwD,QAAiB1J,MAAMN,EAAK,CAChCiK,OAAQ,OACRzJ,YAAa,UACbC,QAASC,eACTwJ,KAAMC,KAAKC,UAAUX,KAKvB,aAFmBO,EAASrJ,OAG5B,MAAOM,GAEP,OADAC,QAAQC,MAAMF,GACP"}
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/services/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 type = IngestType.IMPLICIT,\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,\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 type?: (typeof IngestType)[keyof typeof IngestType];\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 './getAttributes';\nimport { sendToGA } from './sendToGA';\nimport { hasRequiredPrivacyCookies } from '../utils/hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from './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, type, source });\n } else {\n return sendToGA({ submitData, type, 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 { IngestType } from '../interfaces';\n\nexport interface ISendGAEvent {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}\n\nconst sendGAEvent = (props: ISendGAEvent): 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 type?: (typeof IngestType)[keyof typeof IngestType];\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,MAAO,GAET,MAAOC,GAEP,OADAC,QAAQC,MAAMF,GACP,KChCLzB,EAAUC,YAAUD,cCOpB4B,EAAqBC,SAAO,SAAU,CAC1CC,QAAS,qBACTC,QAAS,OACTC,eAAgB,gBAChBC,MAAO,OACPC,gBAAiB,aACjBC,MAAO,WACPC,WAAY,QACZC,SAAU,OACVC,WAAY,SACZC,WAAY,OACZC,kBAAmB,OACnBC,aAAc,WACdC,SAAU,WACVC,YAAa,cACbC,iBAAkB,OAClBC,iBAAkB,cAClBC,WAAY,OACZC,qBAAsB,OACtBC,aAAc,CACZd,gBAAiBe,QAAMC,OAAOC,SAC9BR,YAAaM,QAAMC,OAAOC,SAC1BhB,MAAOc,QAAMC,OAAOE,WACp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AELvL,OAAOwL,UAAU5C,KAAK6C,IAOtBC,CAAY,CACVC,MAAO,oBACPC,OAAQ,oBACRC,SAAU,UAEVxH,MAAOzD,EACPkL,WAAYlL,EACZmK,CAACnK,GAAYuE,EAEb4G,QAAS,UACTC,WAAYzE,KAGP,GDAE0E,CAAS,CAAEpD,WAAAA,EAAYuB,KAAAA,EAAM7C,OAAAA"}
@@ -69,7 +69,42 @@ const getAttributes = async _ref => {
69
69
  return [];
70
70
  }
71
71
  };
72
- const ingest = async _ref2 => {
72
+
73
+ const sendGAEvent = props => {
74
+ if (typeof window === 'undefined') {
75
+ if (process.env.NODE_ENV !== "production") console.warn('NO WINDOW');
76
+ return;
77
+ }
78
+ // Initialize dataLayer if needed
79
+ window.dataLayer = window.dataLayer || [];
80
+ const eventData = {
81
+ ...props
82
+ };
83
+ window.dataLayer.push(eventData);
84
+ };
85
+ const sendToGA = async _ref => {
86
+ let {
87
+ submitData: {
88
+ fieldName,
89
+ value
90
+ },
91
+ source
92
+ } = _ref;
93
+ sendGAEvent({
94
+ event: 'site-onpage-click',
95
+ action: 'site-onpage-click',
96
+ category: 'profile',
97
+ label: fieldName,
98
+ 'de-label': fieldName,
99
+ [fieldName]: value,
100
+ section: 'profile',
101
+ subsection: source
102
+ });
103
+ return true;
104
+ };
105
+
106
+ const base$1 = `${ENDPOINTS.base}/de/v1`;
107
+ const ingest = async _ref => {
73
108
  let {
74
109
  submitData: {
75
110
  fieldName,
@@ -77,21 +112,9 @@ const ingest = async _ref2 => {
77
112
  },
78
113
  type = IngestType.IMPLICIT,
79
114
  source
80
- } = _ref2;
81
- const url = `${base}/ingest`;
115
+ } = _ref;
116
+ const url = `${base$1}/ingest`;
82
117
  const wapo_login_id = getCookie('wapo_login_id');
83
- if (!hasRequiredPrivacyCookies()) {
84
- throw new Error('does not satisfy cookie check');
85
- }
86
- let attributeInfo = attributesCache[fieldName];
87
- if (!attributeInfo) {
88
- attributeInfo = await getAttributes({
89
- fieldName
90
- });
91
- }
92
- if (attributeInfo[0] && attributeInfo[0].name === fieldName && attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT) {
93
- throw new Error('do not collect');
94
- }
95
118
  const jucid = localStorage.getItem('uuid');
96
119
  const ga = getCookie('_ga');
97
120
  const payload = {
@@ -121,6 +144,42 @@ const ingest = async _ref2 => {
121
144
  }
122
145
  };
123
146
 
147
+ const push = async _ref => {
148
+ let {
149
+ submitData,
150
+ source
151
+ } = _ref;
152
+ if (!hasRequiredPrivacyCookies()) {
153
+ throw new Error('does not satisfy cookie check');
154
+ }
155
+ const {
156
+ fieldName
157
+ } = submitData;
158
+ const attributeInfo = await getAttributes({
159
+ fieldName
160
+ });
161
+ if (attributeInfo[0] && attributeInfo[0].name === fieldName && attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT) {
162
+ throw new Error('do not collect');
163
+ }
164
+ const type = attributeInfo[0] && attributeInfo[0].explicit === true ? IngestType.EXPLICIT : IngestType.IMPLICIT;
165
+ if (!attributeInfo[0] && process.env.NODE_ENV !== "production") {
166
+ console.warn(`no attribute info found for ${fieldName}, assuming implicit`);
167
+ }
168
+ if (type === IngestType.EXPLICIT) {
169
+ return ingest({
170
+ submitData,
171
+ type,
172
+ source
173
+ });
174
+ } else {
175
+ return sendToGA({
176
+ submitData,
177
+ type,
178
+ source
179
+ });
180
+ }
181
+ };
182
+
124
183
  const StyledMobileSelect = /*#__PURE__*/styled('select', {
125
184
  padding: '12px 16px 12px 6px',
126
185
  display: 'flex',
@@ -296,16 +355,14 @@ const DESelect = _ref => {
296
355
  const submitSelected = async () => {
297
356
  try {
298
357
  var _window2;
299
- // TODO: Log to GA?
300
358
  const result = await ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.__twpdeu) === null || _window2 === void 0 ? void 0 : _window2.push({
301
359
  submitData: {
302
360
  fieldName,
303
361
  value: selected
304
362
  },
305
- type: config !== null && config !== void 0 && config.explicit ? IngestType.EXPLICIT : IngestType.IMPLICIT,
306
363
  source
307
364
  }));
308
- const isError = result ? result.status !== ResponseStatus.SUCCESS : true;
365
+ const isError = result === true ? false : result ? result.status !== ResponseStatus.SUCCESS : true;
309
366
  onFinished({
310
367
  isFinished: true,
311
368
  isError
@@ -371,5 +428,5 @@ const SelectWrapper = /*#__PURE__*/styled('div', {
371
428
  }
372
429
  });
373
430
 
374
- export { AttributesState, CollectionBehaviors, DESelect, IngestResponseState, IngestType, getAttributes, hasRequiredPrivacyCookies, ingest };
431
+ export { AttributesState, CollectionBehaviors, DESelect, IngestResponseState, IngestType, getAttributes, hasRequiredPrivacyCookies, push };
375
432
  //# 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/dataEnrichment.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 getCookie,\n} from '@washingtonpost/subs-sdk';\nimport {\n Attribute,\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { hasRequiredPrivacyCookies } from '../utils/hasRequiredPrivacyCookies';\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\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n type = IngestType.IMPLICIT,\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n let attributeInfo = attributesCache[fieldName];\n if (!attributeInfo) {\n attributeInfo = await getAttributes({ 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 jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type,\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 type?: (typeof IngestType)[keyof typeof IngestType];\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, IngestType } 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 // TODO: Log to GA?\n\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n type: config?.explicit ? IngestType.EXPLICIT : IngestType.IMPLICIT,\n source,\n });\n\n const isError = 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","ingest","_ref2","submitData","value","type","source","wapo_login_id","Error","attributeInfo","name","collection_behavior","jucid","localStorage","getItem","ga","payload","metadata","response","method","body","JSON","stringify","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","label","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","warn","ScriptStatus","READY","submitSelected","_window2","result","push","explicit","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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V4G,WAAW,CAAC5G,CAAC,CAAC;MACd6D,QAAQ,CAAC;QAAEvD,KAAK,EAAEN;OAAG,CAAC;KACvB;IACD0D,MAAM,EAAEA,MAAM,CAACkB,GAAG,CAAEtE,KAAK,IAAKA,KAAK,CAACM,IAAI,CAAC;IACzCgD,YAAY,EAAEA,YAAY;IAC1Bd,QAAQ,EAAEA;IAEb,CACa;AAEpB,CAAC;AAED,MAAMuF,aAAa,gBAAG3G,MAAM,CAAC,KAAK,EAAE;EAClC4G,SAAS,EAAE,YAAY;EACvB1G,OAAO,EAAE,MAAM;EACf2G,YAAY,EAAE,MAAM;EACpBC,aAAa,EAAE,QAAQ;EACvB,UAAU,EAAE;IACV7G,OAAO,EAAE;GACV;EACD,KAAK,EAAE;IAAE2G,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/services/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","import { IngestType } from '../interfaces';\n\nexport interface ISendGAEvent {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}\n\nconst sendGAEvent = (props: ISendGAEvent): 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 type?: (typeof IngestType)[keyof typeof IngestType];\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 type = IngestType.IMPLICIT,\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,\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 type?: (typeof IngestType)[keyof typeof IngestType];\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 './getAttributes';\nimport { sendToGA } from './sendToGA';\nimport { hasRequiredPrivacyCookies } from '../utils/hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from './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, type, source });\n } else {\n return sendToGA({ submitData, type, 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","type","wapo_login_id","jucid","localStorage","getItem","ga","payload","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","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E,YAAY;IACnBsD,MAAM,EAAE,EAAE;IACVX,QAAQ,EAAE;IAEb,EACA,CAAC0D,QAAQ,IAAIC,MAAM,IAClBlC,oBAAChB,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,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;;;;"}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.0",
2
+ "version": "0.3.1-canary.1",
3
3
  "license": "UNLICENSED",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -42,7 +42,7 @@
42
42
  "name": "de-inputs: DESelect",
43
43
  "path": "dist/subs-de-inputs.esm.js",
44
44
  "import": "{ DESelect }",
45
- "limit": "2 KB"
45
+ "limit": "2.5 KB"
46
46
  }
47
47
  ],
48
48
  "devDependencies": {
package/CHANGELOG.md DELETED
@@ -1,34 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file. See
4
- [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- **[0.3.0 - 2024-05-06]**:
7
- * Uses the native `<select />` element in smaller viewport sizes for better UX
8
-
9
- **[0.2.2 - 2024-05-03]**:
10
- * use `window.__twpdeu.push()` for submitting
11
- * Better loading state when fetching config over the wire
12
- * Prevent extra calls to `ingest` API if user changes value after clicking submit
13
- * Fix `ingest()` function to send the right format (again)
14
-
15
- **[0.2.1 - 2024-05-02]**:
16
- * Revert "ESM build only"
17
- * `ingest()` function throws error if `submitData.value` is not an array (required by BE)
18
-
19
- **[0.2.0 - 2024-05-01]**:
20
- * Adds `ingest()` function
21
- * ESM build only
22
- * Babel config to target recent browsers only
23
-
24
- **[0.1.1 - 2024-04-30]**:
25
- * Fix build by removing unused file
26
-
27
- **[0.1.0 - 2024-04-25]**:
28
- * Add initial `<DESelect />` component
29
-
30
- **[0.0.2 - 2024-04-24]**:
31
- * Fix build error
32
-
33
- **[0.0.1 - 2024-04-09]**:
34
- * Initial setup