@transferwise/components 46.8.0 → 46.9.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.
Files changed (32) hide show
  1. package/build/index.esm.js +50 -72
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +50 -72
  4. package/build/index.js.map +1 -1
  5. package/build/types/checkboxOption/CheckboxOption.d.ts +2 -2
  6. package/build/types/checkboxOption/CheckboxOption.d.ts.map +1 -1
  7. package/build/types/index.d.ts +2 -0
  8. package/build/types/index.d.ts.map +1 -1
  9. package/build/types/snackbar/Snackbar.d.ts +30 -22
  10. package/build/types/snackbar/Snackbar.d.ts.map +1 -1
  11. package/build/types/snackbar/SnackbarContext.d.ts +7 -2
  12. package/build/types/snackbar/SnackbarContext.d.ts.map +1 -1
  13. package/build/types/snackbar/SnackbarProvider.d.ts +7 -12
  14. package/build/types/snackbar/SnackbarProvider.d.ts.map +1 -1
  15. package/build/types/snackbar/index.d.ts +2 -0
  16. package/build/types/snackbar/index.d.ts.map +1 -0
  17. package/build/types/snackbar/useSnackbar.d.ts +1 -1
  18. package/build/types/snackbar/useSnackbar.d.ts.map +1 -1
  19. package/build/types/withNextPortal/withNextPortal.d.ts +1 -1
  20. package/build/types/withNextPortal/withNextPortal.d.ts.map +1 -1
  21. package/package.json +3 -3
  22. package/src/checkboxOption/CheckboxOption.tsx +2 -2
  23. package/src/index.ts +2 -0
  24. package/src/snackbar/{Snackbar.story.js → Snackbar.story.tsx} +2 -1
  25. package/src/snackbar/{Snackbar.js → Snackbar.tsx} +31 -32
  26. package/src/snackbar/SnackbarContext.ts +11 -0
  27. package/src/snackbar/SnackbarProvider.tsx +39 -0
  28. package/src/withNextPortal/withNextPortal.tsx +1 -1
  29. package/src/snackbar/SnackbarContext.js +0 -4
  30. package/src/snackbar/SnackbarProvider.js +0 -51
  31. /package/src/snackbar/{index.js → index.ts} +0 -0
  32. /package/src/snackbar/{useSnackbar.js → useSnackbar.ts} +0 -0
@@ -2578,7 +2578,7 @@ const CheckboxOption = /*#__PURE__*/forwardRef(({
2578
2578
  button: /*#__PURE__*/jsx(CheckboxButton$1, {
2579
2579
  checked: checked,
2580
2580
  disabled: disabled,
2581
- onChange: () => onChange(!checked)
2581
+ onChange: () => onChange?.(!checked)
2582
2582
  })
2583
2583
  });
2584
2584
  });
@@ -11147,18 +11147,19 @@ const SegmentedControl = ({
11147
11147
 
11148
11148
  const CSS_TRANSITION_DURATION = 400;
11149
11149
  class Snackbar extends Component {
11150
- /** @type {RefObject<HTMLSpanElement>} */
11151
11150
  bodyRef = /*#__PURE__*/createRef();
11152
- constructor() {
11153
- super();
11151
+ timeout = 0;
11152
+ transitionTimeout = 0;
11153
+ constructor(props) {
11154
+ super(props);
11154
11155
  this.state = {
11155
11156
  visible: false,
11156
11157
  text: ''
11157
11158
  };
11158
11159
  }
11159
11160
  componentWillUnmount() {
11160
- clearTimeout(this.timeout);
11161
- clearTimeout(this.transitionTimeout);
11161
+ window.clearTimeout(this.timeout);
11162
+ window.clearTimeout(this.transitionTimeout);
11162
11163
  }
11163
11164
  shouldComponentUpdate(nextProps, nextState) {
11164
11165
  if (!nextProps.text) {
@@ -11173,7 +11174,7 @@ class Snackbar extends Component {
11173
11174
  const {
11174
11175
  timeout
11175
11176
  } = this.props;
11176
- this.timeout = setTimeout(() => {
11177
+ this.timeout = window.setTimeout(() => {
11177
11178
  this.setState({
11178
11179
  visible: false
11179
11180
  });
@@ -11196,12 +11197,12 @@ class Snackbar extends Component {
11196
11197
  this.setLeaveTimeout();
11197
11198
  });
11198
11199
  } else if (previousProps.timestamp !== timestamp) {
11199
- clearTimeout(this.timeout);
11200
+ window.clearTimeout(this.timeout);
11200
11201
  if (this.state.visible) {
11201
11202
  this.setState({
11202
11203
  visible: false
11203
11204
  }, () => {
11204
- this.transitionTimeout = setTimeout(() => {
11205
+ this.transitionTimeout = window.setTimeout(() => {
11205
11206
  this.setState({
11206
11207
  visible: true,
11207
11208
  action,
@@ -11226,7 +11227,7 @@ class Snackbar extends Component {
11226
11227
  const {
11227
11228
  action,
11228
11229
  text,
11229
- theme,
11230
+ theme = Theme.LIGHT,
11230
11231
  visible
11231
11232
  } = this.state;
11232
11233
  const {
@@ -11260,74 +11261,51 @@ class Snackbar extends Component {
11260
11261
  }
11261
11262
  }
11262
11263
  Snackbar.contextType = DirectionContext;
11263
- Snackbar.propTypes = {
11264
- action: PropTypes.shape({
11265
- label: PropTypes.string.isRequired,
11266
- onClick: PropTypes.func
11267
- }),
11268
- text: PropTypes.node.isRequired,
11269
- theme: PropTypes.oneOf(['light', 'dark']),
11270
- timeout: PropTypes.number.isRequired,
11271
- timestamp: PropTypes.number.isRequired
11272
- };
11273
- Snackbar.defaultProps = {
11274
- action: null,
11275
- theme: Theme.LIGHT
11276
- };
11277
11264
  var SnackbarPortal = withNextPortalWrapper(Snackbar);
11278
11265
 
11279
- const SnackbarContext = /*#__PURE__*/createContext();
11266
+ const SnackbarContext = /*#__PURE__*/createContext({
11267
+ createSnackbar: () => {}
11268
+ });
11280
11269
  const SnackbarConsumer = SnackbarContext.Consumer;
11281
11270
 
11282
- class SnackbarProvider extends Component {
11283
- constructor() {
11284
- super();
11285
- this.state = {
11286
- text: '',
11287
- timestamp: 0
11288
- };
11289
- }
11290
- create = ({
11271
+ function SnackbarProvider({
11272
+ timeout = 4500,
11273
+ children
11274
+ }) {
11275
+ const [state, setState] = useState({
11276
+ text: '',
11277
+ timestamp: 0
11278
+ });
11279
+ const {
11291
11280
  action,
11292
11281
  text,
11293
- theme
11294
- }) => {
11295
- this.setState({
11296
- action,
11297
- text,
11298
- theme,
11299
- timestamp: Date.now()
11300
- });
11301
- };
11302
- render() {
11303
- const {
11304
- action,
11305
- text,
11306
- theme,
11307
- timestamp
11308
- } = this.state;
11309
- return /*#__PURE__*/jsxs(SnackbarContext.Provider, {
11310
- value: {
11311
- createSnackbar: this.create
11312
- },
11313
- children: [/*#__PURE__*/jsx(SnackbarPortal, {
11314
- action: action,
11315
- text: text,
11316
- timestamp: timestamp,
11317
- timeout: this.props.timeout,
11318
- theme: theme
11319
- }), this.props.children]
11320
- });
11321
- }
11282
+ theme,
11283
+ timestamp
11284
+ } = state;
11285
+ return /*#__PURE__*/jsxs(SnackbarContext.Provider, {
11286
+ value: useMemo(() => ({
11287
+ createSnackbar: ({
11288
+ action,
11289
+ text,
11290
+ theme
11291
+ }) => {
11292
+ setState({
11293
+ action,
11294
+ text,
11295
+ theme,
11296
+ timestamp: Date.now()
11297
+ });
11298
+ }
11299
+ }), []),
11300
+ children: [/*#__PURE__*/jsx(SnackbarPortal, {
11301
+ action: action,
11302
+ text: text,
11303
+ timestamp: timestamp,
11304
+ timeout: timeout,
11305
+ theme: theme
11306
+ }), children]
11307
+ });
11322
11308
  }
11323
- SnackbarProvider.propTypes = {
11324
- children: PropTypes.node.isRequired,
11325
- timeout: PropTypes.number
11326
- };
11327
- SnackbarProvider.defaultProps = {
11328
- timeout: 4500
11329
- };
11330
- var SnackbarProvider$1 = SnackbarProvider;
11331
11309
 
11332
11310
  const Sticky = ({
11333
11311
  open,
@@ -15541,5 +15519,5 @@ const translations = {
15541
15519
  'zh-HK': zhHK
15542
15520
  };
15543
15521
 
15544
- 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$1 as DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as 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$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as 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$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider$1 as SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15522
+ 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$1 as DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as 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$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as 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$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as 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$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15545
15523
  //# sourceMappingURL=index.esm.js.map