@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.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';
@@ -2243,152 +2243,49 @@ var PriceInput = (props) => {
2243
2243
  }
2244
2244
  );
2245
2245
  };
2246
- var QuantityInput = memo((props) => {
2246
+ var QtyAndTotalInput = memo((props) => {
2247
2247
  const { t } = useTranslation();
2248
2248
  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
- },
2249
+ const { base, quote, base_dp, quote_dp } = symbolInfo;
2250
+ return /* @__PURE__ */ jsxs(Grid, { cols: 2, className: "oui-group oui-space-x-1", children: [
2251
+ /* @__PURE__ */ jsx(
2252
+ CustomInput,
2281
2253
  {
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);
2254
+ id: "order_quantity_input",
2255
+ name: "order_quantity_input",
2256
+ label: t("common.qty"),
2257
+ suffix: base,
2258
+ error: getErrorMsg("order_quantity"),
2259
+ value: props.order_quantity,
2260
+ onChange: (e) => {
2261
+ setOrderValue("order_quantity", e);
2262
+ },
2263
+ formatters: [inputFormatter.dpFormatter(base_dp)],
2264
+ onFocus: onFocus(3 /* QUANTITY */),
2265
+ onBlur: onBlur(3 /* QUANTITY */),
2266
+ inputMode: "decimal",
2267
+ className: "!oui-rounded-r oui-rounded-bl-xl"
2331
2268
  }
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(
2269
+ ),
2270
+ /* @__PURE__ */ jsx(
2344
2271
  CustomInput,
2345
2272
  {
2346
- id: "order_margin_input",
2347
- name: "order_margin_input",
2348
- label: `${t("orderEntry.initialMargin")}\u2248`,
2349
- prefix,
2273
+ id: "order_total_input",
2274
+ name: "order_total_input",
2275
+ label: `${t("common.total")}\u2248`,
2350
2276
  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
- }
2277
+ error: getErrorMsg("total"),
2278
+ value: props.total,
2279
+ onChange: (e) => {
2280
+ setOrderValue("total", e);
2281
+ },
2282
+ formatters: [inputFormatter.dpFormatter(quote_dp)],
2283
+ onFocus: onFocus(5 /* TOTAL */),
2284
+ onBlur: onBlur(5 /* TOTAL */),
2285
+ inputMode: "decimal",
2286
+ className: "!oui-rounded-bl oui-rounded-br-xl"
2361
2287
  }
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 })
2288
+ )
2392
2289
  ] });
2393
2290
  });
2394
2291
  QtyAndTotalInput.displayName = "QtyAndTotalInput";
@@ -4504,21 +4401,29 @@ var OrderEntry = (props) => {
4504
4401
  ),
4505
4402
  !showSoundSection && extraButton
4506
4403
  ] }),
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
- ] }),
4404
+ showSoundSection && /* @__PURE__ */ jsxs(
4405
+ Flex,
4406
+ {
4407
+ justify: "between",
4408
+ itemAlign: "center",
4409
+ className: "!oui-mt-0 xl:!oui-mt-3",
4410
+ children: [
4411
+ /* @__PURE__ */ jsxs(Flex, { itemAlign: "center", gapX: 1, children: [
4412
+ /* @__PURE__ */ jsx(
4413
+ Switch,
4414
+ {
4415
+ className: "oui-h-[14px]",
4416
+ id: soundAlertId,
4417
+ checked: soundAlert,
4418
+ onCheckedChange: (checked) => setSoundAlert(checked)
4419
+ }
4420
+ ),
4421
+ /* @__PURE__ */ jsx("label", { htmlFor: soundAlertId, className: "oui-text-xs", children: t("portfolio.setting.soundAlerts") })
4422
+ ] }),
4423
+ extraButton
4424
+ ]
4425
+ }
4426
+ ),
4522
4427
  !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
4428
  pinned && /* @__PURE__ */ jsxs(Box, { p: 2, r: "md", intensity: 700, position: "relative", children: [
4524
4429
  /* @__PURE__ */ jsx(AdditionalInfo, { ...additionalInfoProps }),