@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,62 @@
|
|
|
1
|
+
import { PropertyDeclarations, TemplateResult } from 'lit';
|
|
2
|
+
import { Alert } from '../../primitives/alert/alert';
|
|
3
|
+
export declare const ALERT_STATUSES: readonly ["default", "error", "warning", "success", "info"];
|
|
4
|
+
export type AlertStatus = (typeof ALERT_STATUSES)[number];
|
|
5
|
+
/**
|
|
6
|
+
* # `<pont2-alert>`: kit composite over `<pont2-prim-alert>`
|
|
7
|
+
*
|
|
8
|
+
* The props-driven form of shadcn's Alert, and pont2's version of the legacy
|
|
9
|
+
* `pont-alert` (which composed `pont-callout`, the legacy shadcn alert).
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* <pont2-alert status="error" icon heading="Payment failed"
|
|
13
|
+
* description="Check your card details and try again."></pont2-alert>
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* renders exactly the DOM the primitive form produces:
|
|
17
|
+
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <pont2-alert data-pont2-alert data-slot="alert" data-variant="destructive" data-status="error">
|
|
20
|
+
* <svg …/>
|
|
21
|
+
* <div data-pont2-alert-title data-slot="alert-title">Payment failed</div>
|
|
22
|
+
* <div data-pont2-alert-description data-slot="alert-description">Check your…</div>
|
|
23
|
+
* </pont2-alert>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* - **It is a primitive Alert** (`extends Alert`): same identity, slot, recipe
|
|
27
|
+
* and `variant`. Title and description are rendered as *parts* (plain divs
|
|
28
|
+
* with the primitive's attributes), not nested elements.
|
|
29
|
+
* - **What it adds** over shadcn: `status` (`error` maps to shadcn's
|
|
30
|
+
* `destructive` variant; `warning`/`success`/`info` are coloured in
|
|
31
|
+
* `@layer pont2.kit` with the `--pont2-success|warning|info` tokens), a
|
|
32
|
+
* status icon, and a status-appropriate role (`alert` for error/warning,
|
|
33
|
+
* `status` otherwise, as the legacy `pont-alert` did). An author `role`
|
|
34
|
+
* attribute still wins.
|
|
35
|
+
* - **What it leaves out:** rich content (links, an action button). Use the
|
|
36
|
+
* primitive form for those; a composite ignores author children.
|
|
37
|
+
*
|
|
38
|
+
* `heading` instead of `title`: `title` is a global HTML attribute that shows
|
|
39
|
+
* a native tooltip, so the attribute would leak onto the whole alert.
|
|
40
|
+
*
|
|
41
|
+
* @tag pont2-alert
|
|
42
|
+
* @attr status - default | error | warning | success | info
|
|
43
|
+
* @attr heading - the alert title text
|
|
44
|
+
* @attr description - the description text
|
|
45
|
+
* @attr icon - show the status icon
|
|
46
|
+
*/
|
|
47
|
+
export declare class KitAlert extends Alert {
|
|
48
|
+
static composite: boolean;
|
|
49
|
+
static properties: PropertyDeclarations;
|
|
50
|
+
status: AlertStatus;
|
|
51
|
+
heading: string;
|
|
52
|
+
description: string;
|
|
53
|
+
icon: boolean;
|
|
54
|
+
constructor();
|
|
55
|
+
protected willUpdate(): void;
|
|
56
|
+
protected render(): TemplateResult<1>;
|
|
57
|
+
}
|
|
58
|
+
declare global {
|
|
59
|
+
interface HTMLElementTagNameMap {
|
|
60
|
+
"pont2-alert": KitAlert;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Badge } from '../primitives/badge/badge';
|
|
2
|
+
import { Pont2Button } from '../primitives/button/button';
|
|
3
|
+
import { Checkbox } from '../primitives/checkbox/checkbox';
|
|
4
|
+
import { Pont2Input } from '../primitives/input/input';
|
|
5
|
+
import { Kbd, KbdGroup } from '../primitives/kbd/kbd';
|
|
6
|
+
import { Pont2Label } from '../primitives/label/label';
|
|
7
|
+
import { NativeSelect } from '../primitives/native-select/native-select';
|
|
8
|
+
import { Separator } from '../primitives/separator/separator';
|
|
9
|
+
import { Skeleton } from '../primitives/skeleton/skeleton';
|
|
10
|
+
import { Slider } from '../primitives/slider/slider';
|
|
11
|
+
import { Spinner } from '../primitives/spinner/spinner';
|
|
12
|
+
import { Switch } from '../primitives/switch/switch';
|
|
13
|
+
import { Table } from '../primitives/table/table';
|
|
14
|
+
import { Pont2Textarea } from '../primitives/textarea/textarea';
|
|
15
|
+
declare global {
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
"pont2-badge": Badge;
|
|
18
|
+
"pont2-button": Pont2Button;
|
|
19
|
+
"pont2-checkbox": Checkbox;
|
|
20
|
+
"pont2-input": Pont2Input;
|
|
21
|
+
"pont2-kbd": Kbd;
|
|
22
|
+
"pont2-kbd-group": KbdGroup;
|
|
23
|
+
"pont2-label": Pont2Label;
|
|
24
|
+
"pont2-native-select": NativeSelect;
|
|
25
|
+
"pont2-separator": Separator;
|
|
26
|
+
"pont2-skeleton": Skeleton;
|
|
27
|
+
"pont2-slider": Slider;
|
|
28
|
+
"pont2-spinner": Spinner;
|
|
29
|
+
"pont2-switch": Switch;
|
|
30
|
+
"pont2-table": Table;
|
|
31
|
+
"pont2-textarea": Pont2Textarea;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { nothing, PropertyDeclarations, TemplateResult } from 'lit';
|
|
2
|
+
import { ActionController } from '../../core/controllers/action';
|
|
3
|
+
import { ButtonBase, ButtonOptions } from '../../primitives/button/button';
|
|
4
|
+
import { AuthProvider } from './providers';
|
|
5
|
+
export { AUTH_PROVIDERS, PROVIDER_NAMES, providerIcon, type AuthProvider } from './providers';
|
|
6
|
+
/** What the button shows: the legacy kit's `content` prop. */
|
|
7
|
+
export declare const AUTH_BUTTON_CONTENTS: readonly ["label", "icon-label", "icon"];
|
|
8
|
+
export type AuthButtonContent = (typeof AUTH_BUTTON_CONTENTS)[number];
|
|
9
|
+
export type AuthButtonIconAlign = "start" | "end";
|
|
10
|
+
/**
|
|
11
|
+
* # AuthButton: the shared base of the auth-flow buttons
|
|
12
|
+
*
|
|
13
|
+
* An auth button **is a Button** (`extends ButtonBase`: variant, size,
|
|
14
|
+
* disabled, type… inherited, nothing forwarded) and **has action behaviour**
|
|
15
|
+
* (`ActionController`: the `pont2-action` request/response protocol, see
|
|
16
|
+
* core/controllers/action.ts). Its DOM is the button primitive's:
|
|
17
|
+
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <pont2-provider-button provider="google" data-pont2-shell> ← display: contents
|
|
20
|
+
* <button data-pont2-button data-slot="button" data-variant="outline" data-provider="google" type="button">
|
|
21
|
+
* <svg data-icon="inline-start" …/>Continue with Google
|
|
22
|
+
* </button>
|
|
23
|
+
* </pont2-provider-button>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Two nodes; the legacy `pont-provider-button > pont-button > button` has three.
|
|
27
|
+
*
|
|
28
|
+
* While busy (a `respondWith()` promise is pending, or `loading` is set) the
|
|
29
|
+
* button shows a spinner in place of its icon, sets `aria-busy`, and is
|
|
30
|
+
* disabled *focusably* (`aria-disabled`, Base UI's `focusableWhenDisabled`),
|
|
31
|
+
* so keyboard focus is not lost mid-request and a second press is ignored.
|
|
32
|
+
*
|
|
33
|
+
* Subclasses provide the default copy, the icon, and what a press does.
|
|
34
|
+
*/
|
|
35
|
+
export declare abstract class AuthButton extends ButtonBase {
|
|
36
|
+
static composite: boolean;
|
|
37
|
+
static properties: PropertyDeclarations;
|
|
38
|
+
/**
|
|
39
|
+
* `label` (default), `icon-label` or `icon` (icon only; the label becomes the
|
|
40
|
+
* accessible name). Icon-only keeps the text size, as shadcn's login blocks
|
|
41
|
+
* do: at the default size it is already near-square (38×36px, as shadcn's),
|
|
42
|
+
* and it can still stretch to fill a grid cell (`w-full`). Set
|
|
43
|
+
* `size="icon"` for a fixed square.
|
|
44
|
+
*/
|
|
45
|
+
content: AuthButtonContent;
|
|
46
|
+
iconAlign: AuthButtonIconAlign;
|
|
47
|
+
/** Visible text (and accessible name). Each button has a default. */
|
|
48
|
+
label: string;
|
|
49
|
+
/** The action requested on press (a login-flow event id). */
|
|
50
|
+
event: string | undefined;
|
|
51
|
+
/** Busy state set by the owner, in addition to a pending `respondWith()`. */
|
|
52
|
+
loading: boolean;
|
|
53
|
+
protected readonly action: ActionController;
|
|
54
|
+
constructor();
|
|
55
|
+
/** True while a request is pending or `loading` is set. */
|
|
56
|
+
get busy(): boolean;
|
|
57
|
+
/** The text used when `label` is empty. */
|
|
58
|
+
protected abstract defaultLabel(): string;
|
|
59
|
+
/** The button's icon, with the attributes shadcn's button CSS keys on. */
|
|
60
|
+
protected abstract renderIcon(attrs: Record<string, string>): TemplateResult | typeof nothing;
|
|
61
|
+
/** Data sent with the `pont2-action` request. */
|
|
62
|
+
protected actionData(): Record<string, unknown>;
|
|
63
|
+
/** What a press does. The default requests the action. */
|
|
64
|
+
protected onPress(_e: MouseEvent): void;
|
|
65
|
+
protected get text(): string;
|
|
66
|
+
protected buttonOptions(): ButtonOptions;
|
|
67
|
+
/** Extra attributes for the native button (`data-provider` …). */
|
|
68
|
+
protected extraAttrs(): Record<string, string | boolean | null | undefined>;
|
|
69
|
+
protected renderContent(): TemplateResult<1>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* # `<pont2-provider-button>`: sign in with an identity provider
|
|
73
|
+
*
|
|
74
|
+
* ```html
|
|
75
|
+
* <pont2-provider-button provider="google" event="oauth_google"></pont2-provider-button>
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* Defaults: `variant="outline"`, `content="icon-label"`, label
|
|
79
|
+
* "`prompt` + provider name" ("Continue with Google"). Pressing requests
|
|
80
|
+
* `event` with `{ provider }` (see AuthButton).
|
|
81
|
+
*
|
|
82
|
+
* @tag pont2-provider-button
|
|
83
|
+
* @attr provider - apple | discord | facebook | github | google | linkedin | meta | microsoft | x
|
|
84
|
+
* @attr prompt - text before the provider name in the default label (default "Continue with")
|
|
85
|
+
* @attr label - replaces the whole default label
|
|
86
|
+
* @attr event - the action requested on press
|
|
87
|
+
* @attr content - label | icon-label (default) | icon
|
|
88
|
+
* @attr icon-align - start (default) | end
|
|
89
|
+
* @attr loading - busy state set by the owner
|
|
90
|
+
* @fires pont2-action - `{ action, data: { provider }, respondWith }` on press
|
|
91
|
+
* @fires pont2-action-success - `{ action, data, result }`
|
|
92
|
+
* @fires pont2-action-error - `{ action, data, error, message }`
|
|
93
|
+
*/
|
|
94
|
+
export declare class ProviderButton extends AuthButton {
|
|
95
|
+
static properties: PropertyDeclarations;
|
|
96
|
+
provider: AuthProvider;
|
|
97
|
+
prompt: string;
|
|
98
|
+
constructor();
|
|
99
|
+
protected defaultLabel(): string;
|
|
100
|
+
protected renderIcon(a: Record<string, string>): TemplateResult<1> | typeof nothing;
|
|
101
|
+
protected actionData(): {
|
|
102
|
+
provider: "x" | "meta" | "apple" | "discord" | "facebook" | "github" | "google" | "linkedin" | "microsoft";
|
|
103
|
+
};
|
|
104
|
+
protected extraAttrs(): {
|
|
105
|
+
"data-provider": "x" | "meta" | "apple" | "discord" | "facebook" | "github" | "google" | "linkedin" | "microsoft";
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* # `<pont2-passkey-button>`: sign in with a passkey
|
|
110
|
+
*
|
|
111
|
+
* ```html
|
|
112
|
+
* <pont2-passkey-button event="passkey_login"></pont2-passkey-button>
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* Defaults: `variant="secondary"`, `content="label"`, label "Continue with
|
|
116
|
+
* Passkey", icon lucide `user-round-key`. Pressing requests `event`.
|
|
117
|
+
*
|
|
118
|
+
* The listener must start the WebAuthn call synchronously (call
|
|
119
|
+
* `respondWith()` with the promise straight away). The request is dispatched
|
|
120
|
+
* inside the click, so the call keeps the user activation that
|
|
121
|
+
* `navigator.credentials.get()` needs in Safari.
|
|
122
|
+
*
|
|
123
|
+
* @tag pont2-passkey-button
|
|
124
|
+
* @attr label, event, content, icon-align, loading - see ProviderButton
|
|
125
|
+
* @fires pont2-action, pont2-action-success, pont2-action-error
|
|
126
|
+
*/
|
|
127
|
+
export declare class PasskeyButton extends AuthButton {
|
|
128
|
+
constructor();
|
|
129
|
+
protected defaultLabel(): string;
|
|
130
|
+
protected renderIcon(a: Record<string, string>): TemplateResult<1>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* # `<pont2-submit-button>`: submit an auth form
|
|
134
|
+
*
|
|
135
|
+
* ```html
|
|
136
|
+
* <form>
|
|
137
|
+
* …fields…
|
|
138
|
+
* <pont2-submit-button event="submit_password"></pont2-submit-button>
|
|
139
|
+
* </form>
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* A real `<button type="submit">`, so the browser's own submission rules
|
|
143
|
+
* apply: Enter in a field submits, constraint validation (`required`,
|
|
144
|
+
* `type="email"` …) blocks an invalid form, and `SubmitEvent.submitter` is
|
|
145
|
+
* this button.
|
|
146
|
+
*
|
|
147
|
+
* When its form **submits** (not merely when it is clicked), the button
|
|
148
|
+
* requests `event` with `{ form, formData }` (the FormData includes this
|
|
149
|
+
* button's `name`/`value`, if any):
|
|
150
|
+
*
|
|
151
|
+
* - a listener calls `respondWith()` → the native submission is prevented
|
|
152
|
+
* (the flow is handled in-page) and the button is busy until it settles;
|
|
153
|
+
* - nobody responds → the form submits natively (progressive enhancement:
|
|
154
|
+
* a plain `<form action>` still works).
|
|
155
|
+
*
|
|
156
|
+
* A submission without a submitter (`form.requestSubmit()`, e.g. an OTP
|
|
157
|
+
* auto-submit) is handled by the form's **default button** (its first submit
|
|
158
|
+
* button), as the browser does for implicit submission.
|
|
159
|
+
*
|
|
160
|
+
* Outside a form, a press requests the action directly.
|
|
161
|
+
*
|
|
162
|
+
* Defaults: `variant="default"`, `content="label"`, `icon-align="end"`,
|
|
163
|
+
* label "Submit", icon lucide `arrow-right`.
|
|
164
|
+
*
|
|
165
|
+
* @tag pont2-submit-button
|
|
166
|
+
* @attr label, event, content, icon-align, loading - see ProviderButton
|
|
167
|
+
* @fires pont2-action - `{ action, data: { form, formData }, respondWith }` on submit
|
|
168
|
+
* @fires pont2-action-success, pont2-action-error
|
|
169
|
+
*/
|
|
170
|
+
export declare class SubmitButton extends AuthButton {
|
|
171
|
+
constructor();
|
|
172
|
+
protected defaultLabel(): string;
|
|
173
|
+
protected renderIcon(a: Record<string, string>): TemplateResult<1>;
|
|
174
|
+
connectedCallback(): void;
|
|
175
|
+
disconnectedCallback(): void;
|
|
176
|
+
protected onPress(_e: MouseEvent): void;
|
|
177
|
+
private onSubmit;
|
|
178
|
+
}
|
|
179
|
+
declare global {
|
|
180
|
+
interface HTMLElementTagNameMap {
|
|
181
|
+
"pont2-provider-button": ProviderButton;
|
|
182
|
+
"pont2-passkey-button": PasskeyButton;
|
|
183
|
+
"pont2-submit-button": SubmitButton;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AttrMap } from '../../core/attrs';
|
|
2
|
+
/**
|
|
3
|
+
* Sign-in providers: display names and brand marks.
|
|
4
|
+
*
|
|
5
|
+
* The marks are Simple Icons (https://simpleicons.org, CC0-1.0), the same
|
|
6
|
+
* geometry the legacy kit ships (src/components/renderers/auth/button/
|
|
7
|
+
* button.defs.ts). pont2 keeps its own copy because it imports nothing from
|
|
8
|
+
* the legacy kit (docs/08-parallel-constraints.md).
|
|
9
|
+
*/
|
|
10
|
+
export declare const AUTH_PROVIDERS: readonly ["apple", "discord", "facebook", "github", "google", "linkedin", "meta", "microsoft", "x"];
|
|
11
|
+
export type AuthProvider = (typeof AUTH_PROVIDERS)[number];
|
|
12
|
+
export declare const PROVIDER_NAMES: Record<AuthProvider, string>;
|
|
13
|
+
export declare const isAuthProvider: (p: unknown) => p is AuthProvider;
|
|
14
|
+
/** A provider's brand mark as an `<svg>` (filled with `currentColor`, aria-hidden). */
|
|
15
|
+
export declare function providerIcon(provider: AuthProvider, extra?: AttrMap): import('lit-html').TemplateResult<1>;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { nothing, PropertyDeclarations, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { Field } from '../../primitives/field/field';
|
|
3
|
+
import { InputOptions } from '../../primitives/input/input';
|
|
4
|
+
/**
|
|
5
|
+
* Default error copy, identical to the legacy kit's (field.defs.ts), so
|
|
6
|
+
* existing screens read the same. Every message is overridable per field
|
|
7
|
+
* (`required-error`, `format-error` …). Localised copy is expected from the
|
|
8
|
+
* render spec / widget.
|
|
9
|
+
*/
|
|
10
|
+
export declare const fieldMessages: {
|
|
11
|
+
required: (label: string) => string;
|
|
12
|
+
format: (label: string) => string;
|
|
13
|
+
minlength: (label: string, n?: number) => string;
|
|
14
|
+
maxlength: (label: string, n?: number) => string;
|
|
15
|
+
};
|
|
16
|
+
export type FieldIssueType = "required" | "minlength" | "maxlength" | "format" | "rule" | "match" | "incomplete";
|
|
17
|
+
export interface FieldIssue {
|
|
18
|
+
type: FieldIssueType;
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
/** `pont2-field-validate` detail. The value is deliberately not included (passwords). */
|
|
22
|
+
export interface FieldValidateDetail {
|
|
23
|
+
name: string;
|
|
24
|
+
valid: boolean;
|
|
25
|
+
issues: FieldIssue[];
|
|
26
|
+
}
|
|
27
|
+
/** "default": every rule; "simple": `required` only (the legacy `validation` attribute). */
|
|
28
|
+
export type FieldValidationMode = "default" | "simple";
|
|
29
|
+
/** Compiles a pattern source, preferring Unicode mode (needed for `\p{L}`). */
|
|
30
|
+
export declare function compilePattern(source: string): RegExp | null;
|
|
31
|
+
/**
|
|
32
|
+
* # AuthField: the shared base of the auth-flow text fields
|
|
33
|
+
*
|
|
34
|
+
* An auth field **is a Field** (`extends Field`: the host is shadcn's
|
|
35
|
+
* `div[role=group][data-slot=field]`, styled by the field recipe, with
|
|
36
|
+
* `data-invalid` / `data-disabled`) that renders its label, control,
|
|
37
|
+
* description and error from properties, as parts:
|
|
38
|
+
*
|
|
39
|
+
* ```html
|
|
40
|
+
* <pont2-email-field data-pont2-field data-slot="field" data-orientation="vertical" [data-invalid]>
|
|
41
|
+
* <label data-pont2-label data-pont2-field-label data-slot="field-label" for="…-input">Email</label>
|
|
42
|
+
* <input data-pont2-input data-slot="input" id="…-input" name="email" type="email"
|
|
43
|
+
* autocomplete="email" aria-describedby="…-description …-error" [aria-invalid="true"]>
|
|
44
|
+
* <p data-pont2-field-description data-slot="field-description" id="…-description">…</p>
|
|
45
|
+
* <div data-pont2-field-error data-slot="field-error" role="alert" id="…-error">Please enter a valid email.</div>
|
|
46
|
+
* </pont2-email-field>
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* **The native `<input name>` is the form control.** There is no hidden
|
|
50
|
+
* input and no form-association: the form's own FormData, autofill and
|
|
51
|
+
* password managers, `form.reset()` and `<fieldset disabled>` all work
|
|
52
|
+
* natively.
|
|
53
|
+
*
|
|
54
|
+
* **Validation is the platform's.** The field computes its issues on every
|
|
55
|
+
* change and mirrors the first into `input.setCustomValidity()`, so
|
|
56
|
+
* `form.checkValidity()`, `:invalid` and interactive validation are always
|
|
57
|
+
* right, and the submit button never sends an invalid form. The field cancels
|
|
58
|
+
* the browser's bubble (`invalid` event) and shows its own error instead.
|
|
59
|
+
* Errors are **shown** after the user commits a change (`change`), when the
|
|
60
|
+
* form is submitted, or on `reportValidity()`; once shown they update live
|
|
61
|
+
* while typing.
|
|
62
|
+
*
|
|
63
|
+
* **Normalisation** (trimming, lower-casing an email…) is applied to the
|
|
64
|
+
* submitted value through the form's `formdata` event, without rewriting what
|
|
65
|
+
* the user sees.
|
|
66
|
+
*
|
|
67
|
+
* Subclasses supply defaults and rules through the protected hooks.
|
|
68
|
+
*
|
|
69
|
+
* @fires pont2-field-validate - `{ name, valid, issues }` whenever validity is shown (change, submit, reportValidity)
|
|
70
|
+
*/
|
|
71
|
+
export declare abstract class AuthField extends Field {
|
|
72
|
+
static composite: boolean;
|
|
73
|
+
static properties: PropertyDeclarations;
|
|
74
|
+
/** `id` of the native input (generated when absent), for `<label for>` elsewhere. */
|
|
75
|
+
inputId: string;
|
|
76
|
+
/** Form-data key. Each field has a default (`email`, `password`, `login_id` …). */
|
|
77
|
+
name: string;
|
|
78
|
+
/** Initial value (the `value` attribute, as on a native input). `.value` is live. */
|
|
79
|
+
defaultValue: string;
|
|
80
|
+
label: string;
|
|
81
|
+
placeholder: string;
|
|
82
|
+
description: string;
|
|
83
|
+
/** Text after the label, e.g. "(optional)". */
|
|
84
|
+
mark: string;
|
|
85
|
+
/** Show a `*` after the label when `required` (and no `mark`). */
|
|
86
|
+
caret: boolean;
|
|
87
|
+
autocomplete: string;
|
|
88
|
+
required: boolean;
|
|
89
|
+
validation: FieldValidationMode;
|
|
90
|
+
/** Regex source for the format rule. Each field has a default where the legacy kit had one. */
|
|
91
|
+
pattern: string;
|
|
92
|
+
minlength: number | undefined;
|
|
93
|
+
maxlength: number | undefined;
|
|
94
|
+
requiredError: string;
|
|
95
|
+
formatError: string;
|
|
96
|
+
minlengthError: string;
|
|
97
|
+
maxlengthError: string;
|
|
98
|
+
protected current: string;
|
|
99
|
+
/** Whether issues are displayed (after change / submit / reportValidity). */
|
|
100
|
+
protected shown: boolean;
|
|
101
|
+
private dirty;
|
|
102
|
+
private generatedId;
|
|
103
|
+
private boundForm;
|
|
104
|
+
constructor();
|
|
105
|
+
protected abstract defaultName(): string;
|
|
106
|
+
protected abstract defaultLabel(): string;
|
|
107
|
+
protected inputType(): string;
|
|
108
|
+
protected defaultAutocomplete(): string;
|
|
109
|
+
protected defaultPattern(): string;
|
|
110
|
+
/** Extra attributes for the input (inputmode, autocapitalize, spellcheck …). */
|
|
111
|
+
protected inputAttrs(): Record<string, string | boolean | null | undefined>;
|
|
112
|
+
/** The submitted form of a raw value. Identity by default. */
|
|
113
|
+
normalizeValue(raw: string): string;
|
|
114
|
+
/**
|
|
115
|
+
* Rules for a non-empty value, after `required`. The default is the legacy
|
|
116
|
+
* order: minlength, then maxlength, then the format pattern; first failure only.
|
|
117
|
+
*/
|
|
118
|
+
protected valueIssues(value: string): FieldIssue[];
|
|
119
|
+
/** The native input. */
|
|
120
|
+
get control(): HTMLInputElement | null;
|
|
121
|
+
/** The normalised value (what is submitted). */
|
|
122
|
+
get value(): string;
|
|
123
|
+
set value(v: string);
|
|
124
|
+
/** The effective form-data key. */
|
|
125
|
+
get fieldName(): string;
|
|
126
|
+
/** The effective label text. */
|
|
127
|
+
get text(): string;
|
|
128
|
+
/** Current issues (empty when valid). Independent of whether they are shown. */
|
|
129
|
+
get issues(): FieldIssue[];
|
|
130
|
+
checkValidity(): boolean;
|
|
131
|
+
/** Shows the field's errors (or clears them) and returns validity. Legacy name: `validate()`. */
|
|
132
|
+
reportValidity(): boolean;
|
|
133
|
+
validate(): boolean;
|
|
134
|
+
focus(options?: FocusOptions): void;
|
|
135
|
+
protected computeIssues(): FieldIssue[];
|
|
136
|
+
private show;
|
|
137
|
+
protected onInput: (e: Event) => void;
|
|
138
|
+
/**
|
|
139
|
+
* Sets the raw value and mirrors validity to the input **synchronously**:
|
|
140
|
+
* code that submits in the same task (an OTP auto-submit, `requestSubmit()`
|
|
141
|
+
* in an `input` listener) must not see the previous render's validity.
|
|
142
|
+
*/
|
|
143
|
+
protected setCurrent(raw: string): void;
|
|
144
|
+
protected syncValidity(): void;
|
|
145
|
+
protected onChange: () => void;
|
|
146
|
+
private onInvalid;
|
|
147
|
+
private onFormData;
|
|
148
|
+
protected onReset: () => void;
|
|
149
|
+
private bindForm;
|
|
150
|
+
disconnectedCallback(): void;
|
|
151
|
+
protected get controlId(): string;
|
|
152
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
153
|
+
protected updated(): void;
|
|
154
|
+
/** Options for the control part; subclasses render it differently (password: input group). */
|
|
155
|
+
protected controlOptions(describedBy: string | undefined): InputOptions;
|
|
156
|
+
protected renderControl(o: InputOptions): TemplateResult;
|
|
157
|
+
protected renderLabel(): TemplateResult | typeof nothing;
|
|
158
|
+
protected renderError(id: string, issues: FieldIssue[]): TemplateResult;
|
|
159
|
+
render(): TemplateResult<1>;
|
|
160
|
+
/** The `invalid` event does not bubble, so it is listened to on the input itself. */
|
|
161
|
+
connectedCallback(): void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* `<pont2-email-field>`: `type="email"`, `autocomplete="email"`, name
|
|
165
|
+
* `email`. Normalised to trimmed lower case. Format rule: the legacy pattern
|
|
166
|
+
* `^[^\s@]+@[^\s@]+\.[^\s@]+$`.
|
|
167
|
+
*
|
|
168
|
+
* @tag pont2-email-field
|
|
169
|
+
*/
|
|
170
|
+
export declare class EmailField extends AuthField {
|
|
171
|
+
protected defaultName(): string;
|
|
172
|
+
protected defaultLabel(): string;
|
|
173
|
+
protected inputType(): string;
|
|
174
|
+
protected defaultAutocomplete(): string;
|
|
175
|
+
protected defaultPattern(): string;
|
|
176
|
+
normalizeValue(raw: string): string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* `<pont2-phone-field>`: `type="tel"`, `autocomplete="tel"`, name `phone`.
|
|
180
|
+
* Normalised by removing whitespace. Format rule: the legacy pattern.
|
|
181
|
+
*
|
|
182
|
+
* @tag pont2-phone-field
|
|
183
|
+
*/
|
|
184
|
+
export declare class PhoneField extends AuthField {
|
|
185
|
+
protected defaultName(): string;
|
|
186
|
+
protected defaultLabel(): string;
|
|
187
|
+
protected inputType(): string;
|
|
188
|
+
protected defaultAutocomplete(): string;
|
|
189
|
+
protected defaultPattern(): string;
|
|
190
|
+
normalizeValue(raw: string): string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* `<pont2-username-field>`: `autocomplete="username"`, name `username`,
|
|
194
|
+
* no autocapitalisation or spellcheck. Normalised to trimmed lower case.
|
|
195
|
+
* Rules: `minlength`, `maxlength`, then the pattern `^[a-z0-9_]*$`.
|
|
196
|
+
*
|
|
197
|
+
* @tag pont2-username-field
|
|
198
|
+
*/
|
|
199
|
+
export declare class UsernameField extends AuthField {
|
|
200
|
+
protected defaultName(): string;
|
|
201
|
+
protected defaultLabel(): string;
|
|
202
|
+
protected defaultAutocomplete(): string;
|
|
203
|
+
protected defaultPattern(): string;
|
|
204
|
+
protected inputAttrs(): {
|
|
205
|
+
autocapitalize: string;
|
|
206
|
+
spellcheck: string;
|
|
207
|
+
};
|
|
208
|
+
normalizeValue(raw: string): string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* `<pont2-name-field>`: `autocomplete="name"`, name `name`. Normalised by
|
|
212
|
+
* trimming and collapsing whitespace. Rules: `minlength`, `maxlength`, then
|
|
213
|
+
* the Unicode pattern `^[\p{L} .'-]*$` (letters in any script).
|
|
214
|
+
*
|
|
215
|
+
* @tag pont2-name-field
|
|
216
|
+
*/
|
|
217
|
+
export declare class NameField extends AuthField {
|
|
218
|
+
protected defaultName(): string;
|
|
219
|
+
protected defaultLabel(): string;
|
|
220
|
+
protected defaultAutocomplete(): string;
|
|
221
|
+
protected defaultPattern(): string;
|
|
222
|
+
normalizeValue(raw: string): string;
|
|
223
|
+
}
|
|
224
|
+
export declare const IDENTIFIER_KINDS: readonly ["email", "phone", "username"];
|
|
225
|
+
export type IdentifierKind = (typeof IDENTIFIER_KINDS)[number];
|
|
226
|
+
/** `["email","phone"]` → "Email or phone"; three → "Email, phone, or username" (legacy copy). */
|
|
227
|
+
export declare function identifierLabel(kinds: readonly IdentifierKind[]): string;
|
|
228
|
+
/**
|
|
229
|
+
* `<pont2-identifier-field>`: the sign-in identifier (email, phone or
|
|
230
|
+
* username), submitted as `login_id` (the platform's contract).
|
|
231
|
+
*
|
|
232
|
+
* `identifiers` (attribute: space- or comma-separated; property: array) picks
|
|
233
|
+
* the label ("Email or phone") and the input type: `email` or `tel` when it
|
|
234
|
+
* is exactly one of those, `text` otherwise. `autocomplete="username"`, which
|
|
235
|
+
* is what password managers look for next to a password. Normalised to
|
|
236
|
+
* trimmed lower case. Rule: `required` only (no format), as in the legacy kit.
|
|
237
|
+
*
|
|
238
|
+
* @tag pont2-identifier-field
|
|
239
|
+
* @attr identifiers - e.g. "email phone username"
|
|
240
|
+
*/
|
|
241
|
+
export declare class IdentifierField extends AuthField {
|
|
242
|
+
static properties: PropertyDeclarations;
|
|
243
|
+
identifiers: IdentifierKind[];
|
|
244
|
+
constructor();
|
|
245
|
+
protected defaultName(): string;
|
|
246
|
+
protected defaultLabel(): string;
|
|
247
|
+
protected inputType(): "text" | "email" | "tel";
|
|
248
|
+
protected defaultAutocomplete(): string;
|
|
249
|
+
protected inputAttrs(): {
|
|
250
|
+
autocapitalize: string;
|
|
251
|
+
spellcheck: string;
|
|
252
|
+
};
|
|
253
|
+
protected valueIssues(): never[];
|
|
254
|
+
normalizeValue(raw: string): string;
|
|
255
|
+
}
|
|
256
|
+
declare global {
|
|
257
|
+
interface HTMLElementTagNameMap {
|
|
258
|
+
"pont2-email-field": EmailField;
|
|
259
|
+
"pont2-phone-field": PhoneField;
|
|
260
|
+
"pont2-username-field": UsernameField;
|
|
261
|
+
"pont2-name-field": NameField;
|
|
262
|
+
"pont2-identifier-field": IdentifierField;
|
|
263
|
+
}
|
|
264
|
+
interface HTMLElementEventMap {
|
|
265
|
+
"pont2-field-validate": CustomEvent<FieldValidateDetail>;
|
|
266
|
+
}
|
|
267
|
+
}
|