@pontive/pontkit-core 1.27.0 → 1.29.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.
Files changed (69) hide show
  1. package/catalog.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/components/renderers/auth/scope-list/_scope-list.d.ts +1 -1
  4. package/dist/components/renderers/auth/scope-list/scope-list.types.d.ts +1 -1
  5. package/dist/components/widgets/pont-consent/consent-api.d.ts +1 -1
  6. package/dist/components/widgets/pont-consent/pont-consent.d.ts +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/pont2/core/controllers/action.d.ts +79 -0
  10. package/dist/pont2/core/controllers/copy.d.ts +34 -0
  11. package/dist/pont2/core/icons.d.ts +24 -16
  12. package/dist/pont2/core/index.d.ts +2 -0
  13. package/dist/pont2/core/names.d.ts +1 -1
  14. package/dist/pont2/globals.css +19 -7
  15. package/dist/pont2/index.mjs +3349 -1494
  16. package/dist/pont2/index.mjs.map +1 -1
  17. package/dist/pont2/kit/alert/alert.d.ts +2 -1
  18. package/dist/pont2/kit/auth-button/auth-button.d.ts +185 -0
  19. package/dist/pont2/kit/auth-button/providers.d.ts +15 -0
  20. package/dist/pont2/kit/auth-field/auth-field.d.ts +267 -0
  21. package/dist/pont2/kit/auth-field/password-field.d.ts +124 -0
  22. package/dist/pont2/kit/block/block.d.ts +66 -0
  23. package/dist/pont2/kit/block/branding.d.ts +36 -0
  24. package/dist/pont2/kit/container/container.d.ts +40 -0
  25. package/dist/pont2/kit/countdown/countdown.d.ts +64 -0
  26. package/dist/pont2/kit/divider/divider.d.ts +30 -0
  27. package/dist/pont2/kit/edit-identifier/edit-identifier.d.ts +47 -0
  28. package/dist/pont2/kit/flow-widget/flow-widget.d.ts +151 -0
  29. package/dist/pont2/kit/gap/gap.d.ts +36 -0
  30. package/dist/pont2/kit/header/header.d.ts +37 -0
  31. package/dist/pont2/kit/index.d.ts +23 -0
  32. package/dist/pont2/kit/input-otp/input-otp.d.ts +7 -0
  33. package/dist/pont2/kit/layout/flow-error.d.ts +21 -0
  34. package/dist/pont2/kit/layout/layout.d.ts +120 -0
  35. package/dist/pont2/kit/link/link.d.ts +64 -0
  36. package/dist/pont2/kit/logo/logo.d.ts +57 -0
  37. package/dist/pont2/kit/otp-field/otp-field.d.ts +93 -0
  38. package/dist/pont2/kit/otp-field/otp-resend.d.ts +63 -0
  39. package/dist/pont2/kit/provider-field/provider-field.d.ts +87 -0
  40. package/dist/pont2/kit/qr-code/qr-code.d.ts +87 -0
  41. package/dist/pont2/kit/recovery-codes/recovery-codes.d.ts +65 -0
  42. package/dist/pont2/kit/scope-list/scope-list.d.ts +69 -0
  43. package/dist/pont2/kit/scope-list/scope-value.d.ts +16 -0
  44. package/dist/pont2/kit/secret/secret.d.ts +67 -0
  45. package/dist/pont2/kit/story-helpers.d.ts +9 -0
  46. package/dist/pont2/kit/typography/typography.d.ts +74 -0
  47. package/dist/pont2/kit/watermark/pontive-logo.d.ts +8 -0
  48. package/dist/pont2/kit/watermark/watermark.d.ts +44 -0
  49. package/dist/pont2/primitives/card/card.d.ts +3 -1
  50. package/dist/pont2/primitives/dropdown-menu/dropdown-menu.d.ts +5 -0
  51. package/dist/pont2/primitives/popover/popover.d.ts +2 -0
  52. package/dist/pont2/primitives/tooltip/tooltip.d.ts +2 -0
  53. package/dist/pont2/styles.css +3042 -935
  54. package/dist/pont2/theme/apply.d.ts +29 -0
  55. package/dist/pont2/theme/compile.d.ts +23 -0
  56. package/dist/pont2/theme/index.d.ts +23 -0
  57. package/dist/pont2/theme/manifest.d.ts +2 -0
  58. package/dist/pont2/theme/scopes.d.ts +13 -0
  59. package/dist/pont2/theme/shadcn.d.ts +7 -0
  60. package/dist/pont2/theme/tokens.json.d.ts +7009 -0
  61. package/dist/pont2/theme/types.d.ts +92 -0
  62. package/dist/pont2/theme/validate.d.ts +11 -0
  63. package/dist/pont2/theme/value.d.ts +10 -0
  64. package/dist/pont2/theme/vocabulary.d.ts +32 -0
  65. package/dist/pont2/theme.mjs +337 -0
  66. package/dist/pont2/theme.mjs.map +1 -0
  67. package/dist/pont2/tokens.json +7006 -0
  68. package/dist/pont2/with-legacy.css +1 -1
  69. package/package.json +8 -2
@@ -28,7 +28,7 @@ export type AlertStatus = (typeof ALERT_STATUSES)[number];
28
28
  * with the primitive's attributes), not nested elements.
29
29
  * - **What it adds** over shadcn: `status` (`error` maps to shadcn's
30
30
  * `destructive` variant; `warning`/`success`/`info` are coloured in
31
- * `@layer pont2.kit` with the `--pont2-success|warning|info` tokens), a
31
+ * `@layer pont2.kit` with the `--pont2-sem-color-success|warning|info` tokens), a
32
32
  * status icon, and a status-appropriate role (`alert` for error/warning,
33
33
  * `status` otherwise, as the legacy `pont-alert` did). An author `role`
34
34
  * attribute still wins.
@@ -43,6 +43,7 @@ export type AlertStatus = (typeof ALERT_STATUSES)[number];
43
43
  * @attr heading - the alert title text
44
44
  * @attr description - the description text
45
45
  * @attr icon - show the status icon
46
+ * @cssprop --pont2-alert-warning-fg, --pont2-alert-success-fg, --pont2-alert-info-fg - status colours (default the sem status colours)
46
47
  */
47
48
  export declare class KitAlert extends Alert {
48
49
  static composite: boolean;
@@ -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
+ }
@@ -0,0 +1,124 @@
1
+ import { nothing, PropertyDeclarations, TemplateResult } from 'lit';
2
+ import { ActionController } from '../../core/controllers/action';
3
+ import { InputOptions } from '../../primitives/input/input';
4
+ import { AuthField, FieldIssue } from './auth-field';
5
+ export type PasswordRuleName = "uppercase" | "lowercase" | "number" | "special";
6
+ /** A rule: a named one, or your own `pattern`, each with an optional message. */
7
+ export type PasswordRule = {
8
+ name: PasswordRuleName;
9
+ error?: string;
10
+ } | {
11
+ pattern: string;
12
+ error?: string;
13
+ };
14
+ /** The legacy named patterns (field.defs.ts). */
15
+ export declare const PASSWORD_RULE_PATTERNS: Record<PasswordRuleName, RegExp>;
16
+ export declare const DEFAULT_PASSWORD_RULES: PasswordRule[];
17
+ export type SecretFieldVariant = "toggle" | "simple";
18
+ /**
19
+ * A field whose value is secret: `type="password"`, and with
20
+ * `variant="toggle"` (default) a show/hide button, built as shadcn builds it,
21
+ * from InputGroup parts:
22
+ *
23
+ * ```html
24
+ * <div data-pont2-input-group data-slot="input-group" role="group">
25
+ * <input data-pont2-input data-pont2-input-group-input data-slot="input-group-control" type="password" …>
26
+ * <div data-pont2-input-group-addon data-slot="input-group-addon" data-align="inline-end" role="group">
27
+ * <button data-pont2-button data-pont2-input-group-button data-variant="ghost" data-size="icon-xs"
28
+ * aria-label="Show password" aria-pressed="false" aria-controls="…-input"><svg/></button>
29
+ * </div>
30
+ * </div>
31
+ * ```
32
+ *
33
+ * The toggle is a *toggle button* (`aria-pressed`, a stable name), the
34
+ * WAI-ARIA pattern, rather than a button whose name flips. The value is
35
+ * never normalised.
36
+ *
37
+ * @attr variant - toggle (default) | simple
38
+ * @attr show-label - the toggle's accessible name (default "Show password")
39
+ */
40
+ export declare abstract class SecretField extends AuthField {
41
+ static properties: PropertyDeclarations;
42
+ variant: SecretFieldVariant;
43
+ showLabel: string;
44
+ /** Whether the value is currently shown as text. */
45
+ revealed: boolean;
46
+ constructor();
47
+ protected inputType(): "text" | "password";
48
+ protected inputAttrs(): {
49
+ autocapitalize: string;
50
+ spellcheck: string;
51
+ };
52
+ private toggle;
53
+ protected renderControl(o: InputOptions): TemplateResult;
54
+ }
55
+ /**
56
+ * # `<pont2-password-field>`
57
+ *
58
+ * `autocomplete="current-password"` by default (set `new-password` on
59
+ * sign-up screens), name `password`. Rules: `minlength`, `maxlength`, then
60
+ * **every** `rules` entry; all failing rules are listed (shadcn's FieldError
61
+ * list). Defaults are the legacy four: uppercase, lowercase, number, special.
62
+ *
63
+ * `forgot` adds a "Forgot your password?" link-styled button beside the label
64
+ * (shadcn's login block layout). It requests `forgot-event` through the
65
+ * action protocol (`pont2-action` with `data: { forgot: true }`), exactly
66
+ * like the auth buttons, and is busy until the response settles.
67
+ *
68
+ * @tag pont2-password-field
69
+ * @attr rules - JSON array of `{ name }` / `{ pattern }` rules with optional `error`; `rules="[]"` disables them
70
+ * @attr forgot - show the forgot-password link
71
+ * @attr forgot-label - its text (default "Forgot your password?")
72
+ * @attr forgot-event - the action it requests
73
+ * @fires pont2-action, pont2-action-success, pont2-action-error - from the forgot link
74
+ */
75
+ export declare class PasswordField extends SecretField {
76
+ static properties: PropertyDeclarations;
77
+ rules: PasswordRule[];
78
+ forgot: boolean;
79
+ forgotLabel: string;
80
+ forgotEvent: string | undefined;
81
+ protected readonly forgotAction: ActionController;
82
+ constructor();
83
+ protected defaultName(): string;
84
+ protected defaultLabel(): string;
85
+ protected defaultAutocomplete(): string;
86
+ protected valueIssues(value: string): FieldIssue[];
87
+ protected renderLabel(): TemplateResult | typeof nothing;
88
+ }
89
+ /**
90
+ * # `<pont2-confirm-field>`: repeat a password
91
+ *
92
+ * Valid when its value equals the `pair` field's (default: the first
93
+ * `pont2-password-field` in the same form, else in the document). It
94
+ * re-validates as either changes. `autocomplete="new-password"`, name
95
+ * `confirm`. Unlike the legacy kit, the pair's value is never put in an event.
96
+ *
97
+ * @tag pont2-confirm-field
98
+ * @attr pair - CSS selector of the field to match (default "pont2-password-field")
99
+ * @attr match-error - default "Passwords do not match."
100
+ */
101
+ export declare class ConfirmField extends SecretField {
102
+ static properties: PropertyDeclarations;
103
+ pair: string;
104
+ matchError: string;
105
+ private scope;
106
+ constructor();
107
+ protected defaultName(): string;
108
+ protected defaultLabel(): string;
109
+ protected defaultAutocomplete(): string;
110
+ /** The element being matched (a pont2 field or any element with `.value`). */
111
+ get pairElement(): (Element & {
112
+ value?: string;
113
+ }) | null;
114
+ protected valueIssues(value: string): FieldIssue[];
115
+ private onScopeInput;
116
+ connectedCallback(): void;
117
+ disconnectedCallback(): void;
118
+ }
119
+ declare global {
120
+ interface HTMLElementTagNameMap {
121
+ "pont2-password-field": PasswordField;
122
+ "pont2-confirm-field": ConfirmField;
123
+ }
124
+ }
@@ -0,0 +1,66 @@
1
+ import { nothing, PropertyDeclarations } from 'lit';
2
+ import { Card } from '../../primitives/card/card';
3
+ export { BrandingController, brandingContext, DEFAULT_BRANDING, type BrandingEntitlements } from './branding';
4
+ export type BlockAlign = "stretch" | "start" | "center" | "end";
5
+ export type BlockJustify = "start" | "center" | "end";
6
+ /**
7
+ * # `<pont2-block>`: the screen shell
8
+ *
9
+ * ```html
10
+ * <pont2-block>
11
+ * <pont2-header>…</pont2-header>
12
+ * <form>…</form>
13
+ * </pont2-block>
14
+ * ```
15
+ *
16
+ * **Is a Card** (`extends Card`): the host is the card, the screen's content
17
+ * is its children, **left where they are**, and the block adds one thing of
18
+ * its own, the watermark footer:
19
+ *
20
+ * ```html
21
+ * <pont2-block data-pont2-card data-slot="card" data-align="stretch" data-justify="start">
22
+ * …the screen (author / render-spec content)…
23
+ * <div data-pont2-card-footer data-slot="card-footer" data-border="top">
24
+ * <span data-pont2-watermark data-slot="watermark" data-variant="muted">Powered by <svg/></span>
25
+ * </div>
26
+ * </pont2-block>
27
+ * ```
28
+ *
29
+ * The legacy `pont-block` rendered `pont-card > [card] > pont-card-content >
30
+ * [card-content]` and then **moved** the spec's children into it
31
+ * (`moveLightDomChildrenInto`), the relocation pattern host-as-root exists to
32
+ * remove. pont2 moves nothing: the card's inline padding (CardContent's
33
+ * `px-(--card-spacing)`) is on the host, and the footer bleeds to the edges.
34
+ *
35
+ * **Watermark entitlement** (docs/branding-entitlements.md): the footer is
36
+ * rendered unless the branding context says `showWatermark: false`. There is
37
+ * no attribute or property for it, and it fails closed. It is part of the
38
+ * shell, not the content, so a screen author cannot delete it.
39
+ *
40
+ * Not a props-driven composite (`composite = false`): a block *contains* the
41
+ * screen. Lit renders the footer after the author's children.
42
+ *
43
+ * @tag pont2-block
44
+ * @attr align - stretch (default) | start | center | end: the content's cross-axis alignment
45
+ * @attr justify - start (default) | center | end: when the block is taller than its content
46
+ * @attr size - default | sm (the Card primitive's spacing)
47
+ * @cssprop --pont2-block-max-width - max width on wider screens (default 24rem)
48
+ * @cssprop --pont2-block-gap - gap between children (default 1rem)
49
+ * @cssprop --pont2-block-bg, --pont2-block-fg, --pont2-block-border-color, --pont2-block-radius, --pont2-block-shadow, --pont2-block-spacing - the screen card (fall back to the Card's tokens)
50
+ * @cssprop --pont2-block-footer-bg - the watermark band
51
+ */
52
+ export declare class Block extends Card {
53
+ static composite: boolean;
54
+ static properties: PropertyDeclarations;
55
+ align: BlockAlign;
56
+ justify: BlockJustify;
57
+ private branding;
58
+ constructor();
59
+ protected willUpdate(): void;
60
+ render(): import('lit-html').TemplateResult<1> | typeof nothing;
61
+ }
62
+ declare global {
63
+ interface HTMLElementTagNameMap {
64
+ "pont2-block": Block;
65
+ }
66
+ }