@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.mjs
CHANGED
|
@@ -8,23 +8,22 @@ import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import commonmark from 'commonmark';
|
|
10
10
|
import { useTheme, ThemeProvider } from '@wise/components-theming';
|
|
11
|
-
import { formatDate,
|
|
11
|
+
import { formatDate, formatMoney, formatAmount } from '@transferwise/formatting';
|
|
12
12
|
import { Transition, Listbox } from '@headlessui/react';
|
|
13
13
|
import mergeProps from 'merge-props';
|
|
14
14
|
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
15
15
|
import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
|
|
16
|
+
import { FocusScope } from '@react-aria/focus';
|
|
16
17
|
import { usePreventScroll } from '@react-aria/overlays';
|
|
17
18
|
import { CSSTransition } from 'react-transition-group';
|
|
18
19
|
import { isUndefined, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
|
|
19
20
|
import { createPortal } from 'react-dom';
|
|
20
|
-
import { FocusScope } from '@react-aria/focus';
|
|
21
21
|
import { usePopper } from 'react-popper';
|
|
22
22
|
import throttle from 'lodash.throttle';
|
|
23
23
|
import { Flag, Illustration } from '@wise/art';
|
|
24
24
|
import clamp$2 from 'lodash.clamp';
|
|
25
25
|
import debounce from 'lodash.debounce';
|
|
26
26
|
import requiredIf from 'react-required-if';
|
|
27
|
-
import toPairs from 'lodash.topairs';
|
|
28
27
|
import { Spring, animated } from '@react-spring/web';
|
|
29
28
|
|
|
30
29
|
class HistoryNavigator {
|
|
@@ -63,7 +62,7 @@ var HistoryNavigator$1 = HistoryNavigator;
|
|
|
63
62
|
function isIosDevice() {
|
|
64
63
|
const sampleTouchDevices = ['iphone', 'ipad', 'ipod'];
|
|
65
64
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
66
|
-
const regex = new RegExp(matchString, '
|
|
65
|
+
const regex = new RegExp(matchString, 'gi');
|
|
67
66
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
68
67
|
}
|
|
69
68
|
|
|
@@ -909,8 +908,9 @@ function resolveType(type) {
|
|
|
909
908
|
return 'neutral';
|
|
910
909
|
case 'error':
|
|
911
910
|
return 'negative';
|
|
911
|
+
default:
|
|
912
|
+
return type;
|
|
912
913
|
}
|
|
913
|
-
return type;
|
|
914
914
|
}
|
|
915
915
|
function Alert({
|
|
916
916
|
arrow,
|
|
@@ -1056,7 +1056,7 @@ const hashSeed = seed => {
|
|
|
1056
1056
|
const modulo = avatarColors.length;
|
|
1057
1057
|
let hashValue = 0;
|
|
1058
1058
|
let basePow = 1;
|
|
1059
|
-
for (let i = 0; i < seed.length; i
|
|
1059
|
+
for (let i = 0; i < seed.length; i += 1) {
|
|
1060
1060
|
hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;
|
|
1061
1061
|
basePow = basePow * base % modulo;
|
|
1062
1062
|
}
|
|
@@ -1348,11 +1348,15 @@ const Dimmer = ({
|
|
|
1348
1348
|
}, [onClose]);
|
|
1349
1349
|
const onEnter = () => {
|
|
1350
1350
|
setHasNotExited(true);
|
|
1351
|
-
|
|
1351
|
+
if (dimmerReference.current) {
|
|
1352
|
+
dimmerManager.add(dimmerReference.current);
|
|
1353
|
+
}
|
|
1352
1354
|
};
|
|
1353
1355
|
const onExited = () => {
|
|
1354
1356
|
setHasNotExited(false);
|
|
1355
|
-
|
|
1357
|
+
if (dimmerReference.current) {
|
|
1358
|
+
dimmerManager.remove(dimmerReference.current);
|
|
1359
|
+
}
|
|
1356
1360
|
};
|
|
1357
1361
|
useEffect(() => {
|
|
1358
1362
|
const localReferenceCopy = dimmerReference.current;
|
|
@@ -4327,508 +4331,6 @@ const DropFade = ({
|
|
|
4327
4331
|
});
|
|
4328
4332
|
};
|
|
4329
4333
|
|
|
4330
|
-
/* eslint-disable no-unused-vars */
|
|
4331
|
-
/* eslint-disable no-param-reassign */
|
|
4332
|
-
|
|
4333
|
-
const prepFields = (fields, model, validationMessages) => {
|
|
4334
|
-
if (!fields) {
|
|
4335
|
-
return {};
|
|
4336
|
-
}
|
|
4337
|
-
let preparedFields = copyOf(fields);
|
|
4338
|
-
preparedFields = flattenFieldsWithGroups(preparedFields);
|
|
4339
|
-
preparedFields = transformFieldArrayToMap(preparedFields);
|
|
4340
|
-
preparedFields = transformNestedKeysToNestedSpecs(preparedFields);
|
|
4341
|
-
Object.keys(preparedFields).forEach(key => {
|
|
4342
|
-
preparedFields[key] = prepField(preparedFields[key], model, validationMessages);
|
|
4343
|
-
});
|
|
4344
|
-
return preparedFields;
|
|
4345
|
-
};
|
|
4346
|
-
const prepField = (field, model, validationMessages) => {
|
|
4347
|
-
const preparedField = copyOf(field);
|
|
4348
|
-
prepLegacyProps(preparedField);
|
|
4349
|
-
prepType(preparedField);
|
|
4350
|
-
prepPattern(preparedField);
|
|
4351
|
-
prepValidationMessages(preparedField, validationMessages);
|
|
4352
|
-
return preparedField;
|
|
4353
|
-
};
|
|
4354
|
-
|
|
4355
|
-
/**
|
|
4356
|
-
* In an older format we had an extra fieldGroup level, here we flatten that out
|
|
4357
|
-
* So the inner arrays of fields within the different field groups are flattened
|
|
4358
|
-
* to a single array, which is returned.
|
|
4359
|
-
*
|
|
4360
|
-
* @param fields
|
|
4361
|
-
*/
|
|
4362
|
-
const flattenFieldsWithGroups = fields => {
|
|
4363
|
-
if (Array.isArray(fields)) {
|
|
4364
|
-
let flattenedFields = [];
|
|
4365
|
-
fields.forEach(field => {
|
|
4366
|
-
// If we've been given a group with nested fields, break them out.
|
|
4367
|
-
if (field.fields) {
|
|
4368
|
-
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.fields));
|
|
4369
|
-
} else if (field.group) {
|
|
4370
|
-
flattenedFields = flattenedFields.concat(flattenFieldWithGroup(field, field.group));
|
|
4371
|
-
} else {
|
|
4372
|
-
// Otherwise it's a regular field, just add it.
|
|
4373
|
-
flattenedFields.push(field);
|
|
4374
|
-
}
|
|
4375
|
-
});
|
|
4376
|
-
return flattenedFields;
|
|
4377
|
-
}
|
|
4378
|
-
return fields;
|
|
4379
|
-
};
|
|
4380
|
-
const flattenFieldWithGroup = (field, subFields) => {
|
|
4381
|
-
// If first field doesn't have a label, use the one from the group
|
|
4382
|
-
if (field.name && subFields.length > 0 && !subFields[0].name) {
|
|
4383
|
-
subFields[0].name = field.name;
|
|
4384
|
-
}
|
|
4385
|
-
if (field.width && subFields.length > 0 && !subFields[0].width) {
|
|
4386
|
-
subFields[0].width = field.width;
|
|
4387
|
-
}
|
|
4388
|
-
|
|
4389
|
-
// If there was a tooltip at fieldGroup level move it to first field.
|
|
4390
|
-
if (field.tooltip && subFields.length > 0 && !subFields[0].help) {
|
|
4391
|
-
subFields[0].help = {
|
|
4392
|
-
message: field.tooltip
|
|
4393
|
-
};
|
|
4394
|
-
}
|
|
4395
|
-
if (field.info && subFields.length > 0 && !subFields[0].help) {
|
|
4396
|
-
subFields[0].help = {
|
|
4397
|
-
message: field.info
|
|
4398
|
-
};
|
|
4399
|
-
}
|
|
4400
|
-
|
|
4401
|
-
// If there are two parts of this group, render them side by side
|
|
4402
|
-
if (subFields.length === 2) {
|
|
4403
|
-
subFields.forEach(nestedField => {
|
|
4404
|
-
nestedField.width = 'md';
|
|
4405
|
-
});
|
|
4406
|
-
}
|
|
4407
|
-
|
|
4408
|
-
// If there are three parts, render the first two side by side
|
|
4409
|
-
if (subFields.length === 3) {
|
|
4410
|
-
subFields[0].width = 'md';
|
|
4411
|
-
subFields[1].width = 'md';
|
|
4412
|
-
}
|
|
4413
|
-
return subFields;
|
|
4414
|
-
};
|
|
4415
|
-
|
|
4416
|
-
/*
|
|
4417
|
-
* Some older requirements return an array of fields, where it should be a map
|
|
4418
|
-
* from the property name to the spec. This converts arrays to maps.
|
|
4419
|
-
*/
|
|
4420
|
-
const transformFieldArrayToMap = fields => {
|
|
4421
|
-
if (Array.isArray(fields)) {
|
|
4422
|
-
const fieldMap = {};
|
|
4423
|
-
fields.forEach(field => {
|
|
4424
|
-
const key = field.key || field.name;
|
|
4425
|
-
delete field.key;
|
|
4426
|
-
fieldMap[key] = copyOf(field);
|
|
4427
|
-
});
|
|
4428
|
-
return fieldMap;
|
|
4429
|
-
}
|
|
4430
|
-
return fields;
|
|
4431
|
-
};
|
|
4432
|
-
|
|
4433
|
-
/*
|
|
4434
|
-
* Some older format return keys like 'address.city', expecting the value of
|
|
4435
|
-
* city to be nested inside an address object. This function creates a spec of
|
|
4436
|
-
* type 'object', and nests such fields inside of it. When we render we pass
|
|
4437
|
-
* this object spec to a nested fieldset.
|
|
4438
|
-
*/
|
|
4439
|
-
const transformNestedKeysToNestedSpecs = fieldMap => {
|
|
4440
|
-
if (Array.isArray(fieldMap)) {
|
|
4441
|
-
throw new TypeError('Expecting a map of fields, not an array');
|
|
4442
|
-
}
|
|
4443
|
-
const nestedFields = {};
|
|
4444
|
-
Object.keys(fieldMap).forEach(key => {
|
|
4445
|
-
if (key.indexOf('.') > 0) {
|
|
4446
|
-
// If the key contains a period we need to nest the fields in another object
|
|
4447
|
-
const pathSections = key.split('.');
|
|
4448
|
-
const nestedKey = pathSections[0];
|
|
4449
|
-
|
|
4450
|
-
// If this sub object doesn't exist yet, create it
|
|
4451
|
-
if (!nestedFields[nestedKey]) {
|
|
4452
|
-
nestedFields[nestedKey] = {
|
|
4453
|
-
type: 'object',
|
|
4454
|
-
properties: {}
|
|
4455
|
-
};
|
|
4456
|
-
}
|
|
4457
|
-
nestedFields[nestedKey].properties[pathSections[1]] = fieldMap[key];
|
|
4458
|
-
} else {
|
|
4459
|
-
nestedFields[key] = fieldMap[key];
|
|
4460
|
-
}
|
|
4461
|
-
});
|
|
4462
|
-
return nestedFields;
|
|
4463
|
-
};
|
|
4464
|
-
const prepType = field => {
|
|
4465
|
-
const type = field.type && field.type.toLowerCase && field.type.toLowerCase();
|
|
4466
|
-
switch (type) {
|
|
4467
|
-
case 'text':
|
|
4468
|
-
field.type = 'string';
|
|
4469
|
-
break;
|
|
4470
|
-
case 'date':
|
|
4471
|
-
field.type = 'string';
|
|
4472
|
-
field.format = 'date';
|
|
4473
|
-
break;
|
|
4474
|
-
case 'password':
|
|
4475
|
-
field.type = 'string';
|
|
4476
|
-
field.control = 'password';
|
|
4477
|
-
break;
|
|
4478
|
-
case 'checkbox':
|
|
4479
|
-
field.type = 'boolean';
|
|
4480
|
-
break;
|
|
4481
|
-
case 'select':
|
|
4482
|
-
if (!field.control) {
|
|
4483
|
-
field.control = 'select';
|
|
4484
|
-
}
|
|
4485
|
-
delete field.type;
|
|
4486
|
-
break;
|
|
4487
|
-
case 'radio':
|
|
4488
|
-
field.control = 'radio';
|
|
4489
|
-
delete field.type;
|
|
4490
|
-
break;
|
|
4491
|
-
case 'upload':
|
|
4492
|
-
field.type = 'string';
|
|
4493
|
-
field.format = 'base64url';
|
|
4494
|
-
break;
|
|
4495
|
-
case 'tel':
|
|
4496
|
-
field.type = 'string';
|
|
4497
|
-
field.format = 'phone';
|
|
4498
|
-
break;
|
|
4499
|
-
case 'textarea':
|
|
4500
|
-
field.type = 'string';
|
|
4501
|
-
field.control = 'textarea';
|
|
4502
|
-
break;
|
|
4503
|
-
}
|
|
4504
|
-
if (!field.control && field.type !== 'object') {
|
|
4505
|
-
field.control = getControlType(field);
|
|
4506
|
-
}
|
|
4507
|
-
};
|
|
4508
|
-
const prepLegacyProps = field => {
|
|
4509
|
-
if (field.name && !field.title) {
|
|
4510
|
-
field.title = field.name;
|
|
4511
|
-
delete field.name;
|
|
4512
|
-
}
|
|
4513
|
-
if (field.validationRegexp) {
|
|
4514
|
-
field.pattern = field.validationRegexp;
|
|
4515
|
-
delete field.validationRegexp;
|
|
4516
|
-
}
|
|
4517
|
-
if (field.min) {
|
|
4518
|
-
field.minimum = field.min;
|
|
4519
|
-
delete field.min;
|
|
4520
|
-
}
|
|
4521
|
-
if (field.max) {
|
|
4522
|
-
field.maximum = field.max;
|
|
4523
|
-
delete field.max;
|
|
4524
|
-
}
|
|
4525
|
-
if (field.example && !field.placeholder) {
|
|
4526
|
-
field.placeholder = field.example;
|
|
4527
|
-
delete field.example;
|
|
4528
|
-
}
|
|
4529
|
-
if (field.tooltip && !field.help) {
|
|
4530
|
-
field.help = {
|
|
4531
|
-
message: field.tooltip
|
|
4532
|
-
};
|
|
4533
|
-
delete field.tooltip;
|
|
4534
|
-
}
|
|
4535
|
-
if (field.valuesAllowed && !field.values) {
|
|
4536
|
-
field.values = field.valuesAllowed;
|
|
4537
|
-
delete field.valuesAllowed;
|
|
4538
|
-
}
|
|
4539
|
-
if (field.values && field.values.map) {
|
|
4540
|
-
field.values = prepLegacyValues(field.values);
|
|
4541
|
-
}
|
|
4542
|
-
if (field.value && !field.default) {
|
|
4543
|
-
field.default = field.value;
|
|
4544
|
-
delete field.value;
|
|
4545
|
-
}
|
|
4546
|
-
if (field.values) {
|
|
4547
|
-
// In some legacy arrays the first value is a placeholder, extract it.
|
|
4548
|
-
if (field.values && field.values.length > 0 && field.values[0] && !field.values[0].value && field.values[0].label && !field.placeholder) {
|
|
4549
|
-
field.placeholder = field.values[0].label;
|
|
4550
|
-
field.values = field.values.slice(1);
|
|
4551
|
-
}
|
|
4552
|
-
}
|
|
4553
|
-
};
|
|
4554
|
-
const prepLegacyValues = values => values.map(prepLegacyValue);
|
|
4555
|
-
const prepLegacyValue = value => {
|
|
4556
|
-
if (!value.label && value.title) {
|
|
4557
|
-
value.label = value.title;
|
|
4558
|
-
delete value.title;
|
|
4559
|
-
}
|
|
4560
|
-
if (!value.label && value.name) {
|
|
4561
|
-
value.label = value.name;
|
|
4562
|
-
delete value.name;
|
|
4563
|
-
}
|
|
4564
|
-
if (!value.value && value.code) {
|
|
4565
|
-
value.value = value.code;
|
|
4566
|
-
delete value.code;
|
|
4567
|
-
}
|
|
4568
|
-
if (!value.value && value.key) {
|
|
4569
|
-
value.value = value.key;
|
|
4570
|
-
delete value.key;
|
|
4571
|
-
}
|
|
4572
|
-
return value;
|
|
4573
|
-
};
|
|
4574
|
-
const prepPattern = field => {
|
|
4575
|
-
if (field.pattern) {
|
|
4576
|
-
try {
|
|
4577
|
-
new RegExp(field.pattern);
|
|
4578
|
-
} catch {
|
|
4579
|
-
// eslint-disable-next-line no-console
|
|
4580
|
-
console.warn('API regexp is invalid');
|
|
4581
|
-
delete field.pattern;
|
|
4582
|
-
}
|
|
4583
|
-
} else {
|
|
4584
|
-
delete field.pattern;
|
|
4585
|
-
}
|
|
4586
|
-
};
|
|
4587
|
-
const prepValidationMessages = (field, validationMessages) => {
|
|
4588
|
-
field.validationMessages = field.validationMessages ? field.validationMessages : validationMessages;
|
|
4589
|
-
if (!field.validationMessages) {
|
|
4590
|
-
delete field.validationMessages;
|
|
4591
|
-
return;
|
|
4592
|
-
}
|
|
4593
|
-
if (field.validationMessages.minimum) {
|
|
4594
|
-
field.validationMessages.min = field.validationMessages.minimum;
|
|
4595
|
-
delete field.validationMessages.minimum;
|
|
4596
|
-
}
|
|
4597
|
-
if (field.validationMessages.maximum) {
|
|
4598
|
-
field.validationMessages.max = field.validationMessages.maximum;
|
|
4599
|
-
delete field.validationMessages.maximum;
|
|
4600
|
-
}
|
|
4601
|
-
};
|
|
4602
|
-
const getControlType = field => {
|
|
4603
|
-
if (field.control) {
|
|
4604
|
-
return field.control.toLowerCase();
|
|
4605
|
-
}
|
|
4606
|
-
if (field.hidden) {
|
|
4607
|
-
return 'hidden';
|
|
4608
|
-
}
|
|
4609
|
-
if (field.values && field.values.length > 0) {
|
|
4610
|
-
return getSelectionType(field);
|
|
4611
|
-
}
|
|
4612
|
-
switch (field.type) {
|
|
4613
|
-
case 'string':
|
|
4614
|
-
return getControlForStringFormat(field.format);
|
|
4615
|
-
case 'number':
|
|
4616
|
-
case 'integer':
|
|
4617
|
-
return 'number';
|
|
4618
|
-
case 'boolean':
|
|
4619
|
-
return 'checkbox';
|
|
4620
|
-
default:
|
|
4621
|
-
return 'text';
|
|
4622
|
-
}
|
|
4623
|
-
};
|
|
4624
|
-
const getControlForStringFormat = format => {
|
|
4625
|
-
switch (format) {
|
|
4626
|
-
case 'date':
|
|
4627
|
-
return 'date';
|
|
4628
|
-
case 'base64url':
|
|
4629
|
-
return 'file';
|
|
4630
|
-
case 'password':
|
|
4631
|
-
return 'password';
|
|
4632
|
-
case 'uri':
|
|
4633
|
-
return 'text';
|
|
4634
|
-
// 'url'; - not implemented
|
|
4635
|
-
case 'email':
|
|
4636
|
-
return 'text';
|
|
4637
|
-
// 'email'; - not implemented
|
|
4638
|
-
case 'phone':
|
|
4639
|
-
return 'tel';
|
|
4640
|
-
default:
|
|
4641
|
-
return 'text';
|
|
4642
|
-
}
|
|
4643
|
-
};
|
|
4644
|
-
const getSelectionType = field => {
|
|
4645
|
-
if (field.control) {
|
|
4646
|
-
return field.control;
|
|
4647
|
-
}
|
|
4648
|
-
if (field.type === 'select') {
|
|
4649
|
-
return 'select';
|
|
4650
|
-
}
|
|
4651
|
-
if (field.type === 'radio') {
|
|
4652
|
-
return 'radio';
|
|
4653
|
-
}
|
|
4654
|
-
if (field.values) {
|
|
4655
|
-
return field.values.length > 3 ? 'select' : 'radio';
|
|
4656
|
-
}
|
|
4657
|
-
return 'select';
|
|
4658
|
-
};
|
|
4659
|
-
const copyOf = object => JSON.parse(JSON.stringify(object));
|
|
4660
|
-
|
|
4661
|
-
const formatUsingPattern = (value = '', pattern) => {
|
|
4662
|
-
if (typeof pattern !== 'string') {
|
|
4663
|
-
return value;
|
|
4664
|
-
}
|
|
4665
|
-
let newPattern = pattern;
|
|
4666
|
-
if (newPattern.indexOf('||') > 0) {
|
|
4667
|
-
newPattern = newPattern.slice(0, Math.max(0, pattern.indexOf('||')));
|
|
4668
|
-
}
|
|
4669
|
-
let newValue = '';
|
|
4670
|
-
let separators = 0;
|
|
4671
|
-
let charactersToAllocate = value.length;
|
|
4672
|
-
let position = 0;
|
|
4673
|
-
while (charactersToAllocate) {
|
|
4674
|
-
if (positionIsSeparator(newPattern, position)) {
|
|
4675
|
-
newValue += newPattern[position];
|
|
4676
|
-
separators += 1;
|
|
4677
|
-
} else {
|
|
4678
|
-
newValue += value[position - separators];
|
|
4679
|
-
charactersToAllocate -= 1;
|
|
4680
|
-
}
|
|
4681
|
-
position += 1;
|
|
4682
|
-
}
|
|
4683
|
-
const separatorsAfterCursor = countSeparatorsAfterCursor(newPattern, position);
|
|
4684
|
-
if (separatorsAfterCursor) {
|
|
4685
|
-
newValue += newPattern.slice(position, separatorsAfterCursor);
|
|
4686
|
-
}
|
|
4687
|
-
return newValue;
|
|
4688
|
-
};
|
|
4689
|
-
const countSeparatorsAfterCursor = (newPattern, position) => {
|
|
4690
|
-
let separators = 0;
|
|
4691
|
-
while (positionIsSeparator(newPattern, position + separators)) {
|
|
4692
|
-
separators += 1;
|
|
4693
|
-
}
|
|
4694
|
-
return separators;
|
|
4695
|
-
};
|
|
4696
|
-
const positionIsSeparator = (newPattern, position) => newPattern[position] && newPattern[position] !== '*';
|
|
4697
|
-
|
|
4698
|
-
const getValueLabel = (options, value) => {
|
|
4699
|
-
const option = options.find(currentOption => currentOption.value === value);
|
|
4700
|
-
return option && option.label ? option.label : value;
|
|
4701
|
-
};
|
|
4702
|
-
|
|
4703
|
-
/**
|
|
4704
|
-
*
|
|
4705
|
-
* @param {string} value
|
|
4706
|
-
*/
|
|
4707
|
-
const mask = value => new Array(value.length + 1).join('*');
|
|
4708
|
-
const FormattedValue = ({
|
|
4709
|
-
field,
|
|
4710
|
-
value
|
|
4711
|
-
}) => {
|
|
4712
|
-
const {
|
|
4713
|
-
locale
|
|
4714
|
-
} = useIntl();
|
|
4715
|
-
const style = [];
|
|
4716
|
-
if (field.tagClassName && field.tagClassName.h3) {
|
|
4717
|
-
style.push('np-text-body-large-bold');
|
|
4718
|
-
style.push('formatted-value__h3-custom-alignment');
|
|
4719
|
-
}
|
|
4720
|
-
switch (field.control) {
|
|
4721
|
-
case 'select':
|
|
4722
|
-
case 'radio':
|
|
4723
|
-
return /*#__PURE__*/jsx("span", {
|
|
4724
|
-
children: getValueLabel(field.values, value)
|
|
4725
|
-
});
|
|
4726
|
-
case 'date':
|
|
4727
|
-
return /*#__PURE__*/jsx("span", {
|
|
4728
|
-
children: formatDate(value instanceof Date ? value : new Date(value), locale)
|
|
4729
|
-
});
|
|
4730
|
-
case 'number':
|
|
4731
|
-
return /*#__PURE__*/jsx("span", {
|
|
4732
|
-
children: formatNumber(value, locale)
|
|
4733
|
-
});
|
|
4734
|
-
case 'password':
|
|
4735
|
-
return /*#__PURE__*/jsx("span", {
|
|
4736
|
-
children: mask(value)
|
|
4737
|
-
});
|
|
4738
|
-
case 'file':
|
|
4739
|
-
return /*#__PURE__*/jsx("div", {
|
|
4740
|
-
className: "thumbnail",
|
|
4741
|
-
children: /*#__PURE__*/jsx("img", {
|
|
4742
|
-
alt: field.title,
|
|
4743
|
-
src: value
|
|
4744
|
-
})
|
|
4745
|
-
});
|
|
4746
|
-
case 'checkbox':
|
|
4747
|
-
return /*#__PURE__*/jsx("span", {
|
|
4748
|
-
children: JSON.stringify(value)
|
|
4749
|
-
});
|
|
4750
|
-
default:
|
|
4751
|
-
return /*#__PURE__*/jsx("span", {
|
|
4752
|
-
className: classNames(style),
|
|
4753
|
-
children: formatUsingPattern(value, field.displayFormat)
|
|
4754
|
-
});
|
|
4755
|
-
}
|
|
4756
|
-
};
|
|
4757
|
-
FormattedValue.propTypes = {
|
|
4758
|
-
field: PropTypes.shape({
|
|
4759
|
-
control: PropTypes.string.isRequired,
|
|
4760
|
-
displayFormat: PropTypes.string,
|
|
4761
|
-
refreshRequirementsOnChange: PropTypes.bool,
|
|
4762
|
-
title: PropTypes.string.isRequired,
|
|
4763
|
-
type: PropTypes.string.isRequired,
|
|
4764
|
-
width: PropTypes.string,
|
|
4765
|
-
tagClassName: PropTypes.shape({
|
|
4766
|
-
h3: PropTypes.bool
|
|
4767
|
-
}),
|
|
4768
|
-
values: PropTypes.arrayOf(PropTypes.shape({
|
|
4769
|
-
value: PropTypes.any
|
|
4770
|
-
}))
|
|
4771
|
-
}).isRequired,
|
|
4772
|
-
value: PropTypes.any.isRequired
|
|
4773
|
-
};
|
|
4774
|
-
var FormattedValue$1 = FormattedValue;
|
|
4775
|
-
|
|
4776
|
-
function createDefinitions(fields, model) {
|
|
4777
|
-
return toPairs(fields).map(([name, field]) => createDefinition(name, field, model)).filter(definition => !!definition);
|
|
4778
|
-
}
|
|
4779
|
-
function createDefinition(name, field, model) {
|
|
4780
|
-
const {
|
|
4781
|
-
title,
|
|
4782
|
-
group,
|
|
4783
|
-
hidden
|
|
4784
|
-
} = field;
|
|
4785
|
-
if (!model[name] || hidden) {
|
|
4786
|
-
return null;
|
|
4787
|
-
}
|
|
4788
|
-
return {
|
|
4789
|
-
title,
|
|
4790
|
-
value: group ? group.map((groupField, groupFieldIndex) => /*#__PURE__*/jsx(FormattedValue$1, {
|
|
4791
|
-
// eslint-disable-line react/no-array-index-key
|
|
4792
|
-
field: groupField,
|
|
4793
|
-
value: model[name]
|
|
4794
|
-
}, groupFieldIndex)) : /*#__PURE__*/jsx(FormattedValue$1, {
|
|
4795
|
-
field: field,
|
|
4796
|
-
value: model[name]
|
|
4797
|
-
}),
|
|
4798
|
-
key: name
|
|
4799
|
-
};
|
|
4800
|
-
}
|
|
4801
|
-
|
|
4802
|
-
const DynamicFieldDefinitionList = ({
|
|
4803
|
-
model,
|
|
4804
|
-
title,
|
|
4805
|
-
layout,
|
|
4806
|
-
fields
|
|
4807
|
-
}) => /*#__PURE__*/jsxs(Fragment, {
|
|
4808
|
-
children: [title && /*#__PURE__*/jsx("div", {
|
|
4809
|
-
className: "m-t-1 m-b-3",
|
|
4810
|
-
children: /*#__PURE__*/jsx(Title, {
|
|
4811
|
-
type: Typography.TITLE_BODY,
|
|
4812
|
-
className: "p-t-3",
|
|
4813
|
-
children: title
|
|
4814
|
-
})
|
|
4815
|
-
}), /*#__PURE__*/jsx(DefinitionList$1, {
|
|
4816
|
-
layout: layout,
|
|
4817
|
-
definitions: createDefinitions(prepFields(fields), model)
|
|
4818
|
-
})]
|
|
4819
|
-
});
|
|
4820
|
-
DynamicFieldDefinitionList.propTypes = {
|
|
4821
|
-
model: PropTypes.shape({}).isRequired,
|
|
4822
|
-
fields: PropTypes.shape({}).isRequired,
|
|
4823
|
-
title: PropTypes.string,
|
|
4824
|
-
layout: PropTypes.oneOf(['VERTICAL_TWO_COLUMN', 'VERTICAL_ONE_COLUMN', 'HORIZONTAL_JUSTIFIED', 'HORIZONTAL_LEFT_ALIGNED'])
|
|
4825
|
-
};
|
|
4826
|
-
DynamicFieldDefinitionList.defaultProps = {
|
|
4827
|
-
title: null,
|
|
4828
|
-
layout: Layout.VERTICAL_TWO_COLUMN
|
|
4829
|
-
};
|
|
4830
|
-
var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
|
|
4831
|
-
|
|
4832
4334
|
const ESCAPED_OPENING_CHEVRON = '<';
|
|
4833
4335
|
const ESCAPED_CLOSING_CHEVRON = '>';
|
|
4834
4336
|
class EmphasisHtmlTransformer {
|
|
@@ -5049,15 +4551,14 @@ const Logo = ({
|
|
|
5049
4551
|
}) => {
|
|
5050
4552
|
const LogoSm = svgPaths[`WISE_FLAG${type === LogoType.WISE_PLATFORM ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`];
|
|
5051
4553
|
const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5052
|
-
const screenMd = useScreenSize(Breakpoint.MEDIUM);
|
|
5053
4554
|
return /*#__PURE__*/jsxs("span", {
|
|
5054
4555
|
"aria-label": type === LogoType.WISE ? 'Wise' : 'Wise Business' | type === LogoType.WISE_PLATFORM ? 'Wise Platform' : 'Wise Business',
|
|
5055
4556
|
role: "img",
|
|
5056
4557
|
className: classNames(className, 'np-logo'),
|
|
5057
|
-
children: [
|
|
5058
|
-
className: "np-logo-svg"
|
|
5059
|
-
}),
|
|
5060
|
-
className: "np-logo-svg"
|
|
4558
|
+
children: [/*#__PURE__*/jsx(LogoSm, {
|
|
4559
|
+
className: "np-logo-svg np-logo-svg--size-sm"
|
|
4560
|
+
}), /*#__PURE__*/jsx(LogoMd, {
|
|
4561
|
+
className: "np-logo-svg np-logo-svg--size-md"
|
|
5061
4562
|
})]
|
|
5062
4563
|
});
|
|
5063
4564
|
};
|
|
@@ -5169,7 +4670,6 @@ const Tooltip = ({
|
|
|
5169
4670
|
|
|
5170
4671
|
function supportsTouchEvents() {
|
|
5171
4672
|
const onTouchStartIsDefined = typeof window !== 'undefined' && window.ontouchstart !== undefined;
|
|
5172
|
-
// eslint-disable-next-line compat/compat
|
|
5173
4673
|
const maxTouchPointsIsDefined = typeof navigator !== 'undefined' && navigator.maxTouchPoints;
|
|
5174
4674
|
const documentTouchIsDefined = typeof window !== 'undefined' && window.DocumentTouch && document instanceof window.DocumentTouch;
|
|
5175
4675
|
return !!(onTouchStartIsDefined || maxTouchPointsIsDefined || documentTouchIsDefined);
|
|
@@ -5177,7 +4677,7 @@ function supportsTouchEvents() {
|
|
|
5177
4677
|
function userAgentSuggestsTouchDevice() {
|
|
5178
4678
|
const sampleTouchDevices = ['android', 'iemobile', 'iphone', 'ipad', 'ipod', 'blackberry', 'bada'];
|
|
5179
4679
|
const matchString = sampleTouchDevices.map(device => `(${device})`).join('|');
|
|
5180
|
-
const regex = new RegExp(matchString, '
|
|
4680
|
+
const regex = new RegExp(matchString, 'gi');
|
|
5181
4681
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
5182
4682
|
}
|
|
5183
4683
|
// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
|
|
@@ -5583,8 +5083,9 @@ function resolvePlacement(preferredPlacement) {
|
|
|
5583
5083
|
case 'bottom-left':
|
|
5584
5084
|
case 'bottom-right':
|
|
5585
5085
|
return 'bottom';
|
|
5086
|
+
default:
|
|
5087
|
+
return preferredPlacement;
|
|
5586
5088
|
}
|
|
5587
|
-
return preferredPlacement;
|
|
5588
5089
|
}
|
|
5589
5090
|
function Popover$1({
|
|
5590
5091
|
children,
|
|
@@ -5988,35 +5489,37 @@ function BottomSheet({
|
|
|
5988
5489
|
enterFrom: "np-bottom-sheet-v2-content--enter-from",
|
|
5989
5490
|
leave: "np-bottom-sheet-v2-content--leave",
|
|
5990
5491
|
leaveTo: "np-bottom-sheet-v2-content--leave-to",
|
|
5991
|
-
children: /*#__PURE__*/jsx(
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
'np-bottom-sheet-v2-content-inner
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
5492
|
+
children: /*#__PURE__*/jsx(FocusScope, {
|
|
5493
|
+
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
5494
|
+
context: context,
|
|
5495
|
+
initialFocus: initialFocusRef,
|
|
5496
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
5497
|
+
// Force inner state invalidation on open
|
|
5498
|
+
ref: refs.setFloating,
|
|
5499
|
+
className: "np-bottom-sheet-v2-content-inner-container",
|
|
5500
|
+
...getFloatingProps(),
|
|
5501
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
5502
|
+
className: "np-bottom-sheet-v2-header",
|
|
5503
|
+
children: /*#__PURE__*/jsx(CloseButton, {
|
|
5504
|
+
size: Size.SMALL,
|
|
5505
|
+
onClick: () => {
|
|
5506
|
+
onClose?.();
|
|
5507
|
+
}
|
|
5508
|
+
})
|
|
5509
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
5510
|
+
className: classNames('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
|
|
5511
|
+
'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
|
|
5512
|
+
}),
|
|
5513
|
+
children: [title ? /*#__PURE__*/jsx("h2", {
|
|
5514
|
+
className: "np-bottom-sheet-v2-title np-text-title-body",
|
|
5515
|
+
children: title
|
|
5516
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
5517
|
+
className: "np-bottom-sheet-v2-body np-text-body-default",
|
|
5518
|
+
children: children
|
|
5519
|
+
})]
|
|
6017
5520
|
})]
|
|
6018
|
-
})
|
|
6019
|
-
}
|
|
5521
|
+
}, floatingKey)
|
|
5522
|
+
})
|
|
6020
5523
|
})
|
|
6021
5524
|
})
|
|
6022
5525
|
})]
|
|
@@ -6117,32 +5620,34 @@ function Popover({
|
|
|
6117
5620
|
setFloatingKey(prev => prev + 1);
|
|
6118
5621
|
},
|
|
6119
5622
|
afterLeave: onCloseEnd,
|
|
6120
|
-
children: /*#__PURE__*/jsx(
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
'np-popover-v2-container
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
'np-popover-v2
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
5623
|
+
children: /*#__PURE__*/jsx(FocusScope, {
|
|
5624
|
+
children: /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
5625
|
+
context: context,
|
|
5626
|
+
children: /*#__PURE__*/jsx("div", {
|
|
5627
|
+
// Force inner state invalidation on open
|
|
5628
|
+
ref: refs.setFloating,
|
|
5629
|
+
className: classNames('np-popover-v2-container', {
|
|
5630
|
+
'np-popover-v2-container--size-md': size$1 === 'md',
|
|
5631
|
+
'np-popover-v2-container--size-lg': size$1 === 'lg'
|
|
5632
|
+
})
|
|
5633
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
5634
|
+
,
|
|
5635
|
+
style: floatingStyles,
|
|
5636
|
+
...getFloatingProps(),
|
|
5637
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
5638
|
+
className: classNames('np-popover-v2', title && 'np-popover-v2--has-title', {
|
|
5639
|
+
'np-popover-v2--padding-md': padding === 'md'
|
|
5640
|
+
}),
|
|
5641
|
+
children: [title ? /*#__PURE__*/jsx("h2", {
|
|
5642
|
+
className: "np-popover-v2-title np-text-title-body",
|
|
5643
|
+
children: title
|
|
5644
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
5645
|
+
className: "np-popover-v2-content np-text-body-default",
|
|
5646
|
+
children: children
|
|
5647
|
+
})]
|
|
5648
|
+
})
|
|
5649
|
+
}, floatingKey)
|
|
5650
|
+
})
|
|
6146
5651
|
})
|
|
6147
5652
|
})
|
|
6148
5653
|
})
|
|
@@ -6238,6 +5743,7 @@ const defaultRenderTrigger = ({
|
|
|
6238
5743
|
})
|
|
6239
5744
|
})]
|
|
6240
5745
|
}),
|
|
5746
|
+
initialContentWidth: 24 + 4,
|
|
6241
5747
|
padding: 'sm'
|
|
6242
5748
|
},
|
|
6243
5749
|
disabled: disabled,
|
|
@@ -7147,7 +6653,6 @@ const Loader = ({
|
|
|
7147
6653
|
}, 1000);
|
|
7148
6654
|
}
|
|
7149
6655
|
return () => {
|
|
7150
|
-
// eslint-disable-next-line fp/no-mutation
|
|
7151
6656
|
cancelled = true;
|
|
7152
6657
|
clearTimeout(timeout);
|
|
7153
6658
|
};
|
|
@@ -9084,7 +8589,7 @@ const explodeNumberModel = number => {
|
|
|
9084
8589
|
};
|
|
9085
8590
|
};
|
|
9086
8591
|
|
|
9087
|
-
const DIGITS_MATCH = /^$|^(\+)|(
|
|
8592
|
+
const DIGITS_MATCH = /^$|^(\+)|(\d+)/g;
|
|
9088
8593
|
const cleanNumber = number => number.match(DIGITS_MATCH)?.join('') ?? '';
|
|
9089
8594
|
|
|
9090
8595
|
function sortArrayByProperty(arrayToSort, property) {
|
|
@@ -9170,7 +8675,8 @@ const PhoneNumberInput = ({
|
|
|
9170
8675
|
};
|
|
9171
8676
|
useEffect(() => {
|
|
9172
8677
|
if (broadcastedValue === null) {
|
|
9173
|
-
|
|
8678
|
+
setBroadcastedValue(internalValue);
|
|
8679
|
+
return;
|
|
9174
8680
|
}
|
|
9175
8681
|
const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;
|
|
9176
8682
|
const broadcastedPhoneNumber = `${broadcastedValue.prefix ?? ''}${broadcastedValue.suffix}`;
|
|
@@ -9443,7 +8949,7 @@ const PromoCard = /*#__PURE__*/forwardRef(({
|
|
|
9443
8949
|
const checkedProps = (type === 'checkbox' || type === 'radio') && !href ? {
|
|
9444
8950
|
...commonProps,
|
|
9445
8951
|
'aria-checked': type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
|
|
9446
|
-
'aria-describedby': `${componentId}-title
|
|
8952
|
+
'aria-describedby': `${componentId}-title`,
|
|
9447
8953
|
'aria-disabled': isDisabled,
|
|
9448
8954
|
'data-value': value ?? undefined,
|
|
9449
8955
|
role: type === 'checkbox' || type === 'radio' ? type : undefined,
|
|
@@ -10096,8 +9602,8 @@ function Select({
|
|
|
10096
9602
|
}
|
|
10097
9603
|
};
|
|
10098
9604
|
function selectKeyboardFocusedOption() {
|
|
10099
|
-
if (keyboardFocusedOptionIndex != null) {
|
|
10100
|
-
|
|
9605
|
+
if (keyboardFocusedOptionIndex != null && selectableOptions.length > 0) {
|
|
9606
|
+
selectOption(selectableOptions[keyboardFocusedOptionIndex]);
|
|
10101
9607
|
}
|
|
10102
9608
|
}
|
|
10103
9609
|
function moveFocusWithDifference(difference) {
|
|
@@ -10324,7 +9830,6 @@ function Select({
|
|
|
10324
9830
|
disabled: disabled,
|
|
10325
9831
|
"aria-controls": listboxId,
|
|
10326
9832
|
"aria-expanded": open,
|
|
10327
|
-
"aria-autocomplete": "none",
|
|
10328
9833
|
onClick: handleOnClick,
|
|
10329
9834
|
...buttonProps,
|
|
10330
9835
|
children: [selected ? /*#__PURE__*/jsx(Option$1, {
|
|
@@ -10440,12 +9945,11 @@ Select.defaultProps = {
|
|
|
10440
9945
|
|
|
10441
9946
|
const SegmentedControl = ({
|
|
10442
9947
|
name,
|
|
10443
|
-
|
|
9948
|
+
value,
|
|
10444
9949
|
mode = 'input',
|
|
10445
9950
|
segments,
|
|
10446
9951
|
onChange
|
|
10447
9952
|
}) => {
|
|
10448
|
-
const [selectedValue, setSelectedValue] = useState(defaultValue || segments[0].value);
|
|
10449
9953
|
const [animate, setAnimate] = useState(false);
|
|
10450
9954
|
const segmentsRef = useRef(null);
|
|
10451
9955
|
if (segments.length > 3) {
|
|
@@ -10456,7 +9960,7 @@ const SegmentedControl = ({
|
|
|
10456
9960
|
ref: /*#__PURE__*/createRef()
|
|
10457
9961
|
}));
|
|
10458
9962
|
const updateSegmentPosition = () => {
|
|
10459
|
-
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value ===
|
|
9963
|
+
const selectedSegmentRef = segmentsWithRefs.find(segment => segment.value === value)?.ref;
|
|
10460
9964
|
// We grab the active segments style object from the ref
|
|
10461
9965
|
// and set the css variables to the selected segments width and x position.
|
|
10462
9966
|
// This is so we can animate the highlight to the selected segment
|
|
@@ -10469,6 +9973,7 @@ const SegmentedControl = ({
|
|
|
10469
9973
|
}
|
|
10470
9974
|
};
|
|
10471
9975
|
useEffect(() => {
|
|
9976
|
+
setAnimate(true);
|
|
10472
9977
|
updateSegmentPosition();
|
|
10473
9978
|
const handleWindowSizeChange = () => {
|
|
10474
9979
|
setAnimate(false);
|
|
@@ -10479,10 +9984,7 @@ const SegmentedControl = ({
|
|
|
10479
9984
|
window.removeEventListener('resize', handleWindowSizeChange);
|
|
10480
9985
|
};
|
|
10481
9986
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10482
|
-
}, [segmentsWithRefs,
|
|
10483
|
-
useEffect(() => {
|
|
10484
|
-
onChange(selectedValue);
|
|
10485
|
-
}, [onChange, selectedValue]);
|
|
9987
|
+
}, [segmentsWithRefs, value]);
|
|
10486
9988
|
return /*#__PURE__*/jsx("div", {
|
|
10487
9989
|
ref: segmentsRef,
|
|
10488
9990
|
"data-testid": "segmented-control",
|
|
@@ -10494,50 +9996,50 @@ const SegmentedControl = ({
|
|
|
10494
9996
|
'segmented-control__segments--no-animate': !animate
|
|
10495
9997
|
}),
|
|
10496
9998
|
role: mode !== 'input' ? 'tablist' : undefined,
|
|
10497
|
-
children: segmentsWithRefs.map(segment =>
|
|
10498
|
-
|
|
10499
|
-
htmlFor: segment.id,
|
|
10500
|
-
className: classNames('segmented-control__segment', {
|
|
10501
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10502
|
-
}),
|
|
10503
|
-
children: [/*#__PURE__*/jsx("input", {
|
|
10504
|
-
type: "radio",
|
|
10505
|
-
className: "segmented-control__radio-input",
|
|
10506
|
-
id: segment.id,
|
|
10507
|
-
name: name,
|
|
10508
|
-
value: segment.value,
|
|
10509
|
-
checked: selectedValue === segment.value,
|
|
10510
|
-
onChange: () => {
|
|
10511
|
-
setAnimate(true);
|
|
10512
|
-
setSelectedValue(segment.value);
|
|
10513
|
-
}
|
|
10514
|
-
}), /*#__PURE__*/jsx(Body, {
|
|
10515
|
-
className: "segmented-control__text",
|
|
10516
|
-
as: "span",
|
|
10517
|
-
type: selectedValue === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10518
|
-
children: segment.label
|
|
10519
|
-
})]
|
|
10520
|
-
}, segment.id) : /*#__PURE__*/jsx("button", {
|
|
10521
|
-
ref: segment.ref,
|
|
10522
|
-
type: "button",
|
|
10523
|
-
role: "tab",
|
|
10524
|
-
id: segment.id,
|
|
10525
|
-
"aria-controls": segment.controls,
|
|
10526
|
-
"aria-selected": selectedValue === segment.value,
|
|
10527
|
-
className: classNames('segmented-control__segment', 'segmented-control__button', {
|
|
10528
|
-
'segmented-control__selected-segment': selectedValue === segment.value
|
|
10529
|
-
}),
|
|
10530
|
-
onClick: () => {
|
|
9999
|
+
children: segmentsWithRefs.map(segment => {
|
|
10000
|
+
const onSelect = () => {
|
|
10531
10001
|
setAnimate(true);
|
|
10532
|
-
|
|
10533
|
-
}
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10002
|
+
onChange(segment.value);
|
|
10003
|
+
};
|
|
10004
|
+
return mode === 'input' ? /*#__PURE__*/jsxs("label", {
|
|
10005
|
+
ref: segment.ref,
|
|
10006
|
+
htmlFor: segment.id,
|
|
10007
|
+
className: classNames('segmented-control__segment', {
|
|
10008
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10009
|
+
}),
|
|
10010
|
+
children: [/*#__PURE__*/jsx("input", {
|
|
10011
|
+
type: "radio",
|
|
10012
|
+
className: "segmented-control__radio-input",
|
|
10013
|
+
id: segment.id,
|
|
10014
|
+
name: name,
|
|
10015
|
+
value: segment.value,
|
|
10016
|
+
checked: value === segment.value,
|
|
10017
|
+
onChange: onSelect
|
|
10018
|
+
}), /*#__PURE__*/jsx(Body, {
|
|
10019
|
+
className: "segmented-control__text",
|
|
10020
|
+
as: "span",
|
|
10021
|
+
type: value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10022
|
+
children: segment.label
|
|
10023
|
+
})]
|
|
10024
|
+
}, segment.id) : /*#__PURE__*/jsx("button", {
|
|
10025
|
+
ref: segment.ref,
|
|
10026
|
+
type: "button",
|
|
10027
|
+
role: "tab",
|
|
10028
|
+
id: segment.id,
|
|
10029
|
+
"aria-controls": segment.controls,
|
|
10030
|
+
"aria-selected": value === segment.value,
|
|
10031
|
+
className: classNames('segmented-control__segment', 'segmented-control__button', {
|
|
10032
|
+
'segmented-control__selected-segment': value === segment.value
|
|
10033
|
+
}),
|
|
10034
|
+
onClick: onSelect,
|
|
10035
|
+
children: /*#__PURE__*/jsx(Body, {
|
|
10036
|
+
as: "span",
|
|
10037
|
+
className: "segmented-control__text",
|
|
10038
|
+
type: value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT,
|
|
10039
|
+
children: segment.label
|
|
10040
|
+
})
|
|
10041
|
+
}, segment.id);
|
|
10042
|
+
})
|
|
10541
10043
|
})
|
|
10542
10044
|
});
|
|
10543
10045
|
};
|
|
@@ -14836,5 +14338,5 @@ const translations = {
|
|
|
14836
14338
|
'zh-HK': zhHK
|
|
14837
14339
|
};
|
|
14838
14340
|
|
|
14839
|
-
export { Accordion, ActionButton, ActionOption, Alert, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade,
|
|
14341
|
+
export { Accordion, ActionButton, ActionOption, Alert, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCard$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
|
|
14840
14342
|
//# sourceMappingURL=index.mjs.map
|