@jgb-solutions/kit 0.7.0 → 0.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/CHANGELOG.md +6 -0
- package/README.md +56 -1
- package/dist/account/AccountPage.d.ts +130 -0
- package/dist/account/SignIn.d.ts +54 -0
- package/dist/account/index.d.ts +12 -0
- package/dist/account/native/index.d.ts +173 -0
- package/dist/account/native.d.ts +2 -0
- package/dist/account/native.js +1012 -0
- package/dist/account/result.d.ts +13 -0
- package/dist/account/styles.css +557 -0
- package/dist/account/text.d.ts +108 -0
- package/dist/account/theme.d.ts +47 -0
- package/dist/account/ui.d.ts +73 -0
- package/dist/account.d.ts +2 -0
- package/dist/account.js +1396 -0
- package/package.json +28 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@jgb-solutions/kit`. Versions follow semver.
|
|
4
4
|
|
|
5
|
+
## 0.8.0
|
|
6
|
+
|
|
7
|
+
- `kit/account` (new): the sign-in, sign-up and account pages every app shares, one layout chosen by the owner (2026-12-04), on CSS variables so each app changes only colours, fonts and radius. `SignInPanel`, `SignUpPanel`, `SignedInPanel`, `AccountPage` and its sections, `AccountRoot` and `accountTheme`, and the words in a typed `AccountText` (English: `accountTextEn`). Stylesheet: `@jgb-solutions/kit/account/styles.css`, scoped to `.jac-root`. Actions answer `kit/auth/server`'s `AuthResult`; deleting a Google-only account uses its `REAUTH_REQUIRED` window.
|
|
8
|
+
- `kit/account/native` (new): the same screen for Expo apps (`SignInOrUp`, `AccountProfile` and their pieces). `react-native` and `react-native-svg` are new optional peer dependencies, needed only by this module.
|
|
9
|
+
- Nothing else changes: no breaking changes from 0.7.0.
|
|
10
|
+
|
|
5
11
|
## 0.7.0
|
|
6
12
|
|
|
7
13
|
Security fixes from the 2026-12-04 audit. Breaking changes are marked; see "Upgrading" at the end of this section.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @jgb-solutions/kit
|
|
2
2
|
|
|
3
|
-
One package for JGB Solutions apps, in tree-shakable namespaces: the generic plumbing web apps need (Cloudflare Access, Better Auth) and the admin panel kit (`kit/admin`). An app bundles only the subpaths it imports: one using `kit/access` never ships admin or React code (`bun run check:install` proves it). ESM with TypeScript types, one subpath per module, MIT licensed. The modules run anywhere with Web Crypto and `fetch`: Bun, Node and Cloudflare Workers (`kit/auth/bun` on Bun only, `kit/auth/expo` in React Native, `kit/admin` in React 19 apps).
|
|
3
|
+
One package for JGB Solutions apps, in tree-shakable namespaces: the generic plumbing web apps need (Cloudflare Access, Better Auth) and the admin panel kit (`kit/admin`) and the shared sign-in and account pages (`kit/account`). An app bundles only the subpaths it imports: one using `kit/access` never ships admin or React code (`bun run check:install` proves it). ESM with TypeScript types, one subpath per module, MIT licensed. The modules run anywhere with Web Crypto and `fetch`: Bun, Node and Cloudflare Workers (`kit/auth/bun` on Bun only, `kit/auth/expo` in React Native, `kit/admin` and `kit/account` in React 19 apps, `kit/account/native` in Expo).
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
bun add @jgb-solutions/kit
|
|
@@ -364,6 +364,61 @@ Every text pair meets WCAG AA; `src/contrast.test.ts` checks them, and the E2E t
|
|
|
364
364
|
|
|
365
365
|
Type: Bricolage Grotesque (700/800) for titles and numbers (`tabular-nums`), Figtree (400/500/600) for the rest. Sentence case everywhere. Shape: tiles 24 px (20 on phones), controls 12 px, pills. Motion only in answer to an action, and none with `prefers-reduced-motion`.
|
|
366
366
|
|
|
367
|
+
### `@jgb-solutions/kit/account`: the sign-in and account pages (React 19, and Expo)
|
|
368
|
+
|
|
369
|
+
One sign-in, sign-up and account layout for every app, chosen by the owner (2026-12-04): the same field order, buttons, links and wording rules everywhere, on the web and in Expo. Each app changes only the look (colours, fonts, radius) and the words.
|
|
370
|
+
|
|
371
|
+
- **In:** the sign-in, sign-up and "signed in" cards, and the account page (Profile, the app's own cards, Passkeys, Google, Password, Delete account), in a fixed order.
|
|
372
|
+
- **Not in:** sign-in itself. Every button calls the app's action, which answers `{ ok: true } | { ok: false, code }` (`kit/auth/server`'s `AuthResult`). The kit words the code with the app's `AccountText` (`errorText`), and never shows a raw error. On success the app goes where it wants; the panel stays busy until it does.
|
|
373
|
+
|
|
374
|
+
```tsx
|
|
375
|
+
import '@jgb-solutions/kit/account/styles.css'
|
|
376
|
+
import { AccountRoot, SignInPanel, accountTextEn } from '@jgb-solutions/kit/account'
|
|
377
|
+
|
|
378
|
+
export function SignInPage() {
|
|
379
|
+
return (
|
|
380
|
+
<AccountRoot scheme="dark" theme={{ brand: '#d42320', radiusButton: '12px' }}>
|
|
381
|
+
<SignInPanel
|
|
382
|
+
text={accountTextEn}
|
|
383
|
+
reason={reasonText} // "Sign in to save it to your favorites", or undefined
|
|
384
|
+
initialError={search.error} // Google's ?error= code
|
|
385
|
+
google={() => startGoogleSignIn({ data: { redirect } })} // leave out when Google is off
|
|
386
|
+
passkey={signInWithPasskey}
|
|
387
|
+
onSignIn={(input) => signIn({ data: input })}
|
|
388
|
+
signUpHref="/sign-up"
|
|
389
|
+
renderLink={({ href, className, children }) => (
|
|
390
|
+
<Link to={href} className={className}>
|
|
391
|
+
{children}
|
|
392
|
+
</Link>
|
|
393
|
+
)}
|
|
394
|
+
/>
|
|
395
|
+
</AccountRoot>
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
`SignUpPanel` and `SignedInPanel` work the same way. `AccountPage` takes the person, the passkeys, and one action per change; `afterProfile` holds the app's own cards (notifications, a callout). Deleting an account asks for the password, or, for an account made with Google, a Google sign-in from the last 5 minutes (`confirm: { mode: 'reauth', fresh, onReauth }`, matching `authServer`'s `REAUTH_REQUIRED`). The sections (`ProfileSection`, `PasskeysSection`, `GoogleSection`, `PasswordSection`, `DangerSection`) are exported for a page that needs them apart.
|
|
401
|
+
|
|
402
|
+
**Words:** `AccountText` holds every string; words with a number or a name are functions. Pass a translation, or `{ ...accountTextEn, … }` with a few lines changed. Dates print in UTC, so the server and the browser print the same.
|
|
403
|
+
|
|
404
|
+
**Look:** `AccountRoot`'s `theme` sets these tokens (CSS variables on `.jac-root`; every class is prefixed `jac-`, so nothing outside changes). Light by default, dark with `scheme="dark"` or the system's dark mode (dark by default is a near-black grey). `brandInk` is picked for contrast when the brand is a hex colour.
|
|
405
|
+
|
|
406
|
+
| Theme key | Token | Light default | Dark default |
|
|
407
|
+
| ----------------------------------------------- | -------------------------------------------- | --------------------------------- | --------------------------------- |
|
|
408
|
+
| `brand` / `brandInk` / `brandText` | `--jac-brand` / `-brand-ink` / `-brand-text` | `#2f54c8` / white / `#2a4bb3` | same / same / brand mixed light |
|
|
409
|
+
| `page` / `surface` / `raised` | `--jac-page` / `-surface` / `-raised` | `#f4f4f6` / `#ffffff` / `#ececf0` | `#0b0b0e` / `#15151a` / `#212127` |
|
|
410
|
+
| `line` / `fieldLine` | `--jac-line` / `-field-line` | `#dcdce3` / `#a9a9b4` | `#2d2d34` / `#55555e` |
|
|
411
|
+
| `ink` / `muted` | `--jac-ink` / `-muted` | `#17171c` / `#5b5b66` | `#eeeef1` / `#aaaab2` |
|
|
412
|
+
| `good` / `warn` / `bad` / `info` | `--jac-good` / `-warn` / `-bad` / `-info` | AA on cards | AA on cards |
|
|
413
|
+
| `radiusCard` / `radiusControl` / `radiusButton` | `--jac-radius-card` / `-control` / `-button` | 16px / 12px / 12px | same |
|
|
414
|
+
| `fontDisplay` / `fontBody` | `--jac-font-display` / `-body` | the system's sans | same |
|
|
415
|
+
|
|
416
|
+
Google's button keeps Google's own white style and mark in every theme (its branding rules).
|
|
417
|
+
|
|
418
|
+
#### `kit/account/native`: the same screen in Expo
|
|
419
|
+
|
|
420
|
+
`SignInOrUp` (sign-in and sign-up on one screen, with the mode link), `AccountProfile` (the profile, passkeys, Google, the app's `links`, Sign out, and Delete account behind a second step) and the pieces (`NativeField`, `NativeButton`, `NativeGoogleButton`, `NativeNotice`, `NativeError`, `NativeAvatar`). Same `AccountText`, same actions; the theme is a plain object (`accountNativeDark` or `accountNativeLight`, with your colours, radius and fonts). Needs `react-native` and `react-native-svg` (Google's mark), both optional peer dependencies.
|
|
421
|
+
|
|
367
422
|
## What goes in, and what never goes in
|
|
368
423
|
|
|
369
424
|
**In:** generic plumbing that several apps need in the same shape, written once and tested: checking a signed token, parsing a header, a retry or rate-limit helper, a typed client for a public protocol. Every module:
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type AccountText } from './text';
|
|
3
|
+
import { type AccountLink, type AccountResult } from './ui';
|
|
4
|
+
/** A card of the account page, named by its h2. */
|
|
5
|
+
export declare function AccountSection({ title, tone, children, sectionRef, }: {
|
|
6
|
+
title: string;
|
|
7
|
+
tone?: 'danger';
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
sectionRef?: React.Ref<HTMLElement>;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
/** The page title and Sign out. */
|
|
12
|
+
export declare function AccountHeader({ text, onSignOut }: {
|
|
13
|
+
text: AccountText;
|
|
14
|
+
onSignOut: () => void | Promise<void>;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export type AccountUser = {
|
|
17
|
+
name: string;
|
|
18
|
+
username: string;
|
|
19
|
+
email: string | null;
|
|
20
|
+
image?: string | null | undefined;
|
|
21
|
+
};
|
|
22
|
+
/** A username change refused because the last one was recent: `until` is when the next can happen (ISO). */
|
|
23
|
+
export type SaveResult = AccountResult | {
|
|
24
|
+
ok: false;
|
|
25
|
+
code: 'USERNAME_CHANGED_RECENTLY';
|
|
26
|
+
until?: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
export type ProfileSectionProps = {
|
|
29
|
+
text: AccountText;
|
|
30
|
+
user: AccountUser;
|
|
31
|
+
onSaveName: (name: string) => Promise<SaveResult>;
|
|
32
|
+
onSaveUsername: (username: string) => Promise<SaveResult>;
|
|
33
|
+
usernameLockedUntil?: string | null | undefined;
|
|
34
|
+
/** How often a username may change (the app's rule; 30 is common). */
|
|
35
|
+
usernameChangeDays?: number | undefined;
|
|
36
|
+
nameMax?: number | undefined;
|
|
37
|
+
/** A link to the admin panel, for people allowed in. */
|
|
38
|
+
adminHref?: string | undefined;
|
|
39
|
+
renderLink?: AccountLink | undefined;
|
|
40
|
+
};
|
|
41
|
+
/** Profile: the person, then name, username and email rows, and the admin link. */
|
|
42
|
+
export declare function ProfileSection({ text, user, onSaveName, onSaveUsername, usernameLockedUntil, usernameChangeDays, nameMax, adminHref, renderLink, }: ProfileSectionProps): import("react").JSX.Element;
|
|
43
|
+
export type Passkey = {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string | null;
|
|
46
|
+
createdAt: string | null;
|
|
47
|
+
};
|
|
48
|
+
export type PasskeysSectionProps = {
|
|
49
|
+
text: AccountText;
|
|
50
|
+
passkeys: readonly Passkey[];
|
|
51
|
+
/** The account has no password (made with Google): different words, Google is the way back in. */
|
|
52
|
+
googleOnly: boolean;
|
|
53
|
+
/** Adds one, named `name` ("Passkey 2"); the app reloads the list before answering. */
|
|
54
|
+
onAdd: (name: string) => Promise<AccountResult>;
|
|
55
|
+
onRemove: (id: string) => Promise<AccountResult>;
|
|
56
|
+
};
|
|
57
|
+
/** Passkeys: why they matter, a warning when there are none, the list, and Add. */
|
|
58
|
+
export declare function PasskeysSection({ text, passkeys, googleOnly, onAdd, onRemove }: PasskeysSectionProps): import("react").JSX.Element;
|
|
59
|
+
export type GoogleSectionProps = {
|
|
60
|
+
text: AccountText;
|
|
61
|
+
connected: boolean;
|
|
62
|
+
/** Back from Google after connecting (`?connected=google`): says so, and scrolls into view. */
|
|
63
|
+
justConnected?: boolean | undefined;
|
|
64
|
+
/** Google's `?error=` code after a failed connection. */
|
|
65
|
+
initialError?: string | undefined;
|
|
66
|
+
/** Starts connecting Google (usually a redirect). */
|
|
67
|
+
onConnect: () => Promise<AccountResult>;
|
|
68
|
+
};
|
|
69
|
+
/** Google as a second way in: connected, or Connect Google. */
|
|
70
|
+
export declare function GoogleSection({ text, connected, justConnected, initialError, onConnect }: GoogleSectionProps): import("react").JSX.Element;
|
|
71
|
+
export type PasswordSectionProps = {
|
|
72
|
+
text: AccountText;
|
|
73
|
+
/** False for an account made with Google: the section offers a first password instead. */
|
|
74
|
+
hasPassword: boolean;
|
|
75
|
+
onChange: (input: {
|
|
76
|
+
currentPassword: string;
|
|
77
|
+
newPassword: string;
|
|
78
|
+
}) => Promise<AccountResult>;
|
|
79
|
+
/** Sets a first password; the app reloads (hasPassword becomes true) before answering. */
|
|
80
|
+
onSet: (input: {
|
|
81
|
+
newPassword: string;
|
|
82
|
+
}) => Promise<AccountResult>;
|
|
83
|
+
passwordMin?: number | undefined;
|
|
84
|
+
passwordMax?: number | undefined;
|
|
85
|
+
};
|
|
86
|
+
/** Change password, or Set a password for an account made with Google. */
|
|
87
|
+
export declare function PasswordSection({ text, hasPassword, onChange, onSet, passwordMin, passwordMax, }: PasswordSectionProps): import("react").JSX.Element;
|
|
88
|
+
/**
|
|
89
|
+
* How deleting is confirmed: the password, or, for an account without one (made with Google), a
|
|
90
|
+
* Google sign-in from the last `minutes` (kit/auth/server's REAUTH_MINUTES and REAUTH_REQUIRED).
|
|
91
|
+
*/
|
|
92
|
+
export type DeleteConfirm = {
|
|
93
|
+
mode: 'password';
|
|
94
|
+
} | {
|
|
95
|
+
mode: 'reauth';
|
|
96
|
+
fresh: boolean;
|
|
97
|
+
minutes?: number | undefined;
|
|
98
|
+
onReauth: () => Promise<AccountResult>;
|
|
99
|
+
};
|
|
100
|
+
export type DangerSectionProps = {
|
|
101
|
+
text: AccountText;
|
|
102
|
+
confirm: DeleteConfirm;
|
|
103
|
+
/** Deletes the account; on success the app takes the person away (the panel stays busy). */
|
|
104
|
+
onDelete: (input: {
|
|
105
|
+
password?: string;
|
|
106
|
+
}) => Promise<AccountResult>;
|
|
107
|
+
};
|
|
108
|
+
/** Delete account: a red card, confirmed by the password or by a fresh Google sign-in. */
|
|
109
|
+
export declare function DangerSection({ text, confirm, onDelete }: DangerSectionProps): import("react").JSX.Element;
|
|
110
|
+
export type AccountPageProps = {
|
|
111
|
+
text: AccountText;
|
|
112
|
+
user: AccountUser;
|
|
113
|
+
onSignOut: () => void | Promise<void>;
|
|
114
|
+
/** Just signed up (`?welcome=1`): with no passkey yet, the page asks for one first. */
|
|
115
|
+
welcome?: boolean | undefined;
|
|
116
|
+
profile: Omit<ProfileSectionProps, 'text' | 'user' | 'renderLink'>;
|
|
117
|
+
passkeys: Omit<PasskeysSectionProps, 'text' | 'googleOnly'>;
|
|
118
|
+
/** Leave out when Google sign-in isn't set up. */
|
|
119
|
+
google?: Omit<GoogleSectionProps, 'text'> | undefined;
|
|
120
|
+
password: Omit<PasswordSectionProps, 'text'>;
|
|
121
|
+
danger: Omit<DangerSectionProps, 'text'>;
|
|
122
|
+
/** The app's own cards, after Profile (notifications, then an app callout). */
|
|
123
|
+
afterProfile?: ReactNode;
|
|
124
|
+
renderLink?: AccountLink | undefined;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* The account page, in a fixed order: title and Sign out, the welcome note, Profile, the app's own
|
|
128
|
+
* cards, Passkeys, Google, Password, Delete account.
|
|
129
|
+
*/
|
|
130
|
+
export declare function AccountPage({ text, user, onSignOut, welcome, profile, passkeys, google, password, danger, afterProfile, renderLink, }: AccountPageProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type AccountText } from './text';
|
|
2
|
+
import { type AccountLink, type AccountResult } from './ui';
|
|
3
|
+
type Action<Input = void> = (input: Input) => Promise<AccountResult>;
|
|
4
|
+
type Shared = {
|
|
5
|
+
text: AccountText;
|
|
6
|
+
/** Why the visitor was sent here, in the app's words ("Sign in to save it to your favorites"). */
|
|
7
|
+
reason?: string | undefined;
|
|
8
|
+
/** An error code to show at once, such as Google's `?error=` after a failed sign-in. */
|
|
9
|
+
initialError?: string | undefined;
|
|
10
|
+
/** Starts Google's sign-in (usually a redirect). Leave out when Google isn't set up. */
|
|
11
|
+
google?: Action | undefined;
|
|
12
|
+
renderLink?: AccountLink | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type SignInPanelProps = Shared & {
|
|
15
|
+
signUpHref: string;
|
|
16
|
+
onSignIn: Action<{
|
|
17
|
+
login: string;
|
|
18
|
+
password: string;
|
|
19
|
+
}>;
|
|
20
|
+
/** Signs in with a passkey. Leave out where passkeys can't work. */
|
|
21
|
+
passkey?: Action | undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Sign in: the reason, an error, Google, a passkey, "or", then username or email and
|
|
25
|
+
* password. The footer links to sign-up.
|
|
26
|
+
*/
|
|
27
|
+
export declare function SignInPanel({ text, reason, initialError, google, passkey, onSignIn, signUpHref, renderLink, }: SignInPanelProps): import("react").JSX.Element;
|
|
28
|
+
export type SignUpRules = {
|
|
29
|
+
usernameMin: number;
|
|
30
|
+
usernameMax: number;
|
|
31
|
+
passwordMin: number;
|
|
32
|
+
passwordMax: number;
|
|
33
|
+
};
|
|
34
|
+
/** kit/auth/rules' limits, the ones authServer checks. */
|
|
35
|
+
export declare const DEFAULT_SIGN_UP_RULES: SignUpRules;
|
|
36
|
+
export type SignUpPanelProps = Shared & {
|
|
37
|
+
signInHref: string;
|
|
38
|
+
onSignUp: Action<{
|
|
39
|
+
username: string;
|
|
40
|
+
email: string;
|
|
41
|
+
password: string;
|
|
42
|
+
}>;
|
|
43
|
+
rules?: SignUpRules | undefined;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Create an account: the reason, an error, Google and "or", then username, email
|
|
47
|
+
* (optional) and password, the no-email warning, and the button. The footer links to sign-in.
|
|
48
|
+
*/
|
|
49
|
+
export declare function SignUpPanel({ text, reason, initialError, google, onSignUp, signInHref, rules, renderLink, }: SignUpPanelProps): import("react").JSX.Element;
|
|
50
|
+
/** After Google sends the person back: "Signed in. Taking you back…" while the app finishes. */
|
|
51
|
+
export declare function SignedInPanel({ text }: {
|
|
52
|
+
text: AccountText;
|
|
53
|
+
}): import("react").JSX.Element;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kit/account: the sign-in, sign-up and account pages every app shares (the owner's rule: one
|
|
3
|
+
* layout, the same everywhere). Import the stylesheet once ('@jgb-solutions/kit/account/styles.css'),
|
|
4
|
+
* wrap the pages in <AccountRoot theme={…}>, and give each panel its words (AccountText) and actions.
|
|
5
|
+
* Actions answer `{ ok: true } | { ok: false, code }` (kit/auth/server's AuthResult); the kit words the
|
|
6
|
+
* code with the app's text, and never shows a raw error.
|
|
7
|
+
*/
|
|
8
|
+
export { AccountRoot, accountTheme, type AccountRootProps, type AccountScheme, type AccountTheme } from './theme';
|
|
9
|
+
export { accountTextEn, errorText, type AccountText } from './text';
|
|
10
|
+
export { AccountAvatar, AccountButton, AuthCard, AuthField, FormMessage, GoogleButton, GoogleMark, Notice, OrDivider, plainAccountLink, type AccountButtonProps, type AccountLink, type AccountResult, type AuthFieldProps, type MessageKind, } from './ui';
|
|
11
|
+
export { DEFAULT_SIGN_UP_RULES, SignedInPanel, SignInPanel, SignUpPanel, type SignInPanelProps, type SignUpPanelProps, type SignUpRules, } from './SignIn';
|
|
12
|
+
export { AccountHeader, AccountPage, AccountSection, DangerSection, GoogleSection, PasskeysSection, PasswordSection, ProfileSection, type AccountPageProps, type AccountUser, type DangerSectionProps, type DeleteConfirm, type GoogleSectionProps, type Passkey, type PasskeysSectionProps, type PasswordSectionProps, type ProfileSectionProps, type SaveResult, } from './AccountPage';
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type AccountResult } from '../result';
|
|
3
|
+
import { type AccountText } from '../text';
|
|
4
|
+
/**
|
|
5
|
+
* kit/account/native: the same account screen for Expo apps: one column, sign in or
|
|
6
|
+
* create an account when signed out, the profile when signed in. Same words (AccountText) and the
|
|
7
|
+
* same actions as the web pages; the app changes only the theme.
|
|
8
|
+
*/
|
|
9
|
+
export type AccountNativeTheme = {
|
|
10
|
+
colors: {
|
|
11
|
+
page: string;
|
|
12
|
+
surface: string;
|
|
13
|
+
raised: string;
|
|
14
|
+
/** Field and card borders. */
|
|
15
|
+
border: string;
|
|
16
|
+
text: string;
|
|
17
|
+
muted: string;
|
|
18
|
+
/** Buttons and fills; `brandInk` must read on it. */
|
|
19
|
+
brand: string;
|
|
20
|
+
brandInk: string;
|
|
21
|
+
/** Brand-coloured text and links on the page. */
|
|
22
|
+
accent: string;
|
|
23
|
+
/** Errors, and the danger button's colour. */
|
|
24
|
+
bad: string;
|
|
25
|
+
badInk: string;
|
|
26
|
+
};
|
|
27
|
+
radius: {
|
|
28
|
+
control: number;
|
|
29
|
+
button: number;
|
|
30
|
+
};
|
|
31
|
+
fonts?: {
|
|
32
|
+
display?: string | undefined;
|
|
33
|
+
body?: string | undefined;
|
|
34
|
+
} | undefined;
|
|
35
|
+
};
|
|
36
|
+
/** Dark: near-black greys, with the kit's brand. */
|
|
37
|
+
export declare const accountNativeDark: AccountNativeTheme;
|
|
38
|
+
export declare const accountNativeLight: AccountNativeTheme;
|
|
39
|
+
type Action<Input = void> = (input: Input) => Promise<AccountResult>;
|
|
40
|
+
type Themed = {
|
|
41
|
+
theme: AccountNativeTheme;
|
|
42
|
+
};
|
|
43
|
+
export type NativeFieldProps = Themed & {
|
|
44
|
+
label: string;
|
|
45
|
+
hint?: string | undefined;
|
|
46
|
+
value: string;
|
|
47
|
+
onChangeText: (value: string) => void;
|
|
48
|
+
secure?: boolean | undefined;
|
|
49
|
+
autoComplete?: 'username' | 'email' | 'current-password' | 'new-password' | 'name' | 'off' | undefined;
|
|
50
|
+
keyboardType?: 'default' | 'email-address' | undefined;
|
|
51
|
+
/** Names start with capitals; usernames, emails and passwords never. */
|
|
52
|
+
capitalize?: 'none' | 'words' | undefined;
|
|
53
|
+
maxLength?: number | undefined;
|
|
54
|
+
};
|
|
55
|
+
/** A labelled input, 48 points tall; its hint under it. */
|
|
56
|
+
export declare function NativeField({ theme, label, hint, value, onChangeText, secure, autoComplete, keyboardType, capitalize, maxLength, }: NativeFieldProps): import("react").JSX.Element;
|
|
57
|
+
export type NativeButtonProps = Themed & {
|
|
58
|
+
label: string;
|
|
59
|
+
onPress: () => void;
|
|
60
|
+
variant?: 'primary' | 'quiet' | 'danger' | undefined;
|
|
61
|
+
/** Shows a spinner and ignores presses. */
|
|
62
|
+
busy?: boolean | undefined;
|
|
63
|
+
disabled?: boolean | undefined;
|
|
64
|
+
accessibilityLabel?: string | undefined;
|
|
65
|
+
};
|
|
66
|
+
/** A pill button, at least 44 points tall (Apple's and Google's touch size). */
|
|
67
|
+
export declare function NativeButton({ theme, label, onPress, variant, busy, disabled, accessibilityLabel, }: NativeButtonProps): import("react").JSX.Element;
|
|
68
|
+
/** "Continue with Google": Google's own white button with its mark (Google's branding rules), whatever the app's colours. */
|
|
69
|
+
export declare function NativeGoogleButton({ label, onPress, busy }: {
|
|
70
|
+
label: string;
|
|
71
|
+
onPress: () => void;
|
|
72
|
+
busy?: boolean | undefined;
|
|
73
|
+
}): import("react").JSX.Element;
|
|
74
|
+
/** An error, read out at once. */
|
|
75
|
+
export declare function NativeError({ theme, message }: Themed & {
|
|
76
|
+
message: string | null;
|
|
77
|
+
}): import("react").JSX.Element | null;
|
|
78
|
+
/** A calm note in a box: why the person is here, or a confirmation. */
|
|
79
|
+
export declare function NativeNotice({ theme, children }: Themed & {
|
|
80
|
+
children: ReactNode;
|
|
81
|
+
}): import("react").JSX.Element;
|
|
82
|
+
export type SignInOrUpProps = Themed & {
|
|
83
|
+
text: AccountText;
|
|
84
|
+
/** The intro under "Sign in" (the app's own words: what an account gives). */
|
|
85
|
+
signInIntro: string;
|
|
86
|
+
/** Why the person was sent here ("Sign in to follow Daily News"). */
|
|
87
|
+
reason?: string | undefined;
|
|
88
|
+
google?: Action | undefined;
|
|
89
|
+
/** Leave out where passkeys can't work on this device. */
|
|
90
|
+
passkey?: Action | undefined;
|
|
91
|
+
onSignIn: Action<{
|
|
92
|
+
login: string;
|
|
93
|
+
password: string;
|
|
94
|
+
}>;
|
|
95
|
+
onSignUp: Action<{
|
|
96
|
+
username: string;
|
|
97
|
+
email: string;
|
|
98
|
+
password: string;
|
|
99
|
+
}>;
|
|
100
|
+
rules?: {
|
|
101
|
+
usernameMin: number;
|
|
102
|
+
usernameMax: number;
|
|
103
|
+
passwordMin: number;
|
|
104
|
+
passwordMax: number;
|
|
105
|
+
} | undefined;
|
|
106
|
+
/** Start in sign-up mode. */
|
|
107
|
+
initialMode?: 'in' | 'up' | undefined;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Signed out: title and intro, the reason, Google, a passkey and "or" (sign-in), the
|
|
111
|
+
* fields, the no-email note (sign-up), the error, the button, and the link to the other mode.
|
|
112
|
+
*/
|
|
113
|
+
export declare function SignInOrUp({ theme, text, signInIntro, reason, google, passkey, onSignIn, onSignUp, rules, initialMode, }: SignInOrUpProps): import("react").JSX.Element;
|
|
114
|
+
/** A person's picture (https only) or initials. Decorative: the name is written next to it. */
|
|
115
|
+
export declare function NativeAvatar({ theme, user, size, }: Themed & {
|
|
116
|
+
user: {
|
|
117
|
+
name: string;
|
|
118
|
+
username: string;
|
|
119
|
+
image?: string | null | undefined;
|
|
120
|
+
};
|
|
121
|
+
size?: number;
|
|
122
|
+
}): import("react").JSX.Element;
|
|
123
|
+
type SaveResult = AccountResult | {
|
|
124
|
+
ok: false;
|
|
125
|
+
code: 'USERNAME_CHANGED_RECENTLY';
|
|
126
|
+
until?: string | undefined;
|
|
127
|
+
};
|
|
128
|
+
export type NativeDeleteConfirm = {
|
|
129
|
+
mode: 'password';
|
|
130
|
+
} | {
|
|
131
|
+
mode: 'reauth';
|
|
132
|
+
fresh: boolean;
|
|
133
|
+
minutes?: number | undefined;
|
|
134
|
+
onReauth: Action;
|
|
135
|
+
};
|
|
136
|
+
export type AccountProfileProps = Themed & {
|
|
137
|
+
text: AccountText;
|
|
138
|
+
user: {
|
|
139
|
+
name: string;
|
|
140
|
+
username: string;
|
|
141
|
+
email: string | null;
|
|
142
|
+
image?: string | null | undefined;
|
|
143
|
+
};
|
|
144
|
+
onSaveName: (name: string) => Promise<SaveResult>;
|
|
145
|
+
onSaveUsername: (username: string) => Promise<SaveResult>;
|
|
146
|
+
usernameLockedUntil?: string | null | undefined;
|
|
147
|
+
usernameChangeDays?: number | undefined;
|
|
148
|
+
nameMax?: number | undefined;
|
|
149
|
+
/** Adds a passkey. Leave out where passkeys can't work on this device. */
|
|
150
|
+
onAddPasskey?: Action | undefined;
|
|
151
|
+
/** The account has no password (made with Google). */
|
|
152
|
+
googleOnly: boolean;
|
|
153
|
+
/** Leave out when Google sign-in isn't set up. */
|
|
154
|
+
google?: {
|
|
155
|
+
connected: boolean;
|
|
156
|
+
onConnect: Action;
|
|
157
|
+
} | undefined;
|
|
158
|
+
/** The app's own buttons (My home, Manage on the website), above Sign out. */
|
|
159
|
+
links?: ReactNode;
|
|
160
|
+
onSignOut: () => void | Promise<void>;
|
|
161
|
+
deleteConfirm: NativeDeleteConfirm;
|
|
162
|
+
/** Deletes the account; on success the app signs out and leaves this screen. */
|
|
163
|
+
onDelete: Action<{
|
|
164
|
+
password?: string;
|
|
165
|
+
}>;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Signed in: the avatar and Profile, name and username with Change, the email,
|
|
169
|
+
* passkeys, Google, the app's links, Sign out, and Delete account behind a second step.
|
|
170
|
+
*/
|
|
171
|
+
export declare function AccountProfile({ theme, text, user, onSaveName, onSaveUsername, usernameLockedUntil, usernameChangeDays, nameMax, onAddPasskey, googleOnly, google, links, onSignOut, deleteConfirm, onDelete, }: AccountProfileProps): import("react").JSX.Element;
|
|
172
|
+
export { accountTextEn, errorText, type AccountText } from '../text';
|
|
173
|
+
export type { AccountResult } from '../result';
|