@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
|
@@ -71,6 +71,7 @@ export declare function formDataToObject(fd: FormData | undefined | null): Recor
|
|
|
71
71
|
* @prop renderSpec - the screen's HTML
|
|
72
72
|
* @prop branding - `BrandingEntitlements` (attribute-less on purpose)
|
|
73
73
|
* @prop messages - localised flow messages by code (the flow's `messages`)
|
|
74
|
+
* @prop loginHint - the identifier to pre-fill email and identifier fields with (the URL's `login_hint`, from the provider)
|
|
74
75
|
* @fires pont2-flow-response - `{ action, result }` after every successful request
|
|
75
76
|
* @fires pont2-layout-restart - "Start again" pressed (the widget restarts the flow)
|
|
76
77
|
* @fires pont2-unregistered-element - on `document`, `{ tag }`
|
|
@@ -89,6 +90,12 @@ export declare class Layout extends HostElement {
|
|
|
89
90
|
*/
|
|
90
91
|
designMode: boolean;
|
|
91
92
|
messages: Partial<Record<string, string>>;
|
|
93
|
+
/**
|
|
94
|
+
* The identifier the page was opened with (OpenID Connect's `login_hint`). Email and identifier
|
|
95
|
+
* fields the screen leaves without a `value` are pre-filled with it, as the legacy fields did by
|
|
96
|
+
* reading the URL themselves (migration tracker F-11). A server prefill (`value`) wins.
|
|
97
|
+
*/
|
|
98
|
+
loginHint: string | undefined;
|
|
92
99
|
protected busy: boolean;
|
|
93
100
|
private provider;
|
|
94
101
|
private designProvider;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { isNetworkFailure, tokenErrorCode } from '../provider/account-client';
|
|
2
|
+
export { isNetworkFailure, tokenErrorCode };
|
|
3
|
+
/**
|
|
4
|
+
* # Member management's errors, in the person's words (carry-over §5, §6)
|
|
5
|
+
*
|
|
6
|
+
* A failure is said, never shown as an empty table. The legacy
|
|
7
|
+
* `pont-member-management/errors.ts`, ported onto the account client: the
|
|
8
|
+
* management token's refusals come from `getManagementScopes()` (the SDK's
|
|
9
|
+
* `ManagementTokenError`, which has a `code`), the API's from the request
|
|
10
|
+
* methods (`AccountApiError`, `status` + `code`). Pure: what the widget
|
|
11
|
+
* would need from the session is passed in. Unit-tested in `errors.test.ts`.
|
|
12
|
+
*/
|
|
13
|
+
/** The organization-member scopes (`ORGANIZATION_MEMBER_SCOPES` in `@pontive/oidc-client`). */
|
|
14
|
+
export declare const MEMBER_SCOPES: {
|
|
15
|
+
/** List members and invitations, list the assignable roles. */
|
|
16
|
+
readonly read: "pontive:org:member:read";
|
|
17
|
+
/** Remove a member, change a member's roles. */
|
|
18
|
+
readonly manage: "pontive:org:member:manage";
|
|
19
|
+
/** Send, resend and revoke invitations. */
|
|
20
|
+
readonly invite: "pontive:org:member:invite";
|
|
21
|
+
};
|
|
22
|
+
/** What the widget shows instead of its tables when it cannot show them. */
|
|
23
|
+
export interface LoadProblem {
|
|
24
|
+
message: string;
|
|
25
|
+
/** Whether trying again could help (a "Try again" button). */
|
|
26
|
+
retry: boolean;
|
|
27
|
+
/** For the app's developer, logged with `console.warn`: the setup the app is missing. */
|
|
28
|
+
hint?: string;
|
|
29
|
+
}
|
|
30
|
+
/** What `describeLoadError` needs to know about the app. */
|
|
31
|
+
export interface LoadErrorContext {
|
|
32
|
+
/** The scopes the app requests at sign-in (`client.requestedScopes()`); undefined when the client can't say. */
|
|
33
|
+
requestedScopes?: string[];
|
|
34
|
+
}
|
|
35
|
+
/** The SDK says the session changed (signed out, in again, switched) while the token was being drawn: ask again. */
|
|
36
|
+
export declare function isSessionChanged(error: unknown): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Why loading failed, for the person on the page; and, where the cause is the app's setup rather
|
|
39
|
+
* than the person, a `hint` for its developer (the widget logs it).
|
|
40
|
+
*/
|
|
41
|
+
export declare function describeLoadError(error: unknown, context?: LoadErrorContext): LoadProblem;
|
|
42
|
+
/**
|
|
43
|
+
* The refusals of a member change the server names (pontive-spec 41 §6), each with its own
|
|
44
|
+
* message: a role change of one's own, the role ceiling, roles changed meanwhile, giving / changing
|
|
45
|
+
* / removing `owner` without the right to transfer ownership, and leaving (removing oneself) an
|
|
46
|
+
* organization that doesn't let members leave.
|
|
47
|
+
*/
|
|
48
|
+
export declare const ACTION_CODES: readonly ["self_role_change", "role_ceiling", "member_roles_changed", "owner_transfer_required", "leave_disabled"];
|
|
49
|
+
/** The failure messages a member change can fall back to. */
|
|
50
|
+
export type ActionFailure = "invite_failed" | "update_roles_failed" | "remove_member_failed" | "resend_invitation_failed" | "revoke_invitation_failed";
|
|
51
|
+
/**
|
|
52
|
+
* Why an action failed, in the person's words; `fallback` when there is no better one.
|
|
53
|
+
*
|
|
54
|
+
* A 403 the widget has no message for is "You don't have permission…" only when the session holds
|
|
55
|
+
* no member write scope (`mayWrite`: the management token's manage or invite scope). Someone who
|
|
56
|
+
* can manage members was refused this one change, so they are told that (`member_change_refused`).
|
|
57
|
+
*/
|
|
58
|
+
export declare function describeActionError(error: unknown, fallback: ActionFailure, mayWrite: boolean): string;
|
|
59
|
+
/** The server refused a role change because the member's roles moved meanwhile: read them again. */
|
|
60
|
+
export declare function isRolesChanged(error: unknown): boolean;
|
|
@@ -0,0 +1,237 @@
|
|
|
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, AccountMembersApi, AssignableRole, OrganizationInvitation, OrganizationMember } from '../provider/account-client';
|
|
6
|
+
import { AccountController } from '../provider/account-controller';
|
|
7
|
+
import { LoadProblem } from './errors';
|
|
8
|
+
export type MemberManagementMode = "page" | "modal";
|
|
9
|
+
/** Detail of `pont2-members-invited`. */
|
|
10
|
+
export interface MembersInvitedDetail {
|
|
11
|
+
organizationId: string;
|
|
12
|
+
emails: string[];
|
|
13
|
+
roles: string[];
|
|
14
|
+
invitations: OrganizationInvitation[];
|
|
15
|
+
}
|
|
16
|
+
/** Detail of `pont2-member-roles-updated`. */
|
|
17
|
+
export interface MemberRolesUpdatedDetail {
|
|
18
|
+
organizationId: string;
|
|
19
|
+
userId: string;
|
|
20
|
+
roles: string[];
|
|
21
|
+
}
|
|
22
|
+
/** Detail of `pont2-member-removed`. */
|
|
23
|
+
export interface MemberRemovedDetail {
|
|
24
|
+
organizationId: string;
|
|
25
|
+
userId: string;
|
|
26
|
+
}
|
|
27
|
+
/** Detail of `pont2-invitation-resent` and `pont2-invitation-revoked`. */
|
|
28
|
+
export interface InvitationChangedDetail {
|
|
29
|
+
organizationId: string;
|
|
30
|
+
invitationId: string;
|
|
31
|
+
email: string;
|
|
32
|
+
/** Revoke only: whether the invitee was told. */
|
|
33
|
+
notifyInvitee?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** The page sizes offered ("Rows per page"). */
|
|
36
|
+
export declare const PAGE_SIZES: readonly [5, 10, 25];
|
|
37
|
+
/** The most addresses one invitation request takes (the legacy form's limit). */
|
|
38
|
+
export declare const MAX_INVITE_EMAILS = 10;
|
|
39
|
+
interface ListState<T> {
|
|
40
|
+
rows: T[];
|
|
41
|
+
page: number;
|
|
42
|
+
totalPages: number;
|
|
43
|
+
total: number;
|
|
44
|
+
loading: boolean;
|
|
45
|
+
search: string;
|
|
46
|
+
roles: string[];
|
|
47
|
+
}
|
|
48
|
+
type Confirm = {
|
|
49
|
+
kind: "remove";
|
|
50
|
+
member: OrganizationMember;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "resend";
|
|
53
|
+
invitation: OrganizationInvitation;
|
|
54
|
+
} | {
|
|
55
|
+
kind: "revoke";
|
|
56
|
+
invitation: OrganizationInvitation;
|
|
57
|
+
};
|
|
58
|
+
type Form = {
|
|
59
|
+
kind: "invite";
|
|
60
|
+
} | {
|
|
61
|
+
kind: "roles";
|
|
62
|
+
member: OrganizationMember;
|
|
63
|
+
};
|
|
64
|
+
/** Whether `client` has the member-management part (an app's own client may not). */
|
|
65
|
+
export declare function hasMembersApi(client: AccountClient | undefined): client is AccountClient & AccountMembersApi;
|
|
66
|
+
/** "6–10 / 23": which rows of how many, numbers and punctuation only (account text takes no placeholders). */
|
|
67
|
+
export declare function pageRange(page: number, pageSize: number, total: number, locale?: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* # `<pont2-member-management>`: an organization's members and invitations
|
|
70
|
+
*
|
|
71
|
+
* ```html
|
|
72
|
+
* <pont2-provider app-id="app_123" domain="auth.acme.com" api-base-url="https://api.us.pontive.com"
|
|
73
|
+
* scope="openid email profile offline_access pontive:org:member:read pontive:org:member:manage pontive:org:member:invite">
|
|
74
|
+
* <pont2-organization-switcher></pont2-organization-switcher>
|
|
75
|
+
* <pont2-member-management></pont2-member-management>
|
|
76
|
+
* </pont2-provider>
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* The legacy `pont-member-management` (pontive-spec 41 §5.4–§5.6), with every
|
|
80
|
+
* rule of carry-over §5:
|
|
81
|
+
*
|
|
82
|
+
* - **Data** through the account client's members part (`listMembers`,
|
|
83
|
+
* `listInvitations`, `listAssignableRoles`, `inviteMembers`,
|
|
84
|
+
* `updateMemberRoles`, `removeMember`, `resendInvitation`,
|
|
85
|
+
* `revokeInvitation`), each drawing a **management-API token** per request
|
|
86
|
+
* (the default client does; never the session's token). A client without
|
|
87
|
+
* that part gets a "not available" state.
|
|
88
|
+
* - **Controls by scope**, from the management token (`getManagementScopes`):
|
|
89
|
+
* the lists need `…:read`; changing roles and removing need `…:manage`;
|
|
90
|
+
* inviting, resending and revoking need `…:invite`.
|
|
91
|
+
* - **The role ceiling:** roles the caller may not assign or remove are
|
|
92
|
+
* locked in the pickers; "Remove member" is hidden on a row holding one;
|
|
93
|
+
* "Manage roles" is hidden on the caller's own row and on every row when
|
|
94
|
+
* the caller may assign no role.
|
|
95
|
+
* - **Errors are said, never shown as empty tables** (`errors.ts`), with the
|
|
96
|
+
* management token's `SESSION_CHANGED` retried once; a dialog's failure is
|
|
97
|
+
* said inside the dialog.
|
|
98
|
+
* - **The organization:** `organization-id`, else the session's, read again
|
|
99
|
+
* when the session moves to another organization (the switcher's
|
|
100
|
+
* `pont2-organization-changed`, or a session change from another tab).
|
|
101
|
+
*
|
|
102
|
+
* @tag pont2-member-management
|
|
103
|
+
* @attr organization-id - the organization to manage (default: the session's)
|
|
104
|
+
* @attr mode - `page` (default) | `modal` (legacy `PAGE` / `MODAL`)
|
|
105
|
+
* @attr open - modal mode: whether the dialog is open
|
|
106
|
+
* @attr heading - overrides the title (`msg("member_management_title")`); legacy `title`
|
|
107
|
+
* @attr description - overrides the subtitle (`msg("member_management_subtitle")`)
|
|
108
|
+
* @attr page-size - rows per page: 5 (default), 10 or 25
|
|
109
|
+
* @prop client - its own `AccountClient` (default: the provider's)
|
|
110
|
+
* @fires pont2-members-invited - `{ organizationId, emails, roles, invitations }`
|
|
111
|
+
* @fires pont2-member-roles-updated - `{ organizationId, userId, roles }`
|
|
112
|
+
* @fires pont2-member-removed - `{ organizationId, userId }`
|
|
113
|
+
* @fires pont2-invitation-resent - `{ organizationId, invitationId, email }`
|
|
114
|
+
* @fires pont2-invitation-revoked - `{ organizationId, invitationId, email, notifyInvitee }`
|
|
115
|
+
*/
|
|
116
|
+
export declare class MemberManagement extends HostElement {
|
|
117
|
+
static composite: boolean;
|
|
118
|
+
static properties: PropertyDeclarations;
|
|
119
|
+
client: AccountClient | undefined;
|
|
120
|
+
organizationId: string;
|
|
121
|
+
mode: MemberManagementMode;
|
|
122
|
+
open: boolean;
|
|
123
|
+
heading: string;
|
|
124
|
+
description: string;
|
|
125
|
+
pageSize: number;
|
|
126
|
+
/** Set until the first load settles. */
|
|
127
|
+
protected loading: boolean;
|
|
128
|
+
protected problem: LoadProblem | null;
|
|
129
|
+
protected canRead: boolean;
|
|
130
|
+
protected canManage: boolean;
|
|
131
|
+
protected canInvite: boolean;
|
|
132
|
+
protected roles: AssignableRole[];
|
|
133
|
+
protected members: ListState<OrganizationMember>;
|
|
134
|
+
protected invitations: ListState<OrganizationInvitation>;
|
|
135
|
+
/** The invite or manage-roles dialog. */
|
|
136
|
+
protected form: Form | null;
|
|
137
|
+
/** The confirmation dialog (remove, resend, revoke). */
|
|
138
|
+
protected confirm: Confirm | null;
|
|
139
|
+
protected busy: boolean;
|
|
140
|
+
protected dialogError: string | null;
|
|
141
|
+
protected inviteErrors: {
|
|
142
|
+
emails?: string;
|
|
143
|
+
roles?: string;
|
|
144
|
+
};
|
|
145
|
+
protected notifyInvitee: boolean;
|
|
146
|
+
protected readonly messages: MessagesController;
|
|
147
|
+
protected readonly branding: BrandingController;
|
|
148
|
+
protected readonly account: AccountController;
|
|
149
|
+
private readonly ids;
|
|
150
|
+
/** Which load is current; a later one makes an earlier one's answer stale. */
|
|
151
|
+
private loadSeq;
|
|
152
|
+
/** The organization (and user) the current answer is for. */
|
|
153
|
+
private loadedFor;
|
|
154
|
+
private loadedBy;
|
|
155
|
+
private searchTimers;
|
|
156
|
+
/** The manage-roles picker's selection while its dialog is open. */
|
|
157
|
+
private rolesValue;
|
|
158
|
+
/** What a dialog last showed, kept while it animates closed; bumped per opening so a form starts fresh. */
|
|
159
|
+
private lastForm;
|
|
160
|
+
private lastConfirm;
|
|
161
|
+
private dialogSeq;
|
|
162
|
+
constructor();
|
|
163
|
+
connectedCallback(): void;
|
|
164
|
+
disconnectedCallback(): void;
|
|
165
|
+
/** Modal mode: opens the dialog. */
|
|
166
|
+
show(): void;
|
|
167
|
+
/** Modal mode: closes the dialog. */
|
|
168
|
+
close(): void;
|
|
169
|
+
/** Everything again: the scopes, roles, members and invitations. */
|
|
170
|
+
reload(): Promise<void>;
|
|
171
|
+
/** The organization acted on: `organization-id`, else the session's. */
|
|
172
|
+
get effectiveOrganizationId(): string;
|
|
173
|
+
private onOpenRequest;
|
|
174
|
+
private onCloseRequest;
|
|
175
|
+
/** The switcher moved the session: an explicit `organization-id` stays put. */
|
|
176
|
+
private onOrganizationChanged;
|
|
177
|
+
private whoAmI;
|
|
178
|
+
private refresh;
|
|
179
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
180
|
+
protected updated(changed: PropertyValues): void;
|
|
181
|
+
private get api();
|
|
182
|
+
/** The management token first (what the session may do here), then the roles and both lists. */
|
|
183
|
+
private load;
|
|
184
|
+
private fail;
|
|
185
|
+
private params;
|
|
186
|
+
private withPage;
|
|
187
|
+
/** One list again, as filtered and paged now. A failure replaces the tables (it is said, not an empty table). */
|
|
188
|
+
private loadList;
|
|
189
|
+
private setList;
|
|
190
|
+
private onSearch;
|
|
191
|
+
private onFilter;
|
|
192
|
+
private onPage;
|
|
193
|
+
private onPageSize;
|
|
194
|
+
private get mayWrite();
|
|
195
|
+
private onMemberAction;
|
|
196
|
+
private onInvitationAction;
|
|
197
|
+
private openInvite;
|
|
198
|
+
private openRoles;
|
|
199
|
+
private openConfirm;
|
|
200
|
+
/** A dialog root changed `open` (Escape, the overlay, Cancel): follow it. */
|
|
201
|
+
private onDialogOpenChange;
|
|
202
|
+
private sendInvitations;
|
|
203
|
+
private saveRoles;
|
|
204
|
+
private rereadMember;
|
|
205
|
+
private confirmAction;
|
|
206
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
207
|
+
private renderHeader;
|
|
208
|
+
private renderWatermark;
|
|
209
|
+
private renderBody;
|
|
210
|
+
private renderToolbar;
|
|
211
|
+
private renderPager;
|
|
212
|
+
private roleBadges;
|
|
213
|
+
private when;
|
|
214
|
+
private renderMembers;
|
|
215
|
+
private renderInvitations;
|
|
216
|
+
private dialogAlert;
|
|
217
|
+
private submitButton;
|
|
218
|
+
private renderForm;
|
|
219
|
+
private renderConfirm;
|
|
220
|
+
}
|
|
221
|
+
declare global {
|
|
222
|
+
interface HTMLElementTagNameMap {
|
|
223
|
+
"pont2-member-management": MemberManagement;
|
|
224
|
+
}
|
|
225
|
+
interface HTMLElementEventMap {
|
|
226
|
+
"pont2-members-invited": CustomEvent<MembersInvitedDetail>;
|
|
227
|
+
"pont2-member-roles-updated": CustomEvent<MemberRolesUpdatedDetail>;
|
|
228
|
+
"pont2-member-removed": CustomEvent<MemberRemovedDetail>;
|
|
229
|
+
"pont2-invitation-resent": CustomEvent<InvitationChangedDetail>;
|
|
230
|
+
"pont2-invitation-revoked": CustomEvent<InvitationChangedDetail>;
|
|
231
|
+
}
|
|
232
|
+
interface DocumentEventMap {
|
|
233
|
+
"pont2-open-member-management": CustomEvent<void>;
|
|
234
|
+
"pont2-close-member-management": CustomEvent<void>;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BadgeOption } from '../badge-selector/badge-selector';
|
|
2
|
+
import { AssignableRole, RoleRef } from '../provider/account-client';
|
|
3
|
+
/**
|
|
4
|
+
* # The role ceiling (carry-over §5; pontive-spec 41 §6)
|
|
5
|
+
*
|
|
6
|
+
* The caller's assignable roles (`GET …/assignable-roles`) say, per role,
|
|
7
|
+
* whether the caller may assign or remove it (`assignable_by_caller`). What
|
|
8
|
+
* the server would refuse is not offered. Pure; unit-tested in `roles.test.ts`.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The organization's roles as role-picker options. A role the caller may not assign or remove
|
|
12
|
+
* (beyond their own permissions, or `owner` without the right to transfer ownership) is locked:
|
|
13
|
+
* it can be neither added nor, once held, taken away (`role_ceiling`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function roleOptions(roles: AssignableRole[]): BadgeOption[];
|
|
16
|
+
/** Whether any option is locked (the picker then says so: `roles_locked_hint`). */
|
|
17
|
+
export declare function hasLockedRole(roles: AssignableRole[]): boolean;
|
|
18
|
+
/** Whether the caller may assign or remove any of the organization's roles ("Manage roles" is hidden on every row otherwise). */
|
|
19
|
+
export declare function mayAssignAny(roles: AssignableRole[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the caller may remove a member holding `memberRoles`. Removing a member takes every role
|
|
22
|
+
* they hold, each held to the same ceiling as a role change, so one role the caller may not remove
|
|
23
|
+
* (`owner` without the right to transfer ownership, or one carrying permissions they don't hold)
|
|
24
|
+
* keeps the member, the caller's own row included. A role missing from `roles` is left to the server.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mayRemoveMember(memberRoles: string[], roles: AssignableRole[]): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether "Manage roles" shows on a member's row: the session may manage, the caller may assign at
|
|
29
|
+
* least one role, and the row is not the caller's own (`self_role_change`). Locked roles show
|
|
30
|
+
* locked inside the dialog, so a row holding one keeps the action.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mayManageRoles(member: {
|
|
33
|
+
userId: string;
|
|
34
|
+
}, ctx: {
|
|
35
|
+
canManage: boolean;
|
|
36
|
+
selfId: string | undefined;
|
|
37
|
+
roles: AssignableRole[];
|
|
38
|
+
}): boolean;
|
|
39
|
+
/** The role keys of a member or invitation. */
|
|
40
|
+
export declare function roleKeys(roles: RoleRef[] | undefined): string[];
|
|
41
|
+
/** A role's display name: the member's own copy of it, else the organization's, else its key. */
|
|
42
|
+
export declare function roleName(role: RoleRef, roles: AssignableRole[]): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The multi-email input's pure logic (emails.test.ts).
|
|
3
|
+
*/
|
|
4
|
+
/** `text` split into candidate addresses (trimmed, empty pieces dropped). */
|
|
5
|
+
export declare function splitEmails(text: string): string[];
|
|
6
|
+
export declare function isEmail(text: string): boolean;
|
|
7
|
+
export interface AddResult {
|
|
8
|
+
/** The new list (`current` plus what was accepted). */
|
|
9
|
+
values: string[];
|
|
10
|
+
/** Candidates that are not valid addresses, in the order given. */
|
|
11
|
+
invalid: string[];
|
|
12
|
+
/** Valid candidates left out because `max` was reached. */
|
|
13
|
+
overflow: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Adds `candidates` to `current`: valid addresses only, each once (compared
|
|
17
|
+
* case-insensitively, the first spelling kept), up to `max` in total.
|
|
18
|
+
*/
|
|
19
|
+
export declare function addEmails(current: readonly string[], candidates: readonly string[], max?: number): AddResult;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { PropertyDeclarations, PropertyValues } from 'lit';
|
|
2
|
+
import { FormControlElement, ValidityResult } from '../../core/form-control';
|
|
3
|
+
import { MessagesController } from '../../core/messages';
|
|
4
|
+
export { addEmails, isEmail, splitEmails, type AddResult } from './emails';
|
|
5
|
+
/**
|
|
6
|
+
* # `<pont2-multi-email-input>`: several email addresses as removable chips
|
|
7
|
+
*
|
|
8
|
+
* The account widgets' "invite members" field (legacy `pont-multi-email-input`).
|
|
9
|
+
* Type or paste addresses: Enter, a comma, a semicolon, a space, a paste or
|
|
10
|
+
* leaving the field turns what was typed into chips; invalid addresses stay
|
|
11
|
+
* out and are named in an error below. Backspace in the empty input removes
|
|
12
|
+
* the last chip.
|
|
13
|
+
*
|
|
14
|
+
* It is a form control (form-associated: one `name=address` entry per
|
|
15
|
+
* address, `required`, `disabled`, reset), labelled by its `<label for>`. It
|
|
16
|
+
* reuses the multiple Combobox's chips recipe (`ComboboxChips.part()`: the
|
|
17
|
+
* same box, chips and input as `<pont2-badge-selector>`), with a Field
|
|
18
|
+
* description (a count, `3 / 50`) or error under it.
|
|
19
|
+
*
|
|
20
|
+
* ```html
|
|
21
|
+
* <label data-pont2-label for="invite">Email addresses</label>
|
|
22
|
+
* <pont2-multi-email-input id="invite" name="emails" max="50" required></pont2-multi-email-input>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Words are `msg()` codes: `invite_emails_placeholder`, `invalid_emails`,
|
|
26
|
+
* `email_limit_reached`, `action_remove`. The counter is formatted for the
|
|
27
|
+
* page's language.
|
|
28
|
+
*
|
|
29
|
+
* @tag pont2-multi-email-input
|
|
30
|
+
* @attr name, required, disabled - as a native control's
|
|
31
|
+
* @attr placeholder - shown while empty (default `msg("invite_emails_placeholder")`)
|
|
32
|
+
* @attr max - the most addresses (default 50)
|
|
33
|
+
* @fires input, change - the list changed (read `values`)
|
|
34
|
+
*/
|
|
35
|
+
export declare class MultiEmailInput extends FormControlElement {
|
|
36
|
+
static identity: string;
|
|
37
|
+
static composite: boolean;
|
|
38
|
+
static properties: PropertyDeclarations;
|
|
39
|
+
values: string[];
|
|
40
|
+
placeholder: string;
|
|
41
|
+
max: number;
|
|
42
|
+
/** What the last attempt could not add. */
|
|
43
|
+
protected invalid: string[];
|
|
44
|
+
protected limitReached: boolean;
|
|
45
|
+
protected readonly messages: MessagesController;
|
|
46
|
+
private readonly inputId;
|
|
47
|
+
private readonly hintId;
|
|
48
|
+
private defaultValues;
|
|
49
|
+
constructor();
|
|
50
|
+
protected get hostFocusable(): boolean;
|
|
51
|
+
get input(): HTMLInputElement | null;
|
|
52
|
+
focus(options?: FocusOptions): void;
|
|
53
|
+
/** Add addresses (as if typed). Returns what could not be added. */
|
|
54
|
+
add(text: string | string[]): {
|
|
55
|
+
invalid: string[];
|
|
56
|
+
overflow: string[];
|
|
57
|
+
};
|
|
58
|
+
removeEmail(email: string): void;
|
|
59
|
+
private commit;
|
|
60
|
+
/** Turn the typed text into chips; keeps anything invalid in the input to fix. */
|
|
61
|
+
private flush;
|
|
62
|
+
private onKeyDown;
|
|
63
|
+
private onPaste;
|
|
64
|
+
private onInput;
|
|
65
|
+
protected formValue(): FormData | null;
|
|
66
|
+
protected resetToDefault(): void;
|
|
67
|
+
protected restoreState(state: string | File | FormData | null): void;
|
|
68
|
+
protected validate(): ValidityResult | null;
|
|
69
|
+
protected get validationAnchor(): HTMLElement | undefined;
|
|
70
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
71
|
+
protected updated(changed: PropertyValues): void;
|
|
72
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
73
|
+
}
|
|
74
|
+
declare global {
|
|
75
|
+
interface HTMLElementTagNameMap {
|
|
76
|
+
"pont2-multi-email-input": MultiEmailInput;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PropertyDeclarations } from 'lit';
|
|
2
|
+
import { MessagesController } from '../../core/messages';
|
|
3
|
+
import { DropdownMenu } from '../../primitives/dropdown-menu/dropdown-menu';
|
|
4
|
+
export interface FilterOption {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* # `<pont2-multi-select-filter>`: a "filter by" menu of checkboxes
|
|
10
|
+
*
|
|
11
|
+
* The account widgets' role filter (legacy `pont-multi-select-filter`), as
|
|
12
|
+
* shadcn builds a faceted filter: an outline button with the filter's name
|
|
13
|
+
* and a count badge, opening a Dropdown Menu of checkbox items, plus "Clear
|
|
14
|
+
* filters" when something is chosen. It **is** the Dropdown Menu primitive's
|
|
15
|
+
* root (`extends DropdownMenu`, a `display: contents` coordinator) and
|
|
16
|
+
* renders its trigger and content, so keyboard, focus and dismissal are the
|
|
17
|
+
* menu's. The menu stays open while you tick items.
|
|
18
|
+
*
|
|
19
|
+
* ```html
|
|
20
|
+
* <pont2-multi-select-filter label="Roles"></pont2-multi-select-filter>
|
|
21
|
+
* <script>
|
|
22
|
+
* el.options = [{ value: "admin", label: "Admin" }, { value: "member", label: "Member" }];
|
|
23
|
+
* el.addEventListener("change", () => reload({ roles: el.values }));
|
|
24
|
+
* </script>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Default words are `msg()` codes: `filter` (the label), `clear_filters`. The
|
|
28
|
+
* count is formatted for the page's language.
|
|
29
|
+
*
|
|
30
|
+
* @tag pont2-multi-select-filter
|
|
31
|
+
* @attr label - the button's text and the menu's heading (default `msg("filter")`)
|
|
32
|
+
* @attr disabled - as the menu's
|
|
33
|
+
* @fires change - the chosen values changed (read `values`)
|
|
34
|
+
* @fires pont2-open-change - cancelable `{ open, reason }`
|
|
35
|
+
*/
|
|
36
|
+
export declare class MultiSelectFilter extends DropdownMenu {
|
|
37
|
+
static composite: boolean;
|
|
38
|
+
static properties: PropertyDeclarations;
|
|
39
|
+
options: FilterOption[];
|
|
40
|
+
values: string[];
|
|
41
|
+
label: string;
|
|
42
|
+
protected readonly messages: MessagesController;
|
|
43
|
+
constructor();
|
|
44
|
+
private toggleValue;
|
|
45
|
+
/** Untick everything, as the "Clear filters" item does. */
|
|
46
|
+
clear(): void;
|
|
47
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
48
|
+
}
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementTagNameMap {
|
|
51
|
+
"pont2-multi-select-filter": MultiSelectFilter;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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, MyOrganization } from '../provider/account-client';
|
|
5
|
+
import { AccountController } from '../provider/account-controller';
|
|
6
|
+
/** Detail of `pont2-organization-changed` (and the `onOrganizationChanged` callback). */
|
|
7
|
+
export interface OrganizationChangedDetail {
|
|
8
|
+
organizationId: string;
|
|
9
|
+
roles: string[];
|
|
10
|
+
permissions: string[];
|
|
11
|
+
}
|
|
12
|
+
/** Detail of `pont2-organization-switch-failed` (and `onSwitchFailed`). The session is unchanged. */
|
|
13
|
+
export interface OrganizationSwitchFailedDetail {
|
|
14
|
+
organizationId: string;
|
|
15
|
+
error: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** The sentence for a refused switch: a stopped instance says so (carry-over §6), anything else is "you can't". */
|
|
18
|
+
export declare function describeSwitchError(error: unknown): string;
|
|
19
|
+
/**
|
|
20
|
+
* # `<pont2-organization-switcher>`: move the session to another organization
|
|
21
|
+
*
|
|
22
|
+
* ```html
|
|
23
|
+
* <pont2-provider app-id="app_123" domain="auth.acme.com" api-base-url="https://api.us.pontive.com">
|
|
24
|
+
* <pont2-organization-switcher></pont2-organization-switcher>
|
|
25
|
+
* </pont2-provider>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* The legacy `pont-organization-switcher`. The session acts in one
|
|
29
|
+
* organization at a time; choosing another is a refresh naming it (new
|
|
30
|
+
* tokens, same session, no sign-in). An outline button with the current
|
|
31
|
+
* organization opens a Dropdown Menu of the user's organizations as radio
|
|
32
|
+
* items. It **is** the Dropdown Menu primitive's root (`extends DropdownMenu`).
|
|
33
|
+
*
|
|
34
|
+
* - **Data** comes from the account client (`pont2:account-client`, or its own
|
|
35
|
+
* `client`): `listMyOrganizations()` (`GET /mgmt/v1/me/organizations`, the
|
|
36
|
+
* organizations the user is a direct member of, bounded), `getOrganization()`
|
|
37
|
+
* and `switchOrganization()`. It never calls the SDK or `fetch` itself.
|
|
38
|
+
* - **Renders nothing** until the auth state is resolved, for a signed-out
|
|
39
|
+
* visitor, and for a user with no organizations (a B2C app can include it
|
|
40
|
+
* and never show it).
|
|
41
|
+
* - **Follows the session:** a switch made in another tab, or by another
|
|
42
|
+
* switcher, moves the checked item (the client's `onSessionChange`; a client
|
|
43
|
+
* without one is re-read when the window regains focus). Signing in as
|
|
44
|
+
* someone else reloads the list.
|
|
45
|
+
* - **After a switch** it fires `pont2-organization-changed` and calls
|
|
46
|
+
* `onOrganizationChanged`, so the app can reload what it shows for the old
|
|
47
|
+
* organization; with `reload-on-switch` it reloads the page instead (a
|
|
48
|
+
* server-rendered page reads the new token from the cookie). A refused
|
|
49
|
+
* switch leaves the session as it was, says so inside the menu, fires
|
|
50
|
+
* `pont2-organization-switch-failed` and calls `onSwitchFailed`.
|
|
51
|
+
*
|
|
52
|
+
* Words: `select_organization` (no current organization; `empty-label`
|
|
53
|
+
* overrides it), `organization_switching`, `organization_switch_failed`,
|
|
54
|
+
* `instance_unavailable`.
|
|
55
|
+
*
|
|
56
|
+
* @tag pont2-organization-switcher
|
|
57
|
+
* @attr reload-on-switch - reload the page after a successful switch
|
|
58
|
+
* @attr empty-label - the button's text when the session acts in no organization (default `msg("select_organization")`)
|
|
59
|
+
* @prop client - its own `AccountClient` (default: the provider's)
|
|
60
|
+
* @prop onOrganizationChanged - `(detail: OrganizationChangedDetail) => void`, after a switch
|
|
61
|
+
* @prop onSwitchFailed - `(detail: OrganizationSwitchFailedDetail) => void`, when a switch is refused
|
|
62
|
+
* @prop organizations - `MyOrganization[]` (read-only): the list shown
|
|
63
|
+
* @prop currentId - `string | null` (read-only): the organization the session acts in
|
|
64
|
+
* @fires pont2-organization-changed - `{ organizationId, roles, permissions }`, after a switch
|
|
65
|
+
* @fires pont2-organization-switch-failed - `{ organizationId, error }`, when a switch is refused
|
|
66
|
+
* @fires pont2-open-change - cancelable `{ open, reason }` (the menu's)
|
|
67
|
+
*/
|
|
68
|
+
export declare class OrganizationSwitcher extends DropdownMenu {
|
|
69
|
+
static composite: boolean;
|
|
70
|
+
static properties: PropertyDeclarations;
|
|
71
|
+
client: AccountClient | undefined;
|
|
72
|
+
reloadOnSwitch: boolean;
|
|
73
|
+
emptyLabel: string;
|
|
74
|
+
onOrganizationChanged: ((detail: OrganizationChangedDetail) => void) | undefined;
|
|
75
|
+
onSwitchFailed: ((detail: OrganizationSwitchFailedDetail) => void) | undefined;
|
|
76
|
+
organizations: MyOrganization[];
|
|
77
|
+
currentId: string | null;
|
|
78
|
+
/** The list has been read for the current user. */
|
|
79
|
+
loaded: boolean;
|
|
80
|
+
/** The organization being switched to, while a switch is in the air. */
|
|
81
|
+
switching: string | null;
|
|
82
|
+
/** The last refusal's sentence, shown in the menu until the next attempt. */
|
|
83
|
+
error: string | null;
|
|
84
|
+
protected readonly messages: MessagesController;
|
|
85
|
+
protected readonly account: AccountController;
|
|
86
|
+
/** Bumped per list read, so only the latest answer is shown. */
|
|
87
|
+
private loadSeq;
|
|
88
|
+
/** Who the list was read for (`sub`), so a sign-in as someone else reads it again. */
|
|
89
|
+
private loadedFor;
|
|
90
|
+
constructor();
|
|
91
|
+
/** Reads the list again (and the current organization). */
|
|
92
|
+
reload(): Promise<void>;
|
|
93
|
+
private refresh;
|
|
94
|
+
private whoAmI;
|
|
95
|
+
private readCurrent;
|
|
96
|
+
private load;
|
|
97
|
+
/** Moves the session to `organizationId`, as choosing it in the menu does. */
|
|
98
|
+
select(organizationId: string): Promise<void>;
|
|
99
|
+
private nameOf;
|
|
100
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
101
|
+
render(): import('lit-html').TemplateResult<1> | typeof nothing;
|
|
102
|
+
}
|
|
103
|
+
declare global {
|
|
104
|
+
interface HTMLElementTagNameMap {
|
|
105
|
+
"pont2-organization-switcher": OrganizationSwitcher;
|
|
106
|
+
}
|
|
107
|
+
interface HTMLElementEventMap {
|
|
108
|
+
"pont2-organization-changed": CustomEvent<OrganizationChangedDetail>;
|
|
109
|
+
"pont2-organization-switch-failed": CustomEvent<OrganizationSwitchFailedDetail>;
|
|
110
|
+
}
|
|
111
|
+
}
|