@orderly.network/ui-order-entry 2.12.1-alpha.0 → 2.12.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 +19 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
package/dist/index.mjs
CHANGED
|
@@ -4758,10 +4758,19 @@ var usePnlInputContext = () => {
|
|
|
4758
4758
|
};
|
|
4759
4759
|
|
|
4760
4760
|
// src/components/pnlInput/useBuilder.script.ts
|
|
4761
|
+
function normalizeSlPnlForStore(raw) {
|
|
4762
|
+
const v = `${raw}`.replace(/,/g, "").trim();
|
|
4763
|
+
if (v === "" || v === "-") return v;
|
|
4764
|
+
const withoutTrailingDot = v.replace(/\.$/, "");
|
|
4765
|
+
const num = Number(withoutTrailingDot);
|
|
4766
|
+
if (!isNaN(num) && num === 0) return "0";
|
|
4767
|
+
if (v.startsWith("-")) return v;
|
|
4768
|
+
return `-${v}`;
|
|
4769
|
+
}
|
|
4761
4770
|
var usePNLInputBuilder = (props) => {
|
|
4762
4771
|
const { type, values, quote_dp } = props;
|
|
4763
4772
|
const { t } = useTranslation();
|
|
4764
|
-
const [
|
|
4773
|
+
const [, setFocus] = useState(true);
|
|
4765
4774
|
const { mode, setMode, tipsEle } = usePnlInputContext();
|
|
4766
4775
|
const [tipVisible, setTipVisible] = useState(false);
|
|
4767
4776
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -4774,7 +4783,7 @@ var usePNLInputBuilder = (props) => {
|
|
|
4774
4783
|
default:
|
|
4775
4784
|
return `${type.toLowerCase()}_pnl`;
|
|
4776
4785
|
}
|
|
4777
|
-
}, [mode]);
|
|
4786
|
+
}, [mode, type]);
|
|
4778
4787
|
const [innerValue, setInnerValue] = useState(
|
|
4779
4788
|
values[mode]
|
|
4780
4789
|
);
|
|
@@ -4813,7 +4822,8 @@ var usePNLInputBuilder = (props) => {
|
|
|
4813
4822
|
const percentageSuffix = useRef("");
|
|
4814
4823
|
const onValueChange = (value) => {
|
|
4815
4824
|
setInnerValue(value);
|
|
4816
|
-
|
|
4825
|
+
const outgoing = key === "sl_pnl" ? normalizeSlPnlForStore(value) : value;
|
|
4826
|
+
props.onChange(key, outgoing);
|
|
4817
4827
|
};
|
|
4818
4828
|
const onFocus = () => {
|
|
4819
4829
|
setTipVisible(true);
|
|
@@ -4822,17 +4832,16 @@ var usePNLInputBuilder = (props) => {
|
|
|
4822
4832
|
const onBlur = () => {
|
|
4823
4833
|
setTipVisible(false);
|
|
4824
4834
|
setIsFocused(false);
|
|
4825
|
-
|
|
4835
|
+
const outgoing = key === "sl_pnl" ? normalizeSlPnlForStore(innerValue) : innerValue;
|
|
4836
|
+
props.onChange(key, outgoing);
|
|
4826
4837
|
};
|
|
4827
4838
|
const formatter = (options2) => {
|
|
4828
4839
|
const { dp = 2 } = options2;
|
|
4829
4840
|
return {
|
|
4830
4841
|
onRenderBefore: (value, options3) => {
|
|
4831
4842
|
value = `${value}`;
|
|
4832
|
-
if (
|
|
4833
|
-
|
|
4834
|
-
value = value.startsWith("-") ? value : "-" + value;
|
|
4835
|
-
}
|
|
4843
|
+
if (type === "SL" && mode === "PnL" /* PnL */) {
|
|
4844
|
+
value = value.startsWith("-") ? value : "-" + value;
|
|
4836
4845
|
}
|
|
4837
4846
|
if (value === "" || value === "-") return "";
|
|
4838
4847
|
if (mode === "Offset%" /* PERCENTAGE */) {
|
|
@@ -4869,7 +4878,7 @@ var usePNLInputBuilder = (props) => {
|
|
|
4869
4878
|
value = new Decimal(value).div(100).toString();
|
|
4870
4879
|
value = `${value}${percentageSuffix.current}`;
|
|
4871
4880
|
}
|
|
4872
|
-
} else if (mode === "PnL" /* PnL */ && type === "SL"
|
|
4881
|
+
} else if (mode === "PnL" /* PnL */ && type === "SL") {
|
|
4873
4882
|
value = value.startsWith("-") ? value : "-" + value;
|
|
4874
4883
|
} else {
|
|
4875
4884
|
value = todpIfNeed(value, dp);
|
|
@@ -6336,6 +6345,7 @@ var useOrderEntryScript = (inputs) => {
|
|
|
6336
6345
|
slPrice: formattedOrder.sl_trigger_price,
|
|
6337
6346
|
liqPrice: state.estLiqPrice,
|
|
6338
6347
|
side: formattedOrder.side,
|
|
6348
|
+
markPrice: state.markPrice,
|
|
6339
6349
|
currentPosition: state.currentPosition,
|
|
6340
6350
|
orderQuantity: Number(formattedOrder.order_quantity)
|
|
6341
6351
|
});
|