@pontive/pontkit-core 1.27.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 (41) hide show
  1. package/catalog.json +1 -1
  2. package/custom-elements.json +1 -1
  3. package/dist/pont2/core/controllers/action.d.ts +79 -0
  4. package/dist/pont2/core/controllers/copy.d.ts +34 -0
  5. package/dist/pont2/core/icons.d.ts +24 -16
  6. package/dist/pont2/core/index.d.ts +2 -0
  7. package/dist/pont2/index.mjs +3349 -1494
  8. package/dist/pont2/index.mjs.map +1 -1
  9. package/dist/pont2/kit/auth-button/auth-button.d.ts +185 -0
  10. package/dist/pont2/kit/auth-button/providers.d.ts +15 -0
  11. package/dist/pont2/kit/auth-field/auth-field.d.ts +267 -0
  12. package/dist/pont2/kit/auth-field/password-field.d.ts +124 -0
  13. package/dist/pont2/kit/block/block.d.ts +64 -0
  14. package/dist/pont2/kit/block/branding.d.ts +36 -0
  15. package/dist/pont2/kit/container/container.d.ts +40 -0
  16. package/dist/pont2/kit/countdown/countdown.d.ts +64 -0
  17. package/dist/pont2/kit/divider/divider.d.ts +30 -0
  18. package/dist/pont2/kit/edit-identifier/edit-identifier.d.ts +47 -0
  19. package/dist/pont2/kit/flow-widget/flow-widget.d.ts +151 -0
  20. package/dist/pont2/kit/gap/gap.d.ts +36 -0
  21. package/dist/pont2/kit/header/header.d.ts +37 -0
  22. package/dist/pont2/kit/index.d.ts +23 -0
  23. package/dist/pont2/kit/input-otp/input-otp.d.ts +7 -0
  24. package/dist/pont2/kit/layout/flow-error.d.ts +21 -0
  25. package/dist/pont2/kit/layout/layout.d.ts +120 -0
  26. package/dist/pont2/kit/link/link.d.ts +62 -0
  27. package/dist/pont2/kit/logo/logo.d.ts +57 -0
  28. package/dist/pont2/kit/otp-field/otp-field.d.ts +93 -0
  29. package/dist/pont2/kit/otp-field/otp-resend.d.ts +61 -0
  30. package/dist/pont2/kit/provider-field/provider-field.d.ts +87 -0
  31. package/dist/pont2/kit/qr-code/qr-code.d.ts +86 -0
  32. package/dist/pont2/kit/recovery-codes/recovery-codes.d.ts +64 -0
  33. package/dist/pont2/kit/scope-list/scope-list.d.ts +69 -0
  34. package/dist/pont2/kit/scope-list/scope-value.d.ts +16 -0
  35. package/dist/pont2/kit/secret/secret.d.ts +67 -0
  36. package/dist/pont2/kit/story-helpers.d.ts +9 -0
  37. package/dist/pont2/kit/typography/typography.d.ts +70 -0
  38. package/dist/pont2/kit/watermark/pontive-logo.d.ts +8 -0
  39. package/dist/pont2/kit/watermark/watermark.d.ts +42 -0
  40. package/dist/pont2/styles.css +702 -0
  41. package/package.json +1 -1
@@ -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
+ }
@@ -1,20 +1,28 @@
1
1
  import { TemplateResult } from 'lit';
2
+ import { AttrMap } from './attrs';
2
3
  export declare const icons: {
3
- check: () => TemplateResult<1>;
4
- minus: () => TemplateResult<1>;
5
- x: () => TemplateResult<1>;
6
- chevronDown: () => TemplateResult<1>;
7
- chevronUp: () => TemplateResult<1>;
8
- chevronRight: () => TemplateResult<1>;
9
- chevronLeft: () => TemplateResult<1>;
10
- chevronsUpDown: () => TemplateResult<1>;
11
- search: () => TemplateResult<1>;
12
- circle: () => TemplateResult<1>;
13
- loaderCircle: () => TemplateResult<1>;
14
- circleAlert: () => TemplateResult<1>;
15
- circleX: () => TemplateResult<1>;
16
- circleCheck: () => TemplateResult<1>;
17
- triangleAlert: () => TemplateResult<1>;
18
- info: () => TemplateResult<1>;
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>;
19
27
  };
20
28
  export type IconName = keyof typeof icons;
@@ -6,3 +6,5 @@ export * from './events';
6
6
  export * from './icons';
7
7
  export * from './names';
8
8
  export * from './controllers/roving-focus';
9
+ export * from './controllers/action';
10
+ export * from './controllers/copy';