@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.
Files changed (93) hide show
  1. package/catalog.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/pont2/core/attrs.d.ts +22 -0
  4. package/dist/pont2/core/controllers/action.d.ts +79 -0
  5. package/dist/pont2/core/controllers/copy.d.ts +34 -0
  6. package/dist/pont2/core/controllers/roving-focus.d.ts +38 -0
  7. package/dist/pont2/core/events.d.ts +28 -0
  8. package/dist/pont2/core/form-control.d.ts +70 -0
  9. package/dist/pont2/core/host-element.d.ts +129 -0
  10. package/dist/pont2/core/icons.d.ts +28 -0
  11. package/dist/pont2/core/ids.d.ts +6 -0
  12. package/dist/pont2/core/index.d.ts +10 -0
  13. package/dist/pont2/core/names.d.ts +78 -0
  14. package/dist/pont2/core/popup/anchored.d.ts +48 -0
  15. package/dist/pont2/core/popup/index.d.ts +5 -0
  16. package/dist/pont2/core/popup/list.d.ts +38 -0
  17. package/dist/pont2/core/popup/popup-content.d.ts +68 -0
  18. package/dist/pont2/core/popup/popup-root.d.ts +94 -0
  19. package/dist/pont2/core/popup/position.d.ts +73 -0
  20. package/dist/pont2/globals.css +109 -0
  21. package/dist/pont2/index.d.ts +44 -0
  22. package/dist/pont2/index.mjs +5660 -0
  23. package/dist/pont2/index.mjs.map +1 -0
  24. package/dist/pont2/kit/alert/alert.d.ts +62 -0
  25. package/dist/pont2/kit/aliases.d.ts +33 -0
  26. package/dist/pont2/kit/auth-button/auth-button.d.ts +185 -0
  27. package/dist/pont2/kit/auth-button/providers.d.ts +15 -0
  28. package/dist/pont2/kit/auth-field/auth-field.d.ts +267 -0
  29. package/dist/pont2/kit/auth-field/password-field.d.ts +124 -0
  30. package/dist/pont2/kit/avatar/avatar.d.ts +52 -0
  31. package/dist/pont2/kit/block/block.d.ts +64 -0
  32. package/dist/pont2/kit/block/branding.d.ts +36 -0
  33. package/dist/pont2/kit/container/container.d.ts +40 -0
  34. package/dist/pont2/kit/countdown/countdown.d.ts +64 -0
  35. package/dist/pont2/kit/divider/divider.d.ts +30 -0
  36. package/dist/pont2/kit/edit-identifier/edit-identifier.d.ts +47 -0
  37. package/dist/pont2/kit/flow-widget/flow-widget.d.ts +151 -0
  38. package/dist/pont2/kit/gap/gap.d.ts +36 -0
  39. package/dist/pont2/kit/header/header.d.ts +37 -0
  40. package/dist/pont2/kit/index.d.ts +26 -0
  41. package/dist/pont2/kit/input-otp/input-otp.d.ts +59 -0
  42. package/dist/pont2/kit/layout/flow-error.d.ts +21 -0
  43. package/dist/pont2/kit/layout/layout.d.ts +120 -0
  44. package/dist/pont2/kit/link/link.d.ts +62 -0
  45. package/dist/pont2/kit/logo/logo.d.ts +57 -0
  46. package/dist/pont2/kit/otp-field/otp-field.d.ts +93 -0
  47. package/dist/pont2/kit/otp-field/otp-resend.d.ts +61 -0
  48. package/dist/pont2/kit/provider-field/provider-field.d.ts +87 -0
  49. package/dist/pont2/kit/qr-code/qr-code.d.ts +86 -0
  50. package/dist/pont2/kit/recovery-codes/recovery-codes.d.ts +64 -0
  51. package/dist/pont2/kit/scope-list/scope-list.d.ts +69 -0
  52. package/dist/pont2/kit/scope-list/scope-value.d.ts +16 -0
  53. package/dist/pont2/kit/secret/secret.d.ts +67 -0
  54. package/dist/pont2/kit/story-helpers.d.ts +9 -0
  55. package/dist/pont2/kit/typography/typography.d.ts +70 -0
  56. package/dist/pont2/kit/watermark/pontive-logo.d.ts +8 -0
  57. package/dist/pont2/kit/watermark/watermark.d.ts +42 -0
  58. package/dist/pont2/primitives/alert/alert.d.ts +49 -0
  59. package/dist/pont2/primitives/avatar/avatar.d.ts +89 -0
  60. package/dist/pont2/primitives/badge/badge.d.ts +30 -0
  61. package/dist/pont2/primitives/button/button.d.ts +113 -0
  62. package/dist/pont2/primitives/button-group/button-group.d.ts +55 -0
  63. package/dist/pont2/primitives/card/card.d.ts +63 -0
  64. package/dist/pont2/primitives/checkbox/checkbox.d.ts +54 -0
  65. package/dist/pont2/primitives/combobox/combobox.d.ts +213 -0
  66. package/dist/pont2/primitives/dropdown-menu/dropdown-menu.d.ts +267 -0
  67. package/dist/pont2/primitives/empty/empty.d.ts +60 -0
  68. package/dist/pont2/primitives/field/field.d.ts +146 -0
  69. package/dist/pont2/primitives/input/input.d.ts +47 -0
  70. package/dist/pont2/primitives/input-group/input-group.d.ts +97 -0
  71. package/dist/pont2/primitives/input-otp/input-otp.d.ts +121 -0
  72. package/dist/pont2/primitives/input-otp/otp.d.ts +22 -0
  73. package/dist/pont2/primitives/item/item.d.ts +100 -0
  74. package/dist/pont2/primitives/kbd/kbd.d.ts +29 -0
  75. package/dist/pont2/primitives/label/label.d.ts +37 -0
  76. package/dist/pont2/primitives/native-select/native-select.d.ts +59 -0
  77. package/dist/pont2/primitives/popover/popover.d.ts +85 -0
  78. package/dist/pont2/primitives/progress/progress.d.ts +80 -0
  79. package/dist/pont2/primitives/radio-group/radio-group.d.ts +93 -0
  80. package/dist/pont2/primitives/select/select.d.ts +184 -0
  81. package/dist/pont2/primitives/separator/separator.d.ts +34 -0
  82. package/dist/pont2/primitives/skeleton/skeleton.d.ts +18 -0
  83. package/dist/pont2/primitives/slider/slider-math.d.ts +42 -0
  84. package/dist/pont2/primitives/slider/slider.d.ts +85 -0
  85. package/dist/pont2/primitives/spinner/spinner.d.ts +29 -0
  86. package/dist/pont2/primitives/switch/switch.d.ts +55 -0
  87. package/dist/pont2/primitives/table/table.d.ts +55 -0
  88. package/dist/pont2/primitives/tabs/tabs.d.ts +126 -0
  89. package/dist/pont2/primitives/textarea/textarea.d.ts +41 -0
  90. package/dist/pont2/primitives/tooltip/tooltip.d.ts +69 -0
  91. package/dist/pont2/styles.css +4839 -0
  92. package/dist/pont2/with-legacy.css +10 -0
  93. package/package.json +16 -4
@@ -0,0 +1,22 @@
1
+ import { Directive, ElementPart, PartInfo } from 'lit/directive.js';
2
+ export type AttrValue = string | number | boolean | null | undefined;
3
+ export type AttrMap = Record<string, AttrValue>;
4
+ /**
5
+ * `<button ${attrs({ "data-provider": "google", "aria-busy": loading })}>`
6
+ *
7
+ * Lit has no attribute spread; part functions need one. It plays the role of
8
+ * `{...props}` in a shadcn component: a composing component can put extra
9
+ * attributes on the *same* element a part renders, so it never has to wrap
10
+ * that element. `true` → empty attribute; `false`/`null`/`undefined` → removed;
11
+ * keys dropped since the previous render are removed.
12
+ */
13
+ declare class AttrsDirective extends Directive {
14
+ private prev;
15
+ constructor(info: PartInfo);
16
+ render(_attrs: AttrMap): symbol;
17
+ update(part: ElementPart, [map]: [AttrMap]): symbol;
18
+ }
19
+ export declare const attrs: (_attrs: AttrMap) => import('lit-html/directive.js').DirectiveResult<typeof AttrsDirective>;
20
+ /** Imperative twin of `attrs()`, for code that holds a node rather than a template. */
21
+ export declare function applyAttrs(el: Element, map: AttrMap, previous?: Iterable<string>): void;
22
+ export {};
@@ -0,0 +1,79 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ /**
3
+ * # The action protocol: `pont2-action` + `respondWith()`
4
+ *
5
+ * Some elements start asynchronous work they must not own: a sign-in button
6
+ * starts a login-flow step, but the network call, the session and the next
7
+ * screen belong to whatever hosts the flow (a widget, a layout, the app).
8
+ * The element asks; an ancestor answers.
9
+ *
10
+ * ```
11
+ * element ── pont2-action { action, data, respondWith } ──▶ ancestor (bubbles, composed)
12
+ * ancestor calls detail.respondWith(promise)
13
+ * element: busy until the promise settles
14
+ * element ── pont2-action-success { action, data, result } ──▶
15
+ * or pont2-action-error { action, data, error, message } ──▶
16
+ * ```
17
+ *
18
+ * `respondWith()` must be called **synchronously, inside the listener** (as in
19
+ * a service worker's `FetchEvent`). That is deliberate: the dispatch happens
20
+ * inside the user's click, so work started in the listener still has the
21
+ * click's *transient user activation*, which WebAuthn (passkeys) and
22
+ * `window.open` (OAuth popups) require. Starting the work after an `await`
23
+ * would lose it.
24
+ *
25
+ * ```ts
26
+ * widget.addEventListener("pont2-action", e => {
27
+ * if (e.detail.action) e.detail.respondWith(Auth.processLoginflowEvent({ event: e.detail.action }));
28
+ * });
29
+ * ```
30
+ *
31
+ * Nobody responding is valid: the request event doubles as a click
32
+ * notification (the legacy kit's `<tag>:click`), and an element may then fall
33
+ * back to native behaviour (a submit button lets its form submit).
34
+ *
35
+ * Why an event and not an import: pont2 depends on no auth client, any
36
+ * framework can answer a DOM event, Storybook and tests answer with a fake,
37
+ * and the element never needs to know who is listening (docs/kit/auth-button.md).
38
+ */
39
+ export interface ActionRequestDetail<D = Record<string, unknown>> {
40
+ /** What to do, e.g. a login-flow event id. May be absent (a plain click notification). */
41
+ action: string | undefined;
42
+ /** Context from the element (the provider, the form data…). */
43
+ data: D;
44
+ /** Hand the element the work's promise. Only valid during dispatch, at most once. */
45
+ respondWith(response: unknown): void;
46
+ }
47
+ export interface ActionSuccessDetail<D = Record<string, unknown>> {
48
+ action: string | undefined;
49
+ data: D;
50
+ result: unknown;
51
+ }
52
+ export interface ActionErrorDetail<D = Record<string, unknown>> {
53
+ action: string | undefined;
54
+ data: D;
55
+ error: unknown;
56
+ message: string;
57
+ }
58
+ export declare class ActionController implements ReactiveController {
59
+ private host;
60
+ /** True while a response is pending. The host re-renders when it changes. */
61
+ busy: boolean;
62
+ constructor(host: ReactiveControllerHost & HTMLElement);
63
+ hostConnected(): void;
64
+ /**
65
+ * Fires `pont2-action` from the host. Returns `true` if a listener called
66
+ * `respondWith()` (the element is now busy), `false` otherwise or when
67
+ * already busy (one request at a time).
68
+ */
69
+ request<D extends Record<string, unknown>>(action: string | undefined, data: D): boolean;
70
+ private track;
71
+ private setBusy;
72
+ }
73
+ declare global {
74
+ interface HTMLElementEventMap {
75
+ "pont2-action": CustomEvent<ActionRequestDetail>;
76
+ "pont2-action-success": CustomEvent<ActionSuccessDetail>;
77
+ "pont2-action-error": CustomEvent<ActionErrorDetail>;
78
+ }
79
+ }
@@ -0,0 +1,34 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ export interface CopiedDetail {
3
+ /** What was copied, e.g. "secret", "recovery-codes". Never the copied text. */
4
+ kind: string;
5
+ }
6
+ export interface CopyErrorDetail {
7
+ kind: string;
8
+ error: unknown;
9
+ }
10
+ /**
11
+ * Copy-to-clipboard with transient "copied" feedback.
12
+ *
13
+ * `copy(text)` writes to the clipboard, sets `copied` for `duration` ms (the
14
+ * host re-renders), and fires `pont2-copied` / `pont2-copy-error`. The events
15
+ * deliberately carry no text: what gets copied here is secret (TOTP secrets,
16
+ * recovery codes), and events are observable by any script on the page.
17
+ */
18
+ export declare class CopyController implements ReactiveController {
19
+ private host;
20
+ private kind;
21
+ private duration;
22
+ copied: boolean;
23
+ private timer;
24
+ constructor(host: ReactiveControllerHost & HTMLElement, kind: string, duration?: number);
25
+ hostConnected(): void;
26
+ hostDisconnected(): void;
27
+ copy(text: string): Promise<boolean>;
28
+ }
29
+ declare global {
30
+ interface HTMLElementEventMap {
31
+ "pont2-copied": CustomEvent<CopiedDetail>;
32
+ "pont2-copy-error": CustomEvent<CopyErrorDetail>;
33
+ }
34
+ }
@@ -0,0 +1,38 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ export type Orientation = "horizontal" | "vertical" | "both";
3
+ export interface RovingFocusOptions {
4
+ /** Candidate items, in DOM order. Called on every key press, so it may query live. */
5
+ items: () => HTMLElement[];
6
+ orientation?: () => Orientation;
7
+ /** Wrap from last to first (Base UI `loopFocus`, default true). */
8
+ loop?: () => boolean;
9
+ /** Items to skip. Default: `[data-disabled]` / `aria-disabled="true"` / `:disabled`. */
10
+ isDisabled?: (item: HTMLElement) => boolean;
11
+ /** Called after focus moves through the keyboard (radio/tabs use it to activate). */
12
+ onNavigate?: (item: HTMLElement, event: KeyboardEvent) => void;
13
+ }
14
+ /** `ltr` unless the nearest `[dir]` ancestor (or the document) says `rtl`. */
15
+ export declare function directionOf(el: Element): "ltr" | "rtl";
16
+ /**
17
+ * Roving tabindex (WAI-ARIA APG "managing focus within composites"): exactly
18
+ * one item is a tab stop (`tabindex="0"`), the rest are `-1`, and arrow keys,
19
+ * Home and End move focus between them. Used by RadioGroup, Tabs, ToggleGroup
20
+ * and menus, which is what Base UI's `CompositeRoot` does internally.
21
+ *
22
+ * The host calls `sync(active)` whenever the "current" item may have
23
+ * changed (selection, items added or removed).
24
+ */
25
+ export declare class RovingFocusController implements ReactiveController {
26
+ private readonly host;
27
+ private readonly opts;
28
+ constructor(host: ReactiveControllerHost & HTMLElement, options: RovingFocusOptions);
29
+ hostConnected(): void;
30
+ hostDisconnected(): void;
31
+ /** Make `active` (or the first enabled item) the single tab stop. */
32
+ sync(active?: HTMLElement | null): void;
33
+ /** Focus an item and make it the tab stop. */
34
+ focus(item: HTMLElement, options?: FocusOptions): void;
35
+ private onFocusIn;
36
+ private onKeyDown;
37
+ private findNext;
38
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Event conventions (docs/02-conventions.md, "Events"):
3
+ *
4
+ * - Value-holding widgets fire the platform's own `input` (while the value
5
+ * changes through interaction) and `change` (when it is committed), both
6
+ * bubbling, exactly like native controls. The new value is read from the
7
+ * target (`e.target.checked`, `e.target.value`), so `@change=${…}` in Lit,
8
+ * `onChange` via @lit/react and `addEventListener("change")` all work.
9
+ * - Anything without a native equivalent is a `pont2-<name>` CustomEvent with
10
+ * a typed `detail`, bubbling and composed. Base UI's `onOpenChange(open,
11
+ * details)` becomes `pont2-open-change` with `{ open, reason }`; it is
12
+ * cancelable, and `preventDefault()` keeps the current state (Base UI's
13
+ * `eventDetails.cancel()`).
14
+ * - Events fire only for user-initiated changes, never for property writes,
15
+ * matching native controls (and Base UI's controlled props).
16
+ */
17
+ export declare function fireNative(target: EventTarget, type: "input" | "change"): void;
18
+ export declare function fire<T>(target: EventTarget, type: `pont2-${string}`, detail: T, cancelable?: boolean): boolean;
19
+ export type OpenChangeReason = "trigger-press" | "trigger-hover" | "trigger-focus" | "outside-press" | "escape-key" | "item-press" | "list-navigation" | "input-change" | "focus-out" | "imperative";
20
+ export interface OpenChangeDetail {
21
+ open: boolean;
22
+ reason: OpenChangeReason;
23
+ }
24
+ declare global {
25
+ interface HTMLElementEventMap {
26
+ "pont2-open-change": CustomEvent<OpenChangeDetail>;
27
+ }
28
+ }
@@ -0,0 +1,70 @@
1
+ import { PropertyDeclarations, PropertyValues } from 'lit';
2
+ import { HostElement } from './host-element';
3
+ export interface ValidityResult {
4
+ flags: ValidityStateFlags;
5
+ message: string;
6
+ }
7
+ /**
8
+ * # FormControlElement: Tier 2 form-associated widget
9
+ *
10
+ * The base for widgets whose host is an ARIA widget root *and* a form control
11
+ * (Checkbox, Switch, RadioGroup, Slider, Select, Combobox, InputOTP …). It is
12
+ * a **form-associated custom element** (FACE), so with no hidden `<input>`:
13
+ *
14
+ * - it submits `name=value` with its `<form>` (`internals.setFormValue`);
15
+ * - it takes part in constraint validation (`setValidity`, `:invalid`,
16
+ * `checkValidity()`, `reportValidity()`, blocking submit when `required`);
17
+ * - it is disabled by `disabled`, by an ancestor `<fieldset disabled>` and by
18
+ * its form, through `formDisabledCallback`;
19
+ * - it resets with its form (`formResetCallback`) and restores on
20
+ * back/forward navigation (`formStateRestoreCallback`);
21
+ * - it is labelable: `<label for>` and wrapping labels work, and `labels`
22
+ * lists them;
23
+ * - the `form="id"` content attribute works natively.
24
+ *
25
+ * Base UI renders a visually hidden `<input>` next to each such widget to get
26
+ * the same effect in React. A FACE makes that node unnecessary, which is
27
+ * one node fewer than shadcn/Base UI.
28
+ *
29
+ * Subclasses implement `formValue()`, `resetToDefault()` and optionally
30
+ * `validate()`; the base syncs internals/data attributes after every update.
31
+ */
32
+ export declare abstract class FormControlElement extends HostElement {
33
+ static formAssociated: boolean;
34
+ static properties: PropertyDeclarations;
35
+ name: string;
36
+ disabled: boolean;
37
+ required: boolean;
38
+ readOnly: boolean;
39
+ /** Disabled by an ancestor `<fieldset disabled>` or the form. */
40
+ protected formDisabled: boolean;
41
+ private _customMessage;
42
+ constructor();
43
+ /** What the control submits. `null` submits nothing (an unchecked checkbox). */
44
+ protected abstract formValue(): string | File | FormData | null;
45
+ /** Restore the default value (the one in the markup). */
46
+ protected abstract resetToDefault(): void;
47
+ /** Built-in constraint check. Return `null` when valid. */
48
+ protected validate(): ValidityResult | null;
49
+ /** Whether the host itself is a tab stop. Composite widgets with an inner roving tab stop return false. */
50
+ protected get hostFocusable(): boolean;
51
+ /** Element `reportValidity()` should point at (must be inside the host). */
52
+ protected get validationAnchor(): HTMLElement | undefined;
53
+ get form(): HTMLFormElement | null;
54
+ get labels(): NodeList;
55
+ get validity(): ValidityState;
56
+ get validationMessage(): string;
57
+ get willValidate(): boolean;
58
+ /** `disabled` or disabled by a fieldset/form. */
59
+ get isDisabled(): boolean;
60
+ checkValidity(): boolean;
61
+ reportValidity(): boolean;
62
+ setCustomValidity(message: string): void;
63
+ formResetCallback(): void;
64
+ formDisabledCallback(disabled: boolean): void;
65
+ formStateRestoreCallback(state: string | File | FormData | null): void;
66
+ /** Override to restore from the value `formValue()` produced. */
67
+ protected restoreState(_state: string | File | FormData | null): void;
68
+ protected updated(changed: PropertyValues): void;
69
+ protected syncValidity(): void;
70
+ }
@@ -0,0 +1,129 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import { DirectiveResult } from 'lit/directive.js';
3
+ import { AttrMap } from './attrs';
4
+ /**
5
+ * # HostElement: the host is the component's root element
6
+ *
7
+ * The base class of every pont2 element. A shadcn component is a function
8
+ * that returns its root element and then disappears. A custom element cannot
9
+ * disappear, so in pont2 **the host *is* the root**: `<pont2-prim-separator>` is the
10
+ * separator, it does not render one.
11
+ *
12
+ * What a subclass gets:
13
+ *
14
+ * | Static / member | Does |
15
+ * |---------------------|----------------------------------------------------------------------|
16
+ * | `static identity` | Stamps `data-pont2-<identity>`. Every class in the chain adds its own, so a subclass keeps its base's styles (`pont2-prim-item-separator` carries `data-pont2-separator` *and* `data-pont2-item-separator`). |
17
+ * | `static slotName` | Stamps `data-slot` (shadcn's convention). Most-derived class wins. An author-written `data-slot` is never overwritten. |
18
+ * | `static role` | Default ARIA role through `ElementInternals`. An author's `role=""` attribute still wins. |
19
+ * | `internals` | `ElementInternals`: default ARIA, custom states, forms (see FormControlElement). |
20
+ * | `setData()` | Writes component-owned `data-*` state on the host (Base UI's presence-style attributes). |
21
+ * | `setState()` | Adds/removes a CustomStateSet entry, matchable as `:state(x)`. |
22
+ * | `static part()` | The same identity, slot and role as attributes, for a composite to put on a plain element (see below). |
23
+ * | `static composite` | Marks a kit composite: it renders its whole subtree from properties (docs/10-primitives-and-kit.md). |
24
+ *
25
+ * Light DOM throughout: `createRenderRoot()` returns `this`. Most Tier 1
26
+ * elements never override `render()`; their children are whatever the author
27
+ * wrote, left exactly where the author wrote them.
28
+ */
29
+ export declare abstract class HostElement extends LitElement {
30
+ /** Style identity → `data-pont2-<identity>`. Inherited along the class chain. */
31
+ static identity?: string;
32
+ /** shadcn `data-slot` value. Most-derived wins; never overrides the author. */
33
+ static slotName?: string;
34
+ /** Default ARIA role, set through ElementInternals (author attribute wins). */
35
+ static role?: string;
36
+ /**
37
+ * `true` on kit composites (`src/kit/`): the element renders its entire
38
+ * subtree from properties, so author-written children are a mistake (use the
39
+ * `pont2-prim-*` form for custom content). Reported once in development.
40
+ */
41
+ static composite: boolean;
42
+ /**
43
+ * A **part**: this element's identity, `data-slot` and default role as plain
44
+ * attributes, for a template to put on a native element.
45
+ *
46
+ * ```ts
47
+ * html`<div ${AlertTitle.part()}>${this.heading}</div>`
48
+ * // → <div data-pont2-alert-title data-slot="alert-title">…</div>
49
+ * ```
50
+ *
51
+ * The result is styled by the element's recipe and found by `sel()` lookups,
52
+ * exactly like the element itself, so a composite reproduces shadcn's DOM
53
+ * without nesting custom elements. A part carries **attributes only**: use
54
+ * it for Tier 1 elements whose host adds nothing but identity, slot and role.
55
+ * An element with behaviour (state, observers, keyboard, form association)
56
+ * has to be rendered as the element. `extra` adds or overrides attributes.
57
+ */
58
+ static part(extra?: AttrMap): DirectiveResult;
59
+ protected readonly internals: ElementInternals;
60
+ protected createRenderRoot(): HTMLElement;
61
+ /**
62
+ * Elements that do not override `render()` (most Tier 1 hosts) skip Lit's
63
+ * template rendering entirely. Otherwise lit-html would append a `<!---->`
64
+ * part marker to the author's children: a stray node in a component whose
65
+ * whole point is to add none, and one more node for React to step around.
66
+ */
67
+ protected update(changed: PropertyValues): void;
68
+ connectedCallback(): void;
69
+ /**
70
+ * Sets `data-<name>`: a string value, `true` → empty (presence) attribute,
71
+ * `false`/`null`/`undefined` → removed. Base UI exposes state as presence
72
+ * attributes (`data-checked`, `data-disabled`, `data-open`), which is what
73
+ * shadcn's Base UI styles select on, so `true`/`false` is the common call.
74
+ */
75
+ protected setData(name: string, value: string | boolean | null | undefined): void;
76
+ /** Adds or removes a custom state, matchable in CSS as `:state(<name>)`. */
77
+ protected setState(name: string, on: boolean): void;
78
+ }
79
+ /** Every `identity` declared along the prototype chain, most-derived first. */
80
+ export declare function identitiesOf(ctor: typeof HostElement): string[];
81
+ /**
82
+ * # ShellElement: Tier 3 (native-bound) host
83
+ *
84
+ * Some shadcn roots must stay *native* elements: `<button>`, `<a>`, `<input>`,
85
+ * `<textarea>`, `<label>`, `<select>`, `<table>`, `<fieldset>`. Their behaviour
86
+ * (implicit form submission, `SubmitEvent.submitter`, autofill, password
87
+ * managers, real links, `for=` labelling, table parsing) cannot be emulated
88
+ * faithfully by a custom element.
89
+ *
90
+ * For those, the host is a **transparent shell**: `display: contents`
91
+ * (`[data-pont2-shell]` in styles/base.css), no role, no styles, no box. It
92
+ * exists only so HTML authors have a tag. Everything styled or announced lives
93
+ * on the one native element inside it. Two nodes is the platform floor for
94
+ * native semantics, and composition never adds a third.
95
+ *
96
+ * Never style a shell, give it a role, or anchor positioning to it. Use
97
+ * `control` (the native element) instead.
98
+ */
99
+ export declare abstract class ShellElement extends HostElement {
100
+ static identity: string;
101
+ /** The single native element this shell stands for. */
102
+ abstract get control(): HTMLElement | null;
103
+ focus(options?: FocusOptions): void;
104
+ blur(): void;
105
+ }
106
+ /**
107
+ * # NativeEnhancer: Tier 3 element form ("asChild")
108
+ *
109
+ * `<pont2-prim-button variant="outline"><button>Save</button></pont2-prim-button>`
110
+ *
111
+ * The author writes the native element; the shell applies the recipe to it
112
+ * (attributes only). The native node is never moved, wrapped or re-created,
113
+ * so React, a parent Lit template or server HTML keep owning it. A
114
+ * MutationObserver re-applies the recipe if the child is swapped.
115
+ *
116
+ * This is shadcn's `asChild` / Base UI's `render` prop, expressed in HTML.
117
+ */
118
+ export declare abstract class NativeEnhancer<T extends HTMLElement = HTMLElement> extends ShellElement {
119
+ /** Selector for the native child this enhancer applies its recipe to. */
120
+ static nativeSelector: string;
121
+ private _observer?;
122
+ private _warned;
123
+ get control(): T | null;
124
+ /** Apply the recipe (attributes / properties) to the native element. */
125
+ protected abstract apply(control: T): void;
126
+ connectedCallback(): void;
127
+ disconnectedCallback(): void;
128
+ protected updated(): void;
129
+ }
@@ -0,0 +1,28 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { AttrMap } from './attrs';
3
+ export declare const icons: {
4
+ check: (a?: AttrMap) => TemplateResult<1>;
5
+ minus: (a?: AttrMap) => TemplateResult<1>;
6
+ x: (a?: AttrMap) => TemplateResult<1>;
7
+ chevronDown: (a?: AttrMap) => TemplateResult<1>;
8
+ chevronUp: (a?: AttrMap) => TemplateResult<1>;
9
+ chevronRight: (a?: AttrMap) => TemplateResult<1>;
10
+ chevronLeft: (a?: AttrMap) => TemplateResult<1>;
11
+ chevronsUpDown: (a?: AttrMap) => TemplateResult<1>;
12
+ search: (a?: AttrMap) => TemplateResult<1>;
13
+ circle: (a?: AttrMap) => TemplateResult<1>;
14
+ loaderCircle: (a?: AttrMap) => TemplateResult<1>;
15
+ circleAlert: (a?: AttrMap) => TemplateResult<1>;
16
+ circleX: (a?: AttrMap) => TemplateResult<1>;
17
+ circleCheck: (a?: AttrMap) => TemplateResult<1>;
18
+ triangleAlert: (a?: AttrMap) => TemplateResult<1>;
19
+ info: (a?: AttrMap) => TemplateResult<1>;
20
+ eye: (a?: AttrMap) => TemplateResult<1>;
21
+ eyeOff: (a?: AttrMap) => TemplateResult<1>;
22
+ pencil: (a?: AttrMap) => TemplateResult<1>;
23
+ copy: (a?: AttrMap) => TemplateResult<1>;
24
+ download: (a?: AttrMap) => TemplateResult<1>;
25
+ arrowRight: (a?: AttrMap) => TemplateResult<1>;
26
+ userRoundKey: (a?: AttrMap) => TemplateResult<1>;
27
+ };
28
+ export type IconName = keyof typeof icons;
@@ -0,0 +1,6 @@
1
+ /** A document-unique id, e.g. `pont2-field-3`. Like React's `useId()`. */
2
+ export declare function uid(scope?: string): string;
3
+ /** Returns `el.id`, assigning a fresh `uid(scope)` first if it has none. */
4
+ export declare function ensureId(el: Element, scope?: string): string;
5
+ /** Adds/removes an id in a space-separated IDREF list attribute (aria-describedby etc.). */
6
+ export declare function toggleIdRef(el: Element, attr: string, id: string, on: boolean): void;
@@ -0,0 +1,10 @@
1
+ export * from './host-element';
2
+ export * from './form-control';
3
+ export * from './attrs';
4
+ export * from './ids';
5
+ export * from './events';
6
+ export * from './icons';
7
+ export * from './names';
8
+ export * from './controllers/roving-focus';
9
+ export * from './controllers/action';
10
+ export * from './controllers/copy';
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The pont2 namespace, in one place.
3
+ *
4
+ * | Thing | Form | Example |
5
+ * |------------------|-------------------------------|--------------------------------------|
6
+ * | primitive tag | `pont2-prim-<name>` | `pont2-prim-alert`, `pont2-prim-alert-title` |
7
+ * | kit tag | `pont2-<name>` | `pont2-alert` (composite), `pont2-button` (alias) |
8
+ * | identity attr | `data-pont2-<identity>` | `data-pont2-alert` (tier-neutral: "this is an alert") |
9
+ * | slot attr | `data-slot="<name>"` | `data-slot="item-separator"` (shadcn's own, unprefixed) |
10
+ * | state attrs | `data-<state>` | `data-checked`, `data-open` (Base UI's own, unprefixed) |
11
+ * | CSS custom prop | `--pont2-<name>` | `--pont2-primary` |
12
+ * | cascade layer | `pont2.<layer>` | `pont2.primitives`, `pont2.kit` |
13
+ * | custom event | `pont2-<name>` | `pont2-open-change` |
14
+ *
15
+ * Two element surfaces share one namespace (docs/10-primitives-and-kit.md):
16
+ *
17
+ * - **primitives** `pont2-prim-*`: shadcn's components, one for one.
18
+ * - **kit** `pont2-*`: what applications use. A kit element is either an
19
+ * *alias* of a primitive (same behaviour, second tag) or a *composite* (a
20
+ * subclass of a primitive that renders the primitive's children from
21
+ * properties). Invariant: **`pont2-<name>` is always a `<name>` at its
22
+ * root**, which is what lets `sel()` / `tags()` match both surfaces at once.
23
+ *
24
+ * The identity attribute is tier-neutral on purpose: it says *what* an element
25
+ * is (an alert), not *which tag* produced it. Recipes and lookups key on it, so
26
+ * a primitive, its alias, a composite built on it and hand-written recipe
27
+ * markup are all styled and found the same way.
28
+ *
29
+ * `data-slot` and the state attributes stay unprefixed on purpose: they are
30
+ * shadcn's and Base UI's public styling contract, and keeping them verbatim
31
+ * is what lets shadcn styles port across mechanically.
32
+ */
33
+ export declare const PREFIX = "pont2";
34
+ /** Tag segment that marks the primitive surface. */
35
+ export declare const PRIM = "prim";
36
+ /** Kit tag: `tag("alert")` → `pont2-alert`. */
37
+ export declare const tag: (name: string) => `pont2-${string}`;
38
+ /** Primitive tag: `primTag("alert")` → `pont2-prim-alert`. */
39
+ export declare const primTag: (name: string) => `pont2-prim-${string}`;
40
+ export declare const identityAttr: (identity: string) => `data-pont2-${string}`;
41
+ /**
42
+ * Selector for every element that *is* a `<name>`: its primitive tag, its kit
43
+ * tag (an alias or a composite, which by the kit invariant has that root) and
44
+ * its identity attribute (upgraded elements, parts rendered by composites,
45
+ * hand-written recipe markup).
46
+ *
47
+ * `sel("alert")` → `:is(pont2-prim-alert, pont2-alert, [data-pont2-alert])`
48
+ *
49
+ * Use it for every structural lookup (`closest`, `querySelector`), so a
50
+ * component works whichever surface its parts were written with.
51
+ * Tier 3 shells are the exception: their identity attribute lives on the
52
+ * native child, so look shells up with `tags()`.
53
+ */
54
+ export declare const sel: (name: string) => string;
55
+ /** The element tags only, on both surfaces: `:is(pont2-prim-x, pont2-x)`. Use for shells. */
56
+ export declare const tags: (name: string) => string;
57
+ /**
58
+ * Registers an element once. Re-registration (HMR, a second bundle copy) is a
59
+ * no-op rather than a thrown DOMException, but a *different* class under the
60
+ * same tag is reported, because that means two copies of pont2 are loaded.
61
+ */
62
+ export declare function define(name: string, ctor: CustomElementConstructor): void;
63
+ /**
64
+ * Promotes a primitive to the kit surface unchanged: `pont2-<name>` becomes a
65
+ * second tag for `pont2-prim-<name>`.
66
+ *
67
+ * The platform forbids registering one constructor under two names, so the
68
+ * alias is an empty subclass. It inherits everything (identity, slot, role,
69
+ * properties, form association), so it is styled, announced and submitted
70
+ * exactly like the primitive, and `instanceof` the primitive class holds.
71
+ *
72
+ * ```ts
73
+ * defineAlias("pont2-button", Pont2Button); // <pont2-prim-button> → also <pont2-button>
74
+ * ```
75
+ *
76
+ * Returns the alias constructor.
77
+ */
78
+ export declare function defineAlias<T extends CustomElementConstructor>(kitTag: `pont2-${string}`, base: T): T;
@@ -0,0 +1,48 @@
1
+ import { Align, Side } from './position';
2
+ export interface AnchoredOptions {
3
+ side: Side;
4
+ align: Align;
5
+ sideOffset: number;
6
+ alignOffset: number;
7
+ collisionPadding: number;
8
+ /** Select's `alignItemWithTrigger`: the item to lay over the anchor, if any. */
9
+ alignItem?: HTMLElement | null;
10
+ }
11
+ /**
12
+ * Keeps a floating element (a `popover` in the top layer, so `position:
13
+ * fixed` against the viewport) attached to an anchor element.
14
+ *
15
+ * It only *writes CSS custom properties and data attributes* on the floating
16
+ * element; the stylesheet turns them into `left`/`top`. Base UI's variables
17
+ * are written under pont2's namespace (read by pont2 CSS) and also verbatim,
18
+ * so shadcn classes (`max-h-(--available-height)`, `w-(--anchor-width)`,
19
+ * `origin-(--transform-origin)`) port unchanged into app CSS:
20
+ *
21
+ * | Written | Meaning |
22
+ * |-------------------------|--------------------------------------------|
23
+ * | `--pont2-popup-x/y` | viewport position of the box (px) |
24
+ * | `--pont2-anchor-width/height` (+ `--anchor-*`) | size of the anchor |
25
+ * | `--pont2-available-width/height` (+ `--available-*`) | room left before the collision padding |
26
+ * | `--pont2-transform-origin` (+ `--transform-origin`) | the anchor point the box grows from |
27
+ * | `--pont2-arrow-x/y` | anchor centre relative to the box (for arrows) |
28
+ * | `data-side`, `data-align` | the side/alignment actually used (after flip) |
29
+ *
30
+ * Updates are batched to one per animation frame and re-run on scroll (any
31
+ * ancestor, captured), resize, and size changes of either element.
32
+ */
33
+ export declare class AnchoredPositioner {
34
+ private readonly floating;
35
+ private readonly anchor;
36
+ private readonly options;
37
+ private frame;
38
+ private running;
39
+ private ro?;
40
+ private observedAnchor;
41
+ constructor(floating: HTMLElement, anchor: () => Element | null, options: () => AnchoredOptions);
42
+ start(): void;
43
+ stop(): void;
44
+ private observeAnchor;
45
+ private schedule;
46
+ /** Measure and write synchronously (also called right after showPopover, before first paint). */
47
+ update(): void;
48
+ }
@@ -0,0 +1,5 @@
1
+ export * from './position';
2
+ export * from './anchored';
3
+ export * from './list';
4
+ export * from './popup-content';
5
+ export * from './popup-root';
@@ -0,0 +1,38 @@
1
+ /**
2
+ * List navigation and typeahead for popup lists (menus, select, combobox).
3
+ *
4
+ * Two focus models, as in Base UI:
5
+ * - **real focus** (Menu, Select): the highlighted item *is* `document.activeElement`;
6
+ * items carry `tabindex="-1"` and `data-highlighted` follows focus;
7
+ * - **virtual focus** (Combobox): focus stays in the `<input>`; the highlighted
8
+ * item gets `data-highlighted` and the input points at it with
9
+ * `aria-activedescendant`.
10
+ *
11
+ * Both share `moveIndex()` and `Typeahead`.
12
+ */
13
+ export declare const isItemDisabled: (el: Element) => boolean;
14
+ export declare const isItemVisible: (el: HTMLElement) => boolean;
15
+ export type Move = "next" | "prev" | "first" | "last";
16
+ /** Index of the next enabled item in `direction` from `current` (−1 = none yet). */
17
+ export declare function moveIndex(items: readonly Element[], current: number, move: Move, { loop, isDisabled }?: {
18
+ loop?: boolean;
19
+ isDisabled?: (el: Element) => boolean;
20
+ }): number;
21
+ /** Keyboard key → move, for a vertical list. */
22
+ export declare function keyToMove(key: string): Move | null;
23
+ /**
24
+ * Typeahead (APG): printable keys typed within 500ms build a prefix; the
25
+ * first enabled item after the current one whose label starts with it wins.
26
+ * Repeating one character cycles through items starting with it.
27
+ */
28
+ export declare class Typeahead {
29
+ private readonly timeout;
30
+ private buffer;
31
+ private timer;
32
+ constructor(timeout?: number);
33
+ /** Whether a keyboard event is a typeahead character. */
34
+ static isChar(e: KeyboardEvent): boolean;
35
+ get active(): boolean;
36
+ match(key: string, items: readonly Element[], current: number, label?: (el: Element) => string): number;
37
+ reset(): void;
38
+ }