@orderly.network/hooks 3.0.1 → 3.0.2-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
@@ -170,7 +170,7 @@ declare global {
170
170
  };
171
171
  }
172
172
  }
173
- declare const _default: "3.0.1";
173
+ declare const _default: "3.0.2-alpha.0";
174
174
 
175
175
  declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
176
176
  type useQueryOptions<T> = SWRConfiguration & {
package/dist/index.d.ts CHANGED
@@ -170,7 +170,7 @@ declare global {
170
170
  };
171
171
  }
172
172
  }
173
- declare const _default: "3.0.1";
173
+ declare const _default: "3.0.2-alpha.0";
174
174
 
175
175
  declare const fetcher: (url: string, init: RequestInit | undefined, queryOptions: useQueryOptions<any>) => Promise<any>;
176
176
  type useQueryOptions<T> = SWRConfiguration & {
package/dist/index.js CHANGED
@@ -76,9 +76,9 @@ function useMarketCategoriesConfig() {
76
76
  // src/version.ts
77
77
  if (typeof window !== "undefined") {
78
78
  window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
79
- window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "3.0.1";
79
+ window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "3.0.2-alpha.0";
80
80
  }
81
- var version_default = "3.0.1";
81
+ var version_default = "3.0.2-alpha.0";
82
82
  var fetcher = (url, init2 = {}, queryOptions) => net.get(url, init2, queryOptions?.formatter);
83
83
  var noCacheConfig = {
84
84
  dedupingInterval: 0,
@@ -18671,12 +18671,21 @@ var initialOrderState = {
18671
18671
  order_type: types.OrderType.LIMIT,
18672
18672
  margin_mode: types.MarginMode.CROSS
18673
18673
  };
18674
+ var normalizeInitialOrder = (order) => {
18675
+ if (!order) {
18676
+ return void 0;
18677
+ }
18678
+ const rest = { ...order };
18679
+ delete rest.symbol;
18680
+ return rest;
18681
+ };
18674
18682
  var useOrderEntryNextInternal = (symbol, options = {}) => {
18675
18683
  const { symbolInfo, symbolLeverage } = options;
18684
+ const initialOrder = normalizeInitialOrder(options.initialOrder);
18676
18685
  const [orderEntity, setOrderEntity] = React.useState(
18677
18686
  () => ({
18678
18687
  ...initialOrderState,
18679
- ...options.initialOrder,
18688
+ ...initialOrder,
18680
18689
  symbol
18681
18690
  })
18682
18691
  );
@@ -18692,10 +18701,14 @@ var useOrderEntryNextInternal = (symbol, options = {}) => {
18692
18701
  });
18693
18702
  },
18694
18703
  updateOrder: (order) => {
18695
- setOrderEntity((prev) => ({ ...prev, ...order }));
18704
+ setOrderEntity((prev) => ({ ...prev, ...order, symbol }));
18696
18705
  },
18697
18706
  updateOrderByKey: (key, value) => {
18698
- setOrderEntity((prev) => ({ ...prev, [key]: value }));
18707
+ setOrderEntity((prev) => ({
18708
+ ...prev,
18709
+ [key]: key === "symbol" ? symbol : value,
18710
+ symbol
18711
+ }));
18699
18712
  },
18700
18713
  resetOrder: (_order) => {
18701
18714
  setOrderEntity((prev) => ({
@@ -18723,12 +18736,15 @@ var useOrderEntryNextInternal = (symbol, options = {}) => {
18723
18736
  return typeof order.tp_trigger_price !== "undefined" || typeof order.sl_trigger_price !== "undefined";
18724
18737
  }
18725
18738
  }),
18726
- [orderEntity]
18739
+ [orderEntity, symbol]
18727
18740
  );
18728
18741
  React.useEffect(() => {
18729
- actions.initOrder(symbol, options.initialOrder);
18730
- if (options.initialOrder) {
18731
- actions.updateOrder(options.initialOrder);
18742
+ actions.initOrder(symbol, initialOrder);
18743
+ if (initialOrder) {
18744
+ actions.updateOrder({
18745
+ ...initialOrder,
18746
+ symbol
18747
+ });
18732
18748
  }
18733
18749
  }, [symbol]);
18734
18750
  const calculate2 = React.useCallback(
@@ -18968,7 +18984,7 @@ var useOrderEntryNextInternal = (symbol, options = {}) => {
18968
18984
  }
18969
18985
  actions.updateOrder(newValues);
18970
18986
  },
18971
- [calculate2, options.symbolInfo, symbolLeverage, orderEntity]
18987
+ [actions, calculate2, options.symbolInfo, symbolLeverage, orderEntity]
18972
18988
  );
18973
18989
  const validate = (order, creator, options2) => {
18974
18990
  return creator?.validate(order, {
@@ -18977,10 +18993,16 @@ var useOrderEntryNextInternal = (symbol, options = {}) => {
18977
18993
  });
18978
18994
  };
18979
18995
  const generateOrder = (creator, options2) => {
18980
- const order = creator.create(orderEntity, {
18981
- ...options2,
18982
- symbol: symbolInfo
18983
- });
18996
+ const order = creator.create(
18997
+ {
18998
+ ...orderEntity,
18999
+ symbol
19000
+ },
19001
+ {
19002
+ ...options2,
19003
+ symbol: symbolInfo
19004
+ }
19005
+ );
18984
19006
  return order;
18985
19007
  };
18986
19008
  const submitOrder = React.useCallback(() => {