@deriv-web-design/ui 0.1.34 → 0.1.35

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
@@ -9578,8 +9578,8 @@ function createMarketFeed(discovered, handlers, options = {}) {
9578
9578
  const resolved = resolveMetaId(key, meta);
9579
9579
  if (!resolved) continue;
9580
9580
  applyTick(resolved.id, resolved.meta, tick);
9581
- subscribeTicker(resolved.id);
9582
- subscribeKline(resolved.id);
9581
+ subscribeTicker(key);
9582
+ subscribeKline(key);
9583
9583
  }
9584
9584
  return;
9585
9585
  }
@@ -9928,8 +9928,8 @@ function CoinAvatar({ base, icon, label }) {
9928
9928
  className: "ctc-avatar",
9929
9929
  src: icon,
9930
9930
  alt: "",
9931
- width: 32,
9932
- height: 32,
9931
+ width: 30,
9932
+ height: 30,
9933
9933
  loading: "lazy",
9934
9934
  decoding: "async",
9935
9935
  onError: () => setFailed(true),
@@ -9937,6 +9937,24 @@ function CoinAvatar({ base, icon, label }) {
9937
9937
  }
9938
9938
  );
9939
9939
  }
9940
+ function ChevronIcon4({ className }) {
9941
+ return /* @__PURE__ */ jsx62(
9942
+ "svg",
9943
+ {
9944
+ className,
9945
+ width: 20,
9946
+ height: 20,
9947
+ viewBox: "0 0 24 24",
9948
+ fill: "none",
9949
+ stroke: "currentColor",
9950
+ strokeWidth: "2.2",
9951
+ strokeLinecap: "round",
9952
+ strokeLinejoin: "round",
9953
+ "aria-hidden": "true",
9954
+ children: /* @__PURE__ */ jsx62("polyline", { points: "6 9 12 15 18 9" })
9955
+ }
9956
+ );
9957
+ }
9940
9958
  var CryptoTradeConverter = ({
9941
9959
  variant: _variant = "default",
9942
9960
  market: _market = "spot",
@@ -10043,6 +10061,11 @@ var CryptoTradeConverter = ({
10043
10061
  const priceReady = selected?.last != null && Number.isFinite(selected.last) && selected.last > 0;
10044
10062
  const ctaDisabled = !priceReady || snapshot.status === "unsupported" || snapshot.status === "error" || !conversion.valid;
10045
10063
  const changeClass = selected?.change24hPct == null ? "" : selected.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
10064
+ const payValue = edited === "pay" ? pay : conversion.pay;
10065
+ const receiveValue = edited === "receive" ? receive : conversion.receive;
10066
+ const receiveMeta = priceReady && selected ? `Estimate at 1 ${selected.base} = ${formatPrice(selected.last, selected.pricePrecision)} ${selected.quote}. Fees and spread excluded.` : snapshot.status === "unsupported" ? "Please use a current browser to view live prices." : conversion.error || (snapshot.status === "idle" || snapshot.status === "connecting" ? "Connecting to live prices\u2026" : "Waiting for live price\u2026");
10067
+ const ctaLabel = side === "buy" ? "Buy" : "Sell";
10068
+ const ctaClass = ["ctc-cta__btn", side === "sell" ? "is-sell" : "is-buy"].join(" ");
10046
10069
  return /* @__PURE__ */ jsx62(
10047
10070
  "section",
10048
10071
  {
@@ -10056,33 +10079,20 @@ var CryptoTradeConverter = ({
10056
10079
  /* @__PURE__ */ jsx62("h2", { id: `ctc-heading-${reactId}`, className: "ctc-title", children: "Buy and sell in seconds" }),
10057
10080
  /* @__PURE__ */ jsx62("p", { className: "ctc-subtitle", children: "Choose your asset, enter an amount, and confirm. Your crypto lands in your account instantly, ready to trade, hold, or withdraw whenever you want." })
10058
10081
  ] }),
10059
- /* @__PURE__ */ jsxs58("div", { className: "ctc-card", children: [
10060
- /* @__PURE__ */ jsxs58("div", { className: `ctc-status ctc-status--${statusTone}`, id: statusId, role: "status", "aria-live": "polite", children: [
10061
- /* @__PURE__ */ jsx62("span", { className: "ctc-status-dot", "aria-hidden": "true" }),
10062
- /* @__PURE__ */ jsx62("span", { children: snapshot.status === "idle" || snapshot.status === "connecting" ? "Connecting to live prices\u2026" : snapshot.statusMessage || (priceReady ? "Live prices" : "Waiting for live price\u2026") })
10063
- ] }),
10064
- /* @__PURE__ */ jsxs58("div", { className: "ctc-seg", role: "group", "aria-label": "Trade side", children: [
10065
- /* @__PURE__ */ jsx62(
10066
- "button",
10067
- {
10068
- type: "button",
10069
- className: side === "buy" ? "ctc-seg__btn is-active is-buy" : "ctc-seg__btn is-buy",
10070
- "aria-pressed": side === "buy",
10071
- onClick: () => setSide("buy"),
10072
- children: "Buy"
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
- ] }),
10082
+ /* @__PURE__ */ jsx62("div", { className: "ctc-card", children: /* @__PURE__ */ jsxs58("div", { className: "ctc-widget", children: [
10083
+ /* @__PURE__ */ jsxs58(
10084
+ "div",
10085
+ {
10086
+ className: `ctc-status ctc-status--${statusTone}`,
10087
+ id: statusId,
10088
+ role: "status",
10089
+ "aria-live": "polite",
10090
+ children: [
10091
+ /* @__PURE__ */ jsx62("span", { className: "ctc-status-dot", "aria-hidden": "true" }),
10092
+ /* @__PURE__ */ jsx62("span", { children: snapshot.status === "idle" || snapshot.status === "connecting" ? "Connecting to live prices\u2026" : snapshot.statusMessage || (priceReady ? "Live prices" : "Waiting for live price\u2026") })
10093
+ ]
10094
+ }
10095
+ ),
10086
10096
  /* @__PURE__ */ jsxs58("div", { className: "ctc-pair", children: [
10087
10097
  /* @__PURE__ */ jsxs58(
10088
10098
  "button",
@@ -10127,129 +10137,171 @@ var CryptoTradeConverter = ({
10127
10137
  /* @__PURE__ */ jsx62("span", { className: "ctc-pair__name", children: "Select a market" }),
10128
10138
  /* @__PURE__ */ jsx62("span", { className: "ctc-pair__price", children: "\u2014" })
10129
10139
  ] }),
10130
- /* @__PURE__ */ jsx62("span", { className: "ctc-pair__chevron", "aria-hidden": "true", children: "\u25BE" })
10140
+ /* @__PURE__ */ jsx62(ChevronIcon4, { className: "ctc-pair__chevron" })
10131
10141
  ]
10132
10142
  }
10133
10143
  ),
10134
- pickerOpen ? /* @__PURE__ */ jsx62(
10144
+ pickerOpen ? /* @__PURE__ */ jsxs58(
10135
10145
  "ul",
10136
10146
  {
10137
10147
  ref: listRef,
10138
10148
  id: listboxId,
10139
10149
  className: "ctc-listbox",
10140
10150
  role: "listbox",
10141
- "aria-label": "Market pairs",
10151
+ "aria-label": "Choose a market",
10142
10152
  tabIndex: -1,
10143
10153
  onKeyDown: onPickerKeyDown,
10144
- children: sortedRows.map((row, index) => {
10145
- const selectedOption = selected?.id === row.id;
10146
- const active = index === activeOption;
10147
- const rowChange = row.change24hPct == null ? "" : row.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
10148
- return /* @__PURE__ */ jsxs58(
10149
- "li",
10150
- {
10151
- id: `${listboxId}-opt-${index}`,
10152
- role: "option",
10153
- "aria-selected": selectedOption,
10154
- className: [
10155
- "ctc-option",
10156
- active ? "is-active" : "",
10157
- selectedOption ? "is-selected" : ""
10158
- ].filter(Boolean).join(" "),
10159
- onMouseEnter: () => setActiveOption(index),
10160
- onClick: () => {
10161
- setSelectedId(row.id);
10162
- closePicker();
10154
+ children: [
10155
+ /* @__PURE__ */ jsx62("li", { className: "ctc-listbox__header", role: "presentation", children: "Choose a market" }),
10156
+ sortedRows.map((row, index) => {
10157
+ const selectedOption = selected?.id === row.id;
10158
+ const active = index === activeOption;
10159
+ const rowChange = row.change24hPct == null ? "" : row.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
10160
+ return /* @__PURE__ */ jsxs58(
10161
+ "li",
10162
+ {
10163
+ id: `${listboxId}-opt-${index}`,
10164
+ role: "option",
10165
+ "aria-selected": selectedOption,
10166
+ className: [
10167
+ "ctc-option",
10168
+ active ? "is-active" : "",
10169
+ selectedOption ? "is-selected" : ""
10170
+ ].filter(Boolean).join(" "),
10171
+ onMouseEnter: () => setActiveOption(index),
10172
+ onClick: () => {
10173
+ setSelectedId(row.id);
10174
+ closePicker();
10175
+ },
10176
+ children: [
10177
+ /* @__PURE__ */ jsx62(CoinAvatar, { base: row.base, icon: row.icon, label: row.name }),
10178
+ /* @__PURE__ */ jsxs58("span", { className: "ctc-option__text", children: [
10179
+ /* @__PURE__ */ jsx62("span", { className: "ctc-option__name", children: row.name }),
10180
+ /* @__PURE__ */ jsx62("span", { className: "ctc-option__sub", children: row.longName })
10181
+ ] }),
10182
+ /* @__PURE__ */ jsxs58("span", { className: "ctc-option__stats", children: [
10183
+ /* @__PURE__ */ jsx62("span", { children: formatPrice(row.last, row.pricePrecision) }),
10184
+ /* @__PURE__ */ jsx62("span", { className: ["ctc-change", rowChange].filter(Boolean).join(" "), children: formatPct(row.change24hPct) })
10185
+ ] })
10186
+ ]
10163
10187
  },
10164
- children: [
10165
- /* @__PURE__ */ jsx62(CoinAvatar, { base: row.base, icon: row.icon, label: row.name }),
10166
- /* @__PURE__ */ jsxs58("span", { className: "ctc-option__text", children: [
10167
- /* @__PURE__ */ jsx62("span", { className: "ctc-option__name", children: row.name }),
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
- })
10188
+ row.id
10189
+ );
10190
+ })
10191
+ ]
10179
10192
  }
10180
10193
  ) : null
10181
10194
  ] }),
10182
- /* @__PURE__ */ jsxs58("div", { className: "ctc-fields", children: [
10195
+ /* @__PURE__ */ jsxs58("div", { className: "ctc-seg", role: "group", "aria-label": "Trade side", children: [
10183
10196
  /* @__PURE__ */ jsx62(
10184
- TextField,
10197
+ "button",
10185
10198
  {
10186
- id: payId,
10187
- label: `You pay (${labels.pay})`,
10188
- inputMode: "decimal",
10189
- autoComplete: "off",
10190
- placeholder: "0.00",
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
- }
10199
+ type: "button",
10200
+ className: side === "buy" ? "ctc-seg__btn is-active is-buy" : "ctc-seg__btn is-buy",
10201
+ "aria-pressed": side === "buy",
10202
+ onClick: () => setSide("buy"),
10203
+ children: "Buy"
10199
10204
  }
10200
10205
  ),
10201
10206
  /* @__PURE__ */ jsx62(
10202
- TextField,
10207
+ "button",
10203
10208
  {
10204
- id: receiveId,
10205
- label: `You receive (${labels.receive})`,
10206
- inputMode: "decimal",
10207
- autoComplete: "off",
10208
- placeholder: "0.00",
10209
- value: edited === "receive" ? receive : conversion.receive,
10210
- status: conversion.error ? "fail" : "neutral",
10211
- "aria-invalid": Boolean(conversion.error),
10212
- "aria-describedby": priceReady && selected ? `ctc-rate-${reactId}` : statusId,
10213
- onChange: (event) => {
10214
- setEdited("receive");
10215
- setReceive(event.target.value);
10216
- }
10209
+ type: "button",
10210
+ className: side === "sell" ? "ctc-seg__btn is-active is-sell" : "ctc-seg__btn is-sell",
10211
+ "aria-pressed": side === "sell",
10212
+ onClick: () => setSide("sell"),
10213
+ children: "Sell"
10214
+ }
10215
+ )
10216
+ ] }),
10217
+ /* @__PURE__ */ jsxs58("div", { className: "ctc-fields", children: [
10218
+ /* @__PURE__ */ jsxs58(
10219
+ "label",
10220
+ {
10221
+ className: ["ctc-amount", conversion.error ? "is-invalid" : ""].filter(Boolean).join(" "),
10222
+ htmlFor: payId,
10223
+ children: [
10224
+ /* @__PURE__ */ jsx62("span", { className: "ctc-amount__label", children: "You pay" }),
10225
+ /* @__PURE__ */ jsxs58("span", { className: "ctc-amount__row", children: [
10226
+ /* @__PURE__ */ jsx62(
10227
+ "input",
10228
+ {
10229
+ id: payId,
10230
+ className: "ctc-amount__input",
10231
+ type: "text",
10232
+ inputMode: "decimal",
10233
+ autoComplete: "off",
10234
+ placeholder: "0.00",
10235
+ value: payValue,
10236
+ "aria-label": "Primary trade amount",
10237
+ "aria-invalid": Boolean(conversion.error),
10238
+ "aria-describedby": statusId,
10239
+ onChange: (event) => {
10240
+ setEdited("pay");
10241
+ setPay(event.target.value);
10242
+ }
10243
+ }
10244
+ ),
10245
+ /* @__PURE__ */ jsx62("span", { className: "ctc-amount__unit", children: labels.pay })
10246
+ ] }),
10247
+ /* @__PURE__ */ jsx62("span", { className: "ctc-amount__meta", children: "Amount to spend" })
10248
+ ]
10249
+ }
10250
+ ),
10251
+ /* @__PURE__ */ jsxs58(
10252
+ "label",
10253
+ {
10254
+ className: ["ctc-amount", conversion.error ? "is-invalid" : ""].filter(Boolean).join(" "),
10255
+ htmlFor: receiveId,
10256
+ children: [
10257
+ /* @__PURE__ */ jsx62("span", { className: "ctc-amount__label", children: "You receive" }),
10258
+ /* @__PURE__ */ jsxs58("span", { className: "ctc-amount__row", children: [
10259
+ /* @__PURE__ */ jsx62(
10260
+ "input",
10261
+ {
10262
+ id: receiveId,
10263
+ className: "ctc-amount__input",
10264
+ type: "text",
10265
+ inputMode: "decimal",
10266
+ autoComplete: "off",
10267
+ placeholder: "0.00",
10268
+ value: receiveValue,
10269
+ "aria-label": "Converted trade amount",
10270
+ "aria-invalid": Boolean(conversion.error),
10271
+ "aria-describedby": `ctc-rate-${reactId}`,
10272
+ onChange: (event) => {
10273
+ setEdited("receive");
10274
+ setReceive(event.target.value);
10275
+ }
10276
+ }
10277
+ ),
10278
+ /* @__PURE__ */ jsx62("span", { className: "ctc-amount__unit", children: labels.receive })
10279
+ ] }),
10280
+ /* @__PURE__ */ jsx62("span", { id: `ctc-rate-${reactId}`, className: "ctc-amount__meta", children: receiveMeta })
10281
+ ]
10217
10282
  }
10218
10283
  )
10219
10284
  ] }),
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
10285
  conversion.error ? /* @__PURE__ */ jsx62("p", { className: "ctc-error", role: "alert", children: conversion.error }) : null,
10230
10286
  /* @__PURE__ */ jsx62("div", { className: "ctc-cta", children: ctaDisabled ? /* @__PURE__ */ jsx62(
10231
- Button,
10287
+ "button",
10232
10288
  {
10233
10289
  type: "button",
10234
- colorScheme: "coral",
10235
- variant: "primary",
10236
- fullWidth: true,
10237
- label: side === "buy" ? "Buy" : "Sell",
10290
+ className: ctaClass,
10238
10291
  disabled: true,
10239
- "aria-disabled": "true"
10292
+ "aria-disabled": "true",
10293
+ children: ctaLabel
10240
10294
  }
10241
- ) : /* @__PURE__ */ jsx62("a", { className: "ctc-cta-link", href: tradeHref, rel: "noopener noreferrer", children: /* @__PURE__ */ jsx62(
10242
- Button,
10295
+ ) : /* @__PURE__ */ jsx62(
10296
+ "a",
10243
10297
  {
10244
- type: "button",
10245
- colorScheme: "coral",
10246
- variant: "primary",
10247
- fullWidth: true,
10248
- label: side === "buy" ? "Buy" : "Sell",
10249
- tabIndex: -1
10298
+ className: ["ctc-cta-link", side === "sell" ? "is-sell" : "is-buy"].join(" "),
10299
+ href: tradeHref,
10300
+ rel: "noopener noreferrer",
10301
+ children: ctaLabel
10250
10302
  }
10251
- ) }) })
10252
- ] })
10303
+ ) })
10304
+ ] }) })
10253
10305
  ] })
10254
10306
  }
10255
10307
  );