@strapi-community/plugin-better-auth-dashboard 1.0.0-alpha.9 → 1.0.0-beta.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.
Files changed (42) hide show
  1. package/README.md +65 -0
  2. package/dist/admin/Avatar-CdT7eBCh.js +39 -0
  3. package/dist/admin/Avatar-zlMTAZh3.mjs +40 -0
  4. package/dist/admin/Root-CgVBJuoM.mjs +365 -0
  5. package/dist/admin/Root-CsiOnzlB.js +367 -0
  6. package/dist/admin/cs-C_jSgeON.js +416 -0
  7. package/dist/admin/cs-wtnknvBC.mjs +416 -0
  8. package/dist/admin/de-Cg5HyoCY.js +416 -0
  9. package/dist/admin/de-DnnVdUxk.mjs +416 -0
  10. package/dist/admin/en-B3utEgMT.mjs +416 -0
  11. package/dist/admin/en-Cz1IJEvp.js +416 -0
  12. package/dist/admin/es-CGA0Tslt.js +416 -0
  13. package/dist/admin/es-RoCEriJL.mjs +416 -0
  14. package/dist/admin/fr-Ca74t21t.js +416 -0
  15. package/dist/admin/fr-CtmuSfiQ.mjs +416 -0
  16. package/dist/admin/index-BCBu-0nr.js +457 -0
  17. package/dist/admin/index-BI2WIsds.mjs +458 -0
  18. package/dist/admin/index-CPSoAbZt.js +2321 -0
  19. package/dist/admin/index-D9ttdrT3.js +2716 -0
  20. package/dist/admin/index-DQdn5s8q.js +1184 -0
  21. package/dist/admin/index-DvfwvCj0.mjs +1182 -0
  22. package/dist/admin/index-VyHXoQ6p.mjs +2321 -0
  23. package/dist/admin/index-gFqHlMLP.mjs +2716 -0
  24. package/dist/admin/index.js +2 -2
  25. package/dist/admin/index.mjs +2 -2
  26. package/dist/admin/it-BAB9hDdp.mjs +416 -0
  27. package/dist/admin/it-dYT2_ERV.js +416 -0
  28. package/dist/admin/nl-CVqSbUU9.js +416 -0
  29. package/dist/admin/nl-CYv26PHv.mjs +416 -0
  30. package/dist/admin/pl-Bc0cS2mD.mjs +416 -0
  31. package/dist/admin/pl-HYF4BxRv.js +416 -0
  32. package/dist/admin/pt-DDUGyLtb.js +416 -0
  33. package/dist/admin/pt-DZyyK3EG.mjs +416 -0
  34. package/dist/admin/useModelSchema-BogQah8f.js +756 -0
  35. package/dist/admin/useModelSchema-C6bxNjW4.mjs +755 -0
  36. package/dist/server/index.js +220 -10
  37. package/dist/server/index.mjs +220 -10
  38. package/package.json +5 -4
  39. package/dist/admin/Root-BYdYQBE5.mjs +0 -5742
  40. package/dist/admin/Root-D_vCtQoC.js +0 -5744
  41. package/dist/admin/index-BMTIuxZI.mjs +0 -96
  42. package/dist/admin/index-CkSsWnBx.js +0 -95
@@ -0,0 +1,756 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const designSystem = require("@strapi/design-system");
4
+ const icons = require("@strapi/icons");
5
+ const reactIntl = require("react-intl");
6
+ const index = require("./index-BCBu-0nr.js");
7
+ const react = require("react");
8
+ const styled = require("styled-components");
9
+ const admin = require("@strapi/strapi/admin");
10
+ const reactQuery = require("react-query");
11
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
12
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
13
+ function ConfirmDialog({
14
+ title,
15
+ message,
16
+ confirmLabel,
17
+ variant = "danger",
18
+ loading = false,
19
+ onConfirm,
20
+ onCancel
21
+ }) {
22
+ const { formatMessage } = reactIntl.useIntl();
23
+ return /* @__PURE__ */ jsxRuntime.jsx(
24
+ designSystem.Dialog.Root,
25
+ {
26
+ defaultOpen: true,
27
+ onOpenChange: (open) => !open && onCancel(),
28
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
29
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
30
+ /* @__PURE__ */ jsxRuntime.jsx(
31
+ designSystem.Dialog.Body,
32
+ {
33
+ icon: /* @__PURE__ */ jsxRuntime.jsx(
34
+ icons.WarningCircle,
35
+ {
36
+ fill: variant === "danger" ? "danger600" : "primary600"
37
+ }
38
+ ),
39
+ children: message
40
+ }
41
+ ),
42
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
43
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, variant: "tertiary", disabled: loading, children: formatMessage({
44
+ id: index.getTranslation("components.confirmDialog.cancel"),
45
+ defaultMessage: "Cancel"
46
+ }) }) }),
47
+ /* @__PURE__ */ jsxRuntime.jsx(
48
+ designSystem.Button,
49
+ {
50
+ fullWidth: true,
51
+ variant,
52
+ loading,
53
+ onClick: onConfirm,
54
+ children: confirmLabel ?? formatMessage({
55
+ id: index.getTranslation("components.confirmDialog.confirm"),
56
+ defaultMessage: "Confirm"
57
+ })
58
+ }
59
+ )
60
+ ] })
61
+ ] })
62
+ }
63
+ );
64
+ }
65
+ const DASH_CONTEXT_HEADER = "X-Dash-Context";
66
+ const withContext = (ctx, headers) => ({
67
+ headers: {
68
+ ...headers,
69
+ [DASH_CONTEXT_HEADER]: btoa(JSON.stringify(ctx))
70
+ }
71
+ });
72
+ const FormSection = (props) => /* @__PURE__ */ jsxRuntime.jsx(
73
+ designSystem.Flex,
74
+ {
75
+ direction: "column",
76
+ alignItems: "stretch",
77
+ gap: 4,
78
+ width: "100%",
79
+ background: "neutral100",
80
+ hasRadius: true,
81
+ paddingTop: 4,
82
+ paddingBottom: 4,
83
+ paddingLeft: 5,
84
+ paddingRight: 5,
85
+ ...props
86
+ }
87
+ );
88
+ const EditLayout = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(
89
+ designSystem.Grid.Root,
90
+ {
91
+ gap: 6,
92
+ paddingTop: 6,
93
+ style: {
94
+ gridTemplateColumns: "minmax(0, 1fr) 25.6rem",
95
+ alignItems: "start"
96
+ },
97
+ children
98
+ }
99
+ );
100
+ const EditSidebar = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(
101
+ designSystem.Flex,
102
+ {
103
+ direction: "column",
104
+ alignItems: "stretch",
105
+ gap: 5,
106
+ position: "sticky",
107
+ top: 0,
108
+ children
109
+ }
110
+ );
111
+ const SectionLabel = (props) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", tag: "p", ...props });
112
+ const MetaItem = (props) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, ...props });
113
+ const MetaKey = (props) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", ...props });
114
+ const MetaVal = (props) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", ...props });
115
+ const Code = styled__default.default(designSystem.Typography)`
116
+ font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
117
+ word-break: break-all;
118
+ `;
119
+ const MonoChip = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(
120
+ designSystem.Box,
121
+ {
122
+ background: "primary100",
123
+ borderColor: "primary200",
124
+ borderStyle: "solid",
125
+ borderWidth: "1px",
126
+ hasRadius: true,
127
+ paddingLeft: 2,
128
+ paddingRight: 2,
129
+ paddingTop: 1,
130
+ paddingBottom: 1,
131
+ children: /* @__PURE__ */ jsxRuntime.jsx(Code, { variant: "pi", textColor: "primary600", children })
132
+ }
133
+ );
134
+ const ProviderBadge = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { variant: "primary", children });
135
+ const WarnCard = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(
136
+ designSystem.Flex,
137
+ {
138
+ direction: "column",
139
+ alignItems: "flex-start",
140
+ gap: 1,
141
+ background: "danger100",
142
+ borderColor: "danger200",
143
+ borderStyle: "solid",
144
+ borderWidth: "1px",
145
+ hasRadius: true,
146
+ padding: 4,
147
+ children
148
+ }
149
+ );
150
+ const PreviewPill = ({ children }) => /* @__PURE__ */ jsxRuntime.jsxs(
151
+ designSystem.Flex,
152
+ {
153
+ gap: 2,
154
+ background: "warning100",
155
+ borderColor: "warning200",
156
+ borderStyle: "solid",
157
+ borderWidth: "1px",
158
+ hasRadius: true,
159
+ paddingTop: 2,
160
+ paddingBottom: 2,
161
+ paddingLeft: 3,
162
+ paddingRight: 3,
163
+ width: "fit-content",
164
+ children: [
165
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Clock, { fill: "warning700", width: "1.2rem", height: "1.2rem" }),
166
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "semiBold", textColor: "warning700", children })
167
+ ]
168
+ }
169
+ );
170
+ const AccountRow = (props) => /* @__PURE__ */ jsxRuntime.jsx(
171
+ designSystem.Flex,
172
+ {
173
+ width: "100%",
174
+ justifyContent: "space-between",
175
+ gap: 3,
176
+ background: "neutral0",
177
+ borderColor: "neutral200",
178
+ borderStyle: "solid",
179
+ borderWidth: "1px",
180
+ hasRadius: true,
181
+ paddingTop: 3,
182
+ paddingBottom: 3,
183
+ paddingLeft: 4,
184
+ paddingRight: 4,
185
+ ...props
186
+ }
187
+ );
188
+ const DangerRow = (props) => /* @__PURE__ */ jsxRuntime.jsx(AccountRow, { background: "danger100", borderColor: "danger200", ...props });
189
+ const RoleBadge = ({
190
+ memberRole,
191
+ children
192
+ }) => /* @__PURE__ */ jsxRuntime.jsx(
193
+ designSystem.Badge,
194
+ {
195
+ size: "S",
196
+ variant: memberRole === "owner" ? "primary" : memberRole === "admin" ? "success" : "neutral",
197
+ children
198
+ }
199
+ );
200
+ function MediaPickerField({
201
+ label,
202
+ value,
203
+ onChange,
204
+ hint,
205
+ placeholder,
206
+ name,
207
+ required
208
+ }) {
209
+ const { formatMessage } = reactIntl.useIntl();
210
+ const [showMedia, setShowMedia] = react.useState(false);
211
+ const MediaLibraryDialog = index.getMediaLibraryComponent();
212
+ const handleSelect = (assets) => {
213
+ const asset = assets[0];
214
+ if (!asset) return;
215
+ const url = asset.formats?.small?.url ?? asset.formats?.thumbnail?.url ?? asset.url;
216
+ onChange(url);
217
+ setShowMedia(false);
218
+ };
219
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
220
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: { width: "100%" }, hint, required, children: [
221
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
222
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
223
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { flex: 1, minWidth: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
224
+ designSystem.TextInput,
225
+ {
226
+ name,
227
+ type: "url",
228
+ value,
229
+ onChange: (e) => onChange(e.target.value),
230
+ placeholder
231
+ }
232
+ ) }),
233
+ MediaLibraryDialog && /* @__PURE__ */ jsxRuntime.jsx(
234
+ designSystem.Button,
235
+ {
236
+ variant: "secondary",
237
+ size: "S",
238
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Images, {}),
239
+ onClick: () => setShowMedia(true),
240
+ style: { flexShrink: 0 },
241
+ children: formatMessage({
242
+ id: index.getTranslation("components.mediaPickerField.browse"),
243
+ defaultMessage: "Browse"
244
+ })
245
+ }
246
+ )
247
+ ] }),
248
+ hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
249
+ ] }),
250
+ showMedia && MediaLibraryDialog && /* @__PURE__ */ jsxRuntime.jsx(
251
+ MediaLibraryDialog,
252
+ {
253
+ allowedTypes: ["images"],
254
+ multiple: false,
255
+ onClose: () => setShowMedia(false),
256
+ onSelectAssets: handleSelect
257
+ }
258
+ )
259
+ ] });
260
+ }
261
+ const slideIn = styled.keyframes`
262
+ from { transform: translateX(100%); opacity: 0; }
263
+ to { transform: translateX(0); opacity: 1; }
264
+ `;
265
+ const slideOut = styled.keyframes`
266
+ from { transform: translateX(0); opacity: 1; }
267
+ to { transform: translateX(100%); opacity: 0; }
268
+ `;
269
+ const Content = styled__default.default(designSystem.Modal.Content)`
270
+ && {
271
+ top: 0;
272
+ right: 0;
273
+ bottom: 0;
274
+ left: auto;
275
+ transform: none;
276
+ width: min(${(p) => p.$width}, 95vw);
277
+ max-width: none;
278
+ height: 100%;
279
+ max-height: none;
280
+ border-radius: 0;
281
+ box-shadow: ${({ theme }) => theme.shadows.popupShadow};
282
+
283
+ @media (prefers-reduced-motion: no-preference) {
284
+ &[data-state='open'] {
285
+ animation: ${slideIn} ${({ theme }) => theme.motion.timings["200"]}
286
+ ${({ theme }) => theme.motion.easings.authenticMotion};
287
+ }
288
+ &[data-state='closed'] {
289
+ animation: ${slideOut} ${({ theme }) => theme.motion.timings["120"]}
290
+ ${({ theme }) => theme.motion.easings.easeOutQuad};
291
+ }
292
+ }
293
+ }
294
+ `;
295
+ const Body = styled__default.default(designSystem.Modal.Body)`
296
+ flex: 1 1 auto;
297
+ min-height: 0;
298
+ `;
299
+ const Footer = styled__default.default(designSystem.Modal.Footer)`
300
+ flex: 0 0 auto;
301
+ `;
302
+ function SheetDialog({
303
+ title,
304
+ children,
305
+ actionButtons,
306
+ onClose,
307
+ width = "760px",
308
+ "data-testid": testId
309
+ }) {
310
+ const { formatMessage } = reactIntl.useIntl();
311
+ return /* @__PURE__ */ jsxRuntime.jsx(
312
+ designSystem.Modal.Root,
313
+ {
314
+ defaultOpen: true,
315
+ onOpenChange: (open) => !open && onClose(),
316
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Content, { $width: width, "data-testid": testId, children: [
317
+ /* @__PURE__ */ jsxRuntime.jsx(
318
+ designSystem.Modal.Header,
319
+ {
320
+ closeLabel: formatMessage({
321
+ id: index.getTranslation("components.sheet.closeLabel"),
322
+ defaultMessage: "Close panel"
323
+ }),
324
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title })
325
+ }
326
+ ),
327
+ /* @__PURE__ */ jsxRuntime.jsx(Body, { children }),
328
+ actionButtons && /* @__PURE__ */ jsxRuntime.jsx(Footer, { children: actionButtons })
329
+ ] })
330
+ }
331
+ );
332
+ }
333
+ function getDisplayLabel(doc) {
334
+ for (const key of ["name", "title", "email", "username", "label", "slug"]) {
335
+ const v = doc[key];
336
+ if (typeof v === "string" && v.trim()) return v;
337
+ }
338
+ return String(doc.documentId ?? doc.id ?? "");
339
+ }
340
+ function normalizeValue(val, cache) {
341
+ if (!val) return [];
342
+ if (typeof val === "object" && !Array.isArray(val) && val !== null && "set" in val) {
343
+ const items2 = val.set ?? [];
344
+ return items2.filter((item) => item?.documentId).map((item) => ({
345
+ documentId: item.documentId,
346
+ label: cache.get(item.documentId) ?? item.documentId
347
+ }));
348
+ }
349
+ const items = Array.isArray(val) ? val : [val];
350
+ return items.filter(
351
+ (item) => typeof item === "object" && item !== null && "documentId" in item
352
+ ).map((item) => ({
353
+ documentId: String(item.documentId),
354
+ label: getDisplayLabel(item)
355
+ }));
356
+ }
357
+ function RelationField({
358
+ name,
359
+ label,
360
+ attribute,
361
+ value,
362
+ onChange,
363
+ readOnly = false
364
+ }) {
365
+ const { formatMessage } = reactIntl.useIntl();
366
+ const { get } = admin.useFetchClient();
367
+ const cache = react.useRef(/* @__PURE__ */ new Map());
368
+ const [search, setSearch] = react.useState("");
369
+ const [addKey, setAddKey] = react.useState(0);
370
+ const target = attribute.target ?? "";
371
+ const relationType = attribute.relation ?? "manyToOne";
372
+ const isMulti = relationType === "oneToMany" || relationType === "manyToMany";
373
+ const currentDocs = normalizeValue(value, cache.current);
374
+ const selectedIds = new Set(currentDocs.map((d) => d.documentId));
375
+ const { data: searchResults = [], isLoading } = reactQuery.useQuery({
376
+ queryKey: ["relation-search", target, search],
377
+ queryFn: async () => {
378
+ const params = new URLSearchParams({
379
+ uid: target,
380
+ "pagination[pageSize]": "50"
381
+ });
382
+ if (search) params.set("filters[name][$containsi]", search);
383
+ const { data } = await get(
384
+ `/better-auth-dashboard/db?${params}`
385
+ );
386
+ const docs = data.results ?? [];
387
+ for (const doc of docs) {
388
+ if (doc.documentId) {
389
+ cache.current.set(String(doc.documentId), getDisplayLabel(doc));
390
+ }
391
+ }
392
+ return docs.map((doc) => ({
393
+ documentId: String(doc.documentId ?? ""),
394
+ label: getDisplayLabel(doc)
395
+ })).filter((d) => d.documentId);
396
+ },
397
+ keepPreviousData: true,
398
+ enabled: !readOnly
399
+ });
400
+ const availableOptions = searchResults.filter(
401
+ (r) => !selectedIds.has(r.documentId)
402
+ );
403
+ const commit = (ids) => {
404
+ onChange(name, { set: ids.map((id) => ({ documentId: id })) });
405
+ };
406
+ const handleSelect = (val) => {
407
+ if (!val) return;
408
+ const opt = searchResults.find((r) => r.documentId === val);
409
+ if (opt) cache.current.set(val, opt.label);
410
+ if (isMulti) {
411
+ if (selectedIds.has(val)) return;
412
+ commit([...currentDocs.map((d) => d.documentId), val]);
413
+ } else {
414
+ commit([val]);
415
+ }
416
+ setSearch("");
417
+ setAddKey((k) => k + 1);
418
+ };
419
+ const handleRemove = (docId) => {
420
+ commit(
421
+ currentDocs.filter((d) => d.documentId !== docId).map((d) => d.documentId)
422
+ );
423
+ };
424
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: { width: "100%" }, children: [
425
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
426
+ !readOnly && /* @__PURE__ */ jsxRuntime.jsx(
427
+ designSystem.Combobox,
428
+ {
429
+ value: "",
430
+ onChange: (val) => handleSelect(val),
431
+ onInputChange: (e) => setSearch(e.target.value),
432
+ loading: isLoading,
433
+ placeholder: formatMessage({
434
+ id: index.getTranslation("components.relationField.searchPlaceholder"),
435
+ defaultMessage: "Search…"
436
+ }),
437
+ children: availableOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.ComboboxOption, { value: opt.documentId, children: opt.label }, opt.documentId))
438
+ },
439
+ addKey
440
+ ),
441
+ currentDocs.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
442
+ designSystem.Flex,
443
+ {
444
+ direction: "column",
445
+ alignItems: "stretch",
446
+ gap: 1,
447
+ marginTop: 2,
448
+ width: "100%",
449
+ children: currentDocs.map((doc) => /* @__PURE__ */ jsxRuntime.jsxs(
450
+ designSystem.Flex,
451
+ {
452
+ justifyContent: "space-between",
453
+ gap: 2,
454
+ paddingTop: 2,
455
+ paddingBottom: 2,
456
+ paddingLeft: 3,
457
+ paddingRight: 3,
458
+ background: "neutral0",
459
+ borderColor: "neutral200",
460
+ borderStyle: "solid",
461
+ borderWidth: "1px",
462
+ hasRadius: true,
463
+ children: [
464
+ /* @__PURE__ */ jsxRuntime.jsx(
465
+ designSystem.Typography,
466
+ {
467
+ variant: "omega",
468
+ textColor: "neutral800",
469
+ ellipsis: true,
470
+ style: { flex: 1, minWidth: 0 },
471
+ children: doc.label
472
+ }
473
+ ),
474
+ !readOnly && /* @__PURE__ */ jsxRuntime.jsx(
475
+ designSystem.IconButton,
476
+ {
477
+ label: formatMessage({
478
+ id: index.getTranslation("components.relationField.remove"),
479
+ defaultMessage: "Remove"
480
+ }),
481
+ size: "S",
482
+ onClick: () => handleRemove(doc.documentId),
483
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {})
484
+ }
485
+ )
486
+ ]
487
+ },
488
+ doc.documentId
489
+ ))
490
+ }
491
+ )
492
+ ] });
493
+ }
494
+ function makeLabel(name) {
495
+ return name.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
496
+ }
497
+ const fieldStyle = { width: "100%" };
498
+ function DynamicField({
499
+ field,
500
+ value,
501
+ onChange,
502
+ readOnly = false
503
+ }) {
504
+ const { name, attribute } = field;
505
+ const { type, required, enum: enumValues } = attribute;
506
+ const label = makeLabel(name);
507
+ if (type === "boolean") {
508
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: fieldStyle, children: [
509
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
510
+ /* @__PURE__ */ jsxRuntime.jsx(
511
+ designSystem.Checkbox,
512
+ {
513
+ checked: Boolean(value),
514
+ onCheckedChange: (checked) => onChange(name, checked),
515
+ disabled: readOnly,
516
+ children: label
517
+ }
518
+ )
519
+ ] });
520
+ }
521
+ if (type === "enumeration" && Array.isArray(enumValues)) {
522
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: fieldStyle, children: [
523
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
524
+ /* @__PURE__ */ jsxRuntime.jsx(
525
+ designSystem.SingleSelect,
526
+ {
527
+ value: value != null ? String(value) : "",
528
+ onChange: (v) => onChange(name, String(v)),
529
+ disabled: readOnly,
530
+ required,
531
+ placeholder: "—",
532
+ children: enumValues.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: opt, children: opt }, opt))
533
+ }
534
+ )
535
+ ] });
536
+ }
537
+ if (type === "integer" || type === "biginteger" || type === "float" || type === "decimal") {
538
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: fieldStyle, children: [
539
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
540
+ /* @__PURE__ */ jsxRuntime.jsx(
541
+ designSystem.NumberInput,
542
+ {
543
+ value: value != null ? Number(value) : void 0,
544
+ onValueChange: (v) => onChange(name, v),
545
+ disabled: readOnly,
546
+ required
547
+ }
548
+ )
549
+ ] });
550
+ }
551
+ if (type === "json") {
552
+ const jsonStr = value == null ? "" : typeof value === "string" ? value : JSON.stringify(value, null, 2);
553
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: fieldStyle, children: [
554
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
555
+ /* @__PURE__ */ jsxRuntime.jsx(
556
+ designSystem.JSONInput,
557
+ {
558
+ value: jsonStr,
559
+ onChange: (v) => {
560
+ try {
561
+ onChange(name, JSON.parse(v));
562
+ } catch {
563
+ onChange(name, v);
564
+ }
565
+ },
566
+ disabled: readOnly
567
+ }
568
+ )
569
+ ] });
570
+ }
571
+ if (type === "date") {
572
+ const dateStr = value instanceof Date ? value.toISOString().slice(0, 10) : typeof value === "string" ? value.slice(0, 10) : "";
573
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: fieldStyle, children: [
574
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
575
+ /* @__PURE__ */ jsxRuntime.jsx(
576
+ designSystem.TextInput,
577
+ {
578
+ type: "date",
579
+ value: dateStr,
580
+ onChange: (e) => onChange(name, e.target.value),
581
+ disabled: readOnly,
582
+ required
583
+ }
584
+ )
585
+ ] });
586
+ }
587
+ if (type === "datetime" || type === "timestamp") {
588
+ const dtStr = value instanceof Date ? value.toISOString().slice(0, 16) : typeof value === "string" ? value.slice(0, 16) : "";
589
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: fieldStyle, children: [
590
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
591
+ /* @__PURE__ */ jsxRuntime.jsx(
592
+ designSystem.TextInput,
593
+ {
594
+ type: "datetime-local",
595
+ value: dtStr,
596
+ onChange: (e) => onChange(name, e.target.value),
597
+ disabled: readOnly,
598
+ required
599
+ }
600
+ )
601
+ ] });
602
+ }
603
+ if (type === "text" || type === "richtext") {
604
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: fieldStyle, children: [
605
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
606
+ /* @__PURE__ */ jsxRuntime.jsx(
607
+ designSystem.Textarea,
608
+ {
609
+ value: value != null ? String(value) : "",
610
+ onChange: (e) => onChange(name, e.target.value),
611
+ disabled: readOnly
612
+ }
613
+ )
614
+ ] });
615
+ }
616
+ if (type === "relation") {
617
+ return /* @__PURE__ */ jsxRuntime.jsx(
618
+ RelationField,
619
+ {
620
+ name,
621
+ label,
622
+ attribute,
623
+ value,
624
+ onChange,
625
+ readOnly
626
+ }
627
+ );
628
+ }
629
+ const inputType = type === "email" ? "email" : type === "password" ? "password" : type === "time" ? "time" : "text";
630
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { style: fieldStyle, children: [
631
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
632
+ /* @__PURE__ */ jsxRuntime.jsx(
633
+ designSystem.TextInput,
634
+ {
635
+ type: inputType,
636
+ value: value != null ? String(value) : "",
637
+ onChange: (e) => onChange(name, e.target.value),
638
+ disabled: readOnly,
639
+ required
640
+ }
641
+ )
642
+ ] });
643
+ }
644
+ const SKIP_TYPES = /* @__PURE__ */ new Set(["media", "dynamiczone", "blocks", "component"]);
645
+ function CustomFieldsSection({
646
+ fields,
647
+ data,
648
+ onChange
649
+ }) {
650
+ const { formatMessage } = reactIntl.useIntl();
651
+ const renderable = fields.filter((f) => !SKIP_TYPES.has(f.attribute.type));
652
+ if (renderable.length === 0) return null;
653
+ return /* @__PURE__ */ jsxRuntime.jsxs(FormSection, { children: [
654
+ /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: formatMessage({
655
+ id: index.getTranslation("components.dynamicField.customFields"),
656
+ defaultMessage: "Custom fields"
657
+ }) }),
658
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 4, alignItems: "stretch", children: renderable.map((field) => /* @__PURE__ */ jsxRuntime.jsx(
659
+ DynamicField,
660
+ {
661
+ field,
662
+ value: data[field.name],
663
+ onChange
664
+ },
665
+ field.name
666
+ )) })
667
+ ] });
668
+ }
669
+ function EditViewSidePanels({ model, documentId, document }) {
670
+ const panels = index.getEditViewSidePanels(model);
671
+ if (panels.length === 0) return null;
672
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: panels.map(({ id, title, Component }) => /* @__PURE__ */ jsxRuntime.jsxs(FormSection, { children: [
673
+ /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: title }),
674
+ /* @__PURE__ */ jsxRuntime.jsx(
675
+ Component,
676
+ {
677
+ model,
678
+ documentId,
679
+ document
680
+ }
681
+ )
682
+ ] }, id)) });
683
+ }
684
+ const SYSTEM_FIELDS = /* @__PURE__ */ new Set([
685
+ "id",
686
+ "documentId",
687
+ "createdAt",
688
+ "updatedAt",
689
+ "publishedAt",
690
+ "createdBy",
691
+ "updatedBy",
692
+ "locale",
693
+ "localizations"
694
+ ]);
695
+ const MODEL_UID = {
696
+ user: "plugin::better-auth.user",
697
+ organization: "plugin::better-auth.organization"
698
+ };
699
+ function useModelSchema(model) {
700
+ const { get } = admin.useFetchClient();
701
+ const { formatMessage } = reactIntl.useIntl();
702
+ return reactQuery.useQuery({
703
+ queryKey: ["ba-model-schema", model],
704
+ queryFn: async () => {
705
+ const { data } = await get(
706
+ "/content-manager/content-types"
707
+ );
708
+ const uid = MODEL_UID[model];
709
+ const contentType = data.data.find((ct) => ct.uid === uid);
710
+ if (!contentType)
711
+ throw new Error(
712
+ formatMessage(
713
+ {
714
+ id: index.getTranslation("common.errors.contentTypeNotFound"),
715
+ defaultMessage: "Content type {uid} not found"
716
+ },
717
+ { uid }
718
+ )
719
+ );
720
+ const attributes = {};
721
+ for (const [name, attr] of Object.entries(contentType.attributes)) {
722
+ if (SYSTEM_FIELDS.has(name)) continue;
723
+ if (attr.type === "relation" && typeof attr.target === "string" && (attr.target.startsWith("plugin::users-permissions") || attr.target.startsWith("admin::")))
724
+ continue;
725
+ const baOptions = attr.pluginOptions?.["better-auth"];
726
+ if (baOptions?.managed === true) continue;
727
+ attributes[name] = attr;
728
+ }
729
+ return attributes;
730
+ },
731
+ staleTime: 10 * 60 * 1e3,
732
+ retry: false
733
+ });
734
+ }
735
+ exports.AccountRow = AccountRow;
736
+ exports.Code = Code;
737
+ exports.ConfirmDialog = ConfirmDialog;
738
+ exports.CustomFieldsSection = CustomFieldsSection;
739
+ exports.DangerRow = DangerRow;
740
+ exports.EditLayout = EditLayout;
741
+ exports.EditSidebar = EditSidebar;
742
+ exports.EditViewSidePanels = EditViewSidePanels;
743
+ exports.FormSection = FormSection;
744
+ exports.MediaPickerField = MediaPickerField;
745
+ exports.MetaItem = MetaItem;
746
+ exports.MetaKey = MetaKey;
747
+ exports.MetaVal = MetaVal;
748
+ exports.MonoChip = MonoChip;
749
+ exports.PreviewPill = PreviewPill;
750
+ exports.ProviderBadge = ProviderBadge;
751
+ exports.RoleBadge = RoleBadge;
752
+ exports.SectionLabel = SectionLabel;
753
+ exports.SheetDialog = SheetDialog;
754
+ exports.WarnCard = WarnCard;
755
+ exports.useModelSchema = useModelSchema;
756
+ exports.withContext = withContext;