@transferwise/components 0.0.0-experimental-09aa826 → 0.0.0-experimental-4f94282
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 +24 -62
- package/build/index.esm.js.map +1 -1
- package/build/index.js +25 -64
- package/build/index.js.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/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 +0 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -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 +0 -12
- package/src/moneyInput/MoneyInput.tsx +2 -12
- 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,
|
|
@@ -7757,7 +7721,6 @@ class MoneyInput extends Component {
|
|
|
7757
7721
|
size,
|
|
7758
7722
|
addon,
|
|
7759
7723
|
id,
|
|
7760
|
-
'aria-labelledby': ariaLabelledBy,
|
|
7761
7724
|
selectProps,
|
|
7762
7725
|
maxLengthOverride
|
|
7763
7726
|
} = this.props;
|
|
@@ -7781,7 +7744,6 @@ class MoneyInput extends Component {
|
|
|
7781
7744
|
const isFixedCurrency = !this.state.searchQuery && hasSingleCurrency() || !onCurrencyChange;
|
|
7782
7745
|
const disabled = !this.props.onAmountChange;
|
|
7783
7746
|
return /*#__PURE__*/jsxs("div", {
|
|
7784
|
-
"aria-labelledby": ariaLabelledBy,
|
|
7785
7747
|
className: classNames(this.style('tw-money-input'), this.style('input-group'), this.style(`input-group-${size}`)),
|
|
7786
7748
|
children: [/*#__PURE__*/jsx(Input, {
|
|
7787
7749
|
id: id,
|
|
@@ -15150,5 +15112,5 @@ const translations = {
|
|
|
15150
15112
|
'zh-HK': zhHK
|
|
15151
15113
|
};
|
|
15152
15114
|
|
|
15153
|
-
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$1 as InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown
|
|
15115
|
+
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$1 as 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 };
|
|
15154
15116
|
//# sourceMappingURL=index.esm.js.map
|