opacacms 0.1.0 → 0.1.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 (247) hide show
  1. package/dist/admin/index.js +49 -0
  2. package/dist/{chunk-2zm8cy1w.js → admin/webcomponent.js} +116 -168
  3. package/dist/{chunk-6dhs73zq.js → chunk-2yz1nsxs.js} +1 -1
  4. package/dist/chunk-fa5mg0hr.js +96 -0
  5. package/dist/{chunk-kwp83w8b.js → chunk-m09hahe2.js} +7 -7
  6. package/dist/{chunk-hmhcense.js → chunk-ry15hke8.js} +253 -4
  7. package/dist/chunk-vtvqfhgy.js +2442 -0
  8. package/dist/{chunk-f3nvxn63.js → chunk-y8hc6nm4.js} +1 -1
  9. package/dist/{src/cli → cli}/index.js +10 -10
  10. package/dist/{src/client.js → client.js} +2 -2
  11. package/dist/{src/db → db}/bun-sqlite.js +10 -10
  12. package/dist/{src/db → db}/d1.js +8 -8
  13. package/dist/db/index.d.ts +2 -0
  14. package/dist/db/index.js +7 -0
  15. package/dist/db/migration.d.ts +39 -0
  16. package/dist/{src/db → db}/postgres.js +10 -10
  17. package/dist/{src/db → db}/sqlite.js +8 -8
  18. package/dist/index.d.ts +0 -2
  19. package/dist/index.js +13 -0
  20. package/dist/{src/runtimes → runtimes}/bun.js +5 -6
  21. package/dist/{src/runtimes → runtimes}/cloudflare-workers.js +5 -6
  22. package/dist/{src/runtimes → runtimes}/next.js +5 -6
  23. package/dist/{src/runtimes → runtimes}/node.js +5 -6
  24. package/dist/{src/server.js → server.js} +7 -8
  25. package/dist/storage/index.d.ts +0 -3
  26. package/dist/storage/index.js +35 -0
  27. package/dist/types.d.ts +5 -2
  28. package/package.json +161 -39
  29. package/bun.lock +0 -34
  30. package/dist/api.d.ts +0 -6
  31. package/dist/chunk-8gkhn1d4.js +0 -309
  32. package/dist/chunk-dy5t83hr.js +0 -261
  33. package/dist/src/admin/index.js +0 -176
  34. package/dist/src/admin/webcomponent.js +0 -19
  35. package/dist/src/api.js +0 -27
  36. package/dist/src/index.js +0 -20
  37. package/dist/src/storage/index.js +0 -355
  38. package/global.d.ts +0 -11
  39. package/src/admin/api-client.ts +0 -63
  40. package/src/admin/auth-client.ts +0 -40
  41. package/src/admin/custom-field.ts +0 -179
  42. package/src/admin/index.ts +0 -15
  43. package/src/admin/react.tsx +0 -72
  44. package/src/admin/router.ts +0 -9
  45. package/src/admin/stores/admin-queries.ts +0 -121
  46. package/src/admin/stores/auth.ts +0 -61
  47. package/src/admin/stores/column-visibility.ts +0 -67
  48. package/src/admin/stores/config.ts +0 -15
  49. package/src/admin/stores/media.ts +0 -95
  50. package/src/admin/stores/query.ts +0 -13
  51. package/src/admin/stores/ui.ts +0 -29
  52. package/src/admin/ui/admin-client.tsx +0 -283
  53. package/src/admin/ui/admin-layout.tsx +0 -276
  54. package/src/admin/ui/components/ColumnVisibilityToggle.tsx +0 -141
  55. package/src/admin/ui/components/DataDetailSheet.tsx +0 -141
  56. package/src/admin/ui/components/DataDetailView.tsx +0 -175
  57. package/src/admin/ui/components/Table.tsx +0 -67
  58. package/src/admin/ui/components/fields/ArrayField.tsx +0 -166
  59. package/src/admin/ui/components/fields/BlocksField.tsx +0 -202
  60. package/src/admin/ui/components/fields/BooleanField.tsx +0 -50
  61. package/src/admin/ui/components/fields/CollapsibleField.tsx +0 -75
  62. package/src/admin/ui/components/fields/DateField.tsx +0 -45
  63. package/src/admin/ui/components/fields/FileField.tsx +0 -322
  64. package/src/admin/ui/components/fields/GroupField.tsx +0 -50
  65. package/src/admin/ui/components/fields/JoinField.tsx +0 -23
  66. package/src/admin/ui/components/fields/NumberField.tsx +0 -46
  67. package/src/admin/ui/components/fields/RadioField.tsx +0 -62
  68. package/src/admin/ui/components/fields/RelationshipField.tsx +0 -278
  69. package/src/admin/ui/components/fields/RowField.tsx +0 -40
  70. package/src/admin/ui/components/fields/SelectField.tsx +0 -59
  71. package/src/admin/ui/components/fields/TabsField.tsx +0 -101
  72. package/src/admin/ui/components/fields/TextAreaField.tsx +0 -54
  73. package/src/admin/ui/components/fields/TextField.tsx +0 -49
  74. package/src/admin/ui/components/fields/VirtualField.tsx +0 -53
  75. package/src/admin/ui/components/fields/index.tsx +0 -371
  76. package/src/admin/ui/components/fields/richtext-editor/index.tsx +0 -211
  77. package/src/admin/ui/components/fields/richtext-editor/nodes/ImageComponent.tsx +0 -142
  78. package/src/admin/ui/components/fields/richtext-editor/nodes/ImageNode.tsx +0 -95
  79. package/src/admin/ui/components/fields/richtext-editor/plugins/ComponentPickerPlugin.tsx +0 -226
  80. package/src/admin/ui/components/fields/richtext-editor/plugins/EditableSyncPlugin.tsx +0 -16
  81. package/src/admin/ui/components/fields/richtext-editor/plugins/NotionToolbarPlugin.tsx +0 -184
  82. package/src/admin/ui/components/fields/richtext-editor/plugins/SimpleToolbarPlugin.tsx +0 -240
  83. package/src/admin/ui/components/fields/richtext-editor/plugins/ValueSyncPlugin.tsx +0 -40
  84. package/src/admin/ui/components/fields/utils.ts +0 -1
  85. package/src/admin/ui/components/link.tsx +0 -41
  86. package/src/admin/ui/components/media/AssetManagerModal.tsx +0 -334
  87. package/src/admin/ui/components/toast.tsx +0 -72
  88. package/src/admin/ui/components/ui/accordion.tsx +0 -51
  89. package/src/admin/ui/components/ui/alert-dialog.tsx +0 -98
  90. package/src/admin/ui/components/ui/blocks.tsx +0 -32
  91. package/src/admin/ui/components/ui/breadcrumbs.tsx +0 -59
  92. package/src/admin/ui/components/ui/button.tsx +0 -26
  93. package/src/admin/ui/components/ui/collapsible.tsx +0 -124
  94. package/src/admin/ui/components/ui/dialog.tsx +0 -79
  95. package/src/admin/ui/components/ui/group.tsx +0 -20
  96. package/src/admin/ui/components/ui/index.ts +0 -17
  97. package/src/admin/ui/components/ui/input.tsx +0 -12
  98. package/src/admin/ui/components/ui/join.tsx +0 -53
  99. package/src/admin/ui/components/ui/label.tsx +0 -11
  100. package/src/admin/ui/components/ui/radio-group.tsx +0 -75
  101. package/src/admin/ui/components/ui/relationship-detail-sheet.tsx +0 -122
  102. package/src/admin/ui/components/ui/relationship.tsx +0 -58
  103. package/src/admin/ui/components/ui/scroll-area.tsx +0 -19
  104. package/src/admin/ui/components/ui/select.tsx +0 -187
  105. package/src/admin/ui/components/ui/separator.tsx +0 -21
  106. package/src/admin/ui/components/ui/sheet.tsx +0 -106
  107. package/src/admin/ui/components/ui/tabs.tsx +0 -116
  108. package/src/admin/ui/components/ui/utils.ts +0 -3
  109. package/src/admin/ui/hooks/use-debounce.ts +0 -15
  110. package/src/admin/ui/styles/_locale-switcher.scss +0 -33
  111. package/src/admin/ui/styles/accordion.scss +0 -60
  112. package/src/admin/ui/styles/animations.scss +0 -41
  113. package/src/admin/ui/styles/asset-manager.scss +0 -547
  114. package/src/admin/ui/styles/badge.scss +0 -13
  115. package/src/admin/ui/styles/base.scss +0 -22
  116. package/src/admin/ui/styles/button.scss +0 -161
  117. package/src/admin/ui/styles/card.scss +0 -13
  118. package/src/admin/ui/styles/collapsible.scss +0 -75
  119. package/src/admin/ui/styles/data-detail.scss +0 -92
  120. package/src/admin/ui/styles/dialog.scss +0 -102
  121. package/src/admin/ui/styles/empty-state.scss +0 -22
  122. package/src/admin/ui/styles/group.scss +0 -19
  123. package/src/admin/ui/styles/index.scss +0 -33
  124. package/src/admin/ui/styles/input.scss +0 -80
  125. package/src/admin/ui/styles/label.scss +0 -12
  126. package/src/admin/ui/styles/layout.scss +0 -56
  127. package/src/admin/ui/styles/lexical.scss +0 -469
  128. package/src/admin/ui/styles/loading.scss +0 -102
  129. package/src/admin/ui/styles/media-registry.scss +0 -597
  130. package/src/admin/ui/styles/pagination.scss +0 -20
  131. package/src/admin/ui/styles/radio-group.scss +0 -66
  132. package/src/admin/ui/styles/row.scss +0 -17
  133. package/src/admin/ui/styles/scrollbar.scss +0 -36
  134. package/src/admin/ui/styles/select.scss +0 -121
  135. package/src/admin/ui/styles/separator.scss +0 -14
  136. package/src/admin/ui/styles/sheet.scss +0 -152
  137. package/src/admin/ui/styles/sidebar.scss +0 -148
  138. package/src/admin/ui/styles/switch.scss +0 -59
  139. package/src/admin/ui/styles/table.scss +0 -207
  140. package/src/admin/ui/styles/tabs.scss +0 -62
  141. package/src/admin/ui/styles/toast.scss +0 -45
  142. package/src/admin/ui/styles/variables.scss +0 -24
  143. package/src/admin/ui/views/collection-list-view.tsx +0 -720
  144. package/src/admin/ui/views/dashboard-view.tsx +0 -263
  145. package/src/admin/ui/views/document-edit-view.tsx +0 -384
  146. package/src/admin/ui/views/global-edit-view.tsx +0 -226
  147. package/src/admin/ui/views/init-view.tsx +0 -182
  148. package/src/admin/ui/views/login-view.tsx +0 -123
  149. package/src/admin/ui/views/media-registry-view.tsx +0 -1104
  150. package/src/admin/ui/views/settings-view.tsx +0 -729
  151. package/src/admin/webcomponent.tsx +0 -15
  152. package/src/api.ts +0 -9
  153. package/src/auth/index.ts +0 -194
  154. package/src/auth/migrations.ts +0 -87
  155. package/src/auth/premissions.ts +0 -46
  156. package/src/cli/commands/generate-types.ts +0 -116
  157. package/src/cli/commands/init.ts +0 -95
  158. package/src/cli/commands/migrate-commands.ts +0 -160
  159. package/src/cli/commands/seed-command.ts +0 -11
  160. package/src/cli/d1-mock.ts +0 -101
  161. package/src/cli/index.test.ts +0 -84
  162. package/src/cli/index.ts +0 -183
  163. package/src/cli/r2-mock.ts +0 -217
  164. package/src/cli/seeding.ts +0 -405
  165. package/src/client.ts +0 -181
  166. package/src/config-utils.ts +0 -102
  167. package/src/config.ts +0 -49
  168. package/src/db/adapter.ts +0 -53
  169. package/src/db/better-sqlite.ts +0 -630
  170. package/src/db/bun-sqlite.ts +0 -646
  171. package/src/db/d1.ts +0 -711
  172. package/src/db/kysely/data-mapper.ts +0 -142
  173. package/src/db/kysely/field-mapper.ts +0 -148
  174. package/src/db/kysely/migration-generator.ts +0 -223
  175. package/src/db/kysely/query-builder.ts +0 -92
  176. package/src/db/kysely/schema-builder.ts +0 -439
  177. package/src/db/kysely/sql-utils.ts +0 -13
  178. package/src/db/postgres.ts +0 -621
  179. package/src/db/sqlite.ts +0 -658
  180. package/src/db/system-schema.ts +0 -121
  181. package/src/index.ts +0 -13
  182. package/src/runtimes/README.md +0 -59
  183. package/src/runtimes/bun.ts +0 -49
  184. package/src/runtimes/cloudflare-workers.ts +0 -38
  185. package/src/runtimes/next.ts +0 -26
  186. package/src/runtimes/node.ts +0 -52
  187. package/src/schema/collection.ts +0 -184
  188. package/src/schema/fields/base.ts +0 -164
  189. package/src/schema/fields/index.ts +0 -427
  190. package/src/schema/global.ts +0 -145
  191. package/src/schema/index.ts +0 -4
  192. package/src/schema/infer.ts +0 -72
  193. package/src/server/admin-router.ts +0 -20
  194. package/src/server/admin.ts +0 -142
  195. package/src/server/assets.ts +0 -306
  196. package/src/server/collection-router.ts +0 -55
  197. package/src/server/handlers.ts +0 -722
  198. package/src/server/middlewares/admin.ts +0 -27
  199. package/src/server/middlewares/auth.ts +0 -89
  200. package/src/server/middlewares/context.ts +0 -17
  201. package/src/server/middlewares/cors.ts +0 -24
  202. package/src/server/middlewares/database-init.ts +0 -74
  203. package/src/server/middlewares/rate-limit.ts +0 -71
  204. package/src/server/router.ts +0 -47
  205. package/src/server/setup-middlewares.ts +0 -58
  206. package/src/server/system-router.ts +0 -35
  207. package/src/server.ts +0 -9
  208. package/src/storage/adapters/cloudflare-r2.ts +0 -136
  209. package/src/storage/adapters/local.ts +0 -146
  210. package/src/storage/adapters/s3.ts +0 -186
  211. package/src/storage/errors.ts +0 -46
  212. package/src/storage/index.ts +0 -5
  213. package/src/storage/types.ts +0 -39
  214. package/src/types.ts +0 -577
  215. package/src/utils/lexical.ts +0 -37
  216. package/src/utils/logger.ts +0 -73
  217. package/src/validation.ts +0 -429
  218. package/src/validator.ts +0 -179
  219. package/test/admin-custom-field.test.ts +0 -162
  220. package/test/admin-react-field.test.tsx +0 -134
  221. package/test/api-features.test.ts +0 -78
  222. package/test/api.test.ts +0 -178
  223. package/test/auth.test.ts +0 -62
  224. package/test/cli-integration.test.ts +0 -146
  225. package/test/cli.test.ts +0 -25
  226. package/test/db/postgres.test.ts +0 -95
  227. package/test/db/sqlite-filter.test.ts +0 -53
  228. package/test/db/sqlite.test.ts +0 -82
  229. package/test/engine-features.test.ts +0 -79
  230. package/test/globals.test.ts +0 -74
  231. package/test/integration-tmp/db-app/opacacms.config.ts +0 -15
  232. package/test/integration-tmp/my-sqlite-app/opacacms.config.ts +0 -25
  233. package/test/integration-tmp/my-test-app/index.ts +0 -8
  234. package/test/integration-tmp/my-test-app/opacacms.config.ts +0 -16
  235. package/test/integration-tmp/my-test-app/package.json +0 -12
  236. package/test/populate.test.ts +0 -79
  237. package/test/runtimes.test.ts +0 -43
  238. package/test/schema-builder.test.ts +0 -107
  239. package/test/schema-features.test.ts +0 -63
  240. package/test/seeding.test.ts +0 -68
  241. package/test/storage/local.test.ts +0 -72
  242. package/test/storage/s3.test.ts +0 -60
  243. package/test/structural-data.test.ts +0 -100
  244. package/test/test-setup.ts +0 -11
  245. package/test/validation.test.ts +0 -162
  246. package/tsconfig.json +0 -42
  247. /package/dist/{src/admin/index.css → admin/webcomponent.css} +0 -0
@@ -1,124 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "./utils";
3
- import "../../styles/collapsible.scss";
4
-
5
- interface CollapsibleContextValue {
6
- open?: boolean;
7
- onOpenChange?: (open: boolean) => void;
8
- disabled?: boolean;
9
- }
10
-
11
- const CollapsibleContext = React.createContext<CollapsibleContextValue>({});
12
-
13
- export interface CollapsibleProps extends React.HTMLAttributes<HTMLDivElement> {
14
- open?: boolean;
15
- defaultOpen?: boolean;
16
- onOpenChange?: (open: boolean) => void;
17
- disabled?: boolean;
18
- }
19
-
20
- export const Collapsible = React.forwardRef<HTMLDivElement, CollapsibleProps>(
21
- ({ className, open, defaultOpen, onOpenChange, disabled, children, ...props }, ref) => {
22
- const [uncontrolledOpen, setUncontrolledOpen] = React.useState<boolean>(defaultOpen ?? false);
23
-
24
- const isControlled = open !== undefined;
25
- const currentOpen = isControlled ? open : uncontrolledOpen;
26
-
27
- const handleOpenChange = React.useCallback(
28
- (newOpen: boolean) => {
29
- if (!isControlled) {
30
- setUncontrolledOpen(newOpen);
31
- }
32
- if (onOpenChange) {
33
- onOpenChange(newOpen);
34
- }
35
- },
36
- [isControlled, onOpenChange],
37
- );
38
-
39
- const contextValue = React.useMemo(
40
- () => ({ open: currentOpen, onOpenChange: handleOpenChange, disabled }),
41
- [currentOpen, handleOpenChange, disabled],
42
- );
43
-
44
- return (
45
- <CollapsibleContext.Provider value={contextValue}>
46
- <div ref={ref} className={cn("opaca-ui-collapsible", className)} {...props}>
47
- {children}
48
- </div>
49
- </CollapsibleContext.Provider>
50
- );
51
- },
52
- );
53
- Collapsible.displayName = "Collapsible";
54
-
55
- export interface CollapsibleTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
56
- asChild?: boolean;
57
- }
58
-
59
- export const CollapsibleTrigger = React.forwardRef<HTMLButtonElement, CollapsibleTriggerProps>(
60
- ({ className, disabled, children, ...props }, ref) => {
61
- const context = React.useContext(CollapsibleContext);
62
- const isDisabled = disabled || context.disabled;
63
- const isOpen = context.open;
64
-
65
- const handleClick = React.useCallback(
66
- (event: React.MouseEvent<HTMLButtonElement>) => {
67
- if (!isDisabled && context.onOpenChange) {
68
- context.onOpenChange(!isOpen);
69
- }
70
- if (props.onClick) {
71
- props.onClick(event);
72
- }
73
- },
74
- [isDisabled, isOpen, context.onOpenChange, props.onClick],
75
- );
76
-
77
- return (
78
- <button
79
- type="button"
80
- aria-expanded={isOpen}
81
- disabled={isDisabled}
82
- onClick={handleClick}
83
- ref={ref}
84
- className={cn("opaca-ui-collapsible-trigger", className)}
85
- {...props}
86
- >
87
- {children}
88
- <svg
89
- className="opaca-ui-collapsible-icon"
90
- viewBox="0 0 24 24"
91
- xmlns="http://www.w3.org/2000/svg"
92
- >
93
- <polyline points="6 9 12 15 18 9"></polyline>
94
- </svg>
95
- </button>
96
- );
97
- },
98
- );
99
- CollapsibleTrigger.displayName = "CollapsibleTrigger";
100
-
101
- export interface CollapsibleContentProps extends React.HTMLAttributes<HTMLDivElement> {}
102
-
103
- export const CollapsibleContent = React.forwardRef<HTMLDivElement, CollapsibleContentProps>(
104
- ({ className, children, ...props }, ref) => {
105
- const context = React.useContext(CollapsibleContext);
106
- const isOpen = context.open;
107
-
108
- if (!isOpen) {
109
- return null;
110
- }
111
-
112
- return (
113
- <div
114
- data-state={isOpen ? "open" : "closed"}
115
- ref={ref}
116
- className={cn("opaca-ui-collapsible-content", className)}
117
- {...props}
118
- >
119
- {children}
120
- </div>
121
- );
122
- },
123
- );
124
- CollapsibleContent.displayName = "CollapsibleContent";
@@ -1,79 +0,0 @@
1
- import type * as React from "react";
2
- import { createPortal } from "react-dom";
3
- import { cn } from "./utils";
4
- import "../../styles/dialog.scss";
5
-
6
- export function Dialog({
7
- open,
8
- onOpenChange,
9
- children,
10
- }: {
11
- open: boolean;
12
- onOpenChange: (open: boolean) => void;
13
- children: React.ReactNode;
14
- }) {
15
- if (!open) return null;
16
- return createPortal(
17
- <div className="opaca-ui-dialog-portal">
18
- <button
19
- type="button"
20
- className="opaca-ui-dialog-overlay"
21
- onClick={() => onOpenChange(false)}
22
- tabIndex={-1}
23
- aria-hidden="true"
24
- />
25
- <div className="opaca-ui-dialog-wrapper">{children}</div>
26
- </div>,
27
- document.body,
28
- );
29
- }
30
-
31
- export function DialogContent({
32
- children,
33
- className,
34
- }: {
35
- children: React.ReactNode;
36
- className?: string;
37
- }) {
38
- return <div className={cn("opaca-ui-dialog-content", className)}>{children}</div>;
39
- }
40
-
41
- export function DialogHeader({
42
- children,
43
- className,
44
- }: {
45
- children: React.ReactNode;
46
- className?: string;
47
- }) {
48
- return <div className={cn("opaca-ui-dialog-header", className)}>{children}</div>;
49
- }
50
-
51
- export function DialogTitle({
52
- children,
53
- className,
54
- }: {
55
- children: React.ReactNode;
56
- className?: string;
57
- }) {
58
- return <h2 className={cn("opaca-ui-dialog-title", className)}>{children}</h2>;
59
- }
60
-
61
- export function DialogDescription({
62
- children,
63
- className,
64
- }: {
65
- children: React.ReactNode;
66
- className?: string;
67
- }) {
68
- return <p className={cn("opaca-ui-dialog-description", className)}>{children}</p>;
69
- }
70
-
71
- export function DialogFooter({
72
- children,
73
- className,
74
- }: {
75
- children: React.ReactNode;
76
- className?: string;
77
- }) {
78
- return <div className={cn("opaca-ui-dialog-footer", className)}>{children}</div>;
79
- }
@@ -1,20 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "./utils";
3
- import "../../styles/group.scss";
4
-
5
- export interface GroupProps extends React.HTMLAttributes<HTMLDivElement> {
6
- label?: string;
7
- }
8
-
9
- export const Group = React.forwardRef<HTMLDivElement, GroupProps>(
10
- ({ className, label, children, ...props }, ref) => {
11
- return (
12
- <div ref={ref} className={cn("opaca-ui-group", className)} {...props}>
13
- {label && <h3 className="opaca-ui-group-header">{label}</h3>}
14
- {children}
15
- </div>
16
- );
17
- },
18
- );
19
-
20
- Group.displayName = "Group";
@@ -1,17 +0,0 @@
1
- export * from "./accordion";
2
- export * from "./blocks";
3
- export * from "./button";
4
- export * from "./collapsible";
5
- export * from "./dialog";
6
- export * from "./group";
7
- export * from "./input";
8
- export * from "./join";
9
- export * from "./label";
10
- export * from "./radio-group";
11
- export * from "./relationship";
12
- export * from "./scroll-area";
13
- export * from "./select";
14
- export * from "./separator";
15
- export * from "./sheet";
16
- export * from "./tabs";
17
- export * from "./utils";
@@ -1,12 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "./utils";
3
- import "../../styles/input.scss";
4
-
5
- export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
6
-
7
- export const Input = React.forwardRef<HTMLInputElement, InputProps>(
8
- ({ className, type, ...props }, ref) => {
9
- return <input type={type} className={cn("opaca-ui-input", className)} ref={ref} {...props} />;
10
- },
11
- );
12
- Input.displayName = "Input";
@@ -1,53 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "./utils";
3
-
4
- export interface JoinProps extends React.HTMLAttributes<HTMLDivElement> {
5
- label?: string;
6
- collection: string;
7
- on?: string;
8
- }
9
-
10
- export const Join = React.forwardRef<HTMLDivElement, JoinProps>(
11
- ({ className, label, collection, children, ...props }, ref) => {
12
- return (
13
- <div ref={ref} className={cn("opaca-ui-join", className)} {...props}>
14
- {label && (
15
- <div
16
- style={{
17
- display: "block",
18
- marginBottom: "0.5rem",
19
- fontSize: "0.75rem",
20
- fontWeight: 500,
21
- color: "var(--opaca-text-muted)",
22
- textTransform: "uppercase",
23
- letterSpacing: "0.03em",
24
- }}
25
- >
26
- {label}
27
- </div>
28
- )}
29
- {/* Placeholder for complex virtual data fetch UI */}
30
- <div
31
- style={{
32
- display: "flex",
33
- alignItems: "center",
34
- justifyContent: "space-between",
35
- padding: "0.75rem",
36
- border: "1px solid var(--opaca-border)",
37
- borderRadius: "var(--opaca-radius)",
38
- backgroundColor: "rgba(255, 255, 255, 0.02)",
39
- color: "var(--opaca-text-dim)",
40
- fontSize: "0.8125rem",
41
- }}
42
- >
43
- <span>
44
- Virtually joined from: <strong>{collection}</strong>
45
- </span>
46
- <span style={{ fontSize: "0.7rem", opacity: 0.5 }}>On: {props.on || "dynamic"}</span>
47
- </div>
48
- </div>
49
- );
50
- },
51
- );
52
-
53
- Join.displayName = "Join";
@@ -1,11 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "./utils";
3
- import "../../styles/label.scss";
4
-
5
- export const Label = React.forwardRef<
6
- HTMLLabelElement,
7
- React.LabelHTMLAttributes<HTMLLabelElement>
8
- >(({ className, ...props }, ref) => (
9
- <label ref={ref} className={cn("opaca-ui-label", className)} {...props} />
10
- ));
11
- Label.displayName = "Label";
@@ -1,75 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "./utils";
3
- import "../../styles/radio-group.scss";
4
-
5
- export interface RadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
6
- value?: string;
7
- onValueChange?: (value: string) => void;
8
- disabled?: boolean;
9
- name?: string;
10
- }
11
-
12
- export const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>(
13
- ({ className, value, onValueChange, disabled, name, children, ...props }, ref) => {
14
- const contextValue = React.useMemo(
15
- () => ({ value, onValueChange, disabled, name }),
16
- [value, onValueChange, disabled, name],
17
- );
18
-
19
- return (
20
- <RadioGroupContext.Provider value={contextValue}>
21
- <div ref={ref} className={cn("opaca-ui-radio-group", className)} {...props}>
22
- {children}
23
- </div>
24
- </RadioGroupContext.Provider>
25
- );
26
- },
27
- );
28
- RadioGroup.displayName = "RadioGroup";
29
-
30
- interface RadioGroupContextValue {
31
- value?: string;
32
- onValueChange?: (value: string) => void;
33
- disabled?: boolean;
34
- name?: string;
35
- }
36
-
37
- const RadioGroupContext = React.createContext<RadioGroupContextValue>({});
38
-
39
- export interface RadioGroupItemProps extends React.InputHTMLAttributes<HTMLInputElement> {
40
- value: string;
41
- }
42
-
43
- export const RadioGroupItem = React.forwardRef<HTMLInputElement, RadioGroupItemProps>(
44
- ({ className, value, disabled, id, ...props }, ref) => {
45
- const context = React.useContext(RadioGroupContext);
46
-
47
- const isDisabled = disabled || context.disabled;
48
- const isChecked = context.value === value;
49
- const name = context.name;
50
-
51
- const handleChange = () => {
52
- if (!isDisabled && context.onValueChange) {
53
- context.onValueChange(value);
54
- }
55
- };
56
-
57
- return (
58
- <div className="opaca-ui-radio-item">
59
- <input
60
- type="radio"
61
- ref={ref}
62
- id={id}
63
- name={name}
64
- value={value}
65
- checked={isChecked}
66
- disabled={isDisabled}
67
- onChange={handleChange}
68
- className={cn(className)}
69
- {...props}
70
- />
71
- </div>
72
- );
73
- },
74
- );
75
- RadioGroupItem.displayName = "RadioGroupItem";
@@ -1,122 +0,0 @@
1
- import { useStore } from "@nanostores/react";
2
- import { AlertCircle, Loader2 } from "lucide-react";
3
- import type React from "react";
4
- import { useEffect, useMemo, useState } from "react";
5
- import { api } from "../../../api-client";
6
- import { $config } from "../../../stores/config";
7
- import { FieldRenderer } from "../fields/index";
8
- import { Sheet, SheetContent, SheetHeader, SheetTitle } from "./sheet";
9
-
10
- interface RelationshipDetailSheetProps {
11
- isOpen: boolean;
12
- onOpenChange: (open: boolean) => void;
13
- relationTo: string;
14
- id: string | number;
15
- }
16
-
17
- export const RelationshipDetailSheet: React.FC<RelationshipDetailSheetProps> = ({
18
- isOpen,
19
- onOpenChange,
20
- relationTo,
21
- id,
22
- }) => {
23
- const [data, setData] = useState<Record<string, any> | null>(null);
24
- const [loading, setLoading] = useState(false);
25
- const [error, setError] = useState<string | null>(null);
26
- const config = useStore($config);
27
-
28
- const collection = useMemo(() => {
29
- return config?.collections.find((c) => c.slug === relationTo || c.apiPath === relationTo);
30
- }, [config, relationTo]);
31
-
32
- useEffect(() => {
33
- if (isOpen && id && relationTo) {
34
- setLoading(true);
35
- setError(null);
36
- api
37
- .get(`api/${relationTo}/${id}`)
38
- .json<Record<string, any>>()
39
- .then((res) => {
40
- setData(res);
41
- setLoading(false);
42
- })
43
- .catch((err: Error) => {
44
- console.error("Failed to fetch relation details:", err);
45
- setError("Failed to load document details.");
46
- setLoading(false);
47
- });
48
- } else {
49
- setData(null);
50
- }
51
- }, [isOpen, id, relationTo]);
52
-
53
- return (
54
- <Sheet open={isOpen} onOpenChange={onOpenChange}>
55
- <SheetContent className="p-0 sm:max-w-[500px]" onClose={() => onOpenChange(false)}>
56
- <div style={{ display: "flex", flexDirection: "column", height: "100%" }}>
57
- <div style={{ padding: "1.5rem 1.5rem 1rem" }}>
58
- <SheetHeader>
59
- <SheetTitle>{collection?.label || relationTo} Details</SheetTitle>
60
- </SheetHeader>
61
- <div
62
- style={{ fontSize: "0.875rem", color: "var(--opaca-text-dim)", marginTop: "0.25rem" }}
63
- >
64
- ID: {id}
65
- </div>
66
- </div>
67
-
68
- <div style={{ flex: 1, overflowY: "auto", padding: "1.5rem" }}>
69
- {loading ? (
70
- <div
71
- style={{
72
- display: "flex",
73
- alignItems: "center",
74
- justifyContent: "center",
75
- padding: "3rem",
76
- gap: "0.75rem",
77
- }}
78
- >
79
- <Loader2 size={20} className="opaca-spin" />
80
- <span style={{ color: "var(--opaca-text-dim)" }}>Loading details...</span>
81
- </div>
82
- ) : error ? (
83
- <div
84
- style={{
85
- padding: "1rem",
86
- backgroundColor: "rgba(239, 68, 68, 0.1)",
87
- border: "1px solid var(--opaca-error)",
88
- color: "var(--opaca-error)",
89
- borderRadius: "var(--opaca-radius)",
90
- display: "flex",
91
- alignItems: "center",
92
- gap: "0.75rem",
93
- }}
94
- >
95
- <AlertCircle size={18} />
96
- {error}
97
- </div>
98
- ) : data && collection ? (
99
- <div style={{ display: "grid", gap: "1.5rem" }}>
100
- {collection.fields.map((field, index) => (
101
- <FieldRenderer
102
- key={field.name || index}
103
- field={field}
104
- value={field.name ? data[field.name] : undefined}
105
- onChange={() => {}} // Read-only
106
- readOnly={true}
107
- disabled={true}
108
- parentData={data}
109
- />
110
- ))}
111
- </div>
112
- ) : (
113
- <div style={{ textAlign: "center", padding: "2rem", opacity: 0.5 }}>
114
- No details found for this document.
115
- </div>
116
- )}
117
- </div>
118
- </div>
119
- </SheetContent>
120
- </Sheet>
121
- );
122
- };
@@ -1,58 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "./utils";
3
-
4
- export interface RelationshipProps extends React.HTMLAttributes<HTMLDivElement> {
5
- label?: string;
6
- relationTo: string;
7
- children?: React.ReactNode;
8
- onClick?: () => void;
9
- }
10
-
11
- export const Relationship = React.forwardRef<HTMLDivElement, RelationshipProps>(
12
- ({ className, label, relationTo, children, onClick, ...props }, ref) => {
13
- return (
14
- <div
15
- ref={ref}
16
- className={cn("opaca-ui-relationship", className)}
17
- {...props}
18
- onClick={onClick}
19
- style={{ cursor: onClick ? "pointer" : "default", ...props.style }}
20
- >
21
- {label && (
22
- <div
23
- style={{
24
- display: "block",
25
- marginBottom: "0.5rem",
26
- fontSize: "0.75rem",
27
- fontWeight: 500,
28
- color: "var(--opaca-text-muted)",
29
- textTransform: "uppercase",
30
- letterSpacing: "0.03em",
31
- }}
32
- >
33
- {label}
34
- </div>
35
- )}
36
- <div
37
- style={{
38
- display: "flex",
39
- alignItems: "center",
40
- justifyContent: "space-between",
41
- padding: "0.75rem",
42
- border: "1px solid var(--opaca-border)",
43
- borderRadius: "var(--opaca-radius)",
44
- backgroundColor: "rgba(255, 255, 255, 0.02)",
45
- transition: "all 0.2s ease",
46
- fontSize: "0.8125rem",
47
- }}
48
- className="opaca-ui-relationship-trigger"
49
- >
50
- <span>{children || `Select ${relationTo}...`}</span>
51
- <span style={{ fontSize: "0.7rem", opacity: 0.5 }}>Link: {relationTo}</span>
52
- </div>
53
- </div>
54
- );
55
- },
56
- );
57
-
58
- Relationship.displayName = "Relationship";
@@ -1,19 +0,0 @@
1
- import type * as React from "react";
2
- import { cn } from "./utils";
3
-
4
- interface ScrollAreaProps extends React.HTMLAttributes<HTMLDivElement> {
5
- children: React.ReactNode;
6
- maxHeight?: string | number;
7
- }
8
-
9
- export function ScrollArea({ children, className, maxHeight, ...props }: ScrollAreaProps) {
10
- return (
11
- <div
12
- className={cn("opaca-scroll-area", className)}
13
- style={{ maxHeight, overflowY: "auto", ...props.style }}
14
- {...props}
15
- >
16
- {children}
17
- </div>
18
- );
19
- }