@daimo/pay 1.0.7 → 1.0.9

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/build/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import React$1, { ReactNode } from 'react';
2
+ export { version } from '../package.json';
2
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
  import { CreateConfigParameters } from '@wagmi/core';
4
5
  import { CoinbaseWalletParameters } from 'wagmi/connectors';
@@ -1,5 +1,5 @@
1
1
  var name = "@daimo/pay";
2
- var version = "1.0.7";
2
+ var version = "1.0.9";
3
3
  var author = "Daimo";
4
4
  var homepage = "https://pay.daimo.com";
5
5
  var license = "BSD-2-Clause license";
@@ -39,7 +39,7 @@ var keywords = [
39
39
  ];
40
40
  var dependencies = {
41
41
  "@daimo/common": "0.3.16",
42
- "@daimo/contract": "0.3.15",
42
+ "@daimo/contract": "0.3.16",
43
43
  "@solana/wallet-adapter-base": "^0.9.23",
44
44
  "@solana/wallet-adapter-react": "^0.15.35",
45
45
  "@solana/web3.js": "^1.95.4",
@@ -12,11 +12,10 @@ import Button from '../Button/index.js';
12
12
  /** Shows payment amount. */
13
13
  const OrderHeader = ({ minified = false }) => {
14
14
  const { paymentState } = usePayContext();
15
- const amount = paymentState.daimoPayOrder?.destFinalCallTokenAmount.usd.toFixed(2);
15
+ const amountUsd = paymentState.daimoPayOrder?.destFinalCallTokenAmount.usd;
16
16
  const isEditable = paymentState.daimoPayOrder?.mode === DaimoPayOrderMode.CHOOSE_AMOUNT;
17
- const [editableAmount, setEditableAmount] = useState(amount ?? "");
18
- // Start out in edit mode immediately if amount = 0.
19
- const [isEditing, setIsEditing] = useState(amount === "0.00");
17
+ const [editableAmount, setEditableAmount] = useState(amountUsd == null ? "" : amountUsd.toFixed(2));
18
+ const [isEditing, setIsEditing] = useState(false);
20
19
  const handleSave = () => {
21
20
  if (!isEditing)
22
21
  return;
@@ -28,20 +27,20 @@ const OrderHeader = ({ minified = false }) => {
28
27
  handleSave();
29
28
  }
30
29
  };
31
- const sanitizeAndSetAmount = (amount) => {
32
- if (!amount.match(/^[0-9]*(\.[0-9]{0,2})?$/)) {
30
+ const sanitizeAndSetAmount = (enteredUsd) => {
31
+ if (!enteredUsd.match(/^[0-9]*(\.[0-9]{0,2})?$/)) {
33
32
  return;
34
33
  }
35
34
  const [digitsBeforeDecimal, digitsAfterDecimal] = (() => {
36
- if (amount.includes("."))
37
- return amount.split(".");
35
+ if (enteredUsd.includes("."))
36
+ return enteredUsd.split(".");
38
37
  else
39
- return [amount, ""];
38
+ return [enteredUsd, ""];
40
39
  })();
41
40
  if (digitsBeforeDecimal.length > 5 || digitsAfterDecimal.length > 2) {
42
41
  return;
43
42
  }
44
- setEditableAmount(amount);
43
+ setEditableAmount(enteredUsd);
45
44
  };
46
45
  const titleAmountContent = (() => {
47
46
  const buttonStyles = (() => {
@@ -62,7 +61,10 @@ const OrderHeader = ({ minified = false }) => {
62
61
  fontSize: "20px",
63
62
  };
64
63
  })();
65
- return (jsxs(Fragment, { children: [isEditable && !minified && (jsx("div", { style: { width: buttonStyles.width, height: buttonStyles.height } })), !isEditing ? (jsxs("span", { children: ["$", amount] })) : (jsxs("div", { style: { display: "flex" }, children: ["$", jsx(InputUnderlineField, { value: editableAmount, onChange: (e) => sanitizeAndSetAmount(e.target.value), onBlur: (e) => {
64
+ return (jsxs(Fragment, { children: [isEditable && !minified && (jsx("div", { style: { width: buttonStyles.width, height: buttonStyles.height } })), !isEditing && amountUsd != null && (jsx("span", { children: new Intl.NumberFormat("en-US", {
65
+ style: "currency",
66
+ currency: "USD",
67
+ }).format(amountUsd) })), isEditing && (jsxs("div", { style: { display: "flex" }, children: ["$", jsx(InputUnderlineField, { value: editableAmount, onChange: (e) => sanitizeAndSetAmount(e.target.value), onBlur: (e) => {
66
68
  if (!e.relatedTarget) {
67
69
  setIsEditing(false);
68
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,3 +1,4 @@
1
+ export { version } from '../package.json.js';
1
2
  export { DaimoPayProvider } from './components/DaimoPay.js';
2
3
  export { default as getDefaultConfig } from './defaultConfig.js';
3
4
  export { DaimoPayButton } from './components/DaimoPayButton/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@daimo/pay",
3
3
  "private": false,
4
- "version": "1.0.7",
4
+ "version": "1.0.9",
5
5
  "author": "Daimo",
6
6
  "homepage": "https://pay.daimo.com",
7
7
  "license": "BSD-2-Clause license",
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@daimo/common": "0.3.16",
44
- "@daimo/contract": "0.3.15",
44
+ "@daimo/contract": "0.3.16",
45
45
  "@solana/wallet-adapter-base": "^0.9.23",
46
46
  "@solana/wallet-adapter-react": "^0.15.35",
47
47
  "@solana/web3.js": "^1.95.4",