@kerne/react 0.1.0 → 0.1.2

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,391 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React from 'react';
3
+ import { SubscriptionWithPlan } from '@kerne/types';
4
+ export { K as KerneLocalization, d as defaultLocalization, u as useLocalization } from '../i18n-Qketn1RF.cjs';
5
+
6
+ /**
7
+ * Per-instance overrides of the same custom properties the stylesheet reads,
8
+ * applied as inline style so they win over the class defaults without
9
+ * specificity tricks.
10
+ */
11
+ interface KerneAppearance {
12
+ /**
13
+ * `light` (default), `dark`, or `system` to follow the visitor's OS. Not
14
+ * defaulted to `system`: a light-only host would silently render a dark form
15
+ * for half its users.
16
+ */
17
+ theme?: 'light' | 'dark' | 'system';
18
+ /**
19
+ * The brand colour. Drives the primary button, and - unless overridden below -
20
+ * its label, its hover, and the accent used for focus rings and links.
21
+ */
22
+ primaryColor?: string;
23
+ /** Label on the primary button. Derived from `primaryColor` when omitted. */
24
+ primaryTextColor?: string;
25
+ /** Focus rings and links. Falls back to `primaryColor`. */
26
+ accentColor?: string;
27
+ textColor?: string;
28
+ borderColor?: string;
29
+ /** Background of error/info panels. */
30
+ panelColor?: string;
31
+ /**
32
+ * The ground the component sits on. Leave unset when embedding (the host's
33
+ * page shows through); set it when the component owns the viewport, so its
34
+ * text can never resolve against a background it doesn't know about.
35
+ */
36
+ background?: string;
37
+ /** Opaque ground for the card variant, the account dropdown, a pressed segment. */
38
+ surfaceColor?: string;
39
+ /** `card` wraps the screen in a bordered, raised container. Defaults to `none`. */
40
+ surface?: 'none' | 'card';
41
+ fontFamily?: string;
42
+ /** Corner radius on inputs and buttons, e.g. `"0px"` for square. */
43
+ radius?: string;
44
+ /** Height of inputs and buttons. Defaults to `"44px"`. */
45
+ controlHeight?: string;
46
+ }
47
+
48
+ interface KerneUIProps {
49
+ appearance?: KerneAppearance;
50
+ /** Rendered above the heading - a wordmark or logo. */
51
+ logo?: React.ReactNode;
52
+ className?: string;
53
+ }
54
+
55
+ type AuthFlowStep = 'sign-in' | 'sign-up' | 'forgot-password' | 'reset-password' | 'magic-link' | 'verify-email' | 'activate';
56
+ interface AuthFlowProps extends KerneUIProps {
57
+ /** Where to start when nothing in the URL says otherwise. */
58
+ initialStep?: AuthFlowStep;
59
+ /** Controlled mode - pair with `onStepChange` to drive the flow from your router. */
60
+ step?: AuthFlowStep;
61
+ onStepChange?: (step: AuthFlowStep) => void;
62
+ /** Called once the user holds a session. */
63
+ onSuccess?: () => void;
64
+ /** Hand the session to another origin (the hosted portal's job). */
65
+ redirectUrl?: string;
66
+ /** Where emailed links should land. Defaults to the tenant's configured callbacks. */
67
+ magicLinkCallbackUrl?: string;
68
+ resetPasswordCallbackUrl?: string;
69
+ verificationCallbackUrl?: string;
70
+ /** Skip sign-up entirely, even on an OPEN tenant (e.g. an internal tool). */
71
+ allowSignUp?: boolean;
72
+ legal?: React.ReactNode;
73
+ }
74
+ declare function AuthFlow({ initialStep, step: controlledStep, onStepChange, onSuccess, redirectUrl, magicLinkCallbackUrl, resetPasswordCallbackUrl, verificationCallbackUrl, allowSignUp, legal, appearance, logo, className, }: AuthFlowProps): react_jsx_runtime.JSX.Element;
75
+
76
+ interface LoginFormProps extends KerneUIProps {
77
+ /** Called after a successful password sign-in. */
78
+ onSuccess?: () => void;
79
+ /**
80
+ * Hand the session to another origin after sign-in (the hosted portal's
81
+ * job - see `redirectWithSession`). Takes precedence over `onSuccess`.
82
+ */
83
+ redirectUrl?: string;
84
+ /** Where the emailed sign-in link should land. Defaults to the tenant's configured callback. */
85
+ magicLinkCallbackUrl?: string;
86
+ signUpUrl?: string;
87
+ onSignUpClick?: () => void;
88
+ forgotPasswordUrl?: string;
89
+ onForgotPasswordClick?: () => void;
90
+ onOAuthSelect?: (provider: string) => void;
91
+ title?: string;
92
+ /** Replaces the "First time here? Sign up" line under the title. */
93
+ subtitle?: React.ReactNode;
94
+ /** Small print under the form, e.g. terms and privacy links. */
95
+ legal?: React.ReactNode;
96
+ }
97
+ declare function LoginForm({ onSuccess, redirectUrl, magicLinkCallbackUrl, signUpUrl, onSignUpClick, forgotPasswordUrl, onForgotPasswordClick, onOAuthSelect, title, subtitle, legal, appearance, logo, className, }: LoginFormProps): react_jsx_runtime.JSX.Element;
98
+
99
+ interface RegisterFormProps extends KerneUIProps {
100
+ onSuccess?: () => void;
101
+ /** Hand the session to another origin after sign-up (hosted portal). */
102
+ redirectUrl?: string;
103
+ /** Where the emailed sign-up link should land. Defaults to the tenant's configured callback. */
104
+ magicLinkCallbackUrl?: string;
105
+ /**
106
+ * Invitation token. Read from `?token=` in the URL when omitted, so an
107
+ * emailed invitation link works with no wiring on the host's side.
108
+ */
109
+ invitationToken?: string;
110
+ signInUrl?: string;
111
+ onSignInClick?: () => void;
112
+ onOAuthSelect?: (provider: string) => void;
113
+ title?: string;
114
+ subtitle?: React.ReactNode;
115
+ legal?: React.ReactNode;
116
+ /** Collect a display name alongside the credentials. */
117
+ collectName?: boolean;
118
+ }
119
+ declare function RegisterForm({ onSuccess, redirectUrl, magicLinkCallbackUrl, invitationToken: invitationTokenProp, signInUrl, onSignInClick, onOAuthSelect, title, subtitle, legal, collectName, appearance, logo, className, }: RegisterFormProps): react_jsx_runtime.JSX.Element;
120
+
121
+ interface MagicLinkCallbackProps extends KerneUIProps {
122
+ /** Overrides the `?token=` query param - for hosts that parse routes themselves. */
123
+ token?: string;
124
+ onSuccess?: () => void;
125
+ /** Hand the session to another origin after sign-in (hosted portal). */
126
+ redirectUrl?: string;
127
+ signInUrl?: string;
128
+ onSignInClick?: () => void;
129
+ }
130
+ declare function MagicLinkCallback({ token: tokenProp, onSuccess, redirectUrl, signInUrl, onSignInClick, appearance, logo, className, }: MagicLinkCallbackProps): react_jsx_runtime.JSX.Element;
131
+
132
+ interface ForgotPasswordFormProps extends KerneUIProps {
133
+ /** Where the emailed reset link should land. Defaults to the tenant's configured callback. */
134
+ callbackUrl?: string;
135
+ signInUrl?: string;
136
+ onSignInClick?: () => void;
137
+ onSent?: (email: string) => void;
138
+ title?: string;
139
+ subtitle?: React.ReactNode;
140
+ }
141
+ declare function ForgotPasswordForm({ callbackUrl, signInUrl, onSignInClick, onSent, title, subtitle, appearance, logo, className, }: ForgotPasswordFormProps): react_jsx_runtime.JSX.Element;
142
+
143
+ interface ResetPasswordFormProps extends KerneUIProps {
144
+ /** Overrides the `?token=` query param. */
145
+ token?: string;
146
+ signInUrl?: string;
147
+ onSignInClick?: () => void;
148
+ onSuccess?: () => void;
149
+ title?: string;
150
+ subtitle?: React.ReactNode;
151
+ }
152
+ declare function ResetPasswordForm({ token: tokenProp, signInUrl, onSignInClick, onSuccess, title, subtitle, appearance, logo, className, }: ResetPasswordFormProps): react_jsx_runtime.JSX.Element;
153
+
154
+ interface VerifyEmailFormProps extends KerneUIProps {
155
+ /** Overrides the `?token=` query param. */
156
+ token?: string;
157
+ /** Where a resent verification link should land. */
158
+ callbackUrl?: string;
159
+ onVerified?: () => void;
160
+ title?: string;
161
+ subtitle?: React.ReactNode;
162
+ }
163
+ declare function VerifyEmailForm({ token: tokenProp, callbackUrl, onVerified, title, subtitle, appearance, logo, className, }: VerifyEmailFormProps): react_jsx_runtime.JSX.Element;
164
+
165
+ interface ActivateAccountFormProps extends KerneUIProps {
166
+ /** Overrides the `?token=` query param. */
167
+ token?: string;
168
+ onSuccess?: () => void;
169
+ /** Hand the session to another origin after activation (hosted portal). */
170
+ redirectUrl?: string;
171
+ signInUrl?: string;
172
+ onSignInClick?: () => void;
173
+ title?: string;
174
+ }
175
+ declare function ActivateAccountForm({ token: tokenProp, onSuccess, redirectUrl, signInUrl, onSignInClick, title, appearance, logo, className, }: ActivateAccountFormProps): react_jsx_runtime.JSX.Element;
176
+
177
+ interface ChangePasswordFormProps extends Omit<KerneUIProps, 'logo'> {
178
+ onSuccess?: () => void;
179
+ /** Heading above the fields. Omit for the localized default, `null` for none. */
180
+ title?: string | null;
181
+ }
182
+ declare function ChangePasswordForm({ onSuccess, title, appearance, className, }: ChangePasswordFormProps): react_jsx_runtime.JSX.Element;
183
+
184
+ interface WaitlistFormProps extends KerneUIProps {
185
+ title?: string;
186
+ subtitle?: React.ReactNode;
187
+ /** Collect a name alongside the email. */
188
+ collectName?: boolean;
189
+ /** Attached to the entry - campaign, referrer, anything you want back later. */
190
+ metadata?: Record<string, unknown>;
191
+ submitLabel?: string;
192
+ /** Replaces the default confirmation copy. */
193
+ successMessage?: React.ReactNode;
194
+ onJoined?: (email: string) => void;
195
+ legal?: React.ReactNode;
196
+ }
197
+ declare function WaitlistForm({ title, subtitle, collectName, metadata, submitLabel, successMessage, onJoined, legal, appearance, logo, className, }: WaitlistFormProps): react_jsx_runtime.JSX.Element;
198
+
199
+ interface SignOutButtonProps {
200
+ /** Omit for the localized "Sign out" label. */
201
+ children?: React.ReactNode;
202
+ onSignedOut?: () => void;
203
+ /** Where to send the browser after signing out. */
204
+ redirectUrl?: string;
205
+ className?: string;
206
+ appearance?: KerneAppearance;
207
+ }
208
+ declare function SignOutButton({ children, onSignedOut, redirectUrl, className, appearance, }: SignOutButtonProps): react_jsx_runtime.JSX.Element;
209
+ interface UserButtonMenuItem {
210
+ label: string;
211
+ href?: string;
212
+ onClick?: () => void;
213
+ }
214
+ interface UserButtonProps {
215
+ /** Extra entries above "Sign out" - profile, settings, billing. */
216
+ items?: UserButtonMenuItem[];
217
+ onSignedOut?: () => void;
218
+ signOutRedirectUrl?: string;
219
+ /** Rendered instead of nothing when signed out - e.g. a sign-in link. */
220
+ signedOutFallback?: React.ReactNode;
221
+ appearance?: KerneAppearance;
222
+ className?: string;
223
+ }
224
+ declare function UserButton({ items, onSignedOut, signOutRedirectUrl, signedOutFallback, appearance, className, }: UserButtonProps): react_jsx_runtime.JSX.Element;
225
+
226
+ type UserProfileTab = 'profile' | 'security' | 'billing';
227
+ interface UserProfileExtraTab {
228
+ /** Must not collide with a built-in id. */
229
+ id: string;
230
+ label: string;
231
+ title?: string;
232
+ description?: string;
233
+ content: React.ReactNode;
234
+ }
235
+ interface UserProfileProps extends Omit<KerneUIProps, 'logo'> {
236
+ /** Which built-in tabs to show, in this order. */
237
+ tabs?: UserProfileTab[];
238
+ /** Appended after the built-in tabs. */
239
+ extraTabs?: UserProfileExtraTab[];
240
+ /** Tab shown on mount. Defaults to the first one. */
241
+ defaultTab?: string;
242
+ /** Controlled mode - pair with `onTabChange` to drive tabs from your router. */
243
+ activeTab?: string;
244
+ onTabChange?: (tab: string) => void;
245
+ showDeleteAccount?: boolean;
246
+ onSaved?: () => void;
247
+ onDeleted?: () => void;
248
+ productSlug?: string;
249
+ pricingProductIdOrSlug?: string;
250
+ portalReturnUrl?: string;
251
+ checkoutSuccessUrl?: string;
252
+ checkoutCancelUrl?: string;
253
+ showPlanSwitcher?: boolean;
254
+ showUsage?: boolean;
255
+ usageFeatureKeys?: string[];
256
+ usageLabels?: Record<string, string>;
257
+ verificationCallbackUrl?: string;
258
+ }
259
+ declare function UserProfile({ tabs, extraTabs, defaultTab, activeTab: controlledTab, onTabChange, showDeleteAccount, onSaved, onDeleted, productSlug, pricingProductIdOrSlug, portalReturnUrl, checkoutSuccessUrl, checkoutCancelUrl, showPlanSwitcher, showUsage, usageFeatureKeys, usageLabels, verificationCallbackUrl, appearance, className, }: UserProfileProps): react_jsx_runtime.JSX.Element;
260
+
261
+ /**
262
+ * "Profile" pane: who the user is, and the address they sign in with.
263
+ *
264
+ * The email is deliberately read-only. Changing the address a session is keyed
265
+ * on is a re-verification flow, not a text field, and no endpoint implements it
266
+ * today - rendering an editable input would promise something that silently
267
+ * fails on save.
268
+ */
269
+ interface ProfileSectionProps {
270
+ /** Where a resent verification link should land. */
271
+ verificationCallbackUrl?: string;
272
+ onSaved?: () => void;
273
+ }
274
+ declare function ProfileSection({ verificationCallbackUrl, onSaved }: ProfileSectionProps): react_jsx_runtime.JSX.Element;
275
+
276
+ /**
277
+ * "Security" pane: password, and leaving.
278
+ *
279
+ * Clerk's equivalent also lists active sessions and 2FA. Neither is rendered
280
+ * here because neither exists in the API - there is no session-listing or TOTP
281
+ * endpoint (checked against the public OpenAPI spec). An empty "Active devices"
282
+ * card that never populates is worse than no card, so these appear only once
283
+ * there is something real behind them.
284
+ *
285
+ * The password block hides itself on a magic-link-only tenant: there is no
286
+ * password to change, and `POST /auth/password` would refuse anyway.
287
+ */
288
+ interface SecuritySectionProps {
289
+ showDeleteAccount?: boolean;
290
+ onDeleted?: () => void;
291
+ }
292
+ declare function SecuritySection({ showDeleteAccount, onDeleted }: SecuritySectionProps): react_jsx_runtime.JSX.Element;
293
+
294
+ /**
295
+ * "Billing" pane: the active plan, what it has been used for, and how to move
296
+ * to another one.
297
+ *
298
+ * The plan switcher is a settings control, not the marketing pricing page: it
299
+ * lists what this scope can move to and starts a checkout, and deliberately
300
+ * does not sell. `<PricingTable>` is the surface that sells.
301
+ *
302
+ * Interval handling is the honest minimum until PriceLabel exists (see
303
+ * 34-ENTITLEMENT-ENGINE.md §9.2): prices are grouped by `interval`, and the
304
+ * segmented control only renders when a plan genuinely has more than one. A
305
+ * plan carrying a third price (early-bird, non-profit) still has no way to be
306
+ * described here - which is exactly the gap PriceLabel closes.
307
+ */
308
+ interface BillingSectionProps {
309
+ productSlug?: string;
310
+ /** Product the plan list is read from. Defaults to the tenant's default product. */
311
+ pricingProductIdOrSlug?: string;
312
+ portalReturnUrl?: string;
313
+ checkoutSuccessUrl?: string;
314
+ checkoutCancelUrl?: string;
315
+ /** Hide the plan switcher, e.g. when plan changes go through sales. */
316
+ showPlanSwitcher?: boolean;
317
+ showUsage?: boolean;
318
+ usageFeatureKeys?: string[];
319
+ usageLabels?: Record<string, string>;
320
+ }
321
+ declare function BillingSection({ productSlug, pricingProductIdOrSlug, portalReturnUrl, checkoutSuccessUrl, checkoutCancelUrl, showPlanSwitcher, showUsage, usageFeatureKeys, usageLabels, }: BillingSectionProps): react_jsx_runtime.JSX.Element;
322
+
323
+ interface SubscriptionCardProps extends Omit<KerneUIProps, 'logo'> {
324
+ /** Restrict to one product, when the tenant sells several. */
325
+ productSlug?: string;
326
+ /** Heading above the details. Omit for the localized default, `null` for none. */
327
+ title?: string | null;
328
+ /** Where the provider portal should return to. */
329
+ portalReturnUrl?: string;
330
+ /** Shown when there is no active subscription - your pricing page. */
331
+ upgradeUrl?: string;
332
+ onUpgradeClick?: () => void;
333
+ /** Hide the "Manage billing" button (e.g. when the page has its own). */
334
+ hidePortalButton?: boolean;
335
+ }
336
+ declare function SubscriptionCard({ productSlug, title, portalReturnUrl, upgradeUrl, onUpgradeClick, hidePortalButton, appearance, className, }: SubscriptionCardProps): react_jsx_runtime.JSX.Element;
337
+
338
+ interface UsageMetersProps extends Omit<KerneUIProps, 'logo'> {
339
+ /** Heading above the meters. Omit for the localized default, `null` for none. */
340
+ title?: string | null;
341
+ /** Restrict to these feature keys, in this order - skips the automatic ordering. */
342
+ featureKeys?: string[];
343
+ /** Show entitlements with no ceiling. Off by default: there is no progress to show. */
344
+ showUnlimited?: boolean;
345
+ /** Cap how many meters render, after ordering. */
346
+ limit?: number;
347
+ /** Override the label for a feature key, when the API name is not end-user wording. */
348
+ labels?: Record<string, string>;
349
+ /** Rendered when the scope has no metered quota at all. */
350
+ emptyState?: React.ReactNode;
351
+ }
352
+ declare function UsageMeters({ title, featureKeys, showUnlimited, limit: maxRows, labels, emptyState, appearance, className, }: UsageMetersProps): react_jsx_runtime.JSX.Element;
353
+
354
+ interface CheckoutResultProps extends KerneUIProps {
355
+ /** `cancel` renders the abandoned-checkout copy and skips polling entirely. */
356
+ outcome?: 'success' | 'cancel';
357
+ productSlug?: string;
358
+ /** Where "Continue" sends the user once the subscription is confirmed. */
359
+ continueUrl?: string;
360
+ onContinue?: () => void;
361
+ /** Where to go back to after a cancelled checkout - your pricing page. */
362
+ pricingUrl?: string;
363
+ onRetry?: () => void;
364
+ onConfirmed?: (subscription: SubscriptionWithPlan) => void;
365
+ /** How long to wait for the webhook before showing the "still finishing" state. */
366
+ confirmTimeoutMs?: number;
367
+ }
368
+ declare function CheckoutResult({ outcome, productSlug, continueUrl, onContinue, pricingUrl, onRetry, onConfirmed, confirmTimeoutMs, appearance, logo, className, }: CheckoutResultProps): react_jsx_runtime.JSX.Element;
369
+
370
+ interface UpgradePromptProps extends Omit<KerneUIProps, 'logo'> {
371
+ /** The entitlement that gates the feature. */
372
+ featureKey: string;
373
+ /** How much the action needs, for a quota check. */
374
+ requested?: number;
375
+ /** Human name for the gated capability - beats the raw key in the copy. */
376
+ featureName?: string;
377
+ /** Rendered instead of the prompt when the check allows it. */
378
+ children?: React.ReactNode;
379
+ /** Your pricing page. */
380
+ upgradeUrl?: string;
381
+ onUpgradeClick?: () => void;
382
+ upgradeLabel?: string;
383
+ title?: string;
384
+ /** Replaces the generated explanation entirely. */
385
+ description?: React.ReactNode;
386
+ /** Render nothing at all while the check is in flight. Off by default. */
387
+ hideWhileLoading?: boolean;
388
+ }
389
+ declare function UpgradePrompt({ featureKey, requested, featureName, children, upgradeUrl, onUpgradeClick, upgradeLabel, title, description, hideWhileLoading, appearance, className, }: UpgradePromptProps): react_jsx_runtime.JSX.Element | null;
390
+
391
+ export { ActivateAccountForm, type ActivateAccountFormProps, AuthFlow, type AuthFlowProps, type AuthFlowStep, BillingSection, type BillingSectionProps, ChangePasswordForm, type ChangePasswordFormProps, CheckoutResult, type CheckoutResultProps, ForgotPasswordForm, type ForgotPasswordFormProps, type KerneAppearance, LoginForm, type LoginFormProps, MagicLinkCallback, type MagicLinkCallbackProps, ProfileSection, type ProfileSectionProps, RegisterForm, type RegisterFormProps, ResetPasswordForm, type ResetPasswordFormProps, SecuritySection, type SecuritySectionProps, SignOutButton, type SignOutButtonProps, SubscriptionCard, type SubscriptionCardProps, UpgradePrompt, type UpgradePromptProps, UsageMeters, type UsageMetersProps, UserButton, type UserButtonMenuItem, type UserButtonProps, UserProfile, type UserProfileExtraTab, type UserProfileProps, type UserProfileTab, VerifyEmailForm, type VerifyEmailFormProps, WaitlistForm, type WaitlistFormProps };