opacacms 0.1.11 → 0.1.13
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/admin/index.js +9464 -21
- package/dist/admin/webcomponent.d.ts +1 -1
- package/dist/admin/webcomponent.js +9620 -6
- package/dist/admin.css +1 -0
- package/dist/{chunk-6dhs73zq.js → chunk-0am1m47g.js} +1 -1
- package/dist/{chunk-0nf7fe26.js → chunk-0d9aqz6z.js} +1 -1
- package/dist/{chunk-cvdd4eqh.js → chunk-2kyhqvhc.js} +5 -1
- package/dist/{chunk-gjjcc4hm.js → chunk-2z8wxx9g.js} +21 -6
- package/dist/{chunk-xg35h5a3.js → chunk-7fyepksb.js} +1 -1
- package/dist/{chunk-njytmdb4.js → chunk-pxh5encs.js} +34 -24
- package/dist/{chunk-n8aekdnr.js → chunk-qkn1ykrj.js} +33 -23
- package/dist/{chunk-kwp83w8b.js → chunk-wmvjvn7b.js} +4 -4
- package/dist/{chunk-qrt22f6e.js → chunk-wq314kkx.js} +35 -25
- package/dist/{chunk-eqtsfyjf.js → chunk-x2ejaftz.js} +52 -28
- package/dist/{chunk-6ew02s0c.js → chunk-xtwc125q.js} +18 -18
- package/dist/cli/index.js +5 -5
- package/dist/db/better-sqlite.d.ts +1 -0
- package/dist/db/better-sqlite.js +3 -3
- package/dist/db/bun-sqlite.d.ts +1 -0
- package/dist/db/bun-sqlite.js +3 -3
- package/dist/db/d1.js +3 -3
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.js +17 -13
- package/dist/db/postgres.js +3 -3
- package/dist/db/sqlite.js +3 -3
- package/dist/runtimes/bun.js +2 -2
- package/dist/runtimes/cloudflare-workers.js +2 -2
- package/dist/runtimes/next.js +2 -2
- package/dist/runtimes/node.js +2 -2
- package/dist/server.js +2 -2
- package/package.json +8 -2
- package/bun.lock +0 -34
- package/dist/admin/index.css +0 -47
- package/dist/api.d.ts +0 -6
- package/dist/api.js +0 -27
- package/dist/chunk-2zm8cy1w.js +0 -9482
- package/global.d.ts +0 -11
- package/src/admin/api-client.ts +0 -63
- package/src/admin/auth-client.ts +0 -40
- package/src/admin/custom-field.ts +0 -179
- package/src/admin/index.ts +0 -15
- package/src/admin/react.tsx +0 -72
- package/src/admin/router.ts +0 -9
- package/src/admin/stores/admin-queries.ts +0 -121
- package/src/admin/stores/auth.ts +0 -61
- package/src/admin/stores/column-visibility.ts +0 -67
- package/src/admin/stores/config.ts +0 -15
- package/src/admin/stores/media.ts +0 -95
- package/src/admin/stores/query.ts +0 -13
- package/src/admin/stores/ui.ts +0 -29
- package/src/admin/ui/admin-client.tsx +0 -283
- package/src/admin/ui/admin-layout.tsx +0 -276
- package/src/admin/ui/components/ColumnVisibilityToggle.tsx +0 -141
- package/src/admin/ui/components/DataDetailSheet.tsx +0 -141
- package/src/admin/ui/components/DataDetailView.tsx +0 -175
- package/src/admin/ui/components/Table.tsx +0 -67
- package/src/admin/ui/components/fields/ArrayField.tsx +0 -166
- package/src/admin/ui/components/fields/BlocksField.tsx +0 -202
- package/src/admin/ui/components/fields/BooleanField.tsx +0 -50
- package/src/admin/ui/components/fields/CollapsibleField.tsx +0 -75
- package/src/admin/ui/components/fields/DateField.tsx +0 -45
- package/src/admin/ui/components/fields/FileField.tsx +0 -322
- package/src/admin/ui/components/fields/GroupField.tsx +0 -50
- package/src/admin/ui/components/fields/JoinField.tsx +0 -23
- package/src/admin/ui/components/fields/NumberField.tsx +0 -46
- package/src/admin/ui/components/fields/RadioField.tsx +0 -62
- package/src/admin/ui/components/fields/RelationshipField.tsx +0 -278
- package/src/admin/ui/components/fields/RowField.tsx +0 -40
- package/src/admin/ui/components/fields/SelectField.tsx +0 -59
- package/src/admin/ui/components/fields/TabsField.tsx +0 -101
- package/src/admin/ui/components/fields/TextAreaField.tsx +0 -54
- package/src/admin/ui/components/fields/TextField.tsx +0 -49
- package/src/admin/ui/components/fields/VirtualField.tsx +0 -53
- package/src/admin/ui/components/fields/index.tsx +0 -371
- package/src/admin/ui/components/fields/richtext-editor/index.tsx +0 -211
- package/src/admin/ui/components/fields/richtext-editor/nodes/ImageComponent.tsx +0 -142
- package/src/admin/ui/components/fields/richtext-editor/nodes/ImageNode.tsx +0 -95
- package/src/admin/ui/components/fields/richtext-editor/plugins/ComponentPickerPlugin.tsx +0 -226
- package/src/admin/ui/components/fields/richtext-editor/plugins/EditableSyncPlugin.tsx +0 -16
- package/src/admin/ui/components/fields/richtext-editor/plugins/NotionToolbarPlugin.tsx +0 -184
- package/src/admin/ui/components/fields/richtext-editor/plugins/SimpleToolbarPlugin.tsx +0 -240
- package/src/admin/ui/components/fields/richtext-editor/plugins/ValueSyncPlugin.tsx +0 -40
- package/src/admin/ui/components/fields/utils.ts +0 -1
- package/src/admin/ui/components/link.tsx +0 -41
- package/src/admin/ui/components/media/AssetManagerModal.tsx +0 -334
- package/src/admin/ui/components/toast.tsx +0 -72
- package/src/admin/ui/components/ui/accordion.tsx +0 -51
- package/src/admin/ui/components/ui/alert-dialog.tsx +0 -98
- package/src/admin/ui/components/ui/blocks.tsx +0 -32
- package/src/admin/ui/components/ui/breadcrumbs.tsx +0 -59
- package/src/admin/ui/components/ui/button.tsx +0 -26
- package/src/admin/ui/components/ui/collapsible.tsx +0 -124
- package/src/admin/ui/components/ui/dialog.tsx +0 -79
- package/src/admin/ui/components/ui/group.tsx +0 -20
- package/src/admin/ui/components/ui/index.ts +0 -17
- package/src/admin/ui/components/ui/input.tsx +0 -12
- package/src/admin/ui/components/ui/join.tsx +0 -53
- package/src/admin/ui/components/ui/label.tsx +0 -11
- package/src/admin/ui/components/ui/radio-group.tsx +0 -75
- package/src/admin/ui/components/ui/relationship-detail-sheet.tsx +0 -122
- package/src/admin/ui/components/ui/relationship.tsx +0 -58
- package/src/admin/ui/components/ui/scroll-area.tsx +0 -19
- package/src/admin/ui/components/ui/select.tsx +0 -187
- package/src/admin/ui/components/ui/separator.tsx +0 -21
- package/src/admin/ui/components/ui/sheet.tsx +0 -106
- package/src/admin/ui/components/ui/tabs.tsx +0 -116
- package/src/admin/ui/components/ui/utils.ts +0 -3
- package/src/admin/ui/hooks/use-debounce.ts +0 -15
- package/src/admin/ui/styles/_locale-switcher.scss +0 -33
- package/src/admin/ui/styles/accordion.scss +0 -60
- package/src/admin/ui/styles/animations.scss +0 -41
- package/src/admin/ui/styles/asset-manager.scss +0 -547
- package/src/admin/ui/styles/badge.scss +0 -13
- package/src/admin/ui/styles/base.scss +0 -22
- package/src/admin/ui/styles/button.scss +0 -161
- package/src/admin/ui/styles/card.scss +0 -13
- package/src/admin/ui/styles/collapsible.scss +0 -75
- package/src/admin/ui/styles/data-detail.scss +0 -92
- package/src/admin/ui/styles/dialog.scss +0 -102
- package/src/admin/ui/styles/empty-state.scss +0 -22
- package/src/admin/ui/styles/group.scss +0 -19
- package/src/admin/ui/styles/index.scss +0 -33
- package/src/admin/ui/styles/input.scss +0 -80
- package/src/admin/ui/styles/label.scss +0 -12
- package/src/admin/ui/styles/layout.scss +0 -56
- package/src/admin/ui/styles/lexical.scss +0 -469
- package/src/admin/ui/styles/loading.scss +0 -102
- package/src/admin/ui/styles/media-registry.scss +0 -597
- package/src/admin/ui/styles/pagination.scss +0 -20
- package/src/admin/ui/styles/radio-group.scss +0 -66
- package/src/admin/ui/styles/row.scss +0 -17
- package/src/admin/ui/styles/scrollbar.scss +0 -36
- package/src/admin/ui/styles/select.scss +0 -121
- package/src/admin/ui/styles/separator.scss +0 -14
- package/src/admin/ui/styles/sheet.scss +0 -152
- package/src/admin/ui/styles/sidebar.scss +0 -148
- package/src/admin/ui/styles/switch.scss +0 -59
- package/src/admin/ui/styles/table.scss +0 -207
- package/src/admin/ui/styles/tabs.scss +0 -62
- package/src/admin/ui/styles/toast.scss +0 -45
- package/src/admin/ui/styles/variables.scss +0 -24
- package/src/admin/ui/views/collection-list-view.tsx +0 -720
- package/src/admin/ui/views/dashboard-view.tsx +0 -263
- package/src/admin/ui/views/document-edit-view.tsx +0 -384
- package/src/admin/ui/views/global-edit-view.tsx +0 -226
- package/src/admin/ui/views/init-view.tsx +0 -182
- package/src/admin/ui/views/login-view.tsx +0 -123
- package/src/admin/ui/views/media-registry-view.tsx +0 -1104
- package/src/admin/ui/views/settings-view.tsx +0 -729
- package/src/admin/webcomponent.tsx +0 -15
- package/src/api.ts +0 -9
- package/src/auth/index.ts +0 -194
- package/src/auth/migrations.ts +0 -87
- package/src/auth/premissions.ts +0 -46
- package/src/cli/commands/generate-types.ts +0 -116
- package/src/cli/commands/init.ts +0 -95
- package/src/cli/commands/migrate-commands.ts +0 -160
- package/src/cli/commands/seed-command.ts +0 -11
- package/src/cli/d1-mock.ts +0 -101
- package/src/cli/index.test.ts +0 -84
- package/src/cli/index.ts +0 -183
- package/src/cli/r2-mock.ts +0 -217
- package/src/cli/seeding.ts +0 -409
- package/src/client.ts +0 -181
- package/src/config-utils.ts +0 -102
- package/src/config.ts +0 -49
- package/src/db/adapter.ts +0 -53
- package/src/db/better-sqlite.ts +0 -632
- package/src/db/bun-sqlite.ts +0 -646
- package/src/db/d1.ts +0 -711
- package/src/db/index.ts +0 -6
- package/src/db/kysely/data-mapper.ts +0 -142
- package/src/db/kysely/field-mapper.ts +0 -148
- package/src/db/kysely/migration-generator.ts +0 -223
- package/src/db/kysely/query-builder.ts +0 -92
- package/src/db/kysely/schema-builder.ts +0 -439
- package/src/db/kysely/sql-utils.ts +0 -13
- package/src/db/postgres.ts +0 -621
- package/src/db/sqlite.ts +0 -660
- package/src/db/system-schema.ts +0 -121
- package/src/index.ts +0 -13
- package/src/runtimes/README.md +0 -59
- package/src/runtimes/bun.ts +0 -49
- package/src/runtimes/cloudflare-workers.ts +0 -38
- package/src/runtimes/next.ts +0 -26
- package/src/runtimes/node.ts +0 -52
- package/src/schema/collection.ts +0 -184
- package/src/schema/fields/base.ts +0 -164
- package/src/schema/fields/index.ts +0 -427
- package/src/schema/global.ts +0 -145
- package/src/schema/index.ts +0 -4
- package/src/schema/infer.ts +0 -72
- package/src/server/admin-router.ts +0 -20
- package/src/server/admin.ts +0 -142
- package/src/server/assets.ts +0 -306
- package/src/server/collection-router.ts +0 -55
- package/src/server/handlers.ts +0 -722
- package/src/server/middlewares/admin.ts +0 -27
- package/src/server/middlewares/auth.ts +0 -89
- package/src/server/middlewares/context.ts +0 -17
- package/src/server/middlewares/cors.ts +0 -24
- package/src/server/middlewares/database-init.ts +0 -74
- package/src/server/middlewares/rate-limit.ts +0 -77
- package/src/server/router.ts +0 -47
- package/src/server/setup-middlewares.ts +0 -58
- package/src/server/system-router.ts +0 -35
- package/src/server.ts +0 -9
- package/src/storage/adapters/cloudflare-r2.ts +0 -136
- package/src/storage/adapters/local.ts +0 -146
- package/src/storage/adapters/s3.ts +0 -186
- package/src/storage/errors.ts +0 -46
- package/src/storage/index.ts +0 -5
- package/src/storage/types.ts +0 -39
- package/src/types.ts +0 -577
- package/src/utils/lexical.ts +0 -37
- package/src/utils/logger.ts +0 -73
- package/src/validation.ts +0 -429
- package/src/validator.ts +0 -179
- package/test/admin-custom-field.test.ts +0 -162
- package/test/admin-react-field.test.tsx +0 -134
- package/test/api-features.test.ts +0 -78
- package/test/api.test.ts +0 -178
- package/test/auth.test.ts +0 -62
- package/test/cli-integration.test.ts +0 -148
- package/test/cli.test.ts +0 -25
- package/test/db/postgres.test.ts +0 -95
- package/test/db/sqlite-filter.test.ts +0 -53
- package/test/db/sqlite.test.ts +0 -82
- package/test/engine-features.test.ts +0 -79
- package/test/globals.test.ts +0 -74
- package/test/integration-tmp/db-app/opacacms.config.ts +0 -15
- package/test/integration-tmp/my-sqlite-app/opacacms.config.ts +0 -25
- package/test/integration-tmp/my-test-app/index.ts +0 -8
- package/test/integration-tmp/my-test-app/opacacms.config.ts +0 -16
- package/test/integration-tmp/my-test-app/package.json +0 -12
- package/test/populate.test.ts +0 -79
- package/test/runtimes.test.ts +0 -43
- package/test/schema-builder.test.ts +0 -107
- package/test/schema-features.test.ts +0 -63
- package/test/seeding.test.ts +0 -68
- package/test/storage/local.test.ts +0 -72
- package/test/storage/s3.test.ts +0 -60
- package/test/structural-data.test.ts +0 -100
- package/test/test-setup.ts +0 -11
- package/test/validation.test.ts +0 -162
- package/tsconfig.json +0 -42
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { useStore } from "@nanostores/react";
|
|
2
|
-
import { Check, ChevronDown, Settings2 } from "lucide-react";
|
|
3
|
-
import type React from "react";
|
|
4
|
-
import { useEffect, useRef, useState } from "react";
|
|
5
|
-
import { $columnVisibility, toggleColumnVisibility } from "../../stores/column-visibility";
|
|
6
|
-
|
|
7
|
-
interface ColumnVisibilityToggleProps {
|
|
8
|
-
slug: string;
|
|
9
|
-
fields: { name?: string; label?: string }[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const ColumnVisibilityToggle: React.FC<ColumnVisibilityToggleProps> = ({ slug, fields }) => {
|
|
13
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
14
|
-
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
15
|
-
const visibility = useStore($columnVisibility);
|
|
16
|
-
|
|
17
|
-
const visibleColumns = visibility[slug] || [];
|
|
18
|
-
const selectableFields = fields.filter((f) => f.name);
|
|
19
|
-
|
|
20
|
-
// Close dropdown when clicking outside
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
23
|
-
if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
|
|
24
|
-
setIsOpen(false);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
28
|
-
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
29
|
-
}, []);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className="opaca-column-toggle" ref={dropdownRef} style={{ position: "relative" }}>
|
|
33
|
-
<button
|
|
34
|
-
type="button"
|
|
35
|
-
onClick={() => setIsOpen(!isOpen)}
|
|
36
|
-
className="opaca-btn opaca-btn-outline"
|
|
37
|
-
style={{
|
|
38
|
-
display: "flex",
|
|
39
|
-
alignItems: "center",
|
|
40
|
-
gap: "0.5rem",
|
|
41
|
-
padding: "0.5rem 0.75rem",
|
|
42
|
-
fontSize: "0.875rem",
|
|
43
|
-
}}
|
|
44
|
-
>
|
|
45
|
-
<Settings2 size={16} />
|
|
46
|
-
Columns
|
|
47
|
-
<ChevronDown
|
|
48
|
-
size={14}
|
|
49
|
-
style={{
|
|
50
|
-
opacity: 0.5,
|
|
51
|
-
transform: isOpen ? "rotate(180deg)" : "none",
|
|
52
|
-
transition: "transform 0.2s",
|
|
53
|
-
}}
|
|
54
|
-
/>
|
|
55
|
-
</button>
|
|
56
|
-
|
|
57
|
-
{isOpen && (
|
|
58
|
-
<div
|
|
59
|
-
className="opaca-card shadow-lg"
|
|
60
|
-
style={{
|
|
61
|
-
position: "absolute",
|
|
62
|
-
top: "calc(100% + 0.5rem)",
|
|
63
|
-
right: 0,
|
|
64
|
-
zIndex: 100,
|
|
65
|
-
minWidth: "200px",
|
|
66
|
-
padding: "0.5rem",
|
|
67
|
-
maxHeight: "300px",
|
|
68
|
-
overflowY: "auto",
|
|
69
|
-
border: "1px solid var(--opaca-border)",
|
|
70
|
-
backgroundColor: "var(--opaca-card-bg)",
|
|
71
|
-
borderRadius: "var(--opaca-radius)",
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
74
|
-
<div
|
|
75
|
-
style={{
|
|
76
|
-
padding: "0.5rem",
|
|
77
|
-
fontSize: "0.75rem",
|
|
78
|
-
fontWeight: 600,
|
|
79
|
-
color: "var(--opaca-text-dim)",
|
|
80
|
-
borderBottom: "1px solid var(--opaca-border)",
|
|
81
|
-
marginBottom: "0.25rem",
|
|
82
|
-
}}
|
|
83
|
-
>
|
|
84
|
-
Toggle Columns
|
|
85
|
-
</div>
|
|
86
|
-
{selectableFields.map((field) => {
|
|
87
|
-
const isVisible = visibleColumns.includes(field.name!);
|
|
88
|
-
return (
|
|
89
|
-
<button
|
|
90
|
-
key={field.name}
|
|
91
|
-
type="button"
|
|
92
|
-
onClick={() => toggleColumnVisibility(slug, field.name!)}
|
|
93
|
-
style={{
|
|
94
|
-
width: "100%",
|
|
95
|
-
display: "flex",
|
|
96
|
-
alignItems: "center",
|
|
97
|
-
gap: "0.75rem",
|
|
98
|
-
padding: "0.5rem 0.75rem",
|
|
99
|
-
fontSize: "0.875rem",
|
|
100
|
-
textAlign: "left",
|
|
101
|
-
background: "none",
|
|
102
|
-
border: "none",
|
|
103
|
-
color: isVisible ? "var(--opaca-text)" : "var(--opaca-text-dim)",
|
|
104
|
-
cursor: "pointer",
|
|
105
|
-
borderRadius: "calc(var(--opaca-radius) - 4px)",
|
|
106
|
-
transition: "background 0.2s",
|
|
107
|
-
}}
|
|
108
|
-
className="hover-bg"
|
|
109
|
-
>
|
|
110
|
-
<div
|
|
111
|
-
style={{
|
|
112
|
-
width: "16px",
|
|
113
|
-
height: "16px",
|
|
114
|
-
display: "flex",
|
|
115
|
-
alignItems: "center",
|
|
116
|
-
justifyContent: "center",
|
|
117
|
-
border: isVisible
|
|
118
|
-
? "1px solid var(--opaca-primary)"
|
|
119
|
-
: "1px solid var(--opaca-border)",
|
|
120
|
-
backgroundColor: isVisible ? "var(--opaca-primary)" : "transparent",
|
|
121
|
-
borderRadius: "4px",
|
|
122
|
-
color: "white",
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
{isVisible && <Check size={12} strokeWidth={3} />}
|
|
126
|
-
</div>
|
|
127
|
-
<span style={{ flex: 1 }}>{field.label || field.name}</span>
|
|
128
|
-
</button>
|
|
129
|
-
);
|
|
130
|
-
})}
|
|
131
|
-
</div>
|
|
132
|
-
)}
|
|
133
|
-
|
|
134
|
-
<style>{`
|
|
135
|
-
.hover-bg:hover {
|
|
136
|
-
background-color: var(--opaca-panel-bg) !important;
|
|
137
|
-
}
|
|
138
|
-
`}</style>
|
|
139
|
-
</div>
|
|
140
|
-
);
|
|
141
|
-
};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Edit2, Save, X } from "lucide-react";
|
|
2
|
-
import type React from "react";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { DataDetailView } from "./DataDetailView";
|
|
5
|
-
import { Button } from "./ui/button";
|
|
6
|
-
import { ScrollArea } from "./ui/scroll-area";
|
|
7
|
-
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "./ui/sheet";
|
|
8
|
-
import "../styles/data-detail.scss";
|
|
9
|
-
|
|
10
|
-
interface DataDetailSheetProps {
|
|
11
|
-
open: boolean;
|
|
12
|
-
onOpenChange: (open: boolean) => void;
|
|
13
|
-
title: string;
|
|
14
|
-
description?: string;
|
|
15
|
-
data: any;
|
|
16
|
-
onSave?: (updatedData: any) => void;
|
|
17
|
-
field?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
import { useStore } from "@nanostores/react";
|
|
21
|
-
import { $config } from "../../stores/config";
|
|
22
|
-
|
|
23
|
-
export const DataDetailSheet: React.FC<DataDetailSheetProps> = ({
|
|
24
|
-
open,
|
|
25
|
-
onOpenChange,
|
|
26
|
-
title,
|
|
27
|
-
description,
|
|
28
|
-
data: initialData,
|
|
29
|
-
onSave,
|
|
30
|
-
field,
|
|
31
|
-
}) => {
|
|
32
|
-
const [isEditing, setIsEditing] = useState(false);
|
|
33
|
-
const [data, setData] = useState(initialData);
|
|
34
|
-
|
|
35
|
-
const config = useStore($config) as any;
|
|
36
|
-
const i18nConfig = config?.i18n;
|
|
37
|
-
|
|
38
|
-
const [activeLocale, setActiveLocale] = useState(i18nConfig?.defaultLocale || "default");
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
setData(initialData);
|
|
42
|
-
setIsEditing(false);
|
|
43
|
-
if (i18nConfig) {
|
|
44
|
-
setActiveLocale(i18nConfig.defaultLocale);
|
|
45
|
-
}
|
|
46
|
-
}, [initialData, open, i18nConfig]);
|
|
47
|
-
|
|
48
|
-
const handleSave = () => {
|
|
49
|
-
if (onSave) {
|
|
50
|
-
onSave(data);
|
|
51
|
-
}
|
|
52
|
-
setIsEditing(false);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<Sheet open={open} onOpenChange={onOpenChange}>
|
|
57
|
-
<SheetContent onClose={() => onOpenChange(false)} className="opaca-data-detail-sheet">
|
|
58
|
-
<div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
|
|
59
|
-
<SheetHeader>
|
|
60
|
-
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
|
61
|
-
<div>
|
|
62
|
-
<SheetTitle>{title}</SheetTitle>
|
|
63
|
-
{description && <SheetDescription>{description}</SheetDescription>}
|
|
64
|
-
</div>
|
|
65
|
-
{onSave && (
|
|
66
|
-
<div style={{ display: "flex", gap: "0.5rem", alignItems: "center" }}>
|
|
67
|
-
{isEditing && i18nConfig && i18nConfig.locales.length > 0 && (
|
|
68
|
-
<div
|
|
69
|
-
style={{
|
|
70
|
-
display: "flex",
|
|
71
|
-
borderRight: "1px solid var(--border)",
|
|
72
|
-
paddingRight: "0.5rem",
|
|
73
|
-
marginRight: "0.5rem",
|
|
74
|
-
gap: "0.25rem",
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
{i18nConfig.locales.map((locale: string) => (
|
|
78
|
-
<Button
|
|
79
|
-
key={locale}
|
|
80
|
-
variant={activeLocale === locale ? "default" : "outline"}
|
|
81
|
-
size="sm"
|
|
82
|
-
onClick={() => setActiveLocale(locale)}
|
|
83
|
-
style={{ height: "32px", fontSize: "12px" }}
|
|
84
|
-
>
|
|
85
|
-
{locale.toUpperCase()}
|
|
86
|
-
</Button>
|
|
87
|
-
))}
|
|
88
|
-
</div>
|
|
89
|
-
)}
|
|
90
|
-
{!isEditing ? (
|
|
91
|
-
<Button
|
|
92
|
-
variant="outline"
|
|
93
|
-
size="sm"
|
|
94
|
-
onClick={() => setIsEditing(true)}
|
|
95
|
-
style={{ height: "32px", gap: "4px" }}
|
|
96
|
-
>
|
|
97
|
-
<Edit2 size={14} />
|
|
98
|
-
Edit
|
|
99
|
-
</Button>
|
|
100
|
-
) : (
|
|
101
|
-
<>
|
|
102
|
-
<Button
|
|
103
|
-
variant="ghost"
|
|
104
|
-
size="sm"
|
|
105
|
-
onClick={() => {
|
|
106
|
-
setData(initialData);
|
|
107
|
-
setIsEditing(false);
|
|
108
|
-
}}
|
|
109
|
-
style={{ height: "32px", gap: "4px" }}
|
|
110
|
-
>
|
|
111
|
-
<X size={14} />
|
|
112
|
-
Cancel
|
|
113
|
-
</Button>
|
|
114
|
-
<Button
|
|
115
|
-
variant="default"
|
|
116
|
-
size="sm"
|
|
117
|
-
onClick={handleSave}
|
|
118
|
-
style={{ height: "32px", gap: "4px" }}
|
|
119
|
-
>
|
|
120
|
-
<Save size={14} />
|
|
121
|
-
Save
|
|
122
|
-
</Button>
|
|
123
|
-
</>
|
|
124
|
-
)}
|
|
125
|
-
</div>
|
|
126
|
-
)}
|
|
127
|
-
</div>
|
|
128
|
-
</SheetHeader>
|
|
129
|
-
|
|
130
|
-
<div style={{ flex: 1, minHeight: 0, marginTop: "1.5rem" }}>
|
|
131
|
-
<ScrollArea style={{ height: "100%" }}>
|
|
132
|
-
<div style={{ paddingRight: "1rem", paddingBottom: "2rem" }}>
|
|
133
|
-
<DataDetailView data={data} isEditing={isEditing} onChange={setData} />
|
|
134
|
-
</div>
|
|
135
|
-
</ScrollArea>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
</SheetContent>
|
|
139
|
-
</Sheet>
|
|
140
|
-
);
|
|
141
|
-
};
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { RichTextEditor } from "./fields/richtext-editor";
|
|
2
|
-
import { Input } from "./ui/input";
|
|
3
|
-
import { cn } from "./ui/utils";
|
|
4
|
-
|
|
5
|
-
interface DataDetailViewProps {
|
|
6
|
-
data: any;
|
|
7
|
-
label?: string;
|
|
8
|
-
depth?: number;
|
|
9
|
-
isEditing?: boolean;
|
|
10
|
-
onChange?: (data: any) => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const DataDetailView: React.FC<DataDetailViewProps> = ({
|
|
14
|
-
data,
|
|
15
|
-
label,
|
|
16
|
-
depth = 0,
|
|
17
|
-
isEditing,
|
|
18
|
-
onChange,
|
|
19
|
-
}) => {
|
|
20
|
-
if (data === null || data === undefined) {
|
|
21
|
-
return <span className="opaca-text-muted">None</span>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Handle arrays (Blocks or HasMany Relationships)
|
|
25
|
-
if (Array.isArray(data)) {
|
|
26
|
-
if (data.length === 0) return <span className="opaca-text-muted">Empty</span>;
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div className="opaca-detail-list">
|
|
30
|
-
{data.map((item, index) => (
|
|
31
|
-
<div key={item || index} className="opaca-detail-item-card">
|
|
32
|
-
{item?.blockType && (
|
|
33
|
-
<div className="opaca-detail-item-header">
|
|
34
|
-
<span className="opaca-badge">{item.blockType}</span>
|
|
35
|
-
</div>
|
|
36
|
-
)}
|
|
37
|
-
<div className="opaca-detail-item-content">
|
|
38
|
-
{typeof item === "object" ? (
|
|
39
|
-
<DataDetailView
|
|
40
|
-
data={item}
|
|
41
|
-
depth={depth + 1}
|
|
42
|
-
isEditing={isEditing}
|
|
43
|
-
onChange={(val) => {
|
|
44
|
-
const newData = [...data];
|
|
45
|
-
newData[index] = val;
|
|
46
|
-
onChange?.(newData);
|
|
47
|
-
}}
|
|
48
|
-
/>
|
|
49
|
-
) : isEditing ? (
|
|
50
|
-
<Input
|
|
51
|
-
value={String(item)}
|
|
52
|
-
onChange={(e) => {
|
|
53
|
-
const newData = [...data];
|
|
54
|
-
newData[index] = e.target.value;
|
|
55
|
-
onChange?.(newData);
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
) : (
|
|
59
|
-
<span className="opaca-detail-value">{String(item)}</span>
|
|
60
|
-
)}
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
))}
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Handle objects or strings that might be Lexical JSON
|
|
69
|
-
const isLexicalJSON = (val: unknown): boolean => {
|
|
70
|
-
if (!val) return false;
|
|
71
|
-
|
|
72
|
-
if (typeof val === "object") {
|
|
73
|
-
return val !== null && "root" in val;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (typeof val === "string") {
|
|
77
|
-
const trimmed = val.trim();
|
|
78
|
-
|
|
79
|
-
if (!trimmed.startsWith("{")) return false;
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
const parsed = JSON.parse(trimmed);
|
|
83
|
-
return parsed && typeof parsed === "object" && "root" in parsed;
|
|
84
|
-
} catch {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return false;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
if (isLexicalJSON(data) && depth === 0) {
|
|
93
|
-
let valueToEdit = data;
|
|
94
|
-
if (typeof data === "object") {
|
|
95
|
-
try {
|
|
96
|
-
valueToEdit = JSON.stringify(data);
|
|
97
|
-
} catch (e) {}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<div className="opaca-detail-richtext-preview">
|
|
102
|
-
<RichTextEditor
|
|
103
|
-
value={valueToEdit}
|
|
104
|
-
onChange={(val) => {
|
|
105
|
-
try {
|
|
106
|
-
onChange?.(JSON.parse(val));
|
|
107
|
-
} catch (e) {
|
|
108
|
-
onChange?.(val);
|
|
109
|
-
}
|
|
110
|
-
}}
|
|
111
|
-
readOnly={!isEditing}
|
|
112
|
-
/>
|
|
113
|
-
</div>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Handle objects (Groups or Block contents)
|
|
118
|
-
if (typeof data === "object" && data !== null) {
|
|
119
|
-
const keys = Object.keys(data).filter(
|
|
120
|
-
(k) => k !== "blockType" && k !== "id" && k !== "_order" && !k.startsWith("_"),
|
|
121
|
-
);
|
|
122
|
-
if (keys.length === 0) return <span className="opaca-text-muted">Empty Object</span>;
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<div className={cn("opaca-detail-grid", depth > 0 && "nested")}>
|
|
126
|
-
{keys.map((key) => (
|
|
127
|
-
<div key={key} className="opaca-detail-row">
|
|
128
|
-
<span className="opaca-detail-label">
|
|
129
|
-
{key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase())}
|
|
130
|
-
</span>
|
|
131
|
-
<div className="opaca-detail-value-container">
|
|
132
|
-
{typeof data[key] === "object" && data[key] !== null ? (
|
|
133
|
-
<DataDetailView
|
|
134
|
-
data={data[key]}
|
|
135
|
-
depth={depth + 1}
|
|
136
|
-
isEditing={isEditing}
|
|
137
|
-
onChange={(val) => {
|
|
138
|
-
onChange?.({ ...data, [key]: val });
|
|
139
|
-
}}
|
|
140
|
-
/>
|
|
141
|
-
) : isEditing ? (
|
|
142
|
-
<Input
|
|
143
|
-
value={
|
|
144
|
-
data[key] === true
|
|
145
|
-
? "true"
|
|
146
|
-
: data[key] === false
|
|
147
|
-
? "false"
|
|
148
|
-
: String(data[key] ?? "")
|
|
149
|
-
}
|
|
150
|
-
onChange={(e) => {
|
|
151
|
-
let val: any = e.target.value;
|
|
152
|
-
if (val === "true") val = true;
|
|
153
|
-
if (val === "false") val = false;
|
|
154
|
-
onChange?.({ ...data, [key]: val });
|
|
155
|
-
}}
|
|
156
|
-
/>
|
|
157
|
-
) : (
|
|
158
|
-
<span className="opaca-detail-value">
|
|
159
|
-
{data[key] === true
|
|
160
|
-
? "Yes"
|
|
161
|
-
: data[key] === false
|
|
162
|
-
? "No"
|
|
163
|
-
: String(data[key] ?? "-")}
|
|
164
|
-
</span>
|
|
165
|
-
)}
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
))}
|
|
169
|
-
</div>
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Fallback for primitives
|
|
174
|
-
return <span className="opaca-detail-value">{String(data)}</span>;
|
|
175
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
|
|
4
|
-
({ className, ...props }, ref) => (
|
|
5
|
-
<div className="opaca-table-wrapper">
|
|
6
|
-
<table ref={ref} className={`opaca-new-table ${className || ""}`} {...props} />
|
|
7
|
-
</div>
|
|
8
|
-
),
|
|
9
|
-
);
|
|
10
|
-
Table.displayName = "Table";
|
|
11
|
-
|
|
12
|
-
const TableHeader = React.forwardRef<
|
|
13
|
-
HTMLTableSectionElement,
|
|
14
|
-
React.HTMLAttributes<HTMLTableSectionElement>
|
|
15
|
-
>(({ className, ...props }, ref) => (
|
|
16
|
-
<thead ref={ref} className={`opaca-table-header ${className || ""}`} {...props} />
|
|
17
|
-
));
|
|
18
|
-
TableHeader.displayName = "TableHeader";
|
|
19
|
-
|
|
20
|
-
const TableBody = React.forwardRef<
|
|
21
|
-
HTMLTableSectionElement,
|
|
22
|
-
React.HTMLAttributes<HTMLTableSectionElement>
|
|
23
|
-
>(({ className, ...props }, ref) => (
|
|
24
|
-
<tbody ref={ref} className={`opaca-table-body ${className || ""}`} {...props} />
|
|
25
|
-
));
|
|
26
|
-
TableBody.displayName = "TableBody";
|
|
27
|
-
|
|
28
|
-
const TableFooter = React.forwardRef<
|
|
29
|
-
HTMLTableSectionElement,
|
|
30
|
-
React.HTMLAttributes<HTMLTableSectionElement>
|
|
31
|
-
>(({ className, ...props }, ref) => (
|
|
32
|
-
<tfoot ref={ref} className={`opaca-table-footer ${className || ""}`} {...props} />
|
|
33
|
-
));
|
|
34
|
-
TableFooter.displayName = "TableFooter";
|
|
35
|
-
|
|
36
|
-
const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(
|
|
37
|
-
({ className, ...props }, ref) => (
|
|
38
|
-
<tr ref={ref} className={`opaca-table-row ${className || ""}`} {...props} />
|
|
39
|
-
),
|
|
40
|
-
);
|
|
41
|
-
TableRow.displayName = "TableRow";
|
|
42
|
-
|
|
43
|
-
const TableHead = React.forwardRef<
|
|
44
|
-
HTMLTableCellElement,
|
|
45
|
-
React.ThHTMLAttributes<HTMLTableCellElement>
|
|
46
|
-
>(({ className, ...props }, ref) => (
|
|
47
|
-
<th ref={ref} className={`opaca-table-head ${className || ""}`} {...props} />
|
|
48
|
-
));
|
|
49
|
-
TableHead.displayName = "TableHead";
|
|
50
|
-
|
|
51
|
-
const TableCell = React.forwardRef<
|
|
52
|
-
HTMLTableCellElement,
|
|
53
|
-
React.TdHTMLAttributes<HTMLTableCellElement>
|
|
54
|
-
>(({ className, ...props }, ref) => (
|
|
55
|
-
<td ref={ref} className={`opaca-table-cell ${className || ""}`} {...props} />
|
|
56
|
-
));
|
|
57
|
-
TableCell.displayName = "TableCell";
|
|
58
|
-
|
|
59
|
-
const TableCaption = React.forwardRef<
|
|
60
|
-
HTMLTableCaptionElement,
|
|
61
|
-
React.HTMLAttributes<HTMLTableCaptionElement>
|
|
62
|
-
>(({ className, ...props }, ref) => (
|
|
63
|
-
<caption ref={ref} className={`opaca-table-caption ${className || ""}`} {...props} />
|
|
64
|
-
));
|
|
65
|
-
TableCaption.displayName = "TableCaption";
|
|
66
|
-
|
|
67
|
-
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Plus, Trash2 } from "lucide-react";
|
|
2
|
-
import type React from "react";
|
|
3
|
-
import { Button } from "../ui/button";
|
|
4
|
-
import { capitalize } from "./utils";
|
|
5
|
-
|
|
6
|
-
interface ArrayFieldProps {
|
|
7
|
-
name: string;
|
|
8
|
-
label?: string;
|
|
9
|
-
fields: any[];
|
|
10
|
-
value: any[];
|
|
11
|
-
onChange: (val: any[]) => void;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
readOnly?: boolean;
|
|
14
|
-
renderField: (field: any, value: any, onChange: (val: any) => void) => React.ReactNode;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const ArrayField: React.FC<ArrayFieldProps> = ({
|
|
18
|
-
name,
|
|
19
|
-
label,
|
|
20
|
-
fields = [],
|
|
21
|
-
value = [],
|
|
22
|
-
onChange,
|
|
23
|
-
disabled,
|
|
24
|
-
readOnly,
|
|
25
|
-
renderField,
|
|
26
|
-
}) => {
|
|
27
|
-
const addItem = () => {
|
|
28
|
-
const currentValue = Array.isArray(value) ? value : [];
|
|
29
|
-
const initialData: Record<string, any> = {};
|
|
30
|
-
|
|
31
|
-
fields.forEach((f) => {
|
|
32
|
-
if (f.name) {
|
|
33
|
-
if (f.defaultValue !== undefined) {
|
|
34
|
-
initialData[f.name] = f.defaultValue;
|
|
35
|
-
} else if (f.type === "boolean") {
|
|
36
|
-
initialData[f.name] = false;
|
|
37
|
-
} else if (f.type === "number") {
|
|
38
|
-
initialData[f.name] = 0;
|
|
39
|
-
} else if (f.type === "relationship" && f.hasMany) {
|
|
40
|
-
initialData[f.name] = [];
|
|
41
|
-
} else if (f.type === "blocks") {
|
|
42
|
-
initialData[f.name] = [];
|
|
43
|
-
} else if (f.type === "array") {
|
|
44
|
-
initialData[f.name] = [];
|
|
45
|
-
} else {
|
|
46
|
-
initialData[f.name] = "";
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
onChange([...currentValue, initialData]);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const removeItem = (index: number) => {
|
|
55
|
-
const currentValue = Array.isArray(value) ? value : [];
|
|
56
|
-
const newValue = [...currentValue];
|
|
57
|
-
newValue.splice(index, 1);
|
|
58
|
-
onChange(newValue);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const updateItemData = (index: number, fieldName: string, fieldValue: any) => {
|
|
62
|
-
const currentValue = Array.isArray(value) ? value : [];
|
|
63
|
-
const newValue = [...currentValue];
|
|
64
|
-
newValue[index] = {
|
|
65
|
-
...newValue[index],
|
|
66
|
-
[fieldName]: fieldValue,
|
|
67
|
-
};
|
|
68
|
-
onChange(newValue);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const updateRawItemData = (index: number, fieldValue: any) => {
|
|
72
|
-
const currentValue = Array.isArray(value) ? value : [];
|
|
73
|
-
const newValue = [...currentValue];
|
|
74
|
-
newValue[index] = fieldValue;
|
|
75
|
-
onChange(newValue);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<div className="opaca-array-field">
|
|
80
|
-
<div
|
|
81
|
-
style={{
|
|
82
|
-
display: "flex",
|
|
83
|
-
justifyContent: "space-between",
|
|
84
|
-
alignItems: "center",
|
|
85
|
-
marginBottom: "0.75rem",
|
|
86
|
-
}}
|
|
87
|
-
>
|
|
88
|
-
<label htmlFor={name} className="opaca-label" style={{ marginBottom: 0 }}>
|
|
89
|
-
{label || capitalize(name)}
|
|
90
|
-
</label>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
94
|
-
{(Array.isArray(value) ? value : []).map((item, index) => (
|
|
95
|
-
<div
|
|
96
|
-
key={item || index}
|
|
97
|
-
style={{
|
|
98
|
-
border: "1px solid var(--opaca-border)",
|
|
99
|
-
borderRadius: "var(--opaca-radius-lg)",
|
|
100
|
-
backgroundColor: "rgba(255, 255, 255, 0.02)",
|
|
101
|
-
padding: "1rem",
|
|
102
|
-
position: "relative",
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
<div
|
|
106
|
-
style={{
|
|
107
|
-
display: "flex",
|
|
108
|
-
justifyContent: "flex-end",
|
|
109
|
-
marginBottom: "0.5rem",
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
{!disabled && !readOnly && (
|
|
113
|
-
<Button
|
|
114
|
-
type="button"
|
|
115
|
-
variant="ghost"
|
|
116
|
-
size="icon"
|
|
117
|
-
onClick={() => removeItem(index)}
|
|
118
|
-
style={{
|
|
119
|
-
color: "var(--opaca-text-dim)",
|
|
120
|
-
height: "24px",
|
|
121
|
-
width: "24px",
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
<Trash2 size={14} />
|
|
125
|
-
</Button>
|
|
126
|
-
)}
|
|
127
|
-
</div>
|
|
128
|
-
|
|
129
|
-
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
|
|
130
|
-
{fields.map((field, fieldIndex) => (
|
|
131
|
-
<div key={field.name || fieldIndex} className="array-field-item">
|
|
132
|
-
{renderField(field, field.name ? item[field.name] : item, (val) => {
|
|
133
|
-
if (field.name) {
|
|
134
|
-
updateItemData(index, field.name, val);
|
|
135
|
-
} else {
|
|
136
|
-
updateRawItemData(index, val);
|
|
137
|
-
}
|
|
138
|
-
})}
|
|
139
|
-
</div>
|
|
140
|
-
))}
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
))}
|
|
144
|
-
|
|
145
|
-
{!disabled && !readOnly && (
|
|
146
|
-
<Button
|
|
147
|
-
type="button"
|
|
148
|
-
variant="outline"
|
|
149
|
-
size="sm"
|
|
150
|
-
onClick={addItem}
|
|
151
|
-
style={{
|
|
152
|
-
display: "flex",
|
|
153
|
-
alignItems: "center",
|
|
154
|
-
gap: "6px",
|
|
155
|
-
fontSize: "0.75rem",
|
|
156
|
-
width: "fit-content",
|
|
157
|
-
}}
|
|
158
|
-
>
|
|
159
|
-
<Plus size={12} />
|
|
160
|
-
Add Item
|
|
161
|
-
</Button>
|
|
162
|
-
)}
|
|
163
|
-
</div>
|
|
164
|
-
</div>
|
|
165
|
-
);
|
|
166
|
-
};
|