@ternkit/tern 1.9.0 → 1.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.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime/builtin.js +120 -0
- package/dist/runtime/router.svelte.js +35 -0
- package/dist/runtime/types.d.ts +2 -0
- package/dist/ui/AcceptInvitation.svelte +74 -0
- package/dist/ui/AcceptInvitation.svelte.d.ts +34 -0
- package/dist/ui/ActivityLog.svelte +67 -0
- package/dist/ui/ActivityLog.svelte.d.ts +27 -0
- package/dist/ui/AuthCard.svelte +3 -2
- package/dist/ui/BillingSettings.svelte +120 -0
- package/dist/ui/BillingSettings.svelte.d.ts +27 -0
- package/dist/ui/NewTeam.svelte +31 -0
- package/dist/ui/NewTeam.svelte.d.ts +15 -0
- package/dist/ui/PricingTable.svelte +217 -0
- package/dist/ui/PricingTable.svelte.d.ts +23 -0
- package/dist/ui/TeamInvitations.svelte +97 -0
- package/dist/ui/TeamInvitations.svelte.d.ts +32 -0
- package/dist/ui/TeamMembers.svelte +100 -0
- package/dist/ui/TeamMembers.svelte.d.ts +33 -0
- package/dist/ui/TeamSettings.svelte +88 -0
- package/dist/ui/TeamSettings.svelte.d.ts +22 -0
- package/dist/ui/TeamSwitcher.svelte +58 -0
- package/dist/ui/TeamSwitcher.svelte.d.ts +23 -0
- package/dist/ui/billing.d.ts +31 -0
- package/dist/ui/billing.js +33 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/teams.d.ts +20 -0
- package/dist/ui/teams.js +40 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Membership = {
|
|
2
|
+
team: {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
role: string;
|
|
7
|
+
};
|
|
8
|
+
type Props = {
|
|
9
|
+
/** From acc.Teams. */
|
|
10
|
+
teams: Membership[];
|
|
11
|
+
/** The current team's ID, from accounts.CurrentTeam. */
|
|
12
|
+
current: number;
|
|
13
|
+
/** The action that calls acc.SwitchTeam with the posted id. */
|
|
14
|
+
action: string;
|
|
15
|
+
/** A link to make a new team, such as "/teams/new". */
|
|
16
|
+
newHref?: string;
|
|
17
|
+
/** Opens to the start or end edge of the button. */
|
|
18
|
+
align?: 'start' | 'end';
|
|
19
|
+
class?: string;
|
|
20
|
+
};
|
|
21
|
+
declare const TeamSwitcher: import("svelte").Component<Props, {}, "">;
|
|
22
|
+
type TeamSwitcher = ReturnType<typeof TeamSwitcher>;
|
|
23
|
+
export default TeamSwitcher;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type Interval = 'month' | 'year';
|
|
2
|
+
/** A plan, as billing.Plan marshals it. */
|
|
3
|
+
export type BillingPlan = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
paid: boolean;
|
|
8
|
+
intervals: string[];
|
|
9
|
+
amounts?: Record<string, number> | null;
|
|
10
|
+
currency?: string;
|
|
11
|
+
limits?: Record<string, number> | null;
|
|
12
|
+
features?: string[] | null;
|
|
13
|
+
trialDays?: number;
|
|
14
|
+
perSeat?: boolean;
|
|
15
|
+
highlight?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** A subscription, as billing.Subscription marshals it. */
|
|
18
|
+
export type BillingSubscription = {
|
|
19
|
+
plan: string;
|
|
20
|
+
status: string;
|
|
21
|
+
interval: string;
|
|
22
|
+
seats: number;
|
|
23
|
+
currentPeriodEnd: string;
|
|
24
|
+
cancelAtPeriodEnd: boolean;
|
|
25
|
+
trialEnd: string | null;
|
|
26
|
+
};
|
|
27
|
+
/** An amount in the currency's smallest unit, as the user's locale writes it. */
|
|
28
|
+
export declare function money(amount: number, currency?: string): string;
|
|
29
|
+
/** A date, as the user's locale writes it. */
|
|
30
|
+
export declare function day(iso: string | null | undefined): string;
|
|
31
|
+
export declare function per(interval: string): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Shared by the billing screens. Internal: not exported.
|
|
2
|
+
import { i18n, tb } from '../runtime/i18n.svelte.js';
|
|
3
|
+
/** An amount in the currency's smallest unit, as the user's locale writes it. */
|
|
4
|
+
export function money(amount, currency = 'usd') {
|
|
5
|
+
const code = currency.toUpperCase();
|
|
6
|
+
try {
|
|
7
|
+
const f = new Intl.NumberFormat(i18n.locale || undefined, { style: 'currency', currency: code });
|
|
8
|
+
const digits = f.resolvedOptions().maximumFractionDigits ?? 2;
|
|
9
|
+
const value = amount / 10 ** digits;
|
|
10
|
+
// Whole amounts without the cents: $19, not $19.00.
|
|
11
|
+
return new Intl.NumberFormat(i18n.locale || undefined, { style: 'currency', currency: code, maximumFractionDigits: Number.isInteger(value) ? 0 : digits }).format(value);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return `${(amount / 100).toFixed(2)} ${code}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** A date, as the user's locale writes it. */
|
|
18
|
+
export function day(iso) {
|
|
19
|
+
if (!iso)
|
|
20
|
+
return '';
|
|
21
|
+
const d = new Date(iso);
|
|
22
|
+
if (Number.isNaN(d.getTime()))
|
|
23
|
+
return '';
|
|
24
|
+
try {
|
|
25
|
+
return new Intl.DateTimeFormat(i18n.locale || undefined, { dateStyle: 'medium' }).format(d);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return d.toISOString().slice(0, 10);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function per(interval) {
|
|
32
|
+
return tb(interval === 'year' ? 'tern.ui.billing.perYear' : 'tern.ui.billing.perMonth');
|
|
33
|
+
}
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -58,6 +58,15 @@ export { default as Passkeys } from './Passkeys.svelte';
|
|
|
58
58
|
export { default as LinkedAccounts } from './LinkedAccounts.svelte';
|
|
59
59
|
export { default as TwoStep } from './TwoStep.svelte';
|
|
60
60
|
export { default as TwoStepCode } from './TwoStepCode.svelte';
|
|
61
|
+
export { default as TeamMembers } from './TeamMembers.svelte';
|
|
62
|
+
export { default as TeamInvitations } from './TeamInvitations.svelte';
|
|
63
|
+
export { default as TeamSettings } from './TeamSettings.svelte';
|
|
64
|
+
export { default as TeamSwitcher } from './TeamSwitcher.svelte';
|
|
65
|
+
export { default as NewTeam } from './NewTeam.svelte';
|
|
66
|
+
export { default as AcceptInvitation } from './AcceptInvitation.svelte';
|
|
67
|
+
export { default as ActivityLog } from './ActivityLog.svelte';
|
|
68
|
+
export { default as PricingTable } from './PricingTable.svelte';
|
|
69
|
+
export { default as BillingSettings } from './BillingSettings.svelte';
|
|
61
70
|
export { default as Skeleton } from './Skeleton.svelte';
|
|
62
71
|
export { default as Slider } from './Slider.svelte';
|
|
63
72
|
export { default as Sparkline } from './Sparkline.svelte';
|
package/dist/ui/index.js
CHANGED
|
@@ -61,6 +61,15 @@ export { default as Passkeys } from './Passkeys.svelte';
|
|
|
61
61
|
export { default as LinkedAccounts } from './LinkedAccounts.svelte';
|
|
62
62
|
export { default as TwoStep } from './TwoStep.svelte';
|
|
63
63
|
export { default as TwoStepCode } from './TwoStepCode.svelte';
|
|
64
|
+
export { default as TeamMembers } from './TeamMembers.svelte';
|
|
65
|
+
export { default as TeamInvitations } from './TeamInvitations.svelte';
|
|
66
|
+
export { default as TeamSettings } from './TeamSettings.svelte';
|
|
67
|
+
export { default as TeamSwitcher } from './TeamSwitcher.svelte';
|
|
68
|
+
export { default as NewTeam } from './NewTeam.svelte';
|
|
69
|
+
export { default as AcceptInvitation } from './AcceptInvitation.svelte';
|
|
70
|
+
export { default as ActivityLog } from './ActivityLog.svelte';
|
|
71
|
+
export { default as PricingTable } from './PricingTable.svelte';
|
|
72
|
+
export { default as BillingSettings } from './BillingSettings.svelte';
|
|
64
73
|
export { default as Skeleton } from './Skeleton.svelte';
|
|
65
74
|
export { default as Slider } from './Slider.svelte';
|
|
66
75
|
export { default as Sparkline } from './Sparkline.svelte';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type RoleOption = {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
};
|
|
5
|
+
/** The built-in roles, labelled in the user's language. */
|
|
6
|
+
export declare function builtinRoles(): RoleOption[];
|
|
7
|
+
/** The label of a role, or the role itself for one of the app's own without a label. */
|
|
8
|
+
export declare function roleLabel(roles: RoleOption[], role: string): string;
|
|
9
|
+
/** Whether a role manages members, as accounts decides it. */
|
|
10
|
+
export declare function manages(role: string | undefined): boolean;
|
|
11
|
+
/** The roles someone with role may give: owners any, admins all but owner. */
|
|
12
|
+
export declare function grantable(roles: RoleOption[], role: string | undefined): RoleOption[];
|
|
13
|
+
/**
|
|
14
|
+
* The form-wide error of a failed post from one of a block's forms, which
|
|
15
|
+
* post a hidden tern_form field naming the block: several blocks share the
|
|
16
|
+
* page's form prop, and each shows only its own.
|
|
17
|
+
*/
|
|
18
|
+
export declare function messageFor(form: unknown, block: string): string | undefined;
|
|
19
|
+
/** The page's form prop for a block's own Form, or null if another block posted. */
|
|
20
|
+
export declare function formFor(form: unknown, block: string): unknown;
|
package/dist/ui/teams.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Shared by the team screens. Internal: not exported.
|
|
2
|
+
import { tb } from '../runtime/i18n.svelte.js';
|
|
3
|
+
/** The built-in roles, labelled in the user's language. */
|
|
4
|
+
export function builtinRoles() {
|
|
5
|
+
return [
|
|
6
|
+
{ value: 'owner', label: tb('tern.ui.team.role.owner') },
|
|
7
|
+
{ value: 'admin', label: tb('tern.ui.team.role.admin') },
|
|
8
|
+
{ value: 'member', label: tb('tern.ui.team.role.member') }
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
/** The label of a role, or the role itself for one of the app's own without a label. */
|
|
12
|
+
export function roleLabel(roles, role) {
|
|
13
|
+
return roles.find((r) => r.value === role)?.label ?? role;
|
|
14
|
+
}
|
|
15
|
+
/** Whether a role manages members, as accounts decides it. */
|
|
16
|
+
export function manages(role) {
|
|
17
|
+
return role === 'owner' || role === 'admin';
|
|
18
|
+
}
|
|
19
|
+
/** The roles someone with role may give: owners any, admins all but owner. */
|
|
20
|
+
export function grantable(roles, role) {
|
|
21
|
+
if (role === 'owner')
|
|
22
|
+
return roles;
|
|
23
|
+
if (role === 'admin')
|
|
24
|
+
return roles.filter((r) => r.value !== 'owner');
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The form-wide error of a failed post from one of a block's forms, which
|
|
29
|
+
* post a hidden tern_form field naming the block: several blocks share the
|
|
30
|
+
* page's form prop, and each shows only its own.
|
|
31
|
+
*/
|
|
32
|
+
export function messageFor(form, block) {
|
|
33
|
+
const f = form;
|
|
34
|
+
return f?.values?.tern_form === block ? f.message : undefined;
|
|
35
|
+
}
|
|
36
|
+
/** The page's form prop for a block's own Form, or null if another block posted. */
|
|
37
|
+
export function formFor(form, block) {
|
|
38
|
+
const f = form;
|
|
39
|
+
return f?.values?.tern_form === block ? form : null;
|
|
40
|
+
}
|