@transferwise/components 0.0.0-experimental-29ce40f → 0.0.0-experimental-04e4d95
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/build/index.js +524 -15
- package/build/index.js.map +1 -1
- package/build/index.mjs +524 -17
- package/build/index.mjs.map +1 -1
- package/build/main.css +5 -0
- package/build/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -0
- package/build/styles/main.css +5 -0
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/common/requirements.d.ts +3 -0
- package/build/types/common/requirements.d.ts.map +1 -0
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts +21 -0
- package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts +12 -0
- package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts +2 -0
- package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/index.d.ts +2 -0
- package/build/types/dynamicFieldDefinitionList/index.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts +2 -0
- package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts +2 -0
- package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts.map +1 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/loader/Loader.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/stepper/deviceDetection.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.story.tsx +1 -1
- package/src/alert/Alert.tsx +2 -1
- package/src/avatar/colors/colors.ts +1 -1
- package/src/body/Body.spec.tsx +1 -1
- package/src/body/Body.story.tsx +8 -8
- package/src/checkbox/Checkbox.js +1 -1
- package/src/checkboxButton/CheckboxButton.spec.tsx +0 -1
- package/src/common/Option/Option.tsx +1 -1
- package/src/common/deviceDetection/deviceDetection.js +1 -1
- package/src/common/deviceDetection/deviceDetection.spec.js +4 -2
- package/src/common/responsivePanel/ResponsivePanel.spec.js +11 -15
- package/src/decision/Decision.spec.js +0 -1
- package/src/dimmer/Dimmer.tsx +6 -2
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +41 -0
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.spec.js +21 -0
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.story.js +134 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +73 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.less +4 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.spec.js +200 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/index.js +1 -0
- package/src/dynamicFieldDefinitionList/index.js +1 -0
- package/src/dynamicFieldDefinitionList/utils/createDefinitions.js +33 -0
- package/src/dynamicFieldDefinitionList/utils/createDefinitions.spec.js +83 -0
- package/src/dynamicFieldDefinitionList/utils/text-format.js +46 -0
- package/src/dynamicFieldDefinitionList/utils/text-format.spec.js +43 -0
- package/src/index.ts +1 -0
- package/src/inlineAlert/InlineAlert.story.tsx +8 -7
- package/src/link/Link.story.tsx +16 -16
- package/src/loader/Loader.tsx +0 -1
- package/src/logo/Logo.js +2 -2
- package/src/main.css +5 -0
- package/src/main.less +1 -0
- package/src/moneyInput/MoneyInput.story.tsx +3 -3
- package/src/nudge/Nudge.spec.tsx +5 -5
- package/src/phoneNumberInput/PhoneNumberInput.tsx +2 -1
- package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.ts +1 -1
- package/src/popover/Popover.tsx +2 -1
- package/src/promoCard/PromoCard.tsx +1 -1
- package/src/radioGroup/RadioGroup.spec.js +1 -1
- package/src/section/Section.story.tsx +2 -1
- package/src/segmentedControl/SegmentedControl.spec.tsx +2 -2
- package/src/select/Select.js +2 -3
- package/src/stepper/deviceDetection.js +1 -2
- package/src/stepper/deviceDetection.spec.js +8 -3
- package/src/test-utils/index.js +1 -1
- package/src/test-utils/story-config.ts +1 -1
- package/src/title/Title.spec.tsx +1 -1
- package/src/typeahead/Typeahead.spec.js +4 -2
- package/src/upload/Upload.spec.js +8 -4
- package/src/uploadInput/uploadButton/UploadButton.tsx +1 -0
package/build/index.js
CHANGED
|
@@ -25,6 +25,7 @@ var art = require('@wise/art');
|
|
|
25
25
|
var clamp$2 = require('lodash.clamp');
|
|
26
26
|
var debounce = require('lodash.debounce');
|
|
27
27
|
var requiredIf = require('react-required-if');
|
|
28
|
+
var toPairs = require('lodash.topairs');
|
|
28
29
|
var web = require('@react-spring/web');
|
|
29
30
|
|
|
30
31
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -56,6 +57,7 @@ var throttle__default = /*#__PURE__*/_interopDefault(throttle);
|
|
|
56
57
|
var clamp__default = /*#__PURE__*/_interopDefault(clamp$2);
|
|
57
58
|
var debounce__default = /*#__PURE__*/_interopDefault(debounce);
|
|
58
59
|
var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
|
|
60
|
+
var toPairs__default = /*#__PURE__*/_interopDefault(toPairs);
|
|
59
61
|
|
|
60
62
|
class HistoryNavigator {
|
|
61
63
|
constructor(history = [], historyLimit = null) {
|
|
@@ -93,7 +95,7 @@ var HistoryNavigator$1 = HistoryNavigator;
|
|
|
93
95
|
function isIosDevice() {
|
|
94
96
|
const sampleTouchDevices = ['iphone', 'ipad', 'ipod'];
|
|
95
97
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
96
|
-
const regex = new RegExp(matchString, '
|
|
98
|
+
const regex = new RegExp(matchString, 'gi');
|
|
97
99
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -939,8 +941,9 @@ function resolveType(type) {
|
|
|
939
941
|
return 'neutral';
|
|
940
942
|
case 'error':
|
|
941
943
|
return 'negative';
|
|
944
|
+
default:
|
|
945
|
+
return type;
|
|
942
946
|
}
|
|
943
|
-
return type;
|
|
944
947
|
}
|
|
945
948
|
function Alert({
|
|
946
949
|
arrow,
|
|
@@ -1086,7 +1089,7 @@ const hashSeed = seed => {
|
|
|
1086
1089
|
const modulo = avatarColors.length;
|
|
1087
1090
|
let hashValue = 0;
|
|
1088
1091
|
let basePow = 1;
|
|
1089
|
-
for (let i = 0; i < seed.length; i
|
|
1092
|
+
for (let i = 0; i < seed.length; i += 1) {
|
|
1090
1093
|
hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;
|
|
1091
1094
|
basePow = basePow * base % modulo;
|
|
1092
1095
|
}
|
|
@@ -1378,11 +1381,15 @@ const Dimmer = ({
|
|
|
1378
1381
|
}, [onClose]);
|
|
1379
1382
|
const onEnter = () => {
|
|
1380
1383
|
setHasNotExited(true);
|
|
1381
|
-
|
|
1384
|
+
if (dimmerReference.current) {
|
|
1385
|
+
dimmerManager.add(dimmerReference.current);
|
|
1386
|
+
}
|
|
1382
1387
|
};
|
|
1383
1388
|
const onExited = () => {
|
|
1384
1389
|
setHasNotExited(false);
|
|
1385
|
-
|
|
1390
|
+
if (dimmerReference.current) {
|
|
1391
|
+
dimmerManager.remove(dimmerReference.current);
|
|
1392
|
+
}
|
|
1386
1393
|
};
|
|
1387
1394
|
React.useEffect(() => {
|
|
1388
1395
|
const localReferenceCopy = dimmerReference.current;
|
|
@@ -4357,6 +4364,508 @@ const DropFade = ({
|
|
|
4357
4364
|
});
|
|
4358
4365
|
};
|
|
4359
4366
|
|
|
4367
|
+
/* eslint-disable no-unused-vars */
|
|
4368
|
+
/* eslint-disable no-param-reassign */
|
|
4369
|
+
|
|
4370
|
+
const prepFields = (fields, model, validationMessages) => {
|
|
4371
|
+
if (!fields) {
|
|
4372
|
+
return {};
|
|
4373
|
+
}
|
|
4374
|
+
let preparedFields = copyOf(fields);
|
|
4375
|
+
preparedFields = flattenFieldsWithGroups(preparedFields);
|
|
4376
|
+
preparedFields = transformFieldArrayToMap(preparedFields);
|
|
4377
|
+
preparedFields = transformNestedKeysToNestedSpecs(preparedFields);
|
|
4378
|
+
Object.keys(preparedFields).forEach(key => {
|
|
4379
|
+
preparedFields[key] = prepField(preparedFields[key], model, validationMessages);
|
|
4380
|
+
});
|
|
4381
|
+
return preparedFields;
|
|
4382
|
+
};
|
|
4383
|
+
const prepField = (field, model, validationMessages) => {
|
|
4384
|
+
const preparedField = copyOf(field);
|
|
4385
|
+
prepLegacyProps(preparedField);
|
|
4386
|
+
prepType(preparedField);
|
|
4387
|
+
prepPattern(preparedField);
|
|
4388
|
+
prepValidationMessages(preparedField, validationMessages);
|
|
4389
|
+
return preparedField;
|
|
4390
|
+
};
|
|
4391
|
+
|
|
4392
|
+
/**
|
|
4393
|
+
* In an older format we had an extra fieldGroup level, here we flatten that out
|
|
4394
|
+
* So the inner arrays of fields within the different field groups are flattened
|
|
4395
|
+
* to a single array, which is returned.
|
|
4396
|
+
*
|
|
4397
|
+
* @param fields
|
|
4398
|
+
*/
|
|
4399
|
+
const flattenFieldsWithGroups = fields => {
|
|
4400
|
+
if (Array.isArray(fields)) {
|
|
4401
|
+
let flattenedFields = [];
|
|
4402
|
+
fields.forEach(field => {
|
|
4403
|
+
// If we've been given a group with nested fields, break them out.
|
|
4404
|
+
if (field.fields) {
|
|
4405
|
+
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.fields));
|
|
4406
|
+
} else if (field.group) {
|
|
4407
|
+
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.group));
|
|
4408
|
+
} else {
|
|
4409
|
+
// Otherwise it's a regular field, just add it.
|
|
4410
|
+
flattenedFields.push(field);
|
|
4411
|
+
}
|
|
4412
|
+
});
|
|
4413
|
+
return flattenedFields;
|
|
4414
|
+
}
|
|
4415
|
+
return fields;
|
|
4416
|
+
};
|
|
4417
|
+
const flattenFieldWithGroup = (field, subFields) => {
|
|
4418
|
+
// If first field doesn't have a label, use the one from the group
|
|
4419
|
+
if (field.name && subFields.length > 0 && !subFields[0].name) {
|
|
4420
|
+
subFields[0].name = field.name;
|
|
4421
|
+
}
|
|
4422
|
+
if (field.width && subFields.length > 0 && !subFields[0].width) {
|
|
4423
|
+
subFields[0].width = field.width;
|
|
4424
|
+
}
|
|
4425
|
+
|
|
4426
|
+
// If there was a tooltip at fieldGroup level move it to first field.
|
|
4427
|
+
if (field.tooltip && subFields.length > 0 && !subFields[0].help) {
|
|
4428
|
+
subFields[0].help = {
|
|
4429
|
+
message: field.tooltip
|
|
4430
|
+
};
|
|
4431
|
+
}
|
|
4432
|
+
if (field.info && subFields.length > 0 && !subFields[0].help) {
|
|
4433
|
+
subFields[0].help = {
|
|
4434
|
+
message: field.info
|
|
4435
|
+
};
|
|
4436
|
+
}
|
|
4437
|
+
|
|
4438
|
+
// If there are two parts of this group, render them side by side
|
|
4439
|
+
if (subFields.length === 2) {
|
|
4440
|
+
subFields.forEach(nestedField => {
|
|
4441
|
+
nestedField.width = 'md';
|
|
4442
|
+
});
|
|
4443
|
+
}
|
|
4444
|
+
|
|
4445
|
+
// If there are three parts, render the first two side by side
|
|
4446
|
+
if (subFields.length === 3) {
|
|
4447
|
+
subFields[0].width = 'md';
|
|
4448
|
+
subFields[1].width = 'md';
|
|
4449
|
+
}
|
|
4450
|
+
return subFields;
|
|
4451
|
+
};
|
|
4452
|
+
|
|
4453
|
+
/*
|
|
4454
|
+
* Some older requirements return an array of fields, where it should be a map
|
|
4455
|
+
* from the property name to the spec. This converts arrays to maps.
|
|
4456
|
+
*/
|
|
4457
|
+
const transformFieldArrayToMap = fields => {
|
|
4458
|
+
if (Array.isArray(fields)) {
|
|
4459
|
+
const fieldMap = {};
|
|
4460
|
+
fields.forEach(field => {
|
|
4461
|
+
const key = field.key || field.name;
|
|
4462
|
+
delete field.key;
|
|
4463
|
+
fieldMap[key] = copyOf(field);
|
|
4464
|
+
});
|
|
4465
|
+
return fieldMap;
|
|
4466
|
+
}
|
|
4467
|
+
return fields;
|
|
4468
|
+
};
|
|
4469
|
+
|
|
4470
|
+
/*
|
|
4471
|
+
* Some older format return keys like 'address.city', expecting the value of
|
|
4472
|
+
* city to be nested inside an address object. This function creates a spec of
|
|
4473
|
+
* type 'object', and nests such fields inside of it. When we render we pass
|
|
4474
|
+
* this object spec to a nested fieldset.
|
|
4475
|
+
*/
|
|
4476
|
+
const transformNestedKeysToNestedSpecs = fieldMap => {
|
|
4477
|
+
if (Array.isArray(fieldMap)) {
|
|
4478
|
+
throw new TypeError('Expecting a map of fields, not an array');
|
|
4479
|
+
}
|
|
4480
|
+
const nestedFields = {};
|
|
4481
|
+
Object.keys(fieldMap).forEach(key => {
|
|
4482
|
+
if (key.indexOf('.') > 0) {
|
|
4483
|
+
// If the key contains a period we need to nest the fields in another object
|
|
4484
|
+
const pathSections = key.split('.');
|
|
4485
|
+
const nestedKey = pathSections[0];
|
|
4486
|
+
|
|
4487
|
+
// If this sub object doesn't exist yet, create it
|
|
4488
|
+
if (!nestedFields[nestedKey]) {
|
|
4489
|
+
nestedFields[nestedKey] = {
|
|
4490
|
+
type: 'object',
|
|
4491
|
+
properties: {}
|
|
4492
|
+
};
|
|
4493
|
+
}
|
|
4494
|
+
nestedFields[nestedKey].properties[pathSections[1]] = fieldMap[key];
|
|
4495
|
+
} else {
|
|
4496
|
+
nestedFields[key] = fieldMap[key];
|
|
4497
|
+
}
|
|
4498
|
+
});
|
|
4499
|
+
return nestedFields;
|
|
4500
|
+
};
|
|
4501
|
+
const prepType = field => {
|
|
4502
|
+
const type = field.type && field.type.toLowerCase && field.type.toLowerCase();
|
|
4503
|
+
switch (type) {
|
|
4504
|
+
case 'text':
|
|
4505
|
+
field.type = 'string';
|
|
4506
|
+
break;
|
|
4507
|
+
case 'date':
|
|
4508
|
+
field.type = 'string';
|
|
4509
|
+
field.format = 'date';
|
|
4510
|
+
break;
|
|
4511
|
+
case 'password':
|
|
4512
|
+
field.type = 'string';
|
|
4513
|
+
field.control = 'password';
|
|
4514
|
+
break;
|
|
4515
|
+
case 'checkbox':
|
|
4516
|
+
field.type = 'boolean';
|
|
4517
|
+
break;
|
|
4518
|
+
case 'select':
|
|
4519
|
+
if (!field.control) {
|
|
4520
|
+
field.control = 'select';
|
|
4521
|
+
}
|
|
4522
|
+
delete field.type;
|
|
4523
|
+
break;
|
|
4524
|
+
case 'radio':
|
|
4525
|
+
field.control = 'radio';
|
|
4526
|
+
delete field.type;
|
|
4527
|
+
break;
|
|
4528
|
+
case 'upload':
|
|
4529
|
+
field.type = 'string';
|
|
4530
|
+
field.format = 'base64url';
|
|
4531
|
+
break;
|
|
4532
|
+
case 'tel':
|
|
4533
|
+
field.type = 'string';
|
|
4534
|
+
field.format = 'phone';
|
|
4535
|
+
break;
|
|
4536
|
+
case 'textarea':
|
|
4537
|
+
field.type = 'string';
|
|
4538
|
+
field.control = 'textarea';
|
|
4539
|
+
break;
|
|
4540
|
+
}
|
|
4541
|
+
if (!field.control && field.type !== 'object') {
|
|
4542
|
+
field.control = getControlType(field);
|
|
4543
|
+
}
|
|
4544
|
+
};
|
|
4545
|
+
const prepLegacyProps = field => {
|
|
4546
|
+
if (field.name && !field.title) {
|
|
4547
|
+
field.title = field.name;
|
|
4548
|
+
delete field.name;
|
|
4549
|
+
}
|
|
4550
|
+
if (field.validationRegexp) {
|
|
4551
|
+
field.pattern = field.validationRegexp;
|
|
4552
|
+
delete field.validationRegexp;
|
|
4553
|
+
}
|
|
4554
|
+
if (field.min) {
|
|
4555
|
+
field.minimum = field.min;
|
|
4556
|
+
delete field.min;
|
|
4557
|
+
}
|
|
4558
|
+
if (field.max) {
|
|
4559
|
+
field.maximum = field.max;
|
|
4560
|
+
delete field.max;
|
|
4561
|
+
}
|
|
4562
|
+
if (field.example && !field.placeholder) {
|
|
4563
|
+
field.placeholder = field.example;
|
|
4564
|
+
delete field.example;
|
|
4565
|
+
}
|
|
4566
|
+
if (field.tooltip && !field.help) {
|
|
4567
|
+
field.help = {
|
|
4568
|
+
message: field.tooltip
|
|
4569
|
+
};
|
|
4570
|
+
delete field.tooltip;
|
|
4571
|
+
}
|
|
4572
|
+
if (field.valuesAllowed && !field.values) {
|
|
4573
|
+
field.values = field.valuesAllowed;
|
|
4574
|
+
delete field.valuesAllowed;
|
|
4575
|
+
}
|
|
4576
|
+
if (field.values && field.values.map) {
|
|
4577
|
+
field.values = prepLegacyValues(field.values);
|
|
4578
|
+
}
|
|
4579
|
+
if (field.value && !field.default) {
|
|
4580
|
+
field.default = field.value;
|
|
4581
|
+
delete field.value;
|
|
4582
|
+
}
|
|
4583
|
+
if (field.values) {
|
|
4584
|
+
// In some legacy arrays the first value is a placeholder, extract it.
|
|
4585
|
+
if (field.values && field.values.length > 0 && field.values[0] && !field.values[0].value && field.values[0].label && !field.placeholder) {
|
|
4586
|
+
field.placeholder = field.values[0].label;
|
|
4587
|
+
field.values = field.values.slice(1);
|
|
4588
|
+
}
|
|
4589
|
+
}
|
|
4590
|
+
};
|
|
4591
|
+
const prepLegacyValues = values => values.map(prepLegacyValue);
|
|
4592
|
+
const prepLegacyValue = value => {
|
|
4593
|
+
if (!value.label && value.title) {
|
|
4594
|
+
value.label = value.title;
|
|
4595
|
+
delete value.title;
|
|
4596
|
+
}
|
|
4597
|
+
if (!value.label && value.name) {
|
|
4598
|
+
value.label = value.name;
|
|
4599
|
+
delete value.name;
|
|
4600
|
+
}
|
|
4601
|
+
if (!value.value && value.code) {
|
|
4602
|
+
value.value = value.code;
|
|
4603
|
+
delete value.code;
|
|
4604
|
+
}
|
|
4605
|
+
if (!value.value && value.key) {
|
|
4606
|
+
value.value = value.key;
|
|
4607
|
+
delete value.key;
|
|
4608
|
+
}
|
|
4609
|
+
return value;
|
|
4610
|
+
};
|
|
4611
|
+
const prepPattern = field => {
|
|
4612
|
+
if (field.pattern) {
|
|
4613
|
+
try {
|
|
4614
|
+
new RegExp(field.pattern);
|
|
4615
|
+
} catch {
|
|
4616
|
+
// eslint-disable-next-line no-console
|
|
4617
|
+
console.warn('API regexp is invalid');
|
|
4618
|
+
delete field.pattern;
|
|
4619
|
+
}
|
|
4620
|
+
} else {
|
|
4621
|
+
delete field.pattern;
|
|
4622
|
+
}
|
|
4623
|
+
};
|
|
4624
|
+
const prepValidationMessages = (field, validationMessages) => {
|
|
4625
|
+
field.validationMessages = field.validationMessages ? field.validationMessages : validationMessages;
|
|
4626
|
+
if (!field.validationMessages) {
|
|
4627
|
+
delete field.validationMessages;
|
|
4628
|
+
return;
|
|
4629
|
+
}
|
|
4630
|
+
if (field.validationMessages.minimum) {
|
|
4631
|
+
field.validationMessages.min = field.validationMessages.minimum;
|
|
4632
|
+
delete field.validationMessages.minimum;
|
|
4633
|
+
}
|
|
4634
|
+
if (field.validationMessages.maximum) {
|
|
4635
|
+
field.validationMessages.max = field.validationMessages.maximum;
|
|
4636
|
+
delete field.validationMessages.maximum;
|
|
4637
|
+
}
|
|
4638
|
+
};
|
|
4639
|
+
const getControlType = field => {
|
|
4640
|
+
if (field.control) {
|
|
4641
|
+
return field.control.toLowerCase();
|
|
4642
|
+
}
|
|
4643
|
+
if (field.hidden) {
|
|
4644
|
+
return 'hidden';
|
|
4645
|
+
}
|
|
4646
|
+
if (field.values && field.values.length > 0) {
|
|
4647
|
+
return getSelectionType(field);
|
|
4648
|
+
}
|
|
4649
|
+
switch (field.type) {
|
|
4650
|
+
case 'string':
|
|
4651
|
+
return getControlForStringFormat(field.format);
|
|
4652
|
+
case 'number':
|
|
4653
|
+
case 'integer':
|
|
4654
|
+
return 'number';
|
|
4655
|
+
case 'boolean':
|
|
4656
|
+
return 'checkbox';
|
|
4657
|
+
default:
|
|
4658
|
+
return 'text';
|
|
4659
|
+
}
|
|
4660
|
+
};
|
|
4661
|
+
const getControlForStringFormat = format => {
|
|
4662
|
+
switch (format) {
|
|
4663
|
+
case 'date':
|
|
4664
|
+
return 'date';
|
|
4665
|
+
case 'base64url':
|
|
4666
|
+
return 'file';
|
|
4667
|
+
case 'password':
|
|
4668
|
+
return 'password';
|
|
4669
|
+
case 'uri':
|
|
4670
|
+
return 'text';
|
|
4671
|
+
// 'url'; - not implemented
|
|
4672
|
+
case 'email':
|
|
4673
|
+
return 'text';
|
|
4674
|
+
// 'email'; - not implemented
|
|
4675
|
+
case 'phone':
|
|
4676
|
+
return 'tel';
|
|
4677
|
+
default:
|
|
4678
|
+
return 'text';
|
|
4679
|
+
}
|
|
4680
|
+
};
|
|
4681
|
+
const getSelectionType = field => {
|
|
4682
|
+
if (field.control) {
|
|
4683
|
+
return field.control;
|
|
4684
|
+
}
|
|
4685
|
+
if (field.type === 'select') {
|
|
4686
|
+
return 'select';
|
|
4687
|
+
}
|
|
4688
|
+
if (field.type === 'radio') {
|
|
4689
|
+
return 'radio';
|
|
4690
|
+
}
|
|
4691
|
+
if (field.values) {
|
|
4692
|
+
return field.values.length > 3 ? 'select' : 'radio';
|
|
4693
|
+
}
|
|
4694
|
+
return 'select';
|
|
4695
|
+
};
|
|
4696
|
+
const copyOf = object => JSON.parse(JSON.stringify(object));
|
|
4697
|
+
|
|
4698
|
+
const formatUsingPattern = (value = '', pattern) => {
|
|
4699
|
+
if (typeof pattern !== 'string') {
|
|
4700
|
+
return value;
|
|
4701
|
+
}
|
|
4702
|
+
let newPattern = pattern;
|
|
4703
|
+
if (newPattern.indexOf('||') > 0) {
|
|
4704
|
+
newPattern = newPattern.slice(0, Math.max(0, pattern.indexOf('||')));
|
|
4705
|
+
}
|
|
4706
|
+
let newValue = '';
|
|
4707
|
+
let separators = 0;
|
|
4708
|
+
let charactersToAllocate = value.length;
|
|
4709
|
+
let position = 0;
|
|
4710
|
+
while (charactersToAllocate) {
|
|
4711
|
+
if (positionIsSeparator(newPattern, position)) {
|
|
4712
|
+
newValue += newPattern[position];
|
|
4713
|
+
separators += 1;
|
|
4714
|
+
} else {
|
|
4715
|
+
newValue += value[position - separators];
|
|
4716
|
+
charactersToAllocate -= 1;
|
|
4717
|
+
}
|
|
4718
|
+
position += 1;
|
|
4719
|
+
}
|
|
4720
|
+
const separatorsAfterCursor = countSeparatorsAfterCursor(newPattern, position);
|
|
4721
|
+
if (separatorsAfterCursor) {
|
|
4722
|
+
newValue += newPattern.slice(position, separatorsAfterCursor);
|
|
4723
|
+
}
|
|
4724
|
+
return newValue;
|
|
4725
|
+
};
|
|
4726
|
+
const countSeparatorsAfterCursor = (newPattern, position) => {
|
|
4727
|
+
let separators = 0;
|
|
4728
|
+
while (positionIsSeparator(newPattern, position + separators)) {
|
|
4729
|
+
separators += 1;
|
|
4730
|
+
}
|
|
4731
|
+
return separators;
|
|
4732
|
+
};
|
|
4733
|
+
const positionIsSeparator = (newPattern, position) => newPattern[position] && newPattern[position] !== '*';
|
|
4734
|
+
|
|
4735
|
+
const getValueLabel = (options, value) => {
|
|
4736
|
+
const option = options.find(currentOption => currentOption.value === value);
|
|
4737
|
+
return option && option.label ? option.label : value;
|
|
4738
|
+
};
|
|
4739
|
+
|
|
4740
|
+
/**
|
|
4741
|
+
*
|
|
4742
|
+
* @param {string} value
|
|
4743
|
+
*/
|
|
4744
|
+
const mask = value => new Array(value.length + 1).join('*');
|
|
4745
|
+
const FormattedValue = ({
|
|
4746
|
+
field,
|
|
4747
|
+
value
|
|
4748
|
+
}) => {
|
|
4749
|
+
const {
|
|
4750
|
+
locale
|
|
4751
|
+
} = reactIntl.useIntl();
|
|
4752
|
+
const style = [];
|
|
4753
|
+
if (field.tagClassName && field.tagClassName.h3) {
|
|
4754
|
+
style.push('np-text-body-large-bold');
|
|
4755
|
+
style.push('formatted-value__h3-custom-alignment');
|
|
4756
|
+
}
|
|
4757
|
+
switch (field.control) {
|
|
4758
|
+
case 'select':
|
|
4759
|
+
case 'radio':
|
|
4760
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4761
|
+
children: getValueLabel(field.values, value)
|
|
4762
|
+
});
|
|
4763
|
+
case 'date':
|
|
4764
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4765
|
+
children: formatting.formatDate(value instanceof Date ? value : new Date(value), locale)
|
|
4766
|
+
});
|
|
4767
|
+
case 'number':
|
|
4768
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4769
|
+
children: formatting.formatNumber(value, locale)
|
|
4770
|
+
});
|
|
4771
|
+
case 'password':
|
|
4772
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4773
|
+
children: mask(value)
|
|
4774
|
+
});
|
|
4775
|
+
case 'file':
|
|
4776
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4777
|
+
className: "thumbnail",
|
|
4778
|
+
children: /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
4779
|
+
alt: field.title,
|
|
4780
|
+
src: value
|
|
4781
|
+
})
|
|
4782
|
+
});
|
|
4783
|
+
case 'checkbox':
|
|
4784
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4785
|
+
children: JSON.stringify(value)
|
|
4786
|
+
});
|
|
4787
|
+
default:
|
|
4788
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4789
|
+
className: classNames__default.default(style),
|
|
4790
|
+
children: formatUsingPattern(value, field.displayFormat)
|
|
4791
|
+
});
|
|
4792
|
+
}
|
|
4793
|
+
};
|
|
4794
|
+
FormattedValue.propTypes = {
|
|
4795
|
+
field: PropTypes__default.default.shape({
|
|
4796
|
+
control: PropTypes__default.default.string.isRequired,
|
|
4797
|
+
displayFormat: PropTypes__default.default.string,
|
|
4798
|
+
refreshRequirementsOnChange: PropTypes__default.default.bool,
|
|
4799
|
+
title: PropTypes__default.default.string.isRequired,
|
|
4800
|
+
type: PropTypes__default.default.string.isRequired,
|
|
4801
|
+
width: PropTypes__default.default.string,
|
|
4802
|
+
tagClassName: PropTypes__default.default.shape({
|
|
4803
|
+
h3: PropTypes__default.default.bool
|
|
4804
|
+
}),
|
|
4805
|
+
values: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
4806
|
+
value: PropTypes__default.default.any
|
|
4807
|
+
}))
|
|
4808
|
+
}).isRequired,
|
|
4809
|
+
value: PropTypes__default.default.any.isRequired
|
|
4810
|
+
};
|
|
4811
|
+
var FormattedValue$1 = FormattedValue;
|
|
4812
|
+
|
|
4813
|
+
function createDefinitions(fields, model) {
|
|
4814
|
+
return toPairs__default.default(fields).map(([name, field]) => createDefinition(name, field, model)).filter(definition => !!definition);
|
|
4815
|
+
}
|
|
4816
|
+
function createDefinition(name, field, model) {
|
|
4817
|
+
const {
|
|
4818
|
+
title,
|
|
4819
|
+
group,
|
|
4820
|
+
hidden
|
|
4821
|
+
} = field;
|
|
4822
|
+
if (!model[name] || hidden) {
|
|
4823
|
+
return null;
|
|
4824
|
+
}
|
|
4825
|
+
return {
|
|
4826
|
+
title,
|
|
4827
|
+
value: group ? group.map((groupField, groupFieldIndex) => /*#__PURE__*/jsxRuntime.jsx(FormattedValue$1, {
|
|
4828
|
+
// eslint-disable-line react/no-array-index-key
|
|
4829
|
+
field: groupField,
|
|
4830
|
+
value: model[name]
|
|
4831
|
+
}, groupFieldIndex)) : /*#__PURE__*/jsxRuntime.jsx(FormattedValue$1, {
|
|
4832
|
+
field: field,
|
|
4833
|
+
value: model[name]
|
|
4834
|
+
}),
|
|
4835
|
+
key: name
|
|
4836
|
+
};
|
|
4837
|
+
}
|
|
4838
|
+
|
|
4839
|
+
const DynamicFieldDefinitionList = ({
|
|
4840
|
+
model,
|
|
4841
|
+
title,
|
|
4842
|
+
layout,
|
|
4843
|
+
fields
|
|
4844
|
+
}) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
4845
|
+
children: [title && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4846
|
+
className: "m-t-1 m-b-3",
|
|
4847
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
4848
|
+
type: exports.Typography.TITLE_BODY,
|
|
4849
|
+
className: "p-t-3",
|
|
4850
|
+
children: title
|
|
4851
|
+
})
|
|
4852
|
+
}), /*#__PURE__*/jsxRuntime.jsx(DefinitionList$1, {
|
|
4853
|
+
layout: layout,
|
|
4854
|
+
definitions: createDefinitions(prepFields(fields), model)
|
|
4855
|
+
})]
|
|
4856
|
+
});
|
|
4857
|
+
DynamicFieldDefinitionList.propTypes = {
|
|
4858
|
+
model: PropTypes__default.default.shape({}).isRequired,
|
|
4859
|
+
fields: PropTypes__default.default.shape({}).isRequired,
|
|
4860
|
+
title: PropTypes__default.default.string,
|
|
4861
|
+
layout: PropTypes__default.default.oneOf(['VERTICAL_TWO_COLUMN', 'VERTICAL_ONE_COLUMN', 'HORIZONTAL_JUSTIFIED', 'HORIZONTAL_LEFT_ALIGNED'])
|
|
4862
|
+
};
|
|
4863
|
+
DynamicFieldDefinitionList.defaultProps = {
|
|
4864
|
+
title: null,
|
|
4865
|
+
layout: exports.Layout.VERTICAL_TWO_COLUMN
|
|
4866
|
+
};
|
|
4867
|
+
var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
|
|
4868
|
+
|
|
4360
4869
|
const ESCAPED_OPENING_CHEVRON = '<';
|
|
4361
4870
|
const ESCAPED_CLOSING_CHEVRON = '>';
|
|
4362
4871
|
class EmphasisHtmlTransformer {
|
|
@@ -4697,7 +5206,6 @@ const Tooltip = ({
|
|
|
4697
5206
|
|
|
4698
5207
|
function supportsTouchEvents() {
|
|
4699
5208
|
const onTouchStartIsDefined = typeof window !== 'undefined' && window.ontouchstart !== undefined;
|
|
4700
|
-
// eslint-disable-next-line compat/compat
|
|
4701
5209
|
const maxTouchPointsIsDefined = typeof navigator !== 'undefined' && navigator.maxTouchPoints;
|
|
4702
5210
|
const documentTouchIsDefined = typeof window !== 'undefined' && window.DocumentTouch && document instanceof window.DocumentTouch;
|
|
4703
5211
|
return !!(onTouchStartIsDefined || maxTouchPointsIsDefined || documentTouchIsDefined);
|
|
@@ -4705,7 +5213,7 @@ function supportsTouchEvents() {
|
|
|
4705
5213
|
function userAgentSuggestsTouchDevice() {
|
|
4706
5214
|
const sampleTouchDevices = ['android', 'iemobile', 'iphone', 'ipad', 'ipod', 'blackberry', 'bada'];
|
|
4707
5215
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
4708
|
-
const regex = new RegExp(matchString, '
|
|
5216
|
+
const regex = new RegExp(matchString, 'gi');
|
|
4709
5217
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
4710
5218
|
}
|
|
4711
5219
|
// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
|
|
@@ -5111,8 +5619,9 @@ function resolvePlacement(preferredPlacement) {
|
|
|
5111
5619
|
case 'bottom-left':
|
|
5112
5620
|
case 'bottom-right':
|
|
5113
5621
|
return 'bottom';
|
|
5622
|
+
default:
|
|
5623
|
+
return preferredPlacement;
|
|
5114
5624
|
}
|
|
5115
|
-
return preferredPlacement;
|
|
5116
5625
|
}
|
|
5117
5626
|
function Popover$1({
|
|
5118
5627
|
children,
|
|
@@ -6675,7 +7184,6 @@ const Loader = ({
|
|
|
6675
7184
|
}, 1000);
|
|
6676
7185
|
}
|
|
6677
7186
|
return () => {
|
|
6678
|
-
// eslint-disable-next-line fp/no-mutation
|
|
6679
7187
|
cancelled = true;
|
|
6680
7188
|
clearTimeout(timeout);
|
|
6681
7189
|
};
|
|
@@ -8612,7 +9120,7 @@ const explodeNumberModel = number => {
|
|
|
8612
9120
|
};
|
|
8613
9121
|
};
|
|
8614
9122
|
|
|
8615
|
-
const DIGITS_MATCH = /^$|^(\+)|(
|
|
9123
|
+
const DIGITS_MATCH = /^$|^(\+)|(\d+)/g;
|
|
8616
9124
|
const cleanNumber = number => number.match(DIGITS_MATCH)?.join('') ?? '';
|
|
8617
9125
|
|
|
8618
9126
|
function sortArrayByProperty(arrayToSort, property) {
|
|
@@ -8698,7 +9206,8 @@ const PhoneNumberInput = ({
|
|
|
8698
9206
|
};
|
|
8699
9207
|
React.useEffect(() => {
|
|
8700
9208
|
if (broadcastedValue === null) {
|
|
8701
|
-
|
|
9209
|
+
setBroadcastedValue(internalValue);
|
|
9210
|
+
return;
|
|
8702
9211
|
}
|
|
8703
9212
|
const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;
|
|
8704
9213
|
const broadcastedPhoneNumber = `${broadcastedValue.prefix ?? ''}${broadcastedValue.suffix}`;
|
|
@@ -8971,7 +9480,7 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
|
|
|
8971
9480
|
const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
|
|
8972
9481
|
...commonProps,
|
|
8973
9482
|
'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
|
|
8974
|
-
'aria-describedby': `${componentId}-title
|
|
9483
|
+
'aria-describedby': `${componentId}-title`,
|
|
8975
9484
|
'aria-disabled': isDisabled,
|
|
8976
9485
|
'data-value': value ?? undefined,
|
|
8977
9486
|
role: type === 'checkbox' || type === 'radio' ? type : undefined,
|
|
@@ -9624,8 +10133,8 @@ function Select({
|
|
|
9624
10133
|
}
|
|
9625
10134
|
};
|
|
9626
10135
|
function selectKeyboardFocusedOption() {
|
|
9627
|
-
if (keyboardFocusedOptionIndex != null) {
|
|
9628
|
-
|
|
10136
|
+
if (keyboardFocusedOptionIndex != null && selectableOptions.length > 0) {
|
|
10137
|
+
selectOption(selectableOptions[keyboardFocusedOptionIndex]);
|
|
9629
10138
|
}
|
|
9630
10139
|
}
|
|
9631
10140
|
function moveFocusWithDifference(difference) {
|
|
@@ -9852,7 +10361,6 @@ function Select({
|
|
|
9852
10361
|
disabled: disabled,
|
|
9853
10362
|
"aria-controls": listboxId,
|
|
9854
10363
|
"aria-expanded": open,
|
|
9855
|
-
"aria-autocomplete": "none",
|
|
9856
10364
|
onClick: handleOnClick,
|
|
9857
10365
|
...buttonProps,
|
|
9858
10366
|
children: [selected ? /*#__PURE__*/jsxRuntime.jsx(Option$1, {
|
|
@@ -14393,6 +14901,7 @@ exports.DirectionProvider = DirectionProvider;
|
|
|
14393
14901
|
exports.Display = Display;
|
|
14394
14902
|
exports.Drawer = Drawer$1;
|
|
14395
14903
|
exports.DropFade = DropFade;
|
|
14904
|
+
exports.DynamicFieldDefinitionList = DynamicFieldDefinitionList$1;
|
|
14396
14905
|
exports.Emphasis = Emphasis;
|
|
14397
14906
|
exports.FlowNavigation = FlowNavigation;
|
|
14398
14907
|
exports.Header = Header;
|