@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 CHANGED
@@ -3644,8 +3644,21 @@ var ScaffoldContext = React6.createContext(
3644
3644
  var useScaffoldContext = () => {
3645
3645
  return React6.useContext(ScaffoldContext);
3646
3646
  };
3647
+
3648
+ // src/utils/link.ts
3649
+ var isExternalUrl = (href) => {
3650
+ try {
3651
+ const origin = typeof window !== "undefined" && window.location?.origin ? window.location.origin : void 0;
3652
+ const target = new URL(href, origin ?? "http://localhost");
3653
+ if (!origin)
3654
+ return false;
3655
+ return target.origin !== origin;
3656
+ } catch {
3657
+ return false;
3658
+ }
3659
+ };
3647
3660
  var NotificationUI = (props) => {
3648
- const { dataSource, showAnnouncement } = props;
3661
+ const { dataSource, showAnnouncement, className } = props;
3649
3662
  const { routerAdapter } = useScaffoldContext();
3650
3663
  const onItemClick = (url) => {
3651
3664
  if (!url)
@@ -3653,77 +3666,30 @@ var NotificationUI = (props) => {
3653
3666
  routerAdapter?.onRouteChange({
3654
3667
  href: url,
3655
3668
  name: url,
3656
- target: "_blank"
3669
+ target: isExternalUrl(url) ? "_blank" : void 0
3657
3670
  });
3658
3671
  };
3659
- const notificationRef = React6.useRef(null);
3660
3672
  const len = React6.useMemo(() => dataSource?.length ?? 0, [dataSource]);
3661
- const onClose = React6.useCallback(() => {
3662
- if (len === 0) {
3663
- return;
3664
- }
3665
- orderlyUtils.windowGuard(() => {
3666
- if (notificationRef.current) {
3667
- const animationendHandler = () => {
3668
- props.onClose();
3669
- notificationRef.current.removeEventListener(
3670
- "transitionend",
3671
- animationendHandler
3672
- );
3673
- };
3674
- notificationRef.current.addEventListener(
3675
- "transitionend",
3676
- animationendHandler
3677
- );
3678
- requestAnimationFrame(() => {
3679
- notificationRef.current.style.transform = "translateY(120%)";
3680
- });
3681
- }
3682
- });
3683
- }, [props.onClose, len]);
3684
- React6.useEffect(() => {
3685
- if (len === 0) {
3686
- return;
3687
- }
3688
- if (showAnnouncement) {
3689
- orderlyUtils.windowGuard(() => {
3690
- if (notificationRef.current) {
3691
- requestAnimationFrame(() => {
3692
- notificationRef.current.style.transform = "translateY(0)";
3693
- });
3694
- }
3695
- });
3696
- }
3697
- }, [showAnnouncement, len]);
3698
3673
  if (len === 0) {
3699
3674
  return null;
3700
3675
  }
3701
3676
  return /* @__PURE__ */ jsxRuntime.jsx(
3702
- "div",
3677
+ orderlyUiNotification.AnnouncementBannerUI,
3703
3678
  {
3704
- ref: notificationRef,
3705
- "data-state": showAnnouncement ? "open" : "closed",
3706
- className: orderlyUi.cn(
3707
- "oui-fixed oui-bottom-[calc(env(safe-area-inset-bottom)+8px)] oui-left-2 oui-z-50 oui-w-[calc(100%_-_16px)] oui-translate-y-[120%] oui-rounded-lg oui-border oui-border-line-6 oui-bg-base-8 md:oui-bottom-10 md:oui-left-auto md:oui-right-3 md:oui-w-[420px]",
3708
- "oui-transition-all oui-duration-300 oui-ease-in-out",
3709
- showAnnouncement ? "oui-visible" : "oui-invisible"
3710
- ),
3711
- children: /* @__PURE__ */ jsxRuntime.jsx(
3712
- orderlyUiNotification.NotificationUI,
3713
- {
3714
- dataSource,
3715
- onClose,
3716
- onItemClick
3717
- }
3718
- )
3679
+ dataSource,
3680
+ showAnnouncement,
3681
+ onClose: props.onClose,
3682
+ onItemClick,
3683
+ className: orderlyUi.cn("oui-mx-auto", className)
3719
3684
  }
3720
3685
  );
3721
3686
  };
3722
- var NotificationWidget = () => {
3687
+ var NotificationWidget = ({ className }) => {
3723
3688
  const { announcementState } = useScaffoldContext();
3724
3689
  return /* @__PURE__ */ jsxRuntime.jsx(
3725
3690
  NotificationUI,
3726
3691
  {
3692
+ className,
3727
3693
  dataSource: announcementState.tips,
3728
3694
  onClose: announcementState.closeTips,
3729
3695
  showAnnouncement: announcementState.showAnnouncement
@@ -3764,6 +3730,7 @@ var MobileScaffold = (props) => {
3764
3730
  classNames?.root
3765
3731
  ),
3766
3732
  children: [
3733
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-mx-1 oui-mb-1", children: /* @__PURE__ */ jsxRuntime.jsx(NotificationWidget, {}) }),
3767
3734
  /* @__PURE__ */ jsxRuntime.jsx(
3768
3735
  "header",
3769
3736
  {
@@ -3820,8 +3787,7 @@ var MobileScaffold = (props) => {
3820
3787
  }
3821
3788
  ) })
3822
3789
  }
3823
- ),
3824
- /* @__PURE__ */ jsxRuntime.jsx(NotificationWidget, {})
3790
+ )
3825
3791
  ]
3826
3792
  }
3827
3793
  );
@@ -4288,18 +4254,20 @@ var DesktopScaffold = (props) => {
4288
4254
  classNames?.container
4289
4255
  ),
4290
4256
  children: [
4291
- /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { px: 2, ref: announcementRef, children: /* @__PURE__ */ jsxRuntime.jsx(
4292
- exports.RestrictedInfoWidget,
4293
- {
4294
- className: orderlyUi.cn(
4295
- "oui-scaffold-restricted-info",
4296
- "oui-relative oui-z-[1]",
4297
- "oui-mt-2",
4298
- "oui-bg-base-9",
4299
- "oui-min-w-[994px]"
4300
- )
4301
- }
4302
- ) }),
4257
+ /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Box, { px: 2, ref: announcementRef, className: "oui-space-y-2", children: [
4258
+ /* @__PURE__ */ jsxRuntime.jsx(
4259
+ exports.RestrictedInfoWidget,
4260
+ {
4261
+ className: orderlyUi.cn(
4262
+ "oui-scaffold-restricted-info",
4263
+ "oui-relative oui-z-[1]",
4264
+ "oui-bg-base-9",
4265
+ "oui-min-w-[994px]"
4266
+ )
4267
+ }
4268
+ ),
4269
+ /* @__PURE__ */ jsxRuntime.jsx(NotificationWidget, { className: "oui-mx-auto" })
4270
+ ] }),
4303
4271
  !hasLeftSidebar ? (
4304
4272
  // ----------No leftSidebar layout start ---------
4305
4273
  /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Box, { height: "100%", className: orderlyUi.cn(classNames?.content), children })
@@ -5140,7 +5108,7 @@ var MessageCenter = (props) => {
5140
5108
  routerAdapter?.onRouteChange({
5141
5109
  href: url,
5142
5110
  name: url,
5143
- target: "_blank"
5111
+ target: isExternalUrl(url) ? "_blank" : void 0
5144
5112
  });
5145
5113
  };
5146
5114
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [