@burdenoff/microfe-integrations 2026.807.2 → 2026.810.2
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/generated/wspace-operations.d.ts +36 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -1
- package/dist/generated/wspace-operations.js +98 -81
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/integrations/components/AddConnectionDialog.d.ts.map +1 -1
- package/dist/integrations/components/AddConnectionDialog.js +231 -201
- package/dist/integrations/components/AddConnectionDialog.js.map +1 -1
- package/dist/integrations/components/AuthMethodSelector.d.ts +17 -0
- package/dist/integrations/components/AuthMethodSelector.d.ts.map +1 -1
- package/dist/integrations/components/AuthMethodSelector.js +45 -36
- package/dist/integrations/components/AuthMethodSelector.js.map +1 -1
- package/dist/integrations/components/CredentialStorageSelector.d.ts.map +1 -1
- package/dist/integrations/components/CredentialStorageSelector.js +151 -59
- package/dist/integrations/components/CredentialStorageSelector.js.map +1 -1
- package/dist/integrations/components/SchemaForm.d.ts.map +1 -1
- package/dist/integrations/components/SchemaForm.js +100 -59
- package/dist/integrations/components/SchemaForm.js.map +1 -1
- package/dist/integrations/constants/permissions.d.ts +1 -0
- package/dist/integrations/constants/permissions.d.ts.map +1 -1
- package/dist/integrations/constants/permissions.js +2 -1
- package/dist/integrations/constants/permissions.js.map +1 -1
- package/dist/integrations/hooks/useCredentialVaults.d.ts +19 -0
- package/dist/integrations/hooks/useCredentialVaults.d.ts.map +1 -1
- package/dist/integrations/hooks/useCredentialVaults.js +43 -22
- package/dist/integrations/hooks/useCredentialVaults.js.map +1 -1
- package/dist/integrations/pages/ProviderDetail.d.ts.map +1 -1
- package/dist/integrations/pages/ProviderDetail.js +1 -1
- package/dist/integrations/pages/ProviderDetail.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,83 +1,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { INTEGRATION_PERMISSIONS as e } from "../constants/permissions.js";
|
|
2
|
+
import { useCreateCredentialVault as t, useCredentialVaults as n, useVaultSecrets as r } from "../hooks/useCredentialVaults.js";
|
|
3
|
+
import { useId as i, useState as a } from "react";
|
|
4
|
+
import { AlertCircle as o, Database as s, FolderKey as c, KeyRound as l, Loader2 as u, Plus as d, X as f } from "lucide-react";
|
|
5
|
+
import { usePermissions as p } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
6
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
5
7
|
//#region src/integrations/components/CredentialStorageSelector.tsx
|
|
6
|
-
function
|
|
7
|
-
let { vaults:
|
|
8
|
-
|
|
8
|
+
function _({ value: _, onChange: v, providerAuthType: y }) {
|
|
9
|
+
let { vaults: b, loading: x, refetch: S } = n(), { secrets: C, loading: w } = r(_.vaultId || null, y), { createVault: T, creating: E, error: D, clearError: O } = t(), { hasPermission: k, isLoading: A } = p(), j = !A && k(e.VAULT_CREATE), [M, N] = a(!1), [P, F] = a(""), I = i(), L = `${I}-vault`, R = `${I}-new-vault`, z = `${I}-managed-name`, B = `${I}-existing-secret`, V = () => {
|
|
10
|
+
O(), F(""), N(!0);
|
|
11
|
+
}, H = async () => {
|
|
12
|
+
if (!P.trim()) return;
|
|
13
|
+
let e = await T(P);
|
|
14
|
+
e && (F(""), await S(), v((t) => ({
|
|
15
|
+
...t,
|
|
16
|
+
vaultId: e.id,
|
|
17
|
+
secretId: ""
|
|
18
|
+
})), N(!1));
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ g("div", {
|
|
9
21
|
className: "rounded-xl border border-border-subtle/50 bg-bg-surface p-4 space-y-4",
|
|
10
22
|
children: [
|
|
11
|
-
/* @__PURE__ */
|
|
23
|
+
/* @__PURE__ */ g("div", { children: [/* @__PURE__ */ g("h3", {
|
|
12
24
|
className: "text-sm font-semibold text-text-primary flex items-center gap-2",
|
|
13
|
-
children: [/* @__PURE__ */ s
|
|
25
|
+
children: [/* @__PURE__ */ h(s, {
|
|
14
26
|
size: 16,
|
|
15
27
|
className: "text-primary"
|
|
16
28
|
}), "Credential Storage"]
|
|
17
|
-
}), /* @__PURE__ */
|
|
29
|
+
}), /* @__PURE__ */ h("p", {
|
|
18
30
|
className: "text-xs text-text-secondary mt-1",
|
|
19
31
|
children: "Connections use vault-managed secrets by default. You can also reuse an existing compatible secret."
|
|
20
32
|
})] }),
|
|
21
|
-
/* @__PURE__ */
|
|
33
|
+
/* @__PURE__ */ g("div", {
|
|
22
34
|
className: "grid grid-cols-1 sm:grid-cols-2 gap-3",
|
|
23
|
-
children: [/* @__PURE__ */
|
|
35
|
+
children: [/* @__PURE__ */ g("button", {
|
|
24
36
|
type: "button",
|
|
25
|
-
onClick: () =>
|
|
37
|
+
onClick: () => v((e) => ({
|
|
26
38
|
...e,
|
|
27
39
|
mode: "managed",
|
|
28
40
|
secretId: ""
|
|
29
41
|
})),
|
|
30
|
-
className: `rounded-xl border px-4 py-3 text-left transition-colors ${
|
|
31
|
-
children: [/* @__PURE__ */
|
|
42
|
+
className: `rounded-xl border px-4 py-3 text-left transition-colors ${_.mode === "managed" ? "border-primary bg-action-primary-bg/5" : "border-border-subtle hover:border-primary/40 hover:bg-accent/30"}`,
|
|
43
|
+
children: [/* @__PURE__ */ g("div", {
|
|
32
44
|
className: "flex items-center gap-2 text-sm font-medium text-text-primary",
|
|
33
|
-
children: [/* @__PURE__ */
|
|
45
|
+
children: [/* @__PURE__ */ h(c, {
|
|
34
46
|
size: 16,
|
|
35
47
|
className: "text-primary"
|
|
36
48
|
}), "Dedicated secret"]
|
|
37
|
-
}), /* @__PURE__ */
|
|
49
|
+
}), /* @__PURE__ */ h("p", {
|
|
38
50
|
className: "text-xs text-text-secondary mt-1",
|
|
39
51
|
children: "Create and own a vault secret for this connection."
|
|
40
52
|
})]
|
|
41
|
-
}), /* @__PURE__ */
|
|
53
|
+
}), /* @__PURE__ */ g("button", {
|
|
42
54
|
type: "button",
|
|
43
|
-
onClick: () =>
|
|
55
|
+
onClick: () => v((e) => ({
|
|
44
56
|
...e,
|
|
45
57
|
mode: "existing"
|
|
46
58
|
})),
|
|
47
|
-
className: `rounded-xl border px-4 py-3 text-left transition-colors ${
|
|
48
|
-
children: [/* @__PURE__ */
|
|
59
|
+
className: `rounded-xl border px-4 py-3 text-left transition-colors ${_.mode === "existing" ? "border-primary bg-action-primary-bg/5" : "border-border-subtle hover:border-primary/40 hover:bg-accent/30"}`,
|
|
60
|
+
children: [/* @__PURE__ */ g("div", {
|
|
49
61
|
className: "flex items-center gap-2 text-sm font-medium text-text-primary",
|
|
50
|
-
children: [/* @__PURE__ */
|
|
62
|
+
children: [/* @__PURE__ */ h(l, {
|
|
51
63
|
size: 16,
|
|
52
64
|
className: "text-primary"
|
|
53
65
|
}), "Existing secret"]
|
|
54
|
-
}), /* @__PURE__ */
|
|
66
|
+
}), /* @__PURE__ */ h("p", {
|
|
55
67
|
className: "text-xs text-text-secondary mt-1",
|
|
56
68
|
children: "Reference an already stored secret from the vault."
|
|
57
69
|
})]
|
|
58
70
|
})]
|
|
59
71
|
}),
|
|
60
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ g("div", {
|
|
61
73
|
className: "space-y-2",
|
|
62
|
-
children: [/* @__PURE__ */
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
children: [/* @__PURE__ */ g("div", {
|
|
75
|
+
className: "flex items-center justify-between gap-2",
|
|
76
|
+
children: [/* @__PURE__ */ h("label", {
|
|
77
|
+
htmlFor: L,
|
|
78
|
+
className: "block text-xs font-semibold text-text-primary uppercase tracking-wide",
|
|
79
|
+
children: "Vault"
|
|
80
|
+
}), !M && j && /* @__PURE__ */ g("button", {
|
|
81
|
+
type: "button",
|
|
82
|
+
onClick: V,
|
|
83
|
+
className: "inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline",
|
|
84
|
+
children: [/* @__PURE__ */ h(d, { size: 13 }), " New vault"]
|
|
85
|
+
})]
|
|
86
|
+
}), M ? /* @__PURE__ */ g("div", {
|
|
87
|
+
className: "rounded-lg border border-primary/40 bg-action-primary-bg/5 p-3 space-y-2",
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ g("div", {
|
|
90
|
+
className: "flex items-center justify-between gap-2",
|
|
91
|
+
children: [/* @__PURE__ */ h("label", {
|
|
92
|
+
htmlFor: R,
|
|
93
|
+
className: "text-xs font-medium text-text-primary",
|
|
94
|
+
children: "New vault name"
|
|
95
|
+
}), /* @__PURE__ */ h("button", {
|
|
96
|
+
type: "button",
|
|
97
|
+
onClick: () => N(!1),
|
|
98
|
+
"aria-label": "Cancel creating a vault",
|
|
99
|
+
className: "text-text-secondary hover:text-text-primary",
|
|
100
|
+
children: /* @__PURE__ */ h(f, { size: 14 })
|
|
101
|
+
})]
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ h("input", {
|
|
104
|
+
id: R,
|
|
105
|
+
"aria-label": "New vault name",
|
|
106
|
+
type: "text",
|
|
107
|
+
value: P,
|
|
108
|
+
autoFocus: !0,
|
|
109
|
+
onChange: (e) => F(e.target.value),
|
|
110
|
+
onKeyDown: (e) => {
|
|
111
|
+
e.key === "Enter" && (e.preventDefault(), H());
|
|
112
|
+
},
|
|
113
|
+
placeholder: "e.g. Integrations",
|
|
114
|
+
disabled: E,
|
|
115
|
+
className: "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50"
|
|
116
|
+
}),
|
|
117
|
+
D && /* @__PURE__ */ g("p", {
|
|
118
|
+
className: "flex items-center gap-1.5 text-xs text-status-error-text",
|
|
119
|
+
children: [/* @__PURE__ */ h(o, {
|
|
120
|
+
size: 13,
|
|
121
|
+
className: "flex-shrink-0"
|
|
122
|
+
}), D]
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ g("div", {
|
|
125
|
+
className: "flex items-center gap-2",
|
|
126
|
+
children: [/* @__PURE__ */ g("button", {
|
|
127
|
+
type: "button",
|
|
128
|
+
onClick: () => void H(),
|
|
129
|
+
disabled: E || !P.trim(),
|
|
130
|
+
className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:opacity-50",
|
|
131
|
+
children: [E ? /* @__PURE__ */ h(u, {
|
|
132
|
+
size: 13,
|
|
133
|
+
className: "animate-spin"
|
|
134
|
+
}) : /* @__PURE__ */ h(d, { size: 13 }), "Create vault"]
|
|
135
|
+
}), /* @__PURE__ */ h("span", {
|
|
136
|
+
className: "text-xs text-text-secondary",
|
|
137
|
+
children: "Scoped to this workspace."
|
|
138
|
+
})]
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g("div", {
|
|
67
142
|
className: "relative",
|
|
68
|
-
children: [/* @__PURE__ */
|
|
69
|
-
id:
|
|
70
|
-
value:
|
|
71
|
-
onChange: (e) =>
|
|
143
|
+
children: [/* @__PURE__ */ g("select", {
|
|
144
|
+
id: L,
|
|
145
|
+
value: _.vaultId,
|
|
146
|
+
onChange: (e) => v((t) => ({
|
|
72
147
|
...t,
|
|
73
148
|
vaultId: e.target.value,
|
|
74
149
|
secretId: ""
|
|
75
150
|
})),
|
|
76
151
|
className: "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary",
|
|
77
|
-
children: [/* @__PURE__ */
|
|
152
|
+
children: [/* @__PURE__ */ h("option", {
|
|
78
153
|
value: "",
|
|
79
154
|
children: "Select a vault"
|
|
80
|
-
}),
|
|
155
|
+
}), b.map((e) => /* @__PURE__ */ g("option", {
|
|
81
156
|
value: e.id,
|
|
82
157
|
children: [
|
|
83
158
|
e.name,
|
|
@@ -86,60 +161,77 @@ function l({ value: l, onChange: u, providerAuthType: d }) {
|
|
|
86
161
|
")"
|
|
87
162
|
]
|
|
88
163
|
}, e.id))]
|
|
89
|
-
}),
|
|
164
|
+
}), x && /* @__PURE__ */ h(u, {
|
|
90
165
|
size: 16,
|
|
91
166
|
className: "absolute right-3 top-3 animate-spin text-text-secondary"
|
|
92
167
|
})]
|
|
93
|
-
})
|
|
168
|
+
}), !x && b.length === 0 && (j ? /* @__PURE__ */ g("p", {
|
|
169
|
+
className: "text-xs text-text-secondary",
|
|
170
|
+
children: [
|
|
171
|
+
"No vaults yet.",
|
|
172
|
+
" ",
|
|
173
|
+
/* @__PURE__ */ h("button", {
|
|
174
|
+
type: "button",
|
|
175
|
+
onClick: V,
|
|
176
|
+
className: "font-medium text-primary hover:underline",
|
|
177
|
+
children: "Create one"
|
|
178
|
+
}),
|
|
179
|
+
" ",
|
|
180
|
+
"to store this connection’s credentials."
|
|
181
|
+
]
|
|
182
|
+
}) : /* @__PURE__ */ h("p", {
|
|
183
|
+
className: "text-xs text-text-secondary",
|
|
184
|
+
children: "No vaults yet. Ask an administrator to create one — a connection needs a vault to store its credentials."
|
|
185
|
+
}))] })]
|
|
94
186
|
}),
|
|
95
|
-
|
|
187
|
+
_.mode === "managed" ? /* @__PURE__ */ g("div", {
|
|
96
188
|
className: "space-y-2",
|
|
97
189
|
children: [
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
htmlFor:
|
|
190
|
+
/* @__PURE__ */ h("label", {
|
|
191
|
+
htmlFor: z,
|
|
100
192
|
className: "block text-xs font-semibold text-text-primary uppercase tracking-wide",
|
|
101
193
|
children: "Managed secret name"
|
|
102
194
|
}),
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
id:
|
|
195
|
+
/* @__PURE__ */ h("input", {
|
|
196
|
+
id: z,
|
|
105
197
|
"aria-label": "Managed secret name",
|
|
106
198
|
type: "text",
|
|
107
|
-
value:
|
|
108
|
-
onChange: (e) =>
|
|
199
|
+
value: _.managedSecretName,
|
|
200
|
+
onChange: (e) => v((t) => ({
|
|
109
201
|
...t,
|
|
110
202
|
managedSecretName: e.target.value
|
|
111
203
|
})),
|
|
112
204
|
placeholder: "Optional custom vault secret name",
|
|
113
205
|
className: "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"
|
|
114
206
|
}),
|
|
115
|
-
/* @__PURE__ */
|
|
207
|
+
/* @__PURE__ */ h("p", {
|
|
116
208
|
className: "text-xs text-text-secondary",
|
|
117
209
|
children: "Leave empty to auto-generate a secret name from the connection and provider."
|
|
118
210
|
})
|
|
119
211
|
]
|
|
120
|
-
}) : /* @__PURE__ */
|
|
212
|
+
}) : /* @__PURE__ */ g("div", {
|
|
121
213
|
className: "space-y-2",
|
|
122
214
|
children: [
|
|
123
|
-
/* @__PURE__ */
|
|
124
|
-
htmlFor:
|
|
215
|
+
/* @__PURE__ */ h("label", {
|
|
216
|
+
htmlFor: B,
|
|
125
217
|
className: "block text-xs font-semibold text-text-primary uppercase tracking-wide",
|
|
126
218
|
children: "Existing secret"
|
|
127
219
|
}),
|
|
128
|
-
/* @__PURE__ */
|
|
220
|
+
/* @__PURE__ */ g("div", {
|
|
129
221
|
className: "relative",
|
|
130
|
-
children: [/* @__PURE__ */
|
|
131
|
-
id:
|
|
132
|
-
value:
|
|
133
|
-
onChange: (e) =>
|
|
222
|
+
children: [/* @__PURE__ */ g("select", {
|
|
223
|
+
id: B,
|
|
224
|
+
value: _.secretId,
|
|
225
|
+
onChange: (e) => v((t) => ({
|
|
134
226
|
...t,
|
|
135
227
|
secretId: e.target.value
|
|
136
228
|
})),
|
|
137
|
-
disabled: !
|
|
229
|
+
disabled: !_.vaultId,
|
|
138
230
|
className: "w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-60",
|
|
139
|
-
children: [/* @__PURE__ */
|
|
231
|
+
children: [/* @__PURE__ */ h("option", {
|
|
140
232
|
value: "",
|
|
141
233
|
children: "Select an existing secret"
|
|
142
|
-
}),
|
|
234
|
+
}), C.map((e) => /* @__PURE__ */ g("option", {
|
|
143
235
|
value: e.id,
|
|
144
236
|
children: [
|
|
145
237
|
e.name,
|
|
@@ -147,12 +239,12 @@ function l({ value: l, onChange: u, providerAuthType: d }) {
|
|
|
147
239
|
e.type
|
|
148
240
|
]
|
|
149
241
|
}, e.id))]
|
|
150
|
-
}),
|
|
242
|
+
}), w && /* @__PURE__ */ h(u, {
|
|
151
243
|
size: 16,
|
|
152
244
|
className: "absolute right-3 top-3 animate-spin text-text-secondary"
|
|
153
245
|
})]
|
|
154
246
|
}),
|
|
155
|
-
/* @__PURE__ */
|
|
247
|
+
/* @__PURE__ */ h("p", {
|
|
156
248
|
className: "text-xs text-text-secondary",
|
|
157
249
|
children: "For OAuth and basic auth, choose a structured credential secret created for integrations."
|
|
158
250
|
})
|
|
@@ -162,6 +254,6 @@ function l({ value: l, onChange: u, providerAuthType: d }) {
|
|
|
162
254
|
});
|
|
163
255
|
}
|
|
164
256
|
//#endregion
|
|
165
|
-
export {
|
|
257
|
+
export { _ as CredentialStorageSelector };
|
|
166
258
|
|
|
167
259
|
//# sourceMappingURL=CredentialStorageSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialStorageSelector.js","names":[],"sources":["../../../src/integrations/components/CredentialStorageSelector.tsx"],"sourcesContent":["import { useId, type Dispatch, type SetStateAction } from 'react';\nimport { Database, FolderKey, KeyRound, Loader2 } from 'lucide-react';\n\nimport { useCredentialVaults, useVaultSecrets } from '../hooks/useCredentialVaults';\nimport type { VaultSecretSummary, VaultSummary } from '../types';\n\nexport interface CredentialStorageState {\n mode: 'managed' | 'existing';\n vaultId: string;\n secretId: string;\n managedSecretName: string;\n}\n\ninterface CredentialStorageSelectorProps {\n value: CredentialStorageState;\n onChange: Dispatch<SetStateAction<CredentialStorageState>>;\n providerAuthType?: string | null;\n}\n\nexport function CredentialStorageSelector({\n value,\n onChange,\n providerAuthType,\n}: CredentialStorageSelectorProps) {\n const { vaults, loading: vaultsLoading } = useCredentialVaults();\n const { secrets, loading: secretsLoading } = useVaultSecrets(\n value.vaultId || null,\n providerAuthType\n );\n const idPrefix = useId();\n const vaultSelectId = `${idPrefix}-vault`;\n const managedNameId = `${idPrefix}-managed-name`;\n const existingSecretId = `${idPrefix}-existing-secret`;\n\n return (\n <div className=\"rounded-xl border border-border-subtle/50 bg-bg-surface p-4 space-y-4\">\n <div>\n <h3 className=\"text-sm font-semibold text-text-primary flex items-center gap-2\">\n <Database size={16} className=\"text-primary\" />\n Credential Storage\n </h3>\n <p className=\"text-xs text-text-secondary mt-1\">\n Connections use vault-managed secrets by default. You can also reuse an existing\n compatible secret.\n </p>\n </div>\n\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-3\">\n <button\n type=\"button\"\n onClick={() => onChange((current) => ({ ...current, mode: 'managed', secretId: '' }))}\n className={`rounded-xl border px-4 py-3 text-left transition-colors ${\n value.mode === 'managed'\n ? 'border-primary bg-action-primary-bg/5'\n : 'border-border-subtle hover:border-primary/40 hover:bg-accent/30'\n }`}\n >\n <div className=\"flex items-center gap-2 text-sm font-medium text-text-primary\">\n <FolderKey size={16} className=\"text-primary\" />\n Dedicated secret\n </div>\n <p className=\"text-xs text-text-secondary mt-1\">\n Create and own a vault secret for this connection.\n </p>\n </button>\n\n <button\n type=\"button\"\n onClick={() => onChange((current) => ({ ...current, mode: 'existing' }))}\n className={`rounded-xl border px-4 py-3 text-left transition-colors ${\n value.mode === 'existing'\n ? 'border-primary bg-action-primary-bg/5'\n : 'border-border-subtle hover:border-primary/40 hover:bg-accent/30'\n }`}\n >\n <div className=\"flex items-center gap-2 text-sm font-medium text-text-primary\">\n <KeyRound size={16} className=\"text-primary\" />\n Existing secret\n </div>\n <p className=\"text-xs text-text-secondary mt-1\">\n Reference an already stored secret from the vault.\n </p>\n </button>\n </div>\n\n <div className=\"space-y-2\">\n <label\n htmlFor={vaultSelectId}\n className=\"block text-xs font-semibold text-text-primary uppercase tracking-wide\"\n >\n Vault\n </label>\n <div className=\"relative\">\n <select\n id={vaultSelectId}\n value={value.vaultId}\n onChange={(event) =>\n onChange((current) => ({\n ...current,\n vaultId: event.target.value,\n secretId: '',\n }))\n }\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n >\n <option value=\"\">Select a vault</option>\n {vaults.map((vault: VaultSummary) => (\n <option key={vault.id} value={vault.id}>\n {vault.name} ({vault.secretCount})\n </option>\n ))}\n </select>\n {vaultsLoading && (\n <Loader2\n size={16}\n className=\"absolute right-3 top-3 animate-spin text-text-secondary\"\n />\n )}\n </div>\n </div>\n\n {value.mode === 'managed' ? (\n <div className=\"space-y-2\">\n <label\n htmlFor={managedNameId}\n className=\"block text-xs font-semibold text-text-primary uppercase tracking-wide\"\n >\n Managed secret name\n </label>\n <input\n id={managedNameId}\n aria-label=\"Managed secret name\"\n type=\"text\"\n value={value.managedSecretName}\n onChange={(event) =>\n onChange((current) => ({\n ...current,\n managedSecretName: event.target.value,\n }))\n }\n placeholder=\"Optional custom vault secret name\"\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n />\n <p className=\"text-xs text-text-secondary\">\n Leave empty to auto-generate a secret name from the connection and provider.\n </p>\n </div>\n ) : (\n <div className=\"space-y-2\">\n <label\n htmlFor={existingSecretId}\n className=\"block text-xs font-semibold text-text-primary uppercase tracking-wide\"\n >\n Existing secret\n </label>\n <div className=\"relative\">\n <select\n id={existingSecretId}\n value={value.secretId}\n onChange={(event) =>\n onChange((current) => ({\n ...current,\n secretId: event.target.value,\n }))\n }\n disabled={!value.vaultId}\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-60\"\n >\n <option value=\"\">Select an existing secret</option>\n {secrets.map((secret: VaultSecretSummary) => (\n <option key={secret.id} value={secret.id}>\n {secret.name} · {secret.type}\n </option>\n ))}\n </select>\n {secretsLoading && (\n <Loader2\n size={16}\n className=\"absolute right-3 top-3 animate-spin text-text-secondary\"\n />\n )}\n </div>\n <p className=\"text-xs text-text-secondary\">\n For OAuth and basic auth, choose a structured credential secret created for\n integrations.\n </p>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AAmBA,SAAgB,EAA0B,EACxC,UACA,aACA,uBACiC;CACjC,IAAM,EAAE,WAAQ,SAAS,MAAkB,GAAqB,EAC1D,EAAE,YAAS,SAAS,MAAmB,EAC3C,EAAM,WAAW,MACjB,EACD,EACK,IAAW,GAAO,EAClB,IAAgB,GAAG,EAAS,SAC5B,IAAgB,GAAG,EAAS,gBAC5B,IAAmB,GAAG,EAAS;AAErC,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;IAAI,WAAU;cAAd,CACE,kBAAC,GAAD;KAAU,MAAM;KAAI,WAAU;KAAiB,CAAA,EAAA,qBAE5C;OACL,kBAAC,KAAD;IAAG,WAAU;cAAmC;IAG5C,CAAA,CACA,EAAA,CAAA;GAEN,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,UAAD;KACE,MAAK;KACL,eAAe,GAAU,OAAa;MAAE,GAAG;MAAS,MAAM;MAAW,UAAU;MAAI,EAAE;KACrF,WAAW,2DACT,EAAM,SAAS,YACX,0CACA;eANR,CASE,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,GAAD;OAAW,MAAM;OAAI,WAAU;OAAiB,CAAA,EAAA,mBAE5C;SACN,kBAAC,KAAD;MAAG,WAAU;gBAAmC;MAE5C,CAAA,CACG;QAET,kBAAC,UAAD;KACE,MAAK;KACL,eAAe,GAA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,CAAA;KACR,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,UAAD;OACE,IAAI;OACJ,OAAO,EAAM;OACb,WAAW,MACT,GAAU,OAAa;QACrB,GAAG;QACH,UAAU,EAAM,OAAO;QACxB,EAAE;OAEL,UAAU,CAAC,EAAM;OACjB,WAAU;iBAVZ,CAYE,kBAAC,UAAD;QAAQ,OAAM;kBAAG;QAAkC,CAAA,EAClD,EAAQ,KAAK,MACZ,kBAAC,UAAD;QAAwB,OAAO,EAAO;kBAAtC;SACG,EAAO;SAAK;SAAI,EAAO;SACjB;UAFI,EAAO,GAEX,CACT,CACK;UACR,KACC,kBAAC,GAAD;OACE,MAAM;OACN,WAAU;OACV,CAAA,CAEA;;KACN,kBAAC,KAAD;MAAG,WAAU;gBAA8B;MAGvC,CAAA;KACA;;GAEJ"}
|
|
1
|
+
{"version":3,"file":"CredentialStorageSelector.js","names":[],"sources":["../../../src/integrations/components/CredentialStorageSelector.tsx"],"sourcesContent":["import { useId, useState, type Dispatch, type SetStateAction } from 'react';\nimport { AlertCircle, Database, FolderKey, KeyRound, Loader2, Plus, X } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\n\nimport { INTEGRATION_PERMISSIONS } from '../constants/permissions';\n\nimport {\n useCreateCredentialVault,\n useCredentialVaults,\n useVaultSecrets,\n} from '../hooks/useCredentialVaults';\nimport type { VaultSecretSummary, VaultSummary } from '../types';\n\nexport interface CredentialStorageState {\n mode: 'managed' | 'existing';\n vaultId: string;\n secretId: string;\n managedSecretName: string;\n}\n\ninterface CredentialStorageSelectorProps {\n value: CredentialStorageState;\n onChange: Dispatch<SetStateAction<CredentialStorageState>>;\n providerAuthType?: string | null;\n}\n\nexport function CredentialStorageSelector({\n value,\n onChange,\n providerAuthType,\n}: CredentialStorageSelectorProps) {\n const { vaults, loading: vaultsLoading, refetch: refetchVaults } = useCredentialVaults();\n const { secrets, loading: secretsLoading } = useVaultSecrets(\n value.vaultId || null,\n providerAuthType\n );\n const { createVault, creating, error: createError, clearError } = useCreateCredentialVault();\n // Vaults belong to the security module, so creating a connection does not\n // imply being allowed to create one. Offering the action to someone who is\n // not would produce a button that always fails at the mutation.\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const canCreateVault = !permissionsLoading && hasPermission(INTEGRATION_PERMISSIONS.VAULT_CREATE);\n const [showCreateVault, setShowCreateVault] = useState(false);\n const [newVaultName, setNewVaultName] = useState('');\n const idPrefix = useId();\n const vaultSelectId = `${idPrefix}-vault`;\n const newVaultNameId = `${idPrefix}-new-vault`;\n const managedNameId = `${idPrefix}-managed-name`;\n const existingSecretId = `${idPrefix}-existing-secret`;\n\n const openCreateVault = () => {\n clearError();\n setNewVaultName('');\n setShowCreateVault(true);\n };\n\n const handleCreateVault = async () => {\n if (!newVaultName.trim()) return;\n const created = await createVault(newVaultName);\n if (!created) return;\n setNewVaultName('');\n // Refresh BEFORE selecting, so the new vault's <option> exists on the same\n // render that sets the value. Selecting first left the dropdown blank: a\n // controlled <select> whose value matches no option falls back to \"\", and\n // React does not re-apply an unchanged value prop when the options arrive\n // later — so the selection was silently dropped and saving then failed with\n // \"Please select a vault\", pointing at a vault the user had just made.\n await refetchVaults();\n onChange((current) => ({ ...current, vaultId: created.id, secretId: '' }));\n setShowCreateVault(false);\n };\n\n return (\n <div className=\"rounded-xl border border-border-subtle/50 bg-bg-surface p-4 space-y-4\">\n <div>\n <h3 className=\"text-sm font-semibold text-text-primary flex items-center gap-2\">\n <Database size={16} className=\"text-primary\" />\n Credential Storage\n </h3>\n <p className=\"text-xs text-text-secondary mt-1\">\n Connections use vault-managed secrets by default. You can also reuse an existing\n compatible secret.\n </p>\n </div>\n\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-3\">\n <button\n type=\"button\"\n onClick={() => onChange((current) => ({ ...current, mode: 'managed', secretId: '' }))}\n className={`rounded-xl border px-4 py-3 text-left transition-colors ${\n value.mode === 'managed'\n ? 'border-primary bg-action-primary-bg/5'\n : 'border-border-subtle hover:border-primary/40 hover:bg-accent/30'\n }`}\n >\n <div className=\"flex items-center gap-2 text-sm font-medium text-text-primary\">\n <FolderKey size={16} className=\"text-primary\" />\n Dedicated secret\n </div>\n <p className=\"text-xs text-text-secondary mt-1\">\n Create and own a vault secret for this connection.\n </p>\n </button>\n\n <button\n type=\"button\"\n onClick={() => onChange((current) => ({ ...current, mode: 'existing' }))}\n className={`rounded-xl border px-4 py-3 text-left transition-colors ${\n value.mode === 'existing'\n ? 'border-primary bg-action-primary-bg/5'\n : 'border-border-subtle hover:border-primary/40 hover:bg-accent/30'\n }`}\n >\n <div className=\"flex items-center gap-2 text-sm font-medium text-text-primary\">\n <KeyRound size={16} className=\"text-primary\" />\n Existing secret\n </div>\n <p className=\"text-xs text-text-secondary mt-1\">\n Reference an already stored secret from the vault.\n </p>\n </button>\n </div>\n\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <label\n htmlFor={vaultSelectId}\n className=\"block text-xs font-semibold text-text-primary uppercase tracking-wide\"\n >\n Vault\n </label>\n {!showCreateVault && canCreateVault && (\n <button\n type=\"button\"\n onClick={openCreateVault}\n className=\"inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline\"\n >\n <Plus size={13} /> New vault\n </button>\n )}\n </div>\n\n {showCreateVault ? (\n <div className=\"rounded-lg border border-primary/40 bg-action-primary-bg/5 p-3 space-y-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <label htmlFor={newVaultNameId} className=\"text-xs font-medium text-text-primary\">\n New vault name\n </label>\n <button\n type=\"button\"\n onClick={() => setShowCreateVault(false)}\n aria-label=\"Cancel creating a vault\"\n className=\"text-text-secondary hover:text-text-primary\"\n >\n <X size={14} />\n </button>\n </div>\n <input\n id={newVaultNameId}\n aria-label=\"New vault name\"\n type=\"text\"\n value={newVaultName}\n autoFocus\n onChange={(event) => setNewVaultName(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n void handleCreateVault();\n }\n }}\n placeholder=\"e.g. Integrations\"\n disabled={creating}\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-50\"\n />\n {createError && (\n <p className=\"flex items-center gap-1.5 text-xs text-status-error-text\">\n <AlertCircle size={13} className=\"flex-shrink-0\" />\n {createError}\n </p>\n )}\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => void handleCreateVault()}\n disabled={creating || !newVaultName.trim()}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg/90 disabled:opacity-50\"\n >\n {creating ? <Loader2 size={13} className=\"animate-spin\" /> : <Plus size={13} />}\n Create vault\n </button>\n <span className=\"text-xs text-text-secondary\">Scoped to this workspace.</span>\n </div>\n </div>\n ) : (\n <>\n <div className=\"relative\">\n <select\n id={vaultSelectId}\n value={value.vaultId}\n onChange={(event) =>\n onChange((current) => ({\n ...current,\n vaultId: event.target.value,\n secretId: '',\n }))\n }\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n >\n <option value=\"\">Select a vault</option>\n {vaults.map((vault: VaultSummary) => (\n <option key={vault.id} value={vault.id}>\n {vault.name} ({vault.secretCount})\n </option>\n ))}\n </select>\n {vaultsLoading && (\n <Loader2\n size={16}\n className=\"absolute right-3 top-3 animate-spin text-text-secondary\"\n />\n )}\n </div>\n {/* A workspace starts with no vaults, and a connection cannot be\n saved without one. Saying so here — next to the fix — beats\n letting the user discover it from a validation error on save. */}\n {!vaultsLoading &&\n vaults.length === 0 &&\n (canCreateVault ? (\n <p className=\"text-xs text-text-secondary\">\n No vaults yet.{' '}\n <button\n type=\"button\"\n onClick={openCreateVault}\n className=\"font-medium text-primary hover:underline\"\n >\n Create one\n </button>{' '}\n to store this connection’s credentials.\n </p>\n ) : (\n <p className=\"text-xs text-text-secondary\">\n No vaults yet. Ask an administrator to create one — a connection needs a vault to\n store its credentials.\n </p>\n ))}\n </>\n )}\n </div>\n\n {value.mode === 'managed' ? (\n <div className=\"space-y-2\">\n <label\n htmlFor={managedNameId}\n className=\"block text-xs font-semibold text-text-primary uppercase tracking-wide\"\n >\n Managed secret name\n </label>\n <input\n id={managedNameId}\n aria-label=\"Managed secret name\"\n type=\"text\"\n value={value.managedSecretName}\n onChange={(event) =>\n onChange((current) => ({\n ...current,\n managedSecretName: event.target.value,\n }))\n }\n placeholder=\"Optional custom vault secret name\"\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary\"\n />\n <p className=\"text-xs text-text-secondary\">\n Leave empty to auto-generate a secret name from the connection and provider.\n </p>\n </div>\n ) : (\n <div className=\"space-y-2\">\n <label\n htmlFor={existingSecretId}\n className=\"block text-xs font-semibold text-text-primary uppercase tracking-wide\"\n >\n Existing secret\n </label>\n <div className=\"relative\">\n <select\n id={existingSecretId}\n value={value.secretId}\n onChange={(event) =>\n onChange((current) => ({\n ...current,\n secretId: event.target.value,\n }))\n }\n disabled={!value.vaultId}\n className=\"w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary disabled:opacity-60\"\n >\n <option value=\"\">Select an existing secret</option>\n {secrets.map((secret: VaultSecretSummary) => (\n <option key={secret.id} value={secret.id}>\n {secret.name} · {secret.type}\n </option>\n ))}\n </select>\n {secretsLoading && (\n <Loader2\n size={16}\n className=\"absolute right-3 top-3 animate-spin text-text-secondary\"\n />\n )}\n </div>\n <p className=\"text-xs text-text-secondary\">\n For OAuth and basic auth, choose a structured credential secret created for\n integrations.\n </p>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;AA0BA,SAAgB,EAA0B,EACxC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,SAAD;MACE,SAAS;MACT,WAAU;gBACX;MAEO,CAAA;KACR,kBAAC,SAAD;MACE,IAAI;MACJ,cAAW;MACX,MAAK;MACL,OAAO,EAAM;MACb,WAAW,MACT,GAAU,OAAa;OACrB,GAAG;OACH,mBAAmB,EAAM,OAAO;OACjC,EAAE;MAEL,aAAY;MACZ,WAAU;MACV,CAAA;KACF,kBAAC,KAAD;MAAG,WAAU;gBAA8B;MAEvC,CAAA;KACA;QAEN,kBAAC,OAAD;IAAK,WAAU;cAAf;KACE,kBAAC,SAAD;MACE,SAAS;MACT,WAAU;gBACX;MAEO,CAAA;KACR,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,UAAD;OACE,IAAI;OACJ,OAAO,EAAM;OACb,WAAW,MACT,GAAU,OAAa;QACrB,GAAG;QACH,UAAU,EAAM,OAAO;QACxB,EAAE;OAEL,UAAU,CAAC,EAAM;OACjB,WAAU;iBAVZ,CAYE,kBAAC,UAAD;QAAQ,OAAM;kBAAG;QAAkC,CAAA,EAClD,EAAQ,KAAK,MACZ,kBAAC,UAAD;QAAwB,OAAO,EAAO;kBAAtC;SACG,EAAO;SAAK;SAAI,EAAO;SACjB;UAFI,EAAO,GAEX,CACT,CACK;UACR,KACC,kBAAC,GAAD;OACE,MAAM;OACN,WAAU;OACV,CAAA,CAEA;;KACN,kBAAC,KAAD;MAAG,WAAU;gBAA8B;MAGvC,CAAA;KACA;;GAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaForm.d.ts","sourceRoot":"","sources":["../../../src/integrations/components/SchemaForm.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"SchemaForm.d.ts","sourceRoot":"","sources":["../../../src/integrations/components/SchemaForm.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAiB,EAAE,EAAE,MAAM,OAAO,CA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AU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA2B1C,CAAC"}
|
|
@@ -32,8 +32,14 @@ function l(e) {
|
|
|
32
32
|
}
|
|
33
33
|
function u(e) {
|
|
34
34
|
if (!e) return {};
|
|
35
|
-
let t = {};
|
|
36
|
-
for (let [
|
|
35
|
+
let t = {}, n = new Set(e.required);
|
|
36
|
+
for (let [r, i] of Object.entries(e.properties)) {
|
|
37
|
+
if (i.default !== void 0) {
|
|
38
|
+
t[r] = i.default;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
i.type === "boolean" && n.has(r) && (t[r] = !1);
|
|
42
|
+
}
|
|
37
43
|
return t;
|
|
38
44
|
}
|
|
39
45
|
function d(e, t) {
|
|
@@ -45,11 +51,11 @@ function d(e, t) {
|
|
|
45
51
|
}
|
|
46
52
|
return n;
|
|
47
53
|
}
|
|
48
|
-
var f = ({ schema: e, values: t, onChange: n, disabled: r, idPrefix: a = "schema" }) => {
|
|
54
|
+
var f = typeof CSS < "u" && typeof CSS.supports == "function" && CSS.supports("-webkit-text-security", "disc"), p = ({ schema: e, values: t, onChange: n, disabled: r, idPrefix: a = "schema" }) => {
|
|
49
55
|
let o = new Set(e.required);
|
|
50
56
|
return /* @__PURE__ */ i("div", {
|
|
51
57
|
className: "space-y-3",
|
|
52
|
-
children: Object.entries(e.properties).filter(([, e]) => s(e, t)).map(([e, s]) => /* @__PURE__ */ i(
|
|
58
|
+
children: Object.entries(e.properties).filter(([, e]) => s(e, t)).map(([e, s]) => /* @__PURE__ */ i(m, {
|
|
53
59
|
id: `${a}-${e}`,
|
|
54
60
|
name: e,
|
|
55
61
|
property: s,
|
|
@@ -62,8 +68,8 @@ var f = ({ schema: e, values: t, onChange: n, disabled: r, idPrefix: a = "schema
|
|
|
62
68
|
})
|
|
63
69
|
}, e))
|
|
64
70
|
});
|
|
65
|
-
},
|
|
66
|
-
let [
|
|
71
|
+
}, m = ({ id: o, name: s, property: c, value: u, required: d, disabled: p, onChange: m }) => {
|
|
72
|
+
let [h, g] = e(!1), [_, v] = e(!1), y = c.title ?? s, b = c.placeholder ?? c.description ?? "";
|
|
67
73
|
if (c.type === "notice") return /* @__PURE__ */ a("div", {
|
|
68
74
|
className: "flex items-start gap-2 px-3 py-2 rounded-md bg-status-info-bg-subtle border border-border-default",
|
|
69
75
|
children: [/* @__PURE__ */ i(r, {
|
|
@@ -71,24 +77,24 @@ var f = ({ schema: e, values: t, onChange: n, disabled: r, idPrefix: a = "schema
|
|
|
71
77
|
className: "text-status-info-text flex-shrink-0 mt-0.5"
|
|
72
78
|
}), /* @__PURE__ */ i("span", {
|
|
73
79
|
className: "text-xs text-status-info-text",
|
|
74
|
-
children: c.description ??
|
|
80
|
+
children: c.description ?? y
|
|
75
81
|
})]
|
|
76
82
|
});
|
|
77
|
-
let
|
|
83
|
+
let x = c.description ? /* @__PURE__ */ i("p", {
|
|
78
84
|
className: "mt-1 text-xs text-text-secondary",
|
|
79
85
|
children: c.description
|
|
80
|
-
}) : null,
|
|
86
|
+
}) : null, S = /* @__PURE__ */ a("label", {
|
|
81
87
|
htmlFor: o,
|
|
82
88
|
className: "block text-sm font-medium text-text-primary mb-1.5",
|
|
83
89
|
children: [
|
|
84
|
-
|
|
90
|
+
y,
|
|
85
91
|
" ",
|
|
86
92
|
d && /* @__PURE__ */ i("span", {
|
|
87
93
|
className: "text-status-error-text",
|
|
88
94
|
children: "*"
|
|
89
95
|
})
|
|
90
96
|
]
|
|
91
|
-
}),
|
|
97
|
+
}), C = "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";
|
|
92
98
|
if (c.type === "boolean") {
|
|
93
99
|
let e = !!(u ?? c.default ?? !1);
|
|
94
100
|
return /* @__PURE__ */ a("div", {
|
|
@@ -98,92 +104,127 @@ var f = ({ schema: e, values: t, onChange: n, disabled: r, idPrefix: a = "schema
|
|
|
98
104
|
role: "switch",
|
|
99
105
|
id: o,
|
|
100
106
|
"aria-checked": e,
|
|
101
|
-
"aria-label":
|
|
102
|
-
onClick: () =>
|
|
103
|
-
disabled:
|
|
107
|
+
"aria-label": y,
|
|
108
|
+
onClick: () => m(!e),
|
|
109
|
+
disabled: p,
|
|
104
110
|
className: `relative inline-flex h-5 w-9 items-center rounded-full transition-colors disabled:opacity-50 ${e ? "bg-primary" : "bg-bg-muted"}`,
|
|
105
111
|
children: /* @__PURE__ */ i("span", { className: `inline-block h-3.5 w-3.5 transform rounded-full bg-white transition-transform ${e ? "translate-x-4.5" : "translate-x-0.5"}` })
|
|
106
112
|
}), /* @__PURE__ */ a("span", {
|
|
107
113
|
className: "text-sm font-medium text-text-primary",
|
|
108
|
-
children: [
|
|
114
|
+
children: [y, c.description && /* @__PURE__ */ a("span", {
|
|
109
115
|
className: "text-text-secondary font-normal ml-1",
|
|
110
116
|
children: ["— ", c.description]
|
|
111
117
|
})]
|
|
112
118
|
})]
|
|
113
119
|
});
|
|
114
120
|
}
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
if (c.enum && c.enum.length > 0) return /* @__PURE__ */ a("div", { children: [
|
|
122
|
+
S,
|
|
117
123
|
/* @__PURE__ */ a("select", {
|
|
118
124
|
id: o,
|
|
119
|
-
"aria-label":
|
|
125
|
+
"aria-label": y,
|
|
120
126
|
value: String(u ?? c.default ?? ""),
|
|
121
|
-
onChange: (e) =>
|
|
122
|
-
disabled:
|
|
123
|
-
className:
|
|
127
|
+
onChange: (e) => m(e.target.value),
|
|
128
|
+
disabled: p,
|
|
129
|
+
className: C,
|
|
124
130
|
children: [/* @__PURE__ */ a("option", {
|
|
125
131
|
value: "",
|
|
126
|
-
children: ["Select ",
|
|
132
|
+
children: ["Select ", y.toLowerCase()]
|
|
127
133
|
}), l(c.enum).map((e) => /* @__PURE__ */ i("option", {
|
|
128
134
|
value: e.value,
|
|
129
135
|
children: e.label
|
|
130
136
|
}, e.value))]
|
|
131
137
|
}),
|
|
132
|
-
|
|
133
|
-
] })
|
|
134
|
-
|
|
138
|
+
x
|
|
139
|
+
] });
|
|
140
|
+
if (c.type === "number") return /* @__PURE__ */ a("div", { children: [
|
|
141
|
+
S,
|
|
135
142
|
/* @__PURE__ */ i("input", {
|
|
136
143
|
id: o,
|
|
137
|
-
"aria-label":
|
|
144
|
+
"aria-label": y,
|
|
138
145
|
type: "number",
|
|
139
146
|
value: u == null ? "" : String(u),
|
|
140
|
-
onChange: (e) =>
|
|
141
|
-
placeholder:
|
|
142
|
-
disabled:
|
|
143
|
-
className:
|
|
144
|
-
}),
|
|
145
|
-
v
|
|
146
|
-
] }) : c.format === "textarea" || c.format === "json" ? /* @__PURE__ */ a("div", { children: [
|
|
147
|
-
y,
|
|
148
|
-
/* @__PURE__ */ i("textarea", {
|
|
149
|
-
id: o,
|
|
150
|
-
"aria-label": g,
|
|
151
|
-
value: String(u ?? ""),
|
|
152
|
-
onChange: (e) => p(e.target.value),
|
|
153
|
-
placeholder: _,
|
|
154
|
-
disabled: f,
|
|
155
|
-
rows: 5,
|
|
156
|
-
autoComplete: "off",
|
|
157
|
-
spellCheck: !1,
|
|
158
|
-
className: `${b} font-mono`
|
|
147
|
+
onChange: (e) => m(e.target.value === "" ? void 0 : Number(e.target.value)),
|
|
148
|
+
placeholder: b,
|
|
149
|
+
disabled: p,
|
|
150
|
+
className: C
|
|
159
151
|
}),
|
|
160
|
-
|
|
161
|
-
] })
|
|
162
|
-
|
|
152
|
+
x
|
|
153
|
+
] });
|
|
154
|
+
if (c.format === "textarea" || c.format === "json") {
|
|
155
|
+
let e = !!c.secret && !h, r = typeof u == "string" && u.length > 0;
|
|
156
|
+
return e && !f && r && !_ ? /* @__PURE__ */ a("div", { children: [
|
|
157
|
+
S,
|
|
158
|
+
/* @__PURE__ */ a("div", {
|
|
159
|
+
className: "flex items-center justify-between gap-2 px-3 py-2 border border-border-subtle rounded-md bg-bg-surface",
|
|
160
|
+
children: [/* @__PURE__ */ i("span", {
|
|
161
|
+
className: "text-sm font-mono text-text-secondary select-none",
|
|
162
|
+
children: "••••••••••••"
|
|
163
|
+
}), /* @__PURE__ */ a("button", {
|
|
164
|
+
type: "button",
|
|
165
|
+
onClick: () => g(!0),
|
|
166
|
+
disabled: p,
|
|
167
|
+
"aria-label": `Show ${y}`,
|
|
168
|
+
className: "inline-flex items-center gap-1 text-xs text-primary hover:underline disabled:opacity-50",
|
|
169
|
+
children: [/* @__PURE__ */ i(t, { size: 14 }), " Reveal to edit"]
|
|
170
|
+
})]
|
|
171
|
+
}),
|
|
172
|
+
x
|
|
173
|
+
] }) : /* @__PURE__ */ a("div", { children: [
|
|
174
|
+
S,
|
|
175
|
+
/* @__PURE__ */ a("div", {
|
|
176
|
+
className: "relative",
|
|
177
|
+
children: [/* @__PURE__ */ i("textarea", {
|
|
178
|
+
id: o,
|
|
179
|
+
"aria-label": y,
|
|
180
|
+
value: String(u ?? ""),
|
|
181
|
+
onChange: (e) => m(e.target.value),
|
|
182
|
+
onFocus: () => v(!0),
|
|
183
|
+
onBlur: () => v(!1),
|
|
184
|
+
placeholder: b,
|
|
185
|
+
disabled: p,
|
|
186
|
+
rows: 5,
|
|
187
|
+
autoComplete: "off",
|
|
188
|
+
spellCheck: !1,
|
|
189
|
+
style: e ? { WebkitTextSecurity: "disc" } : void 0,
|
|
190
|
+
className: `${C} font-mono ${c.secret ? "pr-10" : ""}`
|
|
191
|
+
}), c.secret && /* @__PURE__ */ i("button", {
|
|
192
|
+
type: "button",
|
|
193
|
+
onClick: () => g((e) => !e),
|
|
194
|
+
"aria-label": h ? `Hide ${y}` : `Show ${y}`,
|
|
195
|
+
className: "absolute right-2 top-2 text-text-secondary hover:text-text-primary",
|
|
196
|
+
children: i(h ? n : t, { size: 16 })
|
|
197
|
+
})]
|
|
198
|
+
}),
|
|
199
|
+
x
|
|
200
|
+
] });
|
|
201
|
+
}
|
|
202
|
+
return /* @__PURE__ */ a("div", { children: [
|
|
203
|
+
S,
|
|
163
204
|
/* @__PURE__ */ a("div", {
|
|
164
205
|
className: "relative",
|
|
165
206
|
children: [/* @__PURE__ */ i("input", {
|
|
166
207
|
id: o,
|
|
167
|
-
"aria-label":
|
|
168
|
-
type: c.secret && !
|
|
208
|
+
"aria-label": y,
|
|
209
|
+
type: c.secret && !h ? "password" : "text",
|
|
169
210
|
value: String(u ?? ""),
|
|
170
|
-
onChange: (e) =>
|
|
171
|
-
placeholder:
|
|
172
|
-
disabled:
|
|
211
|
+
onChange: (e) => m(e.target.value),
|
|
212
|
+
placeholder: b,
|
|
213
|
+
disabled: p,
|
|
173
214
|
autoComplete: "off",
|
|
174
|
-
className: `${
|
|
215
|
+
className: `${C} ${c.secret ? "font-mono pr-10" : ""}`
|
|
175
216
|
}), c.secret && /* @__PURE__ */ i("button", {
|
|
176
217
|
type: "button",
|
|
177
|
-
onClick: () =>
|
|
178
|
-
"aria-label":
|
|
218
|
+
onClick: () => g((e) => !e),
|
|
219
|
+
"aria-label": h ? `Hide ${y}` : `Show ${y}`,
|
|
179
220
|
className: "absolute right-2 top-1/2 -translate-y-1/2 text-text-secondary hover:text-text-primary",
|
|
180
|
-
children: i(
|
|
221
|
+
children: i(h ? n : t, { size: 16 })
|
|
181
222
|
})]
|
|
182
223
|
}),
|
|
183
|
-
|
|
224
|
+
x
|
|
184
225
|
] });
|
|
185
226
|
};
|
|
186
227
|
//#endregion
|
|
187
|
-
export {
|
|
228
|
+
export { p as SchemaForm, u as initialValuesFromSchema, c as isSchemaComplete, o as parseFormSchema, d as visibleValues };
|
|
188
229
|
|
|
189
230
|
//# sourceMappingURL=SchemaForm.js.map
|