@sonic-equipment/ui 0.0.105 → 0.0.107
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/dist/index.js
CHANGED
|
@@ -2126,7 +2126,7 @@ function nextTick(callback, delay) {
|
|
|
2126
2126
|
}
|
|
2127
2127
|
return setTimeout(callback, delay);
|
|
2128
2128
|
}
|
|
2129
|
-
function now() {
|
|
2129
|
+
function now$1() {
|
|
2130
2130
|
return Date.now();
|
|
2131
2131
|
}
|
|
2132
2132
|
function getComputedStyle$1(el) {
|
|
@@ -2829,7 +2829,7 @@ function freeMode(_ref) {
|
|
|
2829
2829
|
}
|
|
2830
2830
|
data.velocities.push({
|
|
2831
2831
|
position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
|
|
2832
|
-
time: now()
|
|
2832
|
+
time: now$1()
|
|
2833
2833
|
});
|
|
2834
2834
|
}
|
|
2835
2835
|
function onTouchEnd(_ref2) {
|
|
@@ -2845,7 +2845,7 @@ function freeMode(_ref) {
|
|
|
2845
2845
|
touchEventsData: data
|
|
2846
2846
|
} = swiper;
|
|
2847
2847
|
// Time diff
|
|
2848
|
-
const touchEndTime = now();
|
|
2848
|
+
const touchEndTime = now$1();
|
|
2849
2849
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
2850
2850
|
if (currentPos < -swiper.minTranslate()) {
|
|
2851
2851
|
swiper.slideTo(swiper.activeIndex);
|
|
@@ -2872,7 +2872,7 @@ function freeMode(_ref) {
|
|
|
2872
2872
|
}
|
|
2873
2873
|
// this implies that the user stopped moving a finger then released.
|
|
2874
2874
|
// There would be no events with distance zero, so the last event is stale.
|
|
2875
|
-
if (time > 150 || now() - lastMoveEvent.time > 300) {
|
|
2875
|
+
if (time > 150 || now$1() - lastMoveEvent.time > 300) {
|
|
2876
2876
|
swiper.velocity = 0;
|
|
2877
2877
|
}
|
|
2878
2878
|
} else {
|
|
@@ -5254,7 +5254,7 @@ function onTouchStart(event) {
|
|
|
5254
5254
|
});
|
|
5255
5255
|
touches.startX = startX;
|
|
5256
5256
|
touches.startY = startY;
|
|
5257
|
-
data.touchStartTime = now();
|
|
5257
|
+
data.touchStartTime = now$1();
|
|
5258
5258
|
swiper.allowClick = true;
|
|
5259
5259
|
swiper.updateSize();
|
|
5260
5260
|
swiper.swipeDirection = undefined;
|
|
@@ -5329,7 +5329,7 @@ function onTouchMove(event) {
|
|
|
5329
5329
|
currentX: pageX,
|
|
5330
5330
|
currentY: pageY
|
|
5331
5331
|
});
|
|
5332
|
-
data.touchStartTime = now();
|
|
5332
|
+
data.touchStartTime = now$1();
|
|
5333
5333
|
}
|
|
5334
5334
|
return;
|
|
5335
5335
|
}
|
|
@@ -5590,7 +5590,7 @@ function onTouchEnd(event) {
|
|
|
5590
5590
|
}
|
|
5591
5591
|
|
|
5592
5592
|
// Time diff
|
|
5593
|
-
const touchEndTime = now();
|
|
5593
|
+
const touchEndTime = now$1();
|
|
5594
5594
|
const timeDiff = touchEndTime - data.touchStartTime;
|
|
5595
5595
|
|
|
5596
5596
|
// Tap, doubleTap, Click
|
|
@@ -5602,7 +5602,7 @@ function onTouchEnd(event) {
|
|
|
5602
5602
|
swiper.emit('doubleTap doubleClick', e);
|
|
5603
5603
|
}
|
|
5604
5604
|
}
|
|
5605
|
-
data.lastClickTime = now();
|
|
5605
|
+
data.lastClickTime = now$1();
|
|
5606
5606
|
nextTick(() => {
|
|
5607
5607
|
if (!swiper.destroyed) swiper.allowClick = true;
|
|
5608
5608
|
});
|
|
@@ -8319,16 +8319,18 @@ function Announcement({ announcement: { href, id, text, title, type }, onDismiss
|
|
|
8319
8319
|
return (jsxs(RouteLink, { className: clsx(styles$C.announcement, styles$C[type]), href: href, children: [jsxs("div", { className: styles$C.wrapper, children: [jsx("div", { className: styles$C.icon, children: iconMap[type] }), jsxs("div", { className: styles$C.content, children: [jsx("h2", { className: styles$C.title, children: title }), jsxs("p", { className: styles$C.text, children: [text, jsx(GlyphsArrowSemiBoldRightIcon, {})] })] })] }), jsx("div", { className: styles$C.close, children: jsx(IconButton, { color: "current-color", onClick: () => onDismiss?.(id), children: jsx(StrokeCloseboxIcon, {}) }) })] }));
|
|
8320
8320
|
}
|
|
8321
8321
|
|
|
8322
|
+
const now = () => new Date();
|
|
8322
8323
|
function ConnectedAnnouncement({ announcement: { endDate, startDate, ...announcement }, onDismiss, }) {
|
|
8324
|
+
const [isVisible, setIsVisible] = useState((!startDate || startDate <= now()) && (!endDate || endDate > now()));
|
|
8323
8325
|
useEffect(() => {
|
|
8326
|
+
if (endDate && now() >= endDate)
|
|
8327
|
+
return;
|
|
8324
8328
|
const interval = setInterval(() => {
|
|
8325
|
-
|
|
8326
|
-
onDismiss?.(announcement.id);
|
|
8327
|
-
}
|
|
8329
|
+
setIsVisible((!startDate || startDate <= now()) && (!endDate || endDate > now()));
|
|
8328
8330
|
}, 1 * TIME.MINUTE);
|
|
8329
8331
|
return () => clearInterval(interval);
|
|
8330
|
-
}, [endDate,
|
|
8331
|
-
if (
|
|
8332
|
+
}, [endDate, startDate]);
|
|
8333
|
+
if (!isVisible)
|
|
8332
8334
|
return null;
|
|
8333
8335
|
return jsx(Announcement, { announcement: announcement, onDismiss: onDismiss });
|
|
8334
8336
|
}
|
|
@@ -8337,23 +8339,18 @@ var styles$B = {"announcement-provider":"announcement-provider-module-sVIKY","an
|
|
|
8337
8339
|
|
|
8338
8340
|
function AnnouncementProvider() {
|
|
8339
8341
|
const languageCode = useLanguageCode();
|
|
8342
|
+
const nodeRef = useRef(null);
|
|
8340
8343
|
const { data: announcements } = useFetchAnnouncements({
|
|
8341
8344
|
languageCode,
|
|
8342
8345
|
});
|
|
8343
8346
|
const [dismissedIds, setDismissedIds] = useLocalStorage('dismissedAnnouncementIds', []);
|
|
8344
8347
|
const filteredAnnouncements = announcements?.filter(({ id }) => !dismissedIds.includes(id));
|
|
8345
|
-
return (jsx(TransitionGroup, { className: styles$B['announcement-provider'], children: filteredAnnouncements?.map(
|
|
8348
|
+
return (jsx(TransitionGroup, { className: styles$B['announcement-provider'], children: filteredAnnouncements?.map(announcement => (jsx(CSSTransition, { classNames: {
|
|
8346
8349
|
enter: styles$B['announcement-enter'],
|
|
8347
8350
|
enterActive: styles$B['announcement-enter-active'],
|
|
8348
8351
|
exit: styles$B['announcement-exit'],
|
|
8349
8352
|
exitActive: styles$B['announcement-exit-active'],
|
|
8350
|
-
}, timeout: 300, children: jsx(ConnectedAnnouncement, { announcement:
|
|
8351
|
-
href,
|
|
8352
|
-
id,
|
|
8353
|
-
text,
|
|
8354
|
-
title,
|
|
8355
|
-
type,
|
|
8356
|
-
}, onDismiss: id => setDismissedIds(dismissedIds => [...dismissedIds, id]) }) }, id))) }));
|
|
8353
|
+
}, nodeRef: nodeRef, timeout: 300, children: jsx(ConnectedAnnouncement, { announcement: announcement, onDismiss: id => setDismissedIds(dismissedIds => [...dismissedIds, id]) }) }, announcement.id))) }));
|
|
8357
8354
|
}
|
|
8358
8355
|
|
|
8359
8356
|
var styles$A = {"page-container":"page-container-module-PYmbC","inner-page-container":"page-container-module-uD8GF"};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react';
|
|
2
2
|
import { Announcement } from './announcement';
|
|
3
|
+
import { AnnouncementProvider } from './announcement-provider';
|
|
3
4
|
declare const meta: {
|
|
4
5
|
component: typeof Announcement;
|
|
5
6
|
parameters: {
|
|
@@ -14,3 +15,4 @@ export declare const Promo: Story;
|
|
|
14
15
|
export declare const Informative: Story;
|
|
15
16
|
export declare const Notice: Story;
|
|
16
17
|
export declare const Critical: Story;
|
|
18
|
+
export declare const Connected: StoryObj<typeof AnnouncementProvider>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnnouncementProps } from './announcement';
|
|
2
2
|
type ConnectedAnnouncementProps = AnnouncementProps;
|
|
3
|
+
export declare const now: () => Date;
|
|
3
4
|
export declare function ConnectedAnnouncement({ announcement: { endDate, startDate, ...announcement }, onDismiss, }: ConnectedAnnouncementProps): import("react/jsx-runtime").JSX.Element | null;
|
|
4
5
|
export {};
|