@orderly.network/react-app 2.12.4-alpha.0 → 3.0.0-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.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import react, { ReactNode, ComponentType, PropsWithChildren, Component, ErrorInfo } from 'react';
2
- import { ExtensionPosition, OrderlyThemeProviderProps } from '@orderly.network/ui';
2
+ import { OrderlyPlugin, PluginRegistrationFn, ExtensionPosition, OrderlyThemeProviderProps } from '@orderly.network/ui';
3
3
  import { ConfigProviderProps, ExclusiveConfigProviderProps, Chains, WalletState, RestrictedInfoReturns, MarketCategoryConfig, RestrictedInfoOptions, OrderValidationResult } from '@orderly.network/hooks';
4
4
  import { Chain, NetworkId, AccountStatusEnum } from '@orderly.network/types';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -16,6 +16,8 @@ type AppLogos = Partial<{
16
16
  type OrderlyAppConfig = {
17
17
  appIcons?: AppLogos;
18
18
  dateFormatting?: string;
19
+ /** Plugins for the new interceptor system (registerPlugin descriptors or registration fns) */
20
+ plugins?: (OrderlyPlugin | PluginRegistrationFn)[];
19
21
  components?: {
20
22
  [position in ExtensionPosition]: ComponentType;
21
23
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import react, { ReactNode, ComponentType, PropsWithChildren, Component, ErrorInfo } from 'react';
2
- import { ExtensionPosition, OrderlyThemeProviderProps } from '@orderly.network/ui';
2
+ import { OrderlyPlugin, PluginRegistrationFn, ExtensionPosition, OrderlyThemeProviderProps } from '@orderly.network/ui';
3
3
  import { ConfigProviderProps, ExclusiveConfigProviderProps, Chains, WalletState, RestrictedInfoReturns, MarketCategoryConfig, RestrictedInfoOptions, OrderValidationResult } from '@orderly.network/hooks';
4
4
  import { Chain, NetworkId, AccountStatusEnum } from '@orderly.network/types';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -16,6 +16,8 @@ type AppLogos = Partial<{
16
16
  type OrderlyAppConfig = {
17
17
  appIcons?: AppLogos;
18
18
  dateFormatting?: string;
19
+ /** Plugins for the new interceptor system (registerPlugin descriptors or registration fns) */
20
+ plugins?: (OrderlyPlugin | PluginRegistrationFn)[];
19
21
  components?: {
20
22
  [position in ExtensionPosition]: ComponentType;
21
23
  };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var react = require('react');
3
4
  var hooks = require('@orderly.network/hooks');
4
5
  var ui = require('@orderly.network/ui');
5
- var react = require('react');
6
6
  var types = require('@orderly.network/types');
7
7
  var i18n = require('@orderly.network/i18n');
8
8
  var utils = require('@orderly.network/utils');
@@ -700,38 +700,7 @@ var AppStateProvider = (props) => {
700
700
  );
701
701
  return /* @__PURE__ */ jsxRuntime.jsx(AppStateContext.Provider, { value: memoizedValue, children: /* @__PURE__ */ jsxRuntime.jsx(hooks.MarketCategoriesConfigProvider, { value: props.widgetConfigs?.marketTabs, children: props.children }) });
702
702
  };
703
- var ORDERLY_THEME_STORAGE_KEY = "orderly_theme_id";
704
- var AppThemeProvider = (props) => {
705
- const { children, themes, ...rest } = props;
706
- const [currentThemeId, setCurrentThemeId] = hooks.useLocalStorage(ORDERLY_THEME_STORAGE_KEY, themes?.[0]?.id);
707
- const currentTheme = react.useMemo(() => {
708
- return themes?.find((theme) => theme.id === currentThemeId);
709
- }, [themes, currentThemeId]);
710
- react.useEffect(() => {
711
- if (typeof document === "undefined") return;
712
- const root = document.documentElement;
713
- if (!currentThemeId) {
714
- root.removeAttribute("data-oui-theme");
715
- return;
716
- }
717
- root.setAttribute("data-oui-theme", currentThemeId);
718
- Object.entries(ui.DARK_THEME_CSS_VARS).forEach(([key, value]) => {
719
- const newValue = currentTheme?.cssVars?.[key] || value;
720
- root.style.setProperty(key, newValue);
721
- });
722
- }, [currentThemeId, currentTheme]);
723
- return /* @__PURE__ */ jsxRuntime.jsx(
724
- ui.OrderlyThemeProvider,
725
- {
726
- themes,
727
- currentThemeId,
728
- currentTheme,
729
- setCurrentThemeId,
730
- ...rest,
731
- children
732
- }
733
- );
734
- };
703
+ var EMPTY_PLUGINS = [];
735
704
  var ExecutionReportListener = () => {
736
705
  useExecutionReport();
737
706
  return null;
@@ -741,7 +710,7 @@ var OrderlyAppProvider = (props) => {
741
710
  // dateFormatting,
742
711
  components,
743
712
  appIcons,
744
- themes,
713
+ plugins,
745
714
  onChainChanged,
746
715
  defaultChain,
747
716
  widgetConfigs,
@@ -750,23 +719,39 @@ var OrderlyAppProvider = (props) => {
750
719
  hooks.useTrack();
751
720
  useBootstrap();
752
721
  const uiLocale = useUILocale();
722
+ const pluginState = react.useMemo(
723
+ () => ({
724
+ config: { appIcons, brokerName: props.brokerName },
725
+ networkId: configProps.networkId
726
+ }),
727
+ [appIcons, props.brokerName, configProps.networkId]
728
+ );
729
+ const pluginsList = plugins ?? EMPTY_PLUGINS;
753
730
  return /* @__PURE__ */ jsxRuntime.jsx(AppConfigProvider, { appIcons, brokerName: props.brokerName, children: /* @__PURE__ */ jsxRuntime.jsx(
754
- AppThemeProvider,
731
+ ui.OrderlyThemeProvider,
755
732
  {
756
733
  components,
757
734
  overrides: props.overrides,
758
- themes,
759
735
  children: /* @__PURE__ */ jsxRuntime.jsxs(hooks.OrderlyConfigProvider, { ...configProps, children: [
760
- /* @__PURE__ */ jsxRuntime.jsx(ExecutionReportListener, {}),
761
- /* @__PURE__ */ jsxRuntime.jsx(
762
- AppStateProvider,
736
+ /* @__PURE__ */ jsxRuntime.jsxs(
737
+ ui.OrderlyPluginProvider,
763
738
  {
764
- onChainChanged,
765
- defaultChain,
766
- restrictedInfo: props.restrictedInfo,
767
- onRouteChange: props.onRouteChange,
768
- widgetConfigs,
769
- children: /* @__PURE__ */ jsxRuntime.jsx(ui.LocaleProvider, { locale: uiLocale, children: /* @__PURE__ */ jsxRuntime.jsx(ui.TooltipProvider, { delayDuration: 300, children: /* @__PURE__ */ jsxRuntime.jsx(ui.ModalProvider, { children: props.children }) }) })
739
+ plugins: pluginsList,
740
+ pluginState,
741
+ children: [
742
+ /* @__PURE__ */ jsxRuntime.jsx(ExecutionReportListener, {}),
743
+ /* @__PURE__ */ jsxRuntime.jsx(
744
+ AppStateProvider,
745
+ {
746
+ onChainChanged,
747
+ defaultChain,
748
+ restrictedInfo: props.restrictedInfo,
749
+ onRouteChange: props.onRouteChange,
750
+ widgetConfigs,
751
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.LocaleProvider, { locale: uiLocale, children: /* @__PURE__ */ jsxRuntime.jsx(ui.TooltipProvider, { delayDuration: 300, children: /* @__PURE__ */ jsxRuntime.jsx(ui.ModalProvider, { children: props.children }) }) })
752
+ }
753
+ )
754
+ ]
770
755
  }
771
756
  ),
772
757
  /* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})