@geomak/ui 5.7.1 → 5.8.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.
- package/dist/index.cjs +295 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +338 -18
- package/dist/index.d.ts +338 -18
- package/dist/index.js +286 -59
- package/dist/index.js.map +1 -1
- package/dist/styles.css +30 -52
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2165,6 +2165,7 @@ function FieldLabel({
|
|
|
2165
2165
|
required,
|
|
2166
2166
|
helperText,
|
|
2167
2167
|
horizontal = false,
|
|
2168
|
+
align = "start",
|
|
2168
2169
|
style,
|
|
2169
2170
|
width,
|
|
2170
2171
|
className = ""
|
|
@@ -2176,7 +2177,10 @@ function FieldLabel({
|
|
|
2176
2177
|
style: { width: horizontal ? width : void 0, ...style },
|
|
2177
2178
|
className: [
|
|
2178
2179
|
"flex items-center gap-1",
|
|
2179
|
-
horizontal ? "
|
|
2180
|
+
horizontal ? "flex-shrink-0 whitespace-nowrap" : "",
|
|
2181
|
+
// Only the 'start' alignment needs the top nudge; 'center' relies
|
|
2182
|
+
// on the row's items-center to line up with a short control.
|
|
2183
|
+
horizontal && align === "start" ? "mt-2" : "",
|
|
2180
2184
|
className
|
|
2181
2185
|
].filter(Boolean).join(" "),
|
|
2182
2186
|
children: [
|
|
@@ -2197,6 +2201,7 @@ function Field({
|
|
|
2197
2201
|
layout = "vertical",
|
|
2198
2202
|
required,
|
|
2199
2203
|
helperText,
|
|
2204
|
+
labelAlign = "start",
|
|
2200
2205
|
labelStyle,
|
|
2201
2206
|
labelWidth,
|
|
2202
2207
|
className = "",
|
|
@@ -2209,7 +2214,7 @@ function Field({
|
|
|
2209
2214
|
{
|
|
2210
2215
|
className: [
|
|
2211
2216
|
"flex",
|
|
2212
|
-
horizontal ?
|
|
2217
|
+
horizontal ? `flex-row gap-3 ${labelAlign === "center" ? "items-center" : "items-start"}` : "flex-col gap-1.5",
|
|
2213
2218
|
className
|
|
2214
2219
|
].filter(Boolean).join(" "),
|
|
2215
2220
|
children: [
|
|
@@ -2221,6 +2226,7 @@ function Field({
|
|
|
2221
2226
|
required,
|
|
2222
2227
|
helperText,
|
|
2223
2228
|
horizontal,
|
|
2229
|
+
align: labelAlign,
|
|
2224
2230
|
style: labelStyle,
|
|
2225
2231
|
width: labelWidth
|
|
2226
2232
|
}
|
|
@@ -2564,15 +2570,7 @@ function Dropdown({
|
|
|
2564
2570
|
hasError && /* @__PURE__ */ jsx("div", { id: errorId, className: "text-status-error text-xs mt-1", children: errorMessage })
|
|
2565
2571
|
] });
|
|
2566
2572
|
}
|
|
2567
|
-
var SHIMMER =
|
|
2568
|
-
"relative overflow-hidden rounded-sm bg-surface-raised",
|
|
2569
|
-
'before:absolute before:inset-0 before:content-[""]',
|
|
2570
|
-
"before:bg-gradient-to-r before:from-transparent before:via-white/30 before:to-transparent",
|
|
2571
|
-
"before:animate-[shimmer_1.6s_linear_infinite]",
|
|
2572
|
-
// Respect prefers-reduced-motion — the resting bg-surface-raised is still
|
|
2573
|
-
// a perfectly legible placeholder for users who have animations off.
|
|
2574
|
-
"motion-reduce:before:hidden"
|
|
2575
|
-
].join(" ");
|
|
2573
|
+
var SHIMMER = "oxy-skeleton rounded-sm bg-surface-raised";
|
|
2576
2574
|
function SkeletonBox({ width, height = 16, radius, className = "", style }) {
|
|
2577
2575
|
return /* @__PURE__ */ jsx(
|
|
2578
2576
|
"span",
|
|
@@ -3679,14 +3677,15 @@ function Checkbox({
|
|
|
3679
3677
|
// legacy alias
|
|
3680
3678
|
onChange,
|
|
3681
3679
|
label,
|
|
3680
|
+
description,
|
|
3682
3681
|
name,
|
|
3683
3682
|
htmlFor,
|
|
3684
3683
|
errorMessage,
|
|
3684
|
+
helperText,
|
|
3685
3685
|
disabled = false,
|
|
3686
|
+
required,
|
|
3686
3687
|
layout = "horizontal",
|
|
3687
|
-
labelPosition = "right"
|
|
3688
|
-
helperText,
|
|
3689
|
-
required
|
|
3688
|
+
labelPosition = "right"
|
|
3690
3689
|
}) {
|
|
3691
3690
|
const isChecked = checked ?? value ?? false;
|
|
3692
3691
|
const labelFirst = labelPosition === "left";
|
|
@@ -3699,11 +3698,12 @@ function Checkbox({
|
|
|
3699
3698
|
name,
|
|
3700
3699
|
checked: isChecked,
|
|
3701
3700
|
disabled,
|
|
3701
|
+
required,
|
|
3702
3702
|
onCheckedChange: (c) => onChange?.({ target: { checked: !!c, id: htmlFor, name } }),
|
|
3703
3703
|
className: [
|
|
3704
|
-
"relative flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center",
|
|
3704
|
+
"relative mt-0.5 flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center",
|
|
3705
3705
|
"rounded-sm border transition-colors duration-150",
|
|
3706
|
-
"border-border-strong
|
|
3706
|
+
hasError ? "border-status-error" : "border-border-strong",
|
|
3707
3707
|
"data-[state=checked]:bg-accent data-[state=checked]:border-accent",
|
|
3708
3708
|
// Focus halo matches the field tokens for a consistent look.
|
|
3709
3709
|
"focus:outline-none focus-visible:ring-[3px] focus-visible:ring-focus-ring",
|
|
@@ -3715,33 +3715,60 @@ function Checkbox({
|
|
|
3715
3715
|
children: /* @__PURE__ */ jsx(CheckboxPrimitive.Indicator, { className: "flex items-center justify-center data-[state=checked]:animate-check-pop", children: /* @__PURE__ */ jsx("svg", { width: "11", height: "9", viewBox: "0 0 11 9", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M1 4.5L4 7.5L10 1", stroke: "white", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
|
|
3716
3716
|
}
|
|
3717
3717
|
);
|
|
3718
|
-
const
|
|
3719
|
-
label,
|
|
3720
|
-
|
|
3721
|
-
|
|
3718
|
+
const labelText = label != null && /* @__PURE__ */ jsxs(
|
|
3719
|
+
"label",
|
|
3720
|
+
{
|
|
3721
|
+
htmlFor,
|
|
3722
|
+
className: ["block select-none text-sm text-foreground leading-snug", disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"].join(" "),
|
|
3723
|
+
children: [
|
|
3724
|
+
label,
|
|
3725
|
+
required && /* @__PURE__ */ jsx("span", { className: "text-status-error ml-0.5", "aria-hidden": "true", children: "*" })
|
|
3726
|
+
]
|
|
3727
|
+
}
|
|
3728
|
+
);
|
|
3729
|
+
const descriptionEl = description != null && /* @__PURE__ */ jsx(
|
|
3730
|
+
"label",
|
|
3731
|
+
{
|
|
3732
|
+
htmlFor,
|
|
3733
|
+
className: `block text-xs text-foreground-secondary mt-0.5 ${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}`,
|
|
3734
|
+
children: description
|
|
3735
|
+
}
|
|
3736
|
+
);
|
|
3737
|
+
let content;
|
|
3738
|
+
if (layout === "vertical") {
|
|
3739
|
+
content = /* @__PURE__ */ jsxs("span", { className: "flex flex-col items-start gap-1.5", children: [
|
|
3740
|
+
labelFirst ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3741
|
+
labelText,
|
|
3742
|
+
box
|
|
3743
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3744
|
+
box,
|
|
3745
|
+
labelText
|
|
3746
|
+
] }),
|
|
3747
|
+
descriptionEl
|
|
3748
|
+
] });
|
|
3749
|
+
} else if (labelFirst) {
|
|
3750
|
+
content = /* @__PURE__ */ jsxs("span", { className: "flex flex-col", children: [
|
|
3751
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-start gap-2.5", children: [
|
|
3752
|
+
labelText,
|
|
3753
|
+
box
|
|
3754
|
+
] }),
|
|
3755
|
+
descriptionEl
|
|
3756
|
+
] });
|
|
3757
|
+
} else {
|
|
3758
|
+
content = /* @__PURE__ */ jsxs("span", { className: "flex items-start gap-2.5", children: [
|
|
3759
|
+
box,
|
|
3760
|
+
/* @__PURE__ */ jsxs("span", { className: "flex flex-col", children: [
|
|
3761
|
+
labelText,
|
|
3762
|
+
descriptionEl
|
|
3763
|
+
] })
|
|
3764
|
+
] });
|
|
3765
|
+
}
|
|
3722
3766
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
3723
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-
|
|
3724
|
-
|
|
3725
|
-
"label",
|
|
3726
|
-
{
|
|
3727
|
-
htmlFor,
|
|
3728
|
-
className: [
|
|
3729
|
-
"inline-flex",
|
|
3730
|
-
layout === "vertical" ? "flex-col items-start gap-1.5" : "flex-row items-center gap-2.5",
|
|
3731
|
-
disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
|
|
3732
|
-
].join(" "),
|
|
3733
|
-
children: labelFirst ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3734
|
-
labelEl,
|
|
3735
|
-
box
|
|
3736
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3737
|
-
box,
|
|
3738
|
-
labelEl
|
|
3739
|
-
] })
|
|
3740
|
-
}
|
|
3741
|
-
),
|
|
3767
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-1", children: [
|
|
3768
|
+
content,
|
|
3742
3769
|
helperText != null && /* @__PURE__ */ jsx(FieldHelpIcon, { text: helperText })
|
|
3743
3770
|
] }),
|
|
3744
|
-
|
|
3771
|
+
hasError && /* @__PURE__ */ jsx("span", { id: errorId, className: "text-xs text-status-error mt-0.5", children: errorMessage })
|
|
3745
3772
|
] });
|
|
3746
3773
|
}
|
|
3747
3774
|
var DOT_SIZE = {
|
|
@@ -3893,6 +3920,7 @@ function Switch({
|
|
|
3893
3920
|
layout,
|
|
3894
3921
|
required,
|
|
3895
3922
|
helperText,
|
|
3923
|
+
labelAlign: "center",
|
|
3896
3924
|
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5", children: [
|
|
3897
3925
|
offLabel != null && /* @__PURE__ */ jsx("label", { htmlFor: id, className: stateLabel(!isOn), children: offLabel }),
|
|
3898
3926
|
/* @__PURE__ */ jsx(
|
|
@@ -4182,19 +4210,17 @@ function TreeSelect({
|
|
|
4182
4210
|
setOpen(false);
|
|
4183
4211
|
}
|
|
4184
4212
|
};
|
|
4185
|
-
return /* @__PURE__ */
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
),
|
|
4197
|
-
/* @__PURE__ */ jsxs(Popover.Root, { open: open && !disabled, onOpenChange: (o) => !disabled && setOpen(o), children: [
|
|
4213
|
+
return /* @__PURE__ */ jsx(
|
|
4214
|
+
Field,
|
|
4215
|
+
{
|
|
4216
|
+
label,
|
|
4217
|
+
htmlFor,
|
|
4218
|
+
errorId,
|
|
4219
|
+
errorMessage,
|
|
4220
|
+
layout,
|
|
4221
|
+
required,
|
|
4222
|
+
helperText,
|
|
4223
|
+
children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Popover.Root, { open: open && !disabled, onOpenChange: (o) => !disabled && setOpen(o), children: [
|
|
4198
4224
|
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
4199
4225
|
"button",
|
|
4200
4226
|
{
|
|
@@ -4258,10 +4284,9 @@ function TreeSelect({
|
|
|
4258
4284
|
)
|
|
4259
4285
|
}
|
|
4260
4286
|
) })
|
|
4261
|
-
] })
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
] });
|
|
4287
|
+
] }) })
|
|
4288
|
+
}
|
|
4289
|
+
);
|
|
4265
4290
|
}
|
|
4266
4291
|
function TreeNodeRow({
|
|
4267
4292
|
node,
|
|
@@ -6213,7 +6238,7 @@ function useForm(options = {}) {
|
|
|
6213
6238
|
isValid: store.isValid,
|
|
6214
6239
|
getValue: store.getValue,
|
|
6215
6240
|
getValues: store.getValues,
|
|
6216
|
-
setValue: (name, value) => store.setValue(name, value),
|
|
6241
|
+
setValue: (name, value, opts) => store.setValue(name, value, opts),
|
|
6217
6242
|
setValues: (patch) => store.setValues(patch),
|
|
6218
6243
|
setError: store.setError,
|
|
6219
6244
|
validateField: (name) => store.validateField(name),
|
|
@@ -6323,6 +6348,208 @@ function useFieldArray(name) {
|
|
|
6323
6348
|
};
|
|
6324
6349
|
}
|
|
6325
6350
|
|
|
6326
|
-
|
|
6351
|
+
// src/components/forms/creditCard.ts
|
|
6352
|
+
var CARD_BRANDS = [
|
|
6353
|
+
{ id: "amex", label: "American Express", short: "AMEX", color: "#1F72CD", pattern: /^3[47]/, lengths: [15], cvv: 4, gaps: [4, 10] },
|
|
6354
|
+
{ id: "visa", label: "Visa", short: "VISA", color: "#1A1F71", pattern: /^4/, lengths: [16, 18, 19], cvv: 3, gaps: [4, 8, 12, 16] },
|
|
6355
|
+
{ id: "mastercard", label: "Mastercard", short: "MC", color: "#EB001B", pattern: /^(5[1-5]|2[2-7])/, lengths: [16], cvv: 3, gaps: [4, 8, 12] },
|
|
6356
|
+
{ id: "discover", label: "Discover", short: "DISC", color: "#FF6000", pattern: /^(6011|64[4-9]|65)/, lengths: [16, 19], cvv: 3, gaps: [4, 8, 12] },
|
|
6357
|
+
{ id: "diners", label: "Diners Club", short: "DINERS", color: "#0079BE", pattern: /^(36|38|30[0-5])/, lengths: [14, 16, 19], cvv: 3, gaps: [4, 10] },
|
|
6358
|
+
{ id: "jcb", label: "JCB", short: "JCB", color: "#0B4EA2", pattern: /^35/, lengths: [16, 17, 18, 19], cvv: 3, gaps: [4, 8, 12] }
|
|
6359
|
+
];
|
|
6360
|
+
var onlyDigits = (s) => (s || "").replace(/\D/g, "");
|
|
6361
|
+
function detectBrand(value) {
|
|
6362
|
+
const d = onlyDigits(value);
|
|
6363
|
+
if (!d) return null;
|
|
6364
|
+
return CARD_BRANDS.find((b) => b.pattern.test(d)) ?? null;
|
|
6365
|
+
}
|
|
6366
|
+
function maxCardLength(value) {
|
|
6367
|
+
const b = detectBrand(value);
|
|
6368
|
+
return b ? Math.max(...b.lengths) : 19;
|
|
6369
|
+
}
|
|
6370
|
+
function luhnValid(value) {
|
|
6371
|
+
const s = onlyDigits(value);
|
|
6372
|
+
if (s.length < 12) return false;
|
|
6373
|
+
let sum = 0;
|
|
6374
|
+
let double = false;
|
|
6375
|
+
for (let i = s.length - 1; i >= 0; i--) {
|
|
6376
|
+
let n = s.charCodeAt(i) - 48;
|
|
6377
|
+
if (double) {
|
|
6378
|
+
n *= 2;
|
|
6379
|
+
if (n > 9) n -= 9;
|
|
6380
|
+
}
|
|
6381
|
+
sum += n;
|
|
6382
|
+
double = !double;
|
|
6383
|
+
}
|
|
6384
|
+
return sum % 10 === 0;
|
|
6385
|
+
}
|
|
6386
|
+
function formatCardNumber(value) {
|
|
6387
|
+
const brand = detectBrand(value);
|
|
6388
|
+
const digits = onlyDigits(value).slice(0, maxCardLength(value));
|
|
6389
|
+
const gaps = brand?.gaps ?? [4, 8, 12, 16];
|
|
6390
|
+
let out = "";
|
|
6391
|
+
for (let i = 0; i < digits.length; i++) {
|
|
6392
|
+
if (gaps.includes(i)) out += " ";
|
|
6393
|
+
out += digits[i];
|
|
6394
|
+
}
|
|
6395
|
+
return out;
|
|
6396
|
+
}
|
|
6397
|
+
function cardNumberError(value) {
|
|
6398
|
+
const d = onlyDigits(value);
|
|
6399
|
+
if (!d) return "Card number is required";
|
|
6400
|
+
const brand = detectBrand(d);
|
|
6401
|
+
if (!brand) return "Unsupported card type";
|
|
6402
|
+
if (!brand.lengths.includes(d.length)) return "Card number is incomplete";
|
|
6403
|
+
if (!luhnValid(d)) return "Card number looks invalid";
|
|
6404
|
+
return void 0;
|
|
6405
|
+
}
|
|
6406
|
+
function formatExpiry(value) {
|
|
6407
|
+
let d = onlyDigits(value).slice(0, 4);
|
|
6408
|
+
if (d.length === 1 && d > "1") d = "0" + d;
|
|
6409
|
+
if (d.length <= 2) return d;
|
|
6410
|
+
return `${d.slice(0, 2)}/${d.slice(2)}`;
|
|
6411
|
+
}
|
|
6412
|
+
function expiryError(value, now = /* @__PURE__ */ new Date()) {
|
|
6413
|
+
if (!value) return "Expiry is required";
|
|
6414
|
+
const m = value.match(/^(\d{2})\/(\d{2})$/);
|
|
6415
|
+
if (!m) return "Use MM/YY";
|
|
6416
|
+
const mm = Number(m[1]);
|
|
6417
|
+
const yy = Number(m[2]);
|
|
6418
|
+
if (mm < 1 || mm > 12) return "Invalid month";
|
|
6419
|
+
const endOfMonth = new Date(2e3 + yy, mm, 0, 23, 59, 59, 999);
|
|
6420
|
+
if (endOfMonth < now) return "Card has expired";
|
|
6421
|
+
return void 0;
|
|
6422
|
+
}
|
|
6423
|
+
function cvvError(value, cardNumber) {
|
|
6424
|
+
const need = detectBrand(cardNumber)?.cvv ?? 3;
|
|
6425
|
+
const d = onlyDigits(value);
|
|
6426
|
+
if (!d) return "CVV is required";
|
|
6427
|
+
if (d.length !== need) return `CVV must be ${need} digits`;
|
|
6428
|
+
return void 0;
|
|
6429
|
+
}
|
|
6430
|
+
var toCard = (vals) => {
|
|
6431
|
+
const number = String(vals.number ?? "");
|
|
6432
|
+
return {
|
|
6433
|
+
number: onlyDigits(number),
|
|
6434
|
+
name: String(vals.name ?? ""),
|
|
6435
|
+
expiry: String(vals.expiry ?? ""),
|
|
6436
|
+
cvv: onlyDigits(String(vals.cvv ?? "")),
|
|
6437
|
+
brand: detectBrand(number)?.id ?? null
|
|
6438
|
+
};
|
|
6439
|
+
};
|
|
6440
|
+
function BrandMark({ brand }) {
|
|
6441
|
+
return /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", "aria-live": "polite", children: [
|
|
6442
|
+
/* @__PURE__ */ jsxs("svg", { width: "28", height: "18", viewBox: "0 0 28 18", fill: "none", "aria-hidden": "true", children: [
|
|
6443
|
+
/* @__PURE__ */ jsx("rect", { x: "0.5", y: "0.5", width: "27", height: "17", rx: "3", fill: "var(--color-surface-raised)", stroke: "var(--color-border)" }),
|
|
6444
|
+
/* @__PURE__ */ jsx("rect", { x: "0.5", y: "3.75", width: "27", height: "3.5", fill: brand ? brand.color : "var(--color-border-strong)" })
|
|
6445
|
+
] }),
|
|
6446
|
+
brand && /* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold uppercase tracking-wide", style: { color: brand.color }, children: brand.short }),
|
|
6447
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: brand ? brand.label : "Unknown card type" })
|
|
6448
|
+
] });
|
|
6449
|
+
}
|
|
6450
|
+
function CreditCardForm({
|
|
6451
|
+
onSubmit,
|
|
6452
|
+
onChange,
|
|
6453
|
+
defaultValue,
|
|
6454
|
+
size = "md",
|
|
6455
|
+
disabled,
|
|
6456
|
+
requireName = true,
|
|
6457
|
+
hideSubmit = false,
|
|
6458
|
+
submitLabel = "Pay",
|
|
6459
|
+
className = "",
|
|
6460
|
+
style
|
|
6461
|
+
}) {
|
|
6462
|
+
const initial = useRef({
|
|
6463
|
+
number: formatCardNumber(defaultValue?.number ?? ""),
|
|
6464
|
+
name: defaultValue?.name ?? "",
|
|
6465
|
+
expiry: formatExpiry(defaultValue?.expiry ?? ""),
|
|
6466
|
+
cvv: onlyDigits(defaultValue?.cvv ?? "")
|
|
6467
|
+
}).current;
|
|
6468
|
+
const form = useForm({ initialValues: initial });
|
|
6469
|
+
const numberStr = String(form.values.number ?? "");
|
|
6470
|
+
const brand = detectBrand(numberStr);
|
|
6471
|
+
useEffect(() => {
|
|
6472
|
+
onChange?.(toCard(form.values));
|
|
6473
|
+
}, [form.values.number, form.values.name, form.values.expiry, form.values.cvv]);
|
|
6474
|
+
const numberBind = form.fieldNative("number", {
|
|
6475
|
+
required: "Card number is required",
|
|
6476
|
+
validate: (v) => cardNumberError(String(v))
|
|
6477
|
+
});
|
|
6478
|
+
const nameBind = form.fieldNative("name", requireName ? { required: "Cardholder name is required" } : void 0);
|
|
6479
|
+
const expiryBind = form.fieldNative("expiry", {
|
|
6480
|
+
required: "Expiry is required",
|
|
6481
|
+
validate: (v) => expiryError(String(v))
|
|
6482
|
+
});
|
|
6483
|
+
const cvvBind = form.fieldNative("cvv", {
|
|
6484
|
+
required: "CVV is required",
|
|
6485
|
+
validate: (v) => cvvError(String(v), numberStr)
|
|
6486
|
+
});
|
|
6487
|
+
const cvvLen = brand?.cvv ?? 3;
|
|
6488
|
+
return /* @__PURE__ */ jsxs(
|
|
6489
|
+
Form,
|
|
6490
|
+
{
|
|
6491
|
+
form,
|
|
6492
|
+
onFinish: (vals) => onSubmit?.(toCard(vals)),
|
|
6493
|
+
className: `flex flex-col gap-4 ${className}`.trim(),
|
|
6494
|
+
style,
|
|
6495
|
+
children: [
|
|
6496
|
+
/* @__PURE__ */ jsx(
|
|
6497
|
+
TextInput,
|
|
6498
|
+
{
|
|
6499
|
+
...numberBind,
|
|
6500
|
+
label: "Card number",
|
|
6501
|
+
placeholder: "1234 5678 9012 3456",
|
|
6502
|
+
size,
|
|
6503
|
+
disabled,
|
|
6504
|
+
value: numberStr,
|
|
6505
|
+
onChange: (e) => form.setValue("number", formatCardNumber(e.target.value), { touch: true }),
|
|
6506
|
+
suffix: /* @__PURE__ */ jsx(BrandMark, { brand })
|
|
6507
|
+
}
|
|
6508
|
+
),
|
|
6509
|
+
/* @__PURE__ */ jsx(
|
|
6510
|
+
TextInput,
|
|
6511
|
+
{
|
|
6512
|
+
...nameBind,
|
|
6513
|
+
label: "Cardholder name",
|
|
6514
|
+
placeholder: "Jane Appleseed",
|
|
6515
|
+
size,
|
|
6516
|
+
disabled,
|
|
6517
|
+
value: String(form.values.name ?? ""),
|
|
6518
|
+
onChange: (e) => form.setValue("name", e.target.value, { touch: true })
|
|
6519
|
+
}
|
|
6520
|
+
),
|
|
6521
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
6522
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
|
|
6523
|
+
TextInput,
|
|
6524
|
+
{
|
|
6525
|
+
...expiryBind,
|
|
6526
|
+
label: "Expiry",
|
|
6527
|
+
placeholder: "MM/YY",
|
|
6528
|
+
size,
|
|
6529
|
+
disabled,
|
|
6530
|
+
value: String(form.values.expiry ?? ""),
|
|
6531
|
+
onChange: (e) => form.setValue("expiry", formatExpiry(e.target.value), { touch: true })
|
|
6532
|
+
}
|
|
6533
|
+
) }),
|
|
6534
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
|
|
6535
|
+
TextInput,
|
|
6536
|
+
{
|
|
6537
|
+
...cvvBind,
|
|
6538
|
+
label: "CVV",
|
|
6539
|
+
placeholder: cvvLen === 4 ? "1234" : "123",
|
|
6540
|
+
size,
|
|
6541
|
+
disabled,
|
|
6542
|
+
value: String(form.values.cvv ?? ""),
|
|
6543
|
+
onChange: (e) => form.setValue("cvv", onlyDigits(e.target.value).slice(0, cvvLen), { touch: true })
|
|
6544
|
+
}
|
|
6545
|
+
) })
|
|
6546
|
+
] }),
|
|
6547
|
+
!hideSubmit && /* @__PURE__ */ jsx(Button, { content: submitLabel, buttonType: "submit", variant: "primary", disabled })
|
|
6548
|
+
]
|
|
6549
|
+
}
|
|
6550
|
+
);
|
|
6551
|
+
}
|
|
6552
|
+
|
|
6553
|
+
export { AppShell, AutoComplete, Avatar, Box, Button, CARD_BRANDS, Catalog, CatalogCarousel, CatalogGrid, Checkbox, ColorPicker, ContextMenu, CreditCardForm, DateRangePicker, Drawer, Dropdown, FadingBase, Field, FieldHelpIcon, FieldLabel, FileInput, Flex, Form, FormContext, FormField, FormStore, Grid2 as Grid, GridCard, icons_default as Icon, IconButton, List2 as List, LoadingSpinner, Modal, NotificationProvider, NumberInput, OpaqueGridCard, OtpInput, Password, Portal, RadioGroup, Rating, ScalableContainer, SearchInput_default as SearchInput, SegmentedControl, Sidebar, SkeletonBox, SkeletonCard, SkeletonCircle, SkeletonText, Slider, Switch, Table, Tabs, TagsInput, DatePicker as Temporal, TextArea, TextInput, ThemeProvider, ThemeSwitch, TimePicker, Tooltip, TooltipProvider, TopBar, Tree, TreeSelect, Typography, Wizard, cardNumberError, cvvError, detectBrand, expiryError, fieldShell, formatCardNumber, formatExpiry, isRequired, luhnValid, onlyDigits, patterns, runFieldRules, useFieldArray, useForm, useFormField, useFormStore, useNotification };
|
|
6327
6554
|
//# sourceMappingURL=index.js.map
|
|
6328
6555
|
//# sourceMappingURL=index.js.map
|