@transferwise/components 46.15.0 → 46.17.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 +49 -76
- package/build/index.esm.js.map +1 -1
- package/build/index.js +51 -79
- package/build/index.js.map +1 -1
- package/build/types/index.d.ts +4 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instructionsList/InstructionsList.d.ts +4 -2
- package/build/types/instructionsList/InstructionsList.d.ts.map +1 -1
- package/build/types/instructionsList/index.d.ts +2 -2
- package/build/types/instructionsList/index.d.ts.map +1 -1
- package/build/types/markdown/Markdown.d.ts +18 -25
- package/build/types/markdown/Markdown.d.ts.map +1 -1
- package/build/types/markdown/index.d.ts +2 -1
- package/build/types/markdown/index.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts +1 -0
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +4 -0
- package/src/instructionsList/InstructionsList.spec.tsx +14 -0
- package/src/instructionsList/{InstructionList.story.tsx → InstructionsList.story.tsx} +14 -2
- package/src/instructionsList/InstructionsList.tsx +31 -17
- package/src/instructionsList/index.ts +3 -0
- package/src/markdown/{Markdown.spec.js → Markdown.spec.tsx} +1 -1
- package/src/markdown/Markdown.tsx +81 -0
- package/src/markdown/index.ts +2 -0
- package/src/moneyInput/MoneyInput.rtl.spec.tsx +12 -0
- package/src/moneyInput/MoneyInput.tsx +12 -2
- package/src/instructionsList/index.js +0 -3
- package/src/markdown/Markdown.js +0 -131
- package/src/markdown/index.js +0 -1
package/build/index.esm.js
CHANGED
|
@@ -20,12 +20,11 @@ import { usePopper } from 'react-popper';
|
|
|
20
20
|
import throttle from 'lodash.throttle';
|
|
21
21
|
import { createPortal } from 'react-dom';
|
|
22
22
|
import { isUndefined, isKey, isNumber, isEmpty, isNull } from '@transferwise/neptune-validation';
|
|
23
|
+
import commonmark from 'commonmark';
|
|
23
24
|
import { Flag, Illustration } from '@wise/art';
|
|
24
25
|
import clamp$2 from 'lodash.clamp';
|
|
25
26
|
import debounce from 'lodash.debounce';
|
|
26
27
|
import requiredIf from 'react-required-if';
|
|
27
|
-
import commonmark from 'commonmark';
|
|
28
|
-
import difference from 'lodash.difference';
|
|
29
28
|
import toPairs from 'lodash.topairs';
|
|
30
29
|
import { Spring, animated } from '@react-spring/web';
|
|
31
30
|
|
|
@@ -872,39 +871,32 @@ const writer = new commonmark.HtmlRenderer({
|
|
|
872
871
|
safe: true
|
|
873
872
|
});
|
|
874
873
|
const NODE_TYPE_LIST = Object.values(MarkdownNodeType);
|
|
875
|
-
|
|
876
|
-
as: Element,
|
|
877
|
-
children,
|
|
878
|
-
className,
|
|
874
|
+
function Markdown({
|
|
875
|
+
as: Element = 'div',
|
|
879
876
|
allowList,
|
|
880
877
|
blockList,
|
|
881
|
-
config
|
|
882
|
-
|
|
878
|
+
config,
|
|
879
|
+
className,
|
|
880
|
+
children
|
|
881
|
+
}) {
|
|
883
882
|
if (!children) {
|
|
884
883
|
return null;
|
|
885
884
|
}
|
|
886
|
-
|
|
885
|
+
const linkTarget = config?.link?.target ?? '_self';
|
|
886
|
+
if (allowList != null && blockList != null) {
|
|
887
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);
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
return parsed;
|
|
891
|
+
const toExclude = allowList != null ? NODE_TYPE_LIST.filter(type => !allowList.includes(type)) : blockList;
|
|
892
|
+
return toExclude != null ? stripNodes({
|
|
893
|
+
parsed,
|
|
894
|
+
blockList: toExclude
|
|
895
|
+
}) : parsed;
|
|
899
896
|
};
|
|
900
897
|
const createMarkup = () => {
|
|
901
|
-
const {
|
|
902
|
-
link: {
|
|
903
|
-
target
|
|
904
|
-
}
|
|
905
|
-
} = config;
|
|
906
898
|
const parsed = parser(children);
|
|
907
|
-
return writer.render(parsed).replace(/<a href="/g, `<a target="${
|
|
899
|
+
return writer.render(parsed).replace(/<a href="/g, `<a target="${linkTarget}" href="`);
|
|
908
900
|
};
|
|
909
901
|
return /*#__PURE__*/jsx(Element, {
|
|
910
902
|
className: className,
|
|
@@ -912,7 +904,7 @@ const Markdown = ({
|
|
|
912
904
|
__html: createMarkup()
|
|
913
905
|
}
|
|
914
906
|
});
|
|
915
|
-
}
|
|
907
|
+
}
|
|
916
908
|
function stripNodes({
|
|
917
909
|
blockList,
|
|
918
910
|
parsed
|
|
@@ -921,51 +913,23 @@ function stripNodes({
|
|
|
921
913
|
return parsed;
|
|
922
914
|
}
|
|
923
915
|
const walker = parsed.walker();
|
|
924
|
-
let event = walker.next();
|
|
925
|
-
while (event) {
|
|
916
|
+
for (let event = walker.next(); event != null; event = walker.next()) {
|
|
926
917
|
const {
|
|
927
918
|
node
|
|
928
919
|
} = event;
|
|
929
|
-
if (blockList.includes(node.type)) {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
node.insertBefore(node.firstChild);
|
|
933
|
-
}
|
|
934
|
-
node.unlink();
|
|
920
|
+
if (blockList.includes(node.type) && !event.entering) {
|
|
921
|
+
while (node.firstChild != null) {
|
|
922
|
+
node.insertBefore(node.firstChild);
|
|
935
923
|
}
|
|
924
|
+
node.unlink();
|
|
936
925
|
}
|
|
937
|
-
event = walker.next();
|
|
938
926
|
}
|
|
939
|
-
return
|
|
927
|
+
return parsed;
|
|
940
928
|
}
|
|
941
|
-
Markdown.propTypes = {
|
|
942
|
-
children: PropTypes.string.isRequired,
|
|
943
|
-
as: PropTypes.string,
|
|
944
|
-
className: PropTypes.string,
|
|
945
|
-
allowList: PropTypes.arrayOf(PropTypes.oneOf(['block_quote', 'code_block', 'code', 'emph', 'heading', 'html_block', 'html_inline', 'image', 'item', 'linebreak', 'link', 'list', 'paragraph', 'softbreak', 'strong', 'thematic_break'])),
|
|
946
|
-
blockList: PropTypes.arrayOf(PropTypes.oneOf(['block_quote', 'code_block', 'code', 'emph', 'heading', 'html_block', 'html_inline', 'image', 'item', 'linebreak', 'link', 'list', 'paragraph', 'softbreak', 'strong', 'thematic_break'])),
|
|
947
|
-
config: PropTypes.shape({
|
|
948
|
-
link: PropTypes.shape({
|
|
949
|
-
target: PropTypes.oneOf(['_blank', '_self'])
|
|
950
|
-
})
|
|
951
|
-
})
|
|
952
|
-
};
|
|
953
|
-
Markdown.defaultProps = {
|
|
954
|
-
as: 'div',
|
|
955
|
-
className: undefined,
|
|
956
|
-
allowList: null,
|
|
957
|
-
blockList: null,
|
|
958
|
-
config: {
|
|
959
|
-
link: {
|
|
960
|
-
target: '_self'
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
};
|
|
964
|
-
var Markdown$1 = Markdown;
|
|
965
929
|
|
|
966
930
|
const allowList = [MarkdownNodeType.STRONG];
|
|
967
931
|
const InlineMarkdown = props => {
|
|
968
|
-
return /*#__PURE__*/jsx(Markdown
|
|
932
|
+
return /*#__PURE__*/jsx(Markdown, {
|
|
969
933
|
...props,
|
|
970
934
|
as: "span",
|
|
971
935
|
allowList: allowList,
|
|
@@ -7382,23 +7346,31 @@ const InputWithDisplayFormat = props => /*#__PURE__*/jsx(WithDisplayFormat, {
|
|
|
7382
7346
|
|
|
7383
7347
|
const InstructionsList = ({
|
|
7384
7348
|
dos,
|
|
7385
|
-
donts
|
|
7349
|
+
donts,
|
|
7350
|
+
sort = 'dosFirst'
|
|
7386
7351
|
}) => {
|
|
7387
|
-
|
|
7352
|
+
const dosInstructions = dos?.map((doThis, index) =>
|
|
7353
|
+
/*#__PURE__*/
|
|
7354
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
7355
|
+
jsx(Instruction, {
|
|
7356
|
+
item: doThis,
|
|
7357
|
+
type: "do"
|
|
7358
|
+
}, index)) ?? null;
|
|
7359
|
+
const dontsInstructions = donts?.map((dont, index) =>
|
|
7360
|
+
/*#__PURE__*/
|
|
7361
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
7362
|
+
jsx(Instruction, {
|
|
7363
|
+
item: dont,
|
|
7364
|
+
type: "dont"
|
|
7365
|
+
}, index)) ?? null;
|
|
7366
|
+
const orderedInstructions = sort === 'dosFirst' ? /*#__PURE__*/jsxs(Fragment, {
|
|
7367
|
+
children: [dosInstructions, dontsInstructions]
|
|
7368
|
+
}) : /*#__PURE__*/jsxs(Fragment, {
|
|
7369
|
+
children: [dontsInstructions, dosInstructions]
|
|
7370
|
+
});
|
|
7371
|
+
return /*#__PURE__*/jsx("div", {
|
|
7388
7372
|
className: "tw-instructions",
|
|
7389
|
-
children:
|
|
7390
|
-
/*#__PURE__*/
|
|
7391
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
7392
|
-
jsx(Instruction, {
|
|
7393
|
-
item: doThis,
|
|
7394
|
-
type: "do"
|
|
7395
|
-
}, index)), donts && donts.map((dont, index) =>
|
|
7396
|
-
/*#__PURE__*/
|
|
7397
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
7398
|
-
jsx(Instruction, {
|
|
7399
|
-
item: dont,
|
|
7400
|
-
type: "dont"
|
|
7401
|
-
}, index))]
|
|
7373
|
+
children: orderedInstructions
|
|
7402
7374
|
});
|
|
7403
7375
|
};
|
|
7404
7376
|
function Instruction({
|
|
@@ -7422,7 +7394,6 @@ function Instruction({
|
|
|
7422
7394
|
})]
|
|
7423
7395
|
});
|
|
7424
7396
|
}
|
|
7425
|
-
var InstructionsList$1 = InstructionsList;
|
|
7426
7397
|
|
|
7427
7398
|
const Loader = ({
|
|
7428
7399
|
small = false,
|
|
@@ -7757,6 +7728,7 @@ class MoneyInput extends Component {
|
|
|
7757
7728
|
size,
|
|
7758
7729
|
addon,
|
|
7759
7730
|
id,
|
|
7731
|
+
'aria-labelledby': ariaLabelledBy,
|
|
7760
7732
|
selectProps,
|
|
7761
7733
|
maxLengthOverride
|
|
7762
7734
|
} = this.props;
|
|
@@ -7780,6 +7752,7 @@ class MoneyInput extends Component {
|
|
|
7780
7752
|
const isFixedCurrency = !this.state.searchQuery && hasSingleCurrency() || !onCurrencyChange;
|
|
7781
7753
|
const disabled = !this.props.onAmountChange;
|
|
7782
7754
|
return /*#__PURE__*/jsxs("div", {
|
|
7755
|
+
"aria-labelledby": ariaLabelledBy,
|
|
7783
7756
|
className: classNames(this.style('tw-money-input'), this.style('input-group'), this.style(`input-group-${size}`)),
|
|
7784
7757
|
children: [/*#__PURE__*/jsx(Input, {
|
|
7785
7758
|
id: id,
|
|
@@ -15148,5 +15121,5 @@ const translations = {
|
|
|
15148
15121
|
'zh-HK': zhHK
|
|
15149
15122
|
};
|
|
15150
15123
|
|
|
15151
|
-
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$1 as 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
|
|
15124
|
+
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$1 as 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 };
|
|
15152
15125
|
//# sourceMappingURL=index.esm.js.map
|