@sweepconsole/js 0.2.4 → 0.2.6

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/README.md CHANGED
@@ -5,7 +5,7 @@ A **Subscribe with USDC** button for your checkout. It asks your server for a UR
5
5
  ~3KB gzipped, no dependencies.
6
6
 
7
7
  ```html
8
- <script src="https://cdn.jsdelivr.net/npm/@sweepconsole/js@0.2.4/dist/sweep.js"></script>
8
+ <script src="https://cdn.jsdelivr.net/npm/@sweepconsole/js@0.2.5/dist/sweep.js"></script>
9
9
  <button id="pay-usdc">Subscribe with USDC</button>
10
10
 
11
11
  <script>
@@ -34,7 +34,7 @@ app.post("/api/sweep/session", requireLogin, async (req, res) => {
34
34
  // externalRef: req.user.id,
35
35
  // maxAmount: usdc("35.00"), // the ceiling, with headroom — not the price
36
36
  // interval: "monthly",
37
- // chains: ["base", "arbitrum", "optimism"],
37
+ // chains: ["base", "arbitrum", "optimism", "monad"],
38
38
  // expiresAt: addYears(new Date(), 1),
39
39
  // });
40
40
  // res.json({ url: mandate.authorizationUrl });
@@ -114,7 +114,7 @@ For a public link — a pricing page, an invoice, a QR code — there is no iden
114
114
  to protect, and a plain anchor is enough:
115
115
 
116
116
  ```html
117
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@sweepconsole/js@0.2.4/dist/button.css">
117
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@sweepconsole/js@0.2.5/dist/button.css">
118
118
  <a class="sweep-pay" href="https://pay.sweepconsole.com/pay/plink_a1b2c3?ref=user_42">
119
119
  Subscribe with USDC
120
120
  </a>
package/dist/index.d.ts CHANGED
@@ -93,7 +93,7 @@ export declare const BUTTON_CSS = ".sweep-pay{--_bg:var(--sweep-bg,#201e1d);--_f
93
93
  * never a styled div, which cannot be reached by keyboard.
94
94
  */
95
95
  export declare function mount(target: string | Element, opts: MountOptions): SweepButton;
96
- export declare const MODAL_CSS = ".sweep-modal{position:fixed;inset:0;z-index:2147483646;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(35,35,59,.55);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);opacity:0;transition:opacity .2s ease}\n.sweep-modal[data-open=true]{opacity:1}\n.sweep-modal__panel{position:relative;width:100%;max-width:820px;height:min(940px,calc(100vh - 48px));background:#fff;border-radius:14px;overflow:hidden;box-shadow:0 0 0 1px rgba(35,35,80,.08),0 30px 60px -30px rgba(35,35,80,.45);opacity:0;transform:translateY(16px) scale(.92);transition:transform .34s cubic-bezier(.2,1.25,.4,1),opacity .2s ease}\n.sweep-modal[data-open=true] .sweep-modal__panel{opacity:1;transform:none}\n.sweep-modal__frame{display:block;width:100%;height:100%;border:0}\n.sweep-modal__close{position:absolute;top:10px;right:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;border:0;border-radius:8px;background:rgba(244,244,251,.9);color:#5D5E73;cursor:pointer;font:inherit;font-size:17px;line-height:1}\n.sweep-modal__close:hover{background:#ECECF3;color:#23233B}\n.sweep-modal__close:focus-visible{outline:2px solid #4447D6;outline-offset:2px}\n@media (max-width:868px){.sweep-modal{padding:0}.sweep-modal__panel{max-width:none;height:100%;border-radius:0;opacity:1;transform:translateY(100%);transition:transform .32s cubic-bezier(.2,.8,.2,1)}.sweep-modal__close{top:8px;right:8px}}\n@media (prefers-reduced-motion:reduce){.sweep-modal,.sweep-modal__panel{transition:none}.sweep-modal__panel{transform:none}}";
96
+ export declare const MODAL_CSS = ".sweep-modal{position:fixed;inset:0;z-index:2147483646;display:flex;align-items:center;justify-content:center;padding:12px;background:rgba(35,35,59,.55);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);opacity:0;transition:opacity .2s ease}\n.sweep-modal[data-open=true]{opacity:1}\n.sweep-modal__panel{position:relative;width:100%;max-width:980px;height:min(1200px,calc(100vh - 24px));background:#fff;border-radius:14px;overflow:hidden;box-shadow:0 0 0 1px rgba(35,35,80,.08),0 30px 60px -30px rgba(35,35,80,.45);opacity:0;transform:translateY(16px) scale(.92);transition:transform .34s cubic-bezier(.2,1.25,.4,1),opacity .2s ease}\n.sweep-modal[data-open=true] .sweep-modal__panel{opacity:1;transform:none}\n.sweep-modal__frame{display:block;width:100%;height:100%;border:0}\n.sweep-modal__close{position:absolute;top:10px;right:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;border:0;border-radius:8px;background:rgba(244,244,251,.9);color:#5D5E73;cursor:pointer;font:inherit;font-size:17px;line-height:1}\n.sweep-modal__close:hover{background:#ECECF3;color:#23233B}\n.sweep-modal__close:focus-visible{outline:2px solid #4447D6;outline-offset:2px}\n@media (max-width:1028px){.sweep-modal{padding:0}.sweep-modal__panel{max-width:none;height:100%;border-radius:0;opacity:1;transform:translateY(100%);transition:transform .32s cubic-bezier(.2,.8,.2,1)}.sweep-modal__close{top:8px;right:8px}}\n@media (prefers-reduced-motion:reduce){.sweep-modal,.sweep-modal__panel{transition:none}.sweep-modal__panel{transform:none}}";
97
97
  export interface AuthorizeResult {
98
98
  /** The mandate the payer signed, as the authorize page reported it. */
99
99
  mandate_id?: string;
package/dist/index.js CHANGED
@@ -291,14 +291,14 @@ const MODAL_STYLE_ID = "sweep-modal-styles";
291
291
  * squeezed. Small enough to never be noticed, and it would have grown to 88px
292
292
  * wide the moment the panel did.
293
293
  */
294
- const PANEL_MAX_WIDTH = 820;
294
+ const PANEL_MAX_WIDTH = 980;
295
295
  const SHEET_MAX_WIDTH = PANEL_MAX_WIDTH + 48;
296
296
  // The panel pops in like a dialog: it grows from 92% with a slight spring past
297
297
  // full size while the backdrop dims and softens. On a phone it is a sheet that
298
298
  // slides up from the bottom instead (see the media query).
299
- export const MODAL_CSS = `.sweep-modal{position:fixed;inset:0;z-index:2147483646;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(35,35,59,.55);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);opacity:0;transition:opacity .2s ease}
299
+ export const MODAL_CSS = `.sweep-modal{position:fixed;inset:0;z-index:2147483646;display:flex;align-items:center;justify-content:center;padding:12px;background:rgba(35,35,59,.55);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);opacity:0;transition:opacity .2s ease}
300
300
  .sweep-modal[data-open=true]{opacity:1}
301
- .sweep-modal__panel{position:relative;width:100%;max-width:${PANEL_MAX_WIDTH}px;height:min(940px,calc(100vh - 48px));background:#fff;border-radius:14px;overflow:hidden;box-shadow:0 0 0 1px rgba(35,35,80,.08),0 30px 60px -30px rgba(35,35,80,.45);opacity:0;transform:translateY(16px) scale(.92);transition:transform .34s cubic-bezier(.2,1.25,.4,1),opacity .2s ease}
301
+ .sweep-modal__panel{position:relative;width:100%;max-width:${PANEL_MAX_WIDTH}px;height:min(1200px,calc(100vh - 24px));background:#fff;border-radius:14px;overflow:hidden;box-shadow:0 0 0 1px rgba(35,35,80,.08),0 30px 60px -30px rgba(35,35,80,.45);opacity:0;transform:translateY(16px) scale(.92);transition:transform .34s cubic-bezier(.2,1.25,.4,1),opacity .2s ease}
302
302
  .sweep-modal[data-open=true] .sweep-modal__panel{opacity:1;transform:none}
303
303
  .sweep-modal__frame{display:block;width:100%;height:100%;border:0}
304
304
  .sweep-modal__close{position:absolute;top:10px;right:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;border:0;border-radius:8px;background:rgba(244,244,251,.9);color:#5D5E73;cursor:pointer;font:inherit;font-size:17px;line-height:1}
@@ -360,6 +360,7 @@ export function openAuthorize(url, opts = {}) {
360
360
  return;
361
361
  done = true;
362
362
  window.removeEventListener("message", onMessage);
363
+ window.removeEventListener("resize", fitPanel);
363
364
  document.removeEventListener("keydown", onKey);
364
365
  document.body.style.overflow = prevOverflow;
365
366
  root.remove();
@@ -401,8 +402,40 @@ export function openAuthorize(url, opts = {}) {
401
402
  }
402
403
  if (msg.type === "cancelled") {
403
404
  dismiss();
405
+ return;
406
+ }
407
+ if (msg.type === "resize") {
408
+ const h = msg.height;
409
+ if (typeof h === "number" && isFinite(h) && h > 0) {
410
+ contentHeight = h;
411
+ fitPanel();
412
+ }
413
+ }
414
+ }
415
+ /**
416
+ * The panel as tall as the checkout, up to the screen.
417
+ *
418
+ * It was a fixed min(1020px, 100vh - 48px) whatever the page held, so on a
419
+ * laptop the checkout scrolled inside a frame that stopped short of the
420
+ * screen's edge. The page now reports its real height and the panel takes
421
+ * exactly that, capped at the viewport less a 12px margin each side — so
422
+ * it only scrolls when the checkout genuinely cannot fit.
423
+ *
424
+ * Not on a phone, where the panel is a full-height sheet and the media
425
+ * query owns its size.
426
+ */
427
+ let contentHeight = 0;
428
+ function fitPanel() {
429
+ if (!contentHeight)
430
+ return;
431
+ if (window.matchMedia && window.matchMedia("(max-width:" + SHEET_MAX_WIDTH + "px)").matches) {
432
+ panel.style.height = "";
433
+ return;
404
434
  }
435
+ const room = window.innerHeight - 24;
436
+ panel.style.height = Math.min(Math.ceil(contentHeight), room) + "px";
405
437
  }
438
+ window.addEventListener("resize", fitPanel);
406
439
  window.addEventListener("message", onMessage);
407
440
  document.addEventListener("keydown", onKey);
408
441
  close.addEventListener("click", dismiss);
package/dist/sweep.js CHANGED
@@ -294,14 +294,14 @@
294
294
  * squeezed. Small enough to never be noticed, and it would have grown to 88px
295
295
  * wide the moment the panel did.
296
296
  */
297
- const PANEL_MAX_WIDTH = 820;
297
+ const PANEL_MAX_WIDTH = 980;
298
298
  const SHEET_MAX_WIDTH = PANEL_MAX_WIDTH + 48;
299
299
  // The panel pops in like a dialog: it grows from 92% with a slight spring past
300
300
  // full size while the backdrop dims and softens. On a phone it is a sheet that
301
301
  // slides up from the bottom instead (see the media query).
302
- const MODAL_CSS = `.sweep-modal{position:fixed;inset:0;z-index:2147483646;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(35,35,59,.55);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);opacity:0;transition:opacity .2s ease}
302
+ const MODAL_CSS = `.sweep-modal{position:fixed;inset:0;z-index:2147483646;display:flex;align-items:center;justify-content:center;padding:12px;background:rgba(35,35,59,.55);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);opacity:0;transition:opacity .2s ease}
303
303
  .sweep-modal[data-open=true]{opacity:1}
304
- .sweep-modal__panel{position:relative;width:100%;max-width:${PANEL_MAX_WIDTH}px;height:min(940px,calc(100vh - 48px));background:#fff;border-radius:14px;overflow:hidden;box-shadow:0 0 0 1px rgba(35,35,80,.08),0 30px 60px -30px rgba(35,35,80,.45);opacity:0;transform:translateY(16px) scale(.92);transition:transform .34s cubic-bezier(.2,1.25,.4,1),opacity .2s ease}
304
+ .sweep-modal__panel{position:relative;width:100%;max-width:${PANEL_MAX_WIDTH}px;height:min(1200px,calc(100vh - 24px));background:#fff;border-radius:14px;overflow:hidden;box-shadow:0 0 0 1px rgba(35,35,80,.08),0 30px 60px -30px rgba(35,35,80,.45);opacity:0;transform:translateY(16px) scale(.92);transition:transform .34s cubic-bezier(.2,1.25,.4,1),opacity .2s ease}
305
305
  .sweep-modal[data-open=true] .sweep-modal__panel{opacity:1;transform:none}
306
306
  .sweep-modal__frame{display:block;width:100%;height:100%;border:0}
307
307
  .sweep-modal__close{position:absolute;top:10px;right:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;border:0;border-radius:8px;background:rgba(244,244,251,.9);color:#5D5E73;cursor:pointer;font:inherit;font-size:17px;line-height:1}
@@ -363,6 +363,7 @@
363
363
  return;
364
364
  done = true;
365
365
  window.removeEventListener("message", onMessage);
366
+ window.removeEventListener("resize", fitPanel);
366
367
  document.removeEventListener("keydown", onKey);
367
368
  document.body.style.overflow = prevOverflow;
368
369
  root.remove();
@@ -404,8 +405,40 @@
404
405
  }
405
406
  if (msg.type === "cancelled") {
406
407
  dismiss();
408
+ return;
409
+ }
410
+ if (msg.type === "resize") {
411
+ const h = msg.height;
412
+ if (typeof h === "number" && isFinite(h) && h > 0) {
413
+ contentHeight = h;
414
+ fitPanel();
415
+ }
416
+ }
417
+ }
418
+ /**
419
+ * The panel as tall as the checkout, up to the screen.
420
+ *
421
+ * It was a fixed min(1020px, 100vh - 48px) whatever the page held, so on a
422
+ * laptop the checkout scrolled inside a frame that stopped short of the
423
+ * screen's edge. The page now reports its real height and the panel takes
424
+ * exactly that, capped at the viewport less a 12px margin each side — so
425
+ * it only scrolls when the checkout genuinely cannot fit.
426
+ *
427
+ * Not on a phone, where the panel is a full-height sheet and the media
428
+ * query owns its size.
429
+ */
430
+ let contentHeight = 0;
431
+ function fitPanel() {
432
+ if (!contentHeight)
433
+ return;
434
+ if (window.matchMedia && window.matchMedia("(max-width:" + SHEET_MAX_WIDTH + "px)").matches) {
435
+ panel.style.height = "";
436
+ return;
407
437
  }
438
+ const room = window.innerHeight - 24;
439
+ panel.style.height = Math.min(Math.ceil(contentHeight), room) + "px";
408
440
  }
441
+ window.addEventListener("resize", fitPanel);
409
442
  window.addEventListener("message", onMessage);
410
443
  document.addEventListener("keydown", onKey);
411
444
  close.addEventListener("click", dismiss);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sweepconsole/js",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Pay-with-USDC button for the browser \u2014 asks your server for a checkout URL and sends the payer there",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,9 +41,9 @@
41
41
  "url": "git+https://github.com/u4believe/sweep-console.git",
42
42
  "directory": "packages/js"
43
43
  },
44
- "homepage": "https://github.com/u4believe/sweep-console#readme",
44
+ "homepage": "https://docs.sweepconsole.xyz",
45
45
  "bugs": {
46
- "url": "https://github.com/u4believe/sweep-console/issues"
46
+ "url": "mailto:support@sweepconsole.xyz"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"