@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.js
CHANGED
|
@@ -21,12 +21,11 @@ var reactPopper = require('react-popper');
|
|
|
21
21
|
var throttle = require('lodash.throttle');
|
|
22
22
|
var reactDom = require('react-dom');
|
|
23
23
|
var neptuneValidation = require('@transferwise/neptune-validation');
|
|
24
|
+
var commonmark = require('commonmark');
|
|
24
25
|
var art = require('@wise/art');
|
|
25
26
|
var clamp$2 = require('lodash.clamp');
|
|
26
27
|
var debounce = require('lodash.debounce');
|
|
27
28
|
var requiredIf = require('react-required-if');
|
|
28
|
-
var commonmark = require('commonmark');
|
|
29
|
-
var difference = require('lodash.difference');
|
|
30
29
|
var toPairs = require('lodash.topairs');
|
|
31
30
|
var web = require('@react-spring/web');
|
|
32
31
|
|
|
@@ -56,11 +55,10 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
|
56
55
|
var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
|
|
57
56
|
var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
|
|
58
57
|
var throttle__default = /*#__PURE__*/_interopDefault(throttle);
|
|
58
|
+
var commonmark__default = /*#__PURE__*/_interopDefault(commonmark);
|
|
59
59
|
var clamp__default = /*#__PURE__*/_interopDefault(clamp$2);
|
|
60
60
|
var debounce__default = /*#__PURE__*/_interopDefault(debounce);
|
|
61
61
|
var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
|
|
62
|
-
var commonmark__default = /*#__PURE__*/_interopDefault(commonmark);
|
|
63
|
-
var difference__default = /*#__PURE__*/_interopDefault(difference);
|
|
64
62
|
var toPairs__default = /*#__PURE__*/_interopDefault(toPairs);
|
|
65
63
|
|
|
66
64
|
class HistoryNavigator {
|
|
@@ -906,39 +904,32 @@ const writer = new commonmark__default.default.HtmlRenderer({
|
|
|
906
904
|
safe: true
|
|
907
905
|
});
|
|
908
906
|
const NODE_TYPE_LIST = Object.values(exports.MarkdownNodeType);
|
|
909
|
-
|
|
910
|
-
as: Element,
|
|
911
|
-
children,
|
|
912
|
-
className,
|
|
907
|
+
function Markdown({
|
|
908
|
+
as: Element = 'div',
|
|
913
909
|
allowList,
|
|
914
910
|
blockList,
|
|
915
|
-
config
|
|
916
|
-
|
|
911
|
+
config,
|
|
912
|
+
className,
|
|
913
|
+
children
|
|
914
|
+
}) {
|
|
917
915
|
if (!children) {
|
|
918
916
|
return null;
|
|
919
917
|
}
|
|
920
|
-
|
|
918
|
+
const linkTarget = config?.link?.target ?? '_self';
|
|
919
|
+
if (allowList != null && blockList != null) {
|
|
921
920
|
logActionRequired$2('Markdown supports only one of `allowList` or `blockList` to be used at a time. `blockList` will be ignored.');
|
|
922
921
|
}
|
|
923
922
|
const parser = nodes => {
|
|
924
923
|
const parsed = reader.parse(nodes);
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
return parsed;
|
|
924
|
+
const toExclude = allowList != null ? NODE_TYPE_LIST.filter(type => !allowList.includes(type)) : blockList;
|
|
925
|
+
return toExclude != null ? stripNodes({
|
|
926
|
+
parsed,
|
|
927
|
+
blockList: toExclude
|
|
928
|
+
}) : parsed;
|
|
933
929
|
};
|
|
934
930
|
const createMarkup = () => {
|
|
935
|
-
const {
|
|
936
|
-
link: {
|
|
937
|
-
target
|
|
938
|
-
}
|
|
939
|
-
} = config;
|
|
940
931
|
const parsed = parser(children);
|
|
941
|
-
return writer.render(parsed).replace(/<a href="/g, `<a target="${
|
|
932
|
+
return writer.render(parsed).replace(/<a href="/g, `<a target="${linkTarget}" href="`);
|
|
942
933
|
};
|
|
943
934
|
return /*#__PURE__*/jsxRuntime.jsx(Element, {
|
|
944
935
|
className: className,
|
|
@@ -946,7 +937,7 @@ const Markdown = ({
|
|
|
946
937
|
__html: createMarkup()
|
|
947
938
|
}
|
|
948
939
|
});
|
|
949
|
-
}
|
|
940
|
+
}
|
|
950
941
|
function stripNodes({
|
|
951
942
|
blockList,
|
|
952
943
|
parsed
|
|
@@ -955,51 +946,23 @@ function stripNodes({
|
|
|
955
946
|
return parsed;
|
|
956
947
|
}
|
|
957
948
|
const walker = parsed.walker();
|
|
958
|
-
let event = walker.next();
|
|
959
|
-
while (event) {
|
|
949
|
+
for (let event = walker.next(); event != null; event = walker.next()) {
|
|
960
950
|
const {
|
|
961
951
|
node
|
|
962
952
|
} = event;
|
|
963
|
-
if (blockList.includes(node.type)) {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
node.insertBefore(node.firstChild);
|
|
967
|
-
}
|
|
968
|
-
node.unlink();
|
|
953
|
+
if (blockList.includes(node.type) && !event.entering) {
|
|
954
|
+
while (node.firstChild != null) {
|
|
955
|
+
node.insertBefore(node.firstChild);
|
|
969
956
|
}
|
|
957
|
+
node.unlink();
|
|
970
958
|
}
|
|
971
|
-
event = walker.next();
|
|
972
959
|
}
|
|
973
|
-
return
|
|
960
|
+
return parsed;
|
|
974
961
|
}
|
|
975
|
-
Markdown.propTypes = {
|
|
976
|
-
children: PropTypes__default.default.string.isRequired,
|
|
977
|
-
as: PropTypes__default.default.string,
|
|
978
|
-
className: PropTypes__default.default.string,
|
|
979
|
-
allowList: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOf(['block_quote', 'code_block', 'code', 'emph', 'heading', 'html_block', 'html_inline', 'image', 'item', 'linebreak', 'link', 'list', 'paragraph', 'softbreak', 'strong', 'thematic_break'])),
|
|
980
|
-
blockList: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOf(['block_quote', 'code_block', 'code', 'emph', 'heading', 'html_block', 'html_inline', 'image', 'item', 'linebreak', 'link', 'list', 'paragraph', 'softbreak', 'strong', 'thematic_break'])),
|
|
981
|
-
config: PropTypes__default.default.shape({
|
|
982
|
-
link: PropTypes__default.default.shape({
|
|
983
|
-
target: PropTypes__default.default.oneOf(['_blank', '_self'])
|
|
984
|
-
})
|
|
985
|
-
})
|
|
986
|
-
};
|
|
987
|
-
Markdown.defaultProps = {
|
|
988
|
-
as: 'div',
|
|
989
|
-
className: undefined,
|
|
990
|
-
allowList: null,
|
|
991
|
-
blockList: null,
|
|
992
|
-
config: {
|
|
993
|
-
link: {
|
|
994
|
-
target: '_self'
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
};
|
|
998
|
-
var Markdown$1 = Markdown;
|
|
999
962
|
|
|
1000
963
|
const allowList = [exports.MarkdownNodeType.STRONG];
|
|
1001
964
|
const InlineMarkdown = props => {
|
|
1002
|
-
return /*#__PURE__*/jsxRuntime.jsx(Markdown
|
|
965
|
+
return /*#__PURE__*/jsxRuntime.jsx(Markdown, {
|
|
1003
966
|
...props,
|
|
1004
967
|
as: "span",
|
|
1005
968
|
allowList: allowList,
|
|
@@ -7416,23 +7379,31 @@ const InputWithDisplayFormat = props => /*#__PURE__*/jsxRuntime.jsx(WithDisplayF
|
|
|
7416
7379
|
|
|
7417
7380
|
const InstructionsList = ({
|
|
7418
7381
|
dos,
|
|
7419
|
-
donts
|
|
7382
|
+
donts,
|
|
7383
|
+
sort = 'dosFirst'
|
|
7420
7384
|
}) => {
|
|
7421
|
-
|
|
7385
|
+
const dosInstructions = dos?.map((doThis, index) =>
|
|
7386
|
+
/*#__PURE__*/
|
|
7387
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
7388
|
+
jsxRuntime.jsx(Instruction, {
|
|
7389
|
+
item: doThis,
|
|
7390
|
+
type: "do"
|
|
7391
|
+
}, index)) ?? null;
|
|
7392
|
+
const dontsInstructions = donts?.map((dont, index) =>
|
|
7393
|
+
/*#__PURE__*/
|
|
7394
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
7395
|
+
jsxRuntime.jsx(Instruction, {
|
|
7396
|
+
item: dont,
|
|
7397
|
+
type: "dont"
|
|
7398
|
+
}, index)) ?? null;
|
|
7399
|
+
const orderedInstructions = sort === 'dosFirst' ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
7400
|
+
children: [dosInstructions, dontsInstructions]
|
|
7401
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
7402
|
+
children: [dontsInstructions, dosInstructions]
|
|
7403
|
+
});
|
|
7404
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
7422
7405
|
className: "tw-instructions",
|
|
7423
|
-
children:
|
|
7424
|
-
/*#__PURE__*/
|
|
7425
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
7426
|
-
jsxRuntime.jsx(Instruction, {
|
|
7427
|
-
item: doThis,
|
|
7428
|
-
type: "do"
|
|
7429
|
-
}, index)), donts && donts.map((dont, index) =>
|
|
7430
|
-
/*#__PURE__*/
|
|
7431
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
7432
|
-
jsxRuntime.jsx(Instruction, {
|
|
7433
|
-
item: dont,
|
|
7434
|
-
type: "dont"
|
|
7435
|
-
}, index))]
|
|
7406
|
+
children: orderedInstructions
|
|
7436
7407
|
});
|
|
7437
7408
|
};
|
|
7438
7409
|
function Instruction({
|
|
@@ -7456,7 +7427,6 @@ function Instruction({
|
|
|
7456
7427
|
})]
|
|
7457
7428
|
});
|
|
7458
7429
|
}
|
|
7459
|
-
var InstructionsList$1 = InstructionsList;
|
|
7460
7430
|
|
|
7461
7431
|
const Loader = ({
|
|
7462
7432
|
small = false,
|
|
@@ -7791,6 +7761,7 @@ class MoneyInput extends React.Component {
|
|
|
7791
7761
|
size,
|
|
7792
7762
|
addon,
|
|
7793
7763
|
id,
|
|
7764
|
+
'aria-labelledby': ariaLabelledBy,
|
|
7794
7765
|
selectProps,
|
|
7795
7766
|
maxLengthOverride
|
|
7796
7767
|
} = this.props;
|
|
@@ -7814,6 +7785,7 @@ class MoneyInput extends React.Component {
|
|
|
7814
7785
|
const isFixedCurrency = !this.state.searchQuery && hasSingleCurrency() || !onCurrencyChange;
|
|
7815
7786
|
const disabled = !this.props.onAmountChange;
|
|
7816
7787
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
7788
|
+
"aria-labelledby": ariaLabelledBy,
|
|
7817
7789
|
className: classNames__default.default(this.style('tw-money-input'), this.style('input-group'), this.style(`input-group-${size}`)),
|
|
7818
7790
|
children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
7819
7791
|
id: id,
|
|
@@ -15223,13 +15195,13 @@ exports.InlineAlert = InlineAlert;
|
|
|
15223
15195
|
exports.Input = Input;
|
|
15224
15196
|
exports.InputGroup = InputGroup;
|
|
15225
15197
|
exports.InputWithDisplayFormat = InputWithDisplayFormat;
|
|
15226
|
-
exports.InstructionsList = InstructionsList
|
|
15198
|
+
exports.InstructionsList = InstructionsList;
|
|
15227
15199
|
exports.LanguageProvider = LanguageProvider;
|
|
15228
15200
|
exports.Link = Link;
|
|
15229
15201
|
exports.ListItem = ListItem$1;
|
|
15230
15202
|
exports.Loader = Loader$1;
|
|
15231
15203
|
exports.Logo = Logo$1;
|
|
15232
|
-
exports.Markdown = Markdown
|
|
15204
|
+
exports.Markdown = Markdown;
|
|
15233
15205
|
exports.Modal = Modal;
|
|
15234
15206
|
exports.Money = Money$1;
|
|
15235
15207
|
exports.MoneyInput = MoneyInput$1;
|