@washingtonpost/subs-de-inputs 1.0.0-react18.0 → 1.0.0-react18.10

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.
@@ -0,0 +1,23 @@
1
+ import { ICookieStore } from '@washingtonpost/subs-sdk';
2
+ interface TCData {
3
+ eventStatus: 'tcloaded' | 'cmpuishown' | 'useractioncomplete';
4
+ listenerId: number;
5
+ [key: string]: any;
6
+ }
7
+ type TCFAPIAddListener = (command: 'addEventListener', version: number, callback: (tcData: TCData, success: boolean) => void) => void;
8
+ type TCFAPIRmListener = (command: 'removeEventListener', version: number, callback: (success: boolean) => void, listenerId: number) => void;
9
+ type TCFAPIPing = (command: 'ping', version: number, callback: (pingReturn: any, success: boolean) => void) => void;
10
+ declare global {
11
+ interface Window {
12
+ cookieStore?: ICookieStore;
13
+ __tcfapi?: TCFAPIAddListener & TCFAPIRmListener & TCFAPIPing;
14
+ }
15
+ }
16
+ export declare const useOneTrustAlertBoxClosed: ({ allowCookieStore, }: {
17
+ allowCookieStore: boolean;
18
+ }) => {
19
+ alertBoxClosed: boolean | undefined;
20
+ listenToCookieStore: boolean;
21
+ listenToTcfApi: boolean;
22
+ };
23
+ export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ interface DisclosureProps {
3
+ /** callback function to be called when the disclosure is finished loading */
4
+ onFinished?: ({ isFinished, isError, }: {
5
+ isFinished: boolean;
6
+ isError: boolean;
7
+ }) => void;
8
+ /** ability to turn off cookiestore listener, primarily for testing purposes */
9
+ allowCookieStore?: boolean;
10
+ }
11
+ export declare const DEDisclosure: React.FC<DisclosureProps>;
12
+ export {};
@@ -0,0 +1 @@
1
+ export declare const checkCookie: () => boolean;
@@ -0,0 +1,2 @@
1
+ import { DisclosureConfigValue } from '../../../interfaces/disclosure';
2
+ export declare const getConfig: () => Promise<DisclosureConfigValue | undefined>;
@@ -0,0 +1,3 @@
1
+ type hydrateLinksType = (str: string) => string | JSX.Element;
2
+ export declare const hydrateLinks: hydrateLinksType;
3
+ export {};
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ interface IDropdownProps {
3
+ id: string;
4
+ label: string;
5
+ values: Array<string>;
6
+ required?: boolean;
7
+ defaultValue?: string;
8
+ onChange?: (value: string) => void;
9
+ disabled?: boolean;
10
+ }
11
+ /**
12
+ * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.
13
+ * @param {IDropdownProps} props The props.
14
+ * @returns {React.ReactElement} The dropdown.
15
+ */
16
+ export declare const Dropdown: ({ id, label, values, required, defaultValue, onChange, disabled, }: IDropdownProps) => React.JSX.Element;
17
+ export {};
@@ -1,15 +1,10 @@
1
1
  import React from 'react';
2
- import { SubsWindow } from '@washingtonpost/subs-sdk';
3
2
  import { Attribute, AttributeValue } from '../../interfaces';
4
- declare global {
5
- interface Window extends SubsWindow {
6
- }
7
- }
8
3
  interface DESelectProps {
9
4
  source: string;
10
5
  fieldName: string;
11
6
  label?: string;
12
- dataDictionaryConfig?: Attribute;
7
+ dataDictionaryConfig?: Attribute | Readonly<Attribute>;
13
8
  defaultValue?: string;
14
9
  disabled?: boolean;
15
10
  submit: boolean;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  export * from './interfaces/index';
2
+ export * from './interfaces/twpdeu';
2
3
  export * from './utils/hasRequiredPrivacyCookies';
3
- export * from './services/dataEnrichment';
4
+ export * from './utils/push';
5
+ export * from './services/getAttributes';
4
6
  export * from './components/DESelect';
7
+ export * from './components/DEDisclosure';
@@ -0,0 +1,8 @@
1
+ export type DisclosureConfigValue = {
2
+ disclosure: string[];
3
+ } & {
4
+ checkBannerStatus: boolean;
5
+ disclosure_beforebanner: string[];
6
+ disclosure_afterbanner: string[];
7
+ };
8
+ export type DisclosureConfig = Record<string, DisclosureConfigValue>;
@@ -13,16 +13,20 @@ export type Attribute = {
13
13
  name: string;
14
14
  approved_for_use?: boolean;
15
15
  collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];
16
- datatype: 'string';
16
+ datatype: string;
17
17
  explicit: boolean;
18
18
  multiple_value: boolean;
19
19
  last_modified_date: Number;
20
20
  date_created: Number;
21
- values: Array<AttributeValue>;
21
+ values: AttributeValue[] | Readonly<AttributeValue[]>;
22
22
  };
23
23
  export declare const AttributesState: {
24
24
  readonly SUCCESS: "100";
25
25
  };
26
+ export declare const IngestType: {
27
+ readonly EXPLICIT: "explicit";
28
+ readonly IMPLICIT: "implicit";
29
+ };
26
30
  export declare const IngestResponseState: {
27
31
  readonly SUCCESS: "100";
28
32
  readonly SYSTEM_ERROR: "101";
@@ -31,4 +35,8 @@ export declare const IngestResponseState: {
31
35
  readonly INVALID_DATA: "104";
32
36
  readonly INVALID_ATTRIBUTE_DEFINITION: "105";
33
37
  readonly INVALID_META_DEFINITION: "106";
38
+ readonly UNAUTHENTICATED: "107";
39
+ readonly MISMATCHED_IDENTIFIER: "108";
40
+ readonly DISABLED_ATTRIBUTE_DEFINITION: "109";
41
+ readonly DO_NOT_COLLECT: "110";
34
42
  };
@@ -0,0 +1,12 @@
1
+ import { getAttributes } from '../services/getAttributes';
2
+ import { push } from '../utils/push';
3
+ export type TWPDEU = {
4
+ getFieldConfigs: typeof getAttributes;
5
+ push: typeof push;
6
+ version?: string;
7
+ };
8
+ declare global {
9
+ interface Window {
10
+ __twpdeu?: TWPDEU;
11
+ }
12
+ }
@@ -0,0 +1,6 @@
1
+ import { Attribute } from '../interfaces';
2
+ export declare const getAttributes: GetAttributesType;
3
+ type GetAttributesType = ({ fieldName, }: {
4
+ fieldName: string;
5
+ }) => Promise<Attribute[]>;
6
+ export {};
@@ -0,0 +1,14 @@
1
+ import { ResponseStatus } from '@washingtonpost/subs-sdk';
2
+ import { IngestResponseState, IngestType } from '../interfaces';
3
+ export declare const ingest: IngestType;
4
+ type IngestType = ({ 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>;
14
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare const sendToGA: SendToGaType;
2
+ type SendToGaType = ({ submitData: { fieldName, value }, source, }: {
3
+ submitData: {
4
+ fieldName: string;
5
+ value: string;
6
+ };
7
+ source: string;
8
+ }) => Promise<true>;
9
+ export {};