@transferwise/components 0.0.0-experimental-a6eccb9 → 0.0.0-experimental-eecc435
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 +73 -60
- package/build/index.esm.js.map +1 -1
- package/build/index.js +72 -59
- package/build/index.js.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 +0 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/info/Info.d.ts +2 -3
- 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 +21 -16
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/popover/index.d.ts +1 -2
- package/build/types/popover/index.d.ts.map +1 -1
- package/package.json +1 -1
- 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 +0 -1
- 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.js +101 -0
- package/src/popover/{Popover.spec.tsx → Popover.spec.js} +2 -5
- package/src/popover/index.js +1 -0
- package/src/popover/Popover.tsx +0 -106
- package/src/popover/index.ts +0 -2
- /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.tsx → Popover.story.js} +0 -0
- /package/src/popover/__snapshots__/{Popover.spec.tsx.snap → Popover.spec.js.snap} +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,
|
|
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';
|
|
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$2(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$1(message) {
|
|
|
824
824
|
}
|
|
825
825
|
function logActionRequiredIf(message, conditional) {
|
|
826
826
|
if (conditional) {
|
|
827
|
-
logActionRequired$
|
|
827
|
+
logActionRequired$2(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$2(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$2('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(props);
|
|
1039
|
+
logActionRequired$1(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$1({
|
|
1123
1123
|
size,
|
|
1124
1124
|
type
|
|
1125
1125
|
}) {
|
|
@@ -5252,6 +5252,7 @@ const Logo = ({
|
|
|
5252
5252
|
const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
|
|
5253
5253
|
return /*#__PURE__*/jsxs("span", {
|
|
5254
5254
|
"aria-label": type === LogoType.WISE ? 'Wise' : 'Wise business',
|
|
5255
|
+
role: "img",
|
|
5255
5256
|
className: classNames(className, 'np-logo'),
|
|
5256
5257
|
children: [/*#__PURE__*/jsx(LogoSm, {
|
|
5257
5258
|
className: "np-logo-svg np-logo-svg--size-sm"
|
|
@@ -5775,31 +5776,17 @@ const Modal = ({
|
|
|
5775
5776
|
});
|
|
5776
5777
|
};
|
|
5777
5778
|
|
|
5778
|
-
|
|
5779
|
-
switch (preferredPlacement) {
|
|
5780
|
-
case 'left-top':
|
|
5781
|
-
case 'right-top':
|
|
5782
|
-
return 'top';
|
|
5783
|
-
case 'bottom-left':
|
|
5784
|
-
case 'bottom-right':
|
|
5785
|
-
return 'bottom';
|
|
5786
|
-
}
|
|
5787
|
-
return preferredPlacement;
|
|
5788
|
-
}
|
|
5789
|
-
function Popover$1({
|
|
5779
|
+
const Popover$1 = ({
|
|
5790
5780
|
children,
|
|
5791
5781
|
className,
|
|
5792
5782
|
content,
|
|
5793
|
-
preferredPlacement
|
|
5783
|
+
preferredPlacement,
|
|
5794
5784
|
title,
|
|
5795
5785
|
onClose
|
|
5796
|
-
}) {
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
logActionRequired$1(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`);
|
|
5801
|
-
}
|
|
5802
|
-
}, [preferredPlacement, resolvedPlacement]);
|
|
5786
|
+
}) => {
|
|
5787
|
+
logActionRequired({
|
|
5788
|
+
preferredPlacement
|
|
5789
|
+
});
|
|
5803
5790
|
const anchorReference = useRef(null);
|
|
5804
5791
|
const [open, setOpen] = useState(false);
|
|
5805
5792
|
const {
|
|
@@ -5814,16 +5801,18 @@ function Popover$1({
|
|
|
5814
5801
|
children: [/*#__PURE__*/jsx("span", {
|
|
5815
5802
|
ref: anchorReference,
|
|
5816
5803
|
className: "d-inline-block",
|
|
5817
|
-
children: /*#__PURE__*/
|
|
5804
|
+
children: /*#__PURE__*/cloneElement(children, {
|
|
5818
5805
|
onClick: () => {
|
|
5819
|
-
children
|
|
5820
|
-
|
|
5806
|
+
if (children?.props?.onClick) {
|
|
5807
|
+
children.props.onClick();
|
|
5808
|
+
}
|
|
5809
|
+
setOpen(!open);
|
|
5821
5810
|
}
|
|
5822
|
-
})
|
|
5811
|
+
})
|
|
5823
5812
|
}), /*#__PURE__*/jsx(ResponsivePanel$1, {
|
|
5824
5813
|
open: open,
|
|
5825
5814
|
anchorRef: anchorReference,
|
|
5826
|
-
position:
|
|
5815
|
+
position: deprecatedPlacements[preferredPlacement] || preferredPlacement,
|
|
5827
5816
|
arrow: true,
|
|
5828
5817
|
className: "np-popover__container",
|
|
5829
5818
|
onClose: handleOnClose,
|
|
@@ -5839,7 +5828,36 @@ function Popover$1({
|
|
|
5839
5828
|
})
|
|
5840
5829
|
})]
|
|
5841
5830
|
});
|
|
5842
|
-
}
|
|
5831
|
+
};
|
|
5832
|
+
const logActionRequired = ({
|
|
5833
|
+
preferredPlacement
|
|
5834
|
+
}) => {
|
|
5835
|
+
logActionRequiredIf(`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${deprecatedPlacements[preferredPlacement]} instead.`, deprecatedPlacements[preferredPlacement]);
|
|
5836
|
+
};
|
|
5837
|
+
Popover$1.defaultProps = {
|
|
5838
|
+
className: undefined,
|
|
5839
|
+
preferredPlacement: Position.RIGHT,
|
|
5840
|
+
title: undefined
|
|
5841
|
+
};
|
|
5842
|
+
Popover$1.propTypes = {
|
|
5843
|
+
children: PropTypes.node.isRequired,
|
|
5844
|
+
className: PropTypes.string,
|
|
5845
|
+
content: PropTypes.node.isRequired,
|
|
5846
|
+
/**
|
|
5847
|
+
* `'left-top'` / `'right-top'` are deprecated use `Position.TOP` / `'top'` instead,
|
|
5848
|
+
* `'bottom-right'` / `'bottom-left'` are deprecated use `Position.BOTTOM` / `'bottom'` instead
|
|
5849
|
+
*/
|
|
5850
|
+
preferredPlacement: PropTypes.oneOf(['top', 'right', 'bottom', 'left', 'left-top', 'right-top', 'bottom-right', 'bottom-left']),
|
|
5851
|
+
onClose: PropTypes.func,
|
|
5852
|
+
title: PropTypes.node
|
|
5853
|
+
};
|
|
5854
|
+
const deprecatedPlacements = {
|
|
5855
|
+
[Position.BOTTOM_LEFT]: Position.BOTTOM,
|
|
5856
|
+
[Position.BOTTOM_RIGHT]: Position.BOTTOM,
|
|
5857
|
+
[Position.LEFT_TOP]: Position.TOP,
|
|
5858
|
+
[Position.RIGHT_TOP]: Position.TOP
|
|
5859
|
+
};
|
|
5860
|
+
var Popover$2 = Popover$1;
|
|
5843
5861
|
|
|
5844
5862
|
var messages$6 = defineMessages({
|
|
5845
5863
|
ariaLabel: {
|
|
@@ -5890,7 +5908,7 @@ const Info = ({
|
|
|
5890
5908
|
title: title,
|
|
5891
5909
|
onClose: () => setOpen(false)
|
|
5892
5910
|
})]
|
|
5893
|
-
}) : /*#__PURE__*/jsx(Popover$
|
|
5911
|
+
}) : /*#__PURE__*/jsx(Popover$2, {
|
|
5894
5912
|
content: content,
|
|
5895
5913
|
preferredPlacement: preferredPlacement,
|
|
5896
5914
|
title: title,
|
|
@@ -6946,14 +6964,13 @@ const getSymbolsInPatternWithPosition = pattern => {
|
|
|
6946
6964
|
});
|
|
6947
6965
|
return patternWithSymbolsPosition;
|
|
6948
6966
|
};
|
|
6949
|
-
var getSymbolsInPatternWithPosition$1 = getSymbolsInPatternWithPosition;
|
|
6950
6967
|
|
|
6951
6968
|
const formatWithPattern = (value, pattern) => {
|
|
6952
6969
|
if (!value || value === '') {
|
|
6953
6970
|
return '';
|
|
6954
6971
|
}
|
|
6955
6972
|
const valueArray = value.toString().split('');
|
|
6956
|
-
const patternWithSymbolsPosition = getSymbolsInPatternWithPosition
|
|
6973
|
+
const patternWithSymbolsPosition = getSymbolsInPatternWithPosition(pattern);
|
|
6957
6974
|
let patternSymbol = [];
|
|
6958
6975
|
// valueArray.length increments during the cycle cause we are adding new elements.
|
|
6959
6976
|
for (let index = 0; index < valueArray.length; index += 1) {
|
|
@@ -6968,7 +6985,6 @@ const formatWithPattern = (value, pattern) => {
|
|
|
6968
6985
|
}
|
|
6969
6986
|
return valueArray.join('');
|
|
6970
6987
|
};
|
|
6971
|
-
var formatWithPattern$1 = formatWithPattern;
|
|
6972
6988
|
|
|
6973
6989
|
const unformatWithPattern = (value, pattern) => {
|
|
6974
6990
|
let valueArray = [''];
|
|
@@ -6979,18 +6995,16 @@ const unformatWithPattern = (value, pattern) => {
|
|
|
6979
6995
|
return valueArray.join('');
|
|
6980
6996
|
};
|
|
6981
6997
|
const getSymbolsInPattern = pattern => pattern.split('').filter(symbol => symbol !== '*');
|
|
6982
|
-
var unformatWithPattern$1 = unformatWithPattern;
|
|
6983
6998
|
|
|
6984
|
-
const getCountOfSymbolsInSelection = (selectionStart, selectionEnd, pattern) => getSymbolsInPatternWithPosition
|
|
6985
|
-
var getCountOfSymbolsInSelection$1 = getCountOfSymbolsInSelection;
|
|
6999
|
+
const getCountOfSymbolsInSelection = (selectionStart, selectionEnd, pattern) => getSymbolsInPatternWithPosition(pattern).filter(symbol => symbol.index >= selectionStart && symbol.index < selectionEnd).length;
|
|
6986
7000
|
|
|
6987
7001
|
const getDistanceToNextSymbol = (selectionStart, pattern) => {
|
|
6988
|
-
const patternArray = getSymbolsInPatternWithPosition
|
|
7002
|
+
const patternArray = getSymbolsInPatternWithPosition(pattern);
|
|
6989
7003
|
const applicablePattern = patternArray.filter(symbol => symbol.index >= selectionStart);
|
|
6990
7004
|
return countConsecutiveSymbols(selectionStart, applicablePattern, 'left');
|
|
6991
7005
|
};
|
|
6992
7006
|
const getDistanceToPreviousSymbol = (selectionStart, pattern) => {
|
|
6993
|
-
const patternArray = getSymbolsInPatternWithPosition
|
|
7007
|
+
const patternArray = getSymbolsInPatternWithPosition(pattern);
|
|
6994
7008
|
const applicablePattern = patternArray.filter(symbol => symbol.index < selectionStart).reverse();
|
|
6995
7009
|
return countConsecutiveSymbols(selectionStart, applicablePattern, 'right');
|
|
6996
7010
|
};
|
|
@@ -7020,7 +7034,7 @@ const getCursorPositionAfterActionStroke = (action, selectionStart, selectionEnd
|
|
|
7020
7034
|
}
|
|
7021
7035
|
break;
|
|
7022
7036
|
case 'Paste':
|
|
7023
|
-
cursorPosition += pastedLength + getCountOfSymbolsInSelection
|
|
7037
|
+
cursorPosition += pastedLength + getCountOfSymbolsInSelection(selectionStart, selectionStart + pastedLength, pattern) + getDistanceToNextSymbol(selectionStart + pastedLength, pattern);
|
|
7024
7038
|
break;
|
|
7025
7039
|
case 'Cut':
|
|
7026
7040
|
case 'Delete':
|
|
@@ -7031,7 +7045,6 @@ const getCursorPositionAfterActionStroke = (action, selectionStart, selectionEnd
|
|
|
7031
7045
|
}
|
|
7032
7046
|
return cursorPosition;
|
|
7033
7047
|
};
|
|
7034
|
-
var getCursorPositionAfterKeystroke = getCursorPositionAfterActionStroke;
|
|
7035
7048
|
|
|
7036
7049
|
class WithDisplayFormat extends Component {
|
|
7037
7050
|
static defaultProps = {
|
|
@@ -7041,9 +7054,9 @@ class WithDisplayFormat extends Component {
|
|
|
7041
7054
|
};
|
|
7042
7055
|
constructor(props) {
|
|
7043
7056
|
super(props);
|
|
7044
|
-
const unformattedValue = unformatWithPattern
|
|
7057
|
+
const unformattedValue = unformatWithPattern(props.value ?? '', props.displayPattern);
|
|
7045
7058
|
this.state = {
|
|
7046
|
-
value: formatWithPattern
|
|
7059
|
+
value: formatWithPattern(unformattedValue, props.displayPattern),
|
|
7047
7060
|
historyNavigator: new HistoryNavigator$1(),
|
|
7048
7061
|
prevDisplayPattern: props.displayPattern,
|
|
7049
7062
|
triggerType: 'Initial',
|
|
@@ -7061,11 +7074,11 @@ class WithDisplayFormat extends Component {
|
|
|
7061
7074
|
historyNavigator
|
|
7062
7075
|
}) {
|
|
7063
7076
|
if (prevDisplayPattern !== displayPattern) {
|
|
7064
|
-
const unFormattedValue = unformatWithPattern
|
|
7077
|
+
const unFormattedValue = unformatWithPattern(value, prevDisplayPattern);
|
|
7065
7078
|
historyNavigator.reset();
|
|
7066
7079
|
return {
|
|
7067
7080
|
prevDisplayPattern: displayPattern,
|
|
7068
|
-
value: formatWithPattern
|
|
7081
|
+
value: formatWithPattern(unFormattedValue, displayPattern),
|
|
7069
7082
|
triggerType: null,
|
|
7070
7083
|
triggerEvent: null,
|
|
7071
7084
|
pastedLength: 0
|
|
@@ -7095,7 +7108,7 @@ class WithDisplayFormat extends Component {
|
|
|
7095
7108
|
return 'Delete';
|
|
7096
7109
|
}
|
|
7097
7110
|
// Android Fix.
|
|
7098
|
-
if (typeof triggerEvent.key === 'undefined' && unformattedValue.length <= unformatWithPattern
|
|
7111
|
+
if (typeof triggerEvent.key === 'undefined' && unformattedValue.length <= unformatWithPattern(value, displayPattern).length) {
|
|
7099
7112
|
return 'Backspace';
|
|
7100
7113
|
}
|
|
7101
7114
|
return triggerEvent.key;
|
|
@@ -7133,13 +7146,13 @@ class WithDisplayFormat extends Component {
|
|
|
7133
7146
|
// Unfortunately Undo and Redo don't trigger OnChange event so we need to handle some value logic here.
|
|
7134
7147
|
let newFormattedValue = '';
|
|
7135
7148
|
if (this.detectUndoRedo(event) === 'Undo') {
|
|
7136
|
-
newFormattedValue = formatWithPattern
|
|
7149
|
+
newFormattedValue = formatWithPattern(historyNavigator.undo(), displayPattern);
|
|
7137
7150
|
this.setState({
|
|
7138
7151
|
value: newFormattedValue,
|
|
7139
7152
|
triggerType: 'Undo'
|
|
7140
7153
|
});
|
|
7141
7154
|
} else if (this.detectUndoRedo(event) === 'Redo') {
|
|
7142
|
-
newFormattedValue = formatWithPattern
|
|
7155
|
+
newFormattedValue = formatWithPattern(historyNavigator.redo(), displayPattern);
|
|
7143
7156
|
this.setState({
|
|
7144
7157
|
value: newFormattedValue,
|
|
7145
7158
|
triggerType: 'Redo'
|
|
@@ -7157,7 +7170,7 @@ class WithDisplayFormat extends Component {
|
|
|
7157
7170
|
const {
|
|
7158
7171
|
displayPattern
|
|
7159
7172
|
} = this.props;
|
|
7160
|
-
const pastedLength = unformatWithPattern
|
|
7173
|
+
const pastedLength = unformatWithPattern(event.clipboardData.getData('Text'), displayPattern).length;
|
|
7161
7174
|
this.setState({
|
|
7162
7175
|
triggerType: 'Paste',
|
|
7163
7176
|
pastedLength
|
|
@@ -7187,7 +7200,7 @@ class WithDisplayFormat extends Component {
|
|
|
7187
7200
|
const {
|
|
7188
7201
|
value
|
|
7189
7202
|
} = event.target;
|
|
7190
|
-
let unformattedValue = unformatWithPattern
|
|
7203
|
+
let unformattedValue = unformatWithPattern(value, displayPattern);
|
|
7191
7204
|
const action = this.getUserAction(unformattedValue);
|
|
7192
7205
|
if (!this.isKeyAllowed(action) || triggerType === 'Undo' || triggerType === 'Redo') {
|
|
7193
7206
|
return;
|
|
@@ -7195,7 +7208,7 @@ class WithDisplayFormat extends Component {
|
|
|
7195
7208
|
if (action === 'Backspace' || action === 'Delete') {
|
|
7196
7209
|
unformattedValue = this.handleDelete(unformattedValue, action);
|
|
7197
7210
|
}
|
|
7198
|
-
const newFormattedValue = formatWithPattern
|
|
7211
|
+
const newFormattedValue = formatWithPattern(unformattedValue, displayPattern);
|
|
7199
7212
|
historyNavigator.add(unformattedValue);
|
|
7200
7213
|
this.handleCursorPositioning(action);
|
|
7201
7214
|
this.setState({
|
|
@@ -7203,13 +7216,13 @@ class WithDisplayFormat extends Component {
|
|
|
7203
7216
|
}, () => {
|
|
7204
7217
|
this.resetEvent();
|
|
7205
7218
|
if (onChange) {
|
|
7206
|
-
const broadcastValue = unformatWithPattern
|
|
7219
|
+
const broadcastValue = unformatWithPattern(newFormattedValue, displayPattern);
|
|
7207
7220
|
onChange(broadcastValue);
|
|
7208
7221
|
}
|
|
7209
7222
|
});
|
|
7210
7223
|
};
|
|
7211
7224
|
handleOnBlur = event => {
|
|
7212
|
-
this.props.onBlur?.(unformatWithPattern
|
|
7225
|
+
this.props.onBlur?.(unformatWithPattern(event.target.value, this.props.displayPattern));
|
|
7213
7226
|
};
|
|
7214
7227
|
handleOnFocus = event => {
|
|
7215
7228
|
const {
|
|
@@ -7218,7 +7231,7 @@ class WithDisplayFormat extends Component {
|
|
|
7218
7231
|
} = this.props;
|
|
7219
7232
|
if (onFocus) {
|
|
7220
7233
|
this.handleOnChange(event);
|
|
7221
|
-
onFocus(unformatWithPattern
|
|
7234
|
+
onFocus(unformatWithPattern(event.target.value, displayPattern));
|
|
7222
7235
|
}
|
|
7223
7236
|
};
|
|
7224
7237
|
handleDelete = (unformattedValue, action) => {
|
|
@@ -7231,7 +7244,7 @@ class WithDisplayFormat extends Component {
|
|
|
7231
7244
|
} = this.state;
|
|
7232
7245
|
const newStack = [...unformattedValue];
|
|
7233
7246
|
if (selectionStart === selectionEnd) {
|
|
7234
|
-
let startPosition = selectionStart - getCountOfSymbolsInSelection
|
|
7247
|
+
let startPosition = selectionStart - getCountOfSymbolsInSelection(0, selectionStart, displayPattern);
|
|
7235
7248
|
let toDelete = 0;
|
|
7236
7249
|
let count = getDistanceToNextSymbol(selectionStart, displayPattern);
|
|
7237
7250
|
if (action === 'Backspace') {
|
|
@@ -7255,7 +7268,7 @@ class WithDisplayFormat extends Component {
|
|
|
7255
7268
|
selectionEnd,
|
|
7256
7269
|
pastedLength
|
|
7257
7270
|
} = this.state;
|
|
7258
|
-
const cursorPosition =
|
|
7271
|
+
const cursorPosition = getCursorPositionAfterActionStroke(action, selectionStart, selectionEnd, displayPattern, pastedLength);
|
|
7259
7272
|
setTimeout(() => {
|
|
7260
7273
|
if (triggerEvent) {
|
|
7261
7274
|
triggerEvent.target.setSelectionRange(cursorPosition, cursorPosition);
|
|
@@ -15100,5 +15113,5 @@ const translations = {
|
|
|
15100
15113
|
'zh-HK': zhHK
|
|
15101
15114
|
};
|
|
15102
15115
|
|
|
15103
|
-
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$
|
|
15116
|
+
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$2 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 };
|
|
15104
15117
|
//# sourceMappingURL=index.esm.js.map
|