@burdenoff/fe-libs 2026.1113.6 → 2026.1113.8
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/dist/connections/ConnectionDialog.d.ts +13 -1
- package/dist/connections/ConnectionDialog.js +13 -11
- package/dist/connections/ConnectionDialogPanel.d.ts +5 -1
- package/dist/connections/ConnectionDialogPanel.js +230 -150
- package/dist/connections/ConnectionFormTab.d.ts +15 -0
- package/dist/connections/ConnectionFormTab.js +192 -189
- package/dist/connections/CredentialStorageSelector.d.ts +9 -0
- package/dist/connections/CredentialStorageSelector.js +145 -137
- package/dist/connections/OneScreenConnectionForm.d.ts +22 -0
- package/dist/connections/OneScreenConnectionForm.js +231 -0
- package/dist/connections/ProviderPickerPanel.d.ts +6 -0
- package/dist/connections/ProviderPickerPanel.js +98 -45
- package/dist/connections/api.d.ts +3 -0
- package/dist/connections/api.js +4 -2
- package/dist/connections/connectionFlow.d.ts +18 -0
- package/dist/connections/connectionFlow.js +3 -3
- package/dist/connections/index.d.ts +4 -3
- package/dist/connections/picker.d.ts +18 -0
- package/dist/connections/picker.js +35 -6
- package/dist/connections/scopes.d.ts +8 -0
- package/dist/connections/scopes.js +9 -1
- package/dist/connections/storage.d.ts +9 -1
- package/dist/connections/storage.js +13 -1
- package/dist/connections/types.d.ts +16 -0
- package/dist/connections/useConnectionSubmit.d.ts +38 -2
- package/dist/connections/useConnectionSubmit.js +115 -71
- package/dist/connections.js +11 -10
- package/dist/credentials/SchemaForm.d.ts +7 -1
- package/dist/credentials/SchemaForm.js +64 -64
- package/dist/credentials/index.d.ts +2 -2
- package/dist/credentials/schema.d.ts +11 -1
- package/dist/credentials/schema.js +13 -5
- package/dist/credentials/types.d.ts +9 -0
- package/dist/credentials.js +5 -5
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/use-heading-document-title.d.ts +19 -0
- package/dist/ui/use-heading-document-title.js +29 -0
- package/dist/ui.js +49 -48
- package/package.json +1 -1
|
@@ -17,4 +17,16 @@ var e = {
|
|
|
17
17
|
function r(e, r) {
|
|
18
18
|
return r === "oauth2" || r === "basic_auth" ? e.filter((e) => t.has(e.type)) : r === "api_key" || r === "bearer_token" ? e.filter((e) => n.has(e.type)) : e;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
function i(e) {
|
|
21
|
+
return e.find((e) => /\bdefault\b/i.test(e.name)) ?? e[0] ?? null;
|
|
22
|
+
}
|
|
23
|
+
function a(e, t) {
|
|
24
|
+
if (e.vaultId || e.mode !== "managed") return e;
|
|
25
|
+
let n = i(t);
|
|
26
|
+
return n ? {
|
|
27
|
+
...e,
|
|
28
|
+
vaultId: n.id,
|
|
29
|
+
secretId: ""
|
|
30
|
+
} : e;
|
|
31
|
+
}
|
|
32
|
+
export { e as EMPTY_STORAGE, r as compatibleSecrets, i as defaultVault, a as withDefaultVault };
|
|
@@ -42,6 +42,22 @@ export interface CreatedConnection {
|
|
|
42
42
|
/** The service's status enum, e.g. `ACTIVE`. */
|
|
43
43
|
status: string;
|
|
44
44
|
provider: ConnectionProvider;
|
|
45
|
+
/** The signed-in account, when the service knows it (OAuth). */
|
|
46
|
+
externalAccountEmail?: string | null;
|
|
47
|
+
externalAccountName?: string | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* An existing connection to sign in to again (Reconnect, BOFF-11875). The
|
|
51
|
+
* dialog runs the same sign-in on this record instead of creating a new one,
|
|
52
|
+
* so its id — and every workflow step that uses it — stays the same.
|
|
53
|
+
*/
|
|
54
|
+
export interface ConnectionReconnectTarget {
|
|
55
|
+
connectionId: string;
|
|
56
|
+
/** The connection's current name, kept as it is. */
|
|
57
|
+
name: string;
|
|
58
|
+
providerId: string;
|
|
59
|
+
/** The sign-in method it was made with; the provider's default when unknown. */
|
|
60
|
+
authMethodKey?: string | null;
|
|
45
61
|
}
|
|
46
62
|
/** Storage modes a method permits for its credential. */
|
|
47
63
|
export type CredentialStorageMode = 'managed' | 'existing';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Translator } from '../credentials/translate';
|
|
2
|
-
import { ConnectionsApi } from './api';
|
|
2
|
+
import { ConnectionRecord, ConnectionsApi } from './api';
|
|
3
3
|
import { ConnectionDraft } from './connectionFlow';
|
|
4
4
|
import { ConnectionDialogEvent, CreatedConnection } from './types';
|
|
5
5
|
interface UseConnectionSubmitOptions {
|
|
@@ -9,13 +9,49 @@ interface UseConnectionSubmitOptions {
|
|
|
9
9
|
onConnectionCreated?: (connection: CreatedConnection) => void;
|
|
10
10
|
onError?: (error: Error) => void;
|
|
11
11
|
onEvent?: (event: ConnectionDialogEvent) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Sign in again on this existing connection instead of creating one
|
|
14
|
+
* (Reconnect). The record keeps its id, so nothing that uses it breaks.
|
|
15
|
+
*/
|
|
16
|
+
reconnectConnection?: ConnectionRecord | null;
|
|
12
17
|
}
|
|
13
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The connection the last attempt created, and the create input that made it.
|
|
20
|
+
* A retry with the same input signs in on that record instead of creating
|
|
21
|
+
* another "not finished" one (BOFF-11875).
|
|
22
|
+
*/
|
|
23
|
+
export interface PreviousAttempt {
|
|
24
|
+
inputKey: string;
|
|
25
|
+
connection: ConnectionRecord;
|
|
26
|
+
/** Whether `connection-created` went out for it yet. */
|
|
27
|
+
announced: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** The create input as a stable string, or null when the draft cannot build one. */
|
|
30
|
+
export declare function createInputKey(draft: ConnectionDraft): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* The record an attempt signs in on instead of creating one: the connection
|
|
33
|
+
* being reconnected, else the last attempt's record when this draft would
|
|
34
|
+
* create exactly the same connection. Anything changed (another app, method,
|
|
35
|
+
* name, client id, storage…) creates a new one.
|
|
36
|
+
*/
|
|
37
|
+
export declare function reusableRecord(reconnect: ConnectionRecord | null | undefined, previous: Pick<PreviousAttempt, 'inputKey' | 'connection'> | null, inputKey: string | null): ConnectionRecord | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Whether `connection-created` goes out for the record an attempt reached:
|
|
40
|
+
* never for a reconnect (that record already existed); for a record this
|
|
41
|
+
* dialog created, once — on the first attempt that gets this far, even if an
|
|
42
|
+
* earlier one failed before announcing it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function shouldAnnounce(connectionId: string, previous: PreviousAttempt | null, reconnect: ConnectionRecord | null | undefined): boolean;
|
|
45
|
+
export declare function useConnectionSubmit({ api, callbackUrl, translate: tr, onConnectionCreated, onError, onEvent, reconnectConnection, }: UseConnectionSubmitOptions): {
|
|
14
46
|
submit: (draft: ConnectionDraft, scopes: string[] | undefined) => Promise<void>;
|
|
15
47
|
busy: boolean;
|
|
16
48
|
oauthWaiting: boolean;
|
|
17
49
|
errorMessage: string;
|
|
18
50
|
setErrorMessage: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
19
51
|
created: CreatedConnection | null;
|
|
52
|
+
/** True while a sign-in window the browser blocked can be opened with a click. */
|
|
53
|
+
signInBlocked: boolean;
|
|
54
|
+
openBlockedSignIn: () => void;
|
|
55
|
+
cancelSignIn: () => void;
|
|
20
56
|
};
|
|
21
57
|
export {};
|
|
@@ -1,98 +1,142 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { waitForOAuthCompletion as
|
|
3
|
-
import { useCallback as
|
|
1
|
+
import { buildCreateInput as e, submitConnection as t, validateDraft as n } from "./connectionFlow.js";
|
|
2
|
+
import { waitForOAuthCompletion as r } from "./oauthPopup.js";
|
|
3
|
+
import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
|
|
4
4
|
// src/connections/useConnectionSubmit.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
function c(t) {
|
|
6
|
+
try {
|
|
7
|
+
return JSON.stringify(e(t));
|
|
8
|
+
} catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
9
11
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
function l(e, t, n) {
|
|
13
|
+
if (e) return e;
|
|
14
|
+
if (t && n !== null && t.inputKey === n) return t.connection;
|
|
15
|
+
}
|
|
16
|
+
function u(e, t, n) {
|
|
17
|
+
return n ? !1 : t && t.connection.id === e ? !t.announced : !0;
|
|
18
|
+
}
|
|
19
|
+
var d = 600, f = 700;
|
|
20
|
+
function p(e) {
|
|
21
|
+
let t = window.screenX + (window.innerWidth - d) / 2, n = window.screenY + (window.innerHeight - f) / 2;
|
|
22
|
+
return window.open(e, "oauth_popup", `width=${d},height=${f},left=${t},top=${n},toolbar=no,menubar=no,scrollbars=yes,resizable=yes`);
|
|
23
|
+
}
|
|
24
|
+
function m({ api: e, callbackUrl: d, translate: f, onConnectionCreated: m, onError: h, onEvent: g, reconnectConnection: _ }) {
|
|
25
|
+
let [v, y] = s(!1), [b, x] = s(!1), [S, C] = s(""), [w, T] = s(null), [E, D] = s(null), O = o(null), k = o(null), A = o(null);
|
|
26
|
+
a(() => () => {
|
|
27
|
+
O.current?.(), k.current && !k.current.closed && k.current.close();
|
|
28
|
+
}, []);
|
|
29
|
+
let j = i((e) => {
|
|
30
|
+
A.current = null, D(null), T(e), m?.(e);
|
|
31
|
+
}, [m]), M = i((e) => {
|
|
32
|
+
C(e), h?.(Error(e));
|
|
33
|
+
}, [h]), N = i((t, n, i) => {
|
|
34
|
+
k.current = n, D(null), x(!0), g?.({
|
|
35
|
+
type: "oauth-started",
|
|
36
|
+
connectionId: t,
|
|
37
|
+
providerKey: i.key
|
|
38
|
+
}), O.current?.(), O.current = r({
|
|
39
|
+
connectionId: t,
|
|
40
|
+
popup: n,
|
|
41
|
+
fetchConnection: () => e.getConnection(t),
|
|
42
|
+
onSuccess: (e) => j({
|
|
43
|
+
...e,
|
|
44
|
+
provider: i
|
|
45
|
+
}),
|
|
46
|
+
onError: (e) => {
|
|
47
|
+
g?.({
|
|
48
|
+
type: "oauth-failed",
|
|
49
|
+
connectionId: t,
|
|
50
|
+
providerKey: i.key,
|
|
51
|
+
error: e
|
|
52
|
+
}), M(e);
|
|
53
|
+
},
|
|
54
|
+
onSettled: () => {
|
|
55
|
+
O.current = null, k.current = null, x(!1);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}, [
|
|
59
|
+
e,
|
|
60
|
+
g,
|
|
61
|
+
j,
|
|
62
|
+
M
|
|
63
|
+
]), P = i(() => {
|
|
64
|
+
if (!E) return;
|
|
65
|
+
let e = p(E.redirectUrl);
|
|
66
|
+
e && (C(""), N(E.connectionId, e, E.provider));
|
|
67
|
+
}, [E, N]), F = i(() => {
|
|
68
|
+
O.current?.(), O.current = null, k.current && !k.current.closed && k.current.close(), k.current = null, x(!1);
|
|
14
69
|
}, []);
|
|
15
|
-
let w = r((e) => {
|
|
16
|
-
x(e), d?.(e);
|
|
17
|
-
}, [d]), T = r((e) => {
|
|
18
|
-
y(e), f?.(Error(e));
|
|
19
|
-
}, [f]);
|
|
20
70
|
return {
|
|
21
|
-
submit:
|
|
22
|
-
if (
|
|
23
|
-
let a =
|
|
71
|
+
submit: i(async (r, i) => {
|
|
72
|
+
if (v || b) return;
|
|
73
|
+
let a = n(r, f);
|
|
24
74
|
if (a) {
|
|
25
|
-
|
|
75
|
+
C(a);
|
|
26
76
|
return;
|
|
27
77
|
}
|
|
28
78
|
let { provider: o } = r;
|
|
29
|
-
|
|
79
|
+
C(""), D(null), y(!0);
|
|
80
|
+
let s = _ ? null : c(r), m = l(_, A.current, s);
|
|
30
81
|
try {
|
|
31
|
-
let
|
|
32
|
-
redirectUri:
|
|
33
|
-
scopes: i
|
|
82
|
+
let n = await t(e, r, {
|
|
83
|
+
redirectUri: d,
|
|
84
|
+
scopes: i,
|
|
85
|
+
existing: m,
|
|
86
|
+
onCreated: (e) => {
|
|
87
|
+
s !== null && (A.current = {
|
|
88
|
+
inputKey: s,
|
|
89
|
+
connection: e,
|
|
90
|
+
announced: !1
|
|
91
|
+
});
|
|
92
|
+
}
|
|
34
93
|
});
|
|
35
|
-
if (
|
|
94
|
+
if (u(n.connection.id, A.current, _) && (A.current?.connection.id === n.connection.id && (A.current.announced = !0), g?.({
|
|
36
95
|
type: "connection-created",
|
|
37
|
-
connectionId:
|
|
96
|
+
connectionId: n.connection.id,
|
|
38
97
|
providerKey: o.key
|
|
39
|
-
}),
|
|
40
|
-
|
|
41
|
-
...
|
|
98
|
+
})), n.kind === "done") {
|
|
99
|
+
j({
|
|
100
|
+
...n.connection,
|
|
42
101
|
provider: o
|
|
43
102
|
});
|
|
44
103
|
return;
|
|
45
104
|
}
|
|
46
|
-
let a =
|
|
105
|
+
let a = p(n.redirectUrl);
|
|
47
106
|
if (!a) {
|
|
48
|
-
|
|
107
|
+
D({
|
|
108
|
+
connectionId: n.connection.id,
|
|
109
|
+
redirectUrl: n.redirectUrl,
|
|
110
|
+
provider: o
|
|
111
|
+
}), M(f("integrations.addConnection.authentication.popupBlocked", "Popup was blocked. Please allow popups for this site and try again.", { provider: o.name }));
|
|
49
112
|
return;
|
|
50
113
|
}
|
|
51
|
-
|
|
52
|
-
C.current = a, _(!0), p?.({
|
|
53
|
-
type: "oauth-started",
|
|
54
|
-
connectionId: d,
|
|
55
|
-
providerKey: o.key
|
|
56
|
-
}), S.current?.(), S.current = n({
|
|
57
|
-
connectionId: d,
|
|
58
|
-
popup: a,
|
|
59
|
-
fetchConnection: () => s.getConnection(d),
|
|
60
|
-
onSuccess: (e) => w({
|
|
61
|
-
...e,
|
|
62
|
-
provider: o
|
|
63
|
-
}),
|
|
64
|
-
onError: (e) => {
|
|
65
|
-
p?.({
|
|
66
|
-
type: "oauth-failed",
|
|
67
|
-
connectionId: d,
|
|
68
|
-
providerKey: o.key,
|
|
69
|
-
error: e
|
|
70
|
-
}), T(e);
|
|
71
|
-
},
|
|
72
|
-
onSettled: () => {
|
|
73
|
-
S.current = null, C.current = null, _(!1);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
114
|
+
N(n.connection.id, a, o);
|
|
76
115
|
} catch (e) {
|
|
77
|
-
|
|
116
|
+
M(e instanceof Error ? e.message : f("integrations.addConnection.errors.authFailed", "Authentication failed"));
|
|
78
117
|
} finally {
|
|
79
|
-
|
|
118
|
+
y(!1);
|
|
80
119
|
}
|
|
81
120
|
}, [
|
|
82
|
-
|
|
121
|
+
v,
|
|
122
|
+
b,
|
|
123
|
+
f,
|
|
124
|
+
e,
|
|
125
|
+
d,
|
|
83
126
|
g,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
w,
|
|
89
|
-
T
|
|
127
|
+
j,
|
|
128
|
+
M,
|
|
129
|
+
N,
|
|
130
|
+
_
|
|
90
131
|
]),
|
|
91
|
-
busy:
|
|
92
|
-
oauthWaiting:
|
|
93
|
-
errorMessage:
|
|
94
|
-
setErrorMessage:
|
|
95
|
-
created:
|
|
132
|
+
busy: v || b,
|
|
133
|
+
oauthWaiting: b,
|
|
134
|
+
errorMessage: S,
|
|
135
|
+
setErrorMessage: C,
|
|
136
|
+
created: w,
|
|
137
|
+
signInBlocked: E !== null,
|
|
138
|
+
openBlockedSignIn: P,
|
|
139
|
+
cancelSignIn: F
|
|
96
140
|
};
|
|
97
141
|
}
|
|
98
|
-
export { u as useConnectionSubmit };
|
|
142
|
+
export { c as createInputKey, l as reusableRecord, u as shouldAnnounce, m as useConnectionSubmit };
|
package/dist/connections.js
CHANGED
|
@@ -8,13 +8,14 @@ import { principalKey as l, resourceShareInput as u, useResourceSharingDraft as
|
|
|
8
8
|
import { VisibilityChoice as f } from "./connections/VisibilityChoice.js";
|
|
9
9
|
import { SHARE_PICKER_LIMIT as p, canManageSharing as m, createConnectionSharingApi as h, createSharePrincipalLister as g, mapConnectionSharing as _ } from "./connections/sharingApi.js";
|
|
10
10
|
import { CredentialStorageSelector as v } from "./connections/CredentialStorageSelector.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
11
|
+
import { CONNECT_MORE_OPTIONS_KEY as y, OneScreenConnectionForm as b } from "./connections/OneScreenConnectionForm.js";
|
|
12
|
+
import { EMPTY_STORAGE as x, compatibleSecrets as S, defaultVault as C, withDefaultVault as w } from "./connections/storage.js";
|
|
13
|
+
import { POPULAR_PROVIDER_KEYS as T, groupByCategory as E, isPopularProvider as D, needsAdminSetup as O, pickableProviders as k, popularFirst as A } from "./connections/picker.js";
|
|
14
|
+
import { ScopePicker as j } from "./connections/ScopePicker.js";
|
|
15
|
+
import { createConnectionsApi as M, mapProvider as N, normalizeAuthType as P } from "./connections/api.js";
|
|
16
|
+
import { buildCreateInput as F, collectsOwnClientId as I, flowForAuthType as L, resolveFlow as R, resolveMethod as z, resolveSchema as B, submitConnection as V, submittedValues as H, validateDraft as U } from "./connections/connectionFlow.js";
|
|
17
|
+
import { isOAuthCallbackMessage as W, waitForOAuthCompletion as G } from "./connections/oauthPopup.js";
|
|
18
|
+
import { getProviderAccent as K, getProviderIconName as q, getProviderImageSource as J, getProviderTextIcon as Y, normalizeProviderCategory as X } from "./connections/providerIdentity.js";
|
|
19
|
+
import { isScopeChecked as Z, parseScopeOptions as Q, requestedScopes as $, toggleScope as ee } from "./connections/scopes.js";
|
|
20
|
+
import { authTypeLabel as te, categoryLabel as ne } from "./connections/labels.js";
|
|
21
|
+
export { t as CONNECTION_DIALOG_FRAME_CLASSES, y as CONNECT_MORE_OPTIONS_KEY, e as ConnectionDialog, v as CredentialStorageSelector, x as EMPTY_STORAGE, b as OneScreenConnectionForm, T as POPULAR_PROVIDER_KEYS, n as ProviderIcon, s as ResourceShareDialog, c as ResourceSharePanel, p as SHARE_PICKER_LIMIT, r as SHARE_TITLE_ID, j as ScopePicker, i as ShareConnectionDialog, f as VisibilityChoice, te as authTypeLabel, F as buildCreateInput, m as canManageSharing, ne as categoryLabel, I as collectsOwnClientId, S as compatibleSecrets, a as connectionShareCopy, o as connectionVisibilityCopy, h as createConnectionSharingApi, M as createConnectionsApi, g as createSharePrincipalLister, C as defaultVault, L as flowForAuthType, K as getProviderAccent, q as getProviderIconName, J as getProviderImageSource, Y as getProviderTextIcon, E as groupByCategory, W as isOAuthCallbackMessage, D as isPopularProvider, Z as isScopeChecked, _ as mapConnectionSharing, N as mapProvider, O as needsAdminSetup, P as normalizeAuthType, X as normalizeProviderCategory, Q as parseScopeOptions, k as pickableProviders, A as popularFirst, l as principalKey, $ as requestedScopes, R as resolveFlow, z as resolveMethod, B as resolveSchema, u as resourceShareInput, V as submitConnection, H as submittedValues, ee as toggleScope, d as useResourceSharingDraft, U as validateDraft, G as waitForOAuthCompletion, w as withDefaultVault };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { Translator } from './translate';
|
|
3
|
-
import { FormSchema } from './types';
|
|
3
|
+
import { FormSchema, SchemaFormPart } from './types';
|
|
4
4
|
interface SchemaFormProps {
|
|
5
5
|
schema: FormSchema;
|
|
6
6
|
values: Record<string, unknown>;
|
|
@@ -10,6 +10,12 @@ interface SchemaFormProps {
|
|
|
10
10
|
idPrefix?: string;
|
|
11
11
|
/** Host translator; English when omitted. */
|
|
12
12
|
translate?: Translator;
|
|
13
|
+
/**
|
|
14
|
+
* Render one part of a split form: `primary` (required fields and notices)
|
|
15
|
+
* or `more` (the optional and `advanced` fields). Default `all` renders
|
|
16
|
+
* every field, as every surface did before.
|
|
17
|
+
*/
|
|
18
|
+
part?: SchemaFormPart;
|
|
13
19
|
}
|
|
14
20
|
export declare const SchemaForm: FC<SchemaFormProps>;
|
|
15
21
|
export {};
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { englishTranslator as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { Eye as
|
|
5
|
-
import { jsx as
|
|
1
|
+
import { isInFormPart as e, isVisible as t, normalizeOptions as n } from "./schema.js";
|
|
2
|
+
import { englishTranslator as r } from "./translate.js";
|
|
3
|
+
import { useState as i } from "react";
|
|
4
|
+
import { Eye as a, EyeOff as o, Info as s } from "lucide-react";
|
|
5
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
6
|
// src/credentials/SchemaForm.tsx
|
|
7
|
-
var
|
|
8
|
-
let
|
|
9
|
-
return /* @__PURE__ */
|
|
7
|
+
var u = typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("-webkit-text-security", "disc"), d = ({ schema: n, values: i, onChange: a, disabled: o, idPrefix: s = "schema", translate: l = r, part: u = "all" }) => {
|
|
8
|
+
let d = new Set(n.required);
|
|
9
|
+
return /* @__PURE__ */ c("div", {
|
|
10
10
|
className: "space-y-3",
|
|
11
|
-
children: Object.entries(
|
|
12
|
-
id: `${
|
|
11
|
+
children: Object.entries(n.properties).filter(([r, a]) => e(r, a, n, u) && t(a, i, n)).map(([e, t]) => /* @__PURE__ */ c(f, {
|
|
12
|
+
id: `${s}-${e}`,
|
|
13
13
|
name: e,
|
|
14
14
|
property: t,
|
|
15
|
-
value:
|
|
16
|
-
required:
|
|
17
|
-
disabled:
|
|
18
|
-
translate:
|
|
19
|
-
onChange: (t) =>
|
|
20
|
-
...
|
|
15
|
+
value: i[e],
|
|
16
|
+
required: d.has(e),
|
|
17
|
+
disabled: o,
|
|
18
|
+
translate: l,
|
|
19
|
+
onChange: (t) => a({
|
|
20
|
+
...i,
|
|
21
21
|
[e]: t
|
|
22
22
|
})
|
|
23
23
|
}, e))
|
|
24
24
|
});
|
|
25
|
-
},
|
|
26
|
-
let [g, _] =
|
|
27
|
-
if (
|
|
25
|
+
}, f = ({ id: e, name: t, property: r, value: d, required: f, disabled: p, translate: m, onChange: h }) => {
|
|
26
|
+
let [g, _] = i(!1), [v, y] = i(!1), b = r.title ?? t, x = r.placeholder ?? r.description ?? "";
|
|
27
|
+
if (r.type === "notice") return /* @__PURE__ */ l("div", {
|
|
28
28
|
className: "flex items-start gap-2 px-3 py-2 rounded-md bg-status-info-bg-subtle border border-border-default",
|
|
29
|
-
children: [/* @__PURE__ */ s
|
|
29
|
+
children: [/* @__PURE__ */ c(s, {
|
|
30
30
|
size: 14,
|
|
31
31
|
className: "text-status-info-text flex-shrink-0 mt-0.5"
|
|
32
|
-
}), /* @__PURE__ */
|
|
32
|
+
}), /* @__PURE__ */ c("span", {
|
|
33
33
|
className: "text-xs text-status-info-text",
|
|
34
|
-
children:
|
|
34
|
+
children: r.description ?? b
|
|
35
35
|
})]
|
|
36
36
|
});
|
|
37
|
-
let S =
|
|
37
|
+
let S = r.description ? /* @__PURE__ */ c("p", {
|
|
38
38
|
className: "mt-1 text-xs text-text-secondary",
|
|
39
|
-
children:
|
|
40
|
-
}) : null, C = /* @__PURE__ */
|
|
39
|
+
children: r.description
|
|
40
|
+
}) : null, C = /* @__PURE__ */ l("label", {
|
|
41
41
|
htmlFor: e,
|
|
42
42
|
className: "block text-sm font-medium text-text-primary mb-1.5",
|
|
43
43
|
children: [
|
|
44
44
|
b,
|
|
45
45
|
" ",
|
|
46
|
-
f && /* @__PURE__ */
|
|
46
|
+
f && /* @__PURE__ */ c("span", {
|
|
47
47
|
className: "text-status-error-text",
|
|
48
48
|
children: "*"
|
|
49
49
|
})
|
|
50
50
|
]
|
|
51
51
|
}), w = "w-full px-3 py-2 border border-border-subtle rounded-md bg-bg-surface text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50";
|
|
52
|
-
if (
|
|
53
|
-
let t = !!(d ??
|
|
54
|
-
return /* @__PURE__ */
|
|
52
|
+
if (r.type === "boolean") {
|
|
53
|
+
let t = !!(d ?? r.default ?? !1);
|
|
54
|
+
return /* @__PURE__ */ l("div", {
|
|
55
55
|
className: "flex items-center gap-3",
|
|
56
|
-
children: [/* @__PURE__ */
|
|
56
|
+
children: [/* @__PURE__ */ c("button", {
|
|
57
57
|
type: "button",
|
|
58
58
|
role: "switch",
|
|
59
59
|
id: e,
|
|
@@ -62,38 +62,38 @@ var l = typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("-
|
|
|
62
62
|
onClick: () => h(!t),
|
|
63
63
|
disabled: p,
|
|
64
64
|
className: `relative inline-flex h-5 w-9 items-center rounded-full transition-colors disabled:opacity-50 ${t ? "bg-primary" : "bg-bg-muted"}`,
|
|
65
|
-
children: /* @__PURE__ */
|
|
66
|
-
}), /* @__PURE__ */
|
|
65
|
+
children: /* @__PURE__ */ c("span", { className: `inline-block h-3.5 w-3.5 transform rounded-full bg-bg-surface transition-transform ${t ? "translate-x-4.5" : "translate-x-0.5"}` })
|
|
66
|
+
}), /* @__PURE__ */ l("span", {
|
|
67
67
|
className: "text-sm font-medium text-text-primary",
|
|
68
|
-
children: [b,
|
|
68
|
+
children: [b, r.description && /* @__PURE__ */ l("span", {
|
|
69
69
|
className: "text-text-secondary font-normal ms-1",
|
|
70
|
-
children: ["— ",
|
|
70
|
+
children: ["— ", r.description]
|
|
71
71
|
})]
|
|
72
72
|
})]
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
if (
|
|
75
|
+
if (r.enum && r.enum.length > 0) return /* @__PURE__ */ l("div", { children: [
|
|
76
76
|
C,
|
|
77
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ l("select", {
|
|
78
78
|
id: e,
|
|
79
79
|
"aria-label": b,
|
|
80
|
-
value: String(d ??
|
|
80
|
+
value: String(d ?? r.default ?? ""),
|
|
81
81
|
onChange: (e) => h(e.target.value),
|
|
82
82
|
disabled: p,
|
|
83
83
|
className: `${w} scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary`,
|
|
84
|
-
children: [/* @__PURE__ */
|
|
84
|
+
children: [/* @__PURE__ */ c("option", {
|
|
85
85
|
value: "",
|
|
86
86
|
children: m("integrations.schemaForm.select", "Select {{label}}", { label: b.toLowerCase() })
|
|
87
|
-
}),
|
|
87
|
+
}), n(r.enum).map((e) => /* @__PURE__ */ c("option", {
|
|
88
88
|
value: e.value,
|
|
89
89
|
children: e.label
|
|
90
90
|
}, e.value))]
|
|
91
91
|
}),
|
|
92
92
|
S
|
|
93
93
|
] });
|
|
94
|
-
if (
|
|
94
|
+
if (r.type === "number") return /* @__PURE__ */ l("div", { children: [
|
|
95
95
|
C,
|
|
96
|
-
/* @__PURE__ */
|
|
96
|
+
/* @__PURE__ */ c("input", {
|
|
97
97
|
id: e,
|
|
98
98
|
"aria-label": b,
|
|
99
99
|
type: "number",
|
|
@@ -105,35 +105,35 @@ var l = typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("-
|
|
|
105
105
|
}),
|
|
106
106
|
S
|
|
107
107
|
] });
|
|
108
|
-
if (
|
|
109
|
-
let t = !!
|
|
110
|
-
return t && !
|
|
108
|
+
if (r.format === "textarea" || r.format === "json") {
|
|
109
|
+
let t = !!r.secret && !g, n = typeof d == "string" && d.length > 0;
|
|
110
|
+
return t && !u && n && !v ? /* @__PURE__ */ l("div", { children: [
|
|
111
111
|
C,
|
|
112
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ l("div", {
|
|
113
113
|
className: "flex items-center justify-between gap-2 px-3 py-2 border border-border-subtle rounded-md bg-bg-surface",
|
|
114
|
-
children: [/* @__PURE__ */
|
|
114
|
+
children: [/* @__PURE__ */ c("span", {
|
|
115
115
|
className: "text-sm font-mono text-text-secondary select-none",
|
|
116
116
|
children: "••••••••••••"
|
|
117
|
-
}), /* @__PURE__ */
|
|
117
|
+
}), /* @__PURE__ */ l("button", {
|
|
118
118
|
type: "button",
|
|
119
119
|
onClick: () => _(!0),
|
|
120
120
|
disabled: p,
|
|
121
121
|
"aria-label": m("integrations.schemaForm.reveal", "Show {{label}}", { label: b }),
|
|
122
122
|
className: "inline-flex items-center gap-1 text-xs text-primary hover:underline disabled:opacity-50",
|
|
123
123
|
children: [
|
|
124
|
-
/* @__PURE__ */
|
|
124
|
+
/* @__PURE__ */ c(a, { size: 14 }),
|
|
125
125
|
" ",
|
|
126
126
|
m("integrations.schemaForm.revealToEdit", "Reveal to edit")
|
|
127
127
|
]
|
|
128
128
|
})]
|
|
129
129
|
}),
|
|
130
130
|
S
|
|
131
|
-
] }) : /* @__PURE__ */
|
|
131
|
+
] }) : /* @__PURE__ */ l("div", { children: [
|
|
132
132
|
C,
|
|
133
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ l("div", {
|
|
134
134
|
className: "relative",
|
|
135
|
-
...
|
|
136
|
-
children: [/* @__PURE__ */
|
|
135
|
+
...r.secret ? { "data-agent-sensitive": "" } : {},
|
|
136
|
+
children: [/* @__PURE__ */ c("textarea", {
|
|
137
137
|
id: e,
|
|
138
138
|
"aria-label": b,
|
|
139
139
|
value: String(d ?? ""),
|
|
@@ -146,42 +146,42 @@ var l = typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("-
|
|
|
146
146
|
autoComplete: "off",
|
|
147
147
|
spellCheck: !1,
|
|
148
148
|
style: t ? { WebkitTextSecurity: "disc" } : void 0,
|
|
149
|
-
className: `${w} font-mono ${
|
|
150
|
-
}),
|
|
149
|
+
className: `${w} font-mono ${r.secret ? "pe-10" : ""}`
|
|
150
|
+
}), r.secret && /* @__PURE__ */ c("button", {
|
|
151
151
|
type: "button",
|
|
152
152
|
onClick: () => _((e) => !e),
|
|
153
153
|
"aria-label": g ? m("integrations.schemaForm.hide", "Hide {{label}}", { label: b }) : m("integrations.schemaForm.reveal", "Show {{label}}", { label: b }),
|
|
154
154
|
className: "absolute end-2 top-2 text-text-secondary hover:text-text-primary",
|
|
155
|
-
children:
|
|
155
|
+
children: c(g ? o : a, { size: 16 })
|
|
156
156
|
})]
|
|
157
157
|
}),
|
|
158
158
|
S
|
|
159
159
|
] });
|
|
160
160
|
}
|
|
161
|
-
return /* @__PURE__ */
|
|
161
|
+
return /* @__PURE__ */ l("div", { children: [
|
|
162
162
|
C,
|
|
163
|
-
/* @__PURE__ */
|
|
163
|
+
/* @__PURE__ */ l("div", {
|
|
164
164
|
className: "relative",
|
|
165
|
-
...
|
|
166
|
-
children: [/* @__PURE__ */
|
|
165
|
+
...r.secret ? { "data-agent-sensitive": "" } : {},
|
|
166
|
+
children: [/* @__PURE__ */ c("input", {
|
|
167
167
|
id: e,
|
|
168
168
|
"aria-label": b,
|
|
169
|
-
type:
|
|
169
|
+
type: r.secret && !g ? "password" : "text",
|
|
170
170
|
value: String(d ?? ""),
|
|
171
171
|
onChange: (e) => h(e.target.value),
|
|
172
172
|
placeholder: x,
|
|
173
173
|
disabled: p,
|
|
174
174
|
autoComplete: "off",
|
|
175
|
-
className: `${w} ${
|
|
176
|
-
}),
|
|
175
|
+
className: `${w} ${r.secret ? "font-mono pe-10" : ""}`
|
|
176
|
+
}), r.secret && /* @__PURE__ */ c("button", {
|
|
177
177
|
type: "button",
|
|
178
178
|
onClick: () => _((e) => !e),
|
|
179
179
|
"aria-label": g ? m("integrations.schemaForm.hide", "Hide {{label}}", { label: b }) : m("integrations.schemaForm.reveal", "Show {{label}}", { label: b }),
|
|
180
180
|
className: "absolute end-2 top-1/2 -translate-y-1/2 text-text-secondary hover:text-text-primary",
|
|
181
|
-
children:
|
|
181
|
+
children: c(g ? o : a, { size: 16 })
|
|
182
182
|
})]
|
|
183
183
|
}),
|
|
184
184
|
S
|
|
185
185
|
] });
|
|
186
186
|
};
|
|
187
|
-
export {
|
|
187
|
+
export { d as SchemaForm };
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* catalog change rather than React in each consuming app.
|
|
9
9
|
*/
|
|
10
10
|
export { SchemaForm } from './SchemaForm';
|
|
11
|
-
export { parseFormSchema, isSchemaComplete, initialValuesFromSchema, visibleValues, } from './schema';
|
|
11
|
+
export { parseFormSchema, isSchemaComplete, initialValuesFromSchema, visibleValues, isInFormPart, hasFieldsInPart, } from './schema';
|
|
12
12
|
export { AuthMethodSelector, AuthMethodNotice } from './AuthMethodSelector';
|
|
13
13
|
export { resolveSelectedMethod } from './methods';
|
|
14
14
|
export { englishTranslator, interpolate, type Translator } from './translate';
|
|
15
|
-
export type { AuthMethodFlow, AuthMethodLike, FormSchema, SchemaProperty } from './types';
|
|
15
|
+
export type { AuthMethodFlow, AuthMethodLike, FormSchema, SchemaFormPart, SchemaProperty, } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormSchema, SchemaProperty } from './types';
|
|
1
|
+
import { FormSchema, SchemaFormPart, SchemaProperty } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Narrow an arbitrary JSON value to a renderable schema. Returns null when the
|
|
4
4
|
* value isn't a usable object schema, so callers can fall back rather than
|
|
@@ -11,6 +11,16 @@ export declare function parseFormSchema(raw: unknown): FormSchema | null;
|
|
|
11
11
|
* revealed by a toggle) need no bespoke component.
|
|
12
12
|
*/
|
|
13
13
|
export declare function isVisible(property: SchemaProperty, values: Record<string, unknown>, schema?: FormSchema, seen?: ReadonlySet<string>): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a field belongs to one part of a split form (Navigation v2's
|
|
16
|
+
* one-screen connect form). The everyday part holds the required fields and
|
|
17
|
+
* informational notices; every optional field, and anything flagged
|
|
18
|
+
* `advanced` that is not required, sits under "More options". `all` keeps the
|
|
19
|
+
* single form every other surface renders.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isInFormPart(field: string, property: SchemaProperty, schema: FormSchema, part: SchemaFormPart): boolean;
|
|
22
|
+
/** Whether a split form has anything to render in this part. */
|
|
23
|
+
export declare function hasFieldsInPart(schema: FormSchema, values: Record<string, unknown>, part: SchemaFormPart): boolean;
|
|
14
24
|
/**
|
|
15
25
|
* Required fields that are visible and filled. Hidden fields are excluded on
|
|
16
26
|
* purpose — a `showIf` field the user never saw must not block submission.
|