@washingtonpost/subs-de-inputs 0.0.1 → 0.0.2
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/CHANGELOG.md +10 -0
- package/dist/components/DEDataSelectProps/index.d.ts +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/interfaces/index.d.ts +28 -61
- package/dist/services/dataEnrichment.d.ts +2 -3
- package/dist/subs-de-inputs.cjs.development.js +67 -436
- package/dist/subs-de-inputs.cjs.development.js.map +1 -1
- package/dist/subs-de-inputs.cjs.production.min.js +1 -1
- package/dist/subs-de-inputs.cjs.production.min.js.map +1 -1
- package/dist/subs-de-inputs.esm.js +65 -435
- package/dist/subs-de-inputs.esm.js.map +1 -1
- package/dist/utils/getDefaultSubmitData.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/DataEnrichmentForm/index.d.ts +0 -2
- package/dist/components/Dropdown/index.d.ts +0 -11
- package/dist/services/sendToGA.d.ts +0 -12
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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.0.2 - 2024-04-24]**:
|
|
7
|
+
* Fix build error
|
|
8
|
+
|
|
9
|
+
**[0.0.1 - 2024-04-09]**:
|
|
10
|
+
* Initial setup
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,64 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare enum I1pIngestDataTypes {
|
|
6
|
-
JOB_LEVEL = "profile_job_level",
|
|
7
|
-
JOB_INDUSTRY = "profile_job_industry",
|
|
8
|
-
NY_PERSONAL_GOALS = "new_year_personal_goals",
|
|
9
|
-
NY_HOBBIES = "new_year_hobbies",
|
|
10
|
-
NY_PROFESSIONAL_GOALS = "new_year_professional_goals",
|
|
11
|
-
NY_INDUSTRY = "new_year_industry",
|
|
12
|
-
NY_NEWS_LOCATION = "new_year_news_location"
|
|
13
|
-
}
|
|
14
|
-
export interface I1pDataInputValue {
|
|
1
|
+
export declare type AttributeValue = {
|
|
2
|
+
name: string;
|
|
3
|
+
date_created: Number;
|
|
4
|
+
last_modified_date: Number;
|
|
15
5
|
archived: boolean;
|
|
6
|
+
order: Number;
|
|
7
|
+
};
|
|
8
|
+
export declare const CollectionBehaviors: {
|
|
9
|
+
readonly COLLECT: "COLLECT";
|
|
10
|
+
readonly DO_NOT_COLLECT: "DO_NOT_COLLECT";
|
|
11
|
+
};
|
|
12
|
+
export declare type Attribute = {
|
|
16
13
|
name: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
EXPLICIT = "explicit",
|
|
35
|
-
IMPLICIT = "implicit"
|
|
36
|
-
}
|
|
37
|
-
export interface I1pDataFormProps {
|
|
38
|
-
source: string;
|
|
39
|
-
submit?: boolean;
|
|
40
|
-
ingestType: I1pDataIngestTypes;
|
|
41
|
-
onChange?: (submitData: I1pDataFormSubmitData, requiredFieldsReady: boolean) => void;
|
|
42
|
-
onFinished?: (isFinished: boolean, isError: boolean) => void;
|
|
43
|
-
formOptions?: Array<I1pDataInputProps>;
|
|
44
|
-
handleSubmit?: FormEventHandler<HTMLFormElement>;
|
|
45
|
-
disabled?: boolean;
|
|
46
|
-
}
|
|
47
|
-
export declare type I1pIngestPropsData = {
|
|
48
|
-
[key in I1pIngestDataTypes]?: string[];
|
|
14
|
+
approved_for_use: boolean;
|
|
15
|
+
collection_behavior: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];
|
|
16
|
+
datatype: 'string';
|
|
17
|
+
explicit: boolean;
|
|
18
|
+
multiple_value: boolean;
|
|
19
|
+
last_modified_date: Number;
|
|
20
|
+
date_created: Number;
|
|
21
|
+
values: Array<any>;
|
|
22
|
+
};
|
|
23
|
+
export declare const IngestResponseState: {
|
|
24
|
+
readonly SUCCESS: "100";
|
|
25
|
+
readonly SYSTEM_ERROR: "101";
|
|
26
|
+
readonly INVALID_TYPE: "102";
|
|
27
|
+
readonly INVALID_IDENTIFIER: "103";
|
|
28
|
+
readonly INVALID_DATA: "104";
|
|
29
|
+
readonly INVALID_ATTRIBUTE_DEFINITION: "105";
|
|
30
|
+
readonly INVALID_META_DEFINITION: "106";
|
|
49
31
|
};
|
|
50
|
-
export interface I1pIngestProps {
|
|
51
|
-
type: 'implicit' | 'explicit';
|
|
52
|
-
data: I1pIngestPropsData;
|
|
53
|
-
metadata?: Record<string, string | null | undefined>;
|
|
54
|
-
[key: string]: any;
|
|
55
|
-
}
|
|
56
|
-
export declare enum IngestResponseState {
|
|
57
|
-
SUCCESS = "100",
|
|
58
|
-
SYSTEM_ERROR = "101",
|
|
59
|
-
INVALID_TYPE = "102",
|
|
60
|
-
INVALID_IDENTIFIER = "103",
|
|
61
|
-
INVALID_DATA = "104",
|
|
62
|
-
INVALID_ATTRIBUTE_DEFINITION = "105",
|
|
63
|
-
INVALID_META_DEFINITION = "106"
|
|
64
|
-
}
|
|
@@ -2,15 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var React__default = _interopDefault(React);
|
|
9
|
-
var wpdsUiKit = require('@washingtonpost/wpds-ui-kit');
|
|
10
|
-
var subsHooks = require('@washingtonpost/subs-hooks');
|
|
11
|
-
var wpdsAssets = require('@washingtonpost/wpds-assets');
|
|
12
5
|
var subsSdk = require('@washingtonpost/subs-sdk');
|
|
13
6
|
|
|
7
|
+
var CollectionBehaviors = {
|
|
8
|
+
COLLECT: 'COLLECT',
|
|
9
|
+
DO_NOT_COLLECT: 'DO_NOT_COLLECT'
|
|
10
|
+
};
|
|
11
|
+
var IngestResponseState = {
|
|
12
|
+
SUCCESS: '100',
|
|
13
|
+
SYSTEM_ERROR: '101',
|
|
14
|
+
INVALID_TYPE: '102',
|
|
15
|
+
INVALID_IDENTIFIER: '103',
|
|
16
|
+
INVALID_DATA: '104',
|
|
17
|
+
INVALID_ATTRIBUTE_DEFINITION: '105',
|
|
18
|
+
INVALID_META_DEFINITION: '106'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var hasRequiredPrivacyCookies = function hasRequiredPrivacyCookies() {
|
|
22
|
+
var _WPGeo;
|
|
23
|
+
if (typeof window === 'undefined') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
var wp_usp = subsSdk.getCookie('wp_usp');
|
|
27
|
+
var countryCode = (_WPGeo = subsSdk.WPGeo()) == null ? void 0 : _WPGeo.country_code;
|
|
28
|
+
return !!(wp_usp && countryCode === 'US');
|
|
29
|
+
};
|
|
30
|
+
|
|
14
31
|
function _regeneratorRuntime() {
|
|
15
32
|
_regeneratorRuntime = function () {
|
|
16
33
|
return exports;
|
|
@@ -342,457 +359,71 @@ function _asyncToGenerator(fn) {
|
|
|
342
359
|
});
|
|
343
360
|
};
|
|
344
361
|
}
|
|
345
|
-
function _extends() {
|
|
346
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
347
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
348
|
-
var source = arguments[i];
|
|
349
|
-
for (var key in source) {
|
|
350
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
351
|
-
target[key] = source[key];
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return target;
|
|
356
|
-
};
|
|
357
|
-
return _extends.apply(this, arguments);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
(function (I1pDataInputTypes) {
|
|
361
|
-
I1pDataInputTypes["DROPDOWN"] = "dropdown";
|
|
362
|
-
})(exports.I1pDataInputTypes || (exports.I1pDataInputTypes = {}));
|
|
363
|
-
(function (I1pIngestDataTypes) {
|
|
364
|
-
I1pIngestDataTypes["JOB_LEVEL"] = "profile_job_level";
|
|
365
|
-
I1pIngestDataTypes["JOB_INDUSTRY"] = "profile_job_industry";
|
|
366
|
-
I1pIngestDataTypes["NY_PERSONAL_GOALS"] = "new_year_personal_goals";
|
|
367
|
-
I1pIngestDataTypes["NY_HOBBIES"] = "new_year_hobbies";
|
|
368
|
-
I1pIngestDataTypes["NY_PROFESSIONAL_GOALS"] = "new_year_professional_goals";
|
|
369
|
-
I1pIngestDataTypes["NY_INDUSTRY"] = "new_year_industry";
|
|
370
|
-
I1pIngestDataTypes["NY_NEWS_LOCATION"] = "new_year_news_location";
|
|
371
|
-
})(exports.I1pIngestDataTypes || (exports.I1pIngestDataTypes = {}));
|
|
372
|
-
(function (I1pDataIngestTypes) {
|
|
373
|
-
I1pDataIngestTypes["EXPLICIT"] = "explicit";
|
|
374
|
-
I1pDataIngestTypes["IMPLICIT"] = "implicit";
|
|
375
|
-
})(exports.I1pDataIngestTypes || (exports.I1pDataIngestTypes = {}));
|
|
376
|
-
(function (IngestResponseState) {
|
|
377
|
-
IngestResponseState["SUCCESS"] = "100";
|
|
378
|
-
IngestResponseState["SYSTEM_ERROR"] = "101";
|
|
379
|
-
IngestResponseState["INVALID_TYPE"] = "102";
|
|
380
|
-
IngestResponseState["INVALID_IDENTIFIER"] = "103";
|
|
381
|
-
IngestResponseState["INVALID_DATA"] = "104";
|
|
382
|
-
IngestResponseState["INVALID_ATTRIBUTE_DEFINITION"] = "105";
|
|
383
|
-
IngestResponseState["INVALID_META_DEFINITION"] = "106";
|
|
384
|
-
})(exports.IngestResponseState || (exports.IngestResponseState = {}));
|
|
385
|
-
|
|
386
|
-
var StyledMobileSelect = /*#__PURE__*/wpdsUiKit.styled('select', {
|
|
387
|
-
padding: '12px 16px 12px 6px',
|
|
388
|
-
display: 'flex',
|
|
389
|
-
justifyContent: 'space-between',
|
|
390
|
-
width: '100%',
|
|
391
|
-
backgroundColor: '$secondary',
|
|
392
|
-
color: '$primary',
|
|
393
|
-
fontFamily: '$meta',
|
|
394
|
-
fontSize: '$100',
|
|
395
|
-
fontWeight: '$light',
|
|
396
|
-
lineHeight: '$125',
|
|
397
|
-
paddingBlockRight: '$125',
|
|
398
|
-
textOverflow: 'ellipsis',
|
|
399
|
-
position: 'relative',
|
|
400
|
-
borderColor: 'transparent',
|
|
401
|
-
borderRightWidth: '10px',
|
|
402
|
-
borderRightColor: 'transparent',
|
|
403
|
-
appearance: 'none',
|
|
404
|
-
'-webkit-appearance': 'none',
|
|
405
|
-
'&:disabled': {
|
|
406
|
-
backgroundColor: wpdsUiKit.theme.colors.disabled,
|
|
407
|
-
borderColor: wpdsUiKit.theme.colors.disabled,
|
|
408
|
-
color: wpdsUiKit.theme.colors.onDisabled,
|
|
409
|
-
cursor: 'not-allowed'
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
var StyledSelectWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
|
|
413
|
-
width: '100%',
|
|
414
|
-
maxWidth: '380px',
|
|
415
|
-
borderRadius: '$012',
|
|
416
|
-
borderColor: '$subtle',
|
|
417
|
-
borderStyle: 'solid',
|
|
418
|
-
borderWidth: '1px',
|
|
419
|
-
backgroundColor: '$secondary',
|
|
420
|
-
position: 'relative'
|
|
421
|
-
});
|
|
422
|
-
var StyledMobileOption = /*#__PURE__*/wpdsUiKit.styled('option', {
|
|
423
|
-
fontFamily: 'inherit',
|
|
424
|
-
fontSize: 'inherit',
|
|
425
|
-
color: 'inherit'
|
|
426
|
-
});
|
|
427
|
-
var Dropdown = function Dropdown(_ref) {
|
|
428
|
-
var id = _ref.id,
|
|
429
|
-
label = _ref.label,
|
|
430
|
-
values = _ref.values,
|
|
431
|
-
_ref$required = _ref.required,
|
|
432
|
-
required = _ref$required === void 0 ? false : _ref$required,
|
|
433
|
-
defaultValue = _ref.defaultValue,
|
|
434
|
-
_ref$onChange = _ref.onChange,
|
|
435
|
-
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
436
|
-
_ref$disabled = _ref.disabled,
|
|
437
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
438
|
-
var _useState = React.useState(),
|
|
439
|
-
answer = _useState[0],
|
|
440
|
-
setAnswer = _useState[1];
|
|
441
|
-
var _useWindowSize = subsHooks.useWindowSize(),
|
|
442
|
-
isMobileSize = _useWindowSize.isMobileSize;
|
|
443
|
-
React.useEffect(function () {
|
|
444
|
-
if (answer) onChange(answer);
|
|
445
|
-
}, [answer]);
|
|
446
|
-
var defaultValueProp = defaultValue ? {
|
|
447
|
-
defaultValue: defaultValue
|
|
448
|
-
} : {};
|
|
449
|
-
var disabledProp = disabled ? {
|
|
450
|
-
disabled: true
|
|
451
|
-
} : {};
|
|
452
|
-
var defaultValuePropMobile = function defaultValuePropMobile(value) {
|
|
453
|
-
return value === defaultValue ? {
|
|
454
|
-
selected: true
|
|
455
|
-
} : {};
|
|
456
|
-
};
|
|
457
|
-
return isMobileSize ? React__default.createElement(StyledSelectWrapper, null, React__default.createElement(StyledMobileSelect, _extends({
|
|
458
|
-
id: "",
|
|
459
|
-
required: required,
|
|
460
|
-
onChange: function onChange(e) {
|
|
461
|
-
return setAnswer(e.target.value);
|
|
462
|
-
},
|
|
463
|
-
placeholder: label
|
|
464
|
-
}, disabledProp), React__default.createElement("label", null, label), React__default.createElement(StyledMobileOption, {
|
|
465
|
-
value: "",
|
|
466
|
-
disabled: true,
|
|
467
|
-
selected: true,
|
|
468
|
-
style: {
|
|
469
|
-
color: '#666666'
|
|
470
|
-
}
|
|
471
|
-
}, label), values.map(function (value) {
|
|
472
|
-
return React__default.createElement(StyledMobileOption, _extends({
|
|
473
|
-
value: value,
|
|
474
|
-
key: value
|
|
475
|
-
}, defaultValuePropMobile(value)), value);
|
|
476
|
-
})), React__default.createElement(wpdsUiKit.Icon, {
|
|
477
|
-
label: "",
|
|
478
|
-
size: "100",
|
|
479
|
-
fill: wpdsUiKit.theme.colors['gray80'],
|
|
480
|
-
style: {
|
|
481
|
-
pointerEvents: 'none',
|
|
482
|
-
position: 'absolute',
|
|
483
|
-
right: '10px',
|
|
484
|
-
top: '50%',
|
|
485
|
-
transform: 'translateY(-50%)'
|
|
486
|
-
}
|
|
487
|
-
}, React__default.createElement(wpdsAssets.ChevronDown, {
|
|
488
|
-
style: {
|
|
489
|
-
position: 'absolute',
|
|
490
|
-
right: '10px'
|
|
491
|
-
}
|
|
492
|
-
}))) : React__default.createElement(wpdsUiKit.Select.Root, _extends({
|
|
493
|
-
onValueChange: function onValueChange(e) {
|
|
494
|
-
return setAnswer(e);
|
|
495
|
-
},
|
|
496
|
-
required: required
|
|
497
|
-
}, defaultValueProp, disabledProp), React__default.createElement(wpdsUiKit.Select.Trigger, {
|
|
498
|
-
"data-test-id": id + "-dropdown-label"
|
|
499
|
-
}, React__default.createElement(wpdsUiKit.Select.Label, null, label), React__default.createElement(wpdsUiKit.Select.Value, null)), React__default.createElement(wpdsUiKit.Select.Content, {
|
|
500
|
-
css: {
|
|
501
|
-
zIndex: 8
|
|
502
|
-
},
|
|
503
|
-
"data-test-id": id + "-dropdown-input"
|
|
504
|
-
}, values.map(function (value) {
|
|
505
|
-
return React__default.createElement(wpdsUiKit.Select.Item, {
|
|
506
|
-
value: value,
|
|
507
|
-
key: value
|
|
508
|
-
}, value);
|
|
509
|
-
})));
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
var hasRequiredPrivacyCookies = function hasRequiredPrivacyCookies() {
|
|
513
|
-
var _WPGeo;
|
|
514
|
-
if (typeof window === 'undefined') {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
var wp_usp = subsSdk.getCookie('wp_usp');
|
|
518
|
-
var countryCode = (_WPGeo = subsSdk.WPGeo()) == null ? void 0 : _WPGeo.country_code;
|
|
519
|
-
return !!(wp_usp && countryCode === 'US');
|
|
520
|
-
};
|
|
521
362
|
|
|
522
363
|
var base = subsSdk.ENDPOINTS.base + "/de/v1";
|
|
523
364
|
var JSONHeaders = {
|
|
524
365
|
Accept: 'application/json',
|
|
525
366
|
'Content-Type': 'application/json'
|
|
526
367
|
};
|
|
527
|
-
var
|
|
528
|
-
|
|
529
|
-
|
|
368
|
+
var attributesCache = {};
|
|
369
|
+
var getAttributes = /*#__PURE__*/function () {
|
|
370
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
371
|
+
var fieldName, fieldNames, url, data, json, attributes;
|
|
530
372
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
531
373
|
while (1) switch (_context.prev = _context.next) {
|
|
532
374
|
case 0:
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
_context.next = 4;
|
|
375
|
+
fieldName = _ref.fieldName;
|
|
376
|
+
if (!attributesCache[fieldName]) {
|
|
377
|
+
_context.next = 3;
|
|
537
378
|
break;
|
|
538
379
|
}
|
|
539
|
-
|
|
540
|
-
case
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
wapo_login_id: wapo_login_id,
|
|
548
|
-
data: submitData,
|
|
549
|
-
metadata: metadata
|
|
550
|
-
};
|
|
551
|
-
_context.prev = 7;
|
|
552
|
-
_context.next = 10;
|
|
553
|
-
return fetch(url, {
|
|
554
|
-
method: 'POST',
|
|
380
|
+
return _context.abrupt("return", attributesCache[fieldName]);
|
|
381
|
+
case 3:
|
|
382
|
+
fieldNames = [fieldName];
|
|
383
|
+
_context.prev = 4;
|
|
384
|
+
url = new URL(base + "/attributes");
|
|
385
|
+
url.searchParams.set('attributes', fieldNames.join(','));
|
|
386
|
+
_context.next = 9;
|
|
387
|
+
return fetch(url.toString(), {
|
|
555
388
|
credentials: 'include',
|
|
556
|
-
headers: JSONHeaders
|
|
557
|
-
body: JSON.stringify(payload)
|
|
389
|
+
headers: JSONHeaders
|
|
558
390
|
});
|
|
559
|
-
case
|
|
560
|
-
|
|
561
|
-
_context.next =
|
|
562
|
-
return
|
|
563
|
-
case
|
|
391
|
+
case 9:
|
|
392
|
+
data = _context.sent;
|
|
393
|
+
_context.next = 12;
|
|
394
|
+
return data.json();
|
|
395
|
+
case 12:
|
|
564
396
|
json = _context.sent;
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
_context.prev = 17;
|
|
568
|
-
_context.t0 = _context["catch"](7);
|
|
569
|
-
console.debug(_context.t0);
|
|
570
|
-
return _context.abrupt("return", null);
|
|
571
|
-
case 21:
|
|
572
|
-
case "end":
|
|
573
|
-
return _context.stop();
|
|
574
|
-
}
|
|
575
|
-
}, _callee, null, [[7, 17]]);
|
|
576
|
-
}));
|
|
577
|
-
return function ingest(_x, _x2) {
|
|
578
|
-
return _ref.apply(this, arguments);
|
|
579
|
-
};
|
|
580
|
-
}();
|
|
581
|
-
|
|
582
|
-
var sendGAEvent = function sendGAEvent(props) {
|
|
583
|
-
if (typeof window === 'undefined') {
|
|
584
|
-
if (process.env.NODE_ENV !== "production") console.warn('NO WINDOW');
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
// Initialize dataLayer if needed
|
|
588
|
-
window.dataLayer = window.dataLayer || [];
|
|
589
|
-
var eventData = _extends({}, props);
|
|
590
|
-
window.dataLayer.push(eventData);
|
|
591
|
-
};
|
|
592
|
-
var sendToGA = /*#__PURE__*/function () {
|
|
593
|
-
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(submitData, metadata) {
|
|
594
|
-
var keysToSubmit;
|
|
595
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
596
|
-
while (1) switch (_context.prev = _context.next) {
|
|
597
|
-
case 0:
|
|
598
|
-
if (hasRequiredPrivacyCookies()) {
|
|
599
|
-
_context.next = 2;
|
|
397
|
+
if (!(data.ok && json.status === subsSdk.ResponseStatus.SUCCESS)) {
|
|
398
|
+
_context.next = 19;
|
|
600
399
|
break;
|
|
601
400
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
});
|
|
617
|
-
return _context.abrupt("return", true);
|
|
618
|
-
case 5:
|
|
401
|
+
attributes = json.attributes || [];
|
|
402
|
+
attributesCache[fieldName] = attributes;
|
|
403
|
+
return _context.abrupt("return", attributes);
|
|
404
|
+
case 19:
|
|
405
|
+
return _context.abrupt("return", []);
|
|
406
|
+
case 20:
|
|
407
|
+
_context.next = 26;
|
|
408
|
+
break;
|
|
409
|
+
case 22:
|
|
410
|
+
_context.prev = 22;
|
|
411
|
+
_context.t0 = _context["catch"](4);
|
|
412
|
+
console.debug(_context.t0);
|
|
413
|
+
return _context.abrupt("return", []);
|
|
414
|
+
case 26:
|
|
619
415
|
case "end":
|
|
620
416
|
return _context.stop();
|
|
621
417
|
}
|
|
622
|
-
}, _callee);
|
|
418
|
+
}, _callee, null, [[4, 22]]);
|
|
623
419
|
}));
|
|
624
|
-
return function
|
|
625
|
-
return
|
|
420
|
+
return function getAttributes(_x) {
|
|
421
|
+
return _ref2.apply(this, arguments);
|
|
626
422
|
};
|
|
627
423
|
}();
|
|
628
424
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
if (formOption.default_value) {
|
|
633
|
-
if (formOption.input_type === exports.I1pDataInputTypes.DROPDOWN && formOption.values) {
|
|
634
|
-
var values = formOption.values.filter(function (value) {
|
|
635
|
-
return value.archived !== true;
|
|
636
|
-
}).map(function (value) {
|
|
637
|
-
return value.name;
|
|
638
|
-
});
|
|
639
|
-
if (values.includes(formOption.default_value)) {
|
|
640
|
-
defaultSubmitData[formOption.id] = [formOption.default_value];
|
|
641
|
-
}
|
|
642
|
-
} else {
|
|
643
|
-
defaultSubmitData[formOption.id] = [formOption.default_value];
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
return defaultSubmitData;
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
var DataEnrichmentForm = function DataEnrichmentForm(_ref) {
|
|
651
|
-
var submit = _ref.submit,
|
|
652
|
-
source = _ref.source,
|
|
653
|
-
ingestType = _ref.ingestType,
|
|
654
|
-
_ref$formOptions = _ref.formOptions,
|
|
655
|
-
formOptions = _ref$formOptions === void 0 ? [] : _ref$formOptions,
|
|
656
|
-
_ref$onChange = _ref.onChange,
|
|
657
|
-
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
658
|
-
_ref$onFinished = _ref.onFinished,
|
|
659
|
-
onFinished = _ref$onFinished === void 0 ? function () {} : _ref$onFinished,
|
|
660
|
-
_ref$handleSubmit = _ref.handleSubmit,
|
|
661
|
-
handleSubmit = _ref$handleSubmit === void 0 ? function () {} : _ref$handleSubmit,
|
|
662
|
-
_ref$disabled = _ref.disabled,
|
|
663
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
664
|
-
var _useState = React.useState(false),
|
|
665
|
-
render = _useState[0],
|
|
666
|
-
setRender = _useState[1];
|
|
667
|
-
var _useState2 = React.useState(getDefaultSubmitData(formOptions)),
|
|
668
|
-
submitData = _useState2[0],
|
|
669
|
-
setSubmitData = _useState2[1];
|
|
670
|
-
var _useState3 = React.useState(true),
|
|
671
|
-
missingRequiredFields = _useState3[0],
|
|
672
|
-
setMissingRequiredFields = _useState3[1];
|
|
673
|
-
React.useEffect(function () {
|
|
674
|
-
if (hasRequiredPrivacyCookies()) {
|
|
675
|
-
setRender(true);
|
|
676
|
-
} else {
|
|
677
|
-
console.error('does not satisfy cookie check');
|
|
678
|
-
onFinished(true, true);
|
|
679
|
-
}
|
|
680
|
-
}, []);
|
|
681
|
-
React.useEffect(function () {
|
|
682
|
-
// check for required fields that haven't been completed yet
|
|
683
|
-
var missingRequiredFields = formOptions.filter(function (option) {
|
|
684
|
-
if (option.required && option.input_type === exports.I1pDataInputTypes.DROPDOWN && !submitData[option.id]) {
|
|
685
|
-
return true;
|
|
686
|
-
}
|
|
687
|
-
return false;
|
|
688
|
-
});
|
|
689
|
-
setMissingRequiredFields(missingRequiredFields.length > 0);
|
|
690
|
-
onChange(submitData, missingRequiredFields.length === 0);
|
|
691
|
-
}, [JSON.stringify(submitData)]);
|
|
692
|
-
React.useEffect(function () {
|
|
693
|
-
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
694
|
-
var result, isError, _result;
|
|
695
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
696
|
-
while (1) switch (_context.prev = _context.next) {
|
|
697
|
-
case 0:
|
|
698
|
-
if (!submit) {
|
|
699
|
-
_context.next = 17;
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
if (!(Object.keys(submitData).length >= 1)) {
|
|
703
|
-
_context.next = 16;
|
|
704
|
-
break;
|
|
705
|
-
}
|
|
706
|
-
if (!(ingestType === exports.I1pDataIngestTypes.EXPLICIT)) {
|
|
707
|
-
_context.next = 10;
|
|
708
|
-
break;
|
|
709
|
-
}
|
|
710
|
-
_context.next = 5;
|
|
711
|
-
return ingest(submitData, {
|
|
712
|
-
source: source
|
|
713
|
-
});
|
|
714
|
-
case 5:
|
|
715
|
-
result = _context.sent;
|
|
716
|
-
isError = result && result.status !== subsSdk.ResponseStatus.SUCCESS;
|
|
717
|
-
onFinished(true, isError);
|
|
718
|
-
_context.next = 14;
|
|
719
|
-
break;
|
|
720
|
-
case 10:
|
|
721
|
-
_context.next = 12;
|
|
722
|
-
return sendToGA(submitData, {
|
|
723
|
-
source: source
|
|
724
|
-
});
|
|
725
|
-
case 12:
|
|
726
|
-
_result = _context.sent;
|
|
727
|
-
onFinished(true, _result);
|
|
728
|
-
case 14:
|
|
729
|
-
_context.next = 17;
|
|
730
|
-
break;
|
|
731
|
-
case 16:
|
|
732
|
-
onFinished(true, false);
|
|
733
|
-
case 17:
|
|
734
|
-
case "end":
|
|
735
|
-
return _context.stop();
|
|
736
|
-
}
|
|
737
|
-
}, _callee);
|
|
738
|
-
}))();
|
|
739
|
-
}, [submit]);
|
|
740
|
-
if (!render) return React__default.createElement(React__default.Fragment, null);
|
|
741
|
-
return React__default.createElement("form", {
|
|
742
|
-
method: "post",
|
|
743
|
-
onSubmit: function onSubmit(e) {
|
|
744
|
-
e.preventDefault();
|
|
745
|
-
handleSubmit(e);
|
|
746
|
-
}
|
|
747
|
-
}, formOptions.map(function (formOption) {
|
|
748
|
-
if (formOption.input_type === exports.I1pDataInputTypes.DROPDOWN && formOption.values) {
|
|
749
|
-
// sort and filter out archived values
|
|
750
|
-
var values = formOption.values.sort(function (a, b) {
|
|
751
|
-
return a.order - b.order;
|
|
752
|
-
}).filter(function (value) {
|
|
753
|
-
return value.archived !== true;
|
|
754
|
-
});
|
|
755
|
-
return React__default.createElement(OptionWrapper, {
|
|
756
|
-
"data-private": true,
|
|
757
|
-
key: formOption.id
|
|
758
|
-
}, React__default.createElement(Dropdown, {
|
|
759
|
-
id: formOption.id,
|
|
760
|
-
label: formOption.input_label,
|
|
761
|
-
values: values.map(function (value) {
|
|
762
|
-
return value.name;
|
|
763
|
-
}),
|
|
764
|
-
required: formOption.required,
|
|
765
|
-
defaultValue: formOption.default_value,
|
|
766
|
-
onChange: function onChange(value) {
|
|
767
|
-
var _extends2;
|
|
768
|
-
setSubmitData(_extends({}, submitData, (_extends2 = {}, _extends2[formOption.id] = [value], _extends2)));
|
|
769
|
-
},
|
|
770
|
-
disabled: disabled
|
|
771
|
-
}));
|
|
772
|
-
}
|
|
773
|
-
return null;
|
|
774
|
-
}), React__default.createElement("input", {
|
|
775
|
-
type: "submit",
|
|
776
|
-
hidden: true,
|
|
777
|
-
disabled: missingRequiredFields || disabled,
|
|
778
|
-
"data-qa": "1p-data-inputs-submit"
|
|
779
|
-
}));
|
|
780
|
-
};
|
|
781
|
-
var OptionWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
|
|
782
|
-
boxSizing: 'border-box',
|
|
783
|
-
display: 'flex',
|
|
784
|
-
marginBottom: '$100',
|
|
785
|
-
flexDirection: 'column',
|
|
786
|
-
'& button': {
|
|
787
|
-
padding: '1px 6px'
|
|
788
|
-
},
|
|
789
|
-
'& *': {
|
|
790
|
-
boxSizing: 'border-box'
|
|
791
|
-
}
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
exports.DataEnrichmentForm = DataEnrichmentForm;
|
|
425
|
+
exports.CollectionBehaviors = CollectionBehaviors;
|
|
426
|
+
exports.IngestResponseState = IngestResponseState;
|
|
427
|
+
exports.getAttributes = getAttributes;
|
|
795
428
|
exports.hasRequiredPrivacyCookies = hasRequiredPrivacyCookies;
|
|
796
|
-
exports.ingest = ingest;
|
|
797
|
-
exports.sendToGA = sendToGA;
|
|
798
429
|
//# sourceMappingURL=subs-de-inputs.cjs.development.js.map
|