@bison-lab/ui 5.8.1 → 5.11.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.d.mts +105 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +317 -161
- package/dist/index.mjs.map +1 -1
- package/dist/validators.d.mts +33 -1
- package/dist/validators.d.mts.map +1 -1
- package/dist/validators.mjs +47 -1
- package/dist/validators.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -521,17 +521,28 @@ const Form = React.forwardRef(({ onSubmit, schema, formMode = "native", errors:
|
|
|
521
521
|
const editedRef = React.useRef(/* @__PURE__ */ new Set());
|
|
522
522
|
const shownRef = React.useRef(/* @__PURE__ */ new Set());
|
|
523
523
|
const judgeBlur = validateOn === "blur" && Boolean(schema);
|
|
524
|
-
/**
|
|
524
|
+
/**
|
|
525
|
+
* Re-judge one field against the whole form's current values, and with it
|
|
526
|
+
* every other field already showing an error. A cross-field rule (a
|
|
527
|
+
* confirmation that must match) reports on one field but is fixed by
|
|
528
|
+
* editing another, so a fix elsewhere has to clear it. Fields not showing
|
|
529
|
+
* an error are left alone: a neighbour's edit never raises a new one.
|
|
530
|
+
*/
|
|
525
531
|
const judgeField = React.useCallback((form, name) => {
|
|
526
532
|
if (!schema) return;
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
533
|
+
const found = schemaErrors(schema, readForm(form));
|
|
534
|
+
const judge = (field) => {
|
|
535
|
+
const message = found[field];
|
|
536
|
+
if (message) {
|
|
537
|
+
shownRef.current.add(field);
|
|
538
|
+
setFieldError(field, message);
|
|
539
|
+
} else if (shownRef.current.has(field)) {
|
|
540
|
+
shownRef.current.delete(field);
|
|
541
|
+
clearFieldError(field);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
judge(name);
|
|
545
|
+
for (const other of Array.from(shownRef.current)) if (other !== name) judge(other);
|
|
535
546
|
}, [
|
|
536
547
|
schema,
|
|
537
548
|
setFieldError,
|
|
@@ -1326,6 +1337,15 @@ const inputSurfaceClasses = "flex w-full rounded-md border border-input bg-backg
|
|
|
1326
1337
|
*/
|
|
1327
1338
|
const inputFocusClasses = "focus-visible:outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary/30 focus-visible:ring-offset-0";
|
|
1328
1339
|
/**
|
|
1340
|
+
* The destructive border on a control in error. Keyed on the `aria-invalid`
|
|
1341
|
+
* a field wrapper already sets, so a stacked field (label above) turns red the
|
|
1342
|
+
* way the outlined layout's shell does. Inside an outlined shell the control's
|
|
1343
|
+
* own border is reset to zero width, so the two never stack.
|
|
1344
|
+
*
|
|
1345
|
+
* Used by: Input, PasswordInput, Checkbox.
|
|
1346
|
+
*/
|
|
1347
|
+
const invalidBorderClasses = "aria-invalid:border-destructive";
|
|
1348
|
+
/**
|
|
1329
1349
|
* Standard single-line input sizing per size: density height + horizontal
|
|
1330
1350
|
* padding + vertical padding, scaled per size. Textarea uses `min-h-[80px]`
|
|
1331
1351
|
* instead of any of these.
|
|
@@ -1444,7 +1464,7 @@ const Input = React.forwardRef(({ className, type, size = "md", ...props }, ref)
|
|
|
1444
1464
|
const fieldProps = useFieldControl(props);
|
|
1445
1465
|
return /* @__PURE__ */ jsx("input", {
|
|
1446
1466
|
type,
|
|
1447
|
-
className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, "file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
|
|
1467
|
+
className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, invalidBorderClasses, "file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
|
|
1448
1468
|
ref,
|
|
1449
1469
|
...fieldProps
|
|
1450
1470
|
});
|
|
@@ -1454,14 +1474,16 @@ Input.displayName = "Input";
|
|
|
1454
1474
|
//#region src/components/password-input.tsx
|
|
1455
1475
|
const PasswordInput = React.forwardRef(({ className, toggleLabel = "Show or hide password", size = "md", ...props }, ref) => {
|
|
1456
1476
|
const fieldProps = useFieldControl(props);
|
|
1477
|
+
const toggleId = `${React.useId()}-toggle`;
|
|
1457
1478
|
return /* @__PURE__ */ jsx(unstable_PasswordToggleField.Root, { children: /* @__PURE__ */ jsxs("div", {
|
|
1458
1479
|
className: "relative",
|
|
1459
1480
|
children: [/* @__PURE__ */ jsx(unstable_PasswordToggleField.Input, {
|
|
1460
|
-
className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, "pr-10 file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
|
|
1481
|
+
className: cn(inputSurfaceClasses, inputSizingClasses(size), inputFocusClasses, invalidBorderClasses, "pr-10 file:border-0 file:bg-transparent file:text-base file:font-medium sm:file:text-sm", className),
|
|
1461
1482
|
ref,
|
|
1462
1483
|
...fieldProps
|
|
1463
1484
|
}), /* @__PURE__ */ jsx(unstable_PasswordToggleField.Toggle, {
|
|
1464
1485
|
className: "absolute right-0 top-0 flex h-full w-10 items-center justify-center text-muted-foreground hover:text-foreground transition-colors disabled:pointer-events-none disabled:opacity-50",
|
|
1486
|
+
id: toggleId,
|
|
1465
1487
|
disabled: props.disabled,
|
|
1466
1488
|
"aria-label": toggleLabel,
|
|
1467
1489
|
children: /* @__PURE__ */ jsx(unstable_PasswordToggleField.Icon, {
|
|
@@ -1998,7 +2020,10 @@ const DatePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a da
|
|
|
1998
2020
|
disabled,
|
|
1999
2021
|
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
|
|
2000
2022
|
...fieldProps,
|
|
2001
|
-
children: [/* @__PURE__ */ jsx(
|
|
2023
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2024
|
+
className: "min-w-0 flex-1 truncate text-left",
|
|
2025
|
+
children: value ? format(value, dateFormat) : placeholder
|
|
2026
|
+
}), /* @__PURE__ */ jsx(Calendar$1, { className: "ml-2 h-4 w-4 shrink-0" })]
|
|
2002
2027
|
})
|
|
2003
2028
|
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
2004
2029
|
className: "w-auto p-0",
|
|
@@ -2260,6 +2285,16 @@ const dateRangePresets = {
|
|
|
2260
2285
|
}
|
|
2261
2286
|
})
|
|
2262
2287
|
};
|
|
2288
|
+
/**
|
|
2289
|
+
* Where the clear button sits: the trigger's right padding, the 16px icon and
|
|
2290
|
+
* the 8px gap before it, so it lands exactly on the reserved slot. Follows
|
|
2291
|
+
* Button's padding per size (px-3, px-4, px-8).
|
|
2292
|
+
*/
|
|
2293
|
+
const clearOffset = {
|
|
2294
|
+
sm: "right-9",
|
|
2295
|
+
md: "right-10",
|
|
2296
|
+
lg: "right-14"
|
|
2297
|
+
};
|
|
2263
2298
|
const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick a date range", dateFormat = "LLL dd, y", disabled = false, className, presets, numberOfMonths = 2, fromDate, toDate, clearable = true, clearLabel = "Clear date range", calendarLabel = "Choose a date range", size = "md" }, ref) => {
|
|
2264
2299
|
const fieldProps = useFieldControl({});
|
|
2265
2300
|
const [open, setOpen] = React.useState(false);
|
|
@@ -2285,14 +2320,20 @@ const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick
|
|
|
2285
2320
|
variant: "outline",
|
|
2286
2321
|
size,
|
|
2287
2322
|
disabled,
|
|
2288
|
-
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground",
|
|
2323
|
+
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
|
|
2289
2324
|
...fieldProps,
|
|
2290
|
-
children: [
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2325
|
+
children: [
|
|
2326
|
+
/* @__PURE__ */ jsx("span", {
|
|
2327
|
+
className: "min-w-0 flex-1 truncate text-left",
|
|
2328
|
+
children: value?.from ? value.to ? `${format(value.from, dateFormat)} – ${format(value.to, dateFormat)}` : format(value.from, dateFormat) : placeholder
|
|
2329
|
+
}),
|
|
2330
|
+
showClear && /* @__PURE__ */ jsx("span", {
|
|
2331
|
+
"aria-hidden": "true",
|
|
2332
|
+
"data-clear-slot": "",
|
|
2333
|
+
className: "ml-2 h-4 w-4 shrink-0"
|
|
2334
|
+
}),
|
|
2335
|
+
/* @__PURE__ */ jsx(Calendar$1, { className: "ml-2 h-4 w-4 shrink-0" })
|
|
2336
|
+
]
|
|
2296
2337
|
})
|
|
2297
2338
|
}), showClear && /* @__PURE__ */ jsx("button", {
|
|
2298
2339
|
type: "button",
|
|
@@ -2302,7 +2343,7 @@ const DateRangePicker = React.forwardRef(({ value, onChange, placeholder = "Pick
|
|
|
2302
2343
|
onKeyDown: (e) => {
|
|
2303
2344
|
if (e.key === "Enter" || e.key === " ") handleClear(e);
|
|
2304
2345
|
},
|
|
2305
|
-
className: "absolute
|
|
2346
|
+
className: cn("absolute top-1/2", clearOffset[size], "-translate-y-1/2 rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1"),
|
|
2306
2347
|
children: /* @__PURE__ */ jsx(CircleX, { className: "h-4 w-4" })
|
|
2307
2348
|
})]
|
|
2308
2349
|
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
@@ -2737,7 +2778,7 @@ const Checkbox = React.forwardRef(({ className, checked, ...props }, ref) => {
|
|
|
2737
2778
|
return /* @__PURE__ */ jsx(Checkbox$1.Root, {
|
|
2738
2779
|
ref,
|
|
2739
2780
|
checked,
|
|
2740
|
-
className: cn("peer h-4 w-4 shrink-0 cursor-pointer rounded-[2px] border border-primary bg-background ring-offset-background transition-[color,background-color,border-color] duration-fast ease-default focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/35 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground", coarseHitAreaClasses, className),
|
|
2781
|
+
className: cn("peer h-4 w-4 shrink-0 cursor-pointer rounded-[2px] border border-primary bg-background ring-offset-background transition-[color,background-color,border-color] duration-fast ease-default focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/35 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground", coarseHitAreaClasses, invalidBorderClasses, className),
|
|
2741
2782
|
...fieldProps,
|
|
2742
2783
|
children: /* @__PURE__ */ jsx(Checkbox$1.Indicator, {
|
|
2743
2784
|
className: cn("flex h-full w-full items-center justify-center text-current"),
|
|
@@ -3063,7 +3104,7 @@ const defaultIcons = {
|
|
|
3063
3104
|
danger: /* @__PURE__ */ jsx(CircleAlert, { className: "size-4" }),
|
|
3064
3105
|
info: /* @__PURE__ */ jsx(Info, { className: "size-4" })
|
|
3065
3106
|
};
|
|
3066
|
-
const Alert = React.forwardRef(({ className, variant = "default", showIcon = false, icon, dismissable = false, onDismiss, children, ...props }, ref) => {
|
|
3107
|
+
const Alert = React.forwardRef(({ className, variant = "default", showIcon = false, icon, dismissable = false, onDismiss, action, children, ...props }, ref) => {
|
|
3067
3108
|
const [dismissed, setDismissed] = React.useState(false);
|
|
3068
3109
|
if (dismissed) return null;
|
|
3069
3110
|
const resolvedIcon = icon ?? (showIcon ? defaultIcons[variant ?? "default"] : null);
|
|
@@ -3084,7 +3125,17 @@ const Alert = React.forwardRef(({ className, variant = "default", showIcon = fal
|
|
|
3084
3125
|
...props,
|
|
3085
3126
|
children: [
|
|
3086
3127
|
leading,
|
|
3087
|
-
/* @__PURE__ */
|
|
3128
|
+
action != null && action !== false ? /* @__PURE__ */ jsxs("div", {
|
|
3129
|
+
className: "flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-center sm:gap-4",
|
|
3130
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3131
|
+
className: "min-w-0 flex-1",
|
|
3132
|
+
children
|
|
3133
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3134
|
+
"data-alert-action": "",
|
|
3135
|
+
className: "shrink-0 whitespace-nowrap font-medium [&_a:not([class])]:underline [&_a:not([class])]:underline-offset-4",
|
|
3136
|
+
children: action
|
|
3137
|
+
})]
|
|
3138
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
3088
3139
|
className: "min-w-0 flex-1",
|
|
3089
3140
|
children
|
|
3090
3141
|
}),
|
|
@@ -5855,6 +5906,83 @@ function SidebarMenuSubButton({ asChild = false, size = "md", isActive = false,
|
|
|
5855
5906
|
});
|
|
5856
5907
|
}
|
|
5857
5908
|
//#endregion
|
|
5909
|
+
//#region src/form/validators.ts
|
|
5910
|
+
/**
|
|
5911
|
+
* A trimmed, non-empty string.
|
|
5912
|
+
*
|
|
5913
|
+
* Trimming happens before the emptiness check, so a field holding only spaces
|
|
5914
|
+
* fails rather than passing as "filled".
|
|
5915
|
+
*/
|
|
5916
|
+
function requiredText({ requiredMessage = "This field is required." } = {}) {
|
|
5917
|
+
return z.string().trim().min(1, { message: requiredMessage });
|
|
5918
|
+
}
|
|
5919
|
+
/** An email address. Trimmed, and empty-tolerant when `optional`. */
|
|
5920
|
+
function emailField({ requiredMessage = "Email address is required.", message = "Enter a valid email address.", optional = false } = {}) {
|
|
5921
|
+
const base = z.string().trim();
|
|
5922
|
+
if (optional) return base.refine((value) => value === "" || z.string().email().safeParse(value).success, { message });
|
|
5923
|
+
return base.min(1, { message: requiredMessage }).email({ message });
|
|
5924
|
+
}
|
|
5925
|
+
/**
|
|
5926
|
+
* A US (NANP) phone number, counted in digits rather than matched by shape.
|
|
5927
|
+
*
|
|
5928
|
+
* Accepts anything `PhoneInput` can produce or a human can paste:
|
|
5929
|
+
* `(555) 123-4567`, `555-123-4567`, `5551234567`, `+1 555 123 4567`. What it
|
|
5930
|
+
* checks is that exactly ten digits are present, which is the only part that
|
|
5931
|
+
* carries meaning — `PhoneInput` already owns the presentation.
|
|
5932
|
+
*/
|
|
5933
|
+
function usPhoneField({ requiredMessage = "Phone number is required.", message = "Enter a 10-digit US phone number.", required = false } = {}) {
|
|
5934
|
+
const base = z.string().trim();
|
|
5935
|
+
const hasTenDigits = (value) => parseUsPhoneDigits(value).length === 10;
|
|
5936
|
+
if (required) return base.min(1, { message: requiredMessage }).refine(hasTenDigits, { message });
|
|
5937
|
+
return base.refine((value) => value === "" || hasTenDigits(value), { message });
|
|
5938
|
+
}
|
|
5939
|
+
/** A value the browser did not post reads as empty, not as a type error. */
|
|
5940
|
+
const posted = (schema) => z.preprocess((value) => value ?? "", schema);
|
|
5941
|
+
/**
|
|
5942
|
+
* A password that only has to be present. Not trimmed: spaces are characters
|
|
5943
|
+
* in a password, and trimming would turn " " into "missing".
|
|
5944
|
+
*/
|
|
5945
|
+
function presentPassword(requiredMessage) {
|
|
5946
|
+
return z.string().min(1, { message: requiredMessage });
|
|
5947
|
+
}
|
|
5948
|
+
/**
|
|
5949
|
+
* The default schema of `SignInBlock`: an email and a password that is
|
|
5950
|
+
* present. Whether the pair is right is the server's call, reported through
|
|
5951
|
+
* the block's `error`.
|
|
5952
|
+
*/
|
|
5953
|
+
function signInSchema() {
|
|
5954
|
+
return z.object({
|
|
5955
|
+
email: posted(emailField()),
|
|
5956
|
+
password: posted(presentPassword("Password is required."))
|
|
5957
|
+
});
|
|
5958
|
+
}
|
|
5959
|
+
/**
|
|
5960
|
+
* The default schema of `SignUpBlock`: first and last name, an email, a
|
|
5961
|
+
* password of at least `minPasswordLength` characters, and a confirmation
|
|
5962
|
+
* that matches it. A site with stricter password rules (an identity
|
|
5963
|
+
* provider's policy, say) passes its own schema to the block.
|
|
5964
|
+
*
|
|
5965
|
+
* The match is reported on `confirmPassword` even while other fields are
|
|
5966
|
+
* still empty, because `validateOn="blur"` judges one field against the
|
|
5967
|
+
* whole form as the person leaves it.
|
|
5968
|
+
*/
|
|
5969
|
+
function signUpSchema({ minPasswordLength = 8 } = {}) {
|
|
5970
|
+
return z.object({
|
|
5971
|
+
firstName: posted(requiredText({ requiredMessage: "First name is required." })),
|
|
5972
|
+
lastName: posted(requiredText({ requiredMessage: "Last name is required." })),
|
|
5973
|
+
email: posted(emailField()),
|
|
5974
|
+
password: posted(presentPassword("Password is required.").min(minPasswordLength, { message: `Use at least ${minPasswordLength} characters.` })),
|
|
5975
|
+
confirmPassword: posted(presentPassword("Confirm your password."))
|
|
5976
|
+
}).refine((data) => !data.confirmPassword || data.password === data.confirmPassword, {
|
|
5977
|
+
message: "Passwords do not match.",
|
|
5978
|
+
path: ["confirmPassword"],
|
|
5979
|
+
when: (payload) => {
|
|
5980
|
+
const value = payload.value;
|
|
5981
|
+
return typeof value?.password === "string" && typeof value?.confirmPassword === "string";
|
|
5982
|
+
}
|
|
5983
|
+
});
|
|
5984
|
+
}
|
|
5985
|
+
//#endregion
|
|
5858
5986
|
//#region src/blocks/auth/social-providers.tsx
|
|
5859
5987
|
const providerConfig = {
|
|
5860
5988
|
google: {
|
|
@@ -5931,7 +6059,17 @@ function SocialProviders({ providers, onSocialLogin, loading, disabled, classNam
|
|
|
5931
6059
|
});
|
|
5932
6060
|
}
|
|
5933
6061
|
//#endregion
|
|
6062
|
+
//#region src/blocks/auth/auth-link.ts
|
|
6063
|
+
/**
|
|
6064
|
+
* A link-styled control in the auth blocks. Underlined, not only colored:
|
|
6065
|
+
* `text-primary` can match the body text in some themes, and a link has to
|
|
6066
|
+
* read as a link without relying on color (WCAG 1.4.1).
|
|
6067
|
+
*/
|
|
6068
|
+
const authLinkClasses = "text-primary underline underline-offset-4 hover:decoration-2";
|
|
6069
|
+
//#endregion
|
|
5934
6070
|
//#region src/blocks/auth/sign-in-block.tsx
|
|
6071
|
+
const DEFAULT_SCHEMA$1 = signInSchema();
|
|
6072
|
+
const OTP_EMAIL_SCHEMA = z.object({ "otp-email": z.preprocess((value) => value ?? "", emailField()) });
|
|
5935
6073
|
const AUTH_TABS = {
|
|
5936
6074
|
PASSWORD: "password",
|
|
5937
6075
|
OTP: "otp"
|
|
@@ -5972,9 +6110,8 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
|
|
|
5972
6110
|
const [otpError, setOtpError] = React.useState();
|
|
5973
6111
|
const isLoading = loading || otpLoading;
|
|
5974
6112
|
const displayError = otpError;
|
|
5975
|
-
const handleEmailSubmit = async (
|
|
5976
|
-
|
|
5977
|
-
const emailValue = new FormData(e.currentTarget).get("otp-email");
|
|
6113
|
+
const handleEmailSubmit = async (data) => {
|
|
6114
|
+
const emailValue = String(data["otp-email"] ?? "");
|
|
5978
6115
|
setOtpError(void 0);
|
|
5979
6116
|
setOtpLoading(true);
|
|
5980
6117
|
try {
|
|
@@ -6015,7 +6152,7 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
|
|
|
6015
6152
|
}),
|
|
6016
6153
|
/* @__PURE__ */ jsx("button", {
|
|
6017
6154
|
type: "button",
|
|
6018
|
-
className: "w-full text-center text-sm
|
|
6155
|
+
className: cn("w-full text-center text-sm", authLinkClasses),
|
|
6019
6156
|
onClick: () => {
|
|
6020
6157
|
setStep("email");
|
|
6021
6158
|
setOtpError(void 0);
|
|
@@ -6024,14 +6161,15 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
|
|
|
6024
6161
|
})
|
|
6025
6162
|
]
|
|
6026
6163
|
})] });
|
|
6027
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: displayError }), /* @__PURE__ */ jsxs(
|
|
6164
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: displayError }), /* @__PURE__ */ jsxs(Form, {
|
|
6165
|
+
schema: OTP_EMAIL_SCHEMA,
|
|
6166
|
+
validateOn: "blur",
|
|
6028
6167
|
onSubmit: handleEmailSubmit,
|
|
6029
6168
|
className: "space-y-4",
|
|
6030
|
-
children: [/* @__PURE__ */ jsx(
|
|
6169
|
+
children: [/* @__PURE__ */ jsx(FormField, {
|
|
6170
|
+
name: "otp-email",
|
|
6031
6171
|
label: "Email",
|
|
6032
|
-
htmlFor: "otp-email",
|
|
6033
6172
|
children: /* @__PURE__ */ jsx(Input, {
|
|
6034
|
-
id: "otp-email",
|
|
6035
6173
|
name: "otp-email",
|
|
6036
6174
|
type: "email",
|
|
6037
6175
|
placeholder: "name@example.com",
|
|
@@ -6049,7 +6187,22 @@ function OtpForm({ onOtpRequest, onOtpVerify, loading = false, disabled = false
|
|
|
6049
6187
|
})]
|
|
6050
6188
|
})] });
|
|
6051
6189
|
}
|
|
6052
|
-
|
|
6190
|
+
/**
|
|
6191
|
+
* Email and password sign-in in a card, with optional social providers and a
|
|
6192
|
+
* one-time-code tab. The fields are a `Form` with `FormField`s, so they get
|
|
6193
|
+
* what every library form gets: the error under the field, a check as the
|
|
6194
|
+
* person leaves a field (`validateOn="blur"`), the shake and focus on the
|
|
6195
|
+
* first wrong field after a failed submit, and a screen-reader summary.
|
|
6196
|
+
*
|
|
6197
|
+
* **Requires `zod` ^4.** The default schema (`signInSchema()` from
|
|
6198
|
+
* `@bison-lab/ui/validators`) is built with it. `zod` is a peer dependency of
|
|
6199
|
+
* `@bison-lab/ui`; install it in the app (`pnpm add zod`) even if the app
|
|
6200
|
+
* writes no schema of its own.
|
|
6201
|
+
*
|
|
6202
|
+
* Server results go in two props: `error` for a message that belongs to no
|
|
6203
|
+
* field (shown in the box above the form), `errors` for one that does.
|
|
6204
|
+
*/
|
|
6205
|
+
function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProviders = [], loading = false, error, errors, schema = DEFAULT_SCHEMA$1, validateOn = "blur", disabled = false, title = "Sign in", description = "Enter your credentials to access your account", signUpHref, onSignUp, className, children, onOtpRequest, onOtpVerify, otpLabel = "Email me a code", onTabChange }) {
|
|
6053
6206
|
const [activeTab, setActiveTab] = React.useState(AUTH_TABS.PASSWORD);
|
|
6054
6207
|
const otpEnabled = Boolean(onOtpRequest && onOtpVerify);
|
|
6055
6208
|
const handleTabChange = React.useCallback((tab) => {
|
|
@@ -6065,23 +6218,23 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
|
|
|
6065
6218
|
}
|
|
6066
6219
|
}, [error, activeTab]);
|
|
6067
6220
|
const visibleError = errorTab === activeTab ? error : void 0;
|
|
6068
|
-
const handleSubmit = async (
|
|
6069
|
-
e.preventDefault();
|
|
6070
|
-
const formData = new FormData(e.currentTarget);
|
|
6221
|
+
const handleSubmit = async (data) => {
|
|
6071
6222
|
await onSubmit({
|
|
6072
|
-
email:
|
|
6073
|
-
password:
|
|
6223
|
+
email: typeof data.email === "string" ? data.email : "",
|
|
6224
|
+
password: typeof data.password === "string" ? data.password : ""
|
|
6074
6225
|
});
|
|
6075
6226
|
};
|
|
6076
|
-
const passwordForm = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: visibleError }), /* @__PURE__ */ jsxs(
|
|
6227
|
+
const passwordForm = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FormError, { message: visibleError }), /* @__PURE__ */ jsxs(Form, {
|
|
6228
|
+
schema,
|
|
6229
|
+
validateOn,
|
|
6230
|
+
errors,
|
|
6077
6231
|
onSubmit: handleSubmit,
|
|
6078
6232
|
className: "space-y-4",
|
|
6079
6233
|
children: [
|
|
6080
|
-
/* @__PURE__ */ jsx(
|
|
6234
|
+
/* @__PURE__ */ jsx(FormField, {
|
|
6235
|
+
name: "email",
|
|
6081
6236
|
label: "Email",
|
|
6082
|
-
htmlFor: "email",
|
|
6083
6237
|
children: /* @__PURE__ */ jsx(Input, {
|
|
6084
|
-
id: "email",
|
|
6085
6238
|
name: "email",
|
|
6086
6239
|
type: "email",
|
|
6087
6240
|
placeholder: "name@example.com",
|
|
@@ -6090,26 +6243,25 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
|
|
|
6090
6243
|
autoComplete: "email"
|
|
6091
6244
|
})
|
|
6092
6245
|
}),
|
|
6093
|
-
/* @__PURE__ */ jsxs(
|
|
6246
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(FormField, {
|
|
6247
|
+
name: "password",
|
|
6094
6248
|
label: "Password",
|
|
6095
|
-
|
|
6096
|
-
children: [/* @__PURE__ */ jsx(PasswordInput, {
|
|
6097
|
-
id: "password",
|
|
6249
|
+
children: /* @__PURE__ */ jsx(PasswordInput, {
|
|
6098
6250
|
name: "password",
|
|
6099
6251
|
required: true,
|
|
6100
6252
|
disabled: loading || disabled,
|
|
6101
6253
|
autoComplete: "current-password"
|
|
6102
|
-
})
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
})
|
|
6112
|
-
}),
|
|
6254
|
+
})
|
|
6255
|
+
}), onForgotPassword && /* @__PURE__ */ jsx("div", {
|
|
6256
|
+
className: "mt-2 flex justify-end",
|
|
6257
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
6258
|
+
type: "button",
|
|
6259
|
+
onClick: onForgotPassword,
|
|
6260
|
+
className: cn("text-sm", "text-primary underline underline-offset-4 hover:decoration-2"),
|
|
6261
|
+
tabIndex: -1,
|
|
6262
|
+
children: "Forgot password?"
|
|
6263
|
+
})
|
|
6264
|
+
})] }),
|
|
6113
6265
|
/* @__PURE__ */ jsx(Button, {
|
|
6114
6266
|
type: "submit",
|
|
6115
6267
|
variant: "default",
|
|
@@ -6146,11 +6298,11 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
|
|
|
6146
6298
|
onSignUp ? /* @__PURE__ */ jsx("button", {
|
|
6147
6299
|
type: "button",
|
|
6148
6300
|
onClick: onSignUp,
|
|
6149
|
-
className: "text-primary
|
|
6301
|
+
className: cn("font-medium", "text-primary underline underline-offset-4 hover:decoration-2"),
|
|
6150
6302
|
children: "Sign up"
|
|
6151
6303
|
}) : /* @__PURE__ */ jsx("a", {
|
|
6152
6304
|
href: signUpHref,
|
|
6153
|
-
className: "text-primary
|
|
6305
|
+
className: cn("font-medium", "text-primary underline underline-offset-4 hover:decoration-2"),
|
|
6154
6306
|
children: "Sign up"
|
|
6155
6307
|
})
|
|
6156
6308
|
]
|
|
@@ -6208,17 +6360,32 @@ function SignInBlock({ onSubmit, onForgotPassword, onSocialLogin, socialProvider
|
|
|
6208
6360
|
}
|
|
6209
6361
|
//#endregion
|
|
6210
6362
|
//#region src/blocks/auth/sign-up-block.tsx
|
|
6211
|
-
|
|
6363
|
+
const DEFAULT_SCHEMA = signUpSchema();
|
|
6364
|
+
/**
|
|
6365
|
+
* Registration in a card: first and last name, email, password and its
|
|
6366
|
+
* confirmation, and a terms tick, with optional social providers. The fields
|
|
6367
|
+
* are a `Form` with `FormField`s, so errors sit under their field, a field is
|
|
6368
|
+
* checked as the person leaves it (`validateOn="blur"`), and a failed submit
|
|
6369
|
+
* shakes the wrong fields, focuses the first and announces the count.
|
|
6370
|
+
*
|
|
6371
|
+
* **Requires `zod` ^4.** The default schema (`signUpSchema()` from
|
|
6372
|
+
* `@bison-lab/ui/validators`) is built with it. `zod` is a peer dependency of
|
|
6373
|
+
* `@bison-lab/ui`; install it in the app (`pnpm add zod`) even if the app
|
|
6374
|
+
* writes no schema of its own.
|
|
6375
|
+
*
|
|
6376
|
+
* Server results go in two props: `error` for a message that belongs to no
|
|
6377
|
+
* field (shown in the box above the form), `errors` for one that does.
|
|
6378
|
+
*/
|
|
6379
|
+
function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading = false, error, errors, schema = DEFAULT_SCHEMA, validateOn = "blur", disabled = false, title = "Create an account", description = "Enter your details to get started", signInHref, onSignIn, termsHref = "#", privacyHref = "#", className }) {
|
|
6212
6380
|
const [termsAccepted, setTermsAccepted] = React.useState(false);
|
|
6213
|
-
const handleSubmit = async (
|
|
6214
|
-
|
|
6215
|
-
const formData = new FormData(e.currentTarget);
|
|
6381
|
+
const handleSubmit = async (data) => {
|
|
6382
|
+
const text = (key) => typeof data[key] === "string" ? data[key] : "";
|
|
6216
6383
|
await onSubmit({
|
|
6217
|
-
firstName:
|
|
6218
|
-
lastName:
|
|
6219
|
-
email:
|
|
6220
|
-
password:
|
|
6221
|
-
confirmPassword:
|
|
6384
|
+
firstName: text("firstName"),
|
|
6385
|
+
lastName: text("lastName"),
|
|
6386
|
+
email: text("email"),
|
|
6387
|
+
password: text("password"),
|
|
6388
|
+
confirmPassword: text("confirmPassword"),
|
|
6222
6389
|
termsAccepted
|
|
6223
6390
|
});
|
|
6224
6391
|
};
|
|
@@ -6249,15 +6416,17 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
|
|
|
6249
6416
|
})]
|
|
6250
6417
|
})] }),
|
|
6251
6418
|
/* @__PURE__ */ jsx(FormError, { message: error }),
|
|
6252
|
-
/* @__PURE__ */ jsxs(
|
|
6419
|
+
/* @__PURE__ */ jsxs(Form, {
|
|
6420
|
+
schema,
|
|
6421
|
+
validateOn,
|
|
6422
|
+
errors,
|
|
6253
6423
|
onSubmit: handleSubmit,
|
|
6254
6424
|
className: "space-y-4",
|
|
6255
6425
|
children: [
|
|
6256
|
-
/* @__PURE__ */ jsx(
|
|
6426
|
+
/* @__PURE__ */ jsx(FormField, {
|
|
6427
|
+
name: "firstName",
|
|
6257
6428
|
label: "First name",
|
|
6258
|
-
htmlFor: "firstName",
|
|
6259
6429
|
children: /* @__PURE__ */ jsx(Input, {
|
|
6260
|
-
id: "firstName",
|
|
6261
6430
|
name: "firstName",
|
|
6262
6431
|
placeholder: "Jane",
|
|
6263
6432
|
required: true,
|
|
@@ -6265,11 +6434,10 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
|
|
|
6265
6434
|
autoComplete: "given-name"
|
|
6266
6435
|
})
|
|
6267
6436
|
}),
|
|
6268
|
-
/* @__PURE__ */ jsx(
|
|
6437
|
+
/* @__PURE__ */ jsx(FormField, {
|
|
6438
|
+
name: "lastName",
|
|
6269
6439
|
label: "Last name",
|
|
6270
|
-
htmlFor: "lastName",
|
|
6271
6440
|
children: /* @__PURE__ */ jsx(Input, {
|
|
6272
|
-
id: "lastName",
|
|
6273
6441
|
name: "lastName",
|
|
6274
6442
|
placeholder: "Doe",
|
|
6275
6443
|
required: true,
|
|
@@ -6277,11 +6445,10 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
|
|
|
6277
6445
|
autoComplete: "family-name"
|
|
6278
6446
|
})
|
|
6279
6447
|
}),
|
|
6280
|
-
/* @__PURE__ */ jsx(
|
|
6448
|
+
/* @__PURE__ */ jsx(FormField, {
|
|
6449
|
+
name: "email",
|
|
6281
6450
|
label: "Email",
|
|
6282
|
-
htmlFor: "email",
|
|
6283
6451
|
children: /* @__PURE__ */ jsx(Input, {
|
|
6284
|
-
id: "email",
|
|
6285
6452
|
name: "email",
|
|
6286
6453
|
type: "email",
|
|
6287
6454
|
placeholder: "name@example.com",
|
|
@@ -6290,22 +6457,20 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
|
|
|
6290
6457
|
autoComplete: "email"
|
|
6291
6458
|
})
|
|
6292
6459
|
}),
|
|
6293
|
-
/* @__PURE__ */ jsx(
|
|
6460
|
+
/* @__PURE__ */ jsx(FormField, {
|
|
6461
|
+
name: "password",
|
|
6294
6462
|
label: "Password",
|
|
6295
|
-
htmlFor: "password",
|
|
6296
6463
|
children: /* @__PURE__ */ jsx(PasswordInput, {
|
|
6297
|
-
id: "password",
|
|
6298
6464
|
name: "password",
|
|
6299
6465
|
required: true,
|
|
6300
6466
|
disabled: loading || disabled,
|
|
6301
6467
|
autoComplete: "new-password"
|
|
6302
6468
|
})
|
|
6303
6469
|
}),
|
|
6304
|
-
/* @__PURE__ */ jsx(
|
|
6470
|
+
/* @__PURE__ */ jsx(FormField, {
|
|
6471
|
+
name: "confirmPassword",
|
|
6305
6472
|
label: "Confirm password",
|
|
6306
|
-
htmlFor: "confirmPassword",
|
|
6307
6473
|
children: /* @__PURE__ */ jsx(PasswordInput, {
|
|
6308
|
-
id: "confirmPassword",
|
|
6309
6474
|
name: "confirmPassword",
|
|
6310
6475
|
required: true,
|
|
6311
6476
|
disabled: loading || disabled,
|
|
@@ -6328,7 +6493,7 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
|
|
|
6328
6493
|
" ",
|
|
6329
6494
|
/* @__PURE__ */ jsx("a", {
|
|
6330
6495
|
href: termsHref,
|
|
6331
|
-
className:
|
|
6496
|
+
className: authLinkClasses,
|
|
6332
6497
|
children: "terms of service"
|
|
6333
6498
|
}),
|
|
6334
6499
|
" ",
|
|
@@ -6336,7 +6501,7 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
|
|
|
6336
6501
|
" ",
|
|
6337
6502
|
/* @__PURE__ */ jsx("a", {
|
|
6338
6503
|
href: privacyHref,
|
|
6339
|
-
className:
|
|
6504
|
+
className: authLinkClasses,
|
|
6340
6505
|
children: "privacy policy"
|
|
6341
6506
|
})
|
|
6342
6507
|
]
|
|
@@ -6359,11 +6524,11 @@ function SignUpBlock({ onSubmit, onSocialLogin, socialProviders = [], loading =
|
|
|
6359
6524
|
onSignIn ? /* @__PURE__ */ jsx("button", {
|
|
6360
6525
|
type: "button",
|
|
6361
6526
|
onClick: onSignIn,
|
|
6362
|
-
className: "text-primary
|
|
6527
|
+
className: cn("font-medium", "text-primary underline underline-offset-4 hover:decoration-2"),
|
|
6363
6528
|
children: "Sign in"
|
|
6364
6529
|
}) : /* @__PURE__ */ jsx("a", {
|
|
6365
6530
|
href: signInHref,
|
|
6366
|
-
className: "text-primary
|
|
6531
|
+
className: cn("font-medium", "text-primary underline underline-offset-4 hover:decoration-2"),
|
|
6367
6532
|
children: "Sign in"
|
|
6368
6533
|
})
|
|
6369
6534
|
]
|
|
@@ -8294,37 +8459,6 @@ const VideoBlock = React.forwardRef(({ eyebrow, title, description, headingLevel
|
|
|
8294
8459
|
});
|
|
8295
8460
|
VideoBlock.displayName = "VideoBlock";
|
|
8296
8461
|
//#endregion
|
|
8297
|
-
//#region src/form/validators.ts
|
|
8298
|
-
/**
|
|
8299
|
-
* A trimmed, non-empty string.
|
|
8300
|
-
*
|
|
8301
|
-
* Trimming happens before the emptiness check, so a field holding only spaces
|
|
8302
|
-
* fails rather than passing as "filled".
|
|
8303
|
-
*/
|
|
8304
|
-
function requiredText({ requiredMessage = "This field is required." } = {}) {
|
|
8305
|
-
return z.string().trim().min(1, { message: requiredMessage });
|
|
8306
|
-
}
|
|
8307
|
-
/** An email address. Trimmed, and empty-tolerant when `optional`. */
|
|
8308
|
-
function emailField({ requiredMessage = "Email address is required.", message = "Enter a valid email address.", optional = false } = {}) {
|
|
8309
|
-
const base = z.string().trim();
|
|
8310
|
-
if (optional) return base.refine((value) => value === "" || z.string().email().safeParse(value).success, { message });
|
|
8311
|
-
return base.min(1, { message: requiredMessage }).email({ message });
|
|
8312
|
-
}
|
|
8313
|
-
/**
|
|
8314
|
-
* A US (NANP) phone number, counted in digits rather than matched by shape.
|
|
8315
|
-
*
|
|
8316
|
-
* Accepts anything `PhoneInput` can produce or a human can paste:
|
|
8317
|
-
* `(555) 123-4567`, `555-123-4567`, `5551234567`, `+1 555 123 4567`. What it
|
|
8318
|
-
* checks is that exactly ten digits are present, which is the only part that
|
|
8319
|
-
* carries meaning — `PhoneInput` already owns the presentation.
|
|
8320
|
-
*/
|
|
8321
|
-
function usPhoneField({ requiredMessage = "Phone number is required.", message = "Enter a 10-digit US phone number.", required = false } = {}) {
|
|
8322
|
-
const base = z.string().trim();
|
|
8323
|
-
const hasTenDigits = (value) => parseUsPhoneDigits(value).length === 10;
|
|
8324
|
-
if (required) return base.min(1, { message: requiredMessage }).refine(hasTenDigits, { message });
|
|
8325
|
-
return base.refine((value) => value === "" || hasTenDigits(value), { message });
|
|
8326
|
-
}
|
|
8327
|
-
//#endregion
|
|
8328
8462
|
//#region src/blocks/marketing/inquiry-form-block.tsx
|
|
8329
8463
|
const AUTOCOMPLETE = {
|
|
8330
8464
|
name: "name",
|
|
@@ -8730,7 +8864,7 @@ const ShowcasePanelsBlock = React.forwardRef(({ items, defaultActiveIndex = 0, a
|
|
|
8730
8864
|
alt: item.image.alt ?? "",
|
|
8731
8865
|
className: "absolute inset-0 h-full w-full object-cover"
|
|
8732
8866
|
});
|
|
8733
|
-
const defaultSpine = (item,
|
|
8867
|
+
const defaultSpine = (item, _i, { numeral }) => {
|
|
8734
8868
|
if (spineVariant === "minimal") return /* @__PURE__ */ jsx("span", {
|
|
8735
8869
|
className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-180 text-sm font-light tracking-[0.25em] whitespace-nowrap text-foreground/90 uppercase [writing-mode:vertical-rl] md:text-base",
|
|
8736
8870
|
children: item.title
|
|
@@ -8766,17 +8900,10 @@ const ShowcasePanelsBlock = React.forwardRef(({ items, defaultActiveIndex = 0, a
|
|
|
8766
8900
|
className: "absolute top-16 left-1/2 -translate-x-1/2 text-xl font-light tracking-widest text-foreground/70 md:text-2xl",
|
|
8767
8901
|
children: numeral
|
|
8768
8902
|
}),
|
|
8903
|
+
" ",
|
|
8769
8904
|
/* @__PURE__ */ jsx("span", {
|
|
8770
8905
|
className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-180 text-sm font-light tracking-[0.25em] whitespace-nowrap text-foreground/90 uppercase [writing-mode:vertical-rl] md:text-base",
|
|
8771
8906
|
children: item.title
|
|
8772
|
-
}),
|
|
8773
|
-
watermark && /* @__PURE__ */ jsxs("span", {
|
|
8774
|
-
className: "absolute bottom-16 left-1/2 -translate-x-1/2 font-mono text-[0.625rem] tracking-widest text-foreground/40 uppercase",
|
|
8775
|
-
children: [
|
|
8776
|
-
watermark,
|
|
8777
|
-
" · ",
|
|
8778
|
-
String(i + 1).padStart(2, "0")
|
|
8779
|
-
]
|
|
8780
8907
|
})
|
|
8781
8908
|
] });
|
|
8782
8909
|
};
|
|
@@ -8850,6 +8977,18 @@ const ShowcasePanelsBlock = React.forwardRef(({ items, defaultActiveIndex = 0, a
|
|
|
8850
8977
|
})
|
|
8851
8978
|
})
|
|
8852
8979
|
}),
|
|
8980
|
+
watermark && !renderSpine && spineVariant !== "minimal" && /* @__PURE__ */ jsx("span", {
|
|
8981
|
+
"aria-hidden": true,
|
|
8982
|
+
className: cn("pointer-events-none absolute inset-0 z-10 transition-opacity duration-300 ease-out", isShown ? "opacity-0" : "opacity-100"),
|
|
8983
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
8984
|
+
className: "absolute bottom-16 left-1/2 -translate-x-1/2 font-mono text-[0.625rem] tracking-widest text-foreground/40 uppercase",
|
|
8985
|
+
children: [
|
|
8986
|
+
watermark,
|
|
8987
|
+
" · ",
|
|
8988
|
+
String(i + 1).padStart(2, "0")
|
|
8989
|
+
]
|
|
8990
|
+
})
|
|
8991
|
+
}),
|
|
8853
8992
|
/* @__PURE__ */ jsxs("div", {
|
|
8854
8993
|
id: panelId(i),
|
|
8855
8994
|
"aria-hidden": !isShown,
|
|
@@ -10111,49 +10250,59 @@ function ResourceScrim({ item, cardVariant }) {
|
|
|
10111
10250
|
return /* @__PURE__ */ jsx("div", {
|
|
10112
10251
|
"aria-hidden": true,
|
|
10113
10252
|
"data-resource-scrim": "true",
|
|
10114
|
-
className: cn("absolute inset-0", item.backgroundClass)
|
|
10253
|
+
className: cn("absolute inset-0 -z-10", item.backgroundClass)
|
|
10115
10254
|
});
|
|
10116
10255
|
}
|
|
10117
10256
|
if (item.scrim) return /* @__PURE__ */ jsx("div", {
|
|
10118
10257
|
"aria-hidden": true,
|
|
10119
10258
|
"data-resource-scrim": "true",
|
|
10120
|
-
className: "absolute inset-0 bg-gradient-to-t from-black/85 to-black/55"
|
|
10259
|
+
className: "absolute inset-0 -z-10 bg-gradient-to-t from-black/85 to-black/55"
|
|
10121
10260
|
});
|
|
10122
10261
|
return null;
|
|
10123
10262
|
}
|
|
10124
|
-
/**
|
|
10125
|
-
|
|
10126
|
-
|
|
10263
|
+
/**
|
|
10264
|
+
* The card box. A linked or clickable card stays a plain box: its title is
|
|
10265
|
+
* the link (`ResourceTitleAction`), stretched over the card, so the link's
|
|
10266
|
+
* accessible name is exactly its visible text (WCAG 2.5.3, Label in Name).
|
|
10267
|
+
* The focus ring is drawn here, around the whole card. `isolate` gives
|
|
10268
|
+
* each card its own stacking context, which the overlay image and the
|
|
10269
|
+
* stretched link's z-index both rely on.
|
|
10270
|
+
*/
|
|
10271
|
+
function ResourceCardWrapper({ item, className, cardVariant, children }) {
|
|
10272
|
+
const actionable = Boolean(item.href || item.onClick);
|
|
10273
|
+
return /* @__PURE__ */ jsx("div", {
|
|
10127
10274
|
"data-resource-id": item.id,
|
|
10128
|
-
...cardVariant === "overlay" && { "data-card-variant": "overlay" }
|
|
10129
|
-
|
|
10275
|
+
...cardVariant === "overlay" && { "data-card-variant": "overlay" },
|
|
10276
|
+
className: cn("relative isolate", actionable && "has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-primary/40 has-[:focus-visible]:ring-offset-2", className),
|
|
10277
|
+
children
|
|
10278
|
+
});
|
|
10279
|
+
}
|
|
10280
|
+
/**
|
|
10281
|
+
* The card's title text, as an anchor (`href`), a button (`onClick`) or plain
|
|
10282
|
+
* text. Its `::after` covers the nearest positioned ancestor, the card, so
|
|
10283
|
+
* the whole card still takes the click.
|
|
10284
|
+
*/
|
|
10285
|
+
function ResourceTitleAction({ item, renderLink }) {
|
|
10286
|
+
const stretch = "after:absolute after:inset-0 after:z-10 after:content-[''] focus-visible:outline-none";
|
|
10130
10287
|
if (item.href) return renderLink({
|
|
10131
10288
|
href: item.href,
|
|
10132
10289
|
...newTabAttributes(item.target === "_blank"),
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
className: cn("block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2", className),
|
|
10136
|
-
children
|
|
10290
|
+
className: stretch,
|
|
10291
|
+
children: item.header
|
|
10137
10292
|
});
|
|
10138
10293
|
if (item.onClick) return /* @__PURE__ */ jsx("button", {
|
|
10139
10294
|
type: "button",
|
|
10140
|
-
"aria-label": item.header,
|
|
10141
10295
|
onClick: item.onClick,
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
children
|
|
10145
|
-
});
|
|
10146
|
-
return /* @__PURE__ */ jsx("div", {
|
|
10147
|
-
className,
|
|
10148
|
-
...dataAttrs,
|
|
10149
|
-
children
|
|
10296
|
+
className: cn("text-left", stretch),
|
|
10297
|
+
children: item.header
|
|
10150
10298
|
});
|
|
10299
|
+
return /* @__PURE__ */ jsx(Fragment, { children: item.header });
|
|
10151
10300
|
}
|
|
10152
|
-
function OverlayCardBody({ item, categoryStyles, headingClassName }) {
|
|
10301
|
+
function OverlayCardBody({ item, categoryStyles, headingClassName, renderLink }) {
|
|
10153
10302
|
const tone = item.image || item.backgroundClass || item.scrim ? "light" : "default";
|
|
10154
10303
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10155
10304
|
/* @__PURE__ */ jsx("div", {
|
|
10156
|
-
className: "absolute inset-0",
|
|
10305
|
+
className: "absolute inset-0 -z-10",
|
|
10157
10306
|
children: /* @__PURE__ */ jsx(ResourceImage, { item })
|
|
10158
10307
|
}),
|
|
10159
10308
|
/* @__PURE__ */ jsx(ResourceScrim, {
|
|
@@ -10161,7 +10310,7 @@ function OverlayCardBody({ item, categoryStyles, headingClassName }) {
|
|
|
10161
10310
|
cardVariant: "overlay"
|
|
10162
10311
|
}),
|
|
10163
10312
|
/* @__PURE__ */ jsxs("div", {
|
|
10164
|
-
className: "
|
|
10313
|
+
className: "flex h-full min-w-0 flex-col justify-between gap-4 p-6",
|
|
10165
10314
|
children: [/* @__PURE__ */ jsx(ResourceCategories, {
|
|
10166
10315
|
item,
|
|
10167
10316
|
categoryStyles
|
|
@@ -10170,7 +10319,10 @@ function OverlayCardBody({ item, categoryStyles, headingClassName }) {
|
|
|
10170
10319
|
children: [
|
|
10171
10320
|
/* @__PURE__ */ jsx("h3", {
|
|
10172
10321
|
className: cn("line-clamp-2 font-semibold tracking-tight", tone === "light" ? "text-white" : "text-foreground", headingClassName),
|
|
10173
|
-
children:
|
|
10322
|
+
children: /* @__PURE__ */ jsx(ResourceTitleAction, {
|
|
10323
|
+
item,
|
|
10324
|
+
renderLink
|
|
10325
|
+
})
|
|
10174
10326
|
}),
|
|
10175
10327
|
item.subtext && /* @__PURE__ */ jsx("p", {
|
|
10176
10328
|
className: cn("line-clamp-2 text-sm", tone === "light" ? "text-white/80" : "text-muted-foreground"),
|
|
@@ -10189,18 +10341,17 @@ function FeaturedResourceCard({ item, categoryStyles, cardVariant = "default", r
|
|
|
10189
10341
|
if (cardVariant === "overlay") return /* @__PURE__ */ jsx(ResourceCardWrapper, {
|
|
10190
10342
|
item,
|
|
10191
10343
|
cardVariant,
|
|
10192
|
-
|
|
10193
|
-
className: "group relative min-h-[24rem] overflow-hidden rounded-lg shadow-sm transition-shadow hover:shadow-md",
|
|
10344
|
+
className: "group min-h-[24rem] overflow-hidden rounded-lg shadow-sm transition-shadow hover:shadow-md",
|
|
10194
10345
|
children: /* @__PURE__ */ jsx(OverlayCardBody, {
|
|
10195
10346
|
item,
|
|
10196
10347
|
categoryStyles,
|
|
10197
|
-
headingClassName: "text-xl md:text-2xl"
|
|
10348
|
+
headingClassName: "text-xl md:text-2xl",
|
|
10349
|
+
renderLink
|
|
10198
10350
|
})
|
|
10199
10351
|
});
|
|
10200
10352
|
return /* @__PURE__ */ jsxs(ResourceCardWrapper, {
|
|
10201
10353
|
item,
|
|
10202
10354
|
cardVariant,
|
|
10203
|
-
renderLink,
|
|
10204
10355
|
className: "group overflow-hidden rounded-lg border bg-card text-card-foreground shadow-sm transition-shadow hover:shadow-md",
|
|
10205
10356
|
children: [/* @__PURE__ */ jsx("div", {
|
|
10206
10357
|
className: "aspect-[16/9] w-full overflow-hidden",
|
|
@@ -10216,7 +10367,10 @@ function FeaturedResourceCard({ item, categoryStyles, cardVariant = "default", r
|
|
|
10216
10367
|
className: "space-y-2",
|
|
10217
10368
|
children: [/* @__PURE__ */ jsx("h3", {
|
|
10218
10369
|
className: "text-xl font-semibold tracking-tight md:text-2xl",
|
|
10219
|
-
children:
|
|
10370
|
+
children: /* @__PURE__ */ jsx(ResourceTitleAction, {
|
|
10371
|
+
item,
|
|
10372
|
+
renderLink
|
|
10373
|
+
})
|
|
10220
10374
|
}), item.subtext && /* @__PURE__ */ jsx("p", {
|
|
10221
10375
|
className: "text-muted-foreground",
|
|
10222
10376
|
children: item.subtext
|
|
@@ -10231,17 +10385,16 @@ function ResourceListCard({ item, categoryStyles, cardVariant = "default", rende
|
|
|
10231
10385
|
if (cardVariant === "overlay") return /* @__PURE__ */ jsx(ResourceCardWrapper, {
|
|
10232
10386
|
item,
|
|
10233
10387
|
cardVariant,
|
|
10234
|
-
|
|
10235
|
-
className: "group relative aspect-[2/1] min-h-[14rem] overflow-hidden rounded-lg shadow-sm transition-shadow hover:shadow-md",
|
|
10388
|
+
className: "group aspect-[2/1] min-h-[14rem] overflow-hidden rounded-lg shadow-sm transition-shadow hover:shadow-md",
|
|
10236
10389
|
children: /* @__PURE__ */ jsx(OverlayCardBody, {
|
|
10237
10390
|
item,
|
|
10238
|
-
categoryStyles
|
|
10391
|
+
categoryStyles,
|
|
10392
|
+
renderLink
|
|
10239
10393
|
})
|
|
10240
10394
|
});
|
|
10241
10395
|
return /* @__PURE__ */ jsxs(ResourceCardWrapper, {
|
|
10242
10396
|
item,
|
|
10243
10397
|
cardVariant,
|
|
10244
|
-
renderLink,
|
|
10245
10398
|
className: "group flex flex-1 gap-4 rounded-lg border bg-card p-4 text-card-foreground shadow-sm transition-shadow hover:shadow-md",
|
|
10246
10399
|
children: [/* @__PURE__ */ jsx("div", {
|
|
10247
10400
|
"data-resource-image": true,
|
|
@@ -10257,7 +10410,10 @@ function ResourceListCard({ item, categoryStyles, cardVariant = "default", rende
|
|
|
10257
10410
|
categoryStyles
|
|
10258
10411
|
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", {
|
|
10259
10412
|
className: "font-semibold tracking-tight",
|
|
10260
|
-
children:
|
|
10413
|
+
children: /* @__PURE__ */ jsx(ResourceTitleAction, {
|
|
10414
|
+
item,
|
|
10415
|
+
renderLink
|
|
10416
|
+
})
|
|
10261
10417
|
}), item.subtext && /* @__PURE__ */ jsx("p", {
|
|
10262
10418
|
className: "line-clamp-2 text-sm text-muted-foreground",
|
|
10263
10419
|
children: item.subtext
|