@kodiak-finance/orderly-ui-order-entry 2.8.21-alpha.0 → 2.8.21-rc.2

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
@@ -2249,152 +2249,49 @@ var PriceInput = (props) => {
2249
2249
  }
2250
2250
  );
2251
2251
  };
2252
- var QuantityInput = React3.memo((props) => {
2252
+ var QtyAndTotalInput = React3.memo((props) => {
2253
2253
  const { t } = orderlyI18n.useTranslation();
2254
2254
  const { symbolInfo, onFocus, onBlur, getErrorMsg, setOrderValue } = useOrderEntryContext();
2255
- const { base, base_dp } = symbolInfo;
2256
- return /* @__PURE__ */ jsxRuntime.jsx(
2257
- CustomInput,
2258
- {
2259
- id: "order_quantity_input",
2260
- name: "order_quantity_input",
2261
- label: t("common.qty"),
2262
- suffix: base,
2263
- error: getErrorMsg("order_quantity"),
2264
- value: props.order_quantity,
2265
- onChange: (e) => {
2266
- setOrderValue("order_quantity", e);
2267
- },
2268
- formatters: [orderlyUi.inputFormatter.dpFormatter(base_dp)],
2269
- onFocus: onFocus(3 /* QUANTITY */),
2270
- onBlur: onBlur(3 /* QUANTITY */),
2271
- className: "!oui-rounded-r",
2272
- classNames: {
2273
- suffix: "oui-justify-end"
2274
- }
2275
- }
2276
- );
2277
- });
2278
- QuantityInput.displayName = "QuantityInput";
2279
- var TotalTypeSelect = React3.memo((props) => {
2280
- const { t } = orderlyI18n.useTranslation();
2281
- const options2 = React3.useMemo(() => {
2282
- return [
2283
- {
2284
- label: t("orderEntry.orderSize"),
2285
- value: "orderSize" /* OrderSize */
2286
- },
2255
+ const { base, quote, base_dp, quote_dp } = symbolInfo;
2256
+ return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Grid, { cols: 2, className: "oui-group oui-space-x-1", children: [
2257
+ /* @__PURE__ */ jsxRuntime.jsx(
2258
+ CustomInput,
2287
2259
  {
2288
- label: t("orderEntry.initialMargin"),
2289
- value: "initialMargin" /* InitialMargin */
2290
- }
2291
- ];
2292
- }, [t]);
2293
- return /* @__PURE__ */ jsxRuntime.jsx(
2294
- orderlyUi.Select.options,
2295
- {
2296
- size: "xs",
2297
- value: props.value,
2298
- valueFormatter: (value, option) => {
2299
- const item = options2.find((o) => o.value === value);
2300
- return item?.label + "\u2248";
2301
- },
2302
- classNames: {
2303
- trigger: orderlyUi.cn(
2304
- "oui-w-auto oui-border-none oui-bg-transparent",
2305
- "oui-absolute oui-left-0 oui-top-[5px] oui-text-2xs oui-text-base-contrast-36"
2306
- )
2307
- },
2308
- onValueChange: props.onChange,
2309
- options: options2
2310
- }
2311
- );
2312
- });
2313
- TotalTypeSelect.displayName = "TotalTypeSelect";
2314
- var TotalInput = React3.memo((props) => {
2315
- const { t } = orderlyI18n.useTranslation();
2316
- const { total } = props;
2317
- const [margin, setMargin] = React3.useState("");
2318
- const {
2319
- symbolInfo,
2320
- onFocus,
2321
- onBlur,
2322
- getErrorMsg,
2323
- setOrderValue,
2324
- leverage = 1,
2325
- currentFocusInput
2326
- } = useOrderEntryContext();
2327
- const { quote } = symbolInfo;
2328
- const [totalType, setTotalType] = orderlyHooks.useLocalStorage(
2329
- "orderly_order_total_type",
2330
- "orderSize" /* OrderSize */
2331
- );
2332
- React3.useEffect(() => {
2333
- if (total) {
2334
- if (currentFocusInput !== 6 /* MARGIN */) {
2335
- const margin2 = new orderlyUtils.Decimal(total).div(leverage).todp(2).toString();
2336
- setMargin(margin2);
2260
+ id: "order_quantity_input",
2261
+ name: "order_quantity_input",
2262
+ label: t("common.qty"),
2263
+ suffix: base,
2264
+ error: getErrorMsg("order_quantity"),
2265
+ value: props.order_quantity,
2266
+ onChange: (e) => {
2267
+ setOrderValue("order_quantity", e);
2268
+ },
2269
+ formatters: [orderlyUi.inputFormatter.dpFormatter(base_dp)],
2270
+ onFocus: onFocus(3 /* QUANTITY */),
2271
+ onBlur: onBlur(3 /* QUANTITY */),
2272
+ inputMode: "decimal",
2273
+ className: "!oui-rounded-r oui-rounded-bl-xl"
2337
2274
  }
2338
- } else {
2339
- setMargin("");
2340
- }
2341
- }, [total, leverage, currentFocusInput]);
2342
- const onMarginChange = (val) => {
2343
- const total2 = val ? new orderlyUtils.Decimal(val).mul(leverage).toString() : "";
2344
- setOrderValue("total", total2);
2345
- setMargin(val);
2346
- };
2347
- const prefix = /* @__PURE__ */ jsxRuntime.jsx(TotalTypeSelect, { value: totalType, onChange: setTotalType });
2348
- if (totalType === "initialMargin" /* InitialMargin */) {
2349
- return /* @__PURE__ */ jsxRuntime.jsx(
2275
+ ),
2276
+ /* @__PURE__ */ jsxRuntime.jsx(
2350
2277
  CustomInput,
2351
2278
  {
2352
- id: "order_margin_input",
2353
- name: "order_margin_input",
2354
- label: `${t("orderEntry.initialMargin")}\u2248`,
2355
- prefix,
2279
+ id: "order_total_input",
2280
+ name: "order_total_input",
2281
+ label: `${t("common.total")}\u2248`,
2356
2282
  suffix: quote,
2357
- error: getErrorMsg("total") ? "initial margin error" : "",
2358
- value: margin,
2359
- onChange: onMarginChange,
2360
- formatters: [orderlyUi.inputFormatter.dpFormatter(2)],
2361
- onFocus: onFocus(6 /* MARGIN */),
2362
- onBlur: onBlur(6 /* MARGIN */),
2363
- className: "!oui-rounded-l",
2364
- classNames: {
2365
- suffix: "oui-justify-end"
2366
- }
2283
+ error: getErrorMsg("total"),
2284
+ value: props.total,
2285
+ onChange: (e) => {
2286
+ setOrderValue("total", e);
2287
+ },
2288
+ formatters: [orderlyUi.inputFormatter.dpFormatter(quote_dp)],
2289
+ onFocus: onFocus(5 /* TOTAL */),
2290
+ onBlur: onBlur(5 /* TOTAL */),
2291
+ inputMode: "decimal",
2292
+ className: "!oui-rounded-bl oui-rounded-br-xl"
2367
2293
  }
2368
- );
2369
- }
2370
- return /* @__PURE__ */ jsxRuntime.jsx(
2371
- CustomInput,
2372
- {
2373
- id: "order_total_input",
2374
- name: "order_total_input",
2375
- label: `${t("orderEntry.orderSize")}\u2248`,
2376
- prefix,
2377
- suffix: quote,
2378
- error: getErrorMsg("total"),
2379
- value: props.total,
2380
- onChange: (val) => {
2381
- setOrderValue("total", val);
2382
- },
2383
- className: "!oui-rounded-l",
2384
- classNames: {
2385
- suffix: "oui-justify-end"
2386
- },
2387
- formatters: [orderlyUi.inputFormatter.dpFormatter(2)],
2388
- onFocus: onFocus(5 /* TOTAL */),
2389
- onBlur: onBlur(5 /* TOTAL */)
2390
- }
2391
- );
2392
- });
2393
- TotalInput.displayName = "TotalInput";
2394
- var QtyAndTotalInput = React3.memo((props) => {
2395
- return /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Grid, { cols: 2, className: "oui-group oui-space-x-1", children: [
2396
- /* @__PURE__ */ jsxRuntime.jsx(QuantityInput, { order_quantity: props.order_quantity }),
2397
- /* @__PURE__ */ jsxRuntime.jsx(TotalInput, { total: props.total })
2294
+ )
2398
2295
  ] });
2399
2296
  });
2400
2297
  QtyAndTotalInput.displayName = "QtyAndTotalInput";
@@ -4510,21 +4407,29 @@ var OrderEntry = (props) => {
4510
4407
  ),
4511
4408
  !showSoundSection && extraButton
4512
4409
  ] }),
4513
- showSoundSection && /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { justify: "between", itemAlign: "center", children: [
4514
- /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { itemAlign: "center", gapX: 1, children: [
4515
- /* @__PURE__ */ jsxRuntime.jsx(
4516
- orderlyUi.Switch,
4517
- {
4518
- className: "oui-h-[14px]",
4519
- id: soundAlertId,
4520
- checked: soundAlert,
4521
- onCheckedChange: (checked) => setSoundAlert(checked)
4522
- }
4523
- ),
4524
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: soundAlertId, className: "oui-text-xs", children: t("portfolio.setting.soundAlerts") })
4525
- ] }),
4526
- extraButton
4527
- ] }),
4410
+ showSoundSection && /* @__PURE__ */ jsxRuntime.jsxs(
4411
+ orderlyUi.Flex,
4412
+ {
4413
+ justify: "between",
4414
+ itemAlign: "center",
4415
+ className: "!oui-mt-0 xl:!oui-mt-3",
4416
+ children: [
4417
+ /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Flex, { itemAlign: "center", gapX: 1, children: [
4418
+ /* @__PURE__ */ jsxRuntime.jsx(
4419
+ orderlyUi.Switch,
4420
+ {
4421
+ className: "oui-h-[14px]",
4422
+ id: soundAlertId,
4423
+ checked: soundAlert,
4424
+ onCheckedChange: (checked) => setSoundAlert(checked)
4425
+ }
4426
+ ),
4427
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: soundAlertId, className: "oui-text-xs", children: t("portfolio.setting.soundAlerts") })
4428
+ ] }),
4429
+ extraButton
4430
+ ]
4431
+ }
4432
+ ),
4528
4433
  !showSoundSection && isMobile && (formattedOrder.order_type == orderlyTypes.OrderType.LIMIT || formattedOrder.order_type == orderlyTypes.OrderType.MARKET) && !formattedOrder.reduce_only && !pinned && /* @__PURE__ */ jsxRuntime.jsx(orderlyUi.Flex, { className: "oui-w-full", justify: "end", children: extraButton }),
4529
4434
  pinned && /* @__PURE__ */ jsxRuntime.jsxs(orderlyUi.Box, { p: 2, r: "md", intensity: 700, position: "relative", children: [
4530
4435
  /* @__PURE__ */ jsxRuntime.jsx(AdditionalInfo, { ...additionalInfoProps }),