@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.js CHANGED
@@ -9676,8 +9676,8 @@ function createMarketFeed(discovered, handlers, options = {}) {
9676
9676
  const resolved = resolveMetaId(key, meta);
9677
9677
  if (!resolved) continue;
9678
9678
  applyTick(resolved.id, resolved.meta, tick);
9679
- subscribeTicker(resolved.id);
9680
- subscribeKline(resolved.id);
9679
+ subscribeTicker(key);
9680
+ subscribeKline(key);
9681
9681
  }
9682
9682
  return;
9683
9683
  }
@@ -10026,8 +10026,8 @@ function CoinAvatar({ base, icon, label }) {
10026
10026
  className: "ctc-avatar",
10027
10027
  src: icon,
10028
10028
  alt: "",
10029
- width: 32,
10030
- height: 32,
10029
+ width: 30,
10030
+ height: 30,
10031
10031
  loading: "lazy",
10032
10032
  decoding: "async",
10033
10033
  onError: () => setFailed(true),
@@ -10035,6 +10035,24 @@ function CoinAvatar({ base, icon, label }) {
10035
10035
  }
10036
10036
  );
10037
10037
  }
10038
+ function ChevronIcon4({ className }) {
10039
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10040
+ "svg",
10041
+ {
10042
+ className,
10043
+ width: 20,
10044
+ height: 20,
10045
+ viewBox: "0 0 24 24",
10046
+ fill: "none",
10047
+ stroke: "currentColor",
10048
+ strokeWidth: "2.2",
10049
+ strokeLinecap: "round",
10050
+ strokeLinejoin: "round",
10051
+ "aria-hidden": "true",
10052
+ children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("polyline", { points: "6 9 12 15 18 9" })
10053
+ }
10054
+ );
10055
+ }
10038
10056
  var CryptoTradeConverter = ({
10039
10057
  variant: _variant = "default",
10040
10058
  market: _market = "spot",
@@ -10141,6 +10159,11 @@ var CryptoTradeConverter = ({
10141
10159
  const priceReady = selected?.last != null && Number.isFinite(selected.last) && selected.last > 0;
10142
10160
  const ctaDisabled = !priceReady || snapshot.status === "unsupported" || snapshot.status === "error" || !conversion.valid;
10143
10161
  const changeClass = selected?.change24hPct == null ? "" : selected.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
10162
+ const payValue = edited === "pay" ? pay : conversion.pay;
10163
+ const receiveValue = edited === "receive" ? receive : conversion.receive;
10164
+ 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");
10165
+ const ctaLabel = side === "buy" ? "Buy" : "Sell";
10166
+ const ctaClass = ["ctc-cta__btn", side === "sell" ? "is-sell" : "is-buy"].join(" ");
10144
10167
  return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10145
10168
  "section",
10146
10169
  {
@@ -10154,33 +10177,20 @@ var CryptoTradeConverter = ({
10154
10177
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("h2", { id: `ctc-heading-${reactId}`, className: "ctc-title", children: "Buy and sell in seconds" }),
10155
10178
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("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." })
10156
10179
  ] }),
10157
- /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "ctc-card", children: [
10158
- /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: `ctc-status ctc-status--${statusTone}`, id: statusId, role: "status", "aria-live": "polite", children: [
10159
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-status-dot", "aria-hidden": "true" }),
10160
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: snapshot.status === "idle" || snapshot.status === "connecting" ? "Connecting to live prices\u2026" : snapshot.statusMessage || (priceReady ? "Live prices" : "Waiting for live price\u2026") })
10161
- ] }),
10162
- /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "ctc-seg", role: "group", "aria-label": "Trade side", children: [
10163
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10164
- "button",
10165
- {
10166
- type: "button",
10167
- className: side === "buy" ? "ctc-seg__btn is-active is-buy" : "ctc-seg__btn is-buy",
10168
- "aria-pressed": side === "buy",
10169
- onClick: () => setSide("buy"),
10170
- children: "Buy"
10171
- }
10172
- ),
10173
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10174
- "button",
10175
- {
10176
- type: "button",
10177
- className: side === "sell" ? "ctc-seg__btn is-active is-sell" : "ctc-seg__btn is-sell",
10178
- "aria-pressed": side === "sell",
10179
- onClick: () => setSide("sell"),
10180
- children: "Sell"
10181
- }
10182
- )
10183
- ] }),
10180
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "ctc-card", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "ctc-widget", children: [
10181
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
10182
+ "div",
10183
+ {
10184
+ className: `ctc-status ctc-status--${statusTone}`,
10185
+ id: statusId,
10186
+ role: "status",
10187
+ "aria-live": "polite",
10188
+ children: [
10189
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-status-dot", "aria-hidden": "true" }),
10190
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: snapshot.status === "idle" || snapshot.status === "connecting" ? "Connecting to live prices\u2026" : snapshot.statusMessage || (priceReady ? "Live prices" : "Waiting for live price\u2026") })
10191
+ ]
10192
+ }
10193
+ ),
10184
10194
  /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "ctc-pair", children: [
10185
10195
  /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
10186
10196
  "button",
@@ -10225,129 +10235,171 @@ var CryptoTradeConverter = ({
10225
10235
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-pair__name", children: "Select a market" }),
10226
10236
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-pair__price", children: "\u2014" })
10227
10237
  ] }),
10228
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-pair__chevron", "aria-hidden": "true", children: "\u25BE" })
10238
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ChevronIcon4, { className: "ctc-pair__chevron" })
10229
10239
  ]
10230
10240
  }
10231
10241
  ),
10232
- pickerOpen ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10242
+ pickerOpen ? /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
10233
10243
  "ul",
10234
10244
  {
10235
10245
  ref: listRef,
10236
10246
  id: listboxId,
10237
10247
  className: "ctc-listbox",
10238
10248
  role: "listbox",
10239
- "aria-label": "Market pairs",
10249
+ "aria-label": "Choose a market",
10240
10250
  tabIndex: -1,
10241
10251
  onKeyDown: onPickerKeyDown,
10242
- children: sortedRows.map((row, index) => {
10243
- const selectedOption = selected?.id === row.id;
10244
- const active = index === activeOption;
10245
- const rowChange = row.change24hPct == null ? "" : row.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
10246
- return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
10247
- "li",
10248
- {
10249
- id: `${listboxId}-opt-${index}`,
10250
- role: "option",
10251
- "aria-selected": selectedOption,
10252
- className: [
10253
- "ctc-option",
10254
- active ? "is-active" : "",
10255
- selectedOption ? "is-selected" : ""
10256
- ].filter(Boolean).join(" "),
10257
- onMouseEnter: () => setActiveOption(index),
10258
- onClick: () => {
10259
- setSelectedId(row.id);
10260
- closePicker();
10252
+ children: [
10253
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("li", { className: "ctc-listbox__header", role: "presentation", children: "Choose a market" }),
10254
+ sortedRows.map((row, index) => {
10255
+ const selectedOption = selected?.id === row.id;
10256
+ const active = index === activeOption;
10257
+ const rowChange = row.change24hPct == null ? "" : row.change24hPct >= 0 ? "ctc-change--up" : "ctc-change--down";
10258
+ return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
10259
+ "li",
10260
+ {
10261
+ id: `${listboxId}-opt-${index}`,
10262
+ role: "option",
10263
+ "aria-selected": selectedOption,
10264
+ className: [
10265
+ "ctc-option",
10266
+ active ? "is-active" : "",
10267
+ selectedOption ? "is-selected" : ""
10268
+ ].filter(Boolean).join(" "),
10269
+ onMouseEnter: () => setActiveOption(index),
10270
+ onClick: () => {
10271
+ setSelectedId(row.id);
10272
+ closePicker();
10273
+ },
10274
+ children: [
10275
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(CoinAvatar, { base: row.base, icon: row.icon, label: row.name }),
10276
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "ctc-option__text", children: [
10277
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-option__name", children: row.name }),
10278
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-option__sub", children: row.longName })
10279
+ ] }),
10280
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "ctc-option__stats", children: [
10281
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: formatPrice(row.last, row.pricePrecision) }),
10282
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: ["ctc-change", rowChange].filter(Boolean).join(" "), children: formatPct(row.change24hPct) })
10283
+ ] })
10284
+ ]
10261
10285
  },
10262
- children: [
10263
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(CoinAvatar, { base: row.base, icon: row.icon, label: row.name }),
10264
- /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "ctc-option__text", children: [
10265
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-option__name", children: row.name }),
10266
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-option__sub", children: row.longName })
10267
- ] }),
10268
- /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "ctc-option__stats", children: [
10269
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { children: formatPrice(row.last, row.pricePrecision) }),
10270
- /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: ["ctc-change", rowChange].filter(Boolean).join(" "), children: formatPct(row.change24hPct) })
10271
- ] })
10272
- ]
10273
- },
10274
- row.id
10275
- );
10276
- })
10286
+ row.id
10287
+ );
10288
+ })
10289
+ ]
10277
10290
  }
10278
10291
  ) : null
10279
10292
  ] }),
10280
- /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "ctc-fields", children: [
10293
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "ctc-seg", role: "group", "aria-label": "Trade side", children: [
10281
10294
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10282
- TextField,
10295
+ "button",
10283
10296
  {
10284
- id: payId,
10285
- label: `You pay (${labels.pay})`,
10286
- inputMode: "decimal",
10287
- autoComplete: "off",
10288
- placeholder: "0.00",
10289
- value: edited === "pay" ? pay : conversion.pay,
10290
- status: conversion.error ? "fail" : "neutral",
10291
- "aria-invalid": Boolean(conversion.error),
10292
- "aria-describedby": statusId,
10293
- onChange: (event) => {
10294
- setEdited("pay");
10295
- setPay(event.target.value);
10296
- }
10297
+ type: "button",
10298
+ className: side === "buy" ? "ctc-seg__btn is-active is-buy" : "ctc-seg__btn is-buy",
10299
+ "aria-pressed": side === "buy",
10300
+ onClick: () => setSide("buy"),
10301
+ children: "Buy"
10297
10302
  }
10298
10303
  ),
10299
10304
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10300
- TextField,
10305
+ "button",
10301
10306
  {
10302
- id: receiveId,
10303
- label: `You receive (${labels.receive})`,
10304
- inputMode: "decimal",
10305
- autoComplete: "off",
10306
- placeholder: "0.00",
10307
- value: edited === "receive" ? receive : conversion.receive,
10308
- status: conversion.error ? "fail" : "neutral",
10309
- "aria-invalid": Boolean(conversion.error),
10310
- "aria-describedby": priceReady && selected ? `ctc-rate-${reactId}` : statusId,
10311
- onChange: (event) => {
10312
- setEdited("receive");
10313
- setReceive(event.target.value);
10314
- }
10307
+ type: "button",
10308
+ className: side === "sell" ? "ctc-seg__btn is-active is-sell" : "ctc-seg__btn is-sell",
10309
+ "aria-pressed": side === "sell",
10310
+ onClick: () => setSide("sell"),
10311
+ children: "Sell"
10312
+ }
10313
+ )
10314
+ ] }),
10315
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "ctc-fields", children: [
10316
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
10317
+ "label",
10318
+ {
10319
+ className: ["ctc-amount", conversion.error ? "is-invalid" : ""].filter(Boolean).join(" "),
10320
+ htmlFor: payId,
10321
+ children: [
10322
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-amount__label", children: "You pay" }),
10323
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "ctc-amount__row", children: [
10324
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10325
+ "input",
10326
+ {
10327
+ id: payId,
10328
+ className: "ctc-amount__input",
10329
+ type: "text",
10330
+ inputMode: "decimal",
10331
+ autoComplete: "off",
10332
+ placeholder: "0.00",
10333
+ value: payValue,
10334
+ "aria-label": "Primary trade amount",
10335
+ "aria-invalid": Boolean(conversion.error),
10336
+ "aria-describedby": statusId,
10337
+ onChange: (event) => {
10338
+ setEdited("pay");
10339
+ setPay(event.target.value);
10340
+ }
10341
+ }
10342
+ ),
10343
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-amount__unit", children: labels.pay })
10344
+ ] }),
10345
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-amount__meta", children: "Amount to spend" })
10346
+ ]
10347
+ }
10348
+ ),
10349
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
10350
+ "label",
10351
+ {
10352
+ className: ["ctc-amount", conversion.error ? "is-invalid" : ""].filter(Boolean).join(" "),
10353
+ htmlFor: receiveId,
10354
+ children: [
10355
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-amount__label", children: "You receive" }),
10356
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("span", { className: "ctc-amount__row", children: [
10357
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10358
+ "input",
10359
+ {
10360
+ id: receiveId,
10361
+ className: "ctc-amount__input",
10362
+ type: "text",
10363
+ inputMode: "decimal",
10364
+ autoComplete: "off",
10365
+ placeholder: "0.00",
10366
+ value: receiveValue,
10367
+ "aria-label": "Converted trade amount",
10368
+ "aria-invalid": Boolean(conversion.error),
10369
+ "aria-describedby": `ctc-rate-${reactId}`,
10370
+ onChange: (event) => {
10371
+ setEdited("receive");
10372
+ setReceive(event.target.value);
10373
+ }
10374
+ }
10375
+ ),
10376
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "ctc-amount__unit", children: labels.receive })
10377
+ ] }),
10378
+ /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { id: `ctc-rate-${reactId}`, className: "ctc-amount__meta", children: receiveMeta })
10379
+ ]
10315
10380
  }
10316
10381
  )
10317
10382
  ] }),
10318
- priceReady && selected ? /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("p", { id: `ctc-rate-${reactId}`, className: "ctc-rate", children: [
10319
- "Estimate at 1 ",
10320
- selected.base,
10321
- " = ",
10322
- formatPrice(selected.last, selected.pricePrecision),
10323
- " ",
10324
- selected.quote,
10325
- ". Fees and spread excluded."
10326
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("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" }),
10327
10383
  conversion.error ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "ctc-error", role: "alert", children: conversion.error }) : null,
10328
10384
  /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "ctc-cta", children: ctaDisabled ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10329
- Button,
10385
+ "button",
10330
10386
  {
10331
10387
  type: "button",
10332
- colorScheme: "coral",
10333
- variant: "primary",
10334
- fullWidth: true,
10335
- label: side === "buy" ? "Buy" : "Sell",
10388
+ className: ctaClass,
10336
10389
  disabled: true,
10337
- "aria-disabled": "true"
10390
+ "aria-disabled": "true",
10391
+ children: ctaLabel
10338
10392
  }
10339
- ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("a", { className: "ctc-cta-link", href: tradeHref, rel: "noopener noreferrer", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10340
- Button,
10393
+ ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
10394
+ "a",
10341
10395
  {
10342
- type: "button",
10343
- colorScheme: "coral",
10344
- variant: "primary",
10345
- fullWidth: true,
10346
- label: side === "buy" ? "Buy" : "Sell",
10347
- tabIndex: -1
10396
+ className: ["ctc-cta-link", side === "sell" ? "is-sell" : "is-buy"].join(" "),
10397
+ href: tradeHref,
10398
+ rel: "noopener noreferrer",
10399
+ children: ctaLabel
10348
10400
  }
10349
- ) }) })
10350
- ] })
10401
+ ) })
10402
+ ] }) })
10351
10403
  ] })
10352
10404
  }
10353
10405
  );