@deriv-web-design/ui 0.1.35 → 0.1.37
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 +317 -6
- package/components.manifest.json +38 -0
- package/dist/index.d.mts +178 -5
- package/dist/index.d.ts +178 -5
- package/dist/index.js +294 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +287 -81
- 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
|
] }) }) });
|
|
@@ -8749,7 +8811,53 @@ var TradingCalculator = ({
|
|
|
8749
8811
|
|
|
8750
8812
|
// templates/TradingCalculatorHowTo/TradingCalculatorHowTo.tsx
|
|
8751
8813
|
import { Fragment as Fragment12, useEffect as useEffect19, useLayoutEffect as useLayoutEffect3, useRef as useRef22, useState as useState24 } from "react";
|
|
8814
|
+
|
|
8815
|
+
// templates/TradingCalculatorHowTo/TradingCalculatorHowTo.types.ts
|
|
8816
|
+
var DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS = {
|
|
8817
|
+
formulaHeading: "Formula",
|
|
8818
|
+
exampleHeading: "Example",
|
|
8819
|
+
swapTabPoints: "Swap calculation (In points)",
|
|
8820
|
+
swapTabPercentage: "Swap calculation (In percentage)"
|
|
8821
|
+
};
|
|
8822
|
+
|
|
8823
|
+
// templates/TradingCalculatorHowTo/TradingCalculatorHowTo.tsx
|
|
8752
8824
|
import { Fragment as Fragment13, jsx as jsx61, jsxs as jsxs57 } from "react/jsx-runtime";
|
|
8825
|
+
function applyContentLabels(base, overrides) {
|
|
8826
|
+
if (!overrides) {
|
|
8827
|
+
return {
|
|
8828
|
+
...base,
|
|
8829
|
+
formulaHeading: DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS.formulaHeading,
|
|
8830
|
+
exampleHeading: DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS.exampleHeading
|
|
8831
|
+
};
|
|
8832
|
+
}
|
|
8833
|
+
return {
|
|
8834
|
+
...base,
|
|
8835
|
+
formulaHeading: overrides.formulaHeading ?? DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS.formulaHeading,
|
|
8836
|
+
exampleHeading: overrides.exampleHeading ?? DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS.exampleHeading,
|
|
8837
|
+
formulaBlocks: overrides.formulaBlocks ?? base.formulaBlocks,
|
|
8838
|
+
exampleIntro: overrides.exampleIntro ?? base.exampleIntro,
|
|
8839
|
+
exampleLead: overrides.exampleLead ?? base.exampleLead,
|
|
8840
|
+
calculations: overrides.calculations ?? base.calculations,
|
|
8841
|
+
resultText: overrides.resultText ?? base.resultText,
|
|
8842
|
+
note: overrides.note ?? base.note
|
|
8843
|
+
};
|
|
8844
|
+
}
|
|
8845
|
+
function bodyLabelsForMode(labels, isSwap, swapTab) {
|
|
8846
|
+
if (!labels) return void 0;
|
|
8847
|
+
const flat = {
|
|
8848
|
+
formulaHeading: labels.formulaHeading,
|
|
8849
|
+
exampleHeading: labels.exampleHeading,
|
|
8850
|
+
formulaBlocks: labels.formulaBlocks,
|
|
8851
|
+
exampleIntro: labels.exampleIntro,
|
|
8852
|
+
exampleLead: labels.exampleLead,
|
|
8853
|
+
calculations: labels.calculations,
|
|
8854
|
+
resultText: labels.resultText,
|
|
8855
|
+
note: labels.note
|
|
8856
|
+
};
|
|
8857
|
+
if (!isSwap) return flat;
|
|
8858
|
+
const tabSpecific = swapTab === "percentage" ? labels.swapPercentage : labels.swapPoints;
|
|
8859
|
+
return { ...flat, ...tabSpecific };
|
|
8860
|
+
}
|
|
8753
8861
|
var MARGIN_CONTENT = {
|
|
8754
8862
|
title: "How to calculate margin requirements",
|
|
8755
8863
|
description: "Use this formula to calculate how much margin is required based on your lot size, leverage ratio, and the current market price.",
|
|
@@ -8894,11 +9002,15 @@ var SWAP_PERCENTAGE_CONTENT = {
|
|
|
8894
9002
|
],
|
|
8895
9003
|
resultText: "This means the swap charge is USD -0.26 to keep the position open overnight."
|
|
8896
9004
|
};
|
|
8897
|
-
var SWAP_TABS = [
|
|
8898
|
-
{ id: "points", label: "Swap calculation (In points)" },
|
|
8899
|
-
{ id: "percentage", label: "Swap calculation (In percentage)" }
|
|
8900
|
-
];
|
|
8901
9005
|
var swapModeForVariant = (variant) => variant === "swap-percentage" ? "percentage" : "points";
|
|
9006
|
+
function swapTabsForLabels(labels) {
|
|
9007
|
+
const points = labels?.swapTabPoints ?? DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS.swapTabPoints;
|
|
9008
|
+
const percentage = labels?.swapTabPercentage ?? DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS.swapTabPercentage;
|
|
9009
|
+
return [
|
|
9010
|
+
{ id: "points", label: points },
|
|
9011
|
+
{ id: "percentage", label: percentage }
|
|
9012
|
+
];
|
|
9013
|
+
}
|
|
8902
9014
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect3 : useEffect19;
|
|
8903
9015
|
var FormulaBlockView = ({ block }) => {
|
|
8904
9016
|
if (block.type === "footnote") {
|
|
@@ -9001,6 +9113,7 @@ var TradingCalculatorHowTo = ({
|
|
|
9001
9113
|
variant = "margin",
|
|
9002
9114
|
title,
|
|
9003
9115
|
description,
|
|
9116
|
+
labels,
|
|
9004
9117
|
className,
|
|
9005
9118
|
...props
|
|
9006
9119
|
}) => {
|
|
@@ -9009,9 +9122,14 @@ var TradingCalculatorHowTo = ({
|
|
|
9009
9122
|
useEffect19(() => {
|
|
9010
9123
|
setSwapTab(swapModeForVariant(variant));
|
|
9011
9124
|
}, [variant]);
|
|
9012
|
-
const
|
|
9125
|
+
const baseContent = variant === "pip" ? PIP_CONTENT : isSwap ? swapTab === "percentage" ? SWAP_PERCENTAGE_CONTENT : SWAP_POINTS_CONTENT : MARGIN_CONTENT;
|
|
9126
|
+
const content = applyContentLabels(
|
|
9127
|
+
baseContent,
|
|
9128
|
+
bodyLabelsForMode(labels, isSwap, swapTab)
|
|
9129
|
+
);
|
|
9013
9130
|
const heading = title ?? content.title;
|
|
9014
9131
|
const desc = description ?? content.description;
|
|
9132
|
+
const swapTabs = swapTabsForLabels(labels);
|
|
9015
9133
|
return /* @__PURE__ */ jsx61("section", { className: ["tchow-section", className ?? ""].filter(Boolean).join(" "), ...props, children: /* @__PURE__ */ jsxs57("div", { className: "tchow-container", children: [
|
|
9016
9134
|
/* @__PURE__ */ jsxs57("div", { className: "tchow-intro", children: [
|
|
9017
9135
|
/* @__PURE__ */ jsx61("h2", { className: "tchow-title", children: heading }),
|
|
@@ -9021,7 +9139,7 @@ var TradingCalculatorHowTo = ({
|
|
|
9021
9139
|
Tabs,
|
|
9022
9140
|
{
|
|
9023
9141
|
className: "tchow-tabs",
|
|
9024
|
-
items:
|
|
9142
|
+
items: swapTabs,
|
|
9025
9143
|
activeId: swapTab,
|
|
9026
9144
|
onChange: (id) => setSwapTab(id)
|
|
9027
9145
|
}
|
|
@@ -9346,9 +9464,11 @@ function browserSupportsMarketStreaming() {
|
|
|
9346
9464
|
|
|
9347
9465
|
// templates/cryptoMarketData/conversion.ts
|
|
9348
9466
|
function convertAmounts(options) {
|
|
9467
|
+
const waitingForPrice = options.messages?.waitingForPrice ?? "Waiting for a live price";
|
|
9468
|
+
const invalidAmount = options.messages?.invalidAmount ?? "Enter a valid amount";
|
|
9349
9469
|
const price = options.price;
|
|
9350
9470
|
if (price == null || !Number.isFinite(price) || price <= 0) {
|
|
9351
|
-
return { pay: options.payInput, receive: options.receiveInput, valid: false, error:
|
|
9471
|
+
return { pay: options.payInput, receive: options.receiveInput, valid: false, error: waitingForPrice };
|
|
9352
9472
|
}
|
|
9353
9473
|
const source = options.edited === "pay" ? options.payInput : options.receiveInput;
|
|
9354
9474
|
const trimmed = source.trim();
|
|
@@ -9361,7 +9481,7 @@ function convertAmounts(options) {
|
|
|
9361
9481
|
pay: options.payInput,
|
|
9362
9482
|
receive: options.receiveInput,
|
|
9363
9483
|
valid: false,
|
|
9364
|
-
error:
|
|
9484
|
+
error: invalidAmount
|
|
9365
9485
|
};
|
|
9366
9486
|
}
|
|
9367
9487
|
if (options.side === "buy") {
|
|
@@ -9906,9 +10026,39 @@ function useCryptoMarketData(options) {
|
|
|
9906
10026
|
return snapshot;
|
|
9907
10027
|
}
|
|
9908
10028
|
|
|
10029
|
+
// templates/CryptoTradeConverter/CryptoTradeConverter.types.ts
|
|
10030
|
+
var DEFAULT_CRYPTO_TRADE_CONVERTER_TITLE = "Buy and sell in seconds";
|
|
10031
|
+
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.";
|
|
10032
|
+
var DEFAULT_CRYPTO_TRADE_CONVERTER_LABELS = {
|
|
10033
|
+
buy: "Buy",
|
|
10034
|
+
sell: "Sell",
|
|
10035
|
+
connecting: "Connecting to live prices\u2026",
|
|
10036
|
+
livePrices: "Live prices",
|
|
10037
|
+
waitingForPrice: "Waiting for a live price",
|
|
10038
|
+
unsupportedBrowser: "Please use a current browser to view live prices.",
|
|
10039
|
+
selectMarket: "Select a market",
|
|
10040
|
+
chooseMarket: "Choose a market",
|
|
10041
|
+
tradeSideGroup: "Trade side",
|
|
10042
|
+
youPay: "You pay",
|
|
10043
|
+
youReceive: "You receive",
|
|
10044
|
+
amountToSpend: "Amount to spend",
|
|
10045
|
+
primaryAmountAria: "Primary trade amount",
|
|
10046
|
+
convertedAmountAria: "Converted trade amount",
|
|
10047
|
+
estimateTemplate: "Estimate at 1 {base} = {price} {quote}. Fees and spread excluded.",
|
|
10048
|
+
change24hSuffix: "(24h)",
|
|
10049
|
+
waitingForLivePrice: "Waiting for live price\u2026",
|
|
10050
|
+
invalidAmount: "Enter a valid amount"
|
|
10051
|
+
};
|
|
10052
|
+
|
|
9909
10053
|
// templates/CryptoTradeConverter/CryptoTradeConverter.tsx
|
|
9910
10054
|
import { Fragment as Fragment14, jsx as jsx62, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
9911
10055
|
var DEFAULT_TRADE_HREF = "https://deriv.exchange";
|
|
10056
|
+
function fillTemplate3(template, values) {
|
|
10057
|
+
return template.replace(/\{(\w+)\}/g, (_, key) => values[key] ?? "");
|
|
10058
|
+
}
|
|
10059
|
+
function mergeLabels2(overrides) {
|
|
10060
|
+
return { ...DEFAULT_CRYPTO_TRADE_CONVERTER_LABELS, ...overrides };
|
|
10061
|
+
}
|
|
9912
10062
|
function matchPair(rows, defaultPair) {
|
|
9913
10063
|
if (!rows.length) return null;
|
|
9914
10064
|
if (!defaultPair) {
|
|
@@ -9961,8 +10111,12 @@ var CryptoTradeConverter = ({
|
|
|
9961
10111
|
defaultPair,
|
|
9962
10112
|
tradeHref = DEFAULT_TRADE_HREF,
|
|
9963
10113
|
apiOrigin,
|
|
10114
|
+
title = DEFAULT_CRYPTO_TRADE_CONVERTER_TITLE,
|
|
10115
|
+
subtitle = DEFAULT_CRYPTO_TRADE_CONVERTER_SUBTITLE,
|
|
10116
|
+
labels: labelsProp,
|
|
9964
10117
|
className
|
|
9965
10118
|
}) => {
|
|
10119
|
+
const copy = mergeLabels2(labelsProp);
|
|
9966
10120
|
const reactId = useId7().replace(/:/g, "");
|
|
9967
10121
|
const listboxId = `ctc-listbox-${reactId}`;
|
|
9968
10122
|
const payId = `ctc-pay-${reactId}`;
|
|
@@ -9990,9 +10144,13 @@ var CryptoTradeConverter = ({
|
|
|
9990
10144
|
price: selected?.last ?? null,
|
|
9991
10145
|
payInput: pay,
|
|
9992
10146
|
receiveInput: receive,
|
|
9993
|
-
edited
|
|
10147
|
+
edited,
|
|
10148
|
+
messages: {
|
|
10149
|
+
waitingForPrice: copy.waitingForPrice,
|
|
10150
|
+
invalidAmount: copy.invalidAmount
|
|
10151
|
+
}
|
|
9994
10152
|
}),
|
|
9995
|
-
[side, selected?.last, pay, receive, edited]
|
|
10153
|
+
[side, selected?.last, pay, receive, edited, copy.waitingForPrice, copy.invalidAmount]
|
|
9996
10154
|
);
|
|
9997
10155
|
useEffect21(() => {
|
|
9998
10156
|
if (edited === "pay") setReceive(conversion.receive);
|
|
@@ -10063,8 +10221,12 @@ var CryptoTradeConverter = ({
|
|
|
10063
10221
|
const changeClass = selected?.change24hPct == null ? "" : selected.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
|
|
10064
10222
|
const payValue = edited === "pay" ? pay : conversion.pay;
|
|
10065
10223
|
const receiveValue = edited === "receive" ? receive : conversion.receive;
|
|
10066
|
-
const receiveMeta = priceReady && selected ?
|
|
10067
|
-
|
|
10224
|
+
const receiveMeta = priceReady && selected ? fillTemplate3(copy.estimateTemplate, {
|
|
10225
|
+
base: selected.base,
|
|
10226
|
+
price: formatPrice(selected.last, selected.pricePrecision),
|
|
10227
|
+
quote: selected.quote
|
|
10228
|
+
}) : snapshot.status === "unsupported" ? copy.unsupportedBrowser : conversion.error || (snapshot.status === "idle" || snapshot.status === "connecting" ? copy.connecting : copy.waitingForLivePrice);
|
|
10229
|
+
const ctaLabel = side === "buy" ? copy.buy : copy.sell;
|
|
10068
10230
|
const ctaClass = ["ctc-cta__btn", side === "sell" ? "is-sell" : "is-buy"].join(" ");
|
|
10069
10231
|
return /* @__PURE__ */ jsx62(
|
|
10070
10232
|
"section",
|
|
@@ -10076,8 +10238,8 @@ var CryptoTradeConverter = ({
|
|
|
10076
10238
|
"aria-labelledby": `ctc-heading-${reactId}`,
|
|
10077
10239
|
children: /* @__PURE__ */ jsxs58("div", { className: "ctc-container", children: [
|
|
10078
10240
|
/* @__PURE__ */ jsxs58("header", { className: "ctc-header", children: [
|
|
10079
|
-
/* @__PURE__ */ jsx62("h2", { id: `ctc-heading-${reactId}`, className: "ctc-title", children:
|
|
10080
|
-
/* @__PURE__ */ jsx62("p", { className: "ctc-subtitle", children:
|
|
10241
|
+
/* @__PURE__ */ jsx62("h2", { id: `ctc-heading-${reactId}`, className: "ctc-title", children: title }),
|
|
10242
|
+
/* @__PURE__ */ jsx62("p", { className: "ctc-subtitle", children: subtitle })
|
|
10081
10243
|
] }),
|
|
10082
10244
|
/* @__PURE__ */ jsx62("div", { className: "ctc-card", children: /* @__PURE__ */ jsxs58("div", { className: "ctc-widget", children: [
|
|
10083
10245
|
/* @__PURE__ */ jsxs58(
|
|
@@ -10089,7 +10251,7 @@ var CryptoTradeConverter = ({
|
|
|
10089
10251
|
"aria-live": "polite",
|
|
10090
10252
|
children: [
|
|
10091
10253
|
/* @__PURE__ */ jsx62("span", { className: "ctc-status-dot", "aria-hidden": "true" }),
|
|
10092
|
-
/* @__PURE__ */ jsx62("span", { children: snapshot.status === "idle" || snapshot.status === "connecting" ?
|
|
10254
|
+
/* @__PURE__ */ jsx62("span", { children: snapshot.status === "idle" || snapshot.status === "connecting" ? copy.connecting : snapshot.statusMessage || (priceReady ? copy.livePrices : copy.waitingForLivePrice) })
|
|
10093
10255
|
]
|
|
10094
10256
|
}
|
|
10095
10257
|
),
|
|
@@ -10129,12 +10291,13 @@ var CryptoTradeConverter = ({
|
|
|
10129
10291
|
" ",
|
|
10130
10292
|
/* @__PURE__ */ jsxs58("span", { className: ["ctc-change", changeClass].filter(Boolean).join(" "), children: [
|
|
10131
10293
|
formatPct(selected.change24hPct),
|
|
10132
|
-
"
|
|
10294
|
+
" ",
|
|
10295
|
+
copy.change24hSuffix
|
|
10133
10296
|
] })
|
|
10134
10297
|
] })
|
|
10135
10298
|
] })
|
|
10136
10299
|
] }) : /* @__PURE__ */ jsxs58("span", { className: "ctc-pair__meta", children: [
|
|
10137
|
-
/* @__PURE__ */ jsx62("span", { className: "ctc-pair__name", children:
|
|
10300
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-pair__name", children: copy.selectMarket }),
|
|
10138
10301
|
/* @__PURE__ */ jsx62("span", { className: "ctc-pair__price", children: "\u2014" })
|
|
10139
10302
|
] }),
|
|
10140
10303
|
/* @__PURE__ */ jsx62(ChevronIcon4, { className: "ctc-pair__chevron" })
|
|
@@ -10148,11 +10311,11 @@ var CryptoTradeConverter = ({
|
|
|
10148
10311
|
id: listboxId,
|
|
10149
10312
|
className: "ctc-listbox",
|
|
10150
10313
|
role: "listbox",
|
|
10151
|
-
"aria-label":
|
|
10314
|
+
"aria-label": copy.chooseMarket,
|
|
10152
10315
|
tabIndex: -1,
|
|
10153
10316
|
onKeyDown: onPickerKeyDown,
|
|
10154
10317
|
children: [
|
|
10155
|
-
/* @__PURE__ */ jsx62("li", { className: "ctc-listbox__header", role: "presentation", children:
|
|
10318
|
+
/* @__PURE__ */ jsx62("li", { className: "ctc-listbox__header", role: "presentation", children: copy.chooseMarket }),
|
|
10156
10319
|
sortedRows.map((row, index) => {
|
|
10157
10320
|
const selectedOption = selected?.id === row.id;
|
|
10158
10321
|
const active = index === activeOption;
|
|
@@ -10192,7 +10355,7 @@ var CryptoTradeConverter = ({
|
|
|
10192
10355
|
}
|
|
10193
10356
|
) : null
|
|
10194
10357
|
] }),
|
|
10195
|
-
/* @__PURE__ */ jsxs58("div", { className: "ctc-seg", role: "group", "aria-label":
|
|
10358
|
+
/* @__PURE__ */ jsxs58("div", { className: "ctc-seg", role: "group", "aria-label": copy.tradeSideGroup, children: [
|
|
10196
10359
|
/* @__PURE__ */ jsx62(
|
|
10197
10360
|
"button",
|
|
10198
10361
|
{
|
|
@@ -10200,7 +10363,7 @@ var CryptoTradeConverter = ({
|
|
|
10200
10363
|
className: side === "buy" ? "ctc-seg__btn is-active is-buy" : "ctc-seg__btn is-buy",
|
|
10201
10364
|
"aria-pressed": side === "buy",
|
|
10202
10365
|
onClick: () => setSide("buy"),
|
|
10203
|
-
children:
|
|
10366
|
+
children: copy.buy
|
|
10204
10367
|
}
|
|
10205
10368
|
),
|
|
10206
10369
|
/* @__PURE__ */ jsx62(
|
|
@@ -10210,7 +10373,7 @@ var CryptoTradeConverter = ({
|
|
|
10210
10373
|
className: side === "sell" ? "ctc-seg__btn is-active is-sell" : "ctc-seg__btn is-sell",
|
|
10211
10374
|
"aria-pressed": side === "sell",
|
|
10212
10375
|
onClick: () => setSide("sell"),
|
|
10213
|
-
children:
|
|
10376
|
+
children: copy.sell
|
|
10214
10377
|
}
|
|
10215
10378
|
)
|
|
10216
10379
|
] }),
|
|
@@ -10221,7 +10384,7 @@ var CryptoTradeConverter = ({
|
|
|
10221
10384
|
className: ["ctc-amount", conversion.error ? "is-invalid" : ""].filter(Boolean).join(" "),
|
|
10222
10385
|
htmlFor: payId,
|
|
10223
10386
|
children: [
|
|
10224
|
-
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__label", children:
|
|
10387
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__label", children: copy.youPay }),
|
|
10225
10388
|
/* @__PURE__ */ jsxs58("span", { className: "ctc-amount__row", children: [
|
|
10226
10389
|
/* @__PURE__ */ jsx62(
|
|
10227
10390
|
"input",
|
|
@@ -10233,7 +10396,7 @@ var CryptoTradeConverter = ({
|
|
|
10233
10396
|
autoComplete: "off",
|
|
10234
10397
|
placeholder: "0.00",
|
|
10235
10398
|
value: payValue,
|
|
10236
|
-
"aria-label":
|
|
10399
|
+
"aria-label": copy.primaryAmountAria,
|
|
10237
10400
|
"aria-invalid": Boolean(conversion.error),
|
|
10238
10401
|
"aria-describedby": statusId,
|
|
10239
10402
|
onChange: (event) => {
|
|
@@ -10244,7 +10407,7 @@ var CryptoTradeConverter = ({
|
|
|
10244
10407
|
),
|
|
10245
10408
|
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__unit", children: labels.pay })
|
|
10246
10409
|
] }),
|
|
10247
|
-
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__meta", children:
|
|
10410
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__meta", children: copy.amountToSpend })
|
|
10248
10411
|
]
|
|
10249
10412
|
}
|
|
10250
10413
|
),
|
|
@@ -10254,7 +10417,7 @@ var CryptoTradeConverter = ({
|
|
|
10254
10417
|
className: ["ctc-amount", conversion.error ? "is-invalid" : ""].filter(Boolean).join(" "),
|
|
10255
10418
|
htmlFor: receiveId,
|
|
10256
10419
|
children: [
|
|
10257
|
-
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__label", children:
|
|
10420
|
+
/* @__PURE__ */ jsx62("span", { className: "ctc-amount__label", children: copy.youReceive }),
|
|
10258
10421
|
/* @__PURE__ */ jsxs58("span", { className: "ctc-amount__row", children: [
|
|
10259
10422
|
/* @__PURE__ */ jsx62(
|
|
10260
10423
|
"input",
|
|
@@ -10266,7 +10429,7 @@ var CryptoTradeConverter = ({
|
|
|
10266
10429
|
autoComplete: "off",
|
|
10267
10430
|
placeholder: "0.00",
|
|
10268
10431
|
value: receiveValue,
|
|
10269
|
-
"aria-label":
|
|
10432
|
+
"aria-label": copy.convertedAmountAria,
|
|
10270
10433
|
"aria-invalid": Boolean(conversion.error),
|
|
10271
10434
|
"aria-describedby": `ctc-rate-${reactId}`,
|
|
10272
10435
|
onChange: (event) => {
|
|
@@ -10309,7 +10472,37 @@ var CryptoTradeConverter = ({
|
|
|
10309
10472
|
|
|
10310
10473
|
// templates/CryptoMarketsTable/CryptoMarketsTable.tsx
|
|
10311
10474
|
import { useEffect as useEffect22, useId as useId8, useMemo as useMemo9, useRef as useRef24, useState as useState27 } from "react";
|
|
10475
|
+
|
|
10476
|
+
// templates/CryptoMarketsTable/CryptoMarketsTable.types.ts
|
|
10477
|
+
var DEFAULT_CRYPTO_MARKETS_TABLE_TITLE = "Explore the markets";
|
|
10478
|
+
var DEFAULT_CRYPTO_MARKETS_TABLE_LABELS = {
|
|
10479
|
+
spot: "Spot",
|
|
10480
|
+
futures: "Futures",
|
|
10481
|
+
live: "Live",
|
|
10482
|
+
connecting: "Connecting\u2026",
|
|
10483
|
+
marketTypeGroup: "Market type",
|
|
10484
|
+
quoteCurrencyTabs: "Quote currency",
|
|
10485
|
+
scrollRegion: "Market prices. Scroll horizontally to see all columns.",
|
|
10486
|
+
columnName: "Name",
|
|
10487
|
+
columnPrice: "Price",
|
|
10488
|
+
column1h: "1h %",
|
|
10489
|
+
column24h: "24h %",
|
|
10490
|
+
column7d: "7d chart",
|
|
10491
|
+
unsupportedBrowser: "Please use a current browser to view market prices.",
|
|
10492
|
+
loadError: "Unable to load market data. Retrying\u2026",
|
|
10493
|
+
loading: "Loading market data\u2026",
|
|
10494
|
+
emptyPairsTemplate: "No {quote} pairs on {kind} yet\u2026",
|
|
10495
|
+
sparklineAriaTemplate: "{name} available hourly price history, up to 7 days"
|
|
10496
|
+
};
|
|
10497
|
+
|
|
10498
|
+
// templates/CryptoMarketsTable/CryptoMarketsTable.tsx
|
|
10312
10499
|
import { jsx as jsx63, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
10500
|
+
function fillTemplate4(template, values) {
|
|
10501
|
+
return template.replace(/\{(\w+)\}/g, (_, key) => values[key] ?? "");
|
|
10502
|
+
}
|
|
10503
|
+
function mergeLabels3(overrides) {
|
|
10504
|
+
return { ...DEFAULT_CRYPTO_MARKETS_TABLE_LABELS, ...overrides };
|
|
10505
|
+
}
|
|
10313
10506
|
function CoinAvatar2({ base, icon }) {
|
|
10314
10507
|
const [failed, setFailed] = useState27(false);
|
|
10315
10508
|
if (failed) {
|
|
@@ -10415,8 +10608,11 @@ var CryptoMarketsTable = ({
|
|
|
10415
10608
|
initialQuoteCurrency = "USDT",
|
|
10416
10609
|
apiOrigin,
|
|
10417
10610
|
maxRows,
|
|
10611
|
+
title = DEFAULT_CRYPTO_MARKETS_TABLE_TITLE,
|
|
10612
|
+
labels: labelsProp,
|
|
10418
10613
|
className
|
|
10419
10614
|
}) => {
|
|
10615
|
+
const copy = mergeLabels3(labelsProp);
|
|
10420
10616
|
const reactId = useId8().replace(/:/g, "");
|
|
10421
10617
|
const [kind, setKind] = useState27(initialMarket);
|
|
10422
10618
|
const [quote, setQuote] = useState27(initialQuoteCurrency.toUpperCase());
|
|
@@ -10463,7 +10659,14 @@ var CryptoMarketsTable = ({
|
|
|
10463
10659
|
}
|
|
10464
10660
|
};
|
|
10465
10661
|
const statusTone = snapshot.status === "live" ? "live" : snapshot.status === "reconnecting" || snapshot.status === "stale" ? "warn" : snapshot.status === "error" || snapshot.status === "unsupported" ? "error" : "muted";
|
|
10466
|
-
const emptyMessage = snapshot.status === "unsupported" ?
|
|
10662
|
+
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 });
|
|
10663
|
+
const columnLabels = [
|
|
10664
|
+
["name", copy.columnName],
|
|
10665
|
+
["last", copy.columnPrice],
|
|
10666
|
+
["change1hPct", copy.column1h],
|
|
10667
|
+
["change24hPct", copy.column24h],
|
|
10668
|
+
["change7dPct", copy.column7d]
|
|
10669
|
+
];
|
|
10467
10670
|
return /* @__PURE__ */ jsx63(
|
|
10468
10671
|
"section",
|
|
10469
10672
|
{
|
|
@@ -10472,26 +10675,26 @@ var CryptoMarketsTable = ({
|
|
|
10472
10675
|
"aria-labelledby": `cmt-heading-${reactId}`,
|
|
10473
10676
|
children: /* @__PURE__ */ jsxs59("div", { className: "cmt-container", children: [
|
|
10474
10677
|
/* @__PURE__ */ jsxs59("header", { className: "cmt-header", children: [
|
|
10475
|
-
/* @__PURE__ */ jsx63("h2", { id: `cmt-heading-${reactId}`, className: "cmt-title", children:
|
|
10678
|
+
/* @__PURE__ */ jsx63("h2", { id: `cmt-heading-${reactId}`, className: "cmt-title", children: title }),
|
|
10476
10679
|
/* @__PURE__ */ jsxs59("p", { className: `cmt-status cmt-status--${statusTone}`, role: "status", "aria-live": "polite", children: [
|
|
10477
10680
|
/* @__PURE__ */ jsx63("span", { className: "cmt-status-dot", "aria-hidden": "true" }),
|
|
10478
|
-
/* @__PURE__ */ jsx63("span", { children: snapshot.status === "live" ?
|
|
10681
|
+
/* @__PURE__ */ jsx63("span", { children: snapshot.status === "live" ? copy.live : snapshot.statusMessage || copy.connecting })
|
|
10479
10682
|
] })
|
|
10480
10683
|
] }),
|
|
10481
10684
|
/* @__PURE__ */ jsxs59("div", { className: "cmt-card", children: [
|
|
10482
10685
|
/* @__PURE__ */ jsxs59("div", { className: "cmt-toolbar", children: [
|
|
10483
|
-
/* @__PURE__ */ jsx63("div", { className: "cmt-seg", role: "group", "aria-label":
|
|
10686
|
+
/* @__PURE__ */ jsx63("div", { className: "cmt-seg", role: "group", "aria-label": copy.marketTypeGroup, children: ["spot", "futures"].map((value) => /* @__PURE__ */ jsx63(
|
|
10484
10687
|
"button",
|
|
10485
10688
|
{
|
|
10486
10689
|
type: "button",
|
|
10487
10690
|
className: kind === value ? "cmt-seg__btn is-active" : "cmt-seg__btn",
|
|
10488
10691
|
"aria-pressed": kind === value,
|
|
10489
10692
|
onClick: () => setKind(value),
|
|
10490
|
-
children: value === "spot" ?
|
|
10693
|
+
children: value === "spot" ? copy.spot : copy.futures
|
|
10491
10694
|
},
|
|
10492
10695
|
value
|
|
10493
10696
|
)) }),
|
|
10494
|
-
/* @__PURE__ */ jsx63("div", { className: "cmt-tabs", role: "tablist", "aria-label":
|
|
10697
|
+
/* @__PURE__ */ jsx63("div", { className: "cmt-tabs", role: "tablist", "aria-label": copy.quoteCurrencyTabs, children: snapshot.quotes.map((q) => /* @__PURE__ */ jsx63(
|
|
10495
10698
|
"button",
|
|
10496
10699
|
{
|
|
10497
10700
|
type: "button",
|
|
@@ -10511,15 +10714,9 @@ var CryptoMarketsTable = ({
|
|
|
10511
10714
|
className: ["cmt-scroll", scrolled ? "is-scrolled" : ""].filter(Boolean).join(" "),
|
|
10512
10715
|
tabIndex: 0,
|
|
10513
10716
|
role: "region",
|
|
10514
|
-
"aria-label":
|
|
10717
|
+
"aria-label": copy.scrollRegion,
|
|
10515
10718
|
children: /* @__PURE__ */ jsxs59("table", { className: "cmt-table", children: [
|
|
10516
|
-
/* @__PURE__ */ jsx63("thead", { children: /* @__PURE__ */ jsx63("tr", { children: [
|
|
10517
|
-
["name", "Name"],
|
|
10518
|
-
["last", "Price"],
|
|
10519
|
-
["change1hPct", "1h %"],
|
|
10520
|
-
["change24hPct", "24h %"],
|
|
10521
|
-
["change7dPct", "7d chart"]
|
|
10522
|
-
].map(([key, label]) => {
|
|
10719
|
+
/* @__PURE__ */ jsx63("thead", { children: /* @__PURE__ */ jsx63("tr", { children: columnLabels.map(([key, label]) => {
|
|
10523
10720
|
const active = sortKey === key;
|
|
10524
10721
|
return /* @__PURE__ */ jsx63(
|
|
10525
10722
|
"th",
|
|
@@ -10564,7 +10761,9 @@ var CryptoMarketsTable = ({
|
|
|
10564
10761
|
{
|
|
10565
10762
|
values: row.spark7d,
|
|
10566
10763
|
up: (row.change7dPct ?? 0) >= 0,
|
|
10567
|
-
label:
|
|
10764
|
+
label: fillTemplate4(copy.sparklineAriaTemplate, {
|
|
10765
|
+
name: row.name
|
|
10766
|
+
}),
|
|
10568
10767
|
reducedMotion
|
|
10569
10768
|
}
|
|
10570
10769
|
) })
|
|
@@ -12221,10 +12420,17 @@ export {
|
|
|
12221
12420
|
CryptoMarketsTable,
|
|
12222
12421
|
CryptoTradeConverter,
|
|
12223
12422
|
DEFAULT_AWARDS,
|
|
12423
|
+
DEFAULT_CRYPTO_MARKETS_TABLE_LABELS,
|
|
12424
|
+
DEFAULT_CRYPTO_MARKETS_TABLE_TITLE,
|
|
12425
|
+
DEFAULT_CRYPTO_TRADE_CONVERTER_LABELS,
|
|
12426
|
+
DEFAULT_CRYPTO_TRADE_CONVERTER_SUBTITLE,
|
|
12427
|
+
DEFAULT_CRYPTO_TRADE_CONVERTER_TITLE,
|
|
12224
12428
|
DEFAULT_CULTURE_CARDS,
|
|
12225
12429
|
DEFAULT_EXCHANGE_RATE_WS_URL,
|
|
12226
12430
|
DEFAULT_SYMBOLS_ENDPOINT,
|
|
12227
12431
|
DEFAULT_TRADE_HREF,
|
|
12432
|
+
DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS,
|
|
12433
|
+
DEFAULT_TRADING_CALCULATOR_LABELS,
|
|
12228
12434
|
DayNightTransition,
|
|
12229
12435
|
DocumentChips,
|
|
12230
12436
|
DotLottieInView,
|