@kodiak-finance/orderly-ui-order-entry 2.8.20 → 2.8.21-beta.3

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.mjs CHANGED
@@ -3,7 +3,7 @@ import { useLocalStorage, utils, usePositionStream, useEventEmitter, useDebounce
3
3
  import { useTranslation, i18n } from '@kodiak-finance/orderly-i18n';
4
4
  import { useOrderEntryFormErrorMsg, useAppContext } from '@kodiak-finance/orderly-react-app';
5
5
  import { EMPTY_LIST, DistributionType, TrailingCallbackType, OrderSide, OrderType, PositionType, BBOOrderType, AccountStatusEnum, OrderLevel, TrackerEventName } from '@kodiak-finance/orderly-types';
6
- import { ExclamationFillIcon, modal, Text, Tooltip, TooltipTrigger, Flex, Input, cn, inputFormatter, Box, registerSimpleDialog, SimpleDialog, Select, Grid, Checkbox, Slider, textVariants, SettingFillIcon, Badge, Divider, Button, TokenIcon, DataTable, SimpleDropdownMenu, CaretDownIcon, Switch, useScreen, toast, ThrottledButton, SimpleSheet, InfoCircleIcon, AddCircleIcon, PopoverRoot, PopoverTrigger, PopoverContent, DotStatus, EditIcon as EditIcon$1, useModal } from '@kodiak-finance/orderly-ui';
6
+ import { ExclamationFillIcon, modal, Text, Tooltip, TooltipTrigger, Flex, Input, cn, inputFormatter, Box, registerSimpleDialog, SimpleDialog, Grid, Checkbox, Select, Slider, textVariants, SettingFillIcon, Badge, Divider, Button, TokenIcon, DataTable, SimpleDropdownMenu, CaretDownIcon, Switch, useScreen, toast, ThrottledButton, SimpleSheet, InfoCircleIcon, AddCircleIcon, PopoverRoot, PopoverTrigger, PopoverContent, DotStatus, EditIcon as EditIcon$1, useModal } from '@kodiak-finance/orderly-ui';
7
7
  import { TPSLPositionTypeWidget, TPSLAdvancedWidget } from '@kodiak-finance/orderly-ui-tpsl';
8
8
  import { Decimal, zero, todpIfNeed, getBBOType, removeTrailingZeros } from '@kodiak-finance/orderly-utils';
9
9
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
@@ -746,6 +746,7 @@ var SlippageEditor = forwardRef((props, ref) => {
746
746
  Input,
747
747
  {
748
748
  suffix: "%",
749
+ inputMode: "decimal",
749
750
  formatters: [
750
751
  inputFormatter.numberFormatter,
751
752
  inputFormatter.dpFormatter(2)
@@ -2243,152 +2244,49 @@ var PriceInput = (props) => {
2243
2244
  }
2244
2245
  );
2245
2246
  };
2246
- var QuantityInput = memo((props) => {
2247
+ var QtyAndTotalInput = memo((props) => {
2247
2248
  const { t } = useTranslation();
2248
2249
  const { symbolInfo, onFocus, onBlur, getErrorMsg, setOrderValue } = useOrderEntryContext();
2249
- const { base, base_dp } = symbolInfo;
2250
- return /* @__PURE__ */ jsx(
2251
- CustomInput,
2252
- {
2253
- id: "order_quantity_input",
2254
- name: "order_quantity_input",
2255
- label: t("common.qty"),
2256
- suffix: base,
2257
- error: getErrorMsg("order_quantity"),
2258
- value: props.order_quantity,
2259
- onChange: (e) => {
2260
- setOrderValue("order_quantity", e);
2261
- },
2262
- formatters: [inputFormatter.dpFormatter(base_dp)],
2263
- onFocus: onFocus(3 /* QUANTITY */),
2264
- onBlur: onBlur(3 /* QUANTITY */),
2265
- className: "!oui-rounded-r",
2266
- classNames: {
2267
- suffix: "oui-justify-end"
2268
- }
2269
- }
2270
- );
2271
- });
2272
- QuantityInput.displayName = "QuantityInput";
2273
- var TotalTypeSelect = memo((props) => {
2274
- const { t } = useTranslation();
2275
- const options2 = useMemo(() => {
2276
- return [
2277
- {
2278
- label: t("orderEntry.orderSize"),
2279
- value: "orderSize" /* OrderSize */
2280
- },
2250
+ const { base, quote, base_dp, quote_dp } = symbolInfo;
2251
+ return /* @__PURE__ */ jsxs(Grid, { cols: 2, className: "oui-group oui-space-x-1", children: [
2252
+ /* @__PURE__ */ jsx(
2253
+ CustomInput,
2281
2254
  {
2282
- label: t("orderEntry.initialMargin"),
2283
- value: "initialMargin" /* InitialMargin */
2284
- }
2285
- ];
2286
- }, [t]);
2287
- return /* @__PURE__ */ jsx(
2288
- Select.options,
2289
- {
2290
- size: "xs",
2291
- value: props.value,
2292
- valueFormatter: (value, option) => {
2293
- const item = options2.find((o) => o.value === value);
2294
- return item?.label + "\u2248";
2295
- },
2296
- classNames: {
2297
- trigger: cn(
2298
- "oui-w-auto oui-border-none oui-bg-transparent",
2299
- "oui-absolute oui-left-0 oui-top-[5px] oui-text-2xs oui-text-base-contrast-36"
2300
- )
2301
- },
2302
- onValueChange: props.onChange,
2303
- options: options2
2304
- }
2305
- );
2306
- });
2307
- TotalTypeSelect.displayName = "TotalTypeSelect";
2308
- var TotalInput = memo((props) => {
2309
- const { t } = useTranslation();
2310
- const { total } = props;
2311
- const [margin, setMargin] = useState("");
2312
- const {
2313
- symbolInfo,
2314
- onFocus,
2315
- onBlur,
2316
- getErrorMsg,
2317
- setOrderValue,
2318
- leverage = 1,
2319
- currentFocusInput
2320
- } = useOrderEntryContext();
2321
- const { quote } = symbolInfo;
2322
- const [totalType, setTotalType] = useLocalStorage(
2323
- "orderly_order_total_type",
2324
- "orderSize" /* OrderSize */
2325
- );
2326
- useEffect(() => {
2327
- if (total) {
2328
- if (currentFocusInput !== 6 /* MARGIN */) {
2329
- const margin2 = new Decimal(total).div(leverage).todp(2).toString();
2330
- setMargin(margin2);
2255
+ id: "order_quantity_input",
2256
+ name: "order_quantity_input",
2257
+ label: t("common.qty"),
2258
+ suffix: base,
2259
+ error: getErrorMsg("order_quantity"),
2260
+ value: props.order_quantity,
2261
+ onChange: (e) => {
2262
+ setOrderValue("order_quantity", e);
2263
+ },
2264
+ formatters: [inputFormatter.dpFormatter(base_dp)],
2265
+ onFocus: onFocus(3 /* QUANTITY */),
2266
+ onBlur: onBlur(3 /* QUANTITY */),
2267
+ inputMode: "decimal",
2268
+ className: "!oui-rounded-r oui-rounded-bl-xl"
2331
2269
  }
2332
- } else {
2333
- setMargin("");
2334
- }
2335
- }, [total, leverage, currentFocusInput]);
2336
- const onMarginChange = (val) => {
2337
- const total2 = val ? new Decimal(val).mul(leverage).toString() : "";
2338
- setOrderValue("total", total2);
2339
- setMargin(val);
2340
- };
2341
- const prefix = /* @__PURE__ */ jsx(TotalTypeSelect, { value: totalType, onChange: setTotalType });
2342
- if (totalType === "initialMargin" /* InitialMargin */) {
2343
- return /* @__PURE__ */ jsx(
2270
+ ),
2271
+ /* @__PURE__ */ jsx(
2344
2272
  CustomInput,
2345
2273
  {
2346
- id: "order_margin_input",
2347
- name: "order_margin_input",
2348
- label: `${t("orderEntry.initialMargin")}\u2248`,
2349
- prefix,
2274
+ id: "order_total_input",
2275
+ name: "order_total_input",
2276
+ label: `${t("common.total")}\u2248`,
2350
2277
  suffix: quote,
2351
- error: getErrorMsg("total") ? "initial margin error" : "",
2352
- value: margin,
2353
- onChange: onMarginChange,
2354
- formatters: [inputFormatter.dpFormatter(2)],
2355
- onFocus: onFocus(6 /* MARGIN */),
2356
- onBlur: onBlur(6 /* MARGIN */),
2357
- className: "!oui-rounded-l",
2358
- classNames: {
2359
- suffix: "oui-justify-end"
2360
- }
2278
+ error: getErrorMsg("total"),
2279
+ value: props.total,
2280
+ onChange: (e) => {
2281
+ setOrderValue("total", e);
2282
+ },
2283
+ formatters: [inputFormatter.dpFormatter(quote_dp)],
2284
+ onFocus: onFocus(5 /* TOTAL */),
2285
+ onBlur: onBlur(5 /* TOTAL */),
2286
+ inputMode: "decimal",
2287
+ className: "!oui-rounded-bl oui-rounded-br-xl"
2361
2288
  }
2362
- );
2363
- }
2364
- return /* @__PURE__ */ jsx(
2365
- CustomInput,
2366
- {
2367
- id: "order_total_input",
2368
- name: "order_total_input",
2369
- label: `${t("orderEntry.orderSize")}\u2248`,
2370
- prefix,
2371
- suffix: quote,
2372
- error: getErrorMsg("total"),
2373
- value: props.total,
2374
- onChange: (val) => {
2375
- setOrderValue("total", val);
2376
- },
2377
- className: "!oui-rounded-l",
2378
- classNames: {
2379
- suffix: "oui-justify-end"
2380
- },
2381
- formatters: [inputFormatter.dpFormatter(2)],
2382
- onFocus: onFocus(5 /* TOTAL */),
2383
- onBlur: onBlur(5 /* TOTAL */)
2384
- }
2385
- );
2386
- });
2387
- TotalInput.displayName = "TotalInput";
2388
- var QtyAndTotalInput = memo((props) => {
2389
- return /* @__PURE__ */ jsxs(Grid, { cols: 2, className: "oui-group oui-space-x-1", children: [
2390
- /* @__PURE__ */ jsx(QuantityInput, { order_quantity: props.order_quantity }),
2391
- /* @__PURE__ */ jsx(TotalInput, { total: props.total })
2289
+ )
2392
2290
  ] });
2393
2291
  });
2394
2292
  QtyAndTotalInput.displayName = "QtyAndTotalInput";
@@ -4036,6 +3934,7 @@ var TPSLTriggerPriceInput = (props) => {
4036
3934
  },
4037
3935
  color: props.error ? "danger" : void 0,
4038
3936
  autoComplete: "off",
3937
+ inputMode: "decimal",
4039
3938
  value: innerValue,
4040
3939
  classNames: {
4041
3940
  additional: "oui-text-base-contrast-54",
@@ -4504,21 +4403,29 @@ var OrderEntry = (props) => {
4504
4403
  ),
4505
4404
  !showSoundSection && extraButton
4506
4405
  ] }),
4507
- showSoundSection && /* @__PURE__ */ jsxs(Flex, { justify: "between", itemAlign: "center", children: [
4508
- /* @__PURE__ */ jsxs(Flex, { itemAlign: "center", gapX: 1, children: [
4509
- /* @__PURE__ */ jsx(
4510
- Switch,
4511
- {
4512
- className: "oui-h-[14px]",
4513
- id: soundAlertId,
4514
- checked: soundAlert,
4515
- onCheckedChange: (checked) => setSoundAlert(checked)
4516
- }
4517
- ),
4518
- /* @__PURE__ */ jsx("label", { htmlFor: soundAlertId, className: "oui-text-xs", children: t("portfolio.setting.soundAlerts") })
4519
- ] }),
4520
- extraButton
4521
- ] }),
4406
+ showSoundSection && /* @__PURE__ */ jsxs(
4407
+ Flex,
4408
+ {
4409
+ justify: "between",
4410
+ itemAlign: "center",
4411
+ className: "!oui-mt-0 xl:!oui-mt-3",
4412
+ children: [
4413
+ /* @__PURE__ */ jsxs(Flex, { itemAlign: "center", gapX: 1, children: [
4414
+ /* @__PURE__ */ jsx(
4415
+ Switch,
4416
+ {
4417
+ className: "oui-h-[14px]",
4418
+ id: soundAlertId,
4419
+ checked: soundAlert,
4420
+ onCheckedChange: (checked) => setSoundAlert(checked)
4421
+ }
4422
+ ),
4423
+ /* @__PURE__ */ jsx("label", { htmlFor: soundAlertId, className: "oui-text-xs", children: t("portfolio.setting.soundAlerts") })
4424
+ ] }),
4425
+ extraButton
4426
+ ]
4427
+ }
4428
+ ),
4522
4429
  !showSoundSection && isMobile && (formattedOrder.order_type == OrderType.LIMIT || formattedOrder.order_type == OrderType.MARKET) && !formattedOrder.reduce_only && !pinned && /* @__PURE__ */ jsx(Flex, { className: "oui-w-full", justify: "end", children: extraButton }),
4523
4430
  pinned && /* @__PURE__ */ jsxs(Box, { p: 2, r: "md", intensity: 700, position: "relative", children: [
4524
4431
  /* @__PURE__ */ jsx(AdditionalInfo, { ...additionalInfoProps }),