@orderly.network/ui-orders 2.11.1-alpha.0 → 2.11.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.js +107 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -47,67 +47,10 @@ var init_orders_script = __esm({
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
function parseBadgesFor(record) {
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!!record.parent_algo_type) {
|
|
55
|
-
if (algoType === types.AlgoOrderType.STOP_LOSS) {
|
|
56
|
-
const types$1 = orderType === types.OrderType.CLOSE_POSITION ? [i18n.i18n.t("common.position"), i18n.i18n.t("tpsl.sl")] : [i18n.i18n.t("tpsl.sl")];
|
|
57
|
-
list.push(...types$1);
|
|
58
|
-
}
|
|
59
|
-
if (algoType === types.AlgoOrderType.TAKE_PROFIT) {
|
|
60
|
-
const types$1 = orderType === types.OrderType.CLOSE_POSITION ? [i18n.i18n.t("common.position"), i18n.i18n.t("tpsl.tp")] : [i18n.i18n.t("tpsl.tp")];
|
|
61
|
-
list.push(...types$1);
|
|
62
|
-
}
|
|
63
|
-
return list;
|
|
64
|
-
}
|
|
65
|
-
const type = typeof orderType === "string" ? orderType.replace("_ORDER", "") : "";
|
|
66
|
-
if ([types.OrderType.ASK, types.OrderType.BID].includes(orderType)) {
|
|
67
|
-
return [i18n.i18n.t("orderEntry.orderType.limit")];
|
|
68
|
-
}
|
|
69
|
-
if (record.algo_order_id === void 0 || record.algo_order_id && algoType === "BRACKET") {
|
|
70
|
-
const typeMap = {
|
|
71
|
-
[types.OrderType.LIMIT]: i18n.i18n.t("orderEntry.orderType.limit"),
|
|
72
|
-
[types.OrderType.MARKET]: i18n.i18n.t("orderEntry.orderType.market"),
|
|
73
|
-
[types.OrderType.POST_ONLY]: i18n.i18n.t("orderEntry.orderType.postOnly"),
|
|
74
|
-
[types.OrderType.IOC]: i18n.i18n.t("orderEntry.orderType.ioc"),
|
|
75
|
-
[types.OrderType.FOK]: i18n.i18n.t("orderEntry.orderType.fok")
|
|
76
|
-
};
|
|
77
|
-
return [
|
|
78
|
-
typeMap[type] || upperCaseFirstLetter(type)
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
if (algoType === types.AlgoOrderRootType.TRAILING_STOP) {
|
|
82
|
-
return [i18n.i18n.t("orderEntry.orderType.trailingStop")];
|
|
83
|
-
}
|
|
84
|
-
if (type) {
|
|
85
|
-
const typeMap = {
|
|
86
|
-
[types.OrderType.LIMIT]: i18n.i18n.t("orderEntry.orderType.stopLimit"),
|
|
87
|
-
[types.OrderType.MARKET]: i18n.i18n.t("orderEntry.orderType.stopMarket")
|
|
88
|
-
};
|
|
89
|
-
return [typeMap[type] || type];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (typeof algoType !== "undefined") {
|
|
93
|
-
const list = [];
|
|
94
|
-
if (algoType === types.AlgoOrderRootType.POSITIONAL_TP_SL) {
|
|
95
|
-
list.push(i18n.i18n.t("common.position"));
|
|
96
|
-
}
|
|
97
|
-
const tpOrder = record?.child_orders?.find(
|
|
98
|
-
(order) => order.algo_type === types.AlgoOrderType.TAKE_PROFIT && !!order.trigger_price
|
|
99
|
-
);
|
|
100
|
-
const slOrder = record?.child_orders?.find(
|
|
101
|
-
(order) => order.algo_type === types.AlgoOrderType.STOP_LOSS && !!order.trigger_price
|
|
102
|
-
);
|
|
103
|
-
if (tpOrder || slOrder) {
|
|
104
|
-
list.push(
|
|
105
|
-
tpOrder && slOrder ? i18n.i18n.t("common.tpsl") : tpOrder ? i18n.i18n.t("tpsl.tp") : i18n.i18n.t("tpsl.sl")
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
return list;
|
|
109
|
-
}
|
|
110
|
-
return void 0;
|
|
50
|
+
const orderTypeBadges = getOrderTypeBadges(record);
|
|
51
|
+
const marginModeBadges = getMarginModeBadges(record);
|
|
52
|
+
const badges = [...orderTypeBadges, ...marginModeBadges];
|
|
53
|
+
return badges.length ? badges : void 0;
|
|
111
54
|
}
|
|
112
55
|
function grayCell(record) {
|
|
113
56
|
return record.status === types.OrderStatus.CANCELLED || record.algo_status === types.OrderStatus.CANCELLED;
|
|
@@ -211,7 +154,7 @@ function convertApiOrderTypeToOrderEntryType(order) {
|
|
|
211
154
|
}
|
|
212
155
|
return order.type;
|
|
213
156
|
}
|
|
214
|
-
var upperCaseFirstLetter;
|
|
157
|
+
var upperCaseFirstLetter, normalizeMarginMode, getMarginModeBadges, getOrderTypeBadges;
|
|
215
158
|
var init_util = __esm({
|
|
216
159
|
"src/utils/util.ts"() {
|
|
217
160
|
upperCaseFirstLetter = (str) => {
|
|
@@ -220,6 +163,88 @@ var init_util = __esm({
|
|
|
220
163
|
if (str.length === 1) return str.charAt(0).toUpperCase();
|
|
221
164
|
return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1);
|
|
222
165
|
};
|
|
166
|
+
normalizeMarginMode = (value) => {
|
|
167
|
+
if (value === 1 || value === types.MarginMode.ISOLATED) {
|
|
168
|
+
return types.MarginMode.ISOLATED;
|
|
169
|
+
}
|
|
170
|
+
if (value === 0 || value === types.MarginMode.CROSS) {
|
|
171
|
+
return types.MarginMode.CROSS;
|
|
172
|
+
}
|
|
173
|
+
return void 0;
|
|
174
|
+
};
|
|
175
|
+
getMarginModeBadges = (record) => {
|
|
176
|
+
const marginMode = normalizeMarginMode(record?.margin_mode);
|
|
177
|
+
if (marginMode === types.MarginMode.ISOLATED) {
|
|
178
|
+
return [i18n.i18n.t("marginMode.isolated")];
|
|
179
|
+
}
|
|
180
|
+
if (marginMode === types.MarginMode.CROSS) {
|
|
181
|
+
return [i18n.i18n.t("marginMode.cross")];
|
|
182
|
+
}
|
|
183
|
+
return [];
|
|
184
|
+
};
|
|
185
|
+
getOrderTypeBadges = (record) => {
|
|
186
|
+
const orderType = record.type;
|
|
187
|
+
const algoType = record.algo_type;
|
|
188
|
+
if (typeof orderType !== "undefined") {
|
|
189
|
+
const list = [];
|
|
190
|
+
if (!!record.parent_algo_type) {
|
|
191
|
+
if (algoType === types.AlgoOrderType.STOP_LOSS) {
|
|
192
|
+
const types$1 = orderType === types.OrderType.CLOSE_POSITION ? [i18n.i18n.t("common.position"), i18n.i18n.t("tpsl.sl")] : [i18n.i18n.t("tpsl.sl")];
|
|
193
|
+
list.push(...types$1);
|
|
194
|
+
}
|
|
195
|
+
if (algoType === types.AlgoOrderType.TAKE_PROFIT) {
|
|
196
|
+
const types$1 = orderType === types.OrderType.CLOSE_POSITION ? [i18n.i18n.t("common.position"), i18n.i18n.t("tpsl.tp")] : [i18n.i18n.t("tpsl.tp")];
|
|
197
|
+
list.push(...types$1);
|
|
198
|
+
}
|
|
199
|
+
return list;
|
|
200
|
+
}
|
|
201
|
+
const type = typeof orderType === "string" ? orderType.replace("_ORDER", "") : "";
|
|
202
|
+
if ([types.OrderType.ASK, types.OrderType.BID].includes(orderType)) {
|
|
203
|
+
return [i18n.i18n.t("orderEntry.orderType.limit")];
|
|
204
|
+
}
|
|
205
|
+
if (record.algo_order_id === void 0 || record.algo_order_id && algoType === "BRACKET") {
|
|
206
|
+
const typeMap = {
|
|
207
|
+
[types.OrderType.LIMIT]: i18n.i18n.t("orderEntry.orderType.limit"),
|
|
208
|
+
[types.OrderType.MARKET]: i18n.i18n.t("orderEntry.orderType.market"),
|
|
209
|
+
[types.OrderType.POST_ONLY]: i18n.i18n.t("orderEntry.orderType.postOnly"),
|
|
210
|
+
[types.OrderType.IOC]: i18n.i18n.t("orderEntry.orderType.ioc"),
|
|
211
|
+
[types.OrderType.FOK]: i18n.i18n.t("orderEntry.orderType.fok")
|
|
212
|
+
};
|
|
213
|
+
return [
|
|
214
|
+
typeMap[type] || upperCaseFirstLetter(type)
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
if (algoType === types.AlgoOrderRootType.TRAILING_STOP) {
|
|
218
|
+
return [i18n.i18n.t("orderEntry.orderType.trailingStop")];
|
|
219
|
+
}
|
|
220
|
+
if (type) {
|
|
221
|
+
const typeMap = {
|
|
222
|
+
[types.OrderType.LIMIT]: i18n.i18n.t("orderEntry.orderType.stopLimit"),
|
|
223
|
+
[types.OrderType.MARKET]: i18n.i18n.t("orderEntry.orderType.stopMarket")
|
|
224
|
+
};
|
|
225
|
+
return [typeMap[type] || type];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (typeof algoType !== "undefined") {
|
|
229
|
+
const list = [];
|
|
230
|
+
if (algoType === types.AlgoOrderRootType.POSITIONAL_TP_SL) {
|
|
231
|
+
list.push(i18n.i18n.t("common.position"));
|
|
232
|
+
}
|
|
233
|
+
const tpOrder = record?.child_orders?.find(
|
|
234
|
+
(order) => order.algo_type === types.AlgoOrderType.TAKE_PROFIT && !!order.trigger_price
|
|
235
|
+
);
|
|
236
|
+
const slOrder = record?.child_orders?.find(
|
|
237
|
+
(order) => order.algo_type === types.AlgoOrderType.STOP_LOSS && !!order.trigger_price
|
|
238
|
+
);
|
|
239
|
+
if (tpOrder || slOrder) {
|
|
240
|
+
list.push(
|
|
241
|
+
tpOrder && slOrder ? i18n.i18n.t("common.tpsl") : tpOrder ? i18n.i18n.t("tpsl.tp") : i18n.i18n.t("tpsl.sl")
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
return list;
|
|
245
|
+
}
|
|
246
|
+
return [];
|
|
247
|
+
};
|
|
223
248
|
}
|
|
224
249
|
});
|
|
225
250
|
var SymbolContext, useSymbolContext;
|
|
@@ -1149,10 +1174,10 @@ var init_tpslOrderRowContext = __esm({
|
|
|
1149
1174
|
}
|
|
1150
1175
|
);
|
|
1151
1176
|
const getRelatedPosition = hooks.useMemoizedFn(
|
|
1152
|
-
(symbol) => {
|
|
1177
|
+
(symbol, marginMode) => {
|
|
1153
1178
|
const positions = config.cache.get(positionKey);
|
|
1154
1179
|
return positions?.data?.rows?.find(
|
|
1155
|
-
(p) => p.symbol === symbol
|
|
1180
|
+
(p) => p.symbol === symbol && (p.margin_mode ?? types.MarginMode.CROSS) === (marginMode ?? types.MarginMode.CROSS)
|
|
1156
1181
|
);
|
|
1157
1182
|
}
|
|
1158
1183
|
);
|
|
@@ -1170,12 +1195,12 @@ var init_tpslOrderRowContext = __esm({
|
|
|
1170
1195
|
});
|
|
1171
1196
|
React2.useEffect(() => {
|
|
1172
1197
|
if ("algo_type" in order || (order?.reduce_only ?? false)) {
|
|
1173
|
-
const position2 = getRelatedPosition(order.symbol);
|
|
1198
|
+
const position2 = getRelatedPosition(order.symbol, order.margin_mode);
|
|
1174
1199
|
if (position2) {
|
|
1175
1200
|
setPosition(position2);
|
|
1176
1201
|
}
|
|
1177
1202
|
}
|
|
1178
|
-
}, [order.symbol]);
|
|
1203
|
+
}, [getRelatedPosition, order.margin_mode, order.symbol]);
|
|
1179
1204
|
const memoizedValue = React2.useMemo(() => {
|
|
1180
1205
|
return {
|
|
1181
1206
|
order,
|
|
@@ -2361,7 +2386,7 @@ function instrument(option) {
|
|
|
2361
2386
|
},
|
|
2362
2387
|
render: (value, record) => {
|
|
2363
2388
|
const showGray = grayCell(record);
|
|
2364
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
2389
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, className: "oui-py-1", children: [
|
|
2365
2390
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2366
2391
|
"div",
|
|
2367
2392
|
{
|
|
@@ -2371,7 +2396,7 @@ function instrument(option) {
|
|
|
2371
2396
|
)
|
|
2372
2397
|
}
|
|
2373
2398
|
),
|
|
2374
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", children: [
|
|
2399
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", itemAlign: "start", gap: 1, children: [
|
|
2375
2400
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2376
2401
|
ui.Text.formatted,
|
|
2377
2402
|
{
|
|
@@ -2385,7 +2410,7 @@ function instrument(option) {
|
|
|
2385
2410
|
children: `${value.split("_")[1]}-PERP`
|
|
2386
2411
|
}
|
|
2387
2412
|
),
|
|
2388
|
-
option?.showType && /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "row", gap: 1, children: parseBadgesFor(record)?.map((e, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2413
|
+
option?.showType && /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "row", gap: 1, wrap: "wrap", children: parseBadgesFor(record)?.map((e, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2389
2414
|
ui.Badge,
|
|
2390
2415
|
{
|
|
2391
2416
|
color: e.toLocaleLowerCase() === "position" ? showGray ? "neutral" : "primary" : "neutral",
|
|
@@ -2931,7 +2956,7 @@ var init_useColumn = __esm({
|
|
|
2931
2956
|
case "all" /* all */:
|
|
2932
2957
|
return [
|
|
2933
2958
|
instrument({
|
|
2934
|
-
width:
|
|
2959
|
+
width: 174,
|
|
2935
2960
|
showType: true,
|
|
2936
2961
|
onSymbolChange,
|
|
2937
2962
|
enableSort: false
|
|
@@ -3011,7 +3036,7 @@ var init_useColumn = __esm({
|
|
|
3011
3036
|
return [
|
|
3012
3037
|
instrument({
|
|
3013
3038
|
showType: true,
|
|
3014
|
-
width:
|
|
3039
|
+
width: 166,
|
|
3015
3040
|
onSymbolChange
|
|
3016
3041
|
}),
|
|
3017
3042
|
// type({ width: 124 }),
|
|
@@ -3093,7 +3118,7 @@ var init_useColumn = __esm({
|
|
|
3093
3118
|
return [
|
|
3094
3119
|
instrument({
|
|
3095
3120
|
showType: true,
|
|
3096
|
-
width:
|
|
3121
|
+
width: 160,
|
|
3097
3122
|
onSymbolChange
|
|
3098
3123
|
}),
|
|
3099
3124
|
// side({ width: 124 }),
|
|
@@ -5397,15 +5422,21 @@ var init_useFormatOrderHistory = __esm({
|
|
|
5397
5422
|
if (!e.is_activated || !e.trigger_price) {
|
|
5398
5423
|
continue;
|
|
5399
5424
|
}
|
|
5400
|
-
|
|
5401
|
-
|
|
5425
|
+
_data.push({
|
|
5426
|
+
...e,
|
|
5427
|
+
parent_algo_type: element.algo_type,
|
|
5428
|
+
margin_mode: e.margin_mode ?? element.margin_mode
|
|
5429
|
+
});
|
|
5402
5430
|
}
|
|
5403
5431
|
} else {
|
|
5404
5432
|
for (let j = 0; j < element.child_orders.length; j++) {
|
|
5405
5433
|
const e = element.child_orders[j];
|
|
5406
5434
|
if (!!e && (e.algo_status === types.OrderStatus.FILLED || e.algo_status === types.OrderStatus.PARTIAL_FILLED)) {
|
|
5407
|
-
|
|
5408
|
-
|
|
5435
|
+
_data.push({
|
|
5436
|
+
...e,
|
|
5437
|
+
parent_algo_type: element.algo_type,
|
|
5438
|
+
margin_mode: e.margin_mode ?? element.margin_mode
|
|
5439
|
+
});
|
|
5409
5440
|
}
|
|
5410
5441
|
}
|
|
5411
5442
|
}
|