pb-sxp-ui 1.9.0 → 1.9.2

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 (66) hide show
  1. package/dist/index.cjs +1005 -241
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.css +72 -4
  4. package/dist/index.js +1005 -241
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.cjs +3 -3
  7. package/dist/index.min.cjs.map +1 -1
  8. package/dist/index.min.js +3 -3
  9. package/dist/index.min.js.map +1 -1
  10. package/dist/pb-ui.js +1005 -241
  11. package/dist/pb-ui.js.map +1 -1
  12. package/dist/pb-ui.min.js +3 -3
  13. package/dist/pb-ui.min.js.map +1 -1
  14. package/es/core/components/SxpPageRender/ExpandableText.js +1 -1
  15. package/es/core/components/SxpPageRender/Hashtag/index.js +2 -2
  16. package/es/core/components/SxpPageRender/Modal/index.js +45 -7
  17. package/es/core/components/SxpPageRender/PictureGroup/index.js +51 -25
  18. package/es/core/components/SxpPageRender/index.js +3 -3
  19. package/es/core/hooks/useFocusTrap.d.ts +2 -0
  20. package/es/core/hooks/useFocusTrap.js +37 -0
  21. package/es/core/utils/tool.d.ts +2 -1
  22. package/es/core/utils/tool.js +12 -1
  23. package/es/index.d.ts +1 -0
  24. package/es/index.js +1 -0
  25. package/es/materials/sxp/cta/AniLinkPopup/index.js +5 -5
  26. package/es/materials/sxp/popup/CommodityDetail/index.js +38 -14
  27. package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +37 -13
  28. package/es/materials/sxp/popup/CommodityList/index.js +32 -28
  29. package/es/materials/sxp/template/Appoint/index.js +1 -1
  30. package/es/materials/sxp/template/Commodity/index.js +4 -4
  31. package/es/materials/sxp/template/CommodityDiro/index.js +4 -4
  32. package/es/materials/sxp/template/CommodityDiroNew/index.js +4 -4
  33. package/es/materials/sxp/template/Link/index.js +1 -1
  34. package/es/materials/sxp/template/MultiCommodity/index.js +23 -42
  35. package/es/materials/sxp/template/MultiCommodityDiro/index.js +24 -42
  36. package/es/materials/sxp/template/MultiCommodityDiroNew/index.js +25 -44
  37. package/es/materials/sxp/template/components/EventProvider.d.ts +2 -0
  38. package/es/materials/sxp/template/components/EventProvider.js +22 -11
  39. package/es/materials/sxp/template/components/Scroll.js +1 -1
  40. package/lib/core/components/SxpPageRender/ExpandableText.js +1 -1
  41. package/lib/core/components/SxpPageRender/Hashtag/index.js +2 -2
  42. package/lib/core/components/SxpPageRender/Modal/index.js +45 -7
  43. package/lib/core/components/SxpPageRender/PictureGroup/index.js +49 -23
  44. package/lib/core/components/SxpPageRender/index.js +3 -3
  45. package/lib/core/hooks/useFocusTrap.d.ts +2 -0
  46. package/lib/core/hooks/useFocusTrap.js +39 -0
  47. package/lib/core/utils/tool.d.ts +2 -1
  48. package/lib/core/utils/tool.js +13 -1
  49. package/lib/index.d.ts +1 -0
  50. package/lib/index.js +1 -0
  51. package/lib/materials/sxp/cta/AniLinkPopup/index.js +5 -5
  52. package/lib/materials/sxp/popup/CommodityDetail/index.js +36 -12
  53. package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +35 -11
  54. package/lib/materials/sxp/popup/CommodityList/index.js +32 -28
  55. package/lib/materials/sxp/template/Appoint/index.js +1 -1
  56. package/lib/materials/sxp/template/Commodity/index.js +4 -4
  57. package/lib/materials/sxp/template/CommodityDiro/index.js +4 -4
  58. package/lib/materials/sxp/template/CommodityDiroNew/index.js +4 -4
  59. package/lib/materials/sxp/template/Link/index.js +1 -1
  60. package/lib/materials/sxp/template/MultiCommodity/index.js +22 -41
  61. package/lib/materials/sxp/template/MultiCommodityDiro/index.js +23 -41
  62. package/lib/materials/sxp/template/MultiCommodityDiroNew/index.js +24 -43
  63. package/lib/materials/sxp/template/components/EventProvider.d.ts +2 -0
  64. package/lib/materials/sxp/template/components/EventProvider.js +21 -10
  65. package/lib/materials/sxp/template/components/Scroll.js +1 -1
  66. package/package.json +1 -1
@@ -50,7 +50,7 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
50
50
  wordBreak: 'break-word'
51
51
  }, dangerouslySetInnerHTML: { __html: setFontForText(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), style) } }),
52
52
  React.createElement("div", { ref: multiRowCopy, dangerouslySetInnerHTML: { __html: setFontForText(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), style) } }),
53
- text && isPost && isShow && (React.createElement("span", { style: { textDecoration: 'underline', cursor: 'pointer' }, onClick: onClick !== null && onClick !== void 0 ? onClick : handleClick, dangerouslySetInnerHTML: {
53
+ text && isPost && isShow && (React.createElement("button", { "aria-label": isShowMore ? unfoldText || 'show less' : foldText || 'show more', style: { textDecoration: 'underline', cursor: 'pointer' }, onClick: onClick !== null && onClick !== void 0 ? onClick : handleClick, dangerouslySetInnerHTML: {
54
54
  __html: setFontForText(isShowMore ? unfoldText || 'show less' : foldText || 'show more', style)
55
55
  } }))));
56
56
  };
@@ -40,7 +40,7 @@ const Hashtag = ({ tags, itemId, itemType, index, rec, hashTagStyle, hashTagRigh
40
40
  marginTop: `${(_a = hashTagStyle === null || hashTagStyle === void 0 ? void 0 : hashTagStyle.marginTop) !== null && _a !== void 0 ? _a : 16}px`,
41
41
  width: hashTagRightMargin
42
42
  } },
43
- React.createElement(Scroll, null, tags === null || tags === void 0 ? void 0 : tags.map((item, index) => (React.createElement(SwiperSlide, { key: index, hidden: !isShowMore ? index >= 6 : false, className: 'clc-sxp-bottom-hashtag-item', style: hashTagStyle, onClick: () => handleClickTag(item), tag: 'button', "aria-label": item },
44
- React.createElement("div", { dangerouslySetInnerHTML: { __html: setFontForText(`#${item}`, hashTagStyle) } })))))));
43
+ React.createElement(Scroll, null, tags === null || tags === void 0 ? void 0 : tags.map((item, index) => (React.createElement(SwiperSlide, { key: index, hidden: !isShowMore ? index >= 6 : false, className: 'clc-sxp-bottom-hashtag-item', style: hashTagStyle, onClick: () => handleClickTag(item), tag: 'li', role: 'listitem' },
44
+ React.createElement("button", { className: 'clc-sxp-bottom-hashtag-item-button', "aria-label": item, "aria-describedby": item, dangerouslySetInnerHTML: { __html: setFontForText(`#${item}`, hashTagStyle) } })))))));
45
45
  };
46
46
  export default memo(Hashtag);
@@ -4,11 +4,12 @@ import * as ReactDOM from 'react-dom';
4
4
  import { useEditor, useSxpDataSource } from '../../../../core/hooks';
5
5
  const closeIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAjhJREFUWEfFlztOw0AQhmeWiJ4CCmpQ5DiRQsIJyAWg5A0lR0AIChDiCJS8ER0cADgBeRSxt4CCDgkaKiq8i+zYeWx2413HEWmiJJv9v535Z2aN8M8vFPT9z3zETD0aAUChUJjwvPFHAJhBhB3Hqd6OAsK2yyucwykAvP38eJX398Z3AJDLlVYR8ToU9Rhj25TWr9KEsKy5dULIGQCMtfZly45TvwsAstm56UwG6wA4FUFwzrdctxZBDcWSy5XWEPG8I84/GcMipdWPtgcsaz5PCHtKG0IuTiqUvjT9U/WYMG2IOPE+AP+LtCB0xKUAAyA2Xbd2o2OG0NQXvTnvhL17D7EPtH9TRCIWwkRcGYGIQgYBABuqPuHXOQBc6pw80lBGwBQiiXhsBHQhkoprA6iM6acjhDQKu5YJZW6XeOI3XJdpvfsdTu52VfXEekD8owQiXGIubpSCbhDbLu8DwKEAd+A41SOdPpE4BS0viFOtvV2iKWqUgn5x/tmS70xR01GuDSCKc86/OCcLgTyyZ0ScDGNhFAktAJV4NFJ9YyaFiAWIE+9uVkkgBgLoig8DMWAa9ro9ynkUdlW5maZDCmB6clmz0k1HH4Cs1Ezbq2p2yEpUuBOKTSZZex00RUWIrltxuuK6EOGDSbGIOPZicpMx6fny650377qNRgBgWeVFQuA+6UjVgREhGIMlSqsPUQqIbZdOOIdZQmCv2axRnU1N1+TzJYsxOEaEV8ep7frPZ7Gd0FTEdP0ft0/kMNdg0eoAAAAASUVORK5CYII=';
6
6
  const Modal = ({ visible, onClose, children, modalStyle, padding, popup, schema, fullHeight = window.innerHeight, isFullScreen = false, openState }) => {
7
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
7
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
8
8
  const touchRef = useRef(null);
9
9
  const fTouchRef = useRef(null);
10
10
  const touchMoveRef = useRef(null);
11
11
  const ref = useRef(null);
12
+ const modalRef = useRef(null);
12
13
  const MODAL_DEF_TRANS = fullHeight * 0.2;
13
14
  const MODAL_DEF_CON_H = isFullScreen ? fullHeight : fullHeight * 0.8;
14
15
  const [modalTrans, setModalTrans] = useState(MODAL_DEF_TRANS);
@@ -56,6 +57,43 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popup, schema,
56
57
  const child = useCallback(() => {
57
58
  return children;
58
59
  }, [_popup, openState, globalConfig]);
60
+ useEffect(() => {
61
+ const trapFocus = (element) => {
62
+ var focusableEls = element === null || element === void 0 ? void 0 : element.querySelectorAll('[role="button"],a, a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])');
63
+ var firstFocusableEl = focusableEls === null || focusableEls === void 0 ? void 0 : focusableEls[0];
64
+ var lastFocusableEl = focusableEls === null || focusableEls === void 0 ? void 0 : focusableEls[(focusableEls === null || focusableEls === void 0 ? void 0 : focusableEls.length) - 1];
65
+ var KEYCODE_TAB = 9;
66
+ element.addEventListener('keydown', function (e) {
67
+ if (e.key === 'Escape' || e.key === 'Esc') {
68
+ handleClose();
69
+ e.preventDefault();
70
+ }
71
+ var isTabPressed = e.key === 'Tab' || e.keyCode === KEYCODE_TAB;
72
+ if (!isTabPressed) {
73
+ return;
74
+ }
75
+ if (e.shiftKey) {
76
+ if ((document === null || document === void 0 ? void 0 : document.activeElement) === firstFocusableEl) {
77
+ lastFocusableEl === null || lastFocusableEl === void 0 ? void 0 : lastFocusableEl.focus();
78
+ e.preventDefault();
79
+ }
80
+ }
81
+ else {
82
+ if ((document === null || document === void 0 ? void 0 : document.activeElement) === lastFocusableEl) {
83
+ firstFocusableEl === null || firstFocusableEl === void 0 ? void 0 : firstFocusableEl.focus();
84
+ e.preventDefault();
85
+ }
86
+ }
87
+ });
88
+ firstFocusableEl === null || firstFocusableEl === void 0 ? void 0 : firstFocusableEl.focus();
89
+ };
90
+ if (modalRef === null || modalRef === void 0 ? void 0 : modalRef.current)
91
+ trapFocus(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current);
92
+ return () => {
93
+ var _a;
94
+ (_a = modalRef === null || modalRef === void 0 ? void 0 : modalRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', trapFocus);
95
+ };
96
+ }, [modalRef, isShow, _popup]);
59
97
  if (!modalEleRef.current)
60
98
  return null;
61
99
  const handleClose = debounce(() => {
@@ -117,7 +155,7 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popup, schema,
117
155
  width: `calc(100% - ${((_r = (_q = (_p = (_o = getPopupById === null || getPopupById === void 0 ? void 0 : getPopupById.item) === null || _o === void 0 ? void 0 : _o.props) === null || _p === void 0 ? void 0 : _p.popupBg) === null || _q === void 0 ? void 0 : _q.horizontalMargin) !== null && _r !== void 0 ? _r : 0) * 2}px)`,
118
156
  height: '100%'
119
157
  } },
120
- React.createElement("div", Object.assign({ className: `modal-container ${isOpen ? 'modal-popIn' : 'modal-popOut'}`, role: 'dialog', "aria-label": (_s = getPopupById === null || getPopupById === void 0 ? void 0 : getPopupById.item) === null || _s === void 0 ? void 0 : _s.displayName, "aria-modal": true, style: Object.assign(Object.assign({ padding, animationDuration: ((_t = popup === null || popup === void 0 ? void 0 : popup.duration) !== null && _t !== void 0 ? _t : 0) / 1000 + 's' }, (isScrollFullScreen && {
158
+ React.createElement("div", Object.assign({ ref: modalRef, className: `modal-container ${isOpen ? 'modal-popIn' : 'modal-popOut'}`, role: 'dialog', "aria-label": (_s = getPopupById === null || getPopupById === void 0 ? void 0 : getPopupById.item) === null || _s === void 0 ? void 0 : _s.displayName, "aria-modal": true, "aria-labelledby": 'modal-content', style: Object.assign(Object.assign({ padding, animationDuration: ((_t = popup === null || popup === void 0 ? void 0 : popup.duration) !== null && _t !== void 0 ? _t : 0) / 1000 + 's' }, (isScrollFullScreen && {
121
159
  transform: `translateY(${modalTrans}px)`
122
160
  })), { overflow: 'hidden', borderRadius: `${(_x = (_w = (_v = (_u = getPopupById === null || getPopupById === void 0 ? void 0 : getPopupById.item) === null || _u === void 0 ? void 0 : _u.props) === null || _v === void 0 ? void 0 : _v.popupBg) === null || _w === void 0 ? void 0 : _w.borderRadius) !== null && _x !== void 0 ? _x : 0}px`, zIndex: 9 }), onClick: (e) => {
123
161
  e.stopPropagation();
@@ -127,17 +165,17 @@ const Modal = ({ visible, onClose, children, modalStyle, padding, popup, schema,
127
165
  onTouchStart: handleTouchStart,
128
166
  onTouchEnd: handleTouchEnd
129
167
  })),
130
- React.createElement("button", { className: 'modal-icon-wrapper', role: 'button', "aria-label": 'close button', onClick: onClose, style: { top: scrollTop } },
131
- React.createElement("img", { src: (_y = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.popupCloseIcon) !== null && _y !== void 0 ? _y : closeIcon, alt: 'close button', className: 'modal-icon' })),
132
- React.createElement("div", Object.assign({ ref: ref, style: {
168
+ React.createElement("div", Object.assign({ id: 'modal-content', ref: ref, style: {
133
169
  height: isScrollFullScreen ? fullHeight : MODAL_DEF_CON_H,
134
170
  overflow: (isScrollFullScreen && modalTrans <= 0) || !isScrollFullScreen ? 'auto' : 'hidden',
135
171
  zIndex: 1
136
- } }, (((_0 = (_z = getPopupById === null || getPopupById === void 0 ? void 0 : getPopupById.item) === null || _z === void 0 ? void 0 : _z.props) === null || _0 === void 0 ? void 0 : _0.enableFixedCloseButton) && {
172
+ } }, (((_z = (_y = getPopupById === null || getPopupById === void 0 ? void 0 : getPopupById.item) === null || _y === void 0 ? void 0 : _y.props) === null || _z === void 0 ? void 0 : _z.enableFixedCloseButton) && {
137
173
  onScroll: (e) => {
138
174
  var _a;
139
175
  setScrollTop(15 - ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.scrollTop));
140
176
  }
141
- })), child())))))), modalEleRef.current);
177
+ })), child()),
178
+ React.createElement("button", { className: 'modal-icon-wrapper', role: 'button', "aria-label": 'close button', onClick: onClose, style: { top: scrollTop } },
179
+ React.createElement("img", { src: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.popupCloseIcon) || closeIcon, alt: 'close button', className: 'modal-icon' }))))))), modalEleRef.current);
142
180
  };
143
181
  export default memo(Modal);
@@ -1,22 +1,24 @@
1
1
  import { __awaiter } from "tslib";
2
- import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
3
- import { Autoplay, Pagination } from 'swiper/modules';
2
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
+ import { Autoplay, Pagination, Navigation, A11y, Mousewheel, Keyboard } from 'swiper/modules';
4
4
  import { Swiper, SwiperSlide, useSwiperSlide } from 'swiper/react';
5
5
  import Picture from './Picture';
6
6
  import { useSxpDataSource } from '../../../../core/hooks';
7
7
  import { css } from '@emotion/css';
8
8
  import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../../../../core/utils/event';
9
+ import { getScreenReader } from '../../../../core/utils/tool';
9
10
  const PictureGroup = ({ imgUrls, width, height, rec, index, onViewImageEndEvent, onViewImageStartEvent, imgUrlsPostConfig }) => {
10
11
  var _a, _b;
11
- const ref = useRef();
12
+ const swiperRef = useRef();
12
13
  const { isActive } = useSwiperSlide();
13
14
  const { sxpParameter, openHashtag } = useSxpDataSource();
14
15
  const [isLoad, setIsLoad] = useState(false);
15
16
  const [imgInfo, setImgInfo] = useState();
16
17
  const initTime = new Date();
18
+ const [swiperActiveIndex, setSwiperActiveIndex] = useState(0);
17
19
  useEffect(() => {
18
20
  if (isLoad && isActive) {
19
- (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.start();
21
+ (swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) && swiperRef.current.swiper.autoplay.start();
20
22
  if (openHashtag) {
21
23
  onViewImageEndEvent(rec);
22
24
  }
@@ -25,7 +27,7 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onViewImageEndEvent,
25
27
  }
26
28
  }
27
29
  else {
28
- (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.swiper.autoplay.stop();
30
+ (swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) && swiperRef.current.swiper.autoplay.stop();
29
31
  }
30
32
  }, [rec, isActive, onViewImageEndEvent, openHashtag, index, onViewImageStartEvent, isLoad, imgInfo]);
31
33
  const showFirstImageFn = useCallback((e) => __awaiter(void 0, void 0, void 0, function* () {
@@ -46,26 +48,50 @@ const PictureGroup = ({ imgUrls, width, height, rec, index, onViewImageEndEvent,
46
48
  SXP_EVENT_BUS.off(SXP_EVENT_TYPE.PAGE_DID_HIDE, onHide);
47
49
  };
48
50
  }, [imgInfo]);
49
- return (React.createElement(Swiper, { ref: ref, defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay], pagination: {
50
- clickable: true,
51
- bulletActiveClass: 'swipe-item-active-bullet',
52
- bulletElement: 'button'
53
- }, className: css(Object.assign(Object.assign({ '.swiper-pagination': {
54
- bottom: (_a = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.marginBottom) !== null && _a !== void 0 ? _a : 0,
55
- fontSize: '14px'
56
- } }, ((imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.dotsBgColor) && {
57
- '.swiper-pagination-bullet': {
58
- backgroundColor: imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.dotsBgColor,
59
- opacity: 1
60
- }
61
- })), ((imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.dotsActiveColor) && {
62
- '.swipe-item-active-bullet': {
63
- backgroundColor: `${imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.dotsActiveColor}!important`,
64
- opacity: 1
51
+ const handleMouseEnter = useCallback(() => {
52
+ if (swiperRef.current && swiperRef.current.swiper && isAlly) {
53
+ swiperRef.current.swiper.autoplay.stop();
54
+ }
55
+ }, []);
56
+ const handleMouseLeave = useCallback(() => {
57
+ if (swiperRef.current && swiperRef.current.swiper && isAlly) {
58
+ swiperRef.current.swiper.autoplay.start();
59
+ }
60
+ }, []);
61
+ const handleSlideChange = useCallback((swiper) => {
62
+ setSwiperActiveIndex(swiper.activeIndex);
63
+ }, []);
64
+ const isAlly = useMemo(() => getScreenReader(), []);
65
+ return (React.createElement("div", { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
66
+ React.createElement(Swiper, Object.assign({ defaultValue: 0, direction: 'horizontal', modules: [Pagination, Autoplay, ...(isAlly ? [Navigation, A11y, Mousewheel, Keyboard] : [])], pagination: {
67
+ clickable: true,
68
+ bulletActiveClass: 'swipe-item-active-bullet',
69
+ bulletElement: 'button'
70
+ } }, (isAlly
71
+ ? {
72
+ mousewheel: true,
73
+ keyboard: true,
74
+ navigation: true,
75
+ a11y: {
76
+ enabled: true
77
+ }
65
78
  }
66
- }))), height: height, loop: true, autoplay: { delay: ((_b = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.delay) !== null && _b !== void 0 ? _b : 3) * 1000 } }, imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url, index) => {
67
- return (React.createElement(SwiperSlide, { key: index },
68
- React.createElement(Picture, { src: !isLoad && index > 0 ? '' : url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: showFirstImageFn })));
69
- })));
79
+ : {}), { loop: true, ref: swiperRef, onSlideChange: handleSlideChange, className: css(Object.assign(Object.assign({ '.swiper-pagination': {
80
+ bottom: (_a = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.marginBottom) !== null && _a !== void 0 ? _a : 0,
81
+ fontSize: '14px'
82
+ } }, ((imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.dotsBgColor) && {
83
+ '.swiper-pagination-bullet': {
84
+ backgroundColor: imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.dotsBgColor,
85
+ opacity: 1
86
+ }
87
+ })), ((imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.dotsActiveColor) && {
88
+ '.swipe-item-active-bullet': {
89
+ backgroundColor: `${imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.dotsActiveColor}!important`,
90
+ opacity: 1
91
+ }
92
+ }))), height: height, autoplay: { delay: ((_b = imgUrlsPostConfig === null || imgUrlsPostConfig === void 0 ? void 0 : imgUrlsPostConfig.delay) !== null && _b !== void 0 ? _b : 3) * 1000 } }), imgUrls === null || imgUrls === void 0 ? void 0 : imgUrls.map((url, srcKey) => {
93
+ return (React.createElement(SwiperSlide, { key: srcKey, "aria-hidden": srcKey !== swiperActiveIndex },
94
+ React.createElement(Picture, { src: !isLoad && srcKey > 0 ? '' : url, height: height, imgUrlsPostConfig: imgUrlsPostConfig, onShowFirstImage: showFirstImageFn })));
95
+ }))));
70
96
  };
71
97
  export default memo(PictureGroup);
@@ -493,9 +493,9 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
493
493
  alignItems: 'center'
494
494
  } },
495
495
  React.createElement("img", { width: 64, height: 64, src: loadingImage, alt: 'loading...', style: { objectFit: 'contain' } }))) : (React.createElement(React.Fragment, null,
496
+ renderBottom(rec, index),
496
497
  renderLikeButton(rec, index, !(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconFixed)),
497
498
  renderToggleButton(!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed)),
498
- renderBottom(rec, index),
499
499
  renderContent(rec, index)))))));
500
500
  });
501
501
  }, [
@@ -561,9 +561,9 @@ const SxpPageRender = ({ globalConfig, descStyle, containerHeight = window.inner
561
561
  }
562
562
  }
563
563
  }, direction: 'vertical', height: height },
564
+ renderView,
564
565
  renderLikeButton(visList[activeIndex], activeIndex, !!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.likeIconFixed)),
565
- renderToggleButton(!!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed)),
566
- renderView),
566
+ renderToggleButton(!!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.muteIconFixed))),
567
567
  React.createElement(WaterFall, Object.assign({}, (_w = (_v = (_u = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.hashTag) === null || _u === void 0 ? void 0 : _u[0]) === null || _v === void 0 ? void 0 : _v.item) === null || _w === void 0 ? void 0 : _w.props)),
568
568
  React.createElement(ConsentPopup, { resolver: resolver, globalConfig: globalConfig })));
569
569
  };
@@ -0,0 +1,2 @@
1
+ declare const useFocusTrap: (elementRef: any) => void;
2
+ export default useFocusTrap;
@@ -0,0 +1,37 @@
1
+ import { useEffect } from 'react';
2
+ const useFocusTrap = (elementRef) => {
3
+ useEffect(() => {
4
+ const trapFocus = (element) => {
5
+ var focusableEls = element === null || element === void 0 ? void 0 : element.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])');
6
+ var firstFocusableEl = focusableEls === null || focusableEls === void 0 ? void 0 : focusableEls[0];
7
+ var lastFocusableEl = focusableEls === null || focusableEls === void 0 ? void 0 : focusableEls[(focusableEls === null || focusableEls === void 0 ? void 0 : focusableEls.length) - 1];
8
+ var KEYCODE_TAB = 9;
9
+ element.addEventListener('keydown', function (e) {
10
+ var isTabPressed = e.key === 'Tab' || e.keyCode === KEYCODE_TAB;
11
+ if (!isTabPressed) {
12
+ return;
13
+ }
14
+ if (e.shiftKey) {
15
+ if ((document === null || document === void 0 ? void 0 : document.activeElement) === firstFocusableEl) {
16
+ lastFocusableEl === null || lastFocusableEl === void 0 ? void 0 : lastFocusableEl.focus();
17
+ e.preventDefault();
18
+ }
19
+ }
20
+ else {
21
+ if ((document === null || document === void 0 ? void 0 : document.activeElement) === lastFocusableEl) {
22
+ firstFocusableEl === null || firstFocusableEl === void 0 ? void 0 : firstFocusableEl.focus();
23
+ e.preventDefault();
24
+ }
25
+ }
26
+ });
27
+ firstFocusableEl === null || firstFocusableEl === void 0 ? void 0 : firstFocusableEl.focus();
28
+ };
29
+ if (elementRef === null || elementRef === void 0 ? void 0 : elementRef.current)
30
+ trapFocus(elementRef === null || elementRef === void 0 ? void 0 : elementRef.current);
31
+ return () => {
32
+ var _a;
33
+ (_a = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', trapFocus);
34
+ };
35
+ }, [elementRef]);
36
+ };
37
+ export default useFocusTrap;
@@ -11,4 +11,5 @@ declare function getBrowserInfo(): string | null;
11
11
  declare function getSystem(): string | null;
12
12
  declare function getDevice(): string | null;
13
13
  declare function getCookie(val: string): string;
14
- export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie };
14
+ declare function getScreenReader(): boolean;
15
+ export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie, getScreenReader };
@@ -156,4 +156,15 @@ function getCookie(val) {
156
156
  });
157
157
  return value !== null && value !== void 0 ? value : '';
158
158
  }
159
- export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie };
159
+ function getScreenReader() {
160
+ let userAgent = self.navigator.userAgent;
161
+ if (!userAgent)
162
+ return false;
163
+ return (/TalkBack/i.test(userAgent) ||
164
+ /Funtouch/i.test(userAgent) ||
165
+ /VoiceOver/i.test(userAgent) ||
166
+ /NVDA/i.test(userAgent) ||
167
+ /JAWS/i.test(userAgent) ||
168
+ /ChromeVox/i.test(userAgent));
169
+ }
170
+ export { uuid, getIndexByblockType, getBrowserInfo, getDevice, getSystem, getCookie, getScreenReader };
package/es/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Pagebuilder } from './core/Pagebuilder';
2
+ import './index.css';
2
3
  export * as core from './core';
3
4
  export * as materials from './materials';
4
5
  export { default as SxpPageRender } from './core/components/SxpPageRender';
package/es/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Pagebuilder } from './core/Pagebuilder';
2
+ import './index.css';
2
3
  import * as core_1 from './core';
3
4
  export { core_1 as core };
4
5
  import * as materials_1 from './materials';
@@ -8,7 +8,7 @@ import { setFontForText } from '../../../../core/utils/tool';
8
8
  import styles from './index.module.less';
9
9
  const closeIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAjhJREFUWEfFlztOw0AQhmeWiJ4CCmpQ5DiRQsIJyAWg5A0lR0AIChDiCJS8ER0cADgBeRSxt4CCDgkaKiq8i+zYeWx2413HEWmiJJv9v535Z2aN8M8vFPT9z3zETD0aAUChUJjwvPFHAJhBhB3Hqd6OAsK2yyucwykAvP38eJX398Z3AJDLlVYR8ToU9Rhj25TWr9KEsKy5dULIGQCMtfZly45TvwsAstm56UwG6wA4FUFwzrdctxZBDcWSy5XWEPG8I84/GcMipdWPtgcsaz5PCHtKG0IuTiqUvjT9U/WYMG2IOPE+AP+LtCB0xKUAAyA2Xbd2o2OG0NQXvTnvhL17D7EPtH9TRCIWwkRcGYGIQgYBABuqPuHXOQBc6pw80lBGwBQiiXhsBHQhkoprA6iM6acjhDQKu5YJZW6XeOI3XJdpvfsdTu52VfXEekD8owQiXGIubpSCbhDbLu8DwKEAd+A41SOdPpE4BS0viFOtvV2iKWqUgn5x/tmS70xR01GuDSCKc86/OCcLgTyyZ0ScDGNhFAktAJV4NFJ9YyaFiAWIE+9uVkkgBgLoig8DMWAa9ro9ynkUdlW5maZDCmB6clmz0k1HH4Cs1Ezbq2p2yEpUuBOKTSZZex00RUWIrltxuuK6EOGDSbGIOPZicpMx6fny650377qNRgBgWeVFQuA+6UjVgREhGIMlSqsPUQqIbZdOOIdZQmCv2axRnU1N1+TzJYsxOEaEV8ep7frPZ7Gd0FTEdP0ft0/kMNdg0eoAAAAASUVORK5CYII=';
10
10
  const AniLinkPopup = (_a) => {
11
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
11
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
12
12
  var { style, recData, ctaTempStyles, index, event, bottom_image, translateY, isTel, onClick, isExternalLink = false, isActive } = _a, props = __rest(_a, ["style", "recData", "ctaTempStyles", "index", "event", "bottom_image", "translateY", "isTel", "onClick", "isExternalLink", "isActive"]);
13
13
  style === null || style === void 0 ? true : delete style.transform;
14
14
  const { sxpParameter, globalConfig, ctaEvent, setPopupDetailData } = useSxpDataSource();
@@ -65,12 +65,12 @@ const AniLinkPopup = (_a) => {
65
65
  paddingLeft: '6px'
66
66
  } }, "Cta Title")) : (React.createElement("div", Object.assign({}, props, { className: `${css(Object.assign(Object.assign({}, style), { '--transY': `translateY(calc(100% + ${(_r = style === null || style === void 0 ? void 0 : style.margin) !== null && _r !== void 0 ? _r : 0}px))` }))} ${styles['aniLinkPopup']} ${aniNamStyle} ${css(aniTimStyle)}`, onClick: handleTo }),
67
67
  React.createElement("div", { onClick: onClose, className: styles['modal-icon-wrapper'], style: { padding: (_s = style === null || style === void 0 ? void 0 : style['padding']) !== null && _s !== void 0 ? _s : 0 } },
68
- React.createElement("img", { src: (_t = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.popupCloseIcon) !== null && _t !== void 0 ? _t : closeIcon, alt: 'close', className: styles['modal-icon-wrapper-img'] })),
69
- React.createElement(Img, { src: src, rec: recData, item: (_y = (_w = (_v = (_u = recData === null || recData === void 0 ? void 0 : recData.video) === null || _u === void 0 ? void 0 : _u.bindProducts) === null || _v === void 0 ? void 0 : _v[0]) !== null && _w !== void 0 ? _w : (_x = recData === null || recData === void 0 ? void 0 : recData.video) === null || _x === void 0 ? void 0 : _x.bindProduct) !== null && _y !== void 0 ? _y : recData === null || recData === void 0 ? void 0 : recData.video, index: index, translateY: translateY, imgStyle: ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img, isActive: isActive }),
68
+ React.createElement("img", { src: (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.popupCloseIcon) || closeIcon, alt: 'close', className: styles['modal-icon-wrapper-img'] })),
69
+ React.createElement(Img, { src: src, rec: recData, item: (_x = (_v = (_u = (_t = recData === null || recData === void 0 ? void 0 : recData.video) === null || _t === void 0 ? void 0 : _t.bindProducts) === null || _u === void 0 ? void 0 : _u[0]) !== null && _v !== void 0 ? _v : (_w = recData === null || recData === void 0 ? void 0 : recData.video) === null || _w === void 0 ? void 0 : _w.bindProduct) !== null && _x !== void 0 ? _x : recData === null || recData === void 0 ? void 0 : recData.video, index: index, translateY: translateY, imgStyle: ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.img, isActive: isActive }),
70
70
  (!recData || (product === null || product === void 0 ? void 0 : product.title)) && (React.createElement("div", { className: styles['one-line-ellipsis'], style: ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.title, dangerouslySetInnerHTML: {
71
- __html: setFontForText((_z = product === null || product === void 0 ? void 0 : product.title) !== null && _z !== void 0 ? _z : 'Product Name', ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.title)
71
+ __html: setFontForText((_y = product === null || product === void 0 ? void 0 : product.title) !== null && _y !== void 0 ? _y : 'Product Name', ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.title)
72
72
  } })),
73
- React.createElement("div", { className: styles['one-line-ellipsis'], style: Object.assign(Object.assign({}, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.ctaTitle), { lineHeight: ((_0 = ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.ctaTitle) === null || _0 === void 0 ? void 0 : _0.height) + 'px' }), dangerouslySetInnerHTML: {
73
+ React.createElement("div", { className: styles['one-line-ellipsis'], style: Object.assign(Object.assign({}, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.ctaTitle), { lineHeight: ((_z = ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.ctaTitle) === null || _z === void 0 ? void 0 : _z.height) + 'px' }), dangerouslySetInnerHTML: {
74
74
  __html: setFontForText(title, ctaTempStyles === null || ctaTempStyles === void 0 ? void 0 : ctaTempStyles.ctaTitle)
75
75
  } })))));
76
76
  };
@@ -3,13 +3,13 @@ import { css } from '@emotion/css';
3
3
  import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { useSxpDataSource } from '../../../../core/hooks';
5
5
  import './index.less';
6
- import { Autoplay, Pagination } from 'swiper/modules';
6
+ import { A11y, Autoplay, Keyboard, Mousewheel, Navigation, Pagination } from 'swiper/modules';
7
7
  import { Swiper, SwiperSlide } from 'swiper/react';
8
8
  import { useEventReport } from '../../../../core/hooks/useEventReport';
9
9
  import Modal from '../../../../core/components/SxpPageRender/Modal';
10
10
  import ExpandableText from '../../../../core/components/SxpPageRender/ExpandableText';
11
11
  import FormatImage from '../../../../core/components/SxpPageRender/FormatImage';
12
- import { setFontForText } from '../../../../core/utils/tool';
12
+ import { getScreenReader, setFontForText } from '../../../../core/utils/tool';
13
13
  import CommodityGroup from '../../template/components/CommodityGroup';
14
14
  import { getPriceText } from '../../../../core/utils/materials';
15
15
  const CommodityDetail = (_a) => {
@@ -21,7 +21,8 @@ const CommodityDetail = (_a) => {
21
21
  const [showModal, setShowModal] = useState(false);
22
22
  const [show3DModal, setShow3DModal] = useState(false);
23
23
  const [checkCommodityIndex, setCheckCommodityIndex] = useState((_b = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.multiCheckIndex) !== null && _b !== void 0 ? _b : 0);
24
- const ref = useRef();
24
+ const swiperRef = useRef();
25
+ const [swiperActiveIndex, setSwiperActiveIndex] = useState(0);
25
26
  const data = isPost ? rec : popupDetailData;
26
27
  let product = isPost ? data === null || data === void 0 ? void 0 : data.product : (_d = (_c = data === null || data === void 0 ? void 0 : data.video) === null || _c === void 0 ? void 0 : _c.bindProduct) !== null && _d !== void 0 ? _d : (_f = (_e = data === null || data === void 0 ? void 0 : data.video) === null || _e === void 0 ? void 0 : _e.bindProducts) === null || _f === void 0 ? void 0 : _f[0];
27
28
  let cta = isPost
@@ -97,7 +98,7 @@ const CommodityDetail = (_a) => {
97
98
  };
98
99
  const renderBtn = () => {
99
100
  var _a, _b;
100
- return (React.createElement(React.Fragment, null, (isDefault || (product === null || product === void 0 ? void 0 : product.link)) && (React.createElement("button", { "aria-label": (_a = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _a !== void 0 ? _a : 'Purchase on Website', onClick: handleLink, className: 'pb-commondity-btn', style: buttonStyle },
101
+ return (React.createElement(React.Fragment, null, (isDefault || (product === null || product === void 0 ? void 0 : product.link)) && (React.createElement("a", { "aria-label": (_a = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _a !== void 0 ? _a : 'Purchase on Website', role: 'button', tabIndex: 0, onClick: handleLink, className: 'pb-commondity-btn', style: buttonStyle },
101
102
  React.createElement("span", { dangerouslySetInnerHTML: {
102
103
  __html: setFontForText((_b = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _b !== void 0 ? _b : 'Purchase on Website', buttonStyle)
103
104
  } })))));
@@ -112,9 +113,9 @@ const CommodityDetail = (_a) => {
112
113
  popupCurTimeRef.current = new Date();
113
114
  setCheckCommodityIndex(index);
114
115
  checkCommodityIndexRef.current = index;
115
- if (ref === null || ref === void 0 ? void 0 : ref.current) {
116
- ref.current.swiper.slideTo(0);
117
- ref.current.swiper.autoplay.start();
116
+ if (swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) {
117
+ swiperRef.current.swiper.slideTo(0);
118
+ swiperRef.current.swiper.autoplay.start();
118
119
  }
119
120
  }, []);
120
121
  const renderCommodityGroup = useCallback(() => {
@@ -132,17 +133,40 @@ const CommodityDetail = (_a) => {
132
133
  return dotsAlignClass === null || dotsAlignClass === void 0 ? void 0 : dotsAlignClass[swiper === null || swiper === void 0 ? void 0 : swiper.dotsAlign];
133
134
  }, [swiper === null || swiper === void 0 ? void 0 : swiper.dotsAlign]);
134
135
  const iframeUrl = product === null || product === void 0 ? void 0 : product.remark;
136
+ const handleMouseEnter = useCallback(() => {
137
+ if (swiperRef.current && swiperRef.current.swiper && isAlly) {
138
+ swiperRef.current.swiper.autoplay.stop();
139
+ }
140
+ }, []);
141
+ const handleMouseLeave = useCallback(() => {
142
+ if (swiperRef.current && swiperRef.current.swiper && isAlly) {
143
+ swiperRef.current.swiper.autoplay.start();
144
+ }
145
+ }, []);
146
+ const handleSlideChange = useCallback((swiper) => {
147
+ setSwiperActiveIndex(swiper.activeIndex);
148
+ }, []);
149
+ const isAlly = useMemo(() => getScreenReader(), []);
135
150
  return (React.createElement(React.Fragment, null,
136
151
  React.createElement("div", Object.assign({ className: css(Object.assign({}, style)) }, props),
137
- React.createElement("div", { style: { position: 'relative' } },
138
- product && ((_w = product === null || product === void 0 ? void 0 : product.homePage) === null || _w === void 0 ? void 0 : _w.length) > 0 && (React.createElement(Swiper, { height: height, modules: [Pagination, Autoplay], pagination: {
152
+ React.createElement("div", { style: { position: 'relative' }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
153
+ product && ((_w = product === null || product === void 0 ? void 0 : product.homePage) === null || _w === void 0 ? void 0 : _w.length) > 0 && (React.createElement(Swiper, Object.assign({ height: height, modules: [Pagination, Autoplay, ...(isAlly ? [Navigation, A11y, Mousewheel, Keyboard] : [])], pagination: {
139
154
  clickable: true,
140
155
  bulletActiveClass: 'swipe-item-active-bullet',
141
156
  clickableClass: getDotsAlign,
142
157
  bulletElement: 'button'
143
- }, loop: true, autoplay: {
158
+ } }, (isAlly
159
+ ? {
160
+ mousewheel: true,
161
+ keyboard: true,
162
+ navigation: true,
163
+ a11y: {
164
+ enabled: true
165
+ }
166
+ }
167
+ : {}), { loop: true, autoplay: {
144
168
  delay: (swiper === null || swiper === void 0 ? void 0 : swiper.delay) * 1000
145
- }, ref: ref, className: css(Object.assign(Object.assign({ '.swiper-pagination': { bottom: (_x = swiper === null || swiper === void 0 ? void 0 : swiper.dotsMarginBottom) !== null && _x !== void 0 ? _x : 0, fontSize: '14px' } }, ((swiper === null || swiper === void 0 ? void 0 : swiper.dotsBgColor) && {
169
+ }, ref: swiperRef, onSlideChange: handleSlideChange, className: css(Object.assign(Object.assign({ '.swiper-pagination': { bottom: (_x = swiper === null || swiper === void 0 ? void 0 : swiper.dotsMarginBottom) !== null && _x !== void 0 ? _x : 0, fontSize: '14px' } }, ((swiper === null || swiper === void 0 ? void 0 : swiper.dotsBgColor) && {
146
170
  '.swiper-pagination-bullet': {
147
171
  backgroundColor: swiper === null || swiper === void 0 ? void 0 : swiper.dotsBgColor,
148
172
  opacity: 1
@@ -152,10 +176,10 @@ const CommodityDetail = (_a) => {
152
176
  backgroundColor: `${swiper === null || swiper === void 0 ? void 0 : swiper.dotsActiveColor}!important`,
153
177
  opacity: 1
154
178
  }
155
- }))) },
156
- React.createElement(React.Fragment, null, (_y = product === null || product === void 0 ? void 0 : product.homePage) === null || _y === void 0 ? void 0 : _y.map((src) => {
179
+ }))) }),
180
+ React.createElement(React.Fragment, null, (_y = product === null || product === void 0 ? void 0 : product.homePage) === null || _y === void 0 ? void 0 : _y.map((src, srcKey) => {
157
181
  var _a;
158
- return (React.createElement(SwiperSlide, { key: src },
182
+ return (React.createElement(SwiperSlide, { key: srcKey, "aria-hidden": srcKey !== swiperActiveIndex },
159
183
  React.createElement("div", { style: {
160
184
  overflow: 'hidden',
161
185
  width,
@@ -3,13 +3,13 @@ import { css } from '@emotion/css';
3
3
  import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { useSxpDataSource } from '../../../../core/hooks';
5
5
  import './index.less';
6
- import { Autoplay, Pagination } from 'swiper/modules';
6
+ import { Autoplay, Pagination, Navigation, A11y, Mousewheel, Keyboard } from 'swiper/modules';
7
7
  import { Swiper, SwiperSlide } from 'swiper/react';
8
8
  import Modal from '../../../../core/components/SxpPageRender/Modal';
9
9
  import ExpandableText from '../../../../core/components/SxpPageRender/ExpandableText';
10
10
  import { useEventReport } from '../../../../core/hooks/useEventReport';
11
11
  import FormatImage from '../../../../core/components/SxpPageRender/FormatImage';
12
- import { setFontForText } from '../../../../core/utils/tool';
12
+ import { getScreenReader, setFontForText } from '../../../../core/utils/tool';
13
13
  import CommodityGroup from '../../template/components/CommodityGroup';
14
14
  import { getPriceText } from '../../../../core/utils/materials';
15
15
  const CommodityDetailDiroNew = (_a) => {
@@ -25,7 +25,8 @@ const CommodityDetailDiroNew = (_a) => {
25
25
  const curTimeRef = useRef(null);
26
26
  const [show3DModal, setShow3DModal] = useState(false);
27
27
  const [checkCommodityIndex, setCheckCommodityIndex] = useState((_b = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.multiCheckIndex) !== null && _b !== void 0 ? _b : 0);
28
- const ref = useRef();
28
+ const swiperRef = useRef();
29
+ const [swiperActiveIndex, setSwiperActiveIndex] = useState(0);
29
30
  const data = isPost ? rec : popupDetailData;
30
31
  let product = isPost ? data === null || data === void 0 ? void 0 : data.product : (_d = (_c = data === null || data === void 0 ? void 0 : data.video) === null || _c === void 0 ? void 0 : _c.bindProduct) !== null && _d !== void 0 ? _d : (_f = (_e = data === null || data === void 0 ? void 0 : data.video) === null || _e === void 0 ? void 0 : _e.bindProducts) === null || _f === void 0 ? void 0 : _f[0];
31
32
  let cta = isPost
@@ -98,9 +99,9 @@ Made in Italy` })));
98
99
  popupCurTimeRef.current = new Date();
99
100
  setCheckCommodityIndex(index);
100
101
  checkCommodityIndexRef.current = index;
101
- if (ref === null || ref === void 0 ? void 0 : ref.current) {
102
- ref.current.swiper.slideTo(0);
103
- ref.current.swiper.autoplay.start();
102
+ if (swiperRef === null || swiperRef === void 0 ? void 0 : swiperRef.current) {
103
+ swiperRef.current.swiper.slideTo(0);
104
+ swiperRef.current.swiper.autoplay.start();
104
105
  }
105
106
  }, []);
106
107
  const renderCommodityGroup = useCallback(() => {
@@ -118,17 +119,40 @@ Made in Italy` })));
118
119
  return dotsAlignClass === null || dotsAlignClass === void 0 ? void 0 : dotsAlignClass[swiper === null || swiper === void 0 ? void 0 : swiper.dotsAlign];
119
120
  }, [swiper === null || swiper === void 0 ? void 0 : swiper.dotsAlign]);
120
121
  const iframeUrl = product === null || product === void 0 ? void 0 : product.remark;
122
+ const handleMouseEnter = useCallback(() => {
123
+ if (swiperRef.current && swiperRef.current.swiper && isAlly) {
124
+ swiperRef.current.swiper.autoplay.stop();
125
+ }
126
+ }, []);
127
+ const handleMouseLeave = useCallback(() => {
128
+ if (swiperRef.current && swiperRef.current.swiper && isAlly) {
129
+ swiperRef.current.swiper.autoplay.start();
130
+ }
131
+ }, []);
132
+ const handleSlideChange = useCallback((swiper) => {
133
+ setSwiperActiveIndex(swiper.activeIndex);
134
+ }, []);
135
+ const isAlly = useMemo(() => getScreenReader(), []);
121
136
  return (React.createElement("div", { className: 'pb-commondityDiroNew' },
122
137
  React.createElement("div", Object.assign({ className: css(Object.assign(Object.assign({}, style), { transform: 'translate3d(0px, 0px, 0px)' })) }, props),
123
- React.createElement("div", { style: { position: 'relative' } },
124
- product && ((_w = product === null || product === void 0 ? void 0 : product.homePage) === null || _w === void 0 ? void 0 : _w.length) > 0 && (React.createElement(Swiper, { height: height, modules: [Pagination, Autoplay], pagination: {
138
+ React.createElement("div", { style: { position: 'relative' }, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
139
+ product && ((_w = product === null || product === void 0 ? void 0 : product.homePage) === null || _w === void 0 ? void 0 : _w.length) > 0 && (React.createElement(Swiper, Object.assign({ height: height, modules: [Pagination, Autoplay, ...(isAlly ? [Navigation, A11y, Mousewheel, Keyboard] : [])], pagination: {
125
140
  clickable: true,
126
141
  bulletActiveClass: 'swipe-item-active-bullet',
127
142
  clickableClass: getDotsAlign,
128
143
  bulletElement: 'button'
129
- }, loop: true, autoplay: {
144
+ } }, (isAlly
145
+ ? {
146
+ mousewheel: true,
147
+ keyboard: true,
148
+ navigation: true,
149
+ a11y: {
150
+ enabled: true
151
+ }
152
+ }
153
+ : {}), { loop: true, ref: swiperRef, onSlideChange: handleSlideChange, autoplay: {
130
154
  delay: (swiper === null || swiper === void 0 ? void 0 : swiper.delay) * 1000
131
- }, ref: ref, className: css(Object.assign(Object.assign({ '.swiper-pagination': {
155
+ }, className: css(Object.assign(Object.assign({ '.swiper-pagination': {
132
156
  bottom: (_x = swiper === null || swiper === void 0 ? void 0 : swiper.dotsMarginBottom) !== null && _x !== void 0 ? _x : 0,
133
157
  fontSize: '14px'
134
158
  } }, ((swiper === null || swiper === void 0 ? void 0 : swiper.dotsBgColor) && {
@@ -141,9 +165,9 @@ Made in Italy` })));
141
165
  backgroundColor: `${swiper === null || swiper === void 0 ? void 0 : swiper.dotsActiveColor}!important`,
142
166
  opacity: 1
143
167
  }
144
- }))) }, (_y = product === null || product === void 0 ? void 0 : product.homePage) === null || _y === void 0 ? void 0 : _y.map((src) => {
168
+ }))) }), (_y = product === null || product === void 0 ? void 0 : product.homePage) === null || _y === void 0 ? void 0 : _y.map((src, srcKey) => {
145
169
  var _a;
146
- return (React.createElement(SwiperSlide, { key: src },
170
+ return (React.createElement(SwiperSlide, { key: srcKey, "aria-hidden": srcKey !== swiperActiveIndex },
147
171
  React.createElement("div", { style: {
148
172
  overflow: 'hidden',
149
173
  width,
@@ -194,7 +218,7 @@ Made in Italy` })));
194
218
  React.createElement("div", { className: 'pb-commondityDiroNew-content-top-right-price', hidden: !!product && !(product === null || product === void 0 ? void 0 : product.taxInfo), style: getStyle(commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.taxInfo), dangerouslySetInnerHTML: {
195
219
  __html: setFontForText((_2 = product === null || product === void 0 ? void 0 : product.taxInfo) !== null && _2 !== void 0 ? _2 : '税费', commodityStyles === null || commodityStyles === void 0 ? void 0 : commodityStyles.taxInfo)
196
220
  } }))),
197
- (!product || (product === null || product === void 0 ? void 0 : product.link)) && (React.createElement("button", { "aria-label": (_3 = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _3 !== void 0 ? _3 : 'Shop now', onClick: handleLink, className: 'pb-commondityDiroNew-btn', style: buttonStyle },
221
+ (!product || (product === null || product === void 0 ? void 0 : product.link)) && (React.createElement("a", { "aria-label": (_3 = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _3 !== void 0 ? _3 : 'Shop now', role: 'button', tabIndex: 0, onClick: handleLink, className: 'pb-commondityDiroNew-btn', style: buttonStyle },
198
222
  React.createElement("span", { dangerouslySetInnerHTML: {
199
223
  __html: setFontForText((_4 = cta === null || cta === void 0 ? void 0 : cta.enTitle) !== null && _4 !== void 0 ? _4 : 'Shop now', buttonStyle)
200
224
  } }))),