@pontive/pontkit-core 1.35.0 → 1.37.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.
@@ -1,12 +1,14 @@
1
1
  import { nothing, PropertyDeclarations, TemplateResult } from 'lit';
2
2
  import { ActionController } from '../../core/controllers/action';
3
+ import { DesignModeController } from '../../core/design-mode';
3
4
  import { ButtonBase, ButtonOptions } from '../../primitives/button/button';
4
5
  import { AuthProvider } from './providers';
5
6
  export { AUTH_PROVIDERS, PROVIDER_NAMES, providerIcon, type AuthProvider } from './providers';
6
7
  /** What the button shows: the legacy kit's `content` prop. */
7
8
  export declare const AUTH_BUTTON_CONTENTS: readonly ["label", "icon-label", "icon"];
8
9
  export type AuthButtonContent = (typeof AUTH_BUTTON_CONTENTS)[number];
9
- export type AuthButtonIconAlign = "start" | "end";
10
+ export declare const AUTH_BUTTON_ICON_ALIGNS: readonly ["start", "end"];
11
+ export type AuthButtonIconAlign = (typeof AUTH_BUTTON_ICON_ALIGNS)[number];
10
12
  /**
11
13
  * # AuthButton: the shared base of the auth-flow buttons
12
14
  *
@@ -95,6 +97,10 @@ export declare class ProviderButton extends AuthButton {
95
97
  static properties: PropertyDeclarations;
96
98
  provider: AuthProvider;
97
99
  prompt: string;
100
+ /** Design mode (core/design-mode.ts): a sample provider until the author picks one. */
101
+ protected readonly design: DesignModeController;
102
+ /** The provider shown: `provider`, or "google" in design mode when none is set (the legacy sample). */
103
+ get shownProvider(): AuthProvider;
98
104
  constructor();
99
105
  protected defaultLabel(): string;
100
106
  protected renderIcon(a: Record<string, string>): TemplateResult<1> | typeof nothing;
@@ -1,4 +1,5 @@
1
1
  import { nothing, PropertyDeclarations, PropertyValues, TemplateResult } from 'lit';
2
+ import { DesignModeController } from '../../core/design-mode';
2
3
  import { Field } from '../../primitives/field/field';
3
4
  import { InputOptions } from '../../primitives/input/input';
4
5
  /**
@@ -25,7 +26,8 @@ export interface FieldValidateDetail {
25
26
  issues: FieldIssue[];
26
27
  }
27
28
  /** "default": every rule; "simple": `required` only (the legacy `validation` attribute). */
28
- export type FieldValidationMode = "default" | "simple";
29
+ export declare const FIELD_VALIDATION_MODES: readonly ["default", "simple"];
30
+ export type FieldValidationMode = (typeof FIELD_VALIDATION_MODES)[number];
29
31
  /** Compiles a pattern source, preferring Unicode mode (needed for `\p{L}`). */
30
32
  export declare function compilePattern(source: string): RegExp | null;
31
33
  /**
@@ -229,18 +231,27 @@ export declare function identifierLabel(kinds: readonly IdentifierKind[]): strin
229
231
  * `<pont2-identifier-field>`: the sign-in identifier (email, phone or
230
232
  * username), submitted as `login_id` (the platform's contract).
231
233
  *
232
- * `identifiers` (attribute: space- or comma-separated; property: array) picks
234
+ * `identifiers` (attribute: a JSON array, as the platform writes it, or space- or
235
+ * comma-separated; property: array) picks
233
236
  * the label ("Email or phone") and the input type: `email` or `tel` when it
234
237
  * is exactly one of those, `text` otherwise. `autocomplete="username"`, which
235
238
  * is what password managers look for next to a password. Normalised to
236
239
  * trimmed lower case. Rule: `required` only (no format), as in the legacy kit.
237
240
  *
238
241
  * @tag pont2-identifier-field
239
- * @attr identifiers - e.g. "email phone username"
242
+ * @attr identifiers - e.g. `["email","phone"]` or "email phone username"
240
243
  */
241
244
  export declare class IdentifierField extends AuthField {
242
245
  static properties: PropertyDeclarations;
243
246
  identifiers: IdentifierKind[];
247
+ /** Design mode (core/design-mode.ts): sample identifiers when none are set. */
248
+ protected readonly design: DesignModeController;
249
+ /**
250
+ * The identifiers shown: `identifiers`, or email, username and phone in design mode when none are
251
+ * set. At serve time the platform narrows the authored list to the app's login methods; the
252
+ * designer narrows nothing, and "Identifier" would tell the author nothing (the legacy samples).
253
+ */
254
+ get shownIdentifiers(): IdentifierKind[];
244
255
  constructor();
245
256
  protected defaultName(): string;
246
257
  protected defaultLabel(): string;
@@ -15,7 +15,8 @@ export type PasswordRule = {
15
15
  /** The legacy named patterns (field.defs.ts). */
16
16
  export declare const PASSWORD_RULE_PATTERNS: Record<PasswordRuleName, RegExp>;
17
17
  export declare const DEFAULT_PASSWORD_RULES: PasswordRule[];
18
- export type SecretFieldVariant = "toggle" | "simple";
18
+ export declare const SECRET_FIELD_VARIANTS: readonly ["toggle", "simple"];
19
+ export type SecretFieldVariant = (typeof SECRET_FIELD_VARIANTS)[number];
19
20
  /**
20
21
  * A field whose value is secret: `type="password"`, and with
21
22
  * `variant="toggle"` (default) a show/hide button, built as shadcn builds it,
@@ -1,7 +1,9 @@
1
1
  import { PropertyDeclarations } from 'lit';
2
+ import { DesignModeController } from '../../core/design-mode';
2
3
  import { HostElement } from '../../core/host-element';
3
4
  /** The legacy render-spec values. */
4
- export type ContainerType = "flex_column" | "flex_row";
5
+ export declare const CONTAINER_TYPES: readonly ["flex_column", "flex_row"];
6
+ export type ContainerType = (typeof CONTAINER_TYPES)[number];
5
7
  export type ContainerAlign = "stretch" | "start" | "center" | "end";
6
8
  export type ContainerJustify = "start" | "center" | "end" | "between";
7
9
  /**
@@ -30,6 +32,8 @@ export declare class Container extends HostElement {
30
32
  type: ContainerType;
31
33
  align: ContainerAlign;
32
34
  justify: ContainerJustify;
35
+ /** Design mode (core/design-mode.ts): outlined and inset on the designer's canvas. */
36
+ protected readonly design: DesignModeController;
33
37
  constructor();
34
38
  protected willUpdate(): void;
35
39
  }
@@ -1,6 +1,7 @@
1
1
  import { PropertyDeclarations, PropertyValues } from 'lit';
2
2
  import { HostElement } from '../../core/host-element';
3
- export type GapType = "vertical" | "horizontal";
3
+ export declare const GAP_TYPES: readonly ["vertical", "horizontal"];
4
+ export type GapType = (typeof GAP_TYPES)[number];
4
5
  /**
5
6
  * # `<pont2-gap>`: a fixed spacer
6
7
  *
@@ -1,6 +1,7 @@
1
1
  import { PropertyDeclarations } from 'lit';
2
2
  import { HostElement } from '../../core/host-element';
3
- export type HeaderAlign = "start" | "center" | "end";
3
+ export declare const HEADER_ALIGNS: readonly ["start", "center", "end"];
4
+ export type HeaderAlign = (typeof HEADER_ALIGNS)[number];
4
5
  /**
5
6
  * # `<pont2-header>`: the screen's heading group (logo, title, subtitle)
6
7
  *
@@ -83,18 +83,39 @@ export declare class Layout extends HostElement {
83
83
  client: FlowClient | undefined;
84
84
  renderSpec: string;
85
85
  branding: BrandingEntitlements;
86
+ /**
87
+ * The screen is on the designer's canvas: elements render representative examples of themselves
88
+ * instead of their empty state (core/design-mode.ts). The dashboard's widget builder sets it.
89
+ */
90
+ designMode: boolean;
86
91
  messages: Partial<Record<string, string>>;
87
92
  protected busy: boolean;
88
93
  private provider;
94
+ private designProvider;
89
95
  private pending;
90
96
  constructor();
91
97
  /** The layout's form (holds the screen). */
92
98
  get form(): HTMLFormElement | null;
93
99
  /** Runs one flow request (what a `pont2-action` from inside triggers). */
94
100
  run(event: string, data?: Record<string, unknown>): Promise<FlowEventResponse>;
101
+ /** The elements `lockScreen` disabled, to give back exactly those. */
102
+ private locked;
103
+ /**
104
+ * While a request runs, the screen's fields and its other buttons are disabled, as in the legacy
105
+ * kit: nothing can be edited or pressed mid-request (migration tracker F-20, F-35). The button
106
+ * that asked stays busy, focusably (it is not disabled). Elements already disabled are left
107
+ * alone and stay disabled afterwards. The values were read before the request started, so
108
+ * disabling the fields doesn't change what was sent.
109
+ */
110
+ private lockScreen;
111
+ private unlockScreen;
95
112
  private onAction;
96
113
  private onError;
97
- /** Shows a flow error at the top of the screen (after its logo/header). */
114
+ /**
115
+ * Shows a flow error at the top of the screen (after its logo/header). It replaces any error
116
+ * already there, the server's injected banner included (`pont2-alert[status="error"]`), so the
117
+ * screen holds one error at a time, as in the legacy kit (migration tracker F-21).
118
+ */
98
119
  showError(message: string, restartable?: boolean): void;
99
120
  private clearBanner;
100
121
  protected willUpdate(changed: PropertyValues): void;
@@ -1,7 +1,10 @@
1
1
  import { nothing, PropertyDeclarations, PropertyValues } from 'lit';
2
2
  import { ActionController } from '../../core/controllers/action';
3
3
  import { HostElement } from '../../core/host-element';
4
- export type LinkAlign = "start" | "center" | "end";
4
+ export declare const LINK_ALIGNS: readonly ["start", "center", "end"];
5
+ export type LinkAlign = (typeof LINK_ALIGNS)[number];
6
+ export declare const LINK_SERVICES: readonly ["auth", "other"];
7
+ export type LinkService = (typeof LINK_SERVICES)[number];
5
8
  /**
6
9
  * # `<pont2-link>`: "Don't have an account? Sign up"
7
10
  *
@@ -45,7 +48,7 @@ export declare class Link extends HostElement {
45
48
  label: string;
46
49
  prompt: string;
47
50
  event: string | undefined;
48
- service: "auth" | "other";
51
+ service: LinkService;
49
52
  href: string | undefined;
50
53
  target: string | undefined;
51
54
  rel: string | undefined;
@@ -1,6 +1,8 @@
1
1
  import { nothing, PropertyDeclarations } from 'lit';
2
+ import { DesignModeController } from '../../core/design-mode';
2
3
  import { HostElement } from '../../core/host-element';
3
- export type LogoAlign = "start" | "center" | "end";
4
+ export declare const LOGO_ALIGNS: readonly ["start", "center", "end"];
5
+ export type LogoAlign = (typeof LOGO_ALIGNS)[number];
4
6
  /**
5
7
  * A logo source as an `<img src>`: URLs and `data:` URIs pass through; a bare
6
8
  * base64 string is treated as an SVG (the legacy `resolveIconSource` rule).
@@ -46,6 +48,8 @@ export declare class Logo extends HostElement {
46
48
  align: LogoAlign;
47
49
  width: string;
48
50
  height: string;
51
+ /** Design mode (core/design-mode.ts): a placeholder mark when no image is set. */
52
+ protected readonly design: DesignModeController;
49
53
  constructor();
50
54
  protected willUpdate(): void;
51
55
  render(): import('lit-html').TemplateResult<1> | typeof nothing;
@@ -4,7 +4,8 @@ import { InputOTP } from '../../primitives/input-otp/input-otp';
4
4
  import { InputOptions } from '../../primitives/input/input';
5
5
  import { AuthField, FieldIssue } from '../auth-field/auth-field';
6
6
  /** The legacy `pont-otp` layouts, kept for render-spec parity. */
7
- export type OtpLayout = "digits_only" | "simple" | "with_separator" | "with_spacing";
7
+ export declare const OTP_LAYOUTS: readonly ["digits_only", "simple", "with_separator", "with_spacing"];
8
+ export type OtpLayout = (typeof OTP_LAYOUTS)[number];
8
9
  /**
9
10
  * # `<pont2-otp-field>`: a verification-code field
10
11
  *
@@ -1,4 +1,5 @@
1
1
  import { PropertyDeclarations, PropertyValues } from 'lit';
2
+ import { DesignModeController } from '../../core/design-mode';
2
3
  import { ButtonSize, ButtonVariant } from '../../primitives/button/button';
3
4
  import { Field } from '../../primitives/field/field';
4
5
  import { AuthButtonContent, AuthButtonIconAlign } from '../auth-button/auth-button';
@@ -27,6 +28,7 @@ export declare const providerEvent: (p: AuthProvider) => string;
27
28
  *
28
29
  * ```html
29
30
  * <pont2-provider-field providers="apple google meta"></pont2-provider-field>
31
+ * <pont2-provider-field providers='["google","github"]'></pont2-provider-field> (the form the platform injects)
30
32
  * ```
31
33
  *
32
34
  * **Is a Field** (`extends Field`), as in shadcn's login blocks (`<Field
@@ -73,7 +75,14 @@ export declare class ProviderField extends Field {
73
75
  label: string | undefined;
74
76
  loading: boolean;
75
77
  constructor();
76
- /** The providers actually rendered: known names, first occurrence only. */
78
+ /** Design mode (core/design-mode.ts): sample providers when none are set. */
79
+ protected readonly design: DesignModeController;
80
+ /**
81
+ * The providers actually rendered: known names, first occurrence only. In design mode with none
82
+ * set, three samples (google, apple, github): at serve time the platform injects the app's
83
+ * providers, and three is where the grid switches to icon-only buttons, the arrangement most
84
+ * real screens end up with (the legacy samples).
85
+ */
77
86
  get list(): AuthProvider[];
78
87
  /** The rendered `<pont2-provider-button>` elements. */
79
88
  get buttons(): HTMLElementTagNameMap["pont2-provider-button"][];
@@ -1,6 +1,7 @@
1
1
  import { nothing, PropertyDeclarations, PropertyValues } from 'lit';
2
2
  import { HostElement } from '../../core/host-element';
3
- export type QrErrorCorrection = "L" | "M" | "Q" | "H";
3
+ export declare const QR_ERROR_CORRECTIONS: readonly ["L", "M", "Q", "H"];
4
+ export type QrErrorCorrection = (typeof QR_ERROR_CORRECTIONS)[number];
4
5
  /**
5
6
  * One SVG path covering every dark module of `text`'s QR code, plus the
6
7
  * code's size. `null` when the text cannot be encoded.
@@ -1,7 +1,9 @@
1
1
  import { PropertyDeclarations, TemplateResult } from 'lit';
2
2
  import { HostElement } from '../../core/host-element';
3
- export type WatermarkVariant = "brand" | "theme" | "muted";
4
- export type WatermarkLogoAlign = "start" | "end";
3
+ export declare const WATERMARK_VARIANTS: readonly ["brand", "theme", "muted"];
4
+ export type WatermarkVariant = (typeof WATERMARK_VARIANTS)[number];
5
+ export declare const WATERMARK_LOGO_ALIGNS: readonly ["start", "end"];
6
+ export type WatermarkLogoAlign = (typeof WATERMARK_LOGO_ALIGNS)[number];
5
7
  /** The watermark's content (label + logo), shared with the block's footer. */
6
8
  export declare function watermarkContent(label: string, logoAlign: WatermarkLogoAlign): TemplateResult;
7
9
  /**
@@ -0,0 +1,29 @@
1
+ export interface CatalogAttribute {
2
+ key: string;
3
+ label?: string;
4
+ type: string;
5
+ description?: string;
6
+ default?: unknown;
7
+ options?: string[];
8
+ required?: boolean;
9
+ }
10
+ export interface CatalogElement {
11
+ tag: string;
12
+ label?: string;
13
+ description?: string;
14
+ category?: string;
15
+ container?: boolean;
16
+ is_field?: boolean;
17
+ is_trigger?: boolean;
18
+ requires_condition?: string | null;
19
+ attributes: CatalogAttribute[];
20
+ insertion_presets?: Record<string, unknown>;
21
+ }
22
+ export declare const pont2TagFor: (legacy: string) => string | null;
23
+ export interface BuiltCatalog {
24
+ elements: CatalogElement[];
25
+ /** What couldn't be derived: each one is a decision to make, not to guess. */
26
+ problems: string[];
27
+ }
28
+ /** Derives pont2's catalog entries from the legacy ones and the live elements. */
29
+ export declare function buildPont2Catalog(legacy: CatalogElement[]): BuiltCatalog;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * # Legacy markup → pont2 markup: the reference implementation of vocabulary.md
3
+ *
4
+ * `toPont2Markup(legacy)` applies docs/migration/vocabulary.md §2 and §3 to one
5
+ * stored widget's markup. It is **not part of the kit** (not exported from the
6
+ * package). It exists to:
7
+ *
8
+ * - prove S1's exit criterion: every built-in screen, rewritten, renders in
9
+ * `pont2-layout` and keeps its contract (the story `Migration/Built-in screens`);
10
+ * - be the golden reference for the S6 migration in branding-svc (M-2), whose
11
+ * Go implementation must produce the same output for the same input.
12
+ *
13
+ * It uses the browser's HTML parser (a `<template>`), so it runs where the
14
+ * stories run. Placeholders (`{{email}}`) and platform directives (`pont-id`,
15
+ * `requires-condition`, `data-pont-widget`) pass through untouched (§1 rule 3).
16
+ *
17
+ * `legacyContract` / `pont2Contract` read the form keys and events a screen
18
+ * submits, from each vocabulary's own rules, so a rewrite can be checked to
19
+ * keep them (the branding-svc gate does the same comparison at S6).
20
+ */
21
+ /** Rewrites one stored widget's markup into the pont2 vocabulary. */
22
+ export declare function toPont2Markup(legacy: string): string;
23
+ export interface Contract {
24
+ /** Form-data keys, sorted. */
25
+ keys: string[];
26
+ /** Events the screen can fire, sorted. */
27
+ events: string[];
28
+ }
29
+ /** The keys and events a legacy screen submits, by the legacy catalog's rules. */
30
+ export declare function legacyContract(legacy: string): Contract;
31
+ /**
32
+ * The keys and events a **rendered** pont2 screen submits, read from the upgraded
33
+ * elements themselves (their effective `fieldName` and `event`), not from the
34
+ * markup: this is what the browser would send.
35
+ */
36
+ export declare function pont2Contract(root: ParentNode): Contract;
@@ -6184,6 +6184,34 @@ layer(pont2.tokens);
6184
6184
  [data-pont2-container][data-justify="between"] {
6185
6185
  justify-content: space-between;
6186
6186
  }
6187
+
6188
+ /*
6189
+ * Design mode (the designer's canvas only; core/design-mode.ts). An outline takes no space, so
6190
+ * showing the container doesn't reflow what the author is arranging. The inset does reflow, on
6191
+ * purpose: without it a nested container's outline lands on its parent's and the parent has no
6192
+ * surface left to click or drop onto. Served screens never get these attributes.
6193
+ */
6194
+ [data-pont2-container][data-design] {
6195
+ outline: 1px dotted color-mix(in oklab, var(--pont2-sem-color-foreground) 35%, transparent);
6196
+ outline-offset: -1px;
6197
+ padding: 0.5rem;
6198
+ }
6199
+ [data-pont2-container][data-design-empty] {
6200
+ position: relative;
6201
+ min-height: 3.5rem;
6202
+ }
6203
+ /* Generated content: never part of the authored tree, never a drop target. */
6204
+ [data-pont2-container][data-design-empty]::after {
6205
+ content: "Container";
6206
+ position: absolute;
6207
+ inset: 0;
6208
+ display: flex;
6209
+ align-items: center;
6210
+ justify-content: center;
6211
+ color: var(--pont2-sem-color-muted-foreground);
6212
+ font-size: var(--pont2-sem-text-sm);
6213
+ pointer-events: none;
6214
+ }
6187
6215
  }
6188
6216
 
6189
6217
  /* ../kit/header/header.css */
@@ -1,10 +1,8 @@
1
1
  /* @pontive/pontkit-core pont2 — generated by pont2/scripts/build-css.mjs */
2
2
  /*
3
- * Load the legacy pontkit stylesheet and pont2 together.
4
- * The legacy file (Tailwind 3, unlayered preflight) is imported INTO the
5
- * lowest layer, so its element resets can no longer override pont2's layered
6
- * recipes. Declared order: pont-legacy < pont2.* < your unlayered CSS.
3
+ * Kept for pages that imported it: the package's main stylesheet,
4
+ * dist/styles.css, now carries both kits itself (the legacy stylesheet in the
5
+ * lowest layer, pont-legacy, then pont2's layers; scripts/build-superset-css.mjs,
6
+ * migration plan decision D4). Importing it is all this file does.
7
7
  */
8
- @layer pont-legacy, pont2.reset, pont2.tokens, pont2.base, pont2.primitives, pont2.kit, pont2.theme.preset, pont2.theme.brand;
9
- @import url("../styles.css") layer(pont-legacy);
10
- @import url("./styles.css");
8
+ @import url("../styles.css");