@kodiak-finance/orderly-ui-scaffold 2.8.19 → 2.8.21-alpha.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.
- package/dist/index.js +40 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -74
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -7,10 +7,10 @@ import { useAppContext, useAppConfig } from '@kodiak-finance/orderly-react-app';
|
|
|
7
7
|
import { AccountStatusEnum, ABSTRACT_CHAIN_ID_MAP, EMPTY_LIST, TrackerEventName, EMPTY_OBJECT } from '@kodiak-finance/orderly-types';
|
|
8
8
|
import { ChainSelectorSheetId, ChainSelectorDialogId, ChainSelectorWidget } from '@kodiak-finance/orderly-ui-chain-selector';
|
|
9
9
|
import { WalletConnectorSheetId, WalletConnectorModalId } from '@kodiak-finance/orderly-ui-connector';
|
|
10
|
-
import { Decimal, getTimestamp
|
|
10
|
+
import { Decimal, getTimestamp } from '@kodiak-finance/orderly-utils';
|
|
11
11
|
import jsQR from 'jsqr';
|
|
12
12
|
import { qrcode } from '@akamfoad/qr';
|
|
13
|
-
import { useAnnouncement,
|
|
13
|
+
import { useAnnouncement, AnnouncementBannerUI, AnnouncementCenterUI } from '@kodiak-finance/orderly-ui-notification';
|
|
14
14
|
import { format } from 'date-fns';
|
|
15
15
|
import { UTCDateMini } from '@date-fns/utc';
|
|
16
16
|
|
|
@@ -3637,8 +3637,21 @@ var ScaffoldContext = createContext(
|
|
|
3637
3637
|
var useScaffoldContext = () => {
|
|
3638
3638
|
return useContext(ScaffoldContext);
|
|
3639
3639
|
};
|
|
3640
|
+
|
|
3641
|
+
// src/utils/link.ts
|
|
3642
|
+
var isExternalUrl = (href) => {
|
|
3643
|
+
try {
|
|
3644
|
+
const origin = typeof window !== "undefined" && window.location?.origin ? window.location.origin : void 0;
|
|
3645
|
+
const target = new URL(href, origin ?? "http://localhost");
|
|
3646
|
+
if (!origin)
|
|
3647
|
+
return false;
|
|
3648
|
+
return target.origin !== origin;
|
|
3649
|
+
} catch {
|
|
3650
|
+
return false;
|
|
3651
|
+
}
|
|
3652
|
+
};
|
|
3640
3653
|
var NotificationUI = (props) => {
|
|
3641
|
-
const { dataSource, showAnnouncement } = props;
|
|
3654
|
+
const { dataSource, showAnnouncement, className } = props;
|
|
3642
3655
|
const { routerAdapter } = useScaffoldContext();
|
|
3643
3656
|
const onItemClick = (url) => {
|
|
3644
3657
|
if (!url)
|
|
@@ -3646,77 +3659,30 @@ var NotificationUI = (props) => {
|
|
|
3646
3659
|
routerAdapter?.onRouteChange({
|
|
3647
3660
|
href: url,
|
|
3648
3661
|
name: url,
|
|
3649
|
-
target: "_blank"
|
|
3662
|
+
target: isExternalUrl(url) ? "_blank" : void 0
|
|
3650
3663
|
});
|
|
3651
3664
|
};
|
|
3652
|
-
const notificationRef = useRef(null);
|
|
3653
3665
|
const len = useMemo(() => dataSource?.length ?? 0, [dataSource]);
|
|
3654
|
-
const onClose = useCallback(() => {
|
|
3655
|
-
if (len === 0) {
|
|
3656
|
-
return;
|
|
3657
|
-
}
|
|
3658
|
-
windowGuard(() => {
|
|
3659
|
-
if (notificationRef.current) {
|
|
3660
|
-
const animationendHandler = () => {
|
|
3661
|
-
props.onClose();
|
|
3662
|
-
notificationRef.current.removeEventListener(
|
|
3663
|
-
"transitionend",
|
|
3664
|
-
animationendHandler
|
|
3665
|
-
);
|
|
3666
|
-
};
|
|
3667
|
-
notificationRef.current.addEventListener(
|
|
3668
|
-
"transitionend",
|
|
3669
|
-
animationendHandler
|
|
3670
|
-
);
|
|
3671
|
-
requestAnimationFrame(() => {
|
|
3672
|
-
notificationRef.current.style.transform = "translateY(120%)";
|
|
3673
|
-
});
|
|
3674
|
-
}
|
|
3675
|
-
});
|
|
3676
|
-
}, [props.onClose, len]);
|
|
3677
|
-
useEffect(() => {
|
|
3678
|
-
if (len === 0) {
|
|
3679
|
-
return;
|
|
3680
|
-
}
|
|
3681
|
-
if (showAnnouncement) {
|
|
3682
|
-
windowGuard(() => {
|
|
3683
|
-
if (notificationRef.current) {
|
|
3684
|
-
requestAnimationFrame(() => {
|
|
3685
|
-
notificationRef.current.style.transform = "translateY(0)";
|
|
3686
|
-
});
|
|
3687
|
-
}
|
|
3688
|
-
});
|
|
3689
|
-
}
|
|
3690
|
-
}, [showAnnouncement, len]);
|
|
3691
3666
|
if (len === 0) {
|
|
3692
3667
|
return null;
|
|
3693
3668
|
}
|
|
3694
3669
|
return /* @__PURE__ */ jsx(
|
|
3695
|
-
|
|
3670
|
+
AnnouncementBannerUI,
|
|
3696
3671
|
{
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
showAnnouncement ? "oui-visible" : "oui-invisible"
|
|
3703
|
-
),
|
|
3704
|
-
children: /* @__PURE__ */ jsx(
|
|
3705
|
-
NotificationUI$1,
|
|
3706
|
-
{
|
|
3707
|
-
dataSource,
|
|
3708
|
-
onClose,
|
|
3709
|
-
onItemClick
|
|
3710
|
-
}
|
|
3711
|
-
)
|
|
3672
|
+
dataSource,
|
|
3673
|
+
showAnnouncement,
|
|
3674
|
+
onClose: props.onClose,
|
|
3675
|
+
onItemClick,
|
|
3676
|
+
className: cn("oui-mx-auto", className)
|
|
3712
3677
|
}
|
|
3713
3678
|
);
|
|
3714
3679
|
};
|
|
3715
|
-
var NotificationWidget = () => {
|
|
3680
|
+
var NotificationWidget = ({ className }) => {
|
|
3716
3681
|
const { announcementState } = useScaffoldContext();
|
|
3717
3682
|
return /* @__PURE__ */ jsx(
|
|
3718
3683
|
NotificationUI,
|
|
3719
3684
|
{
|
|
3685
|
+
className,
|
|
3720
3686
|
dataSource: announcementState.tips,
|
|
3721
3687
|
onClose: announcementState.closeTips,
|
|
3722
3688
|
showAnnouncement: announcementState.showAnnouncement
|
|
@@ -3757,6 +3723,7 @@ var MobileScaffold = (props) => {
|
|
|
3757
3723
|
classNames?.root
|
|
3758
3724
|
),
|
|
3759
3725
|
children: [
|
|
3726
|
+
/* @__PURE__ */ jsx("div", { className: "oui-mx-1 oui-mb-1", children: /* @__PURE__ */ jsx(NotificationWidget, {}) }),
|
|
3760
3727
|
/* @__PURE__ */ jsx(
|
|
3761
3728
|
"header",
|
|
3762
3729
|
{
|
|
@@ -3813,8 +3780,7 @@ var MobileScaffold = (props) => {
|
|
|
3813
3780
|
}
|
|
3814
3781
|
) })
|
|
3815
3782
|
}
|
|
3816
|
-
)
|
|
3817
|
-
/* @__PURE__ */ jsx(NotificationWidget, {})
|
|
3783
|
+
)
|
|
3818
3784
|
]
|
|
3819
3785
|
}
|
|
3820
3786
|
);
|
|
@@ -4281,18 +4247,20 @@ var DesktopScaffold = (props) => {
|
|
|
4281
4247
|
classNames?.container
|
|
4282
4248
|
),
|
|
4283
4249
|
children: [
|
|
4284
|
-
/* @__PURE__ */
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4250
|
+
/* @__PURE__ */ jsxs(Box, { px: 2, ref: announcementRef, className: "oui-space-y-2", children: [
|
|
4251
|
+
/* @__PURE__ */ jsx(
|
|
4252
|
+
RestrictedInfoWidget,
|
|
4253
|
+
{
|
|
4254
|
+
className: cn(
|
|
4255
|
+
"oui-scaffold-restricted-info",
|
|
4256
|
+
"oui-relative oui-z-[1]",
|
|
4257
|
+
"oui-bg-base-9",
|
|
4258
|
+
"oui-min-w-[994px]"
|
|
4259
|
+
)
|
|
4260
|
+
}
|
|
4261
|
+
),
|
|
4262
|
+
/* @__PURE__ */ jsx(NotificationWidget, { className: "oui-mx-auto" })
|
|
4263
|
+
] }),
|
|
4296
4264
|
!hasLeftSidebar ? (
|
|
4297
4265
|
// ----------No leftSidebar layout start ---------
|
|
4298
4266
|
/* @__PURE__ */ jsx(Box, { height: "100%", className: cn(classNames?.content), children })
|
|
@@ -5133,7 +5101,7 @@ var MessageCenter = (props) => {
|
|
|
5133
5101
|
routerAdapter?.onRouteChange({
|
|
5134
5102
|
href: url,
|
|
5135
5103
|
name: url,
|
|
5136
|
-
target: "_blank"
|
|
5104
|
+
target: isExternalUrl(url) ? "_blank" : void 0
|
|
5137
5105
|
});
|
|
5138
5106
|
};
|
|
5139
5107
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|