@transferwise/components 46.16.0 → 46.17.1
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 +25 -61
- package/build/index.esm.js.map +1 -1
- package/build/index.js +26 -63
- package/build/index.js.map +1 -1
- package/build/types/common/RadioButton/RadioButton.d.ts +3 -3
- package/build/types/common/RadioButton/RadioButton.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -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/radio/Radio.d.ts +1 -1
- package/build/types/radio/Radio.d.ts.map +1 -1
- package/build/types/radioGroup/RadioGroup.d.ts +2 -2
- package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
- package/build/types/radioOption/RadioOption.d.ts +1 -1
- package/build/types/radioOption/RadioOption.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/RadioButton/RadioButton.tsx +4 -4
- package/src/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/radio/Radio.tsx +1 -1
- package/src/radioGroup/RadioGroup.tsx +3 -3
- package/src/radioOption/RadioOption.tsx +2 -2
- 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,
|
|
@@ -10068,7 +10032,7 @@ function RadioOption({
|
|
|
10068
10032
|
onChange,
|
|
10069
10033
|
complex,
|
|
10070
10034
|
disabled,
|
|
10071
|
-
value,
|
|
10035
|
+
value = '',
|
|
10072
10036
|
showMediaCircle,
|
|
10073
10037
|
showMediaAtAllSizes,
|
|
10074
10038
|
isContainerAligned
|
|
@@ -15157,5 +15121,5 @@ const translations = {
|
|
|
15157
15121
|
'zh-HK': zhHK
|
|
15158
15122
|
};
|
|
15159
15123
|
|
|
15160
|
-
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
|
|
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 };
|
|
15161
15125
|
//# sourceMappingURL=index.esm.js.map
|