@pontive/pontkit-core 1.39.0 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog.json +1 -1
- package/custom-elements.json +1 -1
- package/dist/index.js +1846 -1289
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17059 -12690
- package/dist/index.mjs.map +1 -1
- package/dist/pont2/core/context-root.d.ts +1 -0
- package/dist/pont2/core/events.d.ts +1 -1
- package/dist/pont2/core/format.d.ts +46 -0
- package/dist/pont2/core/icons.d.ts +11 -0
- package/dist/pont2/core/index.d.ts +2 -0
- package/dist/pont2/core/messages.d.ts +128 -2
- package/dist/pont2/core/popup/index.d.ts +1 -0
- package/dist/pont2/core/popup/modal.d.ts +56 -0
- package/dist/pont2/core/popup/popup-content.d.ts +7 -0
- package/dist/pont2/core/popup/story-helpers.d.ts +6 -0
- package/dist/pont2/custom-elements.json +55405 -24958
- package/dist/pont2/index.d.ts +7 -0
- package/dist/pont2/index.mjs +6600 -2376
- package/dist/pont2/index.mjs.map +1 -1
- package/dist/pont2/kit/account-menu/account-menu.d.ts +115 -0
- package/dist/pont2/kit/account-settings/account-settings.d.ts +157 -0
- package/dist/pont2/kit/account-settings/profile.d.ts +74 -0
- package/dist/pont2/kit/badge-selector/badge-selector.d.ts +65 -0
- package/dist/pont2/kit/consent/consent.d.ts +3 -2
- package/dist/pont2/kit/data-table/data-table.d.ts +120 -0
- package/dist/pont2/kit/data-table/rows.d.ts +25 -0
- package/dist/pont2/kit/flow-widget/flow-widget.d.ts +21 -8
- package/dist/pont2/kit/index.d.ts +11 -0
- package/dist/pont2/kit/layout/layout.d.ts +7 -0
- package/dist/pont2/kit/member-management/errors.d.ts +60 -0
- package/dist/pont2/kit/member-management/member-management.d.ts +237 -0
- package/dist/pont2/kit/member-management/roles.d.ts +42 -0
- package/dist/pont2/kit/multi-email-input/emails.d.ts +19 -0
- package/dist/pont2/kit/multi-email-input/multi-email-input.d.ts +78 -0
- package/dist/pont2/kit/multi-select-filter/multi-select-filter.d.ts +53 -0
- package/dist/pont2/kit/organization-switcher/organization-switcher.d.ts +111 -0
- package/dist/pont2/kit/pagination/pagination.d.ts +61 -0
- package/dist/pont2/kit/pagination/range.d.ts +17 -0
- package/dist/pont2/kit/provider/account-client.d.ts +355 -0
- package/dist/pont2/kit/provider/account-controller.d.ts +47 -0
- package/dist/pont2/kit/provider/account-user.d.ts +16 -0
- package/dist/pont2/kit/provider/coexistence.d.ts +19 -0
- package/dist/pont2/kit/provider/contexts.d.ts +46 -0
- package/dist/pont2/kit/provider/provider.d.ts +219 -0
- package/dist/pont2/kit/provider/redirect.d.ts +122 -0
- package/dist/pont2/kit/provider/runtime-config.d.ts +24 -0
- package/dist/pont2/kit/provider/sdk.d.ts +100 -0
- package/dist/pont2/kit/provider/signed-in.d.ts +81 -0
- package/dist/pont2/kit/provider/widget-messages.d.ts +35 -0
- package/dist/pont2/primitives/alert-dialog/alert-dialog.d.ts +132 -0
- package/dist/pont2/primitives/combobox/combobox.d.ts +82 -14
- package/dist/pont2/primitives/dialog/dialog.d.ts +195 -0
- package/dist/pont2/primitives/drawer/drawer.d.ts +112 -0
- package/dist/pont2/primitives/hover-card/hover-card.d.ts +83 -0
- package/dist/pont2/primitives/pagination/pagination.d.ts +120 -0
- package/dist/pont2/primitives/sheet/sheet.d.ts +92 -0
- package/dist/pont2/primitives/sonner/sonner.d.ts +86 -0
- package/dist/pont2/primitives/sonner/toast-store.d.ts +81 -0
- package/dist/pont2/styles.css +2489 -760
- package/dist/pont2/theme/tokens.json.d.ts +700 -1
- package/dist/pont2/theme-golden.json +45 -45
- package/dist/pont2/theme.mjs +119 -119
- package/dist/pont2/tokens.json +700 -1
- package/dist/styles.css +2475 -746
- package/package.json +2 -2
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { nothing, PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { MessagesController } from '../../core/messages';
|
|
3
|
+
import { DropdownMenu } from '../../primitives/dropdown-menu/dropdown-menu';
|
|
4
|
+
import { AccountClient, SessionUser } from '../provider/account-client';
|
|
5
|
+
import { AccountController } from '../provider/account-controller';
|
|
6
|
+
/** One extra entry of the account menu (legacy `menuItems`). */
|
|
7
|
+
export interface AccountMenuItem {
|
|
8
|
+
/** Identifies the item in events and keeps its toggle/select state (default: `label`). */
|
|
9
|
+
id?: string;
|
|
10
|
+
label: string;
|
|
11
|
+
/** `action` (default) runs `onClick` or follows `href`; `toggle` is a checkbox item; `select` a submenu of options. */
|
|
12
|
+
type?: "action" | "toggle" | "select";
|
|
13
|
+
/** An icon shown before the label: a Lit template (an `<svg>`). */
|
|
14
|
+
icon?: unknown;
|
|
15
|
+
/** `destructive` for an action that deletes or leaves. */
|
|
16
|
+
variant?: "default" | "destructive";
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
href?: string;
|
|
19
|
+
onClick?: (event: Event, item: AccountMenuItem) => void;
|
|
20
|
+
checked?: boolean;
|
|
21
|
+
onToggle?: (checked: boolean) => void;
|
|
22
|
+
options?: {
|
|
23
|
+
value: string;
|
|
24
|
+
label: string;
|
|
25
|
+
}[];
|
|
26
|
+
value?: string;
|
|
27
|
+
onSelect?: (value: string) => void;
|
|
28
|
+
}
|
|
29
|
+
/** Detail of `pont2-menu-item-click`. */
|
|
30
|
+
export interface MenuItemClickDetail {
|
|
31
|
+
item: AccountMenuItem;
|
|
32
|
+
/** A toggle's new state. */
|
|
33
|
+
checked?: boolean;
|
|
34
|
+
/** A select's chosen value. */
|
|
35
|
+
value?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* # `<pont2-account-menu>`: who is signed in, account settings, log out
|
|
39
|
+
*
|
|
40
|
+
* ```html
|
|
41
|
+
* <pont2-provider app-id="app_123" domain="auth.acme.com" api-base-url="https://api.us.pontive.com">
|
|
42
|
+
* <pont2-account-menu account-settings-url="/account"></pont2-account-menu>
|
|
43
|
+
* </pont2-provider>
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* The legacy `pont-account-menu` (with its `pont-user-snippet`), as shadcn's
|
|
47
|
+
* "nav user": a ghost button with the user's avatar, name and email opening a
|
|
48
|
+
* Dropdown Menu with the same header, **Account settings**, the app's own
|
|
49
|
+
* `items`, and **Log out**. It **is** the Dropdown Menu primitive's root
|
|
50
|
+
* (`extends DropdownMenu`), so keyboard, focus and dismissal are the menu's.
|
|
51
|
+
*
|
|
52
|
+
* - **Data** comes from the account client (`pont2:account-client`, or its own
|
|
53
|
+
* `client`): the user is `client.getUser()`, read again on every session
|
|
54
|
+
* change. It never calls the SDK itself.
|
|
55
|
+
* - **Nothing renders** until the provider has resolved the auth state, nor
|
|
56
|
+
* for a signed-out visitor.
|
|
57
|
+
* - **Account settings** fires `pont2-account-settings` (cancelable: cancel it
|
|
58
|
+
* to navigate with a client-side router). Otherwise it goes to
|
|
59
|
+
* `account-settings-url` (not when that is the page already open), else it
|
|
60
|
+
* asks an account-settings dialog to open (`pont2-open-account-settings` on
|
|
61
|
+
* `document`).
|
|
62
|
+
* - **Log out** fires `pont2-logout` (cancelable: cancel it to sign out
|
|
63
|
+
* yourself), then `client.signOut()`.
|
|
64
|
+
* - **Items** fire `pont2-menu-item-click` (`{ item, checked?, value? }`); an
|
|
65
|
+
* action item then runs `onClick`, else follows `href` unless the event was
|
|
66
|
+
* cancelled.
|
|
67
|
+
*
|
|
68
|
+
* Words: `account_settings`, `log_out` (branding-svc Account messages).
|
|
69
|
+
*
|
|
70
|
+
* @tag pont2-account-menu
|
|
71
|
+
* @attr account-settings-url - where "Account settings" goes when nothing cancels `pont2-account-settings`
|
|
72
|
+
* @prop client - its own `AccountClient` (default: the provider's)
|
|
73
|
+
* @prop items - `AccountMenuItem[]`: entries between "Account settings" and "Log out"
|
|
74
|
+
* @fires pont2-account-settings - cancelable, `{}`: "Account settings" was chosen
|
|
75
|
+
* @fires pont2-logout - cancelable, `{}`: "Log out" was chosen
|
|
76
|
+
* @fires pont2-menu-item-click - cancelable `{ item, checked?, value? }`: one of `items` was chosen
|
|
77
|
+
* @fires pont2-open-change - cancelable `{ open, reason }` (the menu's)
|
|
78
|
+
*/
|
|
79
|
+
export declare class AccountMenu extends DropdownMenu {
|
|
80
|
+
static composite: boolean;
|
|
81
|
+
static properties: PropertyDeclarations;
|
|
82
|
+
client: AccountClient | undefined;
|
|
83
|
+
items: AccountMenuItem[];
|
|
84
|
+
accountSettingsUrl: string;
|
|
85
|
+
/** Who is signed in, as last read from the client (null: nobody, or not known yet). */
|
|
86
|
+
user: SessionUser | null;
|
|
87
|
+
protected readonly messages: MessagesController;
|
|
88
|
+
protected readonly account: AccountController;
|
|
89
|
+
/** Toggle and select states, by item key. */
|
|
90
|
+
private itemState;
|
|
91
|
+
constructor();
|
|
92
|
+
private readUser;
|
|
93
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
94
|
+
private onAccountSettings;
|
|
95
|
+
private onLogout;
|
|
96
|
+
private onAction;
|
|
97
|
+
private onToggle;
|
|
98
|
+
private onSelect;
|
|
99
|
+
private snippet;
|
|
100
|
+
private renderItem;
|
|
101
|
+
render(): import('lit-html').TemplateResult<1> | typeof nothing;
|
|
102
|
+
}
|
|
103
|
+
declare global {
|
|
104
|
+
interface HTMLElementTagNameMap {
|
|
105
|
+
"pont2-account-menu": AccountMenu;
|
|
106
|
+
}
|
|
107
|
+
interface HTMLElementEventMap {
|
|
108
|
+
"pont2-account-settings": CustomEvent<Record<string, never>>;
|
|
109
|
+
"pont2-logout": CustomEvent<Record<string, never>>;
|
|
110
|
+
"pont2-menu-item-click": CustomEvent<MenuItemClickDetail>;
|
|
111
|
+
}
|
|
112
|
+
interface DocumentEventMap {
|
|
113
|
+
"pont2-open-account-settings": CustomEvent<void>;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { nothing, PropertyDeclarations, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { HostElement } from '../../core/host-element';
|
|
3
|
+
import { MessagesController } from '../../core/messages';
|
|
4
|
+
import { BrandingController } from '../block/branding';
|
|
5
|
+
import { AccountClient, AccountProfile } from '../provider/account-client';
|
|
6
|
+
import { AccountController } from '../provider/account-controller';
|
|
7
|
+
import { ProfileSection, SectionErrors, SectionValues } from './profile';
|
|
8
|
+
export type AccountSettingsMode = "page" | "modal";
|
|
9
|
+
export type AccountSettingsOrientation = "horizontal" | "vertical";
|
|
10
|
+
export type AccountSettingsLayout = "row" | "column";
|
|
11
|
+
/** A card's own title and icon (legacy `IProfileWidgetCustomization`). */
|
|
12
|
+
export interface AccountSettingsCardContent {
|
|
13
|
+
title?: string;
|
|
14
|
+
/** Shown before the title: a Lit template or an element. */
|
|
15
|
+
icon?: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** The cards' titles and icons (legacy `IProfileContentCustomizations`, same keys). */
|
|
18
|
+
export interface AccountSettingsContent {
|
|
19
|
+
account?: AccountSettingsCardContent;
|
|
20
|
+
personalInfo?: AccountSettingsCardContent;
|
|
21
|
+
locations?: AccountSettingsCardContent;
|
|
22
|
+
urls?: AccountSettingsCardContent;
|
|
23
|
+
}
|
|
24
|
+
/** Detail of `pont2-profile-updated`. */
|
|
25
|
+
export interface ProfileUpdatedDetail {
|
|
26
|
+
section: ProfileSection;
|
|
27
|
+
profile: AccountProfile;
|
|
28
|
+
}
|
|
29
|
+
type LoadState = "idle" | "loading" | "ready" | "error";
|
|
30
|
+
/**
|
|
31
|
+
* # `<pont2-account-settings>`: the signed-in user's own profile
|
|
32
|
+
*
|
|
33
|
+
* ```html
|
|
34
|
+
* <pont2-provider app-id="app_123" domain="auth.acme.com" api-base-url="https://api.us.pontive.com">
|
|
35
|
+
* <pont2-account-menu></pont2-account-menu>
|
|
36
|
+
* <pont2-account-settings mode="modal"></pont2-account-settings>
|
|
37
|
+
* </pont2-provider>
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* The legacy `pont-account-settings`: a Profile tab (Login info with the
|
|
41
|
+
* photo, email and phone; Personal info; Location; Links) and a Security tab
|
|
42
|
+
* (coming soon), each profile card edited and saved on its own.
|
|
43
|
+
*
|
|
44
|
+
* - **Data** comes from the account client (`pont2:account-client`, or its own
|
|
45
|
+
* `client`): `getProfile()` (`GET /mgmt/v1/me`) and `updateProfile()`
|
|
46
|
+
* (`PATCH /mgmt/v1/me`). A client without `getProfile` gets a "not available"
|
|
47
|
+
* state; one without `updateProfile` shows the profile read-only.
|
|
48
|
+
* - **Nothing renders** until the auth state is resolved, nor for a
|
|
49
|
+
* signed-out visitor. Signing in as someone else reads the profile again.
|
|
50
|
+
* - **`mode="page"`** (default) shows it in place (a skeleton while the
|
|
51
|
+
* profile loads). **`mode="modal"`** shows it in a Dialog, opened by `open`,
|
|
52
|
+
* `show()`, or the account menu's "Account settings": this element answers
|
|
53
|
+
* the menu's `pont2-open-account-settings` (on `document`) with
|
|
54
|
+
* `preventDefault()` and opens. `pont2-close-account-settings` on `document`
|
|
55
|
+
* closes it.
|
|
56
|
+
* - **Labels wrap** (carry-over §4): a long translated label keeps a gap from
|
|
57
|
+
* its value and wraps instead of running into it; below 30rem the label
|
|
58
|
+
* sits above the value.
|
|
59
|
+
* - **Errors** are said in the card, in the page's language: a refused save
|
|
60
|
+
* keeps the form open with the section's own failure (`instance_unavailable`
|
|
61
|
+
* for a stopped instance, `connection_failed` with no answer), never the
|
|
62
|
+
* server's English.
|
|
63
|
+
*
|
|
64
|
+
* @tag pont2-account-settings
|
|
65
|
+
* @attr mode - `page` (default) | `modal` (legacy `PAGE` / `MODAL`)
|
|
66
|
+
* @attr orientation - `horizontal` (default: the tabs beside the content) | `vertical` (the tabs above it)
|
|
67
|
+
* @attr widgets-layout - `row` (default: label beside value) | `column` (label above value)
|
|
68
|
+
* @attr open - modal mode: whether the dialog is open
|
|
69
|
+
* @prop client - its own `AccountClient` (default: the provider's)
|
|
70
|
+
* @prop content - `AccountSettingsContent`: the cards' own titles and icons
|
|
71
|
+
* @prop profile - `AccountProfile | null` (read-only): the profile shown
|
|
72
|
+
* @fires pont2-profile-updated - `{ section, profile }`, after a section was saved
|
|
73
|
+
* @fires pont2-open-change - modal mode: cancelable `{ open, reason }` (the dialog's)
|
|
74
|
+
*/
|
|
75
|
+
export declare class AccountSettings extends HostElement {
|
|
76
|
+
static composite: boolean;
|
|
77
|
+
static properties: PropertyDeclarations;
|
|
78
|
+
client: AccountClient | undefined;
|
|
79
|
+
mode: AccountSettingsMode;
|
|
80
|
+
orientation: AccountSettingsOrientation;
|
|
81
|
+
widgetsLayout: AccountSettingsLayout;
|
|
82
|
+
open: boolean;
|
|
83
|
+
content: AccountSettingsContent | null;
|
|
84
|
+
profile: AccountProfile | null;
|
|
85
|
+
protected loadState: LoadState;
|
|
86
|
+
protected loadProblem: {
|
|
87
|
+
message: string;
|
|
88
|
+
retry: boolean;
|
|
89
|
+
} | null;
|
|
90
|
+
/** The section being edited (one at a time). */
|
|
91
|
+
protected editing: ProfileSection | null;
|
|
92
|
+
protected draft: SectionValues;
|
|
93
|
+
protected errors: SectionErrors;
|
|
94
|
+
protected saving: boolean;
|
|
95
|
+
protected saveError: string | null;
|
|
96
|
+
protected readonly messages: MessagesController;
|
|
97
|
+
protected readonly branding: BrandingController;
|
|
98
|
+
protected readonly account: AccountController;
|
|
99
|
+
private readonly ids;
|
|
100
|
+
private loadSeq;
|
|
101
|
+
/** Who the profile was read for (`sub`). */
|
|
102
|
+
private loadedFor;
|
|
103
|
+
private zones;
|
|
104
|
+
constructor();
|
|
105
|
+
connectedCallback(): void;
|
|
106
|
+
disconnectedCallback(): void;
|
|
107
|
+
/** Modal mode: opens the dialog. */
|
|
108
|
+
show(): void;
|
|
109
|
+
/** Modal mode: closes the dialog. */
|
|
110
|
+
close(): void;
|
|
111
|
+
/** Reads the profile again. */
|
|
112
|
+
reload(): Promise<void>;
|
|
113
|
+
/** `pont2-open-account-settings`: the menu's "Account settings" had no URL and nothing cancelled it. */
|
|
114
|
+
private onOpenRequest;
|
|
115
|
+
private onCloseRequest;
|
|
116
|
+
private refresh;
|
|
117
|
+
private whoAmI;
|
|
118
|
+
private get available();
|
|
119
|
+
private get editable();
|
|
120
|
+
private load;
|
|
121
|
+
private startEdit;
|
|
122
|
+
private cancelEdit;
|
|
123
|
+
private setDraft;
|
|
124
|
+
private save;
|
|
125
|
+
private timeZoneList;
|
|
126
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
127
|
+
private fieldId;
|
|
128
|
+
private onDialogOpenChange;
|
|
129
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
130
|
+
private renderBody;
|
|
131
|
+
private renderSkeleton;
|
|
132
|
+
private renderWatermark;
|
|
133
|
+
private cardHeader;
|
|
134
|
+
/** A label / value pair; wraps (carry-over §4). */
|
|
135
|
+
private row;
|
|
136
|
+
private shown;
|
|
137
|
+
private renderLoginInfo;
|
|
138
|
+
private renderSection;
|
|
139
|
+
private displayValue;
|
|
140
|
+
private control;
|
|
141
|
+
private onSubmit;
|
|
142
|
+
private formButtons;
|
|
143
|
+
private renderSaveError;
|
|
144
|
+
private renderSecurity;
|
|
145
|
+
}
|
|
146
|
+
declare global {
|
|
147
|
+
interface HTMLElementTagNameMap {
|
|
148
|
+
"pont2-account-settings": AccountSettings;
|
|
149
|
+
}
|
|
150
|
+
interface HTMLElementEventMap {
|
|
151
|
+
"pont2-profile-updated": CustomEvent<ProfileUpdatedDetail>;
|
|
152
|
+
}
|
|
153
|
+
interface DocumentEventMap {
|
|
154
|
+
"pont2-close-account-settings": CustomEvent<void>;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { KitMessageCode } from '../../core/messages';
|
|
2
|
+
import { AccountProfile, AccountProfileUpdate } from '../provider/account-client';
|
|
3
|
+
/**
|
|
4
|
+
* # Account settings' profile sections: values, rules, updates (W-8)
|
|
5
|
+
*
|
|
6
|
+
* Pure, so the rules can be unit-tested (`profile.test.ts`). The four cards
|
|
7
|
+
* of the legacy profile tab, each edited and saved on its own:
|
|
8
|
+
*
|
|
9
|
+
* | Section | Fields (`/mgmt/v1/me`) |
|
|
10
|
+
* |---|---|
|
|
11
|
+
* | `photo` (in the Login info card) | `picture` |
|
|
12
|
+
* | `personal` | `username`, `given_name`, `middle_name`, `family_name`, `nickname`, `gender`, `profile` (bio) |
|
|
13
|
+
* | `location` | `address.locality`, `zoneinfo` |
|
|
14
|
+
* | `links` | `website` |
|
|
15
|
+
*
|
|
16
|
+
* Email and phone show in the Login info card, read-only (they are
|
|
17
|
+
* identifiers, changed through a verification flow, not here).
|
|
18
|
+
*/
|
|
19
|
+
export type ProfileSection = "photo" | "personal" | "location" | "links";
|
|
20
|
+
export type FieldKey = "picture" | "username" | "given_name" | "middle_name" | "family_name" | "nickname" | "gender" | "profile" | "locality" | "zoneinfo" | "website";
|
|
21
|
+
export type SectionValues = Partial<Record<FieldKey, string>>;
|
|
22
|
+
export type SectionErrors = Partial<Record<FieldKey, string>>;
|
|
23
|
+
export declare const SECTION_FIELDS: Record<ProfileSection, FieldKey[]>;
|
|
24
|
+
/** Each field's label. */
|
|
25
|
+
export declare const FIELD_LABELS: Record<FieldKey, KitMessageCode>;
|
|
26
|
+
/**
|
|
27
|
+
* The longest value each text field takes (`maxlength`; the server's limits). The legacy cards
|
|
28
|
+
* said "X cannot be longer than 100 characters" in English; the input simply stops there instead,
|
|
29
|
+
* which needs no words (account text takes no placeholders).
|
|
30
|
+
*/
|
|
31
|
+
export declare const MAX_LENGTH: Partial<Record<FieldKey, number>>;
|
|
32
|
+
/** Where a failed save says why. */
|
|
33
|
+
export declare const SAVE_FAILED: Record<ProfileSection, KitMessageCode>;
|
|
34
|
+
/** The stored gender values (the legacy options' values) and their words. */
|
|
35
|
+
export declare const GENDERS: {
|
|
36
|
+
value: string;
|
|
37
|
+
label: KitMessageCode;
|
|
38
|
+
}[];
|
|
39
|
+
/** A stored gender in the page's language; a value from elsewhere shows as stored. */
|
|
40
|
+
export declare function genderLabel(value: string | undefined): string;
|
|
41
|
+
/** What a field shows (and its edit box starts with) for `profile`. */
|
|
42
|
+
export declare function fieldValue(profile: AccountProfile | null | undefined, key: FieldKey): string;
|
|
43
|
+
/** A section's values from `profile`, for its edit form. */
|
|
44
|
+
export declare function sectionValues(profile: AccountProfile | null | undefined, section: ProfileSection): SectionValues;
|
|
45
|
+
/** IANA time zone names, from the browser's own tz database (with the user's zone and UTC at least). */
|
|
46
|
+
export declare function timeZones(): string[];
|
|
47
|
+
/** Why an http(s) URL field is wrong (`url_hint`, `url_scheme_invalid`), or undefined when it is fine or empty. */
|
|
48
|
+
export declare function urlProblem(raw: string): KitMessageCode | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The rules the server applies anyway, run here so a refusal is a message beside the field. Every
|
|
51
|
+
* field is optional: a rule only fires on a value typed. `zones` is the time zone list the select
|
|
52
|
+
* offers (a stored value from before the select may be free text: `timezone_hint`).
|
|
53
|
+
*/
|
|
54
|
+
export declare function validateSection(section: ProfileSection, values: SectionValues, zones?: string[]): SectionErrors;
|
|
55
|
+
/** The `PATCH /me` body for a section: its fields, trimmed (the address merged, so the rest of it is kept). */
|
|
56
|
+
export declare function sectionUpdate(section: ProfileSection, values: SectionValues, profile: AccountProfile | null | undefined): AccountProfileUpdate;
|
|
57
|
+
/**
|
|
58
|
+
* A stored website as a link target: absolute http(s) only (carry-over §7's rule), a bare
|
|
59
|
+
* "example.com" from before the field was validated taken as https. `null`: show it as text.
|
|
60
|
+
*/
|
|
61
|
+
export declare function websiteHref(value: string | undefined): string | null;
|
|
62
|
+
/** A stored picture URL fit for an `<img src>`: absolute http(s) or a data:image URL, else `null`. */
|
|
63
|
+
export declare function pictureSrc(value: string | undefined): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Why a save failed, in the person's words: a stopped instance says so (§6), no answer is
|
|
66
|
+
* `connection_failed`, anything else the section's own failure. Never the server's English
|
|
67
|
+
* (`/me` is the management API, whose refusals are English only).
|
|
68
|
+
*/
|
|
69
|
+
export declare function describeProfileError(error: unknown, fallback: KitMessageCode): string;
|
|
70
|
+
/** Why the profile couldn't be read, and whether trying again could help. */
|
|
71
|
+
export declare function describeProfileLoadError(error: unknown): {
|
|
72
|
+
message: string;
|
|
73
|
+
retry: boolean;
|
|
74
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { MessagesController } from '../../core/messages';
|
|
3
|
+
import { Combobox } from '../../primitives/combobox/combobox';
|
|
4
|
+
export interface BadgeOption {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* Can't be added, and **locked** when selected: its badge has no remove
|
|
9
|
+
* button (a role the person may not assign or take away).
|
|
10
|
+
*/
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* # `<pont2-badge-selector>`: kit composite over a multiple `<pont2-prim-combobox>`
|
|
15
|
+
*
|
|
16
|
+
* Pick several options as badges, with type-to-filter: the account widgets'
|
|
17
|
+
* role picker (legacy `pont-badge-selector`). It **is** the Combobox
|
|
18
|
+
* primitive's root in `multiple` mode (form-associated: it submits one
|
|
19
|
+
* `name=value` per selected value), and renders shadcn's multiple-combobox
|
|
20
|
+
* DOM inside it: the chips input, then the popup with the list of options.
|
|
21
|
+
*
|
|
22
|
+
* ```html
|
|
23
|
+
* <pont2-badge-selector name="roles" placeholder="Search roles"></pont2-badge-selector>
|
|
24
|
+
* <script>
|
|
25
|
+
* el.options = [{ value: "owner", label: "Owner", disabled: true }, { value: "admin", label: "Admin" }];
|
|
26
|
+
* el.values = ["owner"]; // owner is locked in
|
|
27
|
+
* el.addEventListener("change", () => save(el.values));
|
|
28
|
+
* </script>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* - **Locked badges:** a selected option with `disabled` can't be removed
|
|
32
|
+
* (no remove button, Backspace skips it) and a disabled option can't be
|
|
33
|
+
* added.
|
|
34
|
+
* - **`max-selections`:** once reached, the unselected options are disabled.
|
|
35
|
+
* - Events are the Combobox's: `input` and `change` when the selection
|
|
36
|
+
* changes (read `values`), `pont2-open-change`.
|
|
37
|
+
*
|
|
38
|
+
* Default words are `msg()` codes: `search_roles` (placeholder), `no_options`
|
|
39
|
+
* (nothing matches).
|
|
40
|
+
*
|
|
41
|
+
* @tag pont2-badge-selector
|
|
42
|
+
* @attr name, required, disabled - as the Combobox's
|
|
43
|
+
* @attr placeholder - shown while nothing is selected (default `msg("search_roles")`)
|
|
44
|
+
* @attr empty-label - shown when no option matches (default `msg("no_options")`)
|
|
45
|
+
* @attr max-selections - the most values that can be selected
|
|
46
|
+
* @fires input, change - the selection changed (read `values`)
|
|
47
|
+
*/
|
|
48
|
+
export declare class BadgeSelector extends Combobox {
|
|
49
|
+
static composite: boolean;
|
|
50
|
+
static properties: PropertyDeclarations;
|
|
51
|
+
options: BadgeOption[];
|
|
52
|
+
placeholder: string;
|
|
53
|
+
emptyLabel: string;
|
|
54
|
+
maxSelections: number | undefined;
|
|
55
|
+
protected readonly messages: MessagesController;
|
|
56
|
+
constructor();
|
|
57
|
+
get maxReached(): boolean;
|
|
58
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
59
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
60
|
+
}
|
|
61
|
+
declare global {
|
|
62
|
+
interface HTMLElementTagNameMap {
|
|
63
|
+
"pont2-badge-selector": BadgeSelector;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -41,7 +41,7 @@ export { CONSENT_EXPIRED_EN, ConsentError, consentEndpoint, consentExpired, fetc
|
|
|
41
41
|
* @attr consent-request - the consent request's id (the page's `consent_request` parameter)
|
|
42
42
|
* @attr base-url - where auth-api is; empty (default) means same origin, which the session cookie needs
|
|
43
43
|
* @attr locales - preferred languages, passed to the load (`?locales=`)
|
|
44
|
-
* @prop branding - the account's branding entitlements (fail closed: the watermark shows)
|
|
44
|
+
* @prop branding - the account's branding entitlements (this, else a `pont2-provider`'s; fail closed: the watermark shows)
|
|
45
45
|
*/
|
|
46
46
|
export declare class Consent extends HostElement {
|
|
47
47
|
static identity: string;
|
|
@@ -49,7 +49,8 @@ export declare class Consent extends HostElement {
|
|
|
49
49
|
consentRequest: string;
|
|
50
50
|
baseUrl: string;
|
|
51
51
|
locales: string;
|
|
52
|
-
branding: BrandingEntitlements;
|
|
52
|
+
branding: BrandingEntitlements | undefined;
|
|
53
|
+
private readonly brandingConsumer;
|
|
53
54
|
protected renderSpec: string;
|
|
54
55
|
protected loadError: {
|
|
55
56
|
message: string;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { MessagesController } from '../../core/messages';
|
|
3
|
+
import { Table } from '../../primitives/table/table';
|
|
4
|
+
import { SortDirection } from './rows';
|
|
5
|
+
export { bodyState, nextSort, sortRows, type SortDirection, type SortState } from './rows';
|
|
6
|
+
export type DataTableRow = any;
|
|
7
|
+
/** One column. Everything but `key` and `header` is optional. */
|
|
8
|
+
export interface DataTableColumn<T = DataTableRow> {
|
|
9
|
+
/** The row field shown (and sorted on) by default; also the column's id in events. */
|
|
10
|
+
key: string;
|
|
11
|
+
/** Header text. */
|
|
12
|
+
header: string;
|
|
13
|
+
/** What the cell shows: text or a Lit template. Default: `row[key]` as text. */
|
|
14
|
+
cell?: (row: T, index: number) => unknown;
|
|
15
|
+
/** The header becomes a sort button. */
|
|
16
|
+
sortable?: boolean;
|
|
17
|
+
/** What the column sorts by (default `row[key]`): numbers and dates by value, text by the page's collation. */
|
|
18
|
+
sortValue?: (row: T) => unknown;
|
|
19
|
+
/** Cell alignment (default start). */
|
|
20
|
+
align?: "start" | "center" | "end";
|
|
21
|
+
}
|
|
22
|
+
/** One entry in each row's actions menu. */
|
|
23
|
+
export interface DataTableAction<T = DataTableRow> {
|
|
24
|
+
/** Sent in `pont2-row-action`. */
|
|
25
|
+
action: string;
|
|
26
|
+
label: string;
|
|
27
|
+
variant?: "default" | "destructive";
|
|
28
|
+
/** Leave the action out of this row's menu. */
|
|
29
|
+
hidden?: (row: T) => boolean;
|
|
30
|
+
disabled?: (row: T) => boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface RowActionDetail<T = DataTableRow> {
|
|
33
|
+
action: string;
|
|
34
|
+
row: T;
|
|
35
|
+
key: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SortChangeDetail {
|
|
38
|
+
key: string | null;
|
|
39
|
+
direction: SortDirection;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* # `<pont2-data-table>`: kit composite over `<pont2-prim-table>`
|
|
43
|
+
*
|
|
44
|
+
* shadcn's "Data Table" is a recipe (TanStack Table + `<Table>`), not a
|
|
45
|
+
* component. This is that recipe as one element, with what the account
|
|
46
|
+
* widgets need (tracker W-11): columns, rows, sortable headers, a per-row
|
|
47
|
+
* actions menu, a loading state and an empty state. It **is** the table
|
|
48
|
+
* container (`extends Table`) and renders a native `<table>` inside it, which
|
|
49
|
+
* the Table primitive's recipe styles as it does any table.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* table.columns = [
|
|
53
|
+
* { key: "name", header: "Name", sortable: true },
|
|
54
|
+
* { key: "joined", header: "Joined", sortable: true, cell: r => formatDate(r.joined) },
|
|
55
|
+
* ];
|
|
56
|
+
* table.actions = [{ action: "remove", label: "Remove member", variant: "destructive", hidden: r => r.isOwner }];
|
|
57
|
+
* table.rows = members;
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* - **Sorting:** pressing a sortable header cycles ascending → descending →
|
|
61
|
+
* unsorted and fires a cancelable `pont2-sort-change` `{ key, direction }`.
|
|
62
|
+
* Rows are sorted here unless `manual-sort` is set (server-side sorting:
|
|
63
|
+
* sort in the handler and set `rows`). The header carries `aria-sort`.
|
|
64
|
+
* - **Actions:** with `actions`, each row ends in a "⋯" menu (a Dropdown Menu
|
|
65
|
+
* primitive) labelled `actions-label`; an item fires `pont2-row-action`
|
|
66
|
+
* `{ action, row, key }`.
|
|
67
|
+
* - **Loading:** `loading` shows `loading-rows` skeleton rows and sets
|
|
68
|
+
* `aria-busy`.
|
|
69
|
+
* - **Empty:** no rows shows one full-width row with `empty-label`.
|
|
70
|
+
*
|
|
71
|
+
* Default words are `msg()` codes: `no_results`, `actions_menu`.
|
|
72
|
+
*
|
|
73
|
+
* @tag pont2-data-table
|
|
74
|
+
* @attr row-key - the row field that identifies a row (default `id`); the `rowKey` property may also be a function
|
|
75
|
+
* @attr sort-key, sort-direction - the current sort (`asc` | `desc`); set them to sort initially or to control it
|
|
76
|
+
* @attr manual-sort - don't sort the rows here, only report `pont2-sort-change`
|
|
77
|
+
* @attr loading - show skeleton rows
|
|
78
|
+
* @attr loading-rows - how many (default 5)
|
|
79
|
+
* @attr empty-label - shown when there are no rows (default `msg("no_results")`)
|
|
80
|
+
* @attr actions-label - the accessible name of each row's actions button (default `msg("actions_menu")`)
|
|
81
|
+
* @attr caption - a caption under the table
|
|
82
|
+
* @fires pont2-sort-change - cancelable `{ key, direction }`, a sortable header was pressed
|
|
83
|
+
* @fires pont2-row-action - `{ action, row, key }`, a row action was chosen
|
|
84
|
+
*/
|
|
85
|
+
export declare class DataTable extends Table {
|
|
86
|
+
static composite: boolean;
|
|
87
|
+
static properties: PropertyDeclarations;
|
|
88
|
+
columns: DataTableColumn[];
|
|
89
|
+
rows: DataTableRow[];
|
|
90
|
+
actions: DataTableAction[];
|
|
91
|
+
rowKey: string | ((row: DataTableRow) => string);
|
|
92
|
+
sortKey: string | null;
|
|
93
|
+
sortDirection: SortDirection;
|
|
94
|
+
manualSort: boolean;
|
|
95
|
+
loading: boolean;
|
|
96
|
+
loadingRows: number;
|
|
97
|
+
emptyLabel: string;
|
|
98
|
+
actionsLabel: string;
|
|
99
|
+
caption: string;
|
|
100
|
+
protected readonly messages: MessagesController;
|
|
101
|
+
constructor();
|
|
102
|
+
/** The rows in the order shown. */
|
|
103
|
+
get visibleRows(): DataTableRow[];
|
|
104
|
+
/** Press a column's sort, as the user did. Returns false if a listener cancelled it. */
|
|
105
|
+
toggleSort(key: string): boolean;
|
|
106
|
+
private keyOf;
|
|
107
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
108
|
+
private headerCell;
|
|
109
|
+
private actionsCell;
|
|
110
|
+
render(): TemplateResult<1>;
|
|
111
|
+
}
|
|
112
|
+
declare global {
|
|
113
|
+
interface HTMLElementTagNameMap {
|
|
114
|
+
"pont2-data-table": DataTable;
|
|
115
|
+
}
|
|
116
|
+
interface HTMLElementEventMap {
|
|
117
|
+
"pont2-sort-change": CustomEvent<SortChangeDetail>;
|
|
118
|
+
"pont2-row-action": CustomEvent<RowActionDetail>;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The data table's pure logic (rows.test.ts): sorting and the three-step
|
|
3
|
+
* sort cycle. Kept out of the element so it runs without a DOM.
|
|
4
|
+
*/
|
|
5
|
+
export type SortDirection = "asc" | "desc";
|
|
6
|
+
export interface SortState {
|
|
7
|
+
key: string | null;
|
|
8
|
+
direction: SortDirection;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The next sort after pressing a column's header: a new column sorts
|
|
12
|
+
* ascending, then the same column descending, then unsorted (the legacy
|
|
13
|
+
* `pont-data-table` cycle, and TanStack's default).
|
|
14
|
+
*/
|
|
15
|
+
export declare function nextSort(current: SortState, key: string): SortState;
|
|
16
|
+
/** A value comparable across types: numbers and dates by value, strings by the locale's collation, empty last. */
|
|
17
|
+
export declare function compareValues(a: unknown, b: unknown, collator: Intl.Collator): number;
|
|
18
|
+
/**
|
|
19
|
+
* `rows` sorted by `sortValue(row)` in `direction`, stably (rows that compare
|
|
20
|
+
* equal keep their order). Empty values sort last in both directions. Returns
|
|
21
|
+
* a new array; with no key, the rows as given.
|
|
22
|
+
*/
|
|
23
|
+
export declare function sortRows<T>(rows: readonly T[], sort: SortState, sortValue: (row: T, key: string) => unknown, locale?: string): T[];
|
|
24
|
+
/** What the body shows: skeleton rows while loading, the empty row when there is nothing, else the rows. */
|
|
25
|
+
export declare function bodyState(loading: boolean, rowCount: number): "loading" | "empty" | "rows";
|
|
@@ -76,8 +76,12 @@ export declare function escapeAttr(value: string): string;
|
|
|
76
76
|
* Nesting `pont2-layout` in a kit template is the allow-listed case (docs/10
|
|
77
77
|
* §5 rule 6): the layout is the stateful flow host, one per widget.
|
|
78
78
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
79
|
+
* Inside a `<pont2-provider>` it needs nothing: the provider's client
|
|
80
|
+
* (`pont2:client`), branding entitlements (`pont2:branding`) and login hint
|
|
81
|
+
* (`pont2:login-hint`) are used unless the widget is given its own.
|
|
82
|
+
*
|
|
83
|
+
* @prop client - `WidgetClient` (e.g. the SDK's `Auth`); the flow starts once there is one (this, else the provider's) and the widget is connected
|
|
84
|
+
* @prop branding - `BrandingEntitlements` from the backend (attribute-less; this, else the provider's, else fail closed)
|
|
81
85
|
* @attr flow-id - the flow to start (each widget has a default)
|
|
82
86
|
* @fires pont2-flow-response - (from the layout) after every successful request
|
|
83
87
|
*/
|
|
@@ -86,8 +90,10 @@ export declare abstract class FlowWidget extends HostElement {
|
|
|
86
90
|
static slotName: string;
|
|
87
91
|
static composite: boolean;
|
|
88
92
|
static properties: PropertyDeclarations;
|
|
93
|
+
/** The app's own client. Wins over the provider's. */
|
|
89
94
|
client: WidgetClient | undefined;
|
|
90
|
-
|
|
95
|
+
/** The app's own entitlements. Win over the provider's; without either, the watermark shows. */
|
|
96
|
+
branding: BrandingEntitlements | undefined;
|
|
91
97
|
flowId: string;
|
|
92
98
|
protected renderSpec: string;
|
|
93
99
|
protected messages: Partial<Record<string, string>>;
|
|
@@ -98,12 +104,20 @@ export declare abstract class FlowWidget extends HostElement {
|
|
|
98
104
|
} | null;
|
|
99
105
|
/** Re-renders when the page's message table changes (the loading label). */
|
|
100
106
|
protected readonly messagesController: MessagesController;
|
|
107
|
+
/** The provider's client (`pont2:client`), undefined until it has configured the SDK. */
|
|
108
|
+
protected providedClient: WidgetClient | undefined;
|
|
109
|
+
private readonly brandingConsumer;
|
|
110
|
+
private readonly hintConsumer;
|
|
101
111
|
/** The SDK's `flowType` this widget runs ("signin", "signup"): which flow-state events apply. */
|
|
102
112
|
protected abstract readonly flowType: string;
|
|
103
113
|
private started;
|
|
104
114
|
constructor();
|
|
105
115
|
/** The widget's layout. */
|
|
106
116
|
get layout(): Layout | null;
|
|
117
|
+
/** The client the flow runs on: the widget's own, else the provider's. */
|
|
118
|
+
get effectiveClient(): WidgetClient | undefined;
|
|
119
|
+
/** Whether the flow runs on the provider's client (which restarts it on a locale change). */
|
|
120
|
+
get usesProvidedClient(): boolean;
|
|
107
121
|
/** Starts the flow over. */
|
|
108
122
|
restart(): Promise<void>;
|
|
109
123
|
/** Applies an SDK flow-state change (what `dispatchFlowState` delivers). */
|
|
@@ -155,11 +169,10 @@ export declare class SignUp extends FlowWidget {
|
|
|
155
169
|
*
|
|
156
170
|
* It starts with **no flow id**: the SDK takes the invitation flow from the
|
|
157
171
|
* page's path, so the app names that path as `invitationUrl` when it configures
|
|
158
|
-
* the SDK (
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* `answersInvitation`; the provider's job, W-1).
|
|
172
|
+
* the SDK (`<pont2-provider invitation-url>`). An invitation answered by the
|
|
173
|
+
* sign-in flow would sign the invitee in and join them to nothing, which is why
|
|
174
|
+
* this is its own element. The page should also drop an existing session before
|
|
175
|
+
* the flow, which `<pont2-provider>` does on a page opened with `?invite_token=`.
|
|
163
176
|
*
|
|
164
177
|
* Everything on screen comes from the flow's render spec: the instance's own
|
|
165
178
|
* invitation widgets if it published any, else the built-in ones.
|
|
@@ -27,3 +27,14 @@ export * from './consent/consent';
|
|
|
27
27
|
export * from './flow-widget/flow-widget';
|
|
28
28
|
export * from './flow-widget/preview';
|
|
29
29
|
export * from './flow-widget/specimens';
|
|
30
|
+
export * from './provider/provider';
|
|
31
|
+
export * from './provider/signed-in';
|
|
32
|
+
export * from './pagination/pagination';
|
|
33
|
+
export * from './data-table/data-table';
|
|
34
|
+
export * from './badge-selector/badge-selector';
|
|
35
|
+
export * from './multi-email-input/multi-email-input';
|
|
36
|
+
export * from './multi-select-filter/multi-select-filter';
|
|
37
|
+
export * from './account-menu/account-menu';
|
|
38
|
+
export * from './organization-switcher/organization-switcher';
|
|
39
|
+
export * from './account-settings/account-settings';
|
|
40
|
+
export * from './member-management/member-management';
|