@pontive/pontkit-core 1.26.0 → 1.28.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/catalog.json +1 -1
- package/custom-elements.json +1 -1
- package/dist/pont2/core/attrs.d.ts +22 -0
- package/dist/pont2/core/controllers/action.d.ts +79 -0
- package/dist/pont2/core/controllers/copy.d.ts +34 -0
- package/dist/pont2/core/controllers/roving-focus.d.ts +38 -0
- package/dist/pont2/core/events.d.ts +28 -0
- package/dist/pont2/core/form-control.d.ts +70 -0
- package/dist/pont2/core/host-element.d.ts +129 -0
- package/dist/pont2/core/icons.d.ts +28 -0
- package/dist/pont2/core/ids.d.ts +6 -0
- package/dist/pont2/core/index.d.ts +10 -0
- package/dist/pont2/core/names.d.ts +78 -0
- package/dist/pont2/core/popup/anchored.d.ts +48 -0
- package/dist/pont2/core/popup/index.d.ts +5 -0
- package/dist/pont2/core/popup/list.d.ts +38 -0
- package/dist/pont2/core/popup/popup-content.d.ts +68 -0
- package/dist/pont2/core/popup/popup-root.d.ts +94 -0
- package/dist/pont2/core/popup/position.d.ts +73 -0
- package/dist/pont2/globals.css +109 -0
- package/dist/pont2/index.d.ts +44 -0
- package/dist/pont2/index.mjs +5660 -0
- package/dist/pont2/index.mjs.map +1 -0
- package/dist/pont2/kit/alert/alert.d.ts +62 -0
- package/dist/pont2/kit/aliases.d.ts +33 -0
- package/dist/pont2/kit/auth-button/auth-button.d.ts +185 -0
- package/dist/pont2/kit/auth-button/providers.d.ts +15 -0
- package/dist/pont2/kit/auth-field/auth-field.d.ts +267 -0
- package/dist/pont2/kit/auth-field/password-field.d.ts +124 -0
- package/dist/pont2/kit/avatar/avatar.d.ts +52 -0
- package/dist/pont2/kit/block/block.d.ts +64 -0
- package/dist/pont2/kit/block/branding.d.ts +36 -0
- package/dist/pont2/kit/container/container.d.ts +40 -0
- package/dist/pont2/kit/countdown/countdown.d.ts +64 -0
- package/dist/pont2/kit/divider/divider.d.ts +30 -0
- package/dist/pont2/kit/edit-identifier/edit-identifier.d.ts +47 -0
- package/dist/pont2/kit/flow-widget/flow-widget.d.ts +151 -0
- package/dist/pont2/kit/gap/gap.d.ts +36 -0
- package/dist/pont2/kit/header/header.d.ts +37 -0
- package/dist/pont2/kit/index.d.ts +26 -0
- package/dist/pont2/kit/input-otp/input-otp.d.ts +59 -0
- package/dist/pont2/kit/layout/flow-error.d.ts +21 -0
- package/dist/pont2/kit/layout/layout.d.ts +120 -0
- package/dist/pont2/kit/link/link.d.ts +62 -0
- package/dist/pont2/kit/logo/logo.d.ts +57 -0
- package/dist/pont2/kit/otp-field/otp-field.d.ts +93 -0
- package/dist/pont2/kit/otp-field/otp-resend.d.ts +61 -0
- package/dist/pont2/kit/provider-field/provider-field.d.ts +87 -0
- package/dist/pont2/kit/qr-code/qr-code.d.ts +86 -0
- package/dist/pont2/kit/recovery-codes/recovery-codes.d.ts +64 -0
- package/dist/pont2/kit/scope-list/scope-list.d.ts +69 -0
- package/dist/pont2/kit/scope-list/scope-value.d.ts +16 -0
- package/dist/pont2/kit/secret/secret.d.ts +67 -0
- package/dist/pont2/kit/story-helpers.d.ts +9 -0
- package/dist/pont2/kit/typography/typography.d.ts +70 -0
- package/dist/pont2/kit/watermark/pontive-logo.d.ts +8 -0
- package/dist/pont2/kit/watermark/watermark.d.ts +42 -0
- package/dist/pont2/primitives/alert/alert.d.ts +49 -0
- package/dist/pont2/primitives/avatar/avatar.d.ts +89 -0
- package/dist/pont2/primitives/badge/badge.d.ts +30 -0
- package/dist/pont2/primitives/button/button.d.ts +113 -0
- package/dist/pont2/primitives/button-group/button-group.d.ts +55 -0
- package/dist/pont2/primitives/card/card.d.ts +63 -0
- package/dist/pont2/primitives/checkbox/checkbox.d.ts +54 -0
- package/dist/pont2/primitives/combobox/combobox.d.ts +213 -0
- package/dist/pont2/primitives/dropdown-menu/dropdown-menu.d.ts +267 -0
- package/dist/pont2/primitives/empty/empty.d.ts +60 -0
- package/dist/pont2/primitives/field/field.d.ts +146 -0
- package/dist/pont2/primitives/input/input.d.ts +47 -0
- package/dist/pont2/primitives/input-group/input-group.d.ts +97 -0
- package/dist/pont2/primitives/input-otp/input-otp.d.ts +121 -0
- package/dist/pont2/primitives/input-otp/otp.d.ts +22 -0
- package/dist/pont2/primitives/item/item.d.ts +100 -0
- package/dist/pont2/primitives/kbd/kbd.d.ts +29 -0
- package/dist/pont2/primitives/label/label.d.ts +37 -0
- package/dist/pont2/primitives/native-select/native-select.d.ts +59 -0
- package/dist/pont2/primitives/popover/popover.d.ts +85 -0
- package/dist/pont2/primitives/progress/progress.d.ts +80 -0
- package/dist/pont2/primitives/radio-group/radio-group.d.ts +93 -0
- package/dist/pont2/primitives/select/select.d.ts +184 -0
- package/dist/pont2/primitives/separator/separator.d.ts +34 -0
- package/dist/pont2/primitives/skeleton/skeleton.d.ts +18 -0
- package/dist/pont2/primitives/slider/slider-math.d.ts +42 -0
- package/dist/pont2/primitives/slider/slider.d.ts +85 -0
- package/dist/pont2/primitives/spinner/spinner.d.ts +29 -0
- package/dist/pont2/primitives/switch/switch.d.ts +55 -0
- package/dist/pont2/primitives/table/table.d.ts +55 -0
- package/dist/pont2/primitives/tabs/tabs.d.ts +126 -0
- package/dist/pont2/primitives/textarea/textarea.d.ts +41 -0
- package/dist/pont2/primitives/tooltip/tooltip.d.ts +69 -0
- package/dist/pont2/styles.css +4839 -0
- package/dist/pont2/with-legacy.css +10 -0
- package/package.json +16 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PropertyDeclarations } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
export type HeaderAlign = "start" | "center" | "end";
|
|
4
|
+
/**
|
|
5
|
+
* # `<pont2-header>`: the screen's heading group (logo, title, subtitle)
|
|
6
|
+
*
|
|
7
|
+
* ```html
|
|
8
|
+
* <pont2-header>
|
|
9
|
+
* <pont2-logo image-url="/logo.svg"></pont2-logo>
|
|
10
|
+
* <pont2-title content="Welcome back"></pont2-title>
|
|
11
|
+
* <pont2-subtitle content="Login to your Acme Inc account"></pont2-subtitle>
|
|
12
|
+
* </pont2-header>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* shadcn's login blocks: `<div class="flex flex-col items-center gap-2
|
|
16
|
+
* text-center">`. Tier 1 host-as-root (the legacy element moved its children
|
|
17
|
+
* into an inner `div`); `align` sets both the boxes' and the text's alignment,
|
|
18
|
+
* as the legacy header does. Not a composite: it contains content.
|
|
19
|
+
*
|
|
20
|
+
* @tag pont2-header
|
|
21
|
+
* @attr align - start | center (default) | end
|
|
22
|
+
* @cssprop --pont2-header-gap - default 0.5rem
|
|
23
|
+
*/
|
|
24
|
+
export declare class Header extends HostElement {
|
|
25
|
+
static identity: string;
|
|
26
|
+
static slotName: string;
|
|
27
|
+
static composite: boolean;
|
|
28
|
+
static properties: PropertyDeclarations;
|
|
29
|
+
align: HeaderAlign;
|
|
30
|
+
constructor();
|
|
31
|
+
protected willUpdate(): void;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"pont2-header": Header;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './alert/alert';
|
|
2
|
+
export * from './avatar/avatar';
|
|
3
|
+
export * from './input-otp/input-otp';
|
|
4
|
+
export * from './auth-button/auth-button';
|
|
5
|
+
export * from './auth-field/auth-field';
|
|
6
|
+
export * from './auth-field/password-field';
|
|
7
|
+
export * from './otp-field/otp-field';
|
|
8
|
+
export * from './otp-field/otp-resend';
|
|
9
|
+
export * from './link/link';
|
|
10
|
+
export * from './divider/divider';
|
|
11
|
+
export * from './typography/typography';
|
|
12
|
+
export * from './provider-field/provider-field';
|
|
13
|
+
export * from './block/block';
|
|
14
|
+
export * from './watermark/watermark';
|
|
15
|
+
export * from './container/container';
|
|
16
|
+
export * from './header/header';
|
|
17
|
+
export * from './gap/gap';
|
|
18
|
+
export * from './logo/logo';
|
|
19
|
+
export * from './countdown/countdown';
|
|
20
|
+
export * from './edit-identifier/edit-identifier';
|
|
21
|
+
export * from './secret/secret';
|
|
22
|
+
export * from './qr-code/qr-code';
|
|
23
|
+
export * from './recovery-codes/recovery-codes';
|
|
24
|
+
export * from './scope-list/scope-list';
|
|
25
|
+
export * from './layout/layout';
|
|
26
|
+
export * from './flow-widget/flow-widget';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { PropertyDeclarations } from 'lit';
|
|
2
|
+
import { InputOTP } from '../../primitives/input-otp/input-otp';
|
|
3
|
+
/** `groupSizes(6, 3)` → `[3, 3]`; `groupSizes(7, 3)` → `[3, 3, 1]`; size ≤ 0 → one group. */
|
|
4
|
+
export declare function groupSizes(length: number, size: number): number[];
|
|
5
|
+
/**
|
|
6
|
+
* The slot structure for `length` characters: groups of `groupSize` (one group
|
|
7
|
+
* when 0), separators between groups when `separator`. Groups and separators
|
|
8
|
+
* are parts; slots are `pont2-prim-input-otp-slot` elements (they have
|
|
9
|
+
* behaviour). Shared with the OTP field (kit/otp-field).
|
|
10
|
+
*/
|
|
11
|
+
export declare function otpGroups(length: number, groupSize: number, separator: boolean): import('lit-html').TemplateResult<1>[];
|
|
12
|
+
/**
|
|
13
|
+
* # `<pont2-input-otp>`: kit composite over `<pont2-prim-input-otp>`
|
|
14
|
+
*
|
|
15
|
+
* ```html
|
|
16
|
+
* <pont2-input-otp name="code" maxlength="6" group-size="3" separator aria-label="Verification code"></pont2-input-otp>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* renders the primitive's DOM, which is shadcn's:
|
|
20
|
+
*
|
|
21
|
+
* ```html
|
|
22
|
+
* <pont2-input-otp data-pont2-input-otp …>
|
|
23
|
+
* <div data-pont2-input-otp-group data-slot="input-otp-group">
|
|
24
|
+
* <pont2-prim-input-otp-slot index="0"></pont2-prim-input-otp-slot> ×3
|
|
25
|
+
* </div>
|
|
26
|
+
* <div data-pont2-input-otp-separator data-slot="input-otp-separator" role="separator"><svg/></div>
|
|
27
|
+
* <div data-pont2-input-otp-group …> …×3 </div>
|
|
28
|
+
* <div data-pont2-input-otp-input-wrapper><input data-slot="input-otp" autocomplete="one-time-code" …></div>
|
|
29
|
+
* </pont2-input-otp>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* - **It is a primitive InputOTP** (`extends InputOTP`): the one native input,
|
|
33
|
+
* form participation, paste cleaning, `pont2-complete` and every primitive
|
|
34
|
+
* attribute (`maxlength`, `pattern`, `value`, `name`, `required`,
|
|
35
|
+
* `disabled`, `aria-*`) work unchanged.
|
|
36
|
+
* - **What it adds:** the slots are generated from `maxlength`, split into
|
|
37
|
+
* groups of `group-size` (one group when absent), with a separator between
|
|
38
|
+
* groups when `separator` is set.
|
|
39
|
+
* - Groups and separators are **parts** (plain divs). Slots are rendered as
|
|
40
|
+
* `pont2-prim-input-otp-slot` **elements**, because each slot has behaviour
|
|
41
|
+
* (it draws its character and the fake caret from state the root pushes in).
|
|
42
|
+
*
|
|
43
|
+
* @tag pont2-input-otp
|
|
44
|
+
* @attr group-size - characters per group (default: all in one group)
|
|
45
|
+
* @attr separator - draw a separator between groups
|
|
46
|
+
*/
|
|
47
|
+
export declare class KitInputOTP extends InputOTP {
|
|
48
|
+
static composite: boolean;
|
|
49
|
+
static properties: PropertyDeclarations;
|
|
50
|
+
groupSize: number;
|
|
51
|
+
separator: boolean;
|
|
52
|
+
constructor();
|
|
53
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
54
|
+
}
|
|
55
|
+
declare global {
|
|
56
|
+
interface HTMLElementTagNameMap {
|
|
57
|
+
"pont2-input-otp": KitInputOTP;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a failed flow request into words for the user: the legacy
|
|
3
|
+
* `describeFlowError` (src/utils/flow-error.ts), ported (pont2 imports nothing
|
|
4
|
+
* from the legacy kit), with the same English and the same message codes, so
|
|
5
|
+
* a flow's localised `messages` (keyed by code) apply unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export type FlowMessageCode = "connection_failed" | "too_many_attempts" | "server_error" | "generic_error" | "flow_ended" | "passkey_cancelled" | "start_again" | "continued_elsewhere_title" | "continued_elsewhere_subtitle" | "continue_here";
|
|
8
|
+
export declare const FLOW_MESSAGES_EN: Record<FlowMessageCode, string>;
|
|
9
|
+
export interface FlowErrorDescription {
|
|
10
|
+
message: string;
|
|
11
|
+
/** The flow is over (409): offer "Start again". */
|
|
12
|
+
restartable: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* - a cancelled or timed-out WebAuthn prompt (`NotAllowedError` / `AbortError`) → passkey_cancelled
|
|
16
|
+
* - 409 → the server's sentence, else flow_ended; restartable
|
|
17
|
+
* - no response at all (NETWORK_ERROR / TIMEOUT) → connection_failed
|
|
18
|
+
* - 429 → too_many_attempts; ≥ 500 → server_error
|
|
19
|
+
* - anything else → the server's sentence, else generic_error
|
|
20
|
+
*/
|
|
21
|
+
export declare function describeFlowError(error: unknown, messages?: Partial<Record<string, string>>): FlowErrorDescription;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
import { BrandingEntitlements } from '../block/branding';
|
|
4
|
+
export { describeFlowError, FLOW_MESSAGES_EN, type FlowErrorDescription, type FlowMessageCode } from './flow-error';
|
|
5
|
+
/**
|
|
6
|
+
* What the layout needs from an auth client: one method. `Auth` from
|
|
7
|
+
* `@pontive/oidc-client` satisfies it structurally, so pont2 never imports an
|
|
8
|
+
* auth client (option (b), docs/kit/layout.md).
|
|
9
|
+
*/
|
|
10
|
+
export interface FlowClient {
|
|
11
|
+
processLoginflowEvent(request: FlowEventRequest): Promise<FlowEventResponse>;
|
|
12
|
+
}
|
|
13
|
+
export interface FlowEventRequest {
|
|
14
|
+
event: string;
|
|
15
|
+
data?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/** The parts of the SDK's `ProcessEventResponse` the layout reads. */
|
|
18
|
+
export interface FlowEventResponse {
|
|
19
|
+
state?: string;
|
|
20
|
+
render_spec?: unknown;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface UnregisteredElementDetail {
|
|
24
|
+
tag: string;
|
|
25
|
+
}
|
|
26
|
+
/** FormData → the plain object the flow API takes (last value wins, files dropped). */
|
|
27
|
+
export declare function formDataToObject(fd: FormData | undefined | null): Record<string, unknown> | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* # `<pont2-layout>`: renders a flow screen and runs its requests
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { Auth } from "@pontive/oidc-client";
|
|
33
|
+
* const layout = document.createElement("pont2-layout");
|
|
34
|
+
* layout.client = Auth; // anything with processLoginflowEvent()
|
|
35
|
+
* layout.branding = response.branding; // the account's entitlements (fail closed)
|
|
36
|
+
* layout.renderSpec = response.render_spec; // the server's HTML for the screen
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* ```html
|
|
40
|
+
* <pont2-layout data-pont2-layout data-slot="layout">
|
|
41
|
+
* <form data-slot="layout-form" aria-busy="false">
|
|
42
|
+
* …the render spec (e.g. <pont2-block>…</pont2-block>)…
|
|
43
|
+
* </form>
|
|
44
|
+
* </pont2-layout>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* The **flow host** for one screen. It:
|
|
48
|
+
*
|
|
49
|
+
* 1. **renders the spec** (server HTML) inside one native `<form>`, upgrading
|
|
50
|
+
* pont2 elements and reporting tags this bundle does not define
|
|
51
|
+
* (`pont2-unregistered-element` on `document`, once per tag);
|
|
52
|
+
* 2. **answers every `pont2-action`** from inside the screen (submit, provider,
|
|
53
|
+
* passkey, link, OTP, resend, forgot, edit-identifier) with
|
|
54
|
+
* `client.processLoginflowEvent({ event, data })`, where `data` is the
|
|
55
|
+
* form's normalised FormData when the request carries one (submit, OTP
|
|
56
|
+
* auto-submit); while a request is pending, another one joins it (no double
|
|
57
|
+
* submit) and the form is `aria-busy`;
|
|
58
|
+
* 3. **renders the next screen** when a response carries `render_spec`;
|
|
59
|
+
* 4. **shows flow errors** (every `pont2-action-error` from inside) as an
|
|
60
|
+
* error `pont2-alert` banner at the top of the screen, with "Start again"
|
|
61
|
+
* (`pont2-layout-restart`) when the flow is over (409);
|
|
62
|
+
* 5. **provides the branding entitlements** (`pont2:branding` context) to the
|
|
63
|
+
* screen's block. Fails closed: without `branding`, the watermark shows.
|
|
64
|
+
*
|
|
65
|
+
* Trust boundary: the render spec is **server HTML** and is inserted as such
|
|
66
|
+
* (as in the legacy `pont-layout`); everything a user types goes through
|
|
67
|
+
* native inputs, never into markup. The spec must not contain its own
|
|
68
|
+
* `<form>` (the layout's form is the one form).
|
|
69
|
+
*
|
|
70
|
+
* @tag pont2-layout
|
|
71
|
+
* @prop client - `FlowClient` (e.g. the SDK's `Auth`). Without one, actions are not answered.
|
|
72
|
+
* @prop renderSpec - the screen's HTML
|
|
73
|
+
* @prop branding - `BrandingEntitlements` (attribute-less on purpose)
|
|
74
|
+
* @prop messages - localised flow messages by code (the flow's `messages`)
|
|
75
|
+
* @fires pont2-flow-response - `{ action, result }` after every successful request
|
|
76
|
+
* @fires pont2-layout-restart - "Start again" pressed (the widget restarts the flow)
|
|
77
|
+
* @fires pont2-unregistered-element - on `document`, `{ tag }`
|
|
78
|
+
*/
|
|
79
|
+
export declare class Layout extends HostElement {
|
|
80
|
+
static identity: string;
|
|
81
|
+
static slotName: string;
|
|
82
|
+
static composite: boolean;
|
|
83
|
+
static properties: PropertyDeclarations;
|
|
84
|
+
client: FlowClient | undefined;
|
|
85
|
+
renderSpec: string;
|
|
86
|
+
branding: BrandingEntitlements;
|
|
87
|
+
messages: Partial<Record<string, string>>;
|
|
88
|
+
protected busy: boolean;
|
|
89
|
+
private provider;
|
|
90
|
+
private pending;
|
|
91
|
+
constructor();
|
|
92
|
+
/** The layout's form (holds the screen). */
|
|
93
|
+
get form(): HTMLFormElement | null;
|
|
94
|
+
/** Runs one flow request (what a `pont2-action` from inside triggers). */
|
|
95
|
+
run(event: string, data?: Record<string, unknown>): Promise<FlowEventResponse>;
|
|
96
|
+
private onAction;
|
|
97
|
+
private onError;
|
|
98
|
+
/** Shows a flow error at the top of the screen (after its logo/header). */
|
|
99
|
+
showError(message: string, restartable?: boolean): void;
|
|
100
|
+
private clearBanner;
|
|
101
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
102
|
+
protected updated(changed: PropertyValues): void;
|
|
103
|
+
private renderScreen;
|
|
104
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
105
|
+
}
|
|
106
|
+
declare global {
|
|
107
|
+
interface HTMLElementTagNameMap {
|
|
108
|
+
"pont2-layout": Layout;
|
|
109
|
+
}
|
|
110
|
+
interface HTMLElementEventMap {
|
|
111
|
+
"pont2-flow-response": CustomEvent<{
|
|
112
|
+
action: string;
|
|
113
|
+
result: FlowEventResponse;
|
|
114
|
+
}>;
|
|
115
|
+
"pont2-layout-restart": CustomEvent<Record<string, never>>;
|
|
116
|
+
}
|
|
117
|
+
interface DocumentEventMap {
|
|
118
|
+
"pont2-unregistered-element": CustomEvent<UnregisteredElementDetail>;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { ActionController } from '../../core/controllers/action';
|
|
3
|
+
import { HostElement } from '../../core/host-element';
|
|
4
|
+
export type LinkAlign = "start" | "center" | "end";
|
|
5
|
+
/**
|
|
6
|
+
* # `<pont2-link>`: "Don't have an account? Sign up"
|
|
7
|
+
*
|
|
8
|
+
* ```html
|
|
9
|
+
* <pont2-link prompt="Don't have an account?" label="Sign up" event="goto_signup"></pont2-link>
|
|
10
|
+
* <pont2-link label="Privacy policy" href="/privacy" target="_blank"></pont2-link>
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* shadcn's login blocks write this as `<div class="text-center text-sm">
|
|
14
|
+
* Don't have an account? <a class="underline underline-offset-4">Sign
|
|
15
|
+
* up</a></div>`. pont2's host is that row; the link is the button
|
|
16
|
+
* primitive's part:
|
|
17
|
+
*
|
|
18
|
+
* - **with `href`**: a real `<a href>` (navigation, middle-click, "open in
|
|
19
|
+
* new tab" work), styled as a link;
|
|
20
|
+
* - **otherwise**: a `<button type="button">` that requests `event` through
|
|
21
|
+
* the action protocol (`data: { service }`), busy until it settles, like
|
|
22
|
+
* the auth buttons. The legacy `service="other"` (no auth call) maps to:
|
|
23
|
+
* don't set `event`, or don't respond.
|
|
24
|
+
*
|
|
25
|
+
* @tag pont2-link
|
|
26
|
+
* @attr label - link text (default "Link")
|
|
27
|
+
* @attr prompt - text before the link
|
|
28
|
+
* @attr event - the action requested on press (button form)
|
|
29
|
+
* @attr service - auth (default) | other: passed in the request's data
|
|
30
|
+
* @attr href, target, rel - render a real link instead
|
|
31
|
+
* @attr align - start | center (default) | end
|
|
32
|
+
* @attr disabled, loading
|
|
33
|
+
* @fires pont2-action, pont2-action-success, pont2-action-error
|
|
34
|
+
*/
|
|
35
|
+
export declare class Link extends HostElement {
|
|
36
|
+
static identity: string;
|
|
37
|
+
static slotName: string;
|
|
38
|
+
static composite: boolean;
|
|
39
|
+
static properties: PropertyDeclarations;
|
|
40
|
+
label: string;
|
|
41
|
+
prompt: string;
|
|
42
|
+
event: string | undefined;
|
|
43
|
+
service: "auth" | "other";
|
|
44
|
+
href: string | undefined;
|
|
45
|
+
target: string | undefined;
|
|
46
|
+
rel: string | undefined;
|
|
47
|
+
align: LinkAlign;
|
|
48
|
+
disabled: boolean;
|
|
49
|
+
loading: boolean;
|
|
50
|
+
protected readonly action: ActionController;
|
|
51
|
+
constructor();
|
|
52
|
+
get busy(): boolean;
|
|
53
|
+
/** The native `<a>` or `<button>`. */
|
|
54
|
+
get control(): HTMLAnchorElement | HTMLButtonElement | null;
|
|
55
|
+
protected willUpdate(_changed: PropertyValues): void;
|
|
56
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
57
|
+
}
|
|
58
|
+
declare global {
|
|
59
|
+
interface HTMLElementTagNameMap {
|
|
60
|
+
"pont2-link": Link;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { nothing, PropertyDeclarations } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
export type LogoAlign = "start" | "center" | "end";
|
|
4
|
+
/**
|
|
5
|
+
* A logo source as an `<img src>`: URLs and `data:` URIs pass through; a bare
|
|
6
|
+
* base64 string is treated as an SVG (the legacy `resolveIconSource` rule).
|
|
7
|
+
* `{{theme}}` in a URL is replaced with `light` or `dark`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function logoSource(raw: string | undefined, theme: "light" | "dark"): string;
|
|
10
|
+
/**
|
|
11
|
+
* # `<pont2-logo>`: the application's logo
|
|
12
|
+
*
|
|
13
|
+
* ```html
|
|
14
|
+
* <pont2-logo image-url="https://cdn.example.com/logo-{{theme}}.svg" alt="Acme"></pont2-logo>
|
|
15
|
+
* → <pont2-logo data-pont2-logo data-slot="logo" data-align="center">
|
|
16
|
+
* <img data-logo-theme="light" src="…logo-light.svg" alt="Acme">
|
|
17
|
+
* <img data-logo-theme="dark" src="…logo-dark.svg" alt="Acme"> (only when it differs)
|
|
18
|
+
* </pont2-logo>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* **Always an `<img>`.** The legacy element decoded base64 SVG and injected
|
|
22
|
+
* it as markup (`unsafeSVG`), which runs whatever the SVG contains in the
|
|
23
|
+
* page. An `<img>` renders the same SVG sandboxed (no script, no external
|
|
24
|
+
* fetches), and needs no decoding.
|
|
25
|
+
*
|
|
26
|
+
* **Dark mode by CSS**, not by watching `<html data-theme>`: when the dark
|
|
27
|
+
* source differs (`image-url-dark`, or `{{theme}}` in the URL), both images
|
|
28
|
+
* are rendered and the stylesheet shows the right one under `.dark` /
|
|
29
|
+
* `[data-theme="dark"]` (the pont2 dark-mode switches).
|
|
30
|
+
*
|
|
31
|
+
* @tag pont2-logo
|
|
32
|
+
* @attr image-url - URL, `data:` URI or bare base64 SVG; `{{theme}}` is replaced
|
|
33
|
+
* @attr image-url-dark - dark-mode source (default: `image-url` with `{{theme}}` = dark)
|
|
34
|
+
* @attr alt - default "Logo" (legacy); set the brand name
|
|
35
|
+
* @attr align - start | center (default) | end
|
|
36
|
+
* @attr width, height - CSS lengths for the image
|
|
37
|
+
*/
|
|
38
|
+
export declare class Logo extends HostElement {
|
|
39
|
+
static identity: string;
|
|
40
|
+
static slotName: string;
|
|
41
|
+
static composite: boolean;
|
|
42
|
+
static properties: PropertyDeclarations;
|
|
43
|
+
imageUrl: string;
|
|
44
|
+
imageUrlDark: string;
|
|
45
|
+
alt: string;
|
|
46
|
+
align: LogoAlign;
|
|
47
|
+
width: string;
|
|
48
|
+
height: string;
|
|
49
|
+
constructor();
|
|
50
|
+
protected willUpdate(): void;
|
|
51
|
+
render(): import('lit-html').TemplateResult<1> | typeof nothing;
|
|
52
|
+
}
|
|
53
|
+
declare global {
|
|
54
|
+
interface HTMLElementTagNameMap {
|
|
55
|
+
"pont2-logo": Logo;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { nothing, PropertyDeclarations, TemplateResult } from 'lit';
|
|
2
|
+
import { ActionController } from '../../core/controllers/action';
|
|
3
|
+
import { InputOTP } from '../../primitives/input-otp/input-otp';
|
|
4
|
+
import { InputOptions } from '../../primitives/input/input';
|
|
5
|
+
import { AuthField, FieldIssue } from '../auth-field/auth-field';
|
|
6
|
+
/** The legacy `pont-otp` layouts, kept for render-spec parity. */
|
|
7
|
+
export type OtpLayout = "digits_only" | "simple" | "with_separator" | "with_spacing";
|
|
8
|
+
/**
|
|
9
|
+
* # `<pont2-otp-field>`: a verification-code field
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* <form>
|
|
13
|
+
* <pont2-otp-field label="Verification code" length="6" layout="with_separator" required></pont2-otp-field>
|
|
14
|
+
* <pont2-submit-button event="verify_code" label="Verify"></pont2-submit-button>
|
|
15
|
+
* </form>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* **Is a Field** (`extends AuthField extends Field`) holding the Input OTP
|
|
19
|
+
* primitive, as shadcn composes it (`<Field><FieldLabel/><InputOTP/>
|
|
20
|
+
* <FieldDescription/></Field>`):
|
|
21
|
+
*
|
|
22
|
+
* ```html
|
|
23
|
+
* <pont2-otp-field data-pont2-field data-slot="field">
|
|
24
|
+
* <label data-pont2-field-label for="…-input">Verification code</label>
|
|
25
|
+
* <pont2-prim-input-otp maxlength="6" name="code" input-id="…-input" …>
|
|
26
|
+
* <div data-pont2-input-otp-group …> <pont2-prim-input-otp-slot index="0"> …×3 </div>
|
|
27
|
+
* <div data-pont2-input-otp-separator …><svg/></div>
|
|
28
|
+
* <div data-pont2-input-otp-group …> …×3 </div>
|
|
29
|
+
* <div data-pont2-input-otp-input-wrapper><input autocomplete="one-time-code" name="code" …></div>
|
|
30
|
+
* </pont2-prim-input-otp>
|
|
31
|
+
* <div data-pont2-field-error role="alert">Please enter the complete verification code.</div>
|
|
32
|
+
* </pont2-otp-field>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* The Input OTP is rendered as its **primitive element** (it has behaviour);
|
|
36
|
+
* its groups and separators are parts, and its slots are elements (kit/input-otp).
|
|
37
|
+
* Everything an auth field does applies: the one native
|
|
38
|
+
* `autocomplete="one-time-code"` input is the form control, validation is
|
|
39
|
+
* native (`required`, then *incomplete*), errors are inline.
|
|
40
|
+
*
|
|
41
|
+
* **Auto-submit** (`auto-submit`): when every slot is filled,
|
|
42
|
+
* - with `event`: requests it through the action protocol, with the same
|
|
43
|
+
* `data: { form, formData }` shape as the submit button (so one flow
|
|
44
|
+
* handler serves both);
|
|
45
|
+
* - without `event`: submits the enclosing form (`form.requestSubmit()`), so
|
|
46
|
+
* its submit button handles the request.
|
|
47
|
+
*
|
|
48
|
+
* @tag pont2-otp-field
|
|
49
|
+
* @attr length - number of characters (default 6)
|
|
50
|
+
* @attr layout - digits_only (one group, default) | simple (2 groups) | with_separator (3 groups) | with_spacing (one slot per group)
|
|
51
|
+
* @attr group-size, separator - explicit grouping (override `layout`)
|
|
52
|
+
* @attr pattern - per-character regex source (default digits; `pattern=""` accepts anything)
|
|
53
|
+
* @attr auto-submit - submit when complete
|
|
54
|
+
* @attr event - the action requested on auto-submit
|
|
55
|
+
* @attr incomplete-error - default "Please enter the complete verification code."
|
|
56
|
+
* @fires pont2-complete - from the Input OTP, `{ value }`
|
|
57
|
+
* @fires pont2-action, pont2-action-success, pont2-action-error - on auto-submit with `event`
|
|
58
|
+
*/
|
|
59
|
+
export declare class OtpField extends AuthField {
|
|
60
|
+
static properties: PropertyDeclarations;
|
|
61
|
+
length: number;
|
|
62
|
+
layout: OtpLayout;
|
|
63
|
+
groupSize: number | undefined;
|
|
64
|
+
separator: boolean | undefined;
|
|
65
|
+
autoSubmit: boolean;
|
|
66
|
+
event: string | undefined;
|
|
67
|
+
incompleteError: string;
|
|
68
|
+
protected readonly action: ActionController;
|
|
69
|
+
constructor();
|
|
70
|
+
protected defaultName(): string;
|
|
71
|
+
protected defaultLabel(): string;
|
|
72
|
+
/** The Input OTP primitive element. */
|
|
73
|
+
get otp(): InputOTP | null;
|
|
74
|
+
get control(): HTMLInputElement | null;
|
|
75
|
+
/** `true` while an auto-submit request is pending. */
|
|
76
|
+
get busy(): boolean;
|
|
77
|
+
protected computeIssues(): FieldIssue[];
|
|
78
|
+
protected valueIssues(value: string): FieldIssue[];
|
|
79
|
+
/** Group size and separators from `layout`, unless set explicitly. */
|
|
80
|
+
get grouping(): {
|
|
81
|
+
size: number;
|
|
82
|
+
separator: boolean;
|
|
83
|
+
};
|
|
84
|
+
private onComplete;
|
|
85
|
+
protected onReset: () => void;
|
|
86
|
+
protected renderLabel(): TemplateResult | typeof nothing;
|
|
87
|
+
protected renderControl(o: InputOptions): TemplateResult;
|
|
88
|
+
}
|
|
89
|
+
declare global {
|
|
90
|
+
interface HTMLElementTagNameMap {
|
|
91
|
+
"pont2-otp-field": OtpField;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { ActionController } from '../../core/controllers/action';
|
|
3
|
+
import { HostElement } from '../../core/host-element';
|
|
4
|
+
/**
|
|
5
|
+
* # `<pont2-otp-resend>`: "Resend code in 42s", then a resend link
|
|
6
|
+
*
|
|
7
|
+
* ```html
|
|
8
|
+
* <pont2-otp-resend event="resend_code" duration="60"></pont2-otp-resend>
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* <pont2-otp-resend data-pont2-otp-resend data-slot="otp-resend">
|
|
13
|
+
* <span data-slot="otp-resend-countdown" role="timer">Resend code in 42s</span>
|
|
14
|
+
* ⟶ when it reaches 0:
|
|
15
|
+
* <button data-pont2-button data-variant="link" data-slot="otp-resend-button" type="button">Resend code</button>
|
|
16
|
+
* </pont2-otp-resend>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* The root is a plain row, so this is a new-name composite on `HostElement`
|
|
20
|
+
* (06-higher-layers: layout renderers). The button is the button primitive's
|
|
21
|
+
* part and requests `event` through the action protocol (`data: { resend:
|
|
22
|
+
* true }`); the countdown restarts when it is pressed, as in the legacy kit.
|
|
23
|
+
*
|
|
24
|
+
* The countdown is `role="timer"` (not announced every second). When it
|
|
25
|
+
* ends, the button appears; focus is not moved.
|
|
26
|
+
*
|
|
27
|
+
* @tag pont2-otp-resend
|
|
28
|
+
* @attr duration - seconds before the button appears (default 60; 0 shows it at once)
|
|
29
|
+
* @attr event - the action requested on press
|
|
30
|
+
* @attr label - button text (default "Resend code")
|
|
31
|
+
* @attr countdown-text - text before the seconds (default "Resend code in ")
|
|
32
|
+
* @fires pont2-action, pont2-action-success, pont2-action-error
|
|
33
|
+
*/
|
|
34
|
+
export declare class OtpResend extends HostElement {
|
|
35
|
+
static identity: string;
|
|
36
|
+
static slotName: string;
|
|
37
|
+
static composite: boolean;
|
|
38
|
+
static properties: PropertyDeclarations;
|
|
39
|
+
duration: number;
|
|
40
|
+
event: string | undefined;
|
|
41
|
+
label: string;
|
|
42
|
+
countdownText: string;
|
|
43
|
+
/** Seconds left. */
|
|
44
|
+
remaining: number;
|
|
45
|
+
protected readonly action: ActionController;
|
|
46
|
+
private timer;
|
|
47
|
+
constructor();
|
|
48
|
+
/** Starts (or restarts) the countdown from `duration`. */
|
|
49
|
+
restart(): void;
|
|
50
|
+
private stop;
|
|
51
|
+
connectedCallback(): void;
|
|
52
|
+
disconnectedCallback(): void;
|
|
53
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
54
|
+
private press;
|
|
55
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
56
|
+
}
|
|
57
|
+
declare global {
|
|
58
|
+
interface HTMLElementTagNameMap {
|
|
59
|
+
"pont2-otp-resend": OtpResend;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { ButtonSize, ButtonVariant } from '../../primitives/button/button';
|
|
3
|
+
import { Field } from '../../primitives/field/field';
|
|
4
|
+
import { AuthButtonContent, AuthButtonIconAlign } from '../auth-button/auth-button';
|
|
5
|
+
import { AuthProvider } from '../auth-button/providers';
|
|
6
|
+
/** Per-provider settings that override the field-wide ones (the legacy `overrides`). */
|
|
7
|
+
export interface ProviderOverride {
|
|
8
|
+
provider: AuthProvider;
|
|
9
|
+
label?: string;
|
|
10
|
+
prompt?: string;
|
|
11
|
+
event?: string;
|
|
12
|
+
variant?: ButtonVariant;
|
|
13
|
+
size?: ButtonSize;
|
|
14
|
+
content?: AuthButtonContent;
|
|
15
|
+
iconAlign?: AuthButtonIconAlign;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** The legacy column layouts of a 12-column grid, by provider count. */
|
|
20
|
+
export type ProviderColumns = "one" | "three" | "four" | "two-three" | "three-four";
|
|
21
|
+
/** 1–2 → one per row; multiples of 3 → three; 5 → 2 + 3; 7 → 3 + 4; otherwise four (legacy rule). */
|
|
22
|
+
export declare function providerColumns(count: number): ProviderColumns;
|
|
23
|
+
/** The legacy default event per provider: the platform's OAuth sign-in action. */
|
|
24
|
+
export declare const providerEvent: (p: AuthProvider) => string;
|
|
25
|
+
/**
|
|
26
|
+
* # `<pont2-provider-field>`: the "continue with…" button grid
|
|
27
|
+
*
|
|
28
|
+
* ```html
|
|
29
|
+
* <pont2-provider-field providers="apple google meta"></pont2-provider-field>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* **Is a Field** (`extends Field`), as in shadcn's login blocks (`<Field
|
|
33
|
+
* className="grid grid-cols-3 gap-4">` holding the buttons), laid out on the
|
|
34
|
+
* legacy kit's 12-column grid (`data-columns`, see `providerColumns`). It
|
|
35
|
+
* renders one **`<pont2-provider-button>` element** per provider:
|
|
36
|
+
*
|
|
37
|
+
* ```html
|
|
38
|
+
* <pont2-provider-field data-pont2-field data-slot="field" role="group" data-columns="three">
|
|
39
|
+
* <pont2-provider-button provider="apple" content="icon" event="signin_with_oauth(apple)" data-pont2-shell>
|
|
40
|
+
* <button data-pont2-button data-variant="outline" data-provider="apple" aria-label="Continue with Apple">…</button>
|
|
41
|
+
* </pont2-provider-button>
|
|
42
|
+
* …
|
|
43
|
+
* </pont2-provider-field>
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* Nesting kit elements is normally forbidden in kit templates. This is the
|
|
47
|
+
* documented exception (docs/10-primitives-and-kit.md §5): each button is an
|
|
48
|
+
* **independent, stateful** element (its own busy state and action request),
|
|
49
|
+
* repeated per item, and its host is `display: contents`, so the grid items
|
|
50
|
+
* are the native buttons and the DOM is shadcn's.
|
|
51
|
+
*
|
|
52
|
+
* Field-wide settings apply to every button; `overrides` (JSON attribute or
|
|
53
|
+
* array property) replaces them for one provider. With more than two
|
|
54
|
+
* providers the buttons default to icon-only (legacy).
|
|
55
|
+
*
|
|
56
|
+
* @tag pont2-provider-field
|
|
57
|
+
* @attr providers - e.g. "apple google github" (duplicates and unknown names are dropped)
|
|
58
|
+
* @attr event - one event for every button (default: `signin_with_oauth(<provider>)` each)
|
|
59
|
+
* @attr variant, size, content, icon-align, prompt, label, disabled, loading - passed to every button
|
|
60
|
+
* @attr overrides - JSON array of per-provider settings, e.g. `[{"provider":"google","label":"Google Workspace"}]`
|
|
61
|
+
*/
|
|
62
|
+
export declare class ProviderField extends Field {
|
|
63
|
+
static composite: boolean;
|
|
64
|
+
static properties: PropertyDeclarations;
|
|
65
|
+
providers: AuthProvider[];
|
|
66
|
+
overrides: ProviderOverride[];
|
|
67
|
+
event: string | undefined;
|
|
68
|
+
variant: ButtonVariant | undefined;
|
|
69
|
+
size: ButtonSize | undefined;
|
|
70
|
+
content: AuthButtonContent | undefined;
|
|
71
|
+
iconAlign: AuthButtonIconAlign | undefined;
|
|
72
|
+
prompt: string | undefined;
|
|
73
|
+
label: string | undefined;
|
|
74
|
+
loading: boolean;
|
|
75
|
+
constructor();
|
|
76
|
+
/** The providers actually rendered: known names, first occurrence only. */
|
|
77
|
+
get list(): AuthProvider[];
|
|
78
|
+
/** The rendered `<pont2-provider-button>` elements. */
|
|
79
|
+
get buttons(): HTMLElementTagNameMap["pont2-provider-button"][];
|
|
80
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
81
|
+
render(): unknown;
|
|
82
|
+
}
|
|
83
|
+
declare global {
|
|
84
|
+
interface HTMLElementTagNameMap {
|
|
85
|
+
"pont2-provider-field": ProviderField;
|
|
86
|
+
}
|
|
87
|
+
}
|