@deriv-web-design/ui 0.1.34 → 0.1.36
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/block-registry.json +248 -5
- package/components.manifest.json +33 -0
- package/dist/index.css +331 -115
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +126 -4
- package/dist/index.d.ts +126 -4
- package/dist/index.js +391 -184
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +385 -184
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8216,7 +8216,55 @@ var ParallaxBanner = ({
|
|
|
8216
8216
|
|
|
8217
8217
|
// templates/TradingCalculator/TradingCalculator.tsx
|
|
8218
8218
|
import { useCallback as useCallback6, useEffect as useEffect18, useId as useId6, useMemo as useMemo7, useRef as useRef21, useState as useState23 } from "react";
|
|
8219
|
+
|
|
8220
|
+
// templates/TradingCalculator/TradingCalculator.types.ts
|
|
8221
|
+
var DEFAULT_TRADING_CALCULATOR_LABELS = {
|
|
8222
|
+
calculatorPanel: "Calculator",
|
|
8223
|
+
resultsPanel: "Results",
|
|
8224
|
+
calculate: "Calculate",
|
|
8225
|
+
calculating: "Calculating\u2026",
|
|
8226
|
+
reset: "Reset",
|
|
8227
|
+
symbols: "Symbols",
|
|
8228
|
+
volume: "Volume in Lots",
|
|
8229
|
+
assetPrice: "Asset price",
|
|
8230
|
+
contractSize: "Contract size",
|
|
8231
|
+
pipSize: "Pip size",
|
|
8232
|
+
effectiveLeverage: "Effective Leverage",
|
|
8233
|
+
pointSize: "Point size",
|
|
8234
|
+
marginRequired: "Margin Required",
|
|
8235
|
+
tradeVolume: "Trade Volume",
|
|
8236
|
+
pipValue: "Pip value",
|
|
8237
|
+
swapChargeLong: "Swap Charge Long",
|
|
8238
|
+
swapChargeShort: "Swap Charge Short",
|
|
8239
|
+
swapLongRate: "Swap long rate",
|
|
8240
|
+
swapShortRate: "Swap short rate",
|
|
8241
|
+
swapCalculationType: "Swap calculation type",
|
|
8242
|
+
threeDaySwap: "Three-day swap",
|
|
8243
|
+
weekendSwaps: "Weekend swaps",
|
|
8244
|
+
threeDaySwapFallback: "No",
|
|
8245
|
+
loadingSymbols: "Loading symbols\u2026",
|
|
8246
|
+
symbolsUnavailable: "Symbols unavailable",
|
|
8247
|
+
searchSymbolPlaceholder: "Search symbol, e.g. EURUSD",
|
|
8248
|
+
symbolsLoadError: "Unable to load symbols.",
|
|
8249
|
+
retry: "Retry",
|
|
8250
|
+
selectSymbolError: "Select a symbol to continue.",
|
|
8251
|
+
volumeRequiredError: "Enter a valid volume in lots.",
|
|
8252
|
+
volumePositiveError: "Volume must be greater than 0.",
|
|
8253
|
+
volumeRangeError: "Volume must be between {min} and {max} lots.",
|
|
8254
|
+
assetPriceError: "Enter a valid asset price.",
|
|
8255
|
+
exchangeRateError: "Unable to fetch live exchange rates. Please try again.",
|
|
8256
|
+
exchangeRateErrorWithMessage: "Unable to fetch live exchange rates ({message}). Please try again.",
|
|
8257
|
+
noSymbolsMatch: 'No symbols match "{query}"'
|
|
8258
|
+
};
|
|
8259
|
+
|
|
8260
|
+
// templates/TradingCalculator/TradingCalculator.tsx
|
|
8219
8261
|
import { Fragment as Fragment11, jsx as jsx60, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
8262
|
+
function fillTemplate2(template, values) {
|
|
8263
|
+
return template.replace(/\{(\w+)\}/g, (_, key) => values[key] ?? "");
|
|
8264
|
+
}
|
|
8265
|
+
function mergeLabels(overrides) {
|
|
8266
|
+
return { ...DEFAULT_TRADING_CALCULATOR_LABELS, ...overrides };
|
|
8267
|
+
}
|
|
8220
8268
|
var DEFAULT_SYMBOLS_ENDPOINT = "https://deriv-static-pricingfeedv2.firebaseio.com/n8n/row/prod/dynamic_trading_specs.json";
|
|
8221
8269
|
var DEFAULT_EXCHANGE_RATE_WS_URL = "wss://ws.derivws.com/websockets/v3?app_id=1089";
|
|
8222
8270
|
var USD = "USD";
|
|
@@ -8376,7 +8424,15 @@ function groupByAssetClass(symbols) {
|
|
|
8376
8424
|
}
|
|
8377
8425
|
return [...groups.entries()];
|
|
8378
8426
|
}
|
|
8379
|
-
var SymbolCombobox = ({
|
|
8427
|
+
var SymbolCombobox = ({
|
|
8428
|
+
symbolsState,
|
|
8429
|
+
onRetry,
|
|
8430
|
+
selected,
|
|
8431
|
+
onSelect,
|
|
8432
|
+
error,
|
|
8433
|
+
inputId,
|
|
8434
|
+
copy
|
|
8435
|
+
}) => {
|
|
8380
8436
|
const [query, setQuery] = useState23("");
|
|
8381
8437
|
const [isOpen, setIsOpen] = useState23(false);
|
|
8382
8438
|
const [activeIndex, setActiveIndex] = useState23(-1);
|
|
@@ -8434,7 +8490,8 @@ var SymbolCombobox = ({ symbolsState, onRetry, selected, onSelect, error, inputI
|
|
|
8434
8490
|
{
|
|
8435
8491
|
id: inputId,
|
|
8436
8492
|
label: /* @__PURE__ */ jsxs56(Fragment11, { children: [
|
|
8437
|
-
|
|
8493
|
+
copy.symbols,
|
|
8494
|
+
" ",
|
|
8438
8495
|
/* @__PURE__ */ jsx60("span", { className: "tcalc-required", children: "*" })
|
|
8439
8496
|
] }),
|
|
8440
8497
|
role: "combobox",
|
|
@@ -8449,7 +8506,7 @@ var SymbolCombobox = ({ symbolsState, onRetry, selected, onSelect, error, inputI
|
|
|
8449
8506
|
disabled: isLoading || isError,
|
|
8450
8507
|
hideClearButton: true,
|
|
8451
8508
|
trailingSlot: /* @__PURE__ */ jsx60(ChevronIcon3, {}),
|
|
8452
|
-
placeholder: isLoading ?
|
|
8509
|
+
placeholder: isLoading ? copy.loadingSymbols : isError ? copy.symbolsUnavailable : copy.searchSymbolPlaceholder,
|
|
8453
8510
|
value: displayValue,
|
|
8454
8511
|
onFocus: () => setIsOpen(true),
|
|
8455
8512
|
onChange: (event) => {
|
|
@@ -8461,11 +8518,7 @@ var SymbolCombobox = ({ symbolsState, onRetry, selected, onSelect, error, inputI
|
|
|
8461
8518
|
}
|
|
8462
8519
|
),
|
|
8463
8520
|
isOpen && !isLoading && !isError && /* @__PURE__ */ jsxs56("div", { className: "tcalc-dropdown", id: listboxId, role: "listbox", children: [
|
|
8464
|
-
grouped.length === 0 && /* @__PURE__ */
|
|
8465
|
-
'No symbols match "',
|
|
8466
|
-
query,
|
|
8467
|
-
'"'
|
|
8468
|
-
] }),
|
|
8521
|
+
grouped.length === 0 && /* @__PURE__ */ jsx60("p", { className: "tcalc-dropdownEmpty", children: fillTemplate2(copy.noSymbolsMatch, { query }) }),
|
|
8469
8522
|
grouped.map(([assetClass, items]) => /* @__PURE__ */ jsxs56("div", { className: "tcalc-dropdownGroup", children: [
|
|
8470
8523
|
/* @__PURE__ */ jsx60("p", { className: "tcalc-dropdownGroupTitle", children: assetClass }),
|
|
8471
8524
|
items.map((item) => {
|
|
@@ -8497,9 +8550,10 @@ var SymbolCombobox = ({ symbolsState, onRetry, selected, onSelect, error, inputI
|
|
|
8497
8550
|
] }),
|
|
8498
8551
|
isError && /* @__PURE__ */ jsxs56("p", { className: "tcalc-fieldError", children: [
|
|
8499
8552
|
/* @__PURE__ */ jsx60(ErrorIcon, {}),
|
|
8500
|
-
" Unable to load symbols.",
|
|
8501
8553
|
" ",
|
|
8502
|
-
|
|
8554
|
+
copy.symbolsLoadError,
|
|
8555
|
+
" ",
|
|
8556
|
+
/* @__PURE__ */ jsx60("button", { type: "button", className: "tcalc-retryLink", onClick: onRetry, children: copy.retry })
|
|
8503
8557
|
] }),
|
|
8504
8558
|
!isError && error && /* @__PURE__ */ jsxs56("p", { className: "tcalc-fieldError", children: [
|
|
8505
8559
|
/* @__PURE__ */ jsx60(ErrorIcon, {}),
|
|
@@ -8527,9 +8581,11 @@ var TradingCalculator = ({
|
|
|
8527
8581
|
symbolsEndpoint = DEFAULT_SYMBOLS_ENDPOINT,
|
|
8528
8582
|
exchangeRateWsUrl = DEFAULT_EXCHANGE_RATE_WS_URL,
|
|
8529
8583
|
defaultSymbol,
|
|
8584
|
+
labels: labelsProp,
|
|
8530
8585
|
className,
|
|
8531
8586
|
...props
|
|
8532
8587
|
}) => {
|
|
8588
|
+
const copy = mergeLabels(labelsProp);
|
|
8533
8589
|
const showMargin = variant === "main" || variant === "margin";
|
|
8534
8590
|
const showPip = variant === "main" || variant === "pip";
|
|
8535
8591
|
const showSwap = variant === "main" || variant === "swap";
|
|
@@ -8573,15 +8629,18 @@ var TradingCalculator = ({
|
|
|
8573
8629
|
const volume = Number.parseFloat(volumeInLots);
|
|
8574
8630
|
const price = Number.parseFloat(assetPrice);
|
|
8575
8631
|
const nextErrors = {};
|
|
8576
|
-
if (!selectedSymbol) nextErrors.symbol =
|
|
8632
|
+
if (!selectedSymbol) nextErrors.symbol = copy.selectSymbolError;
|
|
8577
8633
|
if (!volumeInLots || Number.isNaN(volume)) {
|
|
8578
|
-
nextErrors.volume =
|
|
8634
|
+
nextErrors.volume = copy.volumeRequiredError;
|
|
8579
8635
|
} else if (volume <= 0) {
|
|
8580
|
-
nextErrors.volume =
|
|
8636
|
+
nextErrors.volume = copy.volumePositiveError;
|
|
8581
8637
|
} else if (selectedSymbol && (volume < selectedSymbol.volume_min || volume > selectedSymbol.volume_limit)) {
|
|
8582
|
-
nextErrors.volume =
|
|
8638
|
+
nextErrors.volume = fillTemplate2(copy.volumeRangeError, {
|
|
8639
|
+
min: String(selectedSymbol.volume_min),
|
|
8640
|
+
max: String(selectedSymbol.volume_limit)
|
|
8641
|
+
});
|
|
8583
8642
|
}
|
|
8584
|
-
if (!assetPrice || Number.isNaN(price) || price <= 0) nextErrors.price =
|
|
8643
|
+
if (!assetPrice || Number.isNaN(price) || price <= 0) nextErrors.price = copy.assetPriceError;
|
|
8585
8644
|
setErrors(nextErrors);
|
|
8586
8645
|
if (Object.keys(nextErrors).length > 0 || !selectedSymbol) return;
|
|
8587
8646
|
setCalcError(null);
|
|
@@ -8592,7 +8651,7 @@ var TradingCalculator = ({
|
|
|
8592
8651
|
setResults(computeResults(selectedSymbol, volume, price, rates));
|
|
8593
8652
|
} catch (error) {
|
|
8594
8653
|
setCalcError(
|
|
8595
|
-
error instanceof Error ?
|
|
8654
|
+
error instanceof Error ? fillTemplate2(copy.exchangeRateErrorWithMessage, { message: error.message }) : copy.exchangeRateError
|
|
8596
8655
|
);
|
|
8597
8656
|
} finally {
|
|
8598
8657
|
setIsCalculating(false);
|
|
@@ -8603,7 +8662,7 @@ var TradingCalculator = ({
|
|
|
8603
8662
|
const priceInputId = useId6();
|
|
8604
8663
|
return /* @__PURE__ */ jsx60("section", { className: ["tcalc-section", className ?? ""].filter(Boolean).join(" "), ...props, children: /* @__PURE__ */ jsx60("div", { className: "tcalc-container", children: /* @__PURE__ */ jsxs56("div", { className: "tcalc-card", children: [
|
|
8605
8664
|
/* @__PURE__ */ jsxs56("div", { className: "tcalc-column", children: [
|
|
8606
|
-
/* @__PURE__ */ jsx60("h3", { className: "tcalc-panelTitle", children:
|
|
8665
|
+
/* @__PURE__ */ jsx60("h3", { className: "tcalc-panelTitle", children: copy.calculatorPanel }),
|
|
8607
8666
|
/* @__PURE__ */ jsx60(
|
|
8608
8667
|
SymbolCombobox,
|
|
8609
8668
|
{
|
|
@@ -8612,20 +8671,21 @@ var TradingCalculator = ({
|
|
|
8612
8671
|
selected: selectedSymbol,
|
|
8613
8672
|
onSelect: handleSelectSymbol,
|
|
8614
8673
|
error: errors.symbol,
|
|
8615
|
-
inputId: symbolInputId
|
|
8674
|
+
inputId: symbolInputId,
|
|
8675
|
+
copy
|
|
8616
8676
|
}
|
|
8617
8677
|
),
|
|
8618
8678
|
/* @__PURE__ */ jsxs56("div", { className: "tcalc-infoGrid", children: [
|
|
8619
|
-
/* @__PURE__ */ jsx60(InfoRow, { label:
|
|
8620
|
-
/* @__PURE__ */ jsx60(InfoRow, { label:
|
|
8679
|
+
/* @__PURE__ */ jsx60(InfoRow, { label: copy.contractSize, value: selectedSymbol ? integerFormatter.format(selectedSymbol.contract_size) : "-" }),
|
|
8680
|
+
/* @__PURE__ */ jsx60(InfoRow, { label: copy.pipSize, value: selectedSymbol ? String(selectedSymbol.pip_size) : "-" }),
|
|
8621
8681
|
/* @__PURE__ */ jsx60(
|
|
8622
8682
|
InfoRow,
|
|
8623
8683
|
{
|
|
8624
|
-
label:
|
|
8684
|
+
label: copy.effectiveLeverage,
|
|
8625
8685
|
value: selectedSymbol ? `1 : ${Math.round((selectedSymbol.effective_leverage + Number.EPSILON) * 100) / 100}` : "-"
|
|
8626
8686
|
}
|
|
8627
8687
|
),
|
|
8628
|
-
/* @__PURE__ */ jsx60(InfoRow, { label:
|
|
8688
|
+
/* @__PURE__ */ jsx60(InfoRow, { label: copy.pointSize, value: selectedSymbol ? String(selectedSymbol.point_size) : "-" })
|
|
8629
8689
|
] }),
|
|
8630
8690
|
/* @__PURE__ */ jsxs56("div", { className: "tcalc-field", children: [
|
|
8631
8691
|
/* @__PURE__ */ jsx60(
|
|
@@ -8634,7 +8694,8 @@ var TradingCalculator = ({
|
|
|
8634
8694
|
id: volumeInputId,
|
|
8635
8695
|
className: "tcalc-numberField",
|
|
8636
8696
|
label: /* @__PURE__ */ jsxs56(Fragment11, { children: [
|
|
8637
|
-
|
|
8697
|
+
copy.volume,
|
|
8698
|
+
" ",
|
|
8638
8699
|
/* @__PURE__ */ jsx60("span", { className: "tcalc-required", children: "*" })
|
|
8639
8700
|
] }),
|
|
8640
8701
|
status: errors.volume ? "fail" : "neutral",
|
|
@@ -8651,7 +8712,7 @@ var TradingCalculator = ({
|
|
|
8651
8712
|
const isNegative = value !== "" && !Number.isNaN(parsed) && parsed <= 0;
|
|
8652
8713
|
setErrors((prev) => ({
|
|
8653
8714
|
...prev,
|
|
8654
|
-
volume: isNegative ?
|
|
8715
|
+
volume: isNegative ? copy.volumePositiveError : void 0
|
|
8655
8716
|
}));
|
|
8656
8717
|
}
|
|
8657
8718
|
}
|
|
@@ -8669,7 +8730,8 @@ var TradingCalculator = ({
|
|
|
8669
8730
|
id: priceInputId,
|
|
8670
8731
|
className: "tcalc-numberField",
|
|
8671
8732
|
label: /* @__PURE__ */ jsxs56(Fragment11, { children: [
|
|
8672
|
-
|
|
8733
|
+
copy.assetPrice,
|
|
8734
|
+
" ",
|
|
8673
8735
|
/* @__PURE__ */ jsx60("span", { className: "tcalc-required", children: "*" })
|
|
8674
8736
|
] }),
|
|
8675
8737
|
status: errors.price ? "fail" : "neutral",
|
|
@@ -8698,7 +8760,7 @@ var TradingCalculator = ({
|
|
|
8698
8760
|
type: "button",
|
|
8699
8761
|
colorScheme: "coral",
|
|
8700
8762
|
variant: "primary",
|
|
8701
|
-
label: isCalculating ?
|
|
8763
|
+
label: isCalculating ? copy.calculating : copy.calculate,
|
|
8702
8764
|
onClick: handleCalculate,
|
|
8703
8765
|
disabled: isCalculating,
|
|
8704
8766
|
fullWidth: true
|
|
@@ -8710,7 +8772,7 @@ var TradingCalculator = ({
|
|
|
8710
8772
|
type: "button",
|
|
8711
8773
|
colorScheme: "black",
|
|
8712
8774
|
variant: "secondary",
|
|
8713
|
-
label:
|
|
8775
|
+
label: copy.reset,
|
|
8714
8776
|
onClick: handleReset,
|
|
8715
8777
|
fullWidth: true
|
|
8716
8778
|
}
|
|
@@ -8718,16 +8780,16 @@ var TradingCalculator = ({
|
|
|
8718
8780
|
] })
|
|
8719
8781
|
] }),
|
|
8720
8782
|
/* @__PURE__ */ jsxs56("div", { className: "tcalc-column tcalc-column--results", children: [
|
|
8721
|
-
/* @__PURE__ */ jsx60("h3", { className: "tcalc-panelTitle", children:
|
|
8722
|
-
showMargin && /* @__PURE__ */ jsx60(ResultBox, { label:
|
|
8783
|
+
/* @__PURE__ */ jsx60("h3", { className: "tcalc-panelTitle", children: copy.resultsPanel }),
|
|
8784
|
+
showMargin && /* @__PURE__ */ jsx60(ResultBox, { label: copy.marginRequired, value: results ? formatMoney(results.marginRequired) : "$" }),
|
|
8723
8785
|
showTradeVolume && showPip && /* @__PURE__ */ jsxs56("div", { className: "tcalc-resultRow", children: [
|
|
8724
|
-
/* @__PURE__ */ jsx60(ResultBox, { label:
|
|
8725
|
-
/* @__PURE__ */ jsx60(ResultBox, { label:
|
|
8786
|
+
/* @__PURE__ */ jsx60(ResultBox, { label: copy.tradeVolume, value: results ? formatInteger(results.tradeVolume) : "$" }),
|
|
8787
|
+
/* @__PURE__ */ jsx60(ResultBox, { label: copy.pipValue, value: results ? formatMoney(results.pipValue) : "$" })
|
|
8726
8788
|
] }),
|
|
8727
|
-
!showTradeVolume && showPip && /* @__PURE__ */ jsx60(ResultBox, { label:
|
|
8789
|
+
!showTradeVolume && showPip && /* @__PURE__ */ jsx60(ResultBox, { label: copy.pipValue, value: results ? formatMoney(results.pipValue) : "$" }),
|
|
8728
8790
|
showSwap && /* @__PURE__ */ jsxs56("div", { className: "tcalc-resultRow", children: [
|
|
8729
|
-
/* @__PURE__ */ jsx60(ResultBox, { label:
|
|
8730
|
-
/* @__PURE__ */ jsx60(ResultBox, { label:
|
|
8791
|
+
/* @__PURE__ */ jsx60(ResultBox, { label: copy.swapChargeLong, value: results ? formatMoney(results.swapChargeLong) : "$" }),
|
|
8792
|
+
/* @__PURE__ */ jsx60(ResultBox, { label: copy.swapChargeShort, value: results ? formatMoney(results.swapChargeShort) : "$" })
|
|
8731
8793
|
] }),
|
|
8732
8794
|
calcError && /* @__PURE__ */ jsxs56("p", { className: "tcalc-fieldError tcalc-calcError", children: [
|
|
8733
8795
|
/* @__PURE__ */ jsx60(ErrorIcon, {}),
|
|
@@ -8736,12 +8798,12 @@ var TradingCalculator = ({
|
|
|
8736
8798
|
] }),
|
|
8737
8799
|
showSwap && /* @__PURE__ */ jsxs56(Fragment11, { children: [
|
|
8738
8800
|
/* @__PURE__ */ jsxs56("div", { className: "tcalc-infoGrid", children: [
|
|
8739
|
-
/* @__PURE__ */ jsx60(InfoRow, { label:
|
|
8740
|
-
/* @__PURE__ */ jsx60(InfoRow, { label:
|
|
8801
|
+
/* @__PURE__ */ jsx60(InfoRow, { label: copy.swapLongRate, value: selectedSymbol ? String(selectedSymbol.swap_rate_long) : "-" }),
|
|
8802
|
+
/* @__PURE__ */ jsx60(InfoRow, { label: copy.swapShortRate, value: selectedSymbol ? String(selectedSymbol.swap_rate_short) : "-" })
|
|
8741
8803
|
] }),
|
|
8742
|
-
/* @__PURE__ */ jsx60(InfoRow, { separator: ":", label:
|
|
8743
|
-
/* @__PURE__ */ jsx60(InfoRow, { separator: ":", label:
|
|
8744
|
-
/* @__PURE__ */ jsx60(InfoRow, { separator: ":", label:
|
|
8804
|
+
/* @__PURE__ */ jsx60(InfoRow, { separator: ":", label: copy.swapCalculationType, value: selectedSymbol ? selectedSymbol.swap_mode : "-" }),
|
|
8805
|
+
/* @__PURE__ */ jsx60(InfoRow, { separator: ":", label: copy.threeDaySwap, value: selectedSymbol ? selectedSymbol.three_day_swap || copy.threeDaySwapFallback : "-" }),
|
|
8806
|
+
/* @__PURE__ */ jsx60(InfoRow, { separator: ":", label: copy.weekendSwaps, value: selectedSymbol ? String(selectedSymbol.weekend_swaps ?? "-") : "-" })
|
|
8745
8807
|
] })
|
|
8746
8808
|
] })
|
|
8747
8809
|
] }) }) });
|
|
@@ -9346,9 +9408,11 @@ function browserSupportsMarketStreaming() {
|
|
|
9346
9408
|
|
|
9347
9409
|
// templates/cryptoMarketData/conversion.ts
|
|
9348
9410
|
function convertAmounts(options) {
|
|
9411
|
+
const waitingForPrice = options.messages?.waitingForPrice ?? "Waiting for a live price";
|
|
9412
|
+
const invalidAmount = options.messages?.invalidAmount ?? "Enter a valid amount";
|
|
9349
9413
|
const price = options.price;
|
|
9350
9414
|
if (price == null || !Number.isFinite(price) || price <= 0) {
|
|
9351
|
-
return { pay: options.payInput, receive: options.receiveInput, valid: false, error:
|
|
9415
|
+
return { pay: options.payInput, receive: options.receiveInput, valid: false, error: waitingForPrice };
|
|
9352
9416
|
}
|
|
9353
9417
|
const source = options.edited === "pay" ? options.payInput : options.receiveInput;
|
|
9354
9418
|
const trimmed = source.trim();
|
|
@@ -9361,7 +9425,7 @@ function convertAmounts(options) {
|
|
|
9361
9425
|
pay: options.payInput,
|
|
9362
9426
|
receive: options.receiveInput,
|
|
9363
9427
|
valid: false,
|
|
9364
|
-
error:
|
|
9428
|
+
error: invalidAmount
|
|
9365
9429
|
};
|
|
9366
9430
|
}
|
|
9367
9431
|
if (options.side === "buy") {
|
|
@@ -9578,8 +9642,8 @@ function createMarketFeed(discovered, handlers, options = {}) {
|
|
|
9578
9642
|
const resolved = resolveMetaId(key, meta);
|
|
9579
9643
|
if (!resolved) continue;
|
|
9580
9644
|
applyTick(resolved.id, resolved.meta, tick);
|
|
9581
|
-
subscribeTicker(
|
|
9582
|
-
subscribeKline(
|
|
9645
|
+
subscribeTicker(key);
|
|
9646
|
+
subscribeKline(key);
|
|
9583
9647
|
}
|
|
9584
9648
|
return;
|
|
9585
9649
|
}
|
|
@@ -9906,9 +9970,39 @@ function useCryptoMarketData(options) {
|
|
|
9906
9970
|
return snapshot;
|
|
9907
9971
|
}
|
|
9908
9972
|
|
|
9973
|
+
// templates/CryptoTradeConverter/CryptoTradeConverter.types.ts
|
|
9974
|
+
var DEFAULT_CRYPTO_TRADE_CONVERTER_TITLE = "Buy and sell in seconds";
|
|
9975
|
+
var DEFAULT_CRYPTO_TRADE_CONVERTER_SUBTITLE = "Choose your asset, enter an amount, and confirm. Your crypto lands in your account instantly, ready to trade, hold, or withdraw whenever you want.";
|
|
9976
|
+
var DEFAULT_CRYPTO_TRADE_CONVERTER_LABELS = {
|
|
9977
|
+
buy: "Buy",
|
|
9978
|
+
sell: "Sell",
|
|
9979
|
+
connecting: "Connecting to live prices\u2026",
|
|
9980
|
+
livePrices: "Live prices",
|
|
9981
|
+
waitingForPrice: "Waiting for a live price",
|
|
9982
|
+
unsupportedBrowser: "Please use a current browser to view live prices.",
|
|
9983
|
+
selectMarket: "Select a market",
|
|
9984
|
+
chooseMarket: "Choose a market",
|
|
9985
|
+
tradeSideGroup: "Trade side",
|
|
9986
|
+
youPay: "You pay",
|
|
9987
|
+
youReceive: "You receive",
|
|
9988
|
+
amountToSpend: "Amount to spend",
|
|
9989
|
+
primaryAmountAria: "Primary trade amount",
|
|
9990
|
+
convertedAmountAria: "Converted trade amount",
|
|
9991
|
+
estimateTemplate: "Estimate at 1 {base} = {price} {quote}. Fees and spread excluded.",
|
|
9992
|
+
change24hSuffix: "(24h)",
|
|
9993
|
+
waitingForLivePrice: "Waiting for live price\u2026",
|
|
9994
|
+
invalidAmount: "Enter a valid amount"
|
|
9995
|
+
};
|
|
9996
|
+
|
|
9909
9997
|
// templates/CryptoTradeConverter/CryptoTradeConverter.tsx
|
|
9910
9998
|
import { Fragment as Fragment14, jsx as jsx62, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
9911
9999
|
var DEFAULT_TRADE_HREF = "https://deriv.exchange";
|
|
10000
|
+
function fillTemplate3(template, values) {
|
|
10001
|
+
return template.replace(/\{(\w+)\}/g, (_, key) => values[key] ?? "");
|
|
10002
|
+
}
|
|
10003
|
+
function mergeLabels2(overrides) {
|
|
10004
|
+
return { ...DEFAULT_CRYPTO_TRADE_CONVERTER_LABELS, ...overrides };
|
|
10005
|
+
}
|
|
9912
10006
|
function matchPair(rows, defaultPair) {
|
|
9913
10007
|
if (!rows.length) return null;
|
|
9914
10008
|
if (!defaultPair) {
|
|
@@ -9928,8 +10022,8 @@ function CoinAvatar({ base, icon, label }) {
|
|
|
9928
10022
|
className: "ctc-avatar",
|
|
9929
10023
|
src: icon,
|
|
9930
10024
|
alt: "",
|
|
9931
|
-
width:
|
|
9932
|
-
height:
|
|
10025
|
+
width: 30,
|
|
10026
|
+
height: 30,
|
|
9933
10027
|
loading: "lazy",
|
|
9934
10028
|
decoding: "async",
|
|
9935
10029
|
onError: () => setFailed(true),
|
|
@@ -9937,14 +10031,36 @@ function CoinAvatar({ base, icon, label }) {
|
|
|
9937
10031
|
}
|
|
9938
10032
|
);
|
|
9939
10033
|
}
|
|
10034
|
+
function ChevronIcon4({ className }) {
|
|
10035
|
+
return /* @__PURE__ */ jsx62(
|
|
10036
|
+
"svg",
|
|
10037
|
+
{
|
|
10038
|
+
className,
|
|
10039
|
+
width: 20,
|
|
10040
|
+
height: 20,
|
|
10041
|
+
viewBox: "0 0 24 24",
|
|
10042
|
+
fill: "none",
|
|
10043
|
+
stroke: "currentColor",
|
|
10044
|
+
strokeWidth: "2.2",
|
|
10045
|
+
strokeLinecap: "round",
|
|
10046
|
+
strokeLinejoin: "round",
|
|
10047
|
+
"aria-hidden": "true",
|
|
10048
|
+
children: /* @__PURE__ */ jsx62("polyline", { points: "6 9 12 15 18 9" })
|
|
10049
|
+
}
|
|
10050
|
+
);
|
|
10051
|
+
}
|
|
9940
10052
|
var CryptoTradeConverter = ({
|
|
9941
10053
|
variant: _variant = "default",
|
|
9942
10054
|
market: _market = "spot",
|
|
9943
10055
|
defaultPair,
|
|
9944
10056
|
tradeHref = DEFAULT_TRADE_HREF,
|
|
9945
10057
|
apiOrigin,
|
|
10058
|
+
title = DEFAULT_CRYPTO_TRADE_CONVERTER_TITLE,
|
|
10059
|
+
subtitle = DEFAULT_CRYPTO_TRADE_CONVERTER_SUBTITLE,
|
|
10060
|
+
labels: labelsProp,
|
|
9946
10061
|
className
|
|
9947
10062
|
}) => {
|
|
10063
|
+
const copy = mergeLabels2(labelsProp);
|
|
9948
10064
|
const reactId = useId7().replace(/:/g, "");
|
|
9949
10065
|
const listboxId = `ctc-listbox-${reactId}`;
|
|
9950
10066
|
const payId = `ctc-pay-${reactId}`;
|
|
@@ -9972,9 +10088,13 @@ var CryptoTradeConverter = ({
|
|
|
9972
10088
|
price: selected?.last ?? null,
|
|
9973
10089
|
payInput: pay,
|
|
9974
10090
|
receiveInput: receive,
|
|
9975
|
-
edited
|
|
10091
|
+
edited,
|
|
10092
|
+
messages: {
|
|
10093
|
+
waitingForPrice: copy.waitingForPrice,
|
|
10094
|
+
invalidAmount: copy.invalidAmount
|
|
10095
|
+
}
|
|
9976
10096
|
}),
|
|
9977
|
-
[side, selected?.last, pay, receive, edited]
|
|
10097
|
+
[side, selected?.last, pay, receive, edited, copy.waitingForPrice, copy.invalidAmount]
|
|
9978
10098
|
);
|
|
9979
10099
|
useEffect21(() => {
|
|
9980
10100
|
if (edited === "pay") setReceive(conversion.receive);
|
|
@@ -10043,6 +10163,15 @@ var CryptoTradeConverter = ({
|
|
|
10043
10163
|
const priceReady = selected?.last != null && Number.isFinite(selected.last) && selected.last > 0;
|
|
10044
10164
|
const ctaDisabled = !priceReady || snapshot.status === "unsupported" || snapshot.status === "error" || !conversion.valid;
|
|
10045
10165
|
const changeClass = selected?.change24hPct == null ? "" : selected.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
|
|
10166
|
+
const payValue = edited === "pay" ? pay : conversion.pay;
|
|
10167
|
+
const receiveValue = edited === "receive" ? receive : conversion.receive;
|
|
10168
|
+
const receiveMeta = priceReady && selected ? fillTemplate3(copy.estimateTemplate, {
|
|
10169
|
+
base: selected.base,
|
|
10170
|
+
price: formatPrice(selected.last, selected.pricePrecision),
|
|
10171
|
+
quote: selected.quote
|
|
10172
|
+
}) : snapshot.status === "unsupported" ? copy.unsupportedBrowser : conversion.error || (snapshot.status === "idle" || snapshot.status === "connecting" ? copy.connecting : copy.waitingForLivePrice);
|
|
10173
|
+
const ctaLabel = side === "buy" ? copy.buy : copy.sell;
|
|
10174
|
+
const ctaClass = ["ctc-cta__btn", side === "sell" ? "is-sell" : "is-buy"].join(" ");
|
|
10046
10175
|
return /* @__PURE__ */ jsx62(
|
|
10047
10176
|
"section",
|
|
10048
10177
|
{
|
|
@@ -10053,36 +10182,23 @@ var CryptoTradeConverter = ({
|
|
|
10053
10182
|
"aria-labelledby": `ctc-heading-${reactId}`,
|
|
10054
10183
|
children: /* @__PURE__ */ jsxs58("div", { className: "ctc-container", children: [
|
|
10055
10184
|
/* @__PURE__ */ jsxs58("header", { className: "ctc-header", children: [
|
|
10056
|
-
/* @__PURE__ */ jsx62("h2", { id: `ctc-heading-${reactId}`, className: "ctc-title", children:
|
|
10057
|
-
/* @__PURE__ */ jsx62("p", { className: "ctc-subtitle", children:
|
|
10185
|
+
/* @__PURE__ */ jsx62("h2", { id: `ctc-heading-${reactId}`, className: "ctc-title", children: title }),
|
|
10186
|
+
/* @__PURE__ */ jsx62("p", { className: "ctc-subtitle", children: subtitle })
|
|
10058
10187
|
] }),
|
|
10059
|
-
/* @__PURE__ */
|
|
10060
|
-
/* @__PURE__ */ jsxs58(
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
"
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
}
|
|
10074
|
-
),
|
|
10075
|
-
/* @__PURE__ */ jsx62(
|
|
10076
|
-
"button",
|
|
10077
|
-
{
|
|
10078
|
-
type: "button",
|
|
10079
|
-
className: side === "sell" ? "ctc-seg__btn is-active is-sell" : "ctc-seg__btn is-sell",
|
|
10080
|
-
"aria-pressed": side === "sell",
|
|
10081
|
-
onClick: () => setSide("sell"),
|
|
10082
|
-
children: "Sell"
|
|
10083
|
-
}
|
|
10084
|
-
)
|
|
10085
|
-
] }),
|
|
10188
|
+
/* @__PURE__ */ jsx62("div", { className: "ctc-card", children: /* @__PURE__ */ jsxs58("div", { className: "ctc-widget", children: [
|
|
10189
|
+
/* @__PURE__ */ jsxs58(
|
|
10190
|
+
"div",
|
|
10191
|
+
{
|
|
10192
|
+
className: `ctc-status ctc-status--${statusTone}`,
|
|
10193
|
+
id: statusId,
|
|
10194
|
+
role: "status",
|
|
10195
|
+
"aria-live": "polite",
|
|
10196
|
+
children: [
|
|
10197
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-status-dot", "aria-hidden": "true" }),
|
|
10198
|
+
/* @__PURE__ */ jsx62("span", { children: snapshot.status === "idle" || snapshot.status === "connecting" ? copy.connecting : snapshot.statusMessage || (priceReady ? copy.livePrices : copy.waitingForLivePrice) })
|
|
10199
|
+
]
|
|
10200
|
+
}
|
|
10201
|
+
),
|
|
10086
10202
|
/* @__PURE__ */ jsxs58("div", { className: "ctc-pair", children: [
|
|
10087
10203
|
/* @__PURE__ */ jsxs58(
|
|
10088
10204
|
"button",
|
|
@@ -10119,137 +10235,180 @@ var CryptoTradeConverter = ({
|
|
|
10119
10235
|
" ",
|
|
10120
10236
|
/* @__PURE__ */ jsxs58("span", { className: ["ctc-change", changeClass].filter(Boolean).join(" "), children: [
|
|
10121
10237
|
formatPct(selected.change24hPct),
|
|
10122
|
-
"
|
|
10238
|
+
" ",
|
|
10239
|
+
copy.change24hSuffix
|
|
10123
10240
|
] })
|
|
10124
10241
|
] })
|
|
10125
10242
|
] })
|
|
10126
10243
|
] }) : /* @__PURE__ */ jsxs58("span", { className: "ctc-pair__meta", children: [
|
|
10127
|
-
/* @__PURE__ */ jsx62("span", { className: "ctc-pair__name", children:
|
|
10244
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-pair__name", children: copy.selectMarket }),
|
|
10128
10245
|
/* @__PURE__ */ jsx62("span", { className: "ctc-pair__price", children: "\u2014" })
|
|
10129
10246
|
] }),
|
|
10130
|
-
/* @__PURE__ */ jsx62(
|
|
10247
|
+
/* @__PURE__ */ jsx62(ChevronIcon4, { className: "ctc-pair__chevron" })
|
|
10131
10248
|
]
|
|
10132
10249
|
}
|
|
10133
10250
|
),
|
|
10134
|
-
pickerOpen ? /* @__PURE__ */
|
|
10251
|
+
pickerOpen ? /* @__PURE__ */ jsxs58(
|
|
10135
10252
|
"ul",
|
|
10136
10253
|
{
|
|
10137
10254
|
ref: listRef,
|
|
10138
10255
|
id: listboxId,
|
|
10139
10256
|
className: "ctc-listbox",
|
|
10140
10257
|
role: "listbox",
|
|
10141
|
-
"aria-label":
|
|
10258
|
+
"aria-label": copy.chooseMarket,
|
|
10142
10259
|
tabIndex: -1,
|
|
10143
10260
|
onKeyDown: onPickerKeyDown,
|
|
10144
|
-
children:
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
"
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
"
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10261
|
+
children: [
|
|
10262
|
+
/* @__PURE__ */ jsx62("li", { className: "ctc-listbox__header", role: "presentation", children: copy.chooseMarket }),
|
|
10263
|
+
sortedRows.map((row, index) => {
|
|
10264
|
+
const selectedOption = selected?.id === row.id;
|
|
10265
|
+
const active = index === activeOption;
|
|
10266
|
+
const rowChange = row.change24hPct == null ? "" : row.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
|
|
10267
|
+
return /* @__PURE__ */ jsxs58(
|
|
10268
|
+
"li",
|
|
10269
|
+
{
|
|
10270
|
+
id: `${listboxId}-opt-${index}`,
|
|
10271
|
+
role: "option",
|
|
10272
|
+
"aria-selected": selectedOption,
|
|
10273
|
+
className: [
|
|
10274
|
+
"ctc-option",
|
|
10275
|
+
active ? "is-active" : "",
|
|
10276
|
+
selectedOption ? "is-selected" : ""
|
|
10277
|
+
].filter(Boolean).join(" "),
|
|
10278
|
+
onMouseEnter: () => setActiveOption(index),
|
|
10279
|
+
onClick: () => {
|
|
10280
|
+
setSelectedId(row.id);
|
|
10281
|
+
closePicker();
|
|
10282
|
+
},
|
|
10283
|
+
children: [
|
|
10284
|
+
/* @__PURE__ */ jsx62(CoinAvatar, { base: row.base, icon: row.icon, label: row.name }),
|
|
10285
|
+
/* @__PURE__ */ jsxs58("span", { className: "ctc-option__text", children: [
|
|
10286
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-option__name", children: row.name }),
|
|
10287
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-option__sub", children: row.longName })
|
|
10288
|
+
] }),
|
|
10289
|
+
/* @__PURE__ */ jsxs58("span", { className: "ctc-option__stats", children: [
|
|
10290
|
+
/* @__PURE__ */ jsx62("span", { children: formatPrice(row.last, row.pricePrecision) }),
|
|
10291
|
+
/* @__PURE__ */ jsx62("span", { className: ["ctc-change", rowChange].filter(Boolean).join(" "), children: formatPct(row.change24hPct) })
|
|
10292
|
+
] })
|
|
10293
|
+
]
|
|
10163
10294
|
},
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
/* @__PURE__ */ jsx62("span", { className: "ctc-option__sub", children: row.longName })
|
|
10169
|
-
] }),
|
|
10170
|
-
/* @__PURE__ */ jsxs58("span", { className: "ctc-option__stats", children: [
|
|
10171
|
-
/* @__PURE__ */ jsx62("span", { children: formatPrice(row.last, row.pricePrecision) }),
|
|
10172
|
-
/* @__PURE__ */ jsx62("span", { className: ["ctc-change", rowChange].filter(Boolean).join(" "), children: formatPct(row.change24hPct) })
|
|
10173
|
-
] })
|
|
10174
|
-
]
|
|
10175
|
-
},
|
|
10176
|
-
row.id
|
|
10177
|
-
);
|
|
10178
|
-
})
|
|
10295
|
+
row.id
|
|
10296
|
+
);
|
|
10297
|
+
})
|
|
10298
|
+
]
|
|
10179
10299
|
}
|
|
10180
10300
|
) : null
|
|
10181
10301
|
] }),
|
|
10182
|
-
/* @__PURE__ */ jsxs58("div", { className: "ctc-
|
|
10302
|
+
/* @__PURE__ */ jsxs58("div", { className: "ctc-seg", role: "group", "aria-label": copy.tradeSideGroup, children: [
|
|
10183
10303
|
/* @__PURE__ */ jsx62(
|
|
10184
|
-
|
|
10304
|
+
"button",
|
|
10185
10305
|
{
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
value: edited === "pay" ? pay : conversion.pay,
|
|
10192
|
-
status: conversion.error ? "fail" : "neutral",
|
|
10193
|
-
"aria-invalid": Boolean(conversion.error),
|
|
10194
|
-
"aria-describedby": statusId,
|
|
10195
|
-
onChange: (event) => {
|
|
10196
|
-
setEdited("pay");
|
|
10197
|
-
setPay(event.target.value);
|
|
10198
|
-
}
|
|
10306
|
+
type: "button",
|
|
10307
|
+
className: side === "buy" ? "ctc-seg__btn is-active is-buy" : "ctc-seg__btn is-buy",
|
|
10308
|
+
"aria-pressed": side === "buy",
|
|
10309
|
+
onClick: () => setSide("buy"),
|
|
10310
|
+
children: copy.buy
|
|
10199
10311
|
}
|
|
10200
10312
|
),
|
|
10201
10313
|
/* @__PURE__ */ jsx62(
|
|
10202
|
-
|
|
10314
|
+
"button",
|
|
10203
10315
|
{
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
|
|
10209
|
-
|
|
10210
|
-
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
10216
|
-
|
|
10316
|
+
type: "button",
|
|
10317
|
+
className: side === "sell" ? "ctc-seg__btn is-active is-sell" : "ctc-seg__btn is-sell",
|
|
10318
|
+
"aria-pressed": side === "sell",
|
|
10319
|
+
onClick: () => setSide("sell"),
|
|
10320
|
+
children: copy.sell
|
|
10321
|
+
}
|
|
10322
|
+
)
|
|
10323
|
+
] }),
|
|
10324
|
+
/* @__PURE__ */ jsxs58("div", { className: "ctc-fields", children: [
|
|
10325
|
+
/* @__PURE__ */ jsxs58(
|
|
10326
|
+
"label",
|
|
10327
|
+
{
|
|
10328
|
+
className: ["ctc-amount", conversion.error ? "is-invalid" : ""].filter(Boolean).join(" "),
|
|
10329
|
+
htmlFor: payId,
|
|
10330
|
+
children: [
|
|
10331
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__label", children: copy.youPay }),
|
|
10332
|
+
/* @__PURE__ */ jsxs58("span", { className: "ctc-amount__row", children: [
|
|
10333
|
+
/* @__PURE__ */ jsx62(
|
|
10334
|
+
"input",
|
|
10335
|
+
{
|
|
10336
|
+
id: payId,
|
|
10337
|
+
className: "ctc-amount__input",
|
|
10338
|
+
type: "text",
|
|
10339
|
+
inputMode: "decimal",
|
|
10340
|
+
autoComplete: "off",
|
|
10341
|
+
placeholder: "0.00",
|
|
10342
|
+
value: payValue,
|
|
10343
|
+
"aria-label": copy.primaryAmountAria,
|
|
10344
|
+
"aria-invalid": Boolean(conversion.error),
|
|
10345
|
+
"aria-describedby": statusId,
|
|
10346
|
+
onChange: (event) => {
|
|
10347
|
+
setEdited("pay");
|
|
10348
|
+
setPay(event.target.value);
|
|
10349
|
+
}
|
|
10350
|
+
}
|
|
10351
|
+
),
|
|
10352
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__unit", children: labels.pay })
|
|
10353
|
+
] }),
|
|
10354
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__meta", children: copy.amountToSpend })
|
|
10355
|
+
]
|
|
10356
|
+
}
|
|
10357
|
+
),
|
|
10358
|
+
/* @__PURE__ */ jsxs58(
|
|
10359
|
+
"label",
|
|
10360
|
+
{
|
|
10361
|
+
className: ["ctc-amount", conversion.error ? "is-invalid" : ""].filter(Boolean).join(" "),
|
|
10362
|
+
htmlFor: receiveId,
|
|
10363
|
+
children: [
|
|
10364
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__label", children: copy.youReceive }),
|
|
10365
|
+
/* @__PURE__ */ jsxs58("span", { className: "ctc-amount__row", children: [
|
|
10366
|
+
/* @__PURE__ */ jsx62(
|
|
10367
|
+
"input",
|
|
10368
|
+
{
|
|
10369
|
+
id: receiveId,
|
|
10370
|
+
className: "ctc-amount__input",
|
|
10371
|
+
type: "text",
|
|
10372
|
+
inputMode: "decimal",
|
|
10373
|
+
autoComplete: "off",
|
|
10374
|
+
placeholder: "0.00",
|
|
10375
|
+
value: receiveValue,
|
|
10376
|
+
"aria-label": copy.convertedAmountAria,
|
|
10377
|
+
"aria-invalid": Boolean(conversion.error),
|
|
10378
|
+
"aria-describedby": `ctc-rate-${reactId}`,
|
|
10379
|
+
onChange: (event) => {
|
|
10380
|
+
setEdited("receive");
|
|
10381
|
+
setReceive(event.target.value);
|
|
10382
|
+
}
|
|
10383
|
+
}
|
|
10384
|
+
),
|
|
10385
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__unit", children: labels.receive })
|
|
10386
|
+
] }),
|
|
10387
|
+
/* @__PURE__ */ jsx62("span", { id: `ctc-rate-${reactId}`, className: "ctc-amount__meta", children: receiveMeta })
|
|
10388
|
+
]
|
|
10217
10389
|
}
|
|
10218
10390
|
)
|
|
10219
10391
|
] }),
|
|
10220
|
-
priceReady && selected ? /* @__PURE__ */ jsxs58("p", { id: `ctc-rate-${reactId}`, className: "ctc-rate", children: [
|
|
10221
|
-
"Estimate at 1 ",
|
|
10222
|
-
selected.base,
|
|
10223
|
-
" = ",
|
|
10224
|
-
formatPrice(selected.last, selected.pricePrecision),
|
|
10225
|
-
" ",
|
|
10226
|
-
selected.quote,
|
|
10227
|
-
". Fees and spread excluded."
|
|
10228
|
-
] }) : /* @__PURE__ */ jsx62("p", { className: "ctc-rate", role: "status", children: snapshot.status === "unsupported" ? "Please use a current browser to view live prices." : conversion.error || "Waiting for a live market price\u2026" }),
|
|
10229
10392
|
conversion.error ? /* @__PURE__ */ jsx62("p", { className: "ctc-error", role: "alert", children: conversion.error }) : null,
|
|
10230
10393
|
/* @__PURE__ */ jsx62("div", { className: "ctc-cta", children: ctaDisabled ? /* @__PURE__ */ jsx62(
|
|
10231
|
-
|
|
10394
|
+
"button",
|
|
10232
10395
|
{
|
|
10233
10396
|
type: "button",
|
|
10234
|
-
|
|
10235
|
-
variant: "primary",
|
|
10236
|
-
fullWidth: true,
|
|
10237
|
-
label: side === "buy" ? "Buy" : "Sell",
|
|
10397
|
+
className: ctaClass,
|
|
10238
10398
|
disabled: true,
|
|
10239
|
-
"aria-disabled": "true"
|
|
10399
|
+
"aria-disabled": "true",
|
|
10400
|
+
children: ctaLabel
|
|
10240
10401
|
}
|
|
10241
|
-
) : /* @__PURE__ */ jsx62(
|
|
10242
|
-
|
|
10402
|
+
) : /* @__PURE__ */ jsx62(
|
|
10403
|
+
"a",
|
|
10243
10404
|
{
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
label: side === "buy" ? "Buy" : "Sell",
|
|
10249
|
-
tabIndex: -1
|
|
10405
|
+
className: ["ctc-cta-link", side === "sell" ? "is-sell" : "is-buy"].join(" "),
|
|
10406
|
+
href: tradeHref,
|
|
10407
|
+
rel: "noopener noreferrer",
|
|
10408
|
+
children: ctaLabel
|
|
10250
10409
|
}
|
|
10251
|
-
) })
|
|
10252
|
-
] })
|
|
10410
|
+
) })
|
|
10411
|
+
] }) })
|
|
10253
10412
|
] })
|
|
10254
10413
|
}
|
|
10255
10414
|
);
|
|
@@ -10257,7 +10416,37 @@ var CryptoTradeConverter = ({
|
|
|
10257
10416
|
|
|
10258
10417
|
// templates/CryptoMarketsTable/CryptoMarketsTable.tsx
|
|
10259
10418
|
import { useEffect as useEffect22, useId as useId8, useMemo as useMemo9, useRef as useRef24, useState as useState27 } from "react";
|
|
10419
|
+
|
|
10420
|
+
// templates/CryptoMarketsTable/CryptoMarketsTable.types.ts
|
|
10421
|
+
var DEFAULT_CRYPTO_MARKETS_TABLE_TITLE = "Explore the markets";
|
|
10422
|
+
var DEFAULT_CRYPTO_MARKETS_TABLE_LABELS = {
|
|
10423
|
+
spot: "Spot",
|
|
10424
|
+
futures: "Futures",
|
|
10425
|
+
live: "Live",
|
|
10426
|
+
connecting: "Connecting\u2026",
|
|
10427
|
+
marketTypeGroup: "Market type",
|
|
10428
|
+
quoteCurrencyTabs: "Quote currency",
|
|
10429
|
+
scrollRegion: "Market prices. Scroll horizontally to see all columns.",
|
|
10430
|
+
columnName: "Name",
|
|
10431
|
+
columnPrice: "Price",
|
|
10432
|
+
column1h: "1h %",
|
|
10433
|
+
column24h: "24h %",
|
|
10434
|
+
column7d: "7d chart",
|
|
10435
|
+
unsupportedBrowser: "Please use a current browser to view market prices.",
|
|
10436
|
+
loadError: "Unable to load market data. Retrying\u2026",
|
|
10437
|
+
loading: "Loading market data\u2026",
|
|
10438
|
+
emptyPairsTemplate: "No {quote} pairs on {kind} yet\u2026",
|
|
10439
|
+
sparklineAriaTemplate: "{name} available hourly price history, up to 7 days"
|
|
10440
|
+
};
|
|
10441
|
+
|
|
10442
|
+
// templates/CryptoMarketsTable/CryptoMarketsTable.tsx
|
|
10260
10443
|
import { jsx as jsx63, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
10444
|
+
function fillTemplate4(template, values) {
|
|
10445
|
+
return template.replace(/\{(\w+)\}/g, (_, key) => values[key] ?? "");
|
|
10446
|
+
}
|
|
10447
|
+
function mergeLabels3(overrides) {
|
|
10448
|
+
return { ...DEFAULT_CRYPTO_MARKETS_TABLE_LABELS, ...overrides };
|
|
10449
|
+
}
|
|
10261
10450
|
function CoinAvatar2({ base, icon }) {
|
|
10262
10451
|
const [failed, setFailed] = useState27(false);
|
|
10263
10452
|
if (failed) {
|
|
@@ -10363,8 +10552,11 @@ var CryptoMarketsTable = ({
|
|
|
10363
10552
|
initialQuoteCurrency = "USDT",
|
|
10364
10553
|
apiOrigin,
|
|
10365
10554
|
maxRows,
|
|
10555
|
+
title = DEFAULT_CRYPTO_MARKETS_TABLE_TITLE,
|
|
10556
|
+
labels: labelsProp,
|
|
10366
10557
|
className
|
|
10367
10558
|
}) => {
|
|
10559
|
+
const copy = mergeLabels3(labelsProp);
|
|
10368
10560
|
const reactId = useId8().replace(/:/g, "");
|
|
10369
10561
|
const [kind, setKind] = useState27(initialMarket);
|
|
10370
10562
|
const [quote, setQuote] = useState27(initialQuoteCurrency.toUpperCase());
|
|
@@ -10411,7 +10603,14 @@ var CryptoMarketsTable = ({
|
|
|
10411
10603
|
}
|
|
10412
10604
|
};
|
|
10413
10605
|
const statusTone = snapshot.status === "live" ? "live" : snapshot.status === "reconnecting" || snapshot.status === "stale" ? "warn" : snapshot.status === "error" || snapshot.status === "unsupported" ? "error" : "muted";
|
|
10414
|
-
const emptyMessage = snapshot.status === "unsupported" ?
|
|
10606
|
+
const emptyMessage = snapshot.status === "unsupported" ? copy.unsupportedBrowser : snapshot.status === "error" ? copy.loadError : snapshot.status === "connecting" || snapshot.status === "idle" ? copy.loading : fillTemplate4(copy.emptyPairsTemplate, { quote, kind });
|
|
10607
|
+
const columnLabels = [
|
|
10608
|
+
["name", copy.columnName],
|
|
10609
|
+
["last", copy.columnPrice],
|
|
10610
|
+
["change1hPct", copy.column1h],
|
|
10611
|
+
["change24hPct", copy.column24h],
|
|
10612
|
+
["change7dPct", copy.column7d]
|
|
10613
|
+
];
|
|
10415
10614
|
return /* @__PURE__ */ jsx63(
|
|
10416
10615
|
"section",
|
|
10417
10616
|
{
|
|
@@ -10420,26 +10619,26 @@ var CryptoMarketsTable = ({
|
|
|
10420
10619
|
"aria-labelledby": `cmt-heading-${reactId}`,
|
|
10421
10620
|
children: /* @__PURE__ */ jsxs59("div", { className: "cmt-container", children: [
|
|
10422
10621
|
/* @__PURE__ */ jsxs59("header", { className: "cmt-header", children: [
|
|
10423
|
-
/* @__PURE__ */ jsx63("h2", { id: `cmt-heading-${reactId}`, className: "cmt-title", children:
|
|
10622
|
+
/* @__PURE__ */ jsx63("h2", { id: `cmt-heading-${reactId}`, className: "cmt-title", children: title }),
|
|
10424
10623
|
/* @__PURE__ */ jsxs59("p", { className: `cmt-status cmt-status--${statusTone}`, role: "status", "aria-live": "polite", children: [
|
|
10425
10624
|
/* @__PURE__ */ jsx63("span", { className: "cmt-status-dot", "aria-hidden": "true" }),
|
|
10426
|
-
/* @__PURE__ */ jsx63("span", { children: snapshot.status === "live" ?
|
|
10625
|
+
/* @__PURE__ */ jsx63("span", { children: snapshot.status === "live" ? copy.live : snapshot.statusMessage || copy.connecting })
|
|
10427
10626
|
] })
|
|
10428
10627
|
] }),
|
|
10429
10628
|
/* @__PURE__ */ jsxs59("div", { className: "cmt-card", children: [
|
|
10430
10629
|
/* @__PURE__ */ jsxs59("div", { className: "cmt-toolbar", children: [
|
|
10431
|
-
/* @__PURE__ */ jsx63("div", { className: "cmt-seg", role: "group", "aria-label":
|
|
10630
|
+
/* @__PURE__ */ jsx63("div", { className: "cmt-seg", role: "group", "aria-label": copy.marketTypeGroup, children: ["spot", "futures"].map((value) => /* @__PURE__ */ jsx63(
|
|
10432
10631
|
"button",
|
|
10433
10632
|
{
|
|
10434
10633
|
type: "button",
|
|
10435
10634
|
className: kind === value ? "cmt-seg__btn is-active" : "cmt-seg__btn",
|
|
10436
10635
|
"aria-pressed": kind === value,
|
|
10437
10636
|
onClick: () => setKind(value),
|
|
10438
|
-
children: value === "spot" ?
|
|
10637
|
+
children: value === "spot" ? copy.spot : copy.futures
|
|
10439
10638
|
},
|
|
10440
10639
|
value
|
|
10441
10640
|
)) }),
|
|
10442
|
-
/* @__PURE__ */ jsx63("div", { className: "cmt-tabs", role: "tablist", "aria-label":
|
|
10641
|
+
/* @__PURE__ */ jsx63("div", { className: "cmt-tabs", role: "tablist", "aria-label": copy.quoteCurrencyTabs, children: snapshot.quotes.map((q) => /* @__PURE__ */ jsx63(
|
|
10443
10642
|
"button",
|
|
10444
10643
|
{
|
|
10445
10644
|
type: "button",
|
|
@@ -10459,15 +10658,9 @@ var CryptoMarketsTable = ({
|
|
|
10459
10658
|
className: ["cmt-scroll", scrolled ? "is-scrolled" : ""].filter(Boolean).join(" "),
|
|
10460
10659
|
tabIndex: 0,
|
|
10461
10660
|
role: "region",
|
|
10462
|
-
"aria-label":
|
|
10661
|
+
"aria-label": copy.scrollRegion,
|
|
10463
10662
|
children: /* @__PURE__ */ jsxs59("table", { className: "cmt-table", children: [
|
|
10464
|
-
/* @__PURE__ */ jsx63("thead", { children: /* @__PURE__ */ jsx63("tr", { children: [
|
|
10465
|
-
["name", "Name"],
|
|
10466
|
-
["last", "Price"],
|
|
10467
|
-
["change1hPct", "1h %"],
|
|
10468
|
-
["change24hPct", "24h %"],
|
|
10469
|
-
["change7dPct", "7d chart"]
|
|
10470
|
-
].map(([key, label]) => {
|
|
10663
|
+
/* @__PURE__ */ jsx63("thead", { children: /* @__PURE__ */ jsx63("tr", { children: columnLabels.map(([key, label]) => {
|
|
10471
10664
|
const active = sortKey === key;
|
|
10472
10665
|
return /* @__PURE__ */ jsx63(
|
|
10473
10666
|
"th",
|
|
@@ -10512,7 +10705,9 @@ var CryptoMarketsTable = ({
|
|
|
10512
10705
|
{
|
|
10513
10706
|
values: row.spark7d,
|
|
10514
10707
|
up: (row.change7dPct ?? 0) >= 0,
|
|
10515
|
-
label:
|
|
10708
|
+
label: fillTemplate4(copy.sparklineAriaTemplate, {
|
|
10709
|
+
name: row.name
|
|
10710
|
+
}),
|
|
10516
10711
|
reducedMotion
|
|
10517
10712
|
}
|
|
10518
10713
|
) })
|
|
@@ -12169,10 +12364,16 @@ export {
|
|
|
12169
12364
|
CryptoMarketsTable,
|
|
12170
12365
|
CryptoTradeConverter,
|
|
12171
12366
|
DEFAULT_AWARDS,
|
|
12367
|
+
DEFAULT_CRYPTO_MARKETS_TABLE_LABELS,
|
|
12368
|
+
DEFAULT_CRYPTO_MARKETS_TABLE_TITLE,
|
|
12369
|
+
DEFAULT_CRYPTO_TRADE_CONVERTER_LABELS,
|
|
12370
|
+
DEFAULT_CRYPTO_TRADE_CONVERTER_SUBTITLE,
|
|
12371
|
+
DEFAULT_CRYPTO_TRADE_CONVERTER_TITLE,
|
|
12172
12372
|
DEFAULT_CULTURE_CARDS,
|
|
12173
12373
|
DEFAULT_EXCHANGE_RATE_WS_URL,
|
|
12174
12374
|
DEFAULT_SYMBOLS_ENDPOINT,
|
|
12175
12375
|
DEFAULT_TRADE_HREF,
|
|
12376
|
+
DEFAULT_TRADING_CALCULATOR_LABELS,
|
|
12176
12377
|
DayNightTransition,
|
|
12177
12378
|
DocumentChips,
|
|
12178
12379
|
DotLottieInView,
|