@coinflowlabs/react 5.20.0 → 5.21.0

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.
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /**
3
+ * Framework-agnostic definitions for the V2 card-form skeleton loader.
4
+ *
5
+ * The React, Vue, and Angular libraries all render the same skeleton while the
6
+ * card-form iframe loads. The grid templates and breakpoint come from the shared
7
+ * {@link buildCardEntryLayout} — the SAME source of truth the real form uses —
8
+ * so the skeleton reflows at exactly the width the loaded form does. Only the
9
+ * box styling and per-framework wiring live here.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SKELETON_BOX_STYLE = exports.SKELETON_ROOT_PADDING_PX = exports.SKELETON_FADE_MS = exports.SKELETON_PULSE_ANIMATION_NAME = exports.SKELETON_LAYOUTS = exports.COMPACT_SKELETON_HEIGHT_PX = exports.INLINE_SKELETON_HEIGHT_PX = void 0;
13
+ exports.shouldStackSkeleton = shouldStackSkeleton;
14
+ exports.guessSkeletonHeightPx = guessSkeletonHeightPx;
15
+ exports.getSkeletonGridTemplate = getSkeletonGridTemplate;
16
+ exports.getSkeletonGridClass = getSkeletonGridClass;
17
+ exports.buildSkeletonCss = buildSkeletonCss;
18
+ exports.getSkeletonColors = getSkeletonColors;
19
+ const cardEntryLayout_1 = require("./cardEntryLayout");
20
+ /** Which fields each iframe variant mounts. */
21
+ const VARIANT_INPUTS = {
22
+ 'card-form': ['card-number', 'expiration', 'cvv'],
23
+ 'card-number-form': ['card-number', 'expiration'],
24
+ 'cvv-form': ['cvv'],
25
+ };
26
+ // The iframe skeletons render without the optional card-brand icon.
27
+ const CARD_ENTRY_LAYOUTS = {
28
+ 'card-form': (0, cardEntryLayout_1.buildCardEntryLayout)({ inputs: VARIANT_INPUTS['card-form'] }),
29
+ 'card-number-form': (0, cardEntryLayout_1.buildCardEntryLayout)({
30
+ inputs: VARIANT_INPUTS['card-number-form'],
31
+ }),
32
+ 'cvv-form': (0, cardEntryLayout_1.buildCardEntryLayout)({ inputs: VARIANT_INPUTS['cvv-form'] }),
33
+ };
34
+ // Iframe height (px) to guess before it reports its real height. Matches the
35
+ // form's rendered height so the skeleton→form swap doesn't jump: field row(s) +
36
+ // the 1px border and the box's `m-0.5` margin on top and bottom.
37
+ const CARD_ENTRY_VERTICAL_CHROME_PX = 2 * cardEntryLayout_1.CARD_ENTRY_BORDER_PX + 2 * cardEntryLayout_1.CARD_ENTRY_MARGIN_PX;
38
+ exports.INLINE_SKELETON_HEIGHT_PX = cardEntryLayout_1.CARD_ENTRY_ROW_HEIGHT_PX + CARD_ENTRY_VERTICAL_CHROME_PX;
39
+ /** Two-row layouts are a second field row plus the 1px divider taller. */
40
+ exports.COMPACT_SKELETON_HEIGHT_PX = 2 * cardEntryLayout_1.CARD_ENTRY_ROW_HEIGHT_PX +
41
+ cardEntryLayout_1.CARD_ENTRY_DIVIDER_PX +
42
+ CARD_ENTRY_VERTICAL_CHROME_PX;
43
+ function toSkeletonLayout(layout) {
44
+ return {
45
+ inline: layout.inline,
46
+ compact: layout.twoRow ?? undefined,
47
+ compactMaxWidthPx: layout.breakpointPx ?? undefined,
48
+ areas: layout.fieldAreas,
49
+ };
50
+ }
51
+ exports.SKELETON_LAYOUTS = {
52
+ 'card-form': toSkeletonLayout(CARD_ENTRY_LAYOUTS['card-form']),
53
+ 'card-number-form': toSkeletonLayout(CARD_ENTRY_LAYOUTS['card-number-form']),
54
+ 'cvv-form': toSkeletonLayout(CARD_ENTRY_LAYOUTS['cvv-form']),
55
+ };
56
+ /** Name of the shared pulse keyframes; referenced by the box `animation`. */
57
+ exports.SKELETON_PULSE_ANIMATION_NAME = 'coinflow-card-form-skeleton-pulse';
58
+ /**
59
+ * Duration (ms) of the skeleton's opacity fade-out. Matches the `opacity 300ms`
60
+ * transition each renderer applies. Renderers unmount the skeleton on
61
+ * `transitionend`, but that event can be skipped (reduced-motion, an ancestor
62
+ * `display:none`, or opacity already 0) — so they also use this as a fallback
63
+ * timeout to force the unmount and avoid a stuck (invisible) skeleton.
64
+ */
65
+ exports.SKELETON_FADE_MS = 300;
66
+ /**
67
+ * Whether the given container width would trigger the variant's two-row layout.
68
+ * Mirrors the real form's container query (`width < breakpoint`). Variants
69
+ * without a two-row layout never reflow.
70
+ */
71
+ function shouldStackSkeleton({ variant, width, }) {
72
+ const { compact, compactMaxWidthPx } = exports.SKELETON_LAYOUTS[variant];
73
+ return (compact !== undefined &&
74
+ compactMaxWidthPx !== undefined &&
75
+ width > 0 &&
76
+ width < compactMaxWidthPx);
77
+ }
78
+ /**
79
+ * Height to guess before the iframe reports its real height. The two-row layout
80
+ * is a field row plus divider taller than the inline one.
81
+ */
82
+ function guessSkeletonHeightPx({ variant, width, }) {
83
+ return shouldStackSkeleton({ variant, width })
84
+ ? exports.COMPACT_SKELETON_HEIGHT_PX
85
+ : exports.INLINE_SKELETON_HEIGHT_PX;
86
+ }
87
+ /**
88
+ * The `grid-template` to apply for the given container width. Frameworks that
89
+ * drive the layout from JS (Vue, Angular) call this from their resize observer;
90
+ * React instead injects a CSS container query via {@link buildSkeletonCss}.
91
+ */
92
+ function getSkeletonGridTemplate({ variant, width, }) {
93
+ const { inline, compact } = exports.SKELETON_LAYOUTS[variant];
94
+ if (compact && shouldStackSkeleton({ variant, width }))
95
+ return compact;
96
+ return inline;
97
+ }
98
+ /** Stable class name for a variant's skeleton grid element. */
99
+ function getSkeletonGridClass(variant) {
100
+ return `coinflow-card-form-skeleton-grid--${variant}`;
101
+ }
102
+ /**
103
+ * CSS (keyframes + grid + container-query breakpoint) for the container-query
104
+ * driven renderer used by React, where the skeleton root is a query container.
105
+ */
106
+ function buildSkeletonCss(variant) {
107
+ const gridClass = getSkeletonGridClass(variant);
108
+ const grid = (0, cardEntryLayout_1.buildCardEntryGridCss)({
109
+ gridSelector: `.${gridClass}`,
110
+ layout: CARD_ENTRY_LAYOUTS[variant],
111
+ extraBaseRules: `.${gridClass} { gap: 0; flex: 1; }`,
112
+ });
113
+ return `@keyframes ${exports.SKELETON_PULSE_ANIMATION_NAME} {0%,100%{opacity:1}50%{opacity:0.4}}
114
+ ${grid}`;
115
+ }
116
+ /**
117
+ * Padding (px) to inset the skeleton grid by, applied on the skeleton root. It
118
+ * equals the form's own chrome — its `m-0.5` margin plus 1px border — so the
119
+ * boxes land in the same area the real fields will, and the grid fills the root
120
+ * exactly (no dead space that would make the boxes look too short).
121
+ */
122
+ exports.SKELETON_ROOT_PADDING_PX = cardEntryLayout_1.CARD_ENTRY_MARGIN_PX + cardEntryLayout_1.CARD_ENTRY_BORDER_PX;
123
+ /**
124
+ * Inline style for each skeleton box, MINUS the `background` — the fill color is
125
+ * theme-dependent (see {@link getSkeletonColors}) so each renderer merges it in.
126
+ * A hairline margin keeps a subtle gap between boxes while letting them fill
127
+ * nearly the full field height (the root padding handles the outer inset). Uses
128
+ * string units so it renders identically in React, Vue, and Angular.
129
+ */
130
+ exports.SKELETON_BOX_STYLE = {
131
+ minWidth: '0',
132
+ margin: '1px',
133
+ borderRadius: '4px',
134
+ opacity: '1',
135
+ animation: `${exports.SKELETON_PULSE_ANIMATION_NAME} 1.5s ease-in-out infinite`,
136
+ };
137
+ // Dark surface → light skeleton; light surface → dark skeleton (the original
138
+ // look); unknown → a neutral mid-grey that reads on either.
139
+ const DARK_SURFACE_COLORS = {
140
+ backdrop: 'rgba(255, 255, 255, 0.05)',
141
+ box: 'rgba(255, 255, 255, 0.30)',
142
+ };
143
+ const LIGHT_SURFACE_COLORS = {
144
+ backdrop: 'rgba(0, 0, 0, 0.04)',
145
+ box: 'rgba(0, 0, 0, 0.30)',
146
+ };
147
+ const NEUTRAL_COLORS = {
148
+ backdrop: 'rgba(128, 128, 128, 0.08)',
149
+ box: 'rgba(128, 128, 128, 0.38)',
150
+ };
151
+ /** Parse a hex (#rgb/#rrggbb/#rrggbbaa) or rgb()/rgba() string to [r,g,b]. */
152
+ function parseRgb(color) {
153
+ const c = color.trim().toLowerCase();
154
+ let hex = c.startsWith('#') ? c.slice(1) : '';
155
+ if (hex && /^[0-9a-f]+$/.test(hex)) {
156
+ if (hex.length === 3)
157
+ hex = hex
158
+ .split('')
159
+ .map(x => x + x)
160
+ .join('');
161
+ if (hex.length === 8)
162
+ hex = hex.slice(0, 6);
163
+ if (hex.length === 6)
164
+ return [
165
+ parseInt(hex.slice(0, 2), 16),
166
+ parseInt(hex.slice(2, 4), 16),
167
+ parseInt(hex.slice(4, 6), 16),
168
+ ];
169
+ }
170
+ const m = c.match(/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/);
171
+ if (m)
172
+ return [Number(m[1]), Number(m[2]), Number(m[3])];
173
+ return null;
174
+ }
175
+ /**
176
+ * Best-effort skeleton palette. The skeleton renders in the SDK (parent), so it
177
+ * can't see the form's resolved colors — it only has the optional `theme` the
178
+ * integrator passed. When `theme.background` is a parseable color we tint the
179
+ * skeleton light-on-dark or dark-on-light to match; otherwise we fall back to a
180
+ * neutral mid-grey that stays visible on any surface.
181
+ */
182
+ function getSkeletonColors(theme) {
183
+ const rgb = theme?.background ? parseRgb(theme.background) : null;
184
+ if (!rgb)
185
+ return NEUTRAL_COLORS;
186
+ const [r, g, b] = rgb;
187
+ const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
188
+ return luminance < 0.5 ? DARK_SURFACE_COLORS : LIGHT_SURFACE_COLORS;
189
+ }
190
+ //# sourceMappingURL=cardFormSkeleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cardFormSkeleton.js","sourceRoot":"","sources":["../../../../src/common/card-form/cardFormSkeleton.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;AAEH,uDAS2B;AAI3B,+CAA+C;AAC/C,MAAM,cAAc,GAAkD;IACpE,WAAW,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,KAAK,CAAC;IACjD,kBAAkB,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC;IACjD,UAAU,EAAE,C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AK,CAAC;YAClB,OAAO;gBACL,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;gBAC7B,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;gBAC7B,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;aAC9B,CAAC;IACN,CAAC;IACD,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,IAAI,CAAC;QAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,2BAAkC,KAEjC;IACC,MAAM,GAAG,GAAG,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,IAAI,CAAC,GAAG;QAAE,OAAO,cAAc,CAAC;IAChC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;IACtB,MAAM,SAAS,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAC5D,OAAO,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,oBAAoB,CAAC;AACtE,CAAC"}
@@ -4,6 +4,8 @@ export * from './CoinflowLibMessageHandlers';
4
4
  export * from './EventBus';
5
5
  export * from './card-form/TokenEx';
6
6
  export * from './card-form/tokenexHelpers';
7
+ export * from './card-form/cardEntryLayout';
8
+ export * from './card-form/cardFormSkeleton';
7
9
  export * from './types/Subtotal';
8
10
  export * from './types/AnyObject';
9
11
  export * from './types/giftCardCartItem';
@@ -8,6 +8,8 @@ tslib_1.__exportStar(require("./CoinflowLibMessageHandlers"), exports);
8
8
  tslib_1.__exportStar(require("./EventBus"), exports);
9
9
  tslib_1.__exportStar(require("./card-form/TokenEx"), exports);
10
10
  tslib_1.__exportStar(require("./card-form/tokenexHelpers"), exports);
11
+ tslib_1.__exportStar(require("./card-form/cardEntryLayout"), exports);
12
+ tslib_1.__exportStar(require("./card-form/cardFormSkeleton"), exports);
11
13
  tslib_1.__exportStar(require("./types/Subtotal"), exports);
12
14
  tslib_1.__exportStar(require("./types/AnyObject"), exports);
13
15
  tslib_1.__exportStar(require("./types/giftCardCartItem"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":";;;;AAAA,0DAAgC;AAChC,0DAAgC;AAChC,uEAA6C;AAC7C,qDAA2B;AAC3B,8DAAoC;AACpC,qEAA2C;AAC3C,2DAAiC;AACjC,4DAAkC;AAClC,mEAAyC;AACzC,8DAAoC;AACpC,iEAAuC;AACvC,8EAAoD;AACpD,mEAAyC;AACzC,mCAIkB;AAHhB,iIAAA,OAAO,OAAkB;AACzB,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":";;;;AAAA,0DAAgC;AAChC,0DAAgC;AAChC,uEAA6C;AAC7C,qDAA2B;AAC3B,8DAAoC;AACpC,qEAA2C;AAC3C,sEAA4C;AAC5C,uEAA6C;AAC7C,2DAAiC;AACjC,4DAAkC;AAClC,mEAAyC;AACzC,8DAAoC;AACpC,iEAAuC;AACvC,8EAAoD;AACpD,mEAAyC;AACzC,mCAIkB;AAHhB,iIAAA,OAAO,OAAkB;AACzB,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA"}
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from 'react';
2
2
  import LZString from 'lz-string';
3
- import { CoinflowUtils, IFrameMessageMethods, } from '../common';
3
+ import { buildSkeletonCss, CoinflowUtils, getSkeletonColors, getSkeletonGridClass, guessSkeletonHeightPx, IFrameMessageMethods, INLINE_SKELETON_HEIGHT_PX, SKELETON_BOX_STYLE, SKELETON_FADE_MS, SKELETON_LAYOUTS, SKELETON_ROOT_PADDING_PX, } from '../common';
4
4
  function useCardFormIframe({ variant, merchantId, env, theme, token, onLoad, }) {
5
5
  const iframeRef = useRef(null);
6
6
  const [loaded, setLoaded] = useState(false);
@@ -18,7 +18,13 @@ function useCardFormIframe({ variant, merchantId, env, theme, token, onLoad, })
18
18
  }
19
19
  return url.toString();
20
20
  }, [variant, merchantId, env, theme, token]);
21
- const handleMessage = useCallback(({ data, origin }) => {
21
+ const handleMessage = useCallback((event) => {
22
+ const { data, origin, source } = event;
23
+ // Only honor messages from THIS instance's iframe. Multiple card forms on
24
+ // one page each listen on `window`, so without this every instance would
25
+ // apply every other iframe's height/loaded events to itself.
26
+ if (source !== iframeRef.current?.contentWindow)
27
+ return;
22
28
  const expectedOrigin = new URL(CoinflowUtils.getCoinflowBaseUrl(env))
23
29
  .origin;
24
30
  if (origin !== expectedOrigin)
@@ -94,7 +100,7 @@ const CoinflowCardFormComponent = forwardRef((props, ref) => {
94
100
  variant: 'card-form',
95
101
  });
96
102
  useImperativeHandle(ref, () => ({ tokenize }), [tokenize]);
97
- return (React.createElement(CardFormIFrame, { iframeRef: iframeRef, url: url, loaded: loaded, iframeHeight: iframeHeight, title: "Card Form" }));
103
+ return (React.createElement(CardFormIFrame, { iframeRef: iframeRef, url: url, loaded: loaded, iframeHeight: iframeHeight, title: "Card Form", variant: "card-form", theme: props.theme }));
98
104
  });
99
105
  const CoinflowCardNumberFormComponent = forwardRef((props, ref) => {
100
106
  const { iframeRef, url, loaded, tokenize, iframeHeight } = useCardFormIframe({
@@ -102,7 +108,7 @@ const CoinflowCardNumberFormComponent = forwardRef((props, ref) => {
102
108
  variant: 'card-number-form',
103
109
  });
104
110
  useImperativeHandle(ref, () => ({ tokenize }), [tokenize]);
105
- return (React.createElement(CardFormIFrame, { iframeRef: iframeRef, url: url, loaded: loaded, iframeHeight: iframeHeight, title: "Card Number Form" }));
111
+ return (React.createElement(CardFormIFrame, { iframeRef: iframeRef, url: url, loaded: loaded, iframeHeight: iframeHeight, title: "Card Number Form", variant: "card-number-form", theme: props.theme }));
106
112
  });
107
113
  const CoinflowCvvFormComponent = forwardRef((props, ref) => {
108
114
  const { iframeRef, url, loaded, tokenize, iframeHeight } = useCardFormIframe({
@@ -110,16 +116,87 @@ const CoinflowCvvFormComponent = forwardRef((props, ref) => {
110
116
  variant: 'cvv-form',
111
117
  });
112
118
  useImperativeHandle(ref, () => ({ tokenize }), [tokenize]);
113
- return (React.createElement(CardFormIFrame, { iframeRef: iframeRef, url: url, loaded: loaded, iframeHeight: iframeHeight, title: "CVV Form" }));
119
+ return (React.createElement(CardFormIFrame, { iframeRef: iframeRef, url: url, loaded: loaded, iframeHeight: iframeHeight, title: "CVV Form", variant: "cvv-form", theme: props.theme }));
114
120
  });
115
- function CardFormIFrame({ iframeRef, url, loaded, iframeHeight, title, }) {
116
- return (React.createElement("iframe", { ref: iframeRef, src: url, title: title, frameBorder: "0", allow: "payment", style: {
121
+ function CardFormIFrame({ iframeRef, url, loaded, iframeHeight, title, variant, theme, }) {
122
+ const wrapperRef = useRef(null);
123
+ // Guess the skeleton height from the container width until the iframe reports
124
+ // its real height: compact (stacked) layouts are taller than the inline one.
125
+ const [guessHeight, setGuessHeight] = useState(INLINE_SKELETON_HEIGHT_PX);
126
+ useLayoutEffect(() => {
127
+ // Measure the wrapper div, not the iframe: a freshly-mounted <iframe> is a
128
+ // replaced element with an intrinsic 300px default width before its
129
+ // width:100% resolves, which would briefly (and wrongly) trip the compact
130
+ // breakpoint and jump the height. A block div reports the true container
131
+ // width immediately.
132
+ const el = wrapperRef.current;
133
+ if (!el || !SKELETON_LAYOUTS[variant].compact)
134
+ return;
135
+ const measure = () => setGuessHeight(guessSkeletonHeightPx({ variant, width: el.clientWidth }));
136
+ measure();
137
+ const observer = new ResizeObserver(measure);
138
+ observer.observe(el);
139
+ return () => observer.disconnect();
140
+ }, [variant]);
141
+ const height = loaded && iframeHeight ? `${iframeHeight}px` : `${guessHeight}px`;
142
+ return (React.createElement("div", { ref: wrapperRef, style: { position: 'relative', width: '100%', height } },
143
+ React.createElement(CardFormSkeleton, { variant: variant, hidden: loaded, theme: theme }),
144
+ React.createElement("iframe", { ref: iframeRef, src: url, title: title, frameBorder: "0", allow: "payment", style: {
145
+ width: '100%',
146
+ height,
147
+ border: 'none',
148
+ opacity: loaded ? 1 : 0,
149
+ transition: 'opacity 300ms linear, height 150ms ease-out',
150
+ } })));
151
+ }
152
+ function CardFormSkeleton({ variant, hidden, theme, }) {
153
+ // Stay mounted while fading out so the opacity transition can play, then
154
+ // unmount on transition end. Remount instantly when shown again.
155
+ const [rendered, setRendered] = useState(!hidden);
156
+ if (!hidden && !rendered)
157
+ setRendered(true);
158
+ // Fallback unmount: `transitionend` may never fire (reduced-motion, an
159
+ // ancestor display:none, or opacity already 0), so force cleanup after the
160
+ // fade window regardless.
161
+ useEffect(() => {
162
+ if (!hidden)
163
+ return;
164
+ const timer = setTimeout(() => setRendered(false), SKELETON_FADE_MS);
165
+ return () => clearTimeout(timer);
166
+ }, [hidden]);
167
+ if (!rendered)
168
+ return null;
169
+ const layout = SKELETON_LAYOUTS[variant];
170
+ const gridClass = getSkeletonGridClass(variant);
171
+ // Best-effort tint from the merchant theme's background (neutral when absent).
172
+ const colors = getSkeletonColors(theme);
173
+ return (React.createElement("div", { role: "status", "aria-label": "Loading card form", onTransitionEnd: e => {
174
+ if (e.propertyName === 'opacity' && hidden)
175
+ setRendered(false);
176
+ }, style: {
177
+ position: 'absolute',
178
+ top: 0,
179
+ left: 0,
117
180
  width: '100%',
118
- height: iframeHeight ? `${iframeHeight}px` : '56px',
119
- border: 'none',
120
- opacity: loaded ? 1 : 0,
181
+ height: '100%',
182
+ display: 'flex',
183
+ pointerEvents: 'none',
184
+ flexDirection: 'column',
185
+ gap: 8,
186
+ padding: SKELETON_ROOT_PADDING_PX,
187
+ boxSizing: 'border-box',
188
+ borderRadius: 8,
189
+ background: colors.backdrop,
190
+ containerType: 'inline-size',
191
+ opacity: hidden ? '0%' : '100%',
121
192
  transition: 'opacity 300ms linear, height 150ms ease-out',
122
- } }));
193
+ } },
194
+ React.createElement("style", null, buildSkeletonCss(variant)),
195
+ React.createElement("div", { className: gridClass }, layout.areas.map(area => (React.createElement("div", { key: area, style: {
196
+ ...SKELETON_BOX_STYLE,
197
+ background: colors.box,
198
+ gridArea: area,
199
+ } }))))));
123
200
  }
124
201
  export const CoinflowCardForm = memo(CoinflowCardFormComponent);
125
202
  export const CoinflowCardNumberForm = memo(CoinflowCardNumberFormComponent);
@@ -1 +1 @@
1
- {"version":3,"file":"CoinflowCardFormV2.js","sourceRoot":"","sources":["../../../src/card-form/CoinflowCardFormV2.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,UAAU,EACV,IAAI,EACJ,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAEL,aAAa,EACb,oBAAoB,GAErB,MAAM,WAAW,CAAC;AA+BnB,SAAS,iBAAiB,CAAC,EACzB,OAAO,EACP,UAAU,EACV,GAAG,EACH,KAAK,EACL,KAAK,EACL,MAAM,GACyD;IAC/D,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,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,EAAE,SAAS,IACtB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CACxB,6BACE,GAAG,EAAE,IAAI,EACT,KAAK,EAAE;gBACL,GAAG,kBAAkB;gBACrB,UAAU,EAAE,MAAM,CAAC,GAAG;gBACtB,QAAQ,EAAE,IAAI;aACf,GACD,CACH,CAAC,CACE,CACF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,yBAAyB,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,+BAA+B,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAE9D,+CAA+C;AAC/C,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,qDAAqD;AACrD,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,8CAA8C;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Single source of truth for the card-entry responsive layout.
3
+ *
4
+ * The real card-entry form (`UnifiedCardEntry` in the core-flows app) and the
5
+ * React/Vue/Angular skeleton loaders all render the same grid. Historically the
6
+ * form drove the inline↔two-row switch from JS (a ResizeObserver toggling React
7
+ * state) while the skeletons hard-coded their own guesses, so the two drifted.
8
+ *
9
+ * This module defines the grid templates and the breakpoint ONCE, as pure data
10
+ * plus a CSS builder, so every consumer reflows at exactly the same width via a
11
+ * CSS container query — no JS width measurement, nothing to keep in sync.
12
+ */
13
+ export type CardEntryInputName = 'card-number' | 'expiration' | 'cvv';
14
+ /**
15
+ * Minimum width (px) each field needs before the row is too cramped and the
16
+ * layout drops to two rows. Mirrors the real form's field sizing.
17
+ */
18
+ export declare const CARD_ENTRY_MIN_WIDTHS: Record<CardEntryInputName, number>;
19
+ /** Notional gap (px) between fields, summed into the reflow breakpoint. */
20
+ export declare const CARD_ENTRY_SLOT_GAP_PX = 8;
21
+ /** Field row height — matches the real form's `3rem` grid rows. */
22
+ export declare const CARD_ENTRY_ROW_HEIGHT = "3rem";
23
+ export declare const CARD_ENTRY_ROW_HEIGHT_PX = 48;
24
+ /** 1px accent line between rows / between exp & cvv in the two-row layout. */
25
+ export declare const CARD_ENTRY_DIVIDER_PX = 1;
26
+ /**
27
+ * The form draws its fields inside a 1px border, so the query container (the
28
+ * full iframe width) is 2px wider than the field row that `minRowWidth`
29
+ * describes. The breakpoint bakes this in so form and skeleton flip together.
30
+ */
31
+ export declare const CARD_ENTRY_BORDER_PX = 1;
32
+ /**
33
+ * The form insets its box by this much on every side (Tailwind `m-0.5`) so the
34
+ * focus ring has room and isn't clipped at the iframe edge. It adds to the box's
35
+ * rendered height, so the skeleton's height guess includes it to avoid a jump
36
+ * when the loaded form replaces the skeleton.
37
+ */
38
+ export declare const CARD_ENTRY_MARGIN_PX = 2;
39
+ export type CardEntryConfig = {
40
+ /** Mounted fields, in DOM/visual order. */
41
+ inputs: CardEntryInputName[];
42
+ /** Whether the animated card-brand icon renders left of the PAN slot. */
43
+ hasIcon?: boolean;
44
+ /** Whether the layout may drop to two rows when narrow (default true). */
45
+ allowTwoRow?: boolean;
46
+ };
47
+ export type CardEntryDivider = {
48
+ area: string;
49
+ orientation: 'v' | 'h';
50
+ };
51
+ export type CardEntryLayout = {
52
+ /** grid-template for the wide (inline) layout. */
53
+ inline: string;
54
+ /** grid-template for the narrow (two-row) layout, or null if it never reflows. */
55
+ twoRow: string | null;
56
+ /**
57
+ * Container width (px) below which the two-row layout applies, measured on the
58
+ * query container (full iframe width, incl. the form's border). Null when the
59
+ * config never reflows.
60
+ */
61
+ breakpointPx: number | null;
62
+ /** grid-area names that hold a field, in DOM order (same in both layouts). */
63
+ fieldAreas: string[];
64
+ /** Whether an `icon` area is present (both layouts). */
65
+ hasIconArea: boolean;
66
+ /** Accent-line elements shown only in the two-row layout. */
67
+ twoRowDividers: CardEntryDivider[];
68
+ };
69
+ /** Resolve the full layout (templates + breakpoint + areas) for a config. */
70
+ export declare function buildCardEntryLayout({ inputs, hasIcon, allowTwoRow, }: CardEntryConfig): CardEntryLayout;
71
+ /**
72
+ * Container-query CSS that switches `gridSelector` between the inline and
73
+ * two-row templates at the layout's breakpoint. The element matched by
74
+ * `gridSelector` must be a descendant of a `container-type: inline-size`
75
+ * ancestor named `containerName`.
76
+ *
77
+ * `extraBaseRules` are emitted before the `@container` block (e.g. the default
78
+ * hidden state of two-row-only dividers); `extraCompactRules` are emitted inside
79
+ * it (e.g. revealing those dividers / hiding wide-only chrome). Keeping the base
80
+ * state first ensures the compact rules win when the query matches.
81
+ */
82
+ export declare function buildCardEntryGridCss({ gridSelector, layout, containerName, extraBaseRules, extraCompactRules, }: {
83
+ gridSelector: string;
84
+ layout: CardEntryLayout;
85
+ containerName?: string;
86
+ extraBaseRules?: string;
87
+ extraCompactRules?: string;
88
+ }): string;