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