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