@washingtonpost/subs-de-inputs 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/components/DESelect/index.d.ts +35 -0
- package/dist/index.d.ts +1 -2
- package/dist/interfaces/index.d.ts +31 -61
- package/dist/services/dataEnrichment.d.ts +2 -3
- package/dist/subs-de-inputs.cjs.development.js +162 -397
- 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 +159 -400
- 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
|
@@ -4,12 +4,37 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
|
+
var subsSdk = require('@washingtonpost/subs-sdk');
|
|
7
8
|
var React = require('react');
|
|
8
9
|
var React__default = _interopDefault(React);
|
|
9
10
|
var wpdsUiKit = require('@washingtonpost/wpds-ui-kit');
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
var CollectionBehaviors = {
|
|
13
|
+
COLLECT: 'COLLECT',
|
|
14
|
+
DO_NOT_COLLECT: 'DO_NOT_COLLECT'
|
|
15
|
+
};
|
|
16
|
+
var AttributesState = {
|
|
17
|
+
SUCCESS: '100'
|
|
18
|
+
};
|
|
19
|
+
var IngestResponseState = {
|
|
20
|
+
SUCCESS: '100',
|
|
21
|
+
SYSTEM_ERROR: '101',
|
|
22
|
+
INVALID_TYPE: '102',
|
|
23
|
+
INVALID_IDENTIFIER: '103',
|
|
24
|
+
INVALID_DATA: '104',
|
|
25
|
+
INVALID_ATTRIBUTE_DEFINITION: '105',
|
|
26
|
+
INVALID_META_DEFINITION: '106'
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var hasRequiredPrivacyCookies = function hasRequiredPrivacyCookies() {
|
|
30
|
+
var _WPGeo;
|
|
31
|
+
if (typeof window === 'undefined') {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
var wp_usp = subsSdk.getCookie('wp_usp');
|
|
35
|
+
var countryCode = (_WPGeo = subsSdk.WPGeo()) == null ? void 0 : _WPGeo.country_code;
|
|
36
|
+
return !!(wp_usp && countryCode === 'US');
|
|
37
|
+
};
|
|
13
38
|
|
|
14
39
|
function _regeneratorRuntime() {
|
|
15
40
|
_regeneratorRuntime = function () {
|
|
@@ -357,428 +382,166 @@ function _extends() {
|
|
|
357
382
|
return _extends.apply(this, arguments);
|
|
358
383
|
}
|
|
359
384
|
|
|
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
|
-
|
|
522
385
|
var base = subsSdk.ENDPOINTS.base + "/de/v1";
|
|
523
|
-
var
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
var ingest = /*#__PURE__*/function () {
|
|
528
|
-
var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(submitData, metadata) {
|
|
529
|
-
var url, wapo_login_id, jucid, ga, payload, response, json;
|
|
386
|
+
var attributesCache = {};
|
|
387
|
+
var getAttributes = /*#__PURE__*/function () {
|
|
388
|
+
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
389
|
+
var fieldName, fieldNames, url, data, json, attributes;
|
|
530
390
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
531
391
|
while (1) switch (_context.prev = _context.next) {
|
|
532
392
|
case 0:
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
_context.next = 4;
|
|
393
|
+
fieldName = _ref.fieldName;
|
|
394
|
+
if (!attributesCache[fieldName]) {
|
|
395
|
+
_context.next = 3;
|
|
537
396
|
break;
|
|
538
397
|
}
|
|
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',
|
|
398
|
+
return _context.abrupt("return", attributesCache[fieldName]);
|
|
399
|
+
case 3:
|
|
400
|
+
fieldNames = [fieldName];
|
|
401
|
+
_context.prev = 4;
|
|
402
|
+
url = new URL(base + "/attributes");
|
|
403
|
+
url.searchParams.set('attributes', fieldNames.join(','));
|
|
404
|
+
_context.next = 9;
|
|
405
|
+
return fetch(url.toString(), {
|
|
555
406
|
credentials: 'include',
|
|
556
|
-
headers:
|
|
557
|
-
body: JSON.stringify(payload)
|
|
407
|
+
headers: subsSdk.JSON_HEADERS
|
|
558
408
|
});
|
|
559
|
-
case
|
|
560
|
-
|
|
561
|
-
_context.next =
|
|
562
|
-
return
|
|
563
|
-
case
|
|
409
|
+
case 9:
|
|
410
|
+
data = _context.sent;
|
|
411
|
+
_context.next = 12;
|
|
412
|
+
return data.json();
|
|
413
|
+
case 12:
|
|
564
414
|
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;
|
|
415
|
+
if (!(data.ok && json.status === subsSdk.ResponseStatus.SUCCESS)) {
|
|
416
|
+
_context.next = 19;
|
|
600
417
|
break;
|
|
601
418
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
});
|
|
617
|
-
return _context.abrupt("return", true);
|
|
618
|
-
case 5:
|
|
419
|
+
attributes = json.attributes || [];
|
|
420
|
+
attributesCache[fieldName] = attributes;
|
|
421
|
+
return _context.abrupt("return", attributes);
|
|
422
|
+
case 19:
|
|
423
|
+
return _context.abrupt("return", []);
|
|
424
|
+
case 20:
|
|
425
|
+
_context.next = 26;
|
|
426
|
+
break;
|
|
427
|
+
case 22:
|
|
428
|
+
_context.prev = 22;
|
|
429
|
+
_context.t0 = _context["catch"](4);
|
|
430
|
+
console.debug(_context.t0);
|
|
431
|
+
return _context.abrupt("return", []);
|
|
432
|
+
case 26:
|
|
619
433
|
case "end":
|
|
620
434
|
return _context.stop();
|
|
621
435
|
}
|
|
622
|
-
}, _callee);
|
|
436
|
+
}, _callee, null, [[4, 22]]);
|
|
623
437
|
}));
|
|
624
|
-
return function
|
|
625
|
-
return
|
|
438
|
+
return function getAttributes(_x) {
|
|
439
|
+
return _ref2.apply(this, arguments);
|
|
626
440
|
};
|
|
627
441
|
}();
|
|
628
442
|
|
|
629
|
-
var
|
|
630
|
-
var
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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,
|
|
443
|
+
var DESelect = function DESelect(_ref) {
|
|
444
|
+
var source = _ref.source,
|
|
445
|
+
fieldName = _ref.fieldName,
|
|
446
|
+
label = _ref.label,
|
|
447
|
+
dataDictionaryConfig = _ref.dataDictionaryConfig,
|
|
448
|
+
defaultValue = _ref.defaultValue,
|
|
449
|
+
disabled = _ref.disabled,
|
|
450
|
+
submit = _ref.submit,
|
|
656
451
|
_ref$onChange = _ref.onChange,
|
|
657
452
|
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
658
453
|
_ref$onFinished = _ref.onFinished,
|
|
659
454
|
onFinished = _ref$onFinished === void 0 ? function () {} : _ref$onFinished,
|
|
660
|
-
_ref$
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
missingRequiredFields = _useState3[0],
|
|
672
|
-
setMissingRequiredFields = _useState3[1];
|
|
455
|
+
_ref$valuesFilter = _ref.valuesFilter,
|
|
456
|
+
valuesFilter = _ref$valuesFilter === void 0 ? function () {
|
|
457
|
+
return true;
|
|
458
|
+
} : _ref$valuesFilter,
|
|
459
|
+
children = _ref.children;
|
|
460
|
+
var _useState = React.useState(dataDictionaryConfig),
|
|
461
|
+
config = _useState[0],
|
|
462
|
+
setConfig = _useState[1];
|
|
463
|
+
var _useState2 = React.useState(''),
|
|
464
|
+
selected = _useState2[0],
|
|
465
|
+
setSelected = _useState2[1];
|
|
673
466
|
React.useEffect(function () {
|
|
674
|
-
if (
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
467
|
+
if (children) {
|
|
468
|
+
if (process.env.NODE_ENV !== "production") {
|
|
469
|
+
console.debug('childen props', children);
|
|
470
|
+
}
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (!config) {
|
|
474
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
475
|
+
var config;
|
|
476
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
477
|
+
while (1) switch (_context.prev = _context.next) {
|
|
478
|
+
case 0:
|
|
479
|
+
_context.next = 2;
|
|
480
|
+
return getAttributes({
|
|
481
|
+
fieldName: fieldName
|
|
482
|
+
});
|
|
483
|
+
case 2:
|
|
484
|
+
config = _context.sent;
|
|
485
|
+
if (process.env.NODE_ENV !== "production") {
|
|
486
|
+
console.debug('config from API', config);
|
|
487
|
+
}
|
|
488
|
+
setConfig(config[0]);
|
|
489
|
+
case 5:
|
|
490
|
+
case "end":
|
|
491
|
+
return _context.stop();
|
|
492
|
+
}
|
|
493
|
+
}, _callee);
|
|
494
|
+
}))();
|
|
679
495
|
}
|
|
680
496
|
}, []);
|
|
681
497
|
React.useEffect(function () {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
return true;
|
|
498
|
+
if (submit && selected) {
|
|
499
|
+
if (process.env.NODE_ENV !== "production") {
|
|
500
|
+
console.error('push not implemented', selected, source);
|
|
686
501
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
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);
|
|
502
|
+
onFinished({
|
|
503
|
+
isFinished: true,
|
|
504
|
+
isError: false
|
|
505
|
+
});
|
|
746
506
|
}
|
|
747
|
-
},
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
507
|
+
}, [submit, selected]);
|
|
508
|
+
if (!(children || config)) {
|
|
509
|
+
return React__default.createElement("span", null, "loading");
|
|
510
|
+
}
|
|
511
|
+
var defaultValueProp = defaultValue ? {
|
|
512
|
+
defaultValue: defaultValue
|
|
513
|
+
} : {};
|
|
514
|
+
var disabledProp = disabled ? {
|
|
515
|
+
disabled: true
|
|
516
|
+
} : {};
|
|
517
|
+
// sort and filter out archived values
|
|
518
|
+
var values = config ? config.values.sort(function (a, b) {
|
|
519
|
+
return a.order - b.order;
|
|
520
|
+
}).filter(function (value) {
|
|
521
|
+
return value.archived !== true;
|
|
522
|
+
}).filter(valuesFilter) : [];
|
|
523
|
+
return React__default.createElement(SelectWrapper, null, React__default.createElement(wpdsUiKit.Select.Root, _extends({
|
|
524
|
+
onValueChange: function onValueChange(e) {
|
|
525
|
+
onChange({
|
|
526
|
+
value: e
|
|
754
527
|
});
|
|
755
|
-
|
|
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
|
-
}));
|
|
528
|
+
setSelected(e);
|
|
772
529
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
530
|
+
}, defaultValueProp, disabledProp), children ? children : null, !children && config && React__default.createElement(React__default.Fragment, null, React__default.createElement(wpdsUiKit.Select.Trigger, {
|
|
531
|
+
"data-test-id": config.name + "-select-trigger"
|
|
532
|
+
}, React__default.createElement(wpdsUiKit.Select.Label, null, label || config.name), React__default.createElement(wpdsUiKit.Select.Value, null)), React__default.createElement(wpdsUiKit.Select.Content, {
|
|
533
|
+
css: {
|
|
534
|
+
zIndex: wpdsUiKit.theme.zIndices.page
|
|
535
|
+
},
|
|
536
|
+
"data-test-id": config.name + "-select-content"
|
|
537
|
+
}, values.map(function (value) {
|
|
538
|
+
return React__default.createElement(wpdsUiKit.Select.Item, {
|
|
539
|
+
value: value.name,
|
|
540
|
+
key: value.name
|
|
541
|
+
}, value.name);
|
|
542
|
+
})))));
|
|
780
543
|
};
|
|
781
|
-
var
|
|
544
|
+
var SelectWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
|
|
782
545
|
boxSizing: 'border-box',
|
|
783
546
|
display: 'flex',
|
|
784
547
|
marginBottom: '$100',
|
|
@@ -791,8 +554,10 @@ var OptionWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
|
|
|
791
554
|
}
|
|
792
555
|
});
|
|
793
556
|
|
|
794
|
-
exports.
|
|
557
|
+
exports.AttributesState = AttributesState;
|
|
558
|
+
exports.CollectionBehaviors = CollectionBehaviors;
|
|
559
|
+
exports.DESelect = DESelect;
|
|
560
|
+
exports.IngestResponseState = IngestResponseState;
|
|
561
|
+
exports.getAttributes = getAttributes;
|
|
795
562
|
exports.hasRequiredPrivacyCookies = hasRequiredPrivacyCookies;
|
|
796
|
-
exports.ingest = ingest;
|
|
797
|
-
exports.sendToGA = sendToGA;
|
|
798
563
|
//# sourceMappingURL=subs-de-inputs.cjs.development.js.map
|