@transferwise/components 46.28.0 → 46.29.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/build/index.js +130 -630
- package/build/index.js.map +1 -1
- package/build/index.mjs +132 -630
- package/build/index.mjs.map +1 -1
- package/build/main.css +16 -5
- package/build/styles/logo/Logo.css +16 -0
- package/build/styles/main.css +16 -5
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/index.d.ts +0 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/inputs/_Popover.d.ts.map +1 -1
- package/build/types/loader/Loader.d.ts.map +1 -1
- package/build/types/logo/Logo.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/segmentedControl/SegmentedControl.d.ts +2 -2
- package/build/types/segmentedControl/SegmentedControl.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/index.ts +0 -1
- package/src/inlineAlert/InlineAlert.story.tsx +8 -7
- package/src/inputs/SelectInput.tsx +1 -0
- package/src/inputs/_BottomSheet.tsx +33 -28
- package/src/inputs/_Popover.tsx +23 -20
- package/src/link/Link.story.tsx +16 -16
- package/src/loader/Loader.tsx +0 -1
- package/src/logo/Logo.css +16 -0
- package/src/logo/Logo.js +4 -9
- package/src/logo/Logo.less +16 -0
- package/src/logo/__snapshots__/Logo.spec.js.snap +104 -8
- package/src/main.css +16 -5
- package/src/main.less +0 -1
- 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 +88 -2
- package/src/segmentedControl/SegmentedControl.story.tsx +54 -16
- package/src/segmentedControl/SegmentedControl.tsx +21 -33
- 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/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +0 -5
- package/build/types/common/requirements.d.ts +0 -3
- package/build/types/common/requirements.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts +0 -21
- package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts +0 -12
- package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts +0 -2
- package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/index.d.ts +0 -2
- package/build/types/dynamicFieldDefinitionList/index.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts +0 -2
- package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts.map +0 -1
- package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts +0 -2
- package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts.map +0 -1
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +0 -41
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.spec.js +0 -21
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.story.js +0 -134
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +0 -5
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +0 -73
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.less +0 -4
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.spec.js +0 -200
- package/src/dynamicFieldDefinitionList/FormattedValue/index.js +0 -1
- package/src/dynamicFieldDefinitionList/index.js +0 -1
- package/src/dynamicFieldDefinitionList/utils/createDefinitions.js +0 -33
- package/src/dynamicFieldDefinitionList/utils/createDefinitions.spec.js +0 -83
- package/src/dynamicFieldDefinitionList/utils/text-format.js +0 -46
- package/src/dynamicFieldDefinitionList/utils/text-format.spec.js +0 -43
package/build/index.js
CHANGED
|
@@ -14,18 +14,17 @@ var react$1 = require('@headlessui/react');
|
|
|
14
14
|
var mergeProps = require('merge-props');
|
|
15
15
|
var index_js = require('use-sync-external-store/shim/index.js');
|
|
16
16
|
var react = require('@floating-ui/react');
|
|
17
|
+
var focus = require('@react-aria/focus');
|
|
17
18
|
var overlays = require('@react-aria/overlays');
|
|
18
19
|
var reactTransitionGroup = require('react-transition-group');
|
|
19
20
|
var neptuneValidation = require('@transferwise/neptune-validation');
|
|
20
21
|
var reactDom = require('react-dom');
|
|
21
|
-
var focus = require('@react-aria/focus');
|
|
22
22
|
var reactPopper = require('react-popper');
|
|
23
23
|
var throttle = require('lodash.throttle');
|
|
24
24
|
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');
|
|
29
28
|
var web = require('@react-spring/web');
|
|
30
29
|
|
|
31
30
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -57,7 +56,6 @@ var throttle__default = /*#__PURE__*/_interopDefault(throttle);
|
|
|
57
56
|
var clamp__default = /*#__PURE__*/_interopDefault(clamp$2);
|
|
58
57
|
var debounce__default = /*#__PURE__*/_interopDefault(debounce);
|
|
59
58
|
var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
|
|
60
|
-
var toPairs__default = /*#__PURE__*/_interopDefault(toPairs);
|
|
61
59
|
|
|
62
60
|
class HistoryNavigator {
|
|
63
61
|
constructor(history = [], historyLimit = null) {
|
|
@@ -95,7 +93,7 @@ var HistoryNavigator$1 = HistoryNavigator;
|
|
|
95
93
|
function isIosDevice() {
|
|
96
94
|
const sampleTouchDevices = ['iphone', 'ipad', 'ipod'];
|
|
97
95
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
98
|
-
const regex = new RegExp(matchString, '
|
|
96
|
+
const regex = new RegExp(matchString, 'gi');
|
|
99
97
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
100
98
|
}
|
|
101
99
|
|
|
@@ -941,8 +939,9 @@ function resolveType(type) {
|
|
|
941
939
|
return 'neutral';
|
|
942
940
|
case 'error':
|
|
943
941
|
return 'negative';
|
|
942
|
+
default:
|
|
943
|
+
return type;
|
|
944
944
|
}
|
|
945
|
-
return type;
|
|
946
945
|
}
|
|
947
946
|
function Alert({
|
|
948
947
|
arrow,
|
|
@@ -1088,7 +1087,7 @@ const hashSeed = seed => {
|
|
|
1088
1087
|
const modulo = avatarColors.length;
|
|
1089
1088
|
let hashValue = 0;
|
|
1090
1089
|
let basePow = 1;
|
|
1091
|
-
for (let i = 0; i < seed.length; i
|
|
1090
|
+
for (let i = 0; i < seed.length; i += 1) {
|
|
1092
1091
|
hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;
|
|
1093
1092
|
basePow = basePow * base % modulo;
|
|
1094
1093
|
}
|
|
@@ -1380,11 +1379,15 @@ const Dimmer = ({
|
|
|
1380
1379
|
}, [onClose]);
|
|
1381
1380
|
const onEnter = () => {
|
|
1382
1381
|
setHasNotExited(true);
|
|
1383
|
-
|
|
1382
|
+
if (dimmerReference.current) {
|
|
1383
|
+
dimmerManager.add(dimmerReference.current);
|
|
1384
|
+
}
|
|
1384
1385
|
};
|
|
1385
1386
|
const onExited = () => {
|
|
1386
1387
|
setHasNotExited(false);
|
|
1387
|
-
|
|
1388
|
+
if (dimmerReference.current) {
|
|
1389
|
+
dimmerManager.remove(dimmerReference.current);
|
|
1390
|
+
}
|
|
1388
1391
|
};
|
|
1389
1392
|
React.useEffect(() => {
|
|
1390
1393
|
const localReferenceCopy = dimmerReference.current;
|
|
@@ -4359,508 +4362,6 @@ const DropFade = ({
|
|
|
4359
4362
|
});
|
|
4360
4363
|
};
|
|
4361
4364
|
|
|
4362
|
-
/* eslint-disable no-unused-vars */
|
|
4363
|
-
/* eslint-disable no-param-reassign */
|
|
4364
|
-
|
|
4365
|
-
const prepFields = (fields, model, validationMessages) => {
|
|
4366
|
-
if (!fields) {
|
|
4367
|
-
return {};
|
|
4368
|
-
}
|
|
4369
|
-
let preparedFields = copyOf(fields);
|
|
4370
|
-
preparedFields = flattenFieldsWithGroups(preparedFields);
|
|
4371
|
-
preparedFields = transformFieldArrayToMap(preparedFields);
|
|
4372
|
-
preparedFields = transformNestedKeysToNestedSpecs(preparedFields);
|
|
4373
|
-
Object.keys(preparedFields).forEach(key => {
|
|
4374
|
-
preparedFields[key] = prepField(preparedFields[key], model, validationMessages);
|
|
4375
|
-
});
|
|
4376
|
-
return preparedFields;
|
|
4377
|
-
};
|
|
4378
|
-
const prepField = (field, model, validationMessages) => {
|
|
4379
|
-
const preparedField = copyOf(field);
|
|
4380
|
-
prepLegacyProps(preparedField);
|
|
4381
|
-
prepType(preparedField);
|
|
4382
|
-
prepPattern(preparedField);
|
|
4383
|
-
prepValidationMessages(preparedField, validationMessages);
|
|
4384
|
-
return preparedField;
|
|
4385
|
-
};
|
|
4386
|
-
|
|
4387
|
-
/**
|
|
4388
|
-
* In an older format we had an extra fieldGroup level, here we flatten that out
|
|
4389
|
-
* So the inner arrays of fields within the different field groups are flattened
|
|
4390
|
-
* to a single array, which is returned.
|
|
4391
|
-
*
|
|
4392
|
-
* @param fields
|
|
4393
|
-
*/
|
|
4394
|
-
const flattenFieldsWithGroups = fields => {
|
|
4395
|
-
if (Array.isArray(fields)) {
|
|
4396
|
-
let flattenedFields = [];
|
|
4397
|
-
fields.forEach(field => {
|
|
4398
|
-
// If we've been given a group with nested fields, break them out.
|
|
4399
|
-
if (field.fields) {
|
|
4400
|
-
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.fields));
|
|
4401
|
-
} else if (field.group) {
|
|
4402
|
-
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.group));
|
|
4403
|
-
} else {
|
|
4404
|
-
// Otherwise it's a regular field, just add it.
|
|
4405
|
-
flattenedFields.push(field);
|
|
4406
|
-
}
|
|
4407
|
-
});
|
|
4408
|
-
return flattenedFields;
|
|
4409
|
-
}
|
|
4410
|
-
return fields;
|
|
4411
|
-
};
|
|
4412
|
-
const flattenFieldWithGroup = (field, subFields) => {
|
|
4413
|
-
// If first field doesn't have a label, use the one from the group
|
|
4414
|
-
if (field.name && subFields.length > 0 && !subFields[0].name) {
|
|
4415
|
-
subFields[0].name = field.name;
|
|
4416
|
-
}
|
|
4417
|
-
if (field.width && subFields.length > 0 && !subFields[0].width) {
|
|
4418
|
-
subFields[0].width = field.width;
|
|
4419
|
-
}
|
|
4420
|
-
|
|
4421
|
-
// If there was a tooltip at fieldGroup level move it to first field.
|
|
4422
|
-
if (field.tooltip && subFields.length > 0 && !subFields[0].help) {
|
|
4423
|
-
subFields[0].help = {
|
|
4424
|
-
message: field.tooltip
|
|
4425
|
-
};
|
|
4426
|
-
}
|
|
4427
|
-
if (field.info && subFields.length > 0 && !subFields[0].help) {
|
|
4428
|
-
subFields[0].help = {
|
|
4429
|
-
message: field.info
|
|
4430
|
-
};
|
|
4431
|
-
}
|
|
4432
|
-
|
|
4433
|
-
// If there are two parts of this group, render them side by side
|
|
4434
|
-
if (subFields.length === 2) {
|
|
4435
|
-
subFields.forEach(nestedField => {
|
|
4436
|
-
nestedField.width = 'md';
|
|
4437
|
-
});
|
|
4438
|
-
}
|
|
4439
|
-
|
|
4440
|
-
// If there are three parts, render the first two side by side
|
|
4441
|
-
if (subFields.length === 3) {
|
|
4442
|
-
subFields[0].width = 'md';
|
|
4443
|
-
subFields[1].width = 'md';
|
|
4444
|
-
}
|
|
4445
|
-
return subFields;
|
|
4446
|
-
};
|
|
4447
|
-
|
|
4448
|
-
/*
|
|
4449
|
-
* Some older requirements return an array of fields, where it should be a map
|
|
4450
|
-
* from the property name to the spec. This converts arrays to maps.
|
|
4451
|
-
*/
|
|
4452
|
-
const transformFieldArrayToMap = fields => {
|
|
4453
|
-
if (Array.isArray(fields)) {
|
|
4454
|
-
const fieldMap = {};
|
|
4455
|
-
fields.forEach(field => {
|
|
4456
|
-
const key = field.key || field.name;
|
|
4457
|
-
delete field.key;
|
|
4458
|
-
fieldMap[key] = copyOf(field);
|
|
4459
|
-
});
|
|
4460
|
-
return fieldMap;
|
|
4461
|
-
}
|
|
4462
|
-
return fields;
|
|
4463
|
-
};
|
|
4464
|
-
|
|
4465
|
-
/*
|
|
4466
|
-
* Some older format return keys like 'address.city', expecting the value of
|
|
4467
|
-
* city to be nested inside an address object. This function creates a spec of
|
|
4468
|
-
* type 'object', and nests such fields inside of it. When we render we pass
|
|
4469
|
-
* this object spec to a nested fieldset.
|
|
4470
|
-
*/
|
|
4471
|
-
const transformNestedKeysToNestedSpecs = fieldMap => {
|
|
4472
|
-
if (Array.isArray(fieldMap)) {
|
|
4473
|
-
throw new TypeError('Expecting a map of fields, not an array');
|
|
4474
|
-
}
|
|
4475
|
-
const nestedFields = {};
|
|
4476
|
-
Object.keys(fieldMap).forEach(key => {
|
|
4477
|
-
if (key.indexOf('.') > 0) {
|
|
4478
|
-
// If the key contains a period we need to nest the fields in another object
|
|
4479
|
-
const pathSections = key.split('.');
|
|
4480
|
-
const nestedKey = pathSections[0];
|
|
4481
|
-
|
|
4482
|
-
// If this sub object doesn't exist yet, create it
|
|
4483
|
-
if (!nestedFields[nestedKey]) {
|
|
4484
|
-
nestedFields[nestedKey] = {
|
|
4485
|
-
type: 'object',
|
|
4486
|
-
properties: {}
|
|
4487
|
-
};
|
|
4488
|
-
}
|
|
4489
|
-
nestedFields[nestedKey].properties[pathSections[1]] = fieldMap[key];
|
|
4490
|
-
} else {
|
|
4491
|
-
nestedFields[key] = fieldMap[key];
|
|
4492
|
-
}
|
|
4493
|
-
});
|
|
4494
|
-
return nestedFields;
|
|
4495
|
-
};
|
|
4496
|
-
const prepType = field => {
|
|
4497
|
-
const type = field.type && field.type.toLowerCase && field.type.toLowerCase();
|
|
4498
|
-
switch (type) {
|
|
4499
|
-
case 'text':
|
|
4500
|
-
field.type = 'string';
|
|
4501
|
-
break;
|
|
4502
|
-
case 'date':
|
|
4503
|
-
field.type = 'string';
|
|
4504
|
-
field.format = 'date';
|
|
4505
|
-
break;
|
|
4506
|
-
case 'password':
|
|
4507
|
-
field.type = 'string';
|
|
4508
|
-
field.control = 'password';
|
|
4509
|
-
break;
|
|
4510
|
-
case 'checkbox':
|
|
4511
|
-
field.type = 'boolean';
|
|
4512
|
-
break;
|
|
4513
|
-
case 'select':
|
|
4514
|
-
if (!field.control) {
|
|
4515
|
-
field.control = 'select';
|
|
4516
|
-
}
|
|
4517
|
-
delete field.type;
|
|
4518
|
-
break;
|
|
4519
|
-
case 'radio':
|
|
4520
|
-
field.control = 'radio';
|
|
4521
|
-
delete field.type;
|
|
4522
|
-
break;
|
|
4523
|
-
case 'upload':
|
|
4524
|
-
field.type = 'string';
|
|
4525
|
-
field.format = 'base64url';
|
|
4526
|
-
break;
|
|
4527
|
-
case 'tel':
|
|
4528
|
-
field.type = 'string';
|
|
4529
|
-
field.format = 'phone';
|
|
4530
|
-
break;
|
|
4531
|
-
case 'textarea':
|
|
4532
|
-
field.type = 'string';
|
|
4533
|
-
field.control = 'textarea';
|
|
4534
|
-
break;
|
|
4535
|
-
}
|
|
4536
|
-
if (!field.control && field.type !== 'object') {
|
|
4537
|
-
field.control = getControlType(field);
|
|
4538
|
-
}
|
|
4539
|
-
};
|
|
4540
|
-
const prepLegacyProps = field => {
|
|
4541
|
-
if (field.name && !field.title) {
|
|
4542
|
-
field.title = field.name;
|
|
4543
|
-
delete field.name;
|
|
4544
|
-
}
|
|
4545
|
-
if (field.validationRegexp) {
|
|
4546
|
-
field.pattern = field.validationRegexp;
|
|
4547
|
-
delete field.validationRegexp;
|
|
4548
|
-
}
|
|
4549
|
-
if (field.min) {
|
|
4550
|
-
field.minimum = field.min;
|
|
4551
|
-
delete field.min;
|
|
4552
|
-
}
|
|
4553
|
-
if (field.max) {
|
|
4554
|
-
field.maximum = field.max;
|
|
4555
|
-
delete field.max;
|
|
4556
|
-
}
|
|
4557
|
-
if (field.example && !field.placeholder) {
|
|
4558
|
-
field.placeholder = field.example;
|
|
4559
|
-
delete field.example;
|
|
4560
|
-
}
|
|
4561
|
-
if (field.tooltip && !field.help) {
|
|
4562
|
-
field.help = {
|
|
4563
|
-
message: field.tooltip
|
|
4564
|
-
};
|
|
4565
|
-
delete field.tooltip;
|
|
4566
|
-
}
|
|
4567
|
-
if (field.valuesAllowed && !field.values) {
|
|
4568
|
-
field.values = field.valuesAllowed;
|
|
4569
|
-
delete field.valuesAllowed;
|
|
4570
|
-
}
|
|
4571
|
-
if (field.values && field.values.map) {
|
|
4572
|
-
field.values = prepLegacyValues(field.values);
|
|
4573
|
-
}
|
|
4574
|
-
if (field.value && !field.default) {
|
|
4575
|
-
field.default = field.value;
|
|
4576
|
-
delete field.value;
|
|
4577
|
-
}
|
|
4578
|
-
if (field.values) {
|
|
4579
|
-
// In some legacy arrays the first value is a placeholder, extract it.
|
|
4580
|
-
if (field.values && field.values.length > 0 && field.values[0] && !field.values[0].value && field.values[0].label && !field.placeholder) {
|
|
4581
|
-
field.placeholder = field.values[0].label;
|
|
4582
|
-
field.values = field.values.slice(1);
|
|
4583
|
-
}
|
|
4584
|
-
}
|
|
4585
|
-
};
|
|
4586
|
-
const prepLegacyValues = values => values.map(prepLegacyValue);
|
|
4587
|
-
const prepLegacyValue = value => {
|
|
4588
|
-
if (!value.label && value.title) {
|
|
4589
|
-
value.label = value.title;
|
|
4590
|
-
delete value.title;
|
|
4591
|
-
}
|
|
4592
|
-
if (!value.label && value.name) {
|
|
4593
|
-
value.label = value.name;
|
|
4594
|
-
delete value.name;
|
|
4595
|
-
}
|
|
4596
|
-
if (!value.value && value.code) {
|
|
4597
|
-
value.value = value.code;
|
|
4598
|
-
delete value.code;
|
|
4599
|
-
}
|
|
4600
|
-
if (!value.value && value.key) {
|
|
4601
|
-
value.value = value.key;
|
|
4602
|
-
delete value.key;
|
|
4603
|
-
}
|
|
4604
|
-
return value;
|
|
4605
|
-
};
|
|
4606
|
-
const prepPattern = field => {
|
|
4607
|
-
if (field.pattern) {
|
|
4608
|
-
try {
|
|
4609
|
-
new RegExp(field.pattern);
|
|
4610
|
-
} catch {
|
|
4611
|
-
// eslint-disable-next-line no-console
|
|
4612
|
-
console.warn('API regexp is invalid');
|
|
4613
|
-
delete field.pattern;
|
|
4614
|
-
}
|
|
4615
|
-
} else {
|
|
4616
|
-
delete field.pattern;
|
|
4617
|
-
}
|
|
4618
|
-
};
|
|
4619
|
-
const prepValidationMessages = (field, validationMessages) => {
|
|
4620
|
-
field.validationMessages = field.validationMessages ? field.validationMessages : validationMessages;
|
|
4621
|
-
if (!field.validationMessages) {
|
|
4622
|
-
delete field.validationMessages;
|
|
4623
|
-
return;
|
|
4624
|
-
}
|
|
4625
|
-
if (field.validationMessages.minimum) {
|
|
4626
|
-
field.validationMessages.min = field.validationMessages.minimum;
|
|
4627
|
-
delete field.validationMessages.minimum;
|
|
4628
|
-
}
|
|
4629
|
-
if (field.validationMessages.maximum) {
|
|
4630
|
-
field.validationMessages.max = field.validationMessages.maximum;
|
|
4631
|
-
delete field.validationMessages.maximum;
|
|
4632
|
-
}
|
|
4633
|
-
};
|
|
4634
|
-
const getControlType = field => {
|
|
4635
|
-
if (field.control) {
|
|
4636
|
-
return field.control.toLowerCase();
|
|
4637
|
-
}
|
|
4638
|
-
if (field.hidden) {
|
|
4639
|
-
return 'hidden';
|
|
4640
|
-
}
|
|
4641
|
-
if (field.values && field.values.length > 0) {
|
|
4642
|
-
return getSelectionType(field);
|
|
4643
|
-
}
|
|
4644
|
-
switch (field.type) {
|
|
4645
|
-
case 'string':
|
|
4646
|
-
return getControlForStringFormat(field.format);
|
|
4647
|
-
case 'number':
|
|
4648
|
-
case 'integer':
|
|
4649
|
-
return 'number';
|
|
4650
|
-
case 'boolean':
|
|
4651
|
-
return 'checkbox';
|
|
4652
|
-
default:
|
|
4653
|
-
return 'text';
|
|
4654
|
-
}
|
|
4655
|
-
};
|
|
4656
|
-
const getControlForStringFormat = format => {
|
|
4657
|
-
switch (format) {
|
|
4658
|
-
case 'date':
|
|
4659
|
-
return 'date';
|
|
4660
|
-
case 'base64url':
|
|
4661
|
-
return 'file';
|
|
4662
|
-
case 'password':
|
|
4663
|
-
return 'password';
|
|
4664
|
-
case 'uri':
|
|
4665
|
-
return 'text';
|
|
4666
|
-
// 'url'; - not implemented
|
|
4667
|
-
case 'email':
|
|
4668
|
-
return 'text';
|
|
4669
|
-
// 'email'; - not implemented
|
|
4670
|
-
case 'phone':
|
|
4671
|
-
return 'tel';
|
|
4672
|
-
default:
|
|
4673
|
-
return 'text';
|
|
4674
|
-
}
|
|
4675
|
-
};
|
|
4676
|
-
const getSelectionType = field => {
|
|
4677
|
-
if (field.control) {
|
|
4678
|
-
return field.control;
|
|
4679
|
-
}
|
|
4680
|
-
if (field.type === 'select') {
|
|
4681
|
-
return 'select';
|
|
4682
|
-
}
|
|
4683
|
-
if (field.type === 'radio') {
|
|
4684
|
-
return 'radio';
|
|
4685
|
-
}
|
|
4686
|
-
if (field.values) {
|
|
4687
|
-
return field.values.length > 3 ? 'select' : 'radio';
|
|
4688
|
-
}
|
|
4689
|
-
return 'select';
|
|
4690
|
-
};
|
|
4691
|
-
const copyOf = object => JSON.parse(JSON.stringify(object));
|
|
4692
|
-
|
|
4693
|
-
const formatUsingPattern = (value = '', pattern) => {
|
|
4694
|
-
if (typeof pattern !== 'string') {
|
|
4695
|
-
return value;
|
|
4696
|
-
}
|
|
4697
|
-
let newPattern = pattern;
|
|
4698
|
-
if (newPattern.indexOf('||') > 0) {
|
|
4699
|
-
newPattern = newPattern.slice(0, Math.max(0, pattern.indexOf('||')));
|
|
4700
|
-
}
|
|
4701
|
-
let newValue = '';
|
|
4702
|
-
let separators = 0;
|
|
4703
|
-
let charactersToAllocate = value.length;
|
|
4704
|
-
let position = 0;
|
|
4705
|
-
while (charactersToAllocate) {
|
|
4706
|
-
if (positionIsSeparator(newPattern, position)) {
|
|
4707
|
-
newValue += newPattern[position];
|
|
4708
|
-
separators += 1;
|
|
4709
|
-
} else {
|
|
4710
|
-
newValue += value[position - separators];
|
|
4711
|
-
charactersToAllocate -= 1;
|
|
4712
|
-
}
|
|
4713
|
-
position += 1;
|
|
4714
|
-
}
|
|
4715
|
-
const separatorsAfterCursor = countSeparatorsAfterCursor(newPattern, position);
|
|
4716
|
-
if (separatorsAfterCursor) {
|
|
4717
|
-
newValue += newPattern.slice(position, separatorsAfterCursor);
|
|
4718
|
-
}
|
|
4719
|
-
return newValue;
|
|
4720
|
-
};
|
|
4721
|
-
const countSeparatorsAfterCursor = (newPattern, position) => {
|
|
4722
|
-
let separators = 0;
|
|
4723
|
-
while (positionIsSeparator(newPattern, position + separators)) {
|
|
4724
|
-
separators += 1;
|
|
4725
|
-
}
|
|
4726
|
-
return separators;
|
|
4727
|
-
};
|
|
4728
|
-
const positionIsSeparator = (newPattern, position) => newPattern[position] && newPattern[position] !== '*';
|
|
4729
|
-
|
|
4730
|
-
const getValueLabel = (options, value) => {
|
|
4731
|
-
const option = options.find(currentOption => currentOption.value === value);
|
|
4732
|
-
return option && option.label ? option.label : value;
|
|
4733
|
-
};
|
|
4734
|
-
|
|
4735
|
-
/**
|
|
4736
|
-
*
|
|
4737
|
-
* @param {string} value
|
|
4738
|
-
*/
|
|
4739
|
-
const mask = value => new Array(value.length + 1).join('*');
|
|
4740
|
-
const FormattedValue = ({
|
|
4741
|
-
field,
|
|
4742
|
-
value
|
|
4743
|
-
}) => {
|
|
4744
|
-
const {
|
|
4745
|
-
locale
|
|
4746
|
-
} = reactIntl.useIntl();
|
|
4747
|
-
const style = [];
|
|
4748
|
-
if (field.tagClassName && field.tagClassName.h3) {
|
|
4749
|
-
style.push('np-text-body-large-bold');
|
|
4750
|
-
style.push('formatted-value__h3-custom-alignment');
|
|
4751
|
-
}
|
|
4752
|
-
switch (field.control) {
|
|
4753
|
-
case 'select':
|
|
4754
|
-
case 'radio':
|
|
4755
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4756
|
-
children: getValueLabel(field.values, value)
|
|
4757
|
-
});
|
|
4758
|
-
case 'date':
|
|
4759
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4760
|
-
children: formatting.formatDate(value instanceof Date ? value : new Date(value), locale)
|
|
4761
|
-
});
|
|
4762
|
-
case 'number':
|
|
4763
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4764
|
-
children: formatting.formatNumber(value, locale)
|
|
4765
|
-
});
|
|
4766
|
-
case 'password':
|
|
4767
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4768
|
-
children: mask(value)
|
|
4769
|
-
});
|
|
4770
|
-
case 'file':
|
|
4771
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4772
|
-
className: "thumbnail",
|
|
4773
|
-
children: /*#__PURE__*/jsxRuntime.jsx("img", {
|
|
4774
|
-
alt: field.title,
|
|
4775
|
-
src: value
|
|
4776
|
-
})
|
|
4777
|
-
});
|
|
4778
|
-
case 'checkbox':
|
|
4779
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4780
|
-
children: JSON.stringify(value)
|
|
4781
|
-
});
|
|
4782
|
-
default:
|
|
4783
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
4784
|
-
className: classNames__default.default(style),
|
|
4785
|
-
children: formatUsingPattern(value, field.displayFormat)
|
|
4786
|
-
});
|
|
4787
|
-
}
|
|
4788
|
-
};
|
|
4789
|
-
FormattedValue.propTypes = {
|
|
4790
|
-
field: PropTypes__default.default.shape({
|
|
4791
|
-
control: PropTypes__default.default.string.isRequired,
|
|
4792
|
-
displayFormat: PropTypes__default.default.string,
|
|
4793
|
-
refreshRequirementsOnChange: PropTypes__default.default.bool,
|
|
4794
|
-
title: PropTypes__default.default.string.isRequired,
|
|
4795
|
-
type: PropTypes__default.default.string.isRequired,
|
|
4796
|
-
width: PropTypes__default.default.string,
|
|
4797
|
-
tagClassName: PropTypes__default.default.shape({
|
|
4798
|
-
h3: PropTypes__default.default.bool
|
|
4799
|
-
}),
|
|
4800
|
-
values: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
4801
|
-
value: PropTypes__default.default.any
|
|
4802
|
-
}))
|
|
4803
|
-
}).isRequired,
|
|
4804
|
-
value: PropTypes__default.default.any.isRequired
|
|
4805
|
-
};
|
|
4806
|
-
var FormattedValue$1 = FormattedValue;
|
|
4807
|
-
|
|
4808
|
-
function createDefinitions(fields, model) {
|
|
4809
|
-
return toPairs__default.default(fields).map(([name, field]) => createDefinition(name, field, model)).filter(definition => !!definition);
|
|
4810
|
-
}
|
|
4811
|
-
function createDefinition(name, field, model) {
|
|
4812
|
-
const {
|
|
4813
|
-
title,
|
|
4814
|
-
group,
|
|
4815
|
-
hidden
|
|
4816
|
-
} = field;
|
|
4817
|
-
if (!model[name] || hidden) {
|
|
4818
|
-
return null;
|
|
4819
|
-
}
|
|
4820
|
-
return {
|
|
4821
|
-
title,
|
|
4822
|
-
value: group ? group.map((groupField, groupFieldIndex) => /*#__PURE__*/jsxRuntime.jsx(FormattedValue$1, {
|
|
4823
|
-
// eslint-disable-line react/no-array-index-key
|
|
4824
|
-
field: groupField,
|
|
4825
|
-
value: model[name]
|
|
4826
|
-
}, groupFieldIndex)) : /*#__PURE__*/jsxRuntime.jsx(FormattedValue$1, {
|
|
4827
|
-
field: field,
|
|
4828
|
-
value: model[name]
|
|
4829
|
-
}),
|
|
4830
|
-
key: name
|
|
4831
|
-
};
|
|
4832
|
-
}
|
|
4833
|
-
|
|
4834
|
-
const DynamicFieldDefinitionList = ({
|
|
4835
|
-
model,
|
|
4836
|
-
title,
|
|
4837
|
-
layout,
|
|
4838
|
-
fields
|
|
4839
|
-
}) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
4840
|
-
children: [title && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
4841
|
-
className: "m-t-1 m-b-3",
|
|
4842
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
4843
|
-
type: exports.Typography.TITLE_BODY,
|
|
4844
|
-
className: "p-t-3",
|
|
4845
|
-
children: title
|
|
4846
|
-
})
|
|
4847
|
-
}), /*#__PURE__*/jsxRuntime.jsx(DefinitionList$1, {
|
|
4848
|
-
layout: layout,
|
|
4849
|
-
definitions: createDefinitions(prepFields(fields), model)
|
|
4850
|
-
})]
|
|
4851
|
-
});
|
|
4852
|
-
DynamicFieldDefinitionList.propTypes = {
|
|
4853
|
-
model: PropTypes__default.default.shape({}).isRequired,
|
|
4854
|
-
fields: PropTypes__default.default.shape({}).isRequired,
|
|
4855
|
-
title: PropTypes__default.default.string,
|
|
4856
|
-
layout: PropTypes__default.default.oneOf(['VERTICAL_TWO_COLUMN', 'VERTICAL_ONE_COLUMN', 'HORIZONTAL_JUSTIFIED', 'HORIZONTAL_LEFT_ALIGNED'])
|
|
4857
|
-
};
|
|
4858
|
-
DynamicFieldDefinitionList.defaultProps = {
|
|
4859
|
-
title: null,
|
|
4860
|
-
layout: exports.Layout.VERTICAL_TWO_COLUMN
|
|
4861
|
-
};
|
|
4862
|
-
var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
|
|
4863
|
-
|
|
4864
4365
|
const ESCAPED_OPENING_CHEVRON = '<';
|
|
4865
4366
|
const ESCAPED_CLOSING_CHEVRON = '>';
|
|
4866
4367
|
class EmphasisHtmlTransformer {
|
|
@@ -5081,15 +4582,14 @@ const Logo = ({
|
|
|
5081
4582
|
}) => {
|
|
5082
4583
|
const LogoSm = svgPaths[`WISE_FLAG${type === exports.LogoType.WISE_PLATFORM ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`];
|
|
5083
4584
|
const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5084
|
-
const screenMd = useScreenSize(exports.Breakpoint.MEDIUM);
|
|
5085
4585
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
5086
4586
|
"aria-label": type === exports.LogoType.WISE ? 'Wise' : 'Wise Business' | type === exports.LogoType.WISE_PLATFORM ? 'Wise Platform' : 'Wise Business',
|
|
5087
4587
|
role: "img",
|
|
5088
4588
|
className: classNames__default.default(className, 'np-logo'),
|
|
5089
|
-
children: [
|
|
5090
|
-
className: "np-logo-svg"
|
|
5091
|
-
}),
|
|
5092
|
-
className: "np-logo-svg"
|
|
4589
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(LogoSm, {
|
|
4590
|
+
className: "np-logo-svg np-logo-svg--size-sm"
|
|
4591
|
+
}), /*#__PURE__*/jsxRuntime.jsx(LogoMd, {
|
|
4592
|
+
className: "np-logo-svg np-logo-svg--size-md"
|
|
5093
4593
|
})]
|
|
5094
4594
|
});
|
|
5095
4595
|
};
|
|
@@ -5201,7 +4701,6 @@ const Tooltip = ({
|
|
|
5201
4701
|
|
|
5202
4702
|
function supportsTouchEvents() {
|
|
5203
4703
|
const onTouchStartIsDefined = typeof window !== 'undefined' && window.ontouchstart !== undefined;
|
|
5204
|
-
// eslint-disable-next-line compat/compat
|
|
5205
4704
|
const maxTouchPointsIsDefined = typeof navigator !== 'undefined' && navigator.maxTouchPoints;
|
|
5206
4705
|
const documentTouchIsDefined = typeof window !== 'undefined' && window.DocumentTouch && document instanceof window.DocumentTouch;
|
|
5207
4706
|
return !!(onTouchStartIsDefined || maxTouchPointsIsDefined || documentTouchIsDefined);
|
|
@@ -5209,7 +4708,7 @@ function supportsTouchEvents() {
|
|
|
5209
4708
|
function userAgentSuggestsTouchDevice() {
|
|
5210
4709
|
const sampleTouchDevices = ['android', 'iemobile', 'iphone', 'ipad', 'ipod', 'blackberry', 'bada'];
|
|
5211
4710
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
5212
|
-
const regex = new RegExp(matchString, '
|
|
4711
|
+
const regex = new RegExp(matchString, 'gi');
|
|
5213
4712
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
5214
4713
|
}
|
|
5215
4714
|
// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
|
|
@@ -5615,8 +5114,9 @@ function resolvePlacement(preferredPlacement) {
|
|
|
5615
5114
|
case 'bottom-left':
|
|
5616
5115
|
case 'bottom-right':
|
|
5617
5116
|
return 'bottom';
|
|
5117
|
+
default:
|
|
5118
|
+
return preferredPlacement;
|
|
5618
5119
|
}
|
|
5619
|
-
return preferredPlacement;
|
|
5620
5120
|
}
|
|
5621
5121
|
function Popover$1({
|
|
5622
5122
|
children,
|
|
@@ -6020,35 +5520,37 @@ function BottomSheet({
|
|
|
6020
5520
|
enterFrom: "np-bottom-sheet-v2-content--enter-from",
|
|
6021
5521
|
leave: "np-bottom-sheet-v2-content--leave",
|
|
6022
5522
|
leaveTo: "np-bottom-sheet-v2-content--leave-to",
|
|
6023
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
'np-bottom-sheet-v2-content-inner
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
5523
|
+
children: /*#__PURE__*/jsxRuntime.jsx(focus.FocusScope, {
|
|
5524
|
+
children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
|
|
5525
|
+
context: context,
|
|
5526
|
+
initialFocus: initialFocusRef,
|
|
5527
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
5528
|
+
// Force inner state invalidation on open
|
|
5529
|
+
ref: refs.setFloating,
|
|
5530
|
+
className: "np-bottom-sheet-v2-content-inner-container",
|
|
5531
|
+
...getFloatingProps(),
|
|
5532
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5533
|
+
className: "np-bottom-sheet-v2-header",
|
|
5534
|
+
children: /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
|
|
5535
|
+
size: exports.Size.SMALL,
|
|
5536
|
+
onClick: () => {
|
|
5537
|
+
onClose?.();
|
|
5538
|
+
}
|
|
5539
|
+
})
|
|
5540
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
5541
|
+
className: classNames__default.default('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
|
|
5542
|
+
'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
|
|
5543
|
+
}),
|
|
5544
|
+
children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
|
|
5545
|
+
className: "np-bottom-sheet-v2-title np-text-title-body",
|
|
5546
|
+
children: title
|
|
5547
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5548
|
+
className: "np-bottom-sheet-v2-body np-text-body-default",
|
|
5549
|
+
children: children
|
|
5550
|
+
})]
|
|
6049
5551
|
})]
|
|
6050
|
-
})
|
|
6051
|
-
}
|
|
5552
|
+
}, floatingKey)
|
|
5553
|
+
})
|
|
6052
5554
|
})
|
|
6053
5555
|
})
|
|
6054
5556
|
})]
|
|
@@ -6149,32 +5651,34 @@ function Popover({
|
|
|
6149
5651
|
setFloatingKey(prev => prev + 1);
|
|
6150
5652
|
},
|
|
6151
5653
|
afterLeave: onCloseEnd,
|
|
6152
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
'np-popover-v2-container
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
'np-popover-v2
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
5654
|
+
children: /*#__PURE__*/jsxRuntime.jsx(focus.FocusScope, {
|
|
5655
|
+
children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
|
|
5656
|
+
context: context,
|
|
5657
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5658
|
+
// Force inner state invalidation on open
|
|
5659
|
+
ref: refs.setFloating,
|
|
5660
|
+
className: classNames__default.default('np-popover-v2-container', {
|
|
5661
|
+
'np-popover-v2-container--size-md': size === 'md',
|
|
5662
|
+
'np-popover-v2-container--size-lg': size === 'lg'
|
|
5663
|
+
})
|
|
5664
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
5665
|
+
,
|
|
5666
|
+
style: floatingStyles,
|
|
5667
|
+
...getFloatingProps(),
|
|
5668
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
5669
|
+
className: classNames__default.default('np-popover-v2', title && 'np-popover-v2--has-title', {
|
|
5670
|
+
'np-popover-v2--padding-md': padding === 'md'
|
|
5671
|
+
}),
|
|
5672
|
+
children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
|
|
5673
|
+
className: "np-popover-v2-title np-text-title-body",
|
|
5674
|
+
children: title
|
|
5675
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5676
|
+
className: "np-popover-v2-content np-text-body-default",
|
|
5677
|
+
children: children
|
|
5678
|
+
})]
|
|
5679
|
+
})
|
|
5680
|
+
}, floatingKey)
|
|
5681
|
+
})
|
|
6178
5682
|
})
|
|
6179
5683
|
})
|
|
6180
5684
|
})
|
|
@@ -6270,6 +5774,7 @@ const defaultRenderTrigger = ({
|
|
|
6270
5774
|
})
|
|
6271
5775
|
})]
|
|
6272
5776
|
}),
|
|
5777
|
+
initialContentWidth: 24 + 4,
|
|
6273
5778
|
padding: 'sm'
|
|
6274
5779
|
},
|
|
6275
5780
|
disabled: disabled,
|
|
@@ -7179,7 +6684,6 @@ const Loader = ({
|
|
|
7179
6684
|
}, 1000);
|
|
7180
6685
|
}
|
|
7181
6686
|
return () => {
|
|
7182
|
-
// eslint-disable-next-line fp/no-mutation
|
|
7183
6687
|
cancelled = true;
|
|
7184
6688
|
clearTimeout(timeout);
|
|
7185
6689
|
};
|
|
@@ -9116,7 +8620,7 @@ const explodeNumberModel = number => {
|
|
|
9116
8620
|
};
|
|
9117
8621
|
};
|
|
9118
8622
|
|
|
9119
|
-
const DIGITS_MATCH = /^$|^(\+)|(
|
|
8623
|
+
const DIGITS_MATCH = /^$|^(\+)|(\d+)/g;
|
|
9120
8624
|
const cleanNumber = number => number.match(DIGITS_MATCH)?.join('') ?? '';
|
|
9121
8625
|
|
|
9122
8626
|
function sortArrayByProperty(arrayToSort, property) {
|
|
@@ -9202,7 +8706,8 @@ const PhoneNumberInput = ({
|
|
|
9202
8706
|
};
|
|
9203
8707
|
React.useEffect(() => {
|
|
9204
8708
|
if (broadcastedValue === null) {
|
|
9205
|
-
|
|
8709
|
+
setBroadcastedValue(internalValue);
|
|
8710
|
+
return;
|
|
9206
8711
|
}
|
|
9207
8712
|
const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;
|
|
9208
8713
|
const broadcastedPhoneNumber = `${broadcastedValue.prefix ?? ''}${broadcastedValue.suffix}`;
|
|
@@ -9475,7 +8980,7 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
|
|
|
9475
8980
|
const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
|
|
9476
8981
|
...commonProps,
|
|
9477
8982
|
'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
|
|
9478
|
-
'aria-describedby': `${componentId}-title
|
|
8983
|
+
'aria-describedby': `${componentId}-title`,
|
|
9479
8984
|
'aria-disabled': isDisabled,
|
|
9480
8985
|
'data-value': value ?? undefined,
|
|
9481
8986
|
role: type === 'checkbox' || type === 'radio' ? type : undefined,
|
|
@@ -10128,8 +9633,8 @@ function Select({
|
|
|
10128
9633
|
}
|
|
10129
9634
|
};
|
|
10130
9635
|
function selectKeyboardFocusedOption() {
|
|
10131
|
-
if (keyboardFocusedOptionIndex != null) {
|
|
10132
|
-
|
|
9636
|
+
if (keyboardFocusedOptionIndex != null && selectableOptions.length > 0) {
|
|
9637
|
+
selectOption(selectableOptions[keyboardFocusedOptionIndex]);
|
|
10133
9638
|
}
|
|
10134
9639
|
}
|
|
10135
9640
|
function moveFocusWithDifference(difference) {
|
|
@@ -10356,7 +9861,6 @@ function Select({
|
|
|
10356
9861
|
disabled: disabled,
|
|
10357
9862
|
"aria-controls": listboxId,
|
|
10358
9863
|
"aria-expanded": open,
|
|
10359
|
-
"aria-autocomplete": "none",
|
|
10360
9864
|
onClick: handleOnClick,
|
|
10361
9865
|
...buttonProps,
|
|
10362
9866
|
children: [selected ? /*#__PURE__*/jsxRuntime.jsx(Option$1, {
|
|
@@ -10472,12 +9976,11 @@ Select.defaultProps = {
|
|
|
10472
9976
|
|
|
10473
9977
|
const SegmentedControl = ({
|
|
10474
9978
|
name,
|
|
10475
|
-
|
|
9979
|
+
value,
|
|
10476
9980
|
mode = 'input',
|
|
10477
9981
|
segments,
|
|
10478
9982
|
onChange
|
|
10479
9983
|
}) => {
|
|
10480
|
-
const [selectedValue, setSelectedValue] = React.useState(defaultValue || segments[0].value);
|
|
10481
9984
|
const [animate, setAnimate] = React.useState(false);
|
|
10482
9985
|
const segmentsRef = React.useRef(null);
|
|
10483
9986
|
if (segments.length > 3) {
|
|
@@ -10488,7 +9991,7 @@ const SegmentedControl = ({
|
|
|
10488
9991
|
ref: /*#__PURE__*/React.createRef()
|
|
10489
9992
|
}));
|
|
10490
9993
|
const updateSegmentPosition = () => {
|
|
10491
|
-
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value ===
|
|
9994
|
+
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value === value)?.ref;
|
|
10492
9995
|
// We grab the active segments style object from the ref
|
|
10493
9996
|
// and set the css variables to the selected segments width and x position.
|
|
10494
9997
|
// This is so we can animate the highlight to the selected segment
|
|
@@ -10501,6 +10004,7 @@ const SegmentedControl = ({
|
|
|
10501
10004
|
}
|
|
10502
10005
|
};
|
|
10503
10006
|
React.useEffect(() => {
|
|
10007
|
+
setAnimate(true);
|
|
10504
10008
|
updateSegmentPosition();
|
|
10505
10009
|
const handleWindowSizeChange = () => {
|
|
10506
10010
|
setAnimate(false);
|
|
@@ -10511,10 +10015,7 @@ const SegmentedControl = ({
|
|
|
10511
10015
|
window.removeEventListener('resize', handleWindowSizeChange);
|
|
10512
10016
|
};
|
|
10513
10017
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10514
|
-
}, [segmentsWithRefs,
|
|
10515
|
-
React.useEffect(() => {
|
|
10516
|
-
onChange(selectedValue);
|
|
10517
|
-
}, [onChange, selectedValue]);
|
|
10018
|
+
}, [segmentsWithRefs, value]);
|
|
10518
10019
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
10519
10020
|
ref: segmentsRef,
|
|
10520
10021
|
"data-testid": "segmented-control",
|
|
@@ -10526,50 +10027,50 @@ const SegmentedControl = ({
|
|
|
10526
10027
|
'segmented-control__segments--no-animate': !animate
|
|
10527
10028
|
}),
|
|
10528
10029
|
role: mode !== 'input' ? 'tablist' : undefined,
|
|
10529
|
-
children: segmentsWithRefs.map(segment =>
|
|
10530
|
-
|
|
10531
|
-
htmlFor: segment.id,
|
|
10532
|
-
className: classNames__default.default('segmented-control__segment', {
|
|
10533
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10534
|
-
}),
|
|
10535
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
10536
|
-
type: "radio",
|
|
10537
|
-
className: "segmented-control__radio-input",
|
|
10538
|
-
id: segment.id,
|
|
10539
|
-
name: name,
|
|
10540
|
-
value: segment.value,
|
|
10541
|
-
checked: selectedValue === segment.value,
|
|
10542
|
-
onChange: () => {
|
|
10543
|
-
setAnimate(true);
|
|
10544
|
-
setSelectedValue(segment.value);
|
|
10545
|
-
}
|
|
10546
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
10547
|
-
className: "segmented-control__text",
|
|
10548
|
-
as: "span",
|
|
10549
|
-
type: selectedValue === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
|
|
10550
|
-
children: segment.label
|
|
10551
|
-
})]
|
|
10552
|
-
}, segment.id) : /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
10553
|
-
ref: segment.ref,
|
|
10554
|
-
type: "button",
|
|
10555
|
-
role: "tab",
|
|
10556
|
-
id: segment.id,
|
|
10557
|
-
"aria-controls": segment.controls,
|
|
10558
|
-
"aria-selected": selectedValue === segment.value,
|
|
10559
|
-
className: classNames__default.default('segmented-control__segment', 'segmented-control__button', {
|
|
10560
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10561
|
-
}),
|
|
10562
|
-
onClick: () => {
|
|
10030
|
+
children: segmentsWithRefs.map(segment => {
|
|
10031
|
+
const onSelect = () => {
|
|
10563
10032
|
setAnimate(true);
|
|
10564
|
-
|
|
10565
|
-
}
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10033
|
+
onChange(segment.value);
|
|
10034
|
+
};
|
|
10035
|
+
return mode === 'input' ? /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
10036
|
+
ref: segment.ref,
|
|
10037
|
+
htmlFor: segment.id,
|
|
10038
|
+
className: classNames__default.default('segmented-control__segment', {
|
|
10039
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10040
|
+
}),
|
|
10041
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
10042
|
+
type: "radio",
|
|
10043
|
+
className: "segmented-control__radio-input",
|
|
10044
|
+
id: segment.id,
|
|
10045
|
+
name: name,
|
|
10046
|
+
value: segment.value,
|
|
10047
|
+
checked: value === segment.value,
|
|
10048
|
+
onChange: onSelect
|
|
10049
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
10050
|
+
className: "segmented-control__text",
|
|
10051
|
+
as: "span",
|
|
10052
|
+
type: value === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
|
|
10053
|
+
children: segment.label
|
|
10054
|
+
})]
|
|
10055
|
+
}, segment.id) : /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
10056
|
+
ref: segment.ref,
|
|
10057
|
+
type: "button",
|
|
10058
|
+
role: "tab",
|
|
10059
|
+
id: segment.id,
|
|
10060
|
+
"aria-controls": segment.controls,
|
|
10061
|
+
"aria-selected": value === segment.value,
|
|
10062
|
+
className: classNames__default.default('segmented-control__segment', 'segmented-control__button', {
|
|
10063
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10064
|
+
}),
|
|
10065
|
+
onClick: onSelect,
|
|
10066
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
10067
|
+
as: "span",
|
|
10068
|
+
className: "segmented-control__text",
|
|
10069
|
+
type: value === segment.value ? exports.Typography.BODY_DEFAULT_BOLD : exports.Typography.BODY_DEFAULT,
|
|
10070
|
+
children: segment.label
|
|
10071
|
+
})
|
|
10072
|
+
}, segment.id);
|
|
10073
|
+
})
|
|
10573
10074
|
})
|
|
10574
10075
|
});
|
|
10575
10076
|
};
|
|
@@ -14899,7 +14400,6 @@ exports.DirectionProvider = DirectionProvider;
|
|
|
14899
14400
|
exports.Display = Display;
|
|
14900
14401
|
exports.Drawer = Drawer$1;
|
|
14901
14402
|
exports.DropFade = DropFade;
|
|
14902
|
-
exports.DynamicFieldDefinitionList = DynamicFieldDefinitionList$1;
|
|
14903
14403
|
exports.Emphasis = Emphasis;
|
|
14904
14404
|
exports.FlowNavigation = FlowNavigation;
|
|
14905
14405
|
exports.Header = Header;
|