@deriv-web-design/ui 0.1.36 → 0.1.38
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 +69 -1
- package/components.manifest.json +5 -0
- package/dist/index.css +23 -18
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +53 -2
- package/dist/index.d.ts +53 -2
- package/dist/index.js +78 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8811,7 +8811,53 @@ var TradingCalculator = ({
|
|
|
8811
8811
|
|
|
8812
8812
|
// templates/TradingCalculatorHowTo/TradingCalculatorHowTo.tsx
|
|
8813
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
|
|
8814
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
|
+
}
|
|
8815
8861
|
var MARGIN_CONTENT = {
|
|
8816
8862
|
title: "How to calculate margin requirements",
|
|
8817
8863
|
description: "Use this formula to calculate how much margin is required based on your lot size, leverage ratio, and the current market price.",
|
|
@@ -8956,11 +9002,15 @@ var SWAP_PERCENTAGE_CONTENT = {
|
|
|
8956
9002
|
],
|
|
8957
9003
|
resultText: "This means the swap charge is USD -0.26 to keep the position open overnight."
|
|
8958
9004
|
};
|
|
8959
|
-
var SWAP_TABS = [
|
|
8960
|
-
{ id: "points", label: "Swap calculation (In points)" },
|
|
8961
|
-
{ id: "percentage", label: "Swap calculation (In percentage)" }
|
|
8962
|
-
];
|
|
8963
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
|
+
}
|
|
8964
9014
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect3 : useEffect19;
|
|
8965
9015
|
var FormulaBlockView = ({ block }) => {
|
|
8966
9016
|
if (block.type === "footnote") {
|
|
@@ -9040,19 +9090,20 @@ var CalculationStrip = ({ tokens }) => {
|
|
|
9040
9090
|
)
|
|
9041
9091
|
}
|
|
9042
9092
|
),
|
|
9043
|
-
/* @__PURE__ */ jsx61(
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9093
|
+
/* @__PURE__ */ jsx61(
|
|
9094
|
+
"span",
|
|
9095
|
+
{
|
|
9096
|
+
className: [
|
|
9097
|
+
"tchow-stripCaption",
|
|
9098
|
+
token.label ? "tchow-stripCaption--labeled" : ""
|
|
9099
|
+
].filter(Boolean).join(" "),
|
|
9100
|
+
"aria-hidden": "true",
|
|
9101
|
+
children: token.label && /* @__PURE__ */ jsxs57(Fragment13, { children: [
|
|
9102
|
+
/* @__PURE__ */ jsx61(ConnectorArrow, {}),
|
|
9103
|
+
/* @__PURE__ */ jsx61("span", { className: "tchow-stripLabel", children: /* @__PURE__ */ jsx61("span", { className: "tchow-stripLabelText", children: token.label }) })
|
|
9104
|
+
] })
|
|
9105
|
+
}
|
|
9106
|
+
)
|
|
9056
9107
|
] }, i))
|
|
9057
9108
|
}
|
|
9058
9109
|
)
|
|
@@ -9063,6 +9114,7 @@ var TradingCalculatorHowTo = ({
|
|
|
9063
9114
|
variant = "margin",
|
|
9064
9115
|
title,
|
|
9065
9116
|
description,
|
|
9117
|
+
labels,
|
|
9066
9118
|
className,
|
|
9067
9119
|
...props
|
|
9068
9120
|
}) => {
|
|
@@ -9071,9 +9123,14 @@ var TradingCalculatorHowTo = ({
|
|
|
9071
9123
|
useEffect19(() => {
|
|
9072
9124
|
setSwapTab(swapModeForVariant(variant));
|
|
9073
9125
|
}, [variant]);
|
|
9074
|
-
const
|
|
9126
|
+
const baseContent = variant === "pip" ? PIP_CONTENT : isSwap ? swapTab === "percentage" ? SWAP_PERCENTAGE_CONTENT : SWAP_POINTS_CONTENT : MARGIN_CONTENT;
|
|
9127
|
+
const content = applyContentLabels(
|
|
9128
|
+
baseContent,
|
|
9129
|
+
bodyLabelsForMode(labels, isSwap, swapTab)
|
|
9130
|
+
);
|
|
9075
9131
|
const heading = title ?? content.title;
|
|
9076
9132
|
const desc = description ?? content.description;
|
|
9133
|
+
const swapTabs = swapTabsForLabels(labels);
|
|
9077
9134
|
return /* @__PURE__ */ jsx61("section", { className: ["tchow-section", className ?? ""].filter(Boolean).join(" "), ...props, children: /* @__PURE__ */ jsxs57("div", { className: "tchow-container", children: [
|
|
9078
9135
|
/* @__PURE__ */ jsxs57("div", { className: "tchow-intro", children: [
|
|
9079
9136
|
/* @__PURE__ */ jsx61("h2", { className: "tchow-title", children: heading }),
|
|
@@ -9083,7 +9140,7 @@ var TradingCalculatorHowTo = ({
|
|
|
9083
9140
|
Tabs,
|
|
9084
9141
|
{
|
|
9085
9142
|
className: "tchow-tabs",
|
|
9086
|
-
items:
|
|
9143
|
+
items: swapTabs,
|
|
9087
9144
|
activeId: swapTab,
|
|
9088
9145
|
onChange: (id) => setSwapTab(id)
|
|
9089
9146
|
}
|
|
@@ -12373,6 +12430,7 @@ export {
|
|
|
12373
12430
|
DEFAULT_EXCHANGE_RATE_WS_URL,
|
|
12374
12431
|
DEFAULT_SYMBOLS_ENDPOINT,
|
|
12375
12432
|
DEFAULT_TRADE_HREF,
|
|
12433
|
+
DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS,
|
|
12376
12434
|
DEFAULT_TRADING_CALCULATOR_LABELS,
|
|
12377
12435
|
DayNightTransition,
|
|
12378
12436
|
DocumentChips,
|