@seamly/web-ui 19.1.1 → 19.1.4

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.
@@ -1,4 +1,6 @@
1
1
  import { useMemo, useRef } from 'preact/hooks'
2
+ import thunkMiddleware from 'redux-thunk'
3
+
2
4
  import {
3
5
  SeamlyEventBusContext,
4
6
  SeamlyApiContext,
@@ -6,7 +8,6 @@ import {
6
8
  StoreProvider,
7
9
  createReduxStore,
8
10
  } from '@seamly/web-ui'
9
-
10
11
  import stateReducer from '../../domains/store/state-reducer'
11
12
  import { Reducer as formReducer } from '../../domains/forms'
12
13
  import { Reducer as translationsReducer } from '../../domains/translations'
@@ -28,6 +29,7 @@ const bareApi = {
28
29
  return Promise.resolve({})
29
30
  },
30
31
  store: { get: () => {}, set: () => {} },
32
+ hasConversation: () => false,
31
33
  }
32
34
 
33
35
  const SeamlyTestCore = ({ state, translations, children }) => {
@@ -59,6 +61,12 @@ const SeamlyTestCore = ({ state, translations, children }) => {
59
61
  [String(interruptReducer)]: interruptSlice,
60
62
  [String(visibilityReducer)]: visibilitySlice,
61
63
  },
64
+ middlewares: [
65
+ thunkMiddleware.withExtraArgument({
66
+ api: bareApi,
67
+ eventBus: eventBusRef.current,
68
+ }),
69
+ ],
62
70
  })
63
71
  newStore.dispatch(ConfigActions.initialize(configSlice || {}))
64
72
  newStore.dispatch(I18nActions.setLocale.fulfilled('en-GB', translations))
@@ -8,6 +8,9 @@ import CarouselMessageSlide from '../carousel-message/components/slide'
8
8
 
9
9
  const defaultGetItemKey = (item, idx, prefix) => `${prefix}${idx}`
10
10
  const defaultGetItemLabel = (item) => item.label
11
+ const preventScroll = ({ target }) => {
12
+ target.scrollLeft = 0
13
+ }
11
14
 
12
15
  export default function CarouselComponent({
13
16
  currentIndex: originalIndex,
@@ -51,7 +54,10 @@ export default function CarouselComponent({
51
54
  role="group"
52
55
  aria-roledescription="carousel"
53
56
  >
54
- <div className={className('carousel__slides-wrapper')}>
57
+ <div
58
+ className={className('carousel__slides-wrapper')}
59
+ onScroll={preventScroll}
60
+ >
55
61
  <div
56
62
  id={carouselItemsId}
57
63
  className={className('carousel__slides')}
@@ -78,6 +84,7 @@ export default function CarouselComponent({
78
84
  item={item}
79
85
  items={items}
80
86
  currentIndex={currentIndex}
87
+ index={idx}
81
88
  isActive={isActive}
82
89
  />
83
90
  </div>
@@ -5,18 +5,17 @@ import CardComponent from '../../card-component'
5
5
  export default function CarouselMessageSlide({
6
6
  item: slide,
7
7
  items,
8
- currentIndex,
8
+ index,
9
9
  isActive,
10
10
  }) {
11
11
  const { t } = useI18n()
12
-
13
12
  return (
14
13
  <div
15
14
  className={className('carousel-item', `carousel-item--${slide.type}`)}
16
15
  role="group"
17
16
  aria-roledescription="slide"
18
17
  aria-label={t('carousel.slide.label', {
19
- index: currentIndex + 1,
18
+ index: index + 1,
20
19
  total: items.length,
21
20
  })}
22
21
  >
@@ -1,11 +1,13 @@
1
1
  import MessageContainer from '../../message-container'
2
2
  import CarouselComponent from '../carousel-component'
3
+ import { useTranslatedEventData } from '../../../../../domains/translations'
3
4
  import CarouselMessageSlide from './components/slide'
4
5
 
5
6
  const getItemKey = (item, idx, prefix = '') => `${prefix}${item.title}:${idx}`
6
7
  const getItemLabel = (item) => item.title
7
8
  const CarouselMessage = ({ event }) => {
8
- const slides = event.payload.body.cards
9
+ const [body] = useTranslatedEventData(event)
10
+ const slides = body.cards
9
11
 
10
12
  return (
11
13
  <MessageContainer event={event} modifiers={'type-carousel'}>