opacacms 0.1.12 → 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.
Files changed (217) hide show
  1. package/dist/admin/index.js +0 -4
  2. package/dist/admin/webcomponent.d.ts +0 -1
  3. package/dist/admin/webcomponent.js +0 -4
  4. package/dist/admin.css +1 -0
  5. package/package.json +8 -2
  6. package/bun.lock +0 -34
  7. package/dist/admin/index.css +0 -47
  8. package/dist/admin/webcomponent.css +0 -47
  9. package/global.d.ts +0 -11
  10. package/src/admin/api-client.ts +0 -63
  11. package/src/admin/auth-client.ts +0 -40
  12. package/src/admin/custom-field.ts +0 -179
  13. package/src/admin/index.ts +0 -15
  14. package/src/admin/react.tsx +0 -72
  15. package/src/admin/router.ts +0 -9
  16. package/src/admin/stores/admin-queries.ts +0 -121
  17. package/src/admin/stores/auth.ts +0 -61
  18. package/src/admin/stores/column-visibility.ts +0 -67
  19. package/src/admin/stores/config.ts +0 -15
  20. package/src/admin/stores/media.ts +0 -95
  21. package/src/admin/stores/query.ts +0 -13
  22. package/src/admin/stores/ui.ts +0 -29
  23. package/src/admin/ui/admin-client.tsx +0 -283
  24. package/src/admin/ui/admin-layout.tsx +0 -276
  25. package/src/admin/ui/components/ColumnVisibilityToggle.tsx +0 -141
  26. package/src/admin/ui/components/DataDetailSheet.tsx +0 -141
  27. package/src/admin/ui/components/DataDetailView.tsx +0 -175
  28. package/src/admin/ui/components/Table.tsx +0 -67
  29. package/src/admin/ui/components/fields/ArrayField.tsx +0 -166
  30. package/src/admin/ui/components/fields/BlocksField.tsx +0 -202
  31. package/src/admin/ui/components/fields/BooleanField.tsx +0 -50
  32. package/src/admin/ui/components/fields/CollapsibleField.tsx +0 -75
  33. package/src/admin/ui/components/fields/DateField.tsx +0 -45
  34. package/src/admin/ui/components/fields/FileField.tsx +0 -322
  35. package/src/admin/ui/components/fields/GroupField.tsx +0 -50
  36. package/src/admin/ui/components/fields/JoinField.tsx +0 -23
  37. package/src/admin/ui/components/fields/NumberField.tsx +0 -46
  38. package/src/admin/ui/components/fields/RadioField.tsx +0 -62
  39. package/src/admin/ui/components/fields/RelationshipField.tsx +0 -278
  40. package/src/admin/ui/components/fields/RowField.tsx +0 -40
  41. package/src/admin/ui/components/fields/SelectField.tsx +0 -59
  42. package/src/admin/ui/components/fields/TabsField.tsx +0 -101
  43. package/src/admin/ui/components/fields/TextAreaField.tsx +0 -54
  44. package/src/admin/ui/components/fields/TextField.tsx +0 -49
  45. package/src/admin/ui/components/fields/VirtualField.tsx +0 -53
  46. package/src/admin/ui/components/fields/index.tsx +0 -371
  47. package/src/admin/ui/components/fields/richtext-editor/index.tsx +0 -211
  48. package/src/admin/ui/components/fields/richtext-editor/nodes/ImageComponent.tsx +0 -142
  49. package/src/admin/ui/components/fields/richtext-editor/nodes/ImageNode.tsx +0 -95
  50. package/src/admin/ui/components/fields/richtext-editor/plugins/ComponentPickerPlugin.tsx +0 -226
  51. package/src/admin/ui/components/fields/richtext-editor/plugins/EditableSyncPlugin.tsx +0 -16
  52. package/src/admin/ui/components/fields/richtext-editor/plugins/NotionToolbarPlugin.tsx +0 -184
  53. package/src/admin/ui/components/fields/richtext-editor/plugins/SimpleToolbarPlugin.tsx +0 -240
  54. package/src/admin/ui/components/fields/richtext-editor/plugins/ValueSyncPlugin.tsx +0 -40
  55. package/src/admin/ui/components/fields/utils.ts +0 -1
  56. package/src/admin/ui/components/link.tsx +0 -41
  57. package/src/admin/ui/components/media/AssetManagerModal.tsx +0 -334
  58. package/src/admin/ui/components/toast.tsx +0 -72
  59. package/src/admin/ui/components/ui/accordion.tsx +0 -51
  60. package/src/admin/ui/components/ui/alert-dialog.tsx +0 -98
  61. package/src/admin/ui/components/ui/blocks.tsx +0 -32
  62. package/src/admin/ui/components/ui/breadcrumbs.tsx +0 -59
  63. package/src/admin/ui/components/ui/button.tsx +0 -26
  64. package/src/admin/ui/components/ui/collapsible.tsx +0 -124
  65. package/src/admin/ui/components/ui/dialog.tsx +0 -79
  66. package/src/admin/ui/components/ui/group.tsx +0 -20
  67. package/src/admin/ui/components/ui/index.ts +0 -17
  68. package/src/admin/ui/components/ui/input.tsx +0 -12
  69. package/src/admin/ui/components/ui/join.tsx +0 -53
  70. package/src/admin/ui/components/ui/label.tsx +0 -11
  71. package/src/admin/ui/components/ui/radio-group.tsx +0 -75
  72. package/src/admin/ui/components/ui/relationship-detail-sheet.tsx +0 -122
  73. package/src/admin/ui/components/ui/relationship.tsx +0 -58
  74. package/src/admin/ui/components/ui/scroll-area.tsx +0 -19
  75. package/src/admin/ui/components/ui/select.tsx +0 -187
  76. package/src/admin/ui/components/ui/separator.tsx +0 -21
  77. package/src/admin/ui/components/ui/sheet.tsx +0 -106
  78. package/src/admin/ui/components/ui/tabs.tsx +0 -116
  79. package/src/admin/ui/components/ui/utils.ts +0 -3
  80. package/src/admin/ui/hooks/use-debounce.ts +0 -15
  81. package/src/admin/ui/styles/_locale-switcher.scss +0 -33
  82. package/src/admin/ui/styles/accordion.scss +0 -60
  83. package/src/admin/ui/styles/animations.scss +0 -41
  84. package/src/admin/ui/styles/asset-manager.scss +0 -547
  85. package/src/admin/ui/styles/badge.scss +0 -13
  86. package/src/admin/ui/styles/base.scss +0 -22
  87. package/src/admin/ui/styles/button.scss +0 -161
  88. package/src/admin/ui/styles/card.scss +0 -13
  89. package/src/admin/ui/styles/collapsible.scss +0 -75
  90. package/src/admin/ui/styles/data-detail.scss +0 -92
  91. package/src/admin/ui/styles/dialog.scss +0 -102
  92. package/src/admin/ui/styles/empty-state.scss +0 -22
  93. package/src/admin/ui/styles/group.scss +0 -19
  94. package/src/admin/ui/styles/index.scss +0 -33
  95. package/src/admin/ui/styles/input.scss +0 -80
  96. package/src/admin/ui/styles/label.scss +0 -12
  97. package/src/admin/ui/styles/layout.scss +0 -56
  98. package/src/admin/ui/styles/lexical.scss +0 -469
  99. package/src/admin/ui/styles/loading.scss +0 -102
  100. package/src/admin/ui/styles/media-registry.scss +0 -597
  101. package/src/admin/ui/styles/pagination.scss +0 -20
  102. package/src/admin/ui/styles/radio-group.scss +0 -66
  103. package/src/admin/ui/styles/row.scss +0 -17
  104. package/src/admin/ui/styles/scrollbar.scss +0 -36
  105. package/src/admin/ui/styles/select.scss +0 -121
  106. package/src/admin/ui/styles/separator.scss +0 -14
  107. package/src/admin/ui/styles/sheet.scss +0 -152
  108. package/src/admin/ui/styles/sidebar.scss +0 -148
  109. package/src/admin/ui/styles/switch.scss +0 -59
  110. package/src/admin/ui/styles/table.scss +0 -207
  111. package/src/admin/ui/styles/tabs.scss +0 -62
  112. package/src/admin/ui/styles/toast.scss +0 -45
  113. package/src/admin/ui/styles/variables.scss +0 -24
  114. package/src/admin/ui/views/collection-list-view.tsx +0 -720
  115. package/src/admin/ui/views/dashboard-view.tsx +0 -263
  116. package/src/admin/ui/views/document-edit-view.tsx +0 -384
  117. package/src/admin/ui/views/global-edit-view.tsx +0 -226
  118. package/src/admin/ui/views/init-view.tsx +0 -182
  119. package/src/admin/ui/views/login-view.tsx +0 -123
  120. package/src/admin/ui/views/media-registry-view.tsx +0 -1104
  121. package/src/admin/ui/views/settings-view.tsx +0 -729
  122. package/src/admin/webcomponent.tsx +0 -15
  123. package/src/auth/index.ts +0 -194
  124. package/src/auth/migrations.ts +0 -87
  125. package/src/auth/premissions.ts +0 -46
  126. package/src/cli/commands/generate-types.ts +0 -116
  127. package/src/cli/commands/init.ts +0 -95
  128. package/src/cli/commands/migrate-commands.ts +0 -160
  129. package/src/cli/commands/seed-command.ts +0 -11
  130. package/src/cli/d1-mock.ts +0 -101
  131. package/src/cli/index.test.ts +0 -84
  132. package/src/cli/index.ts +0 -183
  133. package/src/cli/r2-mock.ts +0 -217
  134. package/src/cli/seeding.ts +0 -409
  135. package/src/client.ts +0 -181
  136. package/src/config-utils.ts +0 -102
  137. package/src/config.ts +0 -49
  138. package/src/db/adapter.ts +0 -53
  139. package/src/db/better-sqlite.ts +0 -657
  140. package/src/db/bun-sqlite.ts +0 -666
  141. package/src/db/d1.ts +0 -721
  142. package/src/db/index.ts +0 -10
  143. package/src/db/kysely/data-mapper.ts +0 -142
  144. package/src/db/kysely/field-mapper.ts +0 -149
  145. package/src/db/kysely/migration-generator.ts +0 -223
  146. package/src/db/kysely/query-builder.ts +0 -92
  147. package/src/db/kysely/schema-builder.ts +0 -439
  148. package/src/db/kysely/sql-utils.ts +0 -13
  149. package/src/db/postgres.ts +0 -631
  150. package/src/db/sqlite.ts +0 -670
  151. package/src/db/system-schema.ts +0 -121
  152. package/src/index.ts +0 -13
  153. package/src/runtimes/README.md +0 -59
  154. package/src/runtimes/bun.ts +0 -49
  155. package/src/runtimes/cloudflare-workers.ts +0 -38
  156. package/src/runtimes/next.ts +0 -26
  157. package/src/runtimes/node.ts +0 -52
  158. package/src/schema/collection.ts +0 -184
  159. package/src/schema/fields/base.ts +0 -164
  160. package/src/schema/fields/index.ts +0 -427
  161. package/src/schema/global.ts +0 -145
  162. package/src/schema/index.ts +0 -4
  163. package/src/schema/infer.ts +0 -72
  164. package/src/server/admin-router.ts +0 -20
  165. package/src/server/admin.ts +0 -142
  166. package/src/server/assets.ts +0 -306
  167. package/src/server/collection-router.ts +0 -55
  168. package/src/server/handlers.ts +0 -722
  169. package/src/server/middlewares/admin.ts +0 -27
  170. package/src/server/middlewares/auth.ts +0 -89
  171. package/src/server/middlewares/context.ts +0 -17
  172. package/src/server/middlewares/cors.ts +0 -24
  173. package/src/server/middlewares/database-init.ts +0 -74
  174. package/src/server/middlewares/rate-limit.ts +0 -77
  175. package/src/server/router.ts +0 -47
  176. package/src/server/setup-middlewares.ts +0 -58
  177. package/src/server/system-router.ts +0 -35
  178. package/src/server.ts +0 -9
  179. package/src/storage/adapters/cloudflare-r2.ts +0 -136
  180. package/src/storage/adapters/local.ts +0 -146
  181. package/src/storage/adapters/s3.ts +0 -186
  182. package/src/storage/errors.ts +0 -46
  183. package/src/storage/index.ts +0 -5
  184. package/src/storage/types.ts +0 -39
  185. package/src/types.ts +0 -577
  186. package/src/utils/lexical.ts +0 -37
  187. package/src/utils/logger.ts +0 -73
  188. package/src/validation.ts +0 -429
  189. package/src/validator.ts +0 -179
  190. package/test/admin-custom-field.test.ts +0 -162
  191. package/test/admin-react-field.test.tsx +0 -134
  192. package/test/api-features.test.ts +0 -78
  193. package/test/api.test.ts +0 -178
  194. package/test/auth.test.ts +0 -62
  195. package/test/cli-integration.test.ts +0 -148
  196. package/test/cli.test.ts +0 -25
  197. package/test/db/postgres.test.ts +0 -95
  198. package/test/db/sqlite-filter.test.ts +0 -53
  199. package/test/db/sqlite.test.ts +0 -82
  200. package/test/engine-features.test.ts +0 -79
  201. package/test/globals.test.ts +0 -74
  202. package/test/integration-tmp/db-app/opacacms.config.ts +0 -15
  203. package/test/integration-tmp/my-sqlite-app/opacacms.config.ts +0 -25
  204. package/test/integration-tmp/my-test-app/index.ts +0 -8
  205. package/test/integration-tmp/my-test-app/opacacms.config.ts +0 -16
  206. package/test/integration-tmp/my-test-app/package.json +0 -12
  207. package/test/populate.test.ts +0 -79
  208. package/test/runtimes.test.ts +0 -43
  209. package/test/schema-builder.test.ts +0 -107
  210. package/test/schema-features.test.ts +0 -63
  211. package/test/seeding.test.ts +0 -68
  212. package/test/storage/local.test.ts +0 -72
  213. package/test/storage/s3.test.ts +0 -60
  214. package/test/structural-data.test.ts +0 -100
  215. package/test/test-setup.ts +0 -11
  216. package/test/validation.test.ts +0 -162
  217. package/tsconfig.json +0 -42
@@ -1,187 +0,0 @@
1
- import { ChevronDown } from "lucide-react";
2
- import * as React from "react";
3
- import { createPortal } from "react-dom";
4
- import { cn } from "./utils";
5
- import "../../styles/select.scss";
6
-
7
- export interface SelectProps {
8
- value?: string;
9
- onValueChange?: (value: string) => void;
10
- children: React.ReactNode;
11
- placeholder?: string;
12
- disabled?: boolean;
13
- className?: string;
14
- }
15
-
16
- const SelectContext = React.createContext<{
17
- value?: string;
18
- onValueChange?: (value: string) => void;
19
- open: boolean;
20
- setOpen: (open: boolean) => void;
21
- triggerRef: React.RefObject<HTMLButtonElement | null>;
22
- } | null>(null);
23
-
24
- export function Select({
25
- value,
26
- onValueChange,
27
- children,
28
- open: controlledOpen,
29
- onOpenChange,
30
- }: SelectProps & { open?: boolean; onOpenChange?: (open: boolean) => void }) {
31
- const [internalOpen, setInternalOpen] = React.useState(false);
32
- const open = controlledOpen ?? internalOpen;
33
- const setOpen = onOpenChange ?? setInternalOpen;
34
- const triggerRef = React.useRef<HTMLButtonElement>(null);
35
-
36
- return (
37
- <SelectContext.Provider value={{ value, onValueChange, open, setOpen, triggerRef }}>
38
- <div className="opaca-ui-select">{children}</div>
39
- </SelectContext.Provider>
40
- );
41
- }
42
-
43
- export function SelectTrigger({
44
- children,
45
- className,
46
- }: {
47
- children?: React.ReactNode;
48
- className?: string;
49
- }) {
50
- const context = React.useContext(SelectContext);
51
- if (!context) throw new Error("SelectTrigger must be used within a Select");
52
-
53
- return (
54
- <button
55
- ref={context.triggerRef}
56
- type="button"
57
- className={cn("opaca-ui-select-trigger", className)}
58
- onClick={() => context.setOpen(!context.open)}
59
- data-state={context.open ? "open" : "closed"}
60
- >
61
- <span className="trigger-content">{children}</span>
62
- <ChevronDown size={14} className="trigger-icon" />
63
- </button>
64
- );
65
- }
66
-
67
- export function SelectValue({ placeholder }: { placeholder?: string }) {
68
- const context = React.useContext(SelectContext);
69
- if (!context) throw new Error("SelectValue must be used within a Select");
70
-
71
- return (
72
- <span className={!context.value ? "trigger-placeholder" : ""}>
73
- {context.value || placeholder}
74
- </span>
75
- );
76
- }
77
-
78
- export function SelectContent({
79
- children,
80
- className,
81
- }: {
82
- children: React.ReactNode;
83
- className?: string;
84
- }) {
85
- const context = React.useContext(SelectContext);
86
- if (!context) throw new Error("SelectContent must be used within a Select");
87
-
88
- const [position, setPosition] = React.useState({ top: 0, left: 0, width: 0 });
89
-
90
- const updatePosition = React.useCallback(() => {
91
- if (context.open && context.triggerRef.current) {
92
- const rect = context.triggerRef.current.getBoundingClientRect();
93
- setPosition({
94
- top: rect.bottom,
95
- left: rect.left,
96
- width: rect.width,
97
- });
98
- }
99
- }, [context.open, context.triggerRef]);
100
-
101
- React.useEffect(() => {
102
- if (context.open) {
103
- updatePosition();
104
- window.addEventListener("scroll", updatePosition, true);
105
- window.addEventListener("resize", updatePosition);
106
- return () => {
107
- window.removeEventListener("scroll", updatePosition, true);
108
- window.removeEventListener("resize", updatePosition);
109
- };
110
- }
111
- }, [context.open, updatePosition]);
112
-
113
- if (!context.open) return null;
114
-
115
- return createPortal(
116
- <div
117
- className="opaca-ui-select-portal"
118
- style={{
119
- top: position.top + 4,
120
- left: position.left,
121
- width: position.width,
122
- }}
123
- >
124
- <button
125
- type="button"
126
- className="opaca-ui-select-content-overlay"
127
- style={{
128
- position: "fixed",
129
- inset: 0,
130
- zIndex: -1,
131
- background: "transparent",
132
- border: "none",
133
- padding: 0,
134
- width: "100%",
135
- height: "100%",
136
- cursor: "default",
137
- }}
138
- onClick={() => context.setOpen(false)}
139
- tabIndex={-1}
140
- aria-hidden="true"
141
- />
142
- <div className={cn("opaca-ui-select-content", className)}>{children}</div>
143
- </div>,
144
- document.body,
145
- );
146
- }
147
-
148
- export function SelectItem({
149
- value,
150
- children,
151
- className,
152
- }: {
153
- value: string;
154
- children: React.ReactNode;
155
- className?: string;
156
- }) {
157
- const context = React.useContext(SelectContext);
158
- if (!context) throw new Error("SelectItem must be used within a Select");
159
-
160
- const isSelected = context.value === value;
161
-
162
- return (
163
- <button
164
- type="button"
165
- className={cn("opaca-ui-select-item", className)}
166
- data-selected={isSelected}
167
- onClick={() => {
168
- context.onValueChange?.(value);
169
- context.setOpen(false);
170
- }}
171
- >
172
- {children}
173
- </button>
174
- );
175
- }
176
-
177
- export function SelectGroup({ children }: { children: React.ReactNode }) {
178
- return <div className="opaca-ui-select-group">{children}</div>;
179
- }
180
-
181
- export function SelectLabel({ children }: { children: React.ReactNode }) {
182
- return <div className="opaca-ui-select-label">{children}</div>;
183
- }
184
-
185
- export function SelectSeparator() {
186
- return <div className="opaca-ui-select-separator" />;
187
- }
@@ -1,21 +0,0 @@
1
- import type React from "react";
2
-
3
- interface SeparatorProps {
4
- className?: string;
5
- orientation?: "horizontal" | "vertical";
6
- margin?: string;
7
- }
8
-
9
- export const Separator: React.FC<SeparatorProps> = ({
10
- className = "",
11
- orientation = "horizontal",
12
- margin,
13
- }) => {
14
- return (
15
- <div
16
- className={`opaca-separator ${orientation} ${className}`}
17
- style={margin ? { margin } : undefined}
18
- role="none"
19
- />
20
- );
21
- };
@@ -1,106 +0,0 @@
1
- import type * as React from "react";
2
- import { createPortal } from "react-dom";
3
- import { cn } from "./utils";
4
- import "../../styles/sheet.scss";
5
-
6
- export function Sheet({
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-sheet-portal">
18
- <button
19
- type="button"
20
- className="opaca-ui-sheet-overlay"
21
- onClick={() => onOpenChange(false)}
22
- tabIndex={-1}
23
- aria-hidden="true"
24
- />
25
- <div className="opaca-ui-sheet-wrapper">{children}</div>
26
- </div>,
27
- document.body,
28
- );
29
- }
30
-
31
- export function SheetContent({
32
- children,
33
- className,
34
- onClose,
35
- }: {
36
- children: React.ReactNode;
37
- className?: string;
38
- onClose?: () => void;
39
- }) {
40
- return (
41
- <div className={cn("opaca-ui-sheet-content", className)}>
42
- {children}
43
- {onClose && (
44
- <button type="button" onClick={onClose} className="opaca-ui-sheet-close">
45
- <svg
46
- aria-hidden="true"
47
- xmlns="http://www.w3.org/2000/svg"
48
- width="24"
49
- height="24"
50
- viewBox="0 0 24 24"
51
- fill="none"
52
- stroke="currentColor"
53
- strokeWidth="2"
54
- strokeLinecap="round"
55
- strokeLinejoin="round"
56
- className="opaca-ui-sheet-close-icon"
57
- >
58
- <line x1="18" x2="6" y1="6" y2="18"></line>
59
- <line x1="6" x2="18" y1="6" y2="18"></line>
60
- </svg>
61
- <span className="opaca-ui-sr-only">Close</span>
62
- </button>
63
- )}
64
- </div>
65
- );
66
- }
67
-
68
- export function SheetHeader({
69
- children,
70
- className,
71
- }: {
72
- children: React.ReactNode;
73
- className?: string;
74
- }) {
75
- return <div className={cn("opaca-ui-sheet-header", className)}>{children}</div>;
76
- }
77
-
78
- export function SheetTitle({
79
- children,
80
- className,
81
- }: {
82
- children: React.ReactNode;
83
- className?: string;
84
- }) {
85
- return <h2 className={cn("opaca-ui-sheet-title", className)}>{children}</h2>;
86
- }
87
-
88
- export function SheetDescription({
89
- children,
90
- className,
91
- }: {
92
- children: React.ReactNode;
93
- className?: string;
94
- }) {
95
- return <p className={cn("opaca-ui-sheet-description", className)}>{children}</p>;
96
- }
97
-
98
- export function SheetFooter({
99
- children,
100
- className,
101
- }: {
102
- children: React.ReactNode;
103
- className?: string;
104
- }) {
105
- return <div className={cn("opaca-ui-sheet-footer", className)}>{children}</div>;
106
- }
@@ -1,116 +0,0 @@
1
- import * as React from "react";
2
- import { cn } from "./utils";
3
- import "../../styles/tabs.scss";
4
-
5
- interface TabsContextValue {
6
- value?: string;
7
- onValueChange?: (value: string) => void;
8
- }
9
-
10
- const TabsContext = React.createContext<TabsContextValue>({});
11
-
12
- export interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
13
- value?: string;
14
- defaultValue?: string;
15
- onValueChange?: (value: string) => void;
16
- }
17
-
18
- export const Tabs = React.forwardRef<HTMLDivElement, TabsProps>(
19
- ({ className, value, defaultValue, onValueChange, children, ...props }, ref) => {
20
- const [uncontrolledValue, setUncontrolledValue] = React.useState<string | undefined>(
21
- defaultValue,
22
- );
23
-
24
- const isControlled = value !== undefined;
25
- const currentValue = isControlled ? value : uncontrolledValue;
26
-
27
- const handleValueChange = React.useCallback(
28
- (newValue: string) => {
29
- if (!isControlled) {
30
- setUncontrolledValue(newValue);
31
- }
32
- if (onValueChange) {
33
- onValueChange(newValue);
34
- }
35
- },
36
- [isControlled, onValueChange],
37
- );
38
-
39
- const contextValue = React.useMemo(
40
- () => ({ value: currentValue, onValueChange: handleValueChange }),
41
- [currentValue, handleValueChange],
42
- );
43
-
44
- return (
45
- <TabsContext.Provider value={contextValue}>
46
- <div ref={ref} className={cn("opaca-ui-tabs", className)} {...props}>
47
- {children}
48
- </div>
49
- </TabsContext.Provider>
50
- );
51
- },
52
- );
53
- Tabs.displayName = "Tabs";
54
-
55
- export const TabsList = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
56
- ({ className, ...props }, ref) => (
57
- <div ref={ref} className={cn("opaca-ui-tabs-list", className)} role="tablist" {...props} />
58
- ),
59
- );
60
- TabsList.displayName = "TabsList";
61
-
62
- export interface TabsTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
63
- value: string;
64
- }
65
-
66
- export const TabsTrigger = React.forwardRef<HTMLButtonElement, TabsTriggerProps>(
67
- ({ className, value, disabled, ...props }, ref) => {
68
- const context = React.useContext(TabsContext);
69
- const isSelected = context.value === value;
70
-
71
- return (
72
- <button
73
- type="button"
74
- role="tab"
75
- aria-selected={isSelected}
76
- data-state={isSelected ? "active" : "inactive"}
77
- disabled={disabled}
78
- onClick={() => {
79
- if (!disabled && context.onValueChange) {
80
- context.onValueChange(value);
81
- }
82
- }}
83
- ref={ref}
84
- className={cn("opaca-ui-tabs-trigger", className)}
85
- {...props}
86
- />
87
- );
88
- },
89
- );
90
- TabsTrigger.displayName = "TabsTrigger";
91
-
92
- export interface TabsContentProps extends React.HTMLAttributes<HTMLDivElement> {
93
- value: string;
94
- }
95
-
96
- export const TabsContent = React.forwardRef<HTMLDivElement, TabsContentProps>(
97
- ({ className, value, ...props }, ref) => {
98
- const context = React.useContext(TabsContext);
99
- const isSelected = context.value === value;
100
-
101
- if (!isSelected) {
102
- return null;
103
- }
104
-
105
- return (
106
- <div
107
- role="tabpanel"
108
- data-state={isSelected ? "active" : "inactive"}
109
- ref={ref}
110
- className={cn("opaca-ui-tabs-content", className)}
111
- {...props}
112
- />
113
- );
114
- },
115
- );
116
- TabsContent.displayName = "TabsContent";
@@ -1,3 +0,0 @@
1
- export function cn(...classes: (string | undefined | null | false)[]) {
2
- return classes.filter(Boolean).join(" ");
3
- }
@@ -1,15 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- export function useDebounce<T>(value: T, delay?: number): T {
4
- const [debouncedValue, setDebouncedValue] = useState<T>(value);
5
-
6
- useEffect(() => {
7
- const timer = setTimeout(() => setDebouncedValue(value), delay || 500);
8
-
9
- return () => {
10
- clearTimeout(timer);
11
- };
12
- }, [value, delay]);
13
-
14
- return debouncedValue;
15
- }
@@ -1,33 +0,0 @@
1
- .opaca-locale-switcher {
2
- display: flex;
3
- align-items: center;
4
- gap: 0.5rem;
5
- background: var(--opaca-card-bg);
6
- padding: 0.25rem;
7
- border-radius: var(--opaca-radius);
8
- border: 1px solid var(--opaca-border);
9
- box-shadow: var(--opaca-shadow-sm);
10
- }
11
-
12
- .opaca-locale-btn {
13
- background: none;
14
- border: none;
15
- padding: 0.375rem 0.75rem;
16
- border-radius: calc(var(--opaca-radius) - 2px);
17
- font-size: 0.75rem;
18
- font-weight: 600;
19
- color: var(--opaca-text-dim);
20
- cursor: pointer;
21
- transition: all var(--opaca-transition);
22
-
23
- &:hover {
24
- color: var(--opaca-text);
25
- background: rgba(255, 255, 255, 0.05);
26
- }
27
-
28
- &.active {
29
- background: var(--opaca-accent);
30
- color: white;
31
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
32
- }
33
- }
@@ -1,60 +0,0 @@
1
- .opaca-sidebar-accordion {
2
- margin-bottom: 0.25rem;
3
- border: none !important;
4
- background: transparent !important;
5
-
6
- .opaca-sidebar-accordion-trigger {
7
- background: transparent;
8
- padding: 1rem 0.75rem 0.5rem 0.75rem;
9
- font-size: 0.625rem;
10
- color: var(--opaca-text-dim);
11
- text-transform: uppercase;
12
- letter-spacing: 0.06em;
13
- font-weight: 500;
14
- width: 100%;
15
- display: flex;
16
- align-items: center;
17
- justify-content: space-between;
18
- cursor: pointer;
19
- transition: color var(--opaca-transition);
20
- border: none;
21
- outline: none;
22
-
23
- &:hover {
24
- color: var(--opaca-text);
25
- }
26
-
27
- .opaca-sidebar-accordion-icon {
28
- width: 12px;
29
- height: 12px;
30
- stroke: var(--opaca-text-dim);
31
- fill: none;
32
- stroke-width: 2;
33
- stroke-linecap: round;
34
- stroke-linejoin: round;
35
- transition: transform 0.2s cubic-bezier(0.87, 0, 0.13, 1);
36
- }
37
-
38
- &[aria-expanded="true"] {
39
- .opaca-sidebar-accordion-icon {
40
- transform: rotate(180deg);
41
- }
42
- }
43
- }
44
-
45
- .opaca-sidebar-accordion-content {
46
- display: grid;
47
- grid-template-rows: 0fr;
48
- transition: grid-template-rows 0.2s cubic-bezier(0.87, 0, 0.13, 1);
49
-
50
- &[data-state="open"] {
51
- grid-template-rows: 1fr;
52
- }
53
-
54
- .opaca-sidebar-accordion-content-inner {
55
- overflow: hidden;
56
- display: flex;
57
- flex-direction: column;
58
- }
59
- }
60
- }
@@ -1,41 +0,0 @@
1
- @keyframes opaca-fade-in {
2
- from {
3
- opacity: 0;
4
- transform: translateY(8px);
5
- }
6
- to {
7
- opacity: 1;
8
- transform: translateY(0);
9
- }
10
- }
11
-
12
- @keyframes opaca-spin {
13
- from { transform: rotate(0deg); }
14
- to { transform: rotate(360deg); }
15
- }
16
-
17
- @keyframes opaca-toast-in {
18
- from {
19
- opacity: 0;
20
- transform: translateX(100%);
21
- }
22
- to {
23
- opacity: 1;
24
- transform: translateX(0);
25
- }
26
- }
27
-
28
- @keyframes opaca-pulse {
29
- 0%, 100% {
30
- transform: scale(1);
31
- opacity: 0.2;
32
- }
33
- 50% {
34
- transform: scale(1.4);
35
- opacity: 0;
36
- }
37
- }
38
-
39
- .opaca-spin {
40
- animation: opaca-spin 1s linear infinite;
41
- }