@deriv-web-design/ui 0.1.36 → 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/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") {
@@ -9063,6 +9113,7 @@ var TradingCalculatorHowTo = ({
9063
9113
  variant = "margin",
9064
9114
  title,
9065
9115
  description,
9116
+ labels,
9066
9117
  className,
9067
9118
  ...props
9068
9119
  }) => {
@@ -9071,9 +9122,14 @@ var TradingCalculatorHowTo = ({
9071
9122
  useEffect19(() => {
9072
9123
  setSwapTab(swapModeForVariant(variant));
9073
9124
  }, [variant]);
9074
- const content = variant === "pip" ? PIP_CONTENT : isSwap ? swapTab === "percentage" ? SWAP_PERCENTAGE_CONTENT : SWAP_POINTS_CONTENT : MARGIN_CONTENT;
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
+ );
9075
9130
  const heading = title ?? content.title;
9076
9131
  const desc = description ?? content.description;
9132
+ const swapTabs = swapTabsForLabels(labels);
9077
9133
  return /* @__PURE__ */ jsx61("section", { className: ["tchow-section", className ?? ""].filter(Boolean).join(" "), ...props, children: /* @__PURE__ */ jsxs57("div", { className: "tchow-container", children: [
9078
9134
  /* @__PURE__ */ jsxs57("div", { className: "tchow-intro", children: [
9079
9135
  /* @__PURE__ */ jsx61("h2", { className: "tchow-title", children: heading }),
@@ -9083,7 +9139,7 @@ var TradingCalculatorHowTo = ({
9083
9139
  Tabs,
9084
9140
  {
9085
9141
  className: "tchow-tabs",
9086
- items: SWAP_TABS,
9142
+ items: swapTabs,
9087
9143
  activeId: swapTab,
9088
9144
  onChange: (id) => setSwapTab(id)
9089
9145
  }
@@ -12373,6 +12429,7 @@ export {
12373
12429
  DEFAULT_EXCHANGE_RATE_WS_URL,
12374
12430
  DEFAULT_SYMBOLS_ENDPOINT,
12375
12431
  DEFAULT_TRADE_HREF,
12432
+ DEFAULT_TRADING_CALCULATOR_HOWTO_LABELS,
12376
12433
  DEFAULT_TRADING_CALCULATOR_LABELS,
12377
12434
  DayNightTransition,
12378
12435
  DocumentChips,