@transferwise/components 46.19.0 → 46.20.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.esm.js +59 -84
- package/build/index.esm.js.map +1 -1
- package/build/index.js +58 -83
- package/build/index.js.map +1 -1
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/common/textFormat/formatWithPattern/index.d.ts +1 -1
- package/build/types/common/textFormat/formatWithPattern/index.d.ts.map +1 -1
- package/build/types/common/textFormat/getCountOfSymbolsInSelection/getCountOfSymbolsInSelection.d.ts +1 -1
- package/build/types/common/textFormat/getCountOfSymbolsInSelection/getCountOfSymbolsInSelection.d.ts.map +1 -1
- package/build/types/common/textFormat/getCountOfSymbolsInSelection/index.d.ts +1 -1
- package/build/types/common/textFormat/getCountOfSymbolsInSelection/index.d.ts.map +1 -1
- package/build/types/common/textFormat/getCursorPositionAfterKeystroke/index.d.ts +1 -1
- package/build/types/common/textFormat/getCursorPositionAfterKeystroke/index.d.ts.map +1 -1
- package/build/types/common/textFormat/getDistanceToSymbol/getDistanceToSymbol.d.ts +2 -2
- package/build/types/common/textFormat/getDistanceToSymbol/getDistanceToSymbol.d.ts.map +1 -1
- package/build/types/common/textFormat/getDistanceToSymbol/index.d.ts +1 -1
- package/build/types/common/textFormat/getDistanceToSymbol/index.d.ts.map +1 -1
- package/build/types/common/textFormat/getSymbolsInPatternWithPosition/index.d.ts +1 -1
- package/build/types/common/textFormat/getSymbolsInPatternWithPosition/index.d.ts.map +1 -1
- package/build/types/common/textFormat/index.d.ts +7 -6
- package/build/types/common/textFormat/index.d.ts.map +1 -1
- package/build/types/common/textFormat/unformatWithPattern/index.d.ts +1 -1
- package/build/types/common/textFormat/unformatWithPattern/index.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/info/Info.d.ts +3 -2
- package/build/types/info/Info.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts +16 -21
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/popover/index.d.ts +2 -1
- package/build/types/popover/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/panel/Panel.tsx +1 -0
- package/src/common/textFormat/getCountOfSymbolsInSelection/{getCountOfSymbolsInSelection.js → getCountOfSymbolsInSelection.ts} +5 -1
- package/src/common/textFormat/getCursorPositionAfterKeystroke/{getCursorPositionAfterKeystroke.spec.js → getCursorPositionAfterKeystroke.spec.ts} +15 -18
- package/src/common/textFormat/getDistanceToSymbol/{getDistanceToSymbol.spec.js → getDistanceToSymbol.spec.ts} +3 -3
- package/src/common/textFormat/getDistanceToSymbol/{getDistanceToSymbol.js → getDistanceToSymbol.ts} +8 -3
- package/src/index.ts +1 -0
- package/src/info/Info.tsx +2 -2
- package/src/logo/Logo.js +1 -0
- package/src/logo/__snapshots__/Logo.spec.js.snap +6 -0
- package/src/popover/{Popover.spec.js → Popover.spec.tsx} +5 -2
- package/src/popover/Popover.tsx +101 -0
- package/src/popover/__snapshots__/{Popover.spec.js.snap → Popover.spec.tsx.snap} +2 -3
- package/src/popover/index.ts +2 -0
- package/src/popover/Popover.js +0 -101
- package/src/popover/index.js +0 -1
- /package/src/common/textFormat/formatWithPattern/{formatWithPattern.spec.js → formatWithPattern.spec.ts} +0 -0
- /package/src/common/textFormat/formatWithPattern/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/getCountOfSymbolsInSelection/{getCountOfSymbolsInSelection.spec.js → getCountOfSymbolsInSelection.spec.ts} +0 -0
- /package/src/common/textFormat/getCountOfSymbolsInSelection/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/getCursorPositionAfterKeystroke/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/getDistanceToSymbol/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/getSymbolsInPatternWithPosition/{getSymbolsInPatternWithPosition.spec.js → getSymbolsInPatternWithPosition.spec.ts} +0 -0
- /package/src/common/textFormat/getSymbolsInPatternWithPosition/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/unformatWithPattern/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.spec.js → unformatWithPattern.spec.ts} +0 -0
- /package/src/popover/{Popover.story.js → Popover.story.tsx} +0 -0
package/build/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { forwardRef, cloneElement, useState, useRef, useMemo, useEffect, useCallback, useLayoutEffect, createContext, useContext, createElement, Component, PureComponent, createRef, Children, Fragment as Fragment$1 } from 'react';
|
|
4
|
+
import React__default, { forwardRef, cloneElement, useState, useRef, useMemo, useEffect, useCallback, useLayoutEffect, createContext, useContext, createElement, Component, PureComponent, createRef, isValidElement, Children, Fragment as Fragment$1 } from 'react';
|
|
5
5
|
import { useId } from '@radix-ui/react-id';
|
|
6
6
|
import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$2, ClockBorderless, CheckCircle, InfoCircle, Warning, CrossCircle, Clock, Briefcase, Person, ArrowLeft, QuestionMarkCircle, AlertCircle, Search, ChevronDown, CheckCircleFill, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, AlertCircleFill } from '@transferwise/icons';
|
|
7
7
|
import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
|
|
@@ -816,7 +816,7 @@ const StatusIcon = ({
|
|
|
816
816
|
});
|
|
817
817
|
};
|
|
818
818
|
|
|
819
|
-
function logActionRequired$
|
|
819
|
+
function logActionRequired$1(message) {
|
|
820
820
|
if (['development', 'test'].includes(process?.env?.NODE_ENV)) {
|
|
821
821
|
// eslint-disable-next-line no-console
|
|
822
822
|
console.warn(message);
|
|
@@ -824,7 +824,7 @@ function logActionRequired$2(message) {
|
|
|
824
824
|
}
|
|
825
825
|
function logActionRequiredIf(message, conditional) {
|
|
826
826
|
if (conditional) {
|
|
827
|
-
logActionRequired$
|
|
827
|
+
logActionRequired$1(message);
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
830
|
|
|
@@ -855,7 +855,7 @@ const deprecated = (validator, {
|
|
|
855
855
|
}) => (props, propertyName, ...rest) => {
|
|
856
856
|
const newPropertyMessage = newProperty ? `Please use ${newProperty} instead.` : message;
|
|
857
857
|
if (props[propertyName] != null && typeof props[propertyName] !== 'undefined') {
|
|
858
|
-
logActionRequired$
|
|
858
|
+
logActionRequired$1(deprecatedMessage({
|
|
859
859
|
component,
|
|
860
860
|
propName: propertyName,
|
|
861
861
|
message: newPropertyMessage,
|
|
@@ -884,7 +884,7 @@ function Markdown({
|
|
|
884
884
|
}
|
|
885
885
|
const linkTarget = config?.link?.target ?? '_self';
|
|
886
886
|
if (allowList != null && blockList != null) {
|
|
887
|
-
logActionRequired$
|
|
887
|
+
logActionRequired$1('Markdown supports only one of `allowList` or `blockList` to be used at a time. `blockList` will be ignored.');
|
|
888
888
|
}
|
|
889
889
|
const parser = nodes => {
|
|
890
890
|
const parsed = reader.parse(nodes);
|
|
@@ -1036,7 +1036,7 @@ const Alert = props => {
|
|
|
1036
1036
|
...props
|
|
1037
1037
|
});
|
|
1038
1038
|
}
|
|
1039
|
-
logActionRequired
|
|
1039
|
+
logActionRequired(props);
|
|
1040
1040
|
const mappedType = deprecatedTypeMap$1[type] || type;
|
|
1041
1041
|
const Icon = iconTypeMap[mappedType];
|
|
1042
1042
|
function generateIcon() {
|
|
@@ -1119,7 +1119,7 @@ const deprecatedTypeMapMessage$1 = {
|
|
|
1119
1119
|
[Sentiment.ERROR]: 'Sentiment.NEGATIVE'
|
|
1120
1120
|
};
|
|
1121
1121
|
const deprecatedTypes$1 = Object.keys(deprecatedTypeMap$1);
|
|
1122
|
-
function logActionRequired
|
|
1122
|
+
function logActionRequired({
|
|
1123
1123
|
size,
|
|
1124
1124
|
type
|
|
1125
1125
|
}) {
|
|
@@ -3119,7 +3119,8 @@ const Panel = /*#__PURE__*/forwardRef(({
|
|
|
3119
3119
|
onClose: onClose,
|
|
3120
3120
|
children: /*#__PURE__*/jsx("div", {
|
|
3121
3121
|
...rest,
|
|
3122
|
-
ref: setPopperElement
|
|
3122
|
+
ref: setPopperElement,
|
|
3123
|
+
role: "dialog"
|
|
3123
3124
|
// eslint-disable-next-line react/forbid-dom-props
|
|
3124
3125
|
,
|
|
3125
3126
|
style: {
|
|
@@ -5252,6 +5253,7 @@ const Logo = ({
|
|
|
5252
5253
|
const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5253
5254
|
return /*#__PURE__*/jsxs("span", {
|
|
5254
5255
|
"aria-label": type === LogoType.WISE ? 'Wise' : 'Wise business',
|
|
5256
|
+
role: "img",
|
|
5255
5257
|
className: classNames(className, 'np-logo'),
|
|
5256
5258
|
children: [/*#__PURE__*/jsx(LogoSm, {
|
|
5257
5259
|
className: "np-logo-svg np-logo-svg--size-sm"
|
|
@@ -5775,22 +5777,33 @@ const Modal = ({
|
|
|
5775
5777
|
});
|
|
5776
5778
|
};
|
|
5777
5779
|
|
|
5778
|
-
|
|
5780
|
+
function resolvePlacement(preferredPlacement) {
|
|
5781
|
+
switch (preferredPlacement) {
|
|
5782
|
+
case 'left-top':
|
|
5783
|
+
case 'right-top':
|
|
5784
|
+
return 'top';
|
|
5785
|
+
case 'bottom-left':
|
|
5786
|
+
case 'bottom-right':
|
|
5787
|
+
return 'bottom';
|
|
5788
|
+
}
|
|
5789
|
+
return preferredPlacement;
|
|
5790
|
+
}
|
|
5791
|
+
function Popover$1({
|
|
5779
5792
|
children,
|
|
5780
5793
|
className,
|
|
5781
5794
|
content,
|
|
5782
|
-
preferredPlacement,
|
|
5795
|
+
preferredPlacement = Position.RIGHT,
|
|
5783
5796
|
title,
|
|
5784
5797
|
onClose
|
|
5785
|
-
})
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5798
|
+
}) {
|
|
5799
|
+
const resolvedPlacement = resolvePlacement(preferredPlacement);
|
|
5800
|
+
useEffect(() => {
|
|
5801
|
+
if (resolvedPlacement !== preferredPlacement) {
|
|
5802
|
+
logActionRequired$1(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`);
|
|
5803
|
+
}
|
|
5804
|
+
}, [preferredPlacement, resolvedPlacement]);
|
|
5789
5805
|
const anchorReference = useRef(null);
|
|
5790
5806
|
const [open, setOpen] = useState(false);
|
|
5791
|
-
const {
|
|
5792
|
-
isModern
|
|
5793
|
-
} = useTheme();
|
|
5794
5807
|
const handleOnClose = () => {
|
|
5795
5808
|
setOpen(false);
|
|
5796
5809
|
onClose?.();
|
|
@@ -5800,25 +5813,21 @@ const Popover$1 = ({
|
|
|
5800
5813
|
children: [/*#__PURE__*/jsx("span", {
|
|
5801
5814
|
ref: anchorReference,
|
|
5802
5815
|
className: "d-inline-block",
|
|
5803
|
-
children: /*#__PURE__*/cloneElement(children, {
|
|
5816
|
+
children: /*#__PURE__*/isValidElement(children) ? /*#__PURE__*/cloneElement(children, {
|
|
5804
5817
|
onClick: () => {
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
}
|
|
5808
|
-
setOpen(!open);
|
|
5818
|
+
children.props.onClick?.();
|
|
5819
|
+
setOpen(prevOpen => !prevOpen);
|
|
5809
5820
|
}
|
|
5810
|
-
})
|
|
5821
|
+
}) : children
|
|
5811
5822
|
}), /*#__PURE__*/jsx(ResponsivePanel$1, {
|
|
5812
5823
|
open: open,
|
|
5813
5824
|
anchorRef: anchorReference,
|
|
5814
|
-
position:
|
|
5825
|
+
position: resolvedPlacement,
|
|
5815
5826
|
arrow: true,
|
|
5816
5827
|
className: "np-popover__container",
|
|
5817
5828
|
onClose: handleOnClose,
|
|
5818
5829
|
children: /*#__PURE__*/jsxs("div", {
|
|
5819
|
-
className:
|
|
5820
|
-
"aria-hidden": !open,
|
|
5821
|
-
role: "dialog",
|
|
5830
|
+
className: "np-popover__content np-text-default-body",
|
|
5822
5831
|
children: [title && /*#__PURE__*/jsx(Title, {
|
|
5823
5832
|
type: Typography.TITLE_BODY,
|
|
5824
5833
|
className: "m-b-1",
|
|
@@ -5827,36 +5836,7 @@ const Popover$1 = ({
|
|
|
5827
5836
|
})
|
|
5828
5837
|
})]
|
|
5829
5838
|
});
|
|
5830
|
-
}
|
|
5831
|
-
const logActionRequired = ({
|
|
5832
|
-
preferredPlacement
|
|
5833
|
-
}) => {
|
|
5834
|
-
logActionRequiredIf(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${deprecatedPlacements[preferredPlacement]} instead.`, deprecatedPlacements[preferredPlacement]);
|
|
5835
|
-
};
|
|
5836
|
-
Popover$1.defaultProps = {
|
|
5837
|
-
className: undefined,
|
|
5838
|
-
preferredPlacement: Position.RIGHT,
|
|
5839
|
-
title: undefined
|
|
5840
|
-
};
|
|
5841
|
-
Popover$1.propTypes = {
|
|
5842
|
-
children: PropTypes.node.isRequired,
|
|
5843
|
-
className: PropTypes.string,
|
|
5844
|
-
content: PropTypes.node.isRequired,
|
|
5845
|
-
/**
|
|
5846
|
-
* `'left-top'` / `'right-top'` are deprecated use `Position.TOP` / `'top'` instead,
|
|
5847
|
-
* `'bottom-right'` / `'bottom-left'` are deprecated use `Position.BOTTOM` / `'bottom'` instead
|
|
5848
|
-
*/
|
|
5849
|
-
preferredPlacement: PropTypes.oneOf(['top', 'right', 'bottom', 'left', 'left-top', 'right-top', 'bottom-right', 'bottom-left']),
|
|
5850
|
-
onClose: PropTypes.func,
|
|
5851
|
-
title: PropTypes.node
|
|
5852
|
-
};
|
|
5853
|
-
const deprecatedPlacements = {
|
|
5854
|
-
[Position.BOTTOM_LEFT]: Position.BOTTOM,
|
|
5855
|
-
[Position.BOTTOM_RIGHT]: Position.BOTTOM,
|
|
5856
|
-
[Position.LEFT_TOP]: Position.TOP,
|
|
5857
|
-
[Position.RIGHT_TOP]: Position.TOP
|
|
5858
|
-
};
|
|
5859
|
-
var Popover$2 = Popover$1;
|
|
5839
|
+
}
|
|
5860
5840
|
|
|
5861
5841
|
var messages$6 = defineMessages({
|
|
5862
5842
|
ariaLabel: {
|
|
@@ -5907,7 +5887,7 @@ const Info = ({
|
|
|
5907
5887
|
title: title,
|
|
5908
5888
|
onClose: () => setOpen(false)
|
|
5909
5889
|
})]
|
|
5910
|
-
}) : /*#__PURE__*/jsx(Popover$
|
|
5890
|
+
}) : /*#__PURE__*/jsx(Popover$1, {
|
|
5911
5891
|
content: content,
|
|
5912
5892
|
preferredPlacement: preferredPlacement,
|
|
5913
5893
|
title: title,
|
|
@@ -6963,14 +6943,13 @@ const getSymbolsInPatternWithPosition = pattern => {
|
|
|
6963
6943
|
});
|
|
6964
6944
|
return patternWithSymbolsPosition;
|
|
6965
6945
|
};
|
|
6966
|
-
var getSymbolsInPatternWithPosition$1 = getSymbolsInPatternWithPosition;
|
|
6967
6946
|
|
|
6968
6947
|
const formatWithPattern = (value, pattern) => {
|
|
6969
6948
|
if (!value || value === '') {
|
|
6970
6949
|
return '';
|
|
6971
6950
|
}
|
|
6972
6951
|
const valueArray = value.toString().split('');
|
|
6973
|
-
const patternWithSymbolsPosition = getSymbolsInPatternWithPosition
|
|
6952
|
+
const patternWithSymbolsPosition = getSymbolsInPatternWithPosition(pattern);
|
|
6974
6953
|
let patternSymbol = [];
|
|
6975
6954
|
// valueArray.length increments during the cycle cause we are adding new elements.
|
|
6976
6955
|
for (let index = 0; index < valueArray.length; index += 1) {
|
|
@@ -6985,7 +6964,6 @@ const formatWithPattern = (value, pattern) => {
|
|
|
6985
6964
|
}
|
|
6986
6965
|
return valueArray.join('');
|
|
6987
6966
|
};
|
|
6988
|
-
var formatWithPattern$1 = formatWithPattern;
|
|
6989
6967
|
|
|
6990
6968
|
const unformatWithPattern = (value, pattern) => {
|
|
6991
6969
|
let valueArray = [''];
|
|
@@ -6996,18 +6974,16 @@ const unformatWithPattern = (value, pattern) => {
|
|
|
6996
6974
|
return valueArray.join('');
|
|
6997
6975
|
};
|
|
6998
6976
|
const getSymbolsInPattern = pattern => pattern.split('').filter(symbol => symbol !== '*');
|
|
6999
|
-
var unformatWithPattern$1 = unformatWithPattern;
|
|
7000
6977
|
|
|
7001
|
-
const getCountOfSymbolsInSelection = (selectionStart, selectionEnd, pattern) => getSymbolsInPatternWithPosition
|
|
7002
|
-
var getCountOfSymbolsInSelection$1 = getCountOfSymbolsInSelection;
|
|
6978
|
+
const getCountOfSymbolsInSelection = (selectionStart, selectionEnd, pattern) => getSymbolsInPatternWithPosition(pattern).filter(symbol => symbol.index >= selectionStart && symbol.index < selectionEnd).length;
|
|
7003
6979
|
|
|
7004
6980
|
const getDistanceToNextSymbol = (selectionStart, pattern) => {
|
|
7005
|
-
const patternArray = getSymbolsInPatternWithPosition
|
|
6981
|
+
const patternArray = getSymbolsInPatternWithPosition(pattern);
|
|
7006
6982
|
const applicablePattern = patternArray.filter(symbol => symbol.index >= selectionStart);
|
|
7007
6983
|
return countConsecutiveSymbols(selectionStart, applicablePattern, 'left');
|
|
7008
6984
|
};
|
|
7009
6985
|
const getDistanceToPreviousSymbol = (selectionStart, pattern) => {
|
|
7010
|
-
const patternArray = getSymbolsInPatternWithPosition
|
|
6986
|
+
const patternArray = getSymbolsInPatternWithPosition(pattern);
|
|
7011
6987
|
const applicablePattern = patternArray.filter(symbol => symbol.index < selectionStart).reverse();
|
|
7012
6988
|
return countConsecutiveSymbols(selectionStart, applicablePattern, 'right');
|
|
7013
6989
|
};
|
|
@@ -7037,7 +7013,7 @@ const getCursorPositionAfterActionStroke = (action, selectionStart, selectionEnd
|
|
|
7037
7013
|
}
|
|
7038
7014
|
break;
|
|
7039
7015
|
case 'Paste':
|
|
7040
|
-
cursorPosition += pastedLength + getCountOfSymbolsInSelection
|
|
7016
|
+
cursorPosition += pastedLength + getCountOfSymbolsInSelection(selectionStart, selectionStart + pastedLength, pattern) + getDistanceToNextSymbol(selectionStart + pastedLength, pattern);
|
|
7041
7017
|
break;
|
|
7042
7018
|
case 'Cut':
|
|
7043
7019
|
case 'Delete':
|
|
@@ -7048,7 +7024,6 @@ const getCursorPositionAfterActionStroke = (action, selectionStart, selectionEnd
|
|
|
7048
7024
|
}
|
|
7049
7025
|
return cursorPosition;
|
|
7050
7026
|
};
|
|
7051
|
-
var getCursorPositionAfterKeystroke = getCursorPositionAfterActionStroke;
|
|
7052
7027
|
|
|
7053
7028
|
class WithDisplayFormat extends Component {
|
|
7054
7029
|
static defaultProps = {
|
|
@@ -7058,9 +7033,9 @@ class WithDisplayFormat extends Component {
|
|
|
7058
7033
|
};
|
|
7059
7034
|
constructor(props) {
|
|
7060
7035
|
super(props);
|
|
7061
|
-
const unformattedValue = unformatWithPattern
|
|
7036
|
+
const unformattedValue = unformatWithPattern(props.value ?? '', props.displayPattern);
|
|
7062
7037
|
this.state = {
|
|
7063
|
-
value: formatWithPattern
|
|
7038
|
+
value: formatWithPattern(unformattedValue, props.displayPattern),
|
|
7064
7039
|
historyNavigator: new HistoryNavigator$1(),
|
|
7065
7040
|
prevDisplayPattern: props.displayPattern,
|
|
7066
7041
|
triggerType: 'Initial',
|
|
@@ -7078,11 +7053,11 @@ class WithDisplayFormat extends Component {
|
|
|
7078
7053
|
historyNavigator
|
|
7079
7054
|
}) {
|
|
7080
7055
|
if (prevDisplayPattern !== displayPattern) {
|
|
7081
|
-
const unFormattedValue = unformatWithPattern
|
|
7056
|
+
const unFormattedValue = unformatWithPattern(value, prevDisplayPattern);
|
|
7082
7057
|
historyNavigator.reset();
|
|
7083
7058
|
return {
|
|
7084
7059
|
prevDisplayPattern: displayPattern,
|
|
7085
|
-
value: formatWithPattern
|
|
7060
|
+
value: formatWithPattern(unFormattedValue, displayPattern),
|
|
7086
7061
|
triggerType: null,
|
|
7087
7062
|
triggerEvent: null,
|
|
7088
7063
|
pastedLength: 0
|
|
@@ -7112,7 +7087,7 @@ class WithDisplayFormat extends Component {
|
|
|
7112
7087
|
return 'Delete';
|
|
7113
7088
|
}
|
|
7114
7089
|
// Android Fix.
|
|
7115
|
-
if (typeof triggerEvent.key === 'undefined' && unformattedValue.length <= unformatWithPattern
|
|
7090
|
+
if (typeof triggerEvent.key === 'undefined' && unformattedValue.length <= unformatWithPattern(value, displayPattern).length) {
|
|
7116
7091
|
return 'Backspace';
|
|
7117
7092
|
}
|
|
7118
7093
|
return triggerEvent.key;
|
|
@@ -7150,13 +7125,13 @@ class WithDisplayFormat extends Component {
|
|
|
7150
7125
|
// Unfortunately Undo and Redo don't trigger OnChange event so we need to handle some value logic here.
|
|
7151
7126
|
let newFormattedValue = '';
|
|
7152
7127
|
if (this.detectUndoRedo(event) === 'Undo') {
|
|
7153
|
-
newFormattedValue = formatWithPattern
|
|
7128
|
+
newFormattedValue = formatWithPattern(historyNavigator.undo(), displayPattern);
|
|
7154
7129
|
this.setState({
|
|
7155
7130
|
value: newFormattedValue,
|
|
7156
7131
|
triggerType: 'Undo'
|
|
7157
7132
|
});
|
|
7158
7133
|
} else if (this.detectUndoRedo(event) === 'Redo') {
|
|
7159
|
-
newFormattedValue = formatWithPattern
|
|
7134
|
+
newFormattedValue = formatWithPattern(historyNavigator.redo(), displayPattern);
|
|
7160
7135
|
this.setState({
|
|
7161
7136
|
value: newFormattedValue,
|
|
7162
7137
|
triggerType: 'Redo'
|
|
@@ -7174,7 +7149,7 @@ class WithDisplayFormat extends Component {
|
|
|
7174
7149
|
const {
|
|
7175
7150
|
displayPattern
|
|
7176
7151
|
} = this.props;
|
|
7177
|
-
const pastedLength = unformatWithPattern
|
|
7152
|
+
const pastedLength = unformatWithPattern(event.clipboardData.getData('Text'), displayPattern).length;
|
|
7178
7153
|
this.setState({
|
|
7179
7154
|
triggerType: 'Paste',
|
|
7180
7155
|
pastedLength
|
|
@@ -7204,7 +7179,7 @@ class WithDisplayFormat extends Component {
|
|
|
7204
7179
|
const {
|
|
7205
7180
|
value
|
|
7206
7181
|
} = event.target;
|
|
7207
|
-
let unformattedValue = unformatWithPattern
|
|
7182
|
+
let unformattedValue = unformatWithPattern(value, displayPattern);
|
|
7208
7183
|
const action = this.getUserAction(unformattedValue);
|
|
7209
7184
|
if (!this.isKeyAllowed(action) || triggerType === 'Undo' || triggerType === 'Redo') {
|
|
7210
7185
|
return;
|
|
@@ -7212,7 +7187,7 @@ class WithDisplayFormat extends Component {
|
|
|
7212
7187
|
if (action === 'Backspace' || action === 'Delete') {
|
|
7213
7188
|
unformattedValue = this.handleDelete(unformattedValue, action);
|
|
7214
7189
|
}
|
|
7215
|
-
const newFormattedValue = formatWithPattern
|
|
7190
|
+
const newFormattedValue = formatWithPattern(unformattedValue, displayPattern);
|
|
7216
7191
|
historyNavigator.add(unformattedValue);
|
|
7217
7192
|
this.handleCursorPositioning(action);
|
|
7218
7193
|
this.setState({
|
|
@@ -7220,13 +7195,13 @@ class WithDisplayFormat extends Component {
|
|
|
7220
7195
|
}, () => {
|
|
7221
7196
|
this.resetEvent();
|
|
7222
7197
|
if (onChange) {
|
|
7223
|
-
const broadcastValue = unformatWithPattern
|
|
7198
|
+
const broadcastValue = unformatWithPattern(newFormattedValue, displayPattern);
|
|
7224
7199
|
onChange(broadcastValue);
|
|
7225
7200
|
}
|
|
7226
7201
|
});
|
|
7227
7202
|
};
|
|
7228
7203
|
handleOnBlur = event => {
|
|
7229
|
-
this.props.onBlur?.(unformatWithPattern
|
|
7204
|
+
this.props.onBlur?.(unformatWithPattern(event.target.value, this.props.displayPattern));
|
|
7230
7205
|
};
|
|
7231
7206
|
handleOnFocus = event => {
|
|
7232
7207
|
const {
|
|
@@ -7235,7 +7210,7 @@ class WithDisplayFormat extends Component {
|
|
|
7235
7210
|
} = this.props;
|
|
7236
7211
|
if (onFocus) {
|
|
7237
7212
|
this.handleOnChange(event);
|
|
7238
|
-
onFocus(unformatWithPattern
|
|
7213
|
+
onFocus(unformatWithPattern(event.target.value, displayPattern));
|
|
7239
7214
|
}
|
|
7240
7215
|
};
|
|
7241
7216
|
handleDelete = (unformattedValue, action) => {
|
|
@@ -7248,7 +7223,7 @@ class WithDisplayFormat extends Component {
|
|
|
7248
7223
|
} = this.state;
|
|
7249
7224
|
const newStack = [...unformattedValue];
|
|
7250
7225
|
if (selectionStart === selectionEnd) {
|
|
7251
|
-
let startPosition = selectionStart - getCountOfSymbolsInSelection
|
|
7226
|
+
let startPosition = selectionStart - getCountOfSymbolsInSelection(0, selectionStart, displayPattern);
|
|
7252
7227
|
let toDelete = 0;
|
|
7253
7228
|
let count = getDistanceToNextSymbol(selectionStart, displayPattern);
|
|
7254
7229
|
if (action === 'Backspace') {
|
|
@@ -7272,7 +7247,7 @@ class WithDisplayFormat extends Component {
|
|
|
7272
7247
|
selectionEnd,
|
|
7273
7248
|
pastedLength
|
|
7274
7249
|
} = this.state;
|
|
7275
|
-
const cursorPosition =
|
|
7250
|
+
const cursorPosition = getCursorPositionAfterActionStroke(action, selectionStart, selectionEnd, displayPattern, pastedLength);
|
|
7276
7251
|
setTimeout(() => {
|
|
7277
7252
|
if (triggerEvent) {
|
|
7278
7253
|
triggerEvent.target.setSelectionRange(cursorPosition, cursorPosition);
|
|
@@ -15117,5 +15092,5 @@ const translations = {
|
|
|
15117
15092
|
'zh-HK': zhHK
|
|
15118
15093
|
};
|
|
15119
15094
|
|
|
15120
|
-
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, 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$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$
|
|
15095
|
+
export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, 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$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 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$1 as Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
|
|
15121
15096
|
//# sourceMappingURL=index.esm.js.map
|