camox 0.0.0 → 0.1.2-alpha.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 (255) hide show
  1. package/LICENSE.md +110 -0
  2. package/dist/components/AuthGate.d.ts +7 -0
  3. package/dist/components/AuthGate.d.ts.map +1 -0
  4. package/dist/core/components/AddBlockControlBar.d.ts +9 -0
  5. package/dist/core/components/AddBlockControlBar.d.ts.map +1 -0
  6. package/dist/core/components/AddBlockControlBar.js +65 -0
  7. package/dist/core/components/lexical/InlineContentEditable.d.ts +7 -0
  8. package/dist/core/components/lexical/InlineContentEditable.d.ts.map +1 -0
  9. package/dist/core/components/lexical/InlineContentEditable.js +40 -0
  10. package/dist/core/components/lexical/InlineLexicalEditor.d.ts +12 -0
  11. package/dist/core/components/lexical/InlineLexicalEditor.d.ts.map +1 -0
  12. package/dist/core/components/lexical/InlineLexicalEditor.js +133 -0
  13. package/dist/core/components/lexical/InlineParagraphNode.d.ts +10 -0
  14. package/dist/core/components/lexical/InlineParagraphNode.d.ts.map +1 -0
  15. package/dist/core/components/lexical/InlineParagraphNode.js +34 -0
  16. package/dist/core/components/lexical/SelectionBroadcaster.d.ts +6 -0
  17. package/dist/core/components/lexical/SelectionBroadcaster.d.ts.map +1 -0
  18. package/dist/core/components/lexical/SelectionBroadcaster.js +62 -0
  19. package/dist/core/components/lexical/SidebarLexicalEditor.d.ts +9 -0
  20. package/dist/core/components/lexical/SidebarLexicalEditor.d.ts.map +1 -0
  21. package/dist/core/components/lexical/editorConfig.d.ts +4 -0
  22. package/dist/core/components/lexical/editorConfig.d.ts.map +1 -0
  23. package/dist/core/components/lexical/editorConfig.js +24 -0
  24. package/dist/core/createApp.d.ts +373 -0
  25. package/dist/core/createApp.d.ts.map +1 -0
  26. package/dist/core/createApp.js +40 -0
  27. package/dist/core/createBlock.d.ts +947 -0
  28. package/dist/core/createBlock.d.ts.map +1 -0
  29. package/dist/core/createBlock.js +873 -0
  30. package/dist/core/createLayout.d.ts +78 -0
  31. package/dist/core/createLayout.d.ts.map +1 -0
  32. package/dist/core/createLayout.js +73 -0
  33. package/dist/core/hooks/useFieldSelection.d.ts +11 -0
  34. package/dist/core/hooks/useFieldSelection.d.ts.map +1 -0
  35. package/dist/core/hooks/useFieldSelection.js +25 -0
  36. package/dist/core/hooks/useIsEditable.d.ts +2 -0
  37. package/dist/core/hooks/useIsEditable.d.ts.map +1 -0
  38. package/dist/core/hooks/useIsEditable.js +12 -0
  39. package/dist/core/hooks/useOverlayMessage.d.ts +10 -0
  40. package/dist/core/hooks/useOverlayMessage.d.ts.map +1 -0
  41. package/dist/core/hooks/useOverlayMessage.js +37 -0
  42. package/dist/core/lib/contentType.d.ts +165 -0
  43. package/dist/core/lib/contentType.d.ts.map +1 -0
  44. package/dist/core/lib/contentType.js +148 -0
  45. package/dist/core/lib/fieldTypes.d.ts +85 -0
  46. package/dist/core/lib/fieldTypes.d.ts.map +1 -0
  47. package/dist/core/lib/lexicalReact.d.ts +3 -0
  48. package/dist/core/lib/lexicalReact.d.ts.map +1 -0
  49. package/dist/core/lib/lexicalReact.js +24 -0
  50. package/dist/core/lib/lexicalState.d.ts +10 -0
  51. package/dist/core/lib/lexicalState.d.ts.map +1 -0
  52. package/dist/core/lib/lexicalState.js +38 -0
  53. package/dist/core/lib/modifierFormats.d.ts +9 -0
  54. package/dist/core/lib/modifierFormats.d.ts.map +1 -0
  55. package/dist/core/lib/modifierFormats.js +8 -0
  56. package/dist/core/lib/modifiers.d.ts +12 -0
  57. package/dist/core/lib/modifiers.d.ts.map +1 -0
  58. package/dist/core/lib/modifiers.js +27 -0
  59. package/dist/features/content/CamoxContent.d.ts +2 -0
  60. package/dist/features/content/CamoxContent.d.ts.map +1 -0
  61. package/dist/features/content/CamoxContent.js +100 -0
  62. package/dist/features/content/components/AssetCard.d.ts +10 -0
  63. package/dist/features/content/components/AssetCard.d.ts.map +1 -0
  64. package/dist/features/content/components/AssetCard.js +41 -0
  65. package/dist/features/content/components/AssetCardSkeleton.d.ts +2 -0
  66. package/dist/features/content/components/AssetCardSkeleton.d.ts.map +1 -0
  67. package/dist/features/content/components/AssetCardSkeleton.js +11 -0
  68. package/dist/features/content/components/ContentSidebar.d.ts +2 -0
  69. package/dist/features/content/components/ContentSidebar.d.ts.map +1 -0
  70. package/dist/features/content/components/ContentSidebar.js +15 -0
  71. package/dist/features/content/components/UploadDropZone.d.ts +9 -0
  72. package/dist/features/content/components/UploadDropZone.d.ts.map +1 -0
  73. package/dist/features/content/components/UploadDropZone.js +51 -0
  74. package/dist/features/content/components/UploadProgressDrawer.d.ts +11 -0
  75. package/dist/features/content/components/UploadProgressDrawer.d.ts.map +1 -0
  76. package/dist/features/content/components/UploadProgressDrawer.js +72 -0
  77. package/dist/features/preview/CamoxPreview.d.ts +124 -0
  78. package/dist/features/preview/CamoxPreview.d.ts.map +1 -0
  79. package/dist/features/preview/CamoxPreview.js +253 -0
  80. package/dist/features/preview/components/AddBlockSheet.d.ts +3 -0
  81. package/dist/features/preview/components/AddBlockSheet.d.ts.map +1 -0
  82. package/dist/features/preview/components/AddBlockSheet.js +121 -0
  83. package/dist/features/preview/components/AgentChatSheet.d.ts +3 -0
  84. package/dist/features/preview/components/AgentChatSheet.d.ts.map +1 -0
  85. package/dist/features/preview/components/AgentChatSheet.js +24 -0
  86. package/dist/features/preview/components/AssetFieldEditor.d.ts +18 -0
  87. package/dist/features/preview/components/AssetFieldEditor.d.ts.map +1 -0
  88. package/dist/features/preview/components/AssetFieldEditor.js +139 -0
  89. package/dist/features/preview/components/AssetLightbox.d.ts +9 -0
  90. package/dist/features/preview/components/AssetLightbox.d.ts.map +1 -0
  91. package/dist/features/preview/components/AssetLightbox.js +421 -0
  92. package/dist/features/preview/components/AssetPickerGrid.d.ts +11 -0
  93. package/dist/features/preview/components/AssetPickerGrid.d.ts.map +1 -0
  94. package/dist/features/preview/components/AssetPickerGrid.js +92 -0
  95. package/dist/features/preview/components/BlockActionsPopover.d.ts +15 -0
  96. package/dist/features/preview/components/BlockActionsPopover.d.ts.map +1 -0
  97. package/dist/features/preview/components/BlockActionsPopover.js +506 -0
  98. package/dist/features/preview/components/CreatePageSheet.d.ts +3 -0
  99. package/dist/features/preview/components/CreatePageSheet.d.ts.map +1 -0
  100. package/dist/features/preview/components/CreatePageSheet.js +159 -0
  101. package/dist/features/preview/components/DebouncedFieldEditor.d.ts +10 -0
  102. package/dist/features/preview/components/DebouncedFieldEditor.d.ts.map +1 -0
  103. package/dist/features/preview/components/DebouncedFieldEditor.js +51 -0
  104. package/dist/features/preview/components/EditPageSheet.d.ts +3 -0
  105. package/dist/features/preview/components/EditPageSheet.d.ts.map +1 -0
  106. package/dist/features/preview/components/EditPageSheet.js +352 -0
  107. package/dist/features/preview/components/ItemFieldsEditor.d.ts +29 -0
  108. package/dist/features/preview/components/ItemFieldsEditor.d.ts.map +1 -0
  109. package/dist/features/preview/components/ItemFieldsEditor.js +308 -0
  110. package/dist/features/preview/components/LinkFieldEditor.d.ts +8 -0
  111. package/dist/features/preview/components/LinkFieldEditor.d.ts.map +1 -0
  112. package/dist/features/preview/components/LinkFieldEditor.js +190 -0
  113. package/dist/features/preview/components/MultipleAssetFieldEditor.d.ts +10 -0
  114. package/dist/features/preview/components/MultipleAssetFieldEditor.d.ts.map +1 -0
  115. package/dist/features/preview/components/MultipleAssetFieldEditor.js +232 -0
  116. package/dist/features/preview/components/OverlayTracker.d.ts +6 -0
  117. package/dist/features/preview/components/OverlayTracker.d.ts.map +1 -0
  118. package/dist/features/preview/components/OverlayTracker.js +41 -0
  119. package/dist/features/preview/components/Overlays.d.ts +6 -0
  120. package/dist/features/preview/components/Overlays.d.ts.map +1 -0
  121. package/dist/features/preview/components/Overlays.js +58 -0
  122. package/dist/features/preview/components/PageContentSheet.d.ts +3 -0
  123. package/dist/features/preview/components/PageContentSheet.d.ts.map +1 -0
  124. package/dist/features/preview/components/PageContentSheet.js +492 -0
  125. package/dist/features/preview/components/PageLocationFieldset.d.ts +14 -0
  126. package/dist/features/preview/components/PageLocationFieldset.d.ts.map +1 -0
  127. package/dist/features/preview/components/PageLocationFieldset.js +77 -0
  128. package/dist/features/preview/components/PagePicker.d.ts +3 -0
  129. package/dist/features/preview/components/PagePicker.d.ts.map +1 -0
  130. package/dist/features/preview/components/PagePicker.js +185 -0
  131. package/dist/features/preview/components/PageTree.d.ts +3 -0
  132. package/dist/features/preview/components/PageTree.d.ts.map +1 -0
  133. package/dist/features/preview/components/PageTree.js +410 -0
  134. package/dist/features/preview/components/PeekedBlock.d.ts +6 -0
  135. package/dist/features/preview/components/PeekedBlock.d.ts.map +1 -0
  136. package/dist/features/preview/components/PeekedBlock.js +95 -0
  137. package/dist/features/preview/components/PreviewPanel.d.ts +12 -0
  138. package/dist/features/preview/components/PreviewPanel.d.ts.map +1 -0
  139. package/dist/features/preview/components/PreviewPanel.js +192 -0
  140. package/dist/features/preview/components/PreviewSideSheet.d.ts +13 -0
  141. package/dist/features/preview/components/PreviewSideSheet.d.ts.map +1 -0
  142. package/dist/features/preview/components/PreviewSideSheet.js +28 -0
  143. package/dist/features/preview/components/PreviewToolbar.d.ts +2 -0
  144. package/dist/features/preview/components/PreviewToolbar.d.ts.map +1 -0
  145. package/dist/features/preview/components/PreviewToolbar.js +79 -0
  146. package/dist/features/preview/components/RepeatableItemsList.d.ts +14 -0
  147. package/dist/features/preview/components/RepeatableItemsList.d.ts.map +1 -0
  148. package/dist/features/preview/components/RepeatableItemsList.js +366 -0
  149. package/dist/features/preview/components/ShikiMarkdown.d.ts +4 -0
  150. package/dist/features/preview/components/ShikiMarkdown.d.ts.map +1 -0
  151. package/dist/features/preview/components/ShikiMarkdown.js +37 -0
  152. package/dist/features/preview/components/TextFormatToolbar.d.ts +2 -0
  153. package/dist/features/preview/components/TextFormatToolbar.d.ts.map +1 -0
  154. package/dist/features/preview/components/TextFormatToolbar.js +73 -0
  155. package/dist/features/preview/components/UnlinkAssetButton.d.ts +9 -0
  156. package/dist/features/preview/components/UnlinkAssetButton.d.ts.map +1 -0
  157. package/dist/features/preview/components/UnlinkAssetButton.js +55 -0
  158. package/dist/features/preview/overlayConstants.d.ts +19 -0
  159. package/dist/features/preview/overlayConstants.d.ts.map +1 -0
  160. package/dist/features/preview/overlayConstants.js +21 -0
  161. package/dist/features/preview/overlayMessages.d.ts +62 -0
  162. package/dist/features/preview/overlayMessages.d.ts.map +1 -0
  163. package/dist/features/preview/overlayMessages.js +9 -0
  164. package/dist/features/preview/previewConstants.d.ts +2 -0
  165. package/dist/features/preview/previewConstants.d.ts.map +1 -0
  166. package/dist/features/preview/previewStore.d.ts +116 -0
  167. package/dist/features/preview/previewStore.d.ts.map +1 -0
  168. package/dist/features/preview/previewStore.js +321 -0
  169. package/dist/features/provider/CamoxProvider.d.ts +11 -0
  170. package/dist/features/provider/CamoxProvider.d.ts.map +1 -0
  171. package/dist/features/provider/CamoxProvider.js +73 -0
  172. package/dist/features/provider/actionsStore.d.ts +39 -0
  173. package/dist/features/provider/actionsStore.d.ts.map +1 -0
  174. package/dist/features/provider/actionsStore.js +35 -0
  175. package/dist/features/provider/components/CamoxAppContext.d.ts +371 -0
  176. package/dist/features/provider/components/CamoxAppContext.d.ts.map +1 -0
  177. package/dist/features/provider/components/CamoxAppContext.js +17 -0
  178. package/dist/features/provider/components/CommandPalette.d.ts +3 -0
  179. package/dist/features/provider/components/CommandPalette.d.ts.map +1 -0
  180. package/dist/features/provider/components/CommandPalette.js +127 -0
  181. package/dist/features/provider/useAdminShortcuts.d.ts +5 -0
  182. package/dist/features/provider/useAdminShortcuts.d.ts.map +1 -0
  183. package/dist/features/provider/useAdminShortcuts.js +83 -0
  184. package/dist/features/routes/ogRoute.d.ts +7 -0
  185. package/dist/features/routes/ogRoute.d.ts.map +1 -0
  186. package/dist/features/routes/ogRoute.js +19 -0
  187. package/dist/features/routes/pageRoute.d.ts +135 -0
  188. package/dist/features/routes/pageRoute.d.ts.map +1 -0
  189. package/dist/features/routes/pageRoute.js +112 -0
  190. package/dist/features/studio/CamoxStudio.d.ts +7 -0
  191. package/dist/features/studio/CamoxStudio.d.ts.map +1 -0
  192. package/dist/features/studio/CamoxStudio.js +24 -0
  193. package/dist/features/studio/components/Navbar.d.ts +4 -0
  194. package/dist/features/studio/components/Navbar.d.ts.map +1 -0
  195. package/dist/features/studio/components/Navbar.js +95 -0
  196. package/dist/features/studio/components/ProjectMenu.d.ts +2 -0
  197. package/dist/features/studio/components/ProjectMenu.d.ts.map +1 -0
  198. package/dist/features/studio/components/ProjectMenu.js +132 -0
  199. package/dist/features/studio/components/UserButton.d.ts +2 -0
  200. package/dist/features/studio/components/UserButton.d.ts.map +1 -0
  201. package/dist/features/studio/components/UserButton.js +96 -0
  202. package/dist/features/studio/studioStore.d.ts +17 -0
  203. package/dist/features/studio/studioStore.d.ts.map +1 -0
  204. package/dist/features/studio/studioStore.js +44 -0
  205. package/dist/features/studio/useTheme.d.ts +9 -0
  206. package/dist/features/studio/useTheme.d.ts.map +1 -0
  207. package/dist/features/studio/useTheme.js +98 -0
  208. package/dist/features/vite/appGeneration.d.ts +4 -0
  209. package/dist/features/vite/appGeneration.d.ts.map +1 -0
  210. package/dist/features/vite/appGeneration.js +67 -0
  211. package/dist/features/vite/blockBoilerplate.d.ts +3 -0
  212. package/dist/features/vite/blockBoilerplate.d.ts.map +1 -0
  213. package/dist/features/vite/blockBoilerplate.js +59 -0
  214. package/dist/features/vite/convexSync.d.ts +6 -0
  215. package/dist/features/vite/convexSync.d.ts.map +1 -0
  216. package/dist/features/vite/convexSync.js +98 -0
  217. package/dist/features/vite/definitionsSync.d.ts +11 -0
  218. package/dist/features/vite/definitionsSync.d.ts.map +1 -0
  219. package/dist/features/vite/definitionsSync.js +157 -0
  220. package/dist/features/vite/routeGeneration.d.ts +4 -0
  221. package/dist/features/vite/routeGeneration.d.ts.map +1 -0
  222. package/dist/features/vite/routeGeneration.js +194 -0
  223. package/dist/features/vite/skillGeneration.d.ts +4 -0
  224. package/dist/features/vite/skillGeneration.d.ts.map +1 -0
  225. package/dist/features/vite/skillGeneration.js +69 -0
  226. package/dist/features/vite/utils.d.ts +2 -0
  227. package/dist/features/vite/utils.d.ts.map +1 -0
  228. package/dist/features/vite/utils.js +10 -0
  229. package/dist/features/vite/vite.d.ts +18 -0
  230. package/dist/features/vite/vite.d.ts.map +1 -0
  231. package/dist/features/vite/vite.js +77 -0
  232. package/dist/hooks/use-file-upload.d.ts +22 -0
  233. package/dist/hooks/use-file-upload.d.ts.map +1 -0
  234. package/dist/hooks/use-marquee-selection.d.ts +17 -0
  235. package/dist/hooks/use-marquee-selection.d.ts.map +1 -0
  236. package/dist/lib/analytics-client.d.ts +3 -0
  237. package/dist/lib/analytics-client.d.ts.map +1 -0
  238. package/dist/lib/analytics.d.ts +3 -0
  239. package/dist/lib/analytics.d.ts.map +1 -0
  240. package/dist/lib/analytics.js +24 -0
  241. package/dist/lib/auth.d.ts +3683 -0
  242. package/dist/lib/auth.d.ts.map +1 -0
  243. package/dist/lib/convex-site.d.ts +3 -0
  244. package/dist/lib/convex-site.d.ts.map +1 -0
  245. package/dist/lib/utils.d.ts +40 -0
  246. package/dist/lib/utils.d.ts.map +1 -0
  247. package/dist/studio.css +2 -0
  248. package/package.json +123 -10
  249. package/server/api.d.ts +1 -0
  250. package/server/api.js +1 -0
  251. package/server/dataModel.d.ts +1 -0
  252. package/server/dataModel.js +1 -0
  253. package/skills/camox-block/SKILL.md +357 -0
  254. package/skills/camox-layout/SKILL.md +181 -0
  255. package/index.js +0 -3
@@ -0,0 +1,78 @@
1
+ import * as React from "react";
2
+ export interface OgImageParams {
3
+ title: string;
4
+ description: string;
5
+ projectName: string;
6
+ }
7
+ export interface LayoutBlockData {
8
+ _id: string;
9
+ type: string;
10
+ content: Record<string, unknown>;
11
+ settings?: Record<string, unknown>;
12
+ position: string;
13
+ }
14
+ /** Minimal block interface — avoids importing the full generic Block type. */
15
+ interface LayoutBlock {
16
+ id: string;
17
+ Component: React.ComponentType<{
18
+ blockData: any;
19
+ mode: "site" | "peek" | "layout";
20
+ isFirstBlock?: boolean;
21
+ showAddBlockTop?: boolean;
22
+ showAddBlockBottom?: boolean;
23
+ addBlockAfterPosition?: string | null;
24
+ }>;
25
+ getInitialContent: () => Record<string, unknown>;
26
+ getInitialSettings: () => Record<string, unknown>;
27
+ }
28
+ interface CreateLayoutOptions {
29
+ id: string;
30
+ title: string;
31
+ description: string;
32
+ blocks: {
33
+ before: LayoutBlock[];
34
+ after: LayoutBlock[];
35
+ };
36
+ component: React.ComponentType<{
37
+ children: React.ReactNode;
38
+ }>;
39
+ buildMetaTitle: (params: {
40
+ pageMetaTitle: string;
41
+ projectName: string;
42
+ pageFullPath: string;
43
+ }) => string;
44
+ buildOgImage?: (params: OgImageParams) => React.ReactElement;
45
+ }
46
+ export declare function createLayout(options: CreateLayoutOptions): {
47
+ id: string;
48
+ title: string;
49
+ description: string;
50
+ buildMetaTitle: (params: {
51
+ pageMetaTitle: string;
52
+ projectName: string;
53
+ pageFullPath: string;
54
+ }) => string;
55
+ buildOgImage: ((params: OgImageParams) => Promise<Response>) | undefined;
56
+ blockDefinitions: ({
57
+ type: string;
58
+ content: Record<string, unknown>;
59
+ settings: Record<string, unknown>;
60
+ placement: "before";
61
+ } | {
62
+ type: string;
63
+ content: Record<string, unknown>;
64
+ settings: Record<string, unknown>;
65
+ placement: "after";
66
+ })[];
67
+ component: React.ComponentType<{
68
+ children: React.ReactNode;
69
+ }>;
70
+ Provider: ({ layoutBlocks, children, }: {
71
+ layoutBlocks: Record<string, LayoutBlockData>;
72
+ children: React.ReactNode;
73
+ }) => import("react/jsx-runtime").JSX.Element;
74
+ blocks: Record<string, React.ComponentType>;
75
+ };
76
+ export type Layout = ReturnType<typeof createLayout>;
77
+ export {};
78
+ //# sourceMappingURL=createLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createLayout.d.ts","sourceRoot":"","sources":["../../src/core/createLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAA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AM,EAAE;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;KACtB,KAAK,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,KAAK,CAAC,YAAY,CAAC;CAC9D;AASD,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB;;;;6BAf9B;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;KACtB,KAAK,MAAM;4BAuFO,aAAa,KAAG,OAAO,CAAC,QAAQ,CAAC;;;;;;;;;;;;;kBA5FT,KAAK,CAAC,SAAS;;4CAmEvD;QACD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;KAC3B;YAsC2B,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC;EAEhE;AAED,MAAM,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
@@ -0,0 +1,73 @@
1
+ import * as React from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/core/createLayout.tsx
4
+ function toPascalCase(str) {
5
+ return str.split(/[-_\s]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
6
+ }
7
+ function createLayout(options) {
8
+ const LayoutContext = React.createContext(null);
9
+ const allBlocks = [...options.blocks.before, ...options.blocks.after];
10
+ const slotComponents = {};
11
+ const lastBeforeBlock = options.blocks.before[options.blocks.before.length - 1];
12
+ const firstAfterBlock = options.blocks.after[0];
13
+ for (const block of allBlocks) {
14
+ const isLastBefore = block === lastBeforeBlock;
15
+ const isFirstAfter = block === firstAfterBlock;
16
+ const SlotComponent = () => {
17
+ const ctx = React.use(LayoutContext);
18
+ if (!ctx) throw new Error(`Layout slot "${block.id}" must be rendered inside a LayoutContextProvider`);
19
+ const blockData = ctx.layoutBlocks[block.id];
20
+ if (!blockData) return null;
21
+ return /* @__PURE__ */ jsx(block.Component, {
22
+ blockData,
23
+ mode: "layout",
24
+ showAddBlockTop: isFirstAfter || void 0,
25
+ showAddBlockBottom: isLastBefore || void 0,
26
+ addBlockAfterPosition: (() => {
27
+ if (isLastBefore) return "";
28
+ if (isFirstAfter) return null;
29
+ })()
30
+ });
31
+ };
32
+ SlotComponent.displayName = `LayoutSlot(${toPascalCase(block.id)})`;
33
+ slotComponents[toPascalCase(block.id)] = SlotComponent;
34
+ }
35
+ const Provider = ({ layoutBlocks, children }) => {
36
+ const value = React.useMemo(() => ({ layoutBlocks }), [layoutBlocks]);
37
+ return /* @__PURE__ */ jsx(LayoutContext.Provider, {
38
+ value,
39
+ children
40
+ });
41
+ };
42
+ const blockDefinitions = [...options.blocks.before.map((block) => ({
43
+ type: block.id,
44
+ content: block.getInitialContent(),
45
+ settings: block.getInitialSettings(),
46
+ placement: "before"
47
+ })), ...options.blocks.after.map((block) => ({
48
+ type: block.id,
49
+ content: block.getInitialContent(),
50
+ settings: block.getInitialSettings(),
51
+ placement: "after"
52
+ }))];
53
+ const buildOgImage = options.buildOgImage ? async (params) => {
54
+ const { ImageResponse } = await import("@takumi-rs/image-response");
55
+ return new ImageResponse(options.buildOgImage(params), {
56
+ width: 1200,
57
+ height: 630
58
+ });
59
+ } : void 0;
60
+ return {
61
+ id: options.id,
62
+ title: options.title,
63
+ description: options.description,
64
+ buildMetaTitle: options.buildMetaTitle,
65
+ buildOgImage,
66
+ blockDefinitions,
67
+ component: options.component,
68
+ Provider,
69
+ blocks: slotComponents
70
+ };
71
+ }
72
+ //#endregion
73
+ export { createLayout };
@@ -0,0 +1,11 @@
1
+ import { FieldType } from '../lib/fieldTypes.tsx';
2
+ /**
3
+ * Returns whether the given field is currently selected based on selectionBreadcrumbs.
4
+ *
5
+ * Matches when the breadcrumb trail contains:
6
+ * 1. A Block crumb matching `blockId`
7
+ * 2. (Optionally) a RepeatableObject crumb matching the repeater context
8
+ * 3. A crumb matching `fieldType` and `fieldName`
9
+ */
10
+ export declare function useFieldSelection(blockId: string, fieldName: string, fieldType: FieldType, repeaterItemId?: string): boolean;
11
+ //# sourceMappingURL=useFieldSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFieldSelection.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/useFieldSelection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,SAAS,EACpB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAwBT"}
@@ -0,0 +1,25 @@
1
+ import { previewStore } from "../../features/preview/previewStore.js";
2
+ import { useSelector } from "@xstate/store/react";
3
+ //#region src/core/hooks/useFieldSelection.ts
4
+ /**
5
+ * Returns whether the given field is currently selected based on selectionBreadcrumbs.
6
+ *
7
+ * Matches when the breadcrumb trail contains:
8
+ * 1. A Block crumb matching `blockId`
9
+ * 2. (Optionally) a RepeatableObject crumb matching the repeater context
10
+ * 3. A crumb matching `fieldType` and `fieldName`
11
+ */
12
+ function useFieldSelection(blockId, fieldName, fieldType, repeaterItemId) {
13
+ return useSelector(previewStore, (state) => {
14
+ const crumbs = state.context.selectionBreadcrumbs;
15
+ if (crumbs.length === 0) return false;
16
+ if (crumbs[0]?.type !== "Block" || crumbs[0]?.id !== blockId) return false;
17
+ if (!crumbs.find((c) => c.type === fieldType && (c.id === fieldName || c.fieldName === fieldName))) return false;
18
+ if (repeaterItemId) {
19
+ if (!crumbs.find((c) => c.type === "RepeatableObject" && c.id === repeaterItemId)) return false;
20
+ }
21
+ return true;
22
+ });
23
+ }
24
+ //#endregion
25
+ export { useFieldSelection };
@@ -0,0 +1,2 @@
1
+ export declare function useIsEditable(mode: "site" | "peek" | "layout"): boolean;
2
+ //# sourceMappingURL=useIsEditable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIsEditable.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/useIsEditable.ts"],"names":[],"mappings":"AAKA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,WAU7D"}
@@ -0,0 +1,12 @@
1
+ import { useSelector } from "@xstate/store/react";
2
+ import { useConvexAuth } from "convex/react";
3
+ import { previewStore } from "@/features/preview/previewStore";
4
+ //#region src/core/hooks/useIsEditable.ts
5
+ function useIsEditable(mode) {
6
+ const { isAuthenticated } = useConvexAuth();
7
+ const isPresentationMode = useSelector(previewStore, (state) => state.context.isPresentationMode);
8
+ const isContentLocked = useSelector(previewStore, (state) => state.context.isContentLocked);
9
+ return isAuthenticated && (mode === "site" || mode === "layout") && !isPresentationMode && !isContentLocked;
10
+ }
11
+ //#endregion
12
+ export { useIsEditable };
@@ -0,0 +1,10 @@
1
+ import { OverlayMessage } from '../../features/preview/overlayMessages';
2
+ /**
3
+ * Listens for a pair of overlay start/end messages on the iframe window and
4
+ * returns whether the "active" (start) state is currently on.
5
+ *
6
+ * Skips setup when `enabled` is false, `iframeWindow` is null, or any value in
7
+ * `match` is undefined.
8
+ */
9
+ export declare function useOverlayMessage(iframeWindow: Window | null, enabled: boolean, startType: OverlayMessage["type"], endType: OverlayMessage["type"], match: Record<string, string | undefined>): boolean;
10
+ //# sourceMappingURL=useOverlayMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOverlayMessage.d.ts","sourceRoot":"","sources":["../../../src/core/hooks/useOverlayMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE/F;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,EACjC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACxC,OAAO,CAyBT"}
@@ -0,0 +1,37 @@
1
+ import { isOverlayMessage } from "../../features/preview/overlayMessages.js";
2
+ import * as React from "react";
3
+ //#region src/core/hooks/useOverlayMessage.ts
4
+ /**
5
+ * Listens for a pair of overlay start/end messages on the iframe window and
6
+ * returns whether the "active" (start) state is currently on.
7
+ *
8
+ * Skips setup when `enabled` is false, `iframeWindow` is null, or any value in
9
+ * `match` is undefined.
10
+ */
11
+ function useOverlayMessage(iframeWindow, enabled, startType, endType, match) {
12
+ const [active, setActive] = React.useState(false);
13
+ const matchJson = JSON.stringify(match);
14
+ React.useEffect(() => {
15
+ if (!enabled || !iframeWindow) return;
16
+ const matchEntries = Object.entries(JSON.parse(matchJson));
17
+ if (matchEntries.some(([, v]) => v === void 0)) return;
18
+ const handleMessage = (event) => {
19
+ if (!isOverlayMessage(event.data)) return;
20
+ const data = event.data;
21
+ if (data.type !== startType && data.type !== endType) return;
22
+ if (!matchEntries.every(([k, v]) => data[k] === v)) return;
23
+ setActive(data.type === startType);
24
+ };
25
+ iframeWindow.addEventListener("message", handleMessage);
26
+ return () => iframeWindow.removeEventListener("message", handleMessage);
27
+ }, [
28
+ enabled,
29
+ iframeWindow,
30
+ startType,
31
+ endType,
32
+ matchJson
33
+ ]);
34
+ return active;
35
+ }
36
+ //#endregion
37
+ export { useOverlayMessage };
@@ -0,0 +1,165 @@
1
+ import { TSchema, TUnsafe, TArray, TObject } from '@sinclair/typebox';
2
+ export type ExtractPlaceholders<S extends string> = S extends `${string}{{${infer Key}}}${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
3
+ export type ExtractAllPlaceholders<T extends readonly string[]> = ExtractPlaceholders<T[number]>;
4
+ declare const EmbedURLBrand: unique symbol;
5
+ export type EmbedURL = string & {
6
+ readonly [EmbedURLBrand]: true;
7
+ };
8
+ declare const LinkBrand: unique symbol;
9
+ export type LinkValue = ({
10
+ type: "external";
11
+ href: string;
12
+ } | {
13
+ type: "page";
14
+ pageId: string;
15
+ }) & {
16
+ text: string;
17
+ newTab: boolean;
18
+ } & {
19
+ readonly [LinkBrand]: true;
20
+ };
21
+ export type ImageValue = {
22
+ url: string;
23
+ alt: string;
24
+ filename: string;
25
+ mimeType: string;
26
+ _fileId?: string;
27
+ } & {
28
+ readonly __brand: "ImageValue";
29
+ };
30
+ export type FileValue = {
31
+ url: string;
32
+ alt: string;
33
+ filename: string;
34
+ mimeType: string;
35
+ _fileId?: string;
36
+ } & {
37
+ readonly __brand: "FileValue";
38
+ };
39
+ declare function _imageType(options: {
40
+ title?: string;
41
+ multiple: true;
42
+ defaultItems: number;
43
+ }): TArray<TObject<{
44
+ image: TUnsafe<ImageValue>;
45
+ }>>;
46
+ declare function _imageType(options: {
47
+ title?: string;
48
+ multiple?: false;
49
+ }): TUnsafe<ImageValue>;
50
+ declare function _fileType(options: {
51
+ accept: string[];
52
+ title?: string;
53
+ multiple: true;
54
+ defaultItems: number;
55
+ }): TArray<TObject<{
56
+ file: TUnsafe<FileValue>;
57
+ }>>;
58
+ declare function _fileType(options: {
59
+ accept: string[];
60
+ title?: string;
61
+ multiple?: false;
62
+ }): TUnsafe<FileValue>;
63
+ /**
64
+ * Type builders for createBlock content schemas.
65
+ * All fields must have default values.
66
+ */
67
+ export declare const Type: {
68
+ /**
69
+ * Creates a string field with a required default value.
70
+ *
71
+ * @example
72
+ * Type.String({ default: 'Hello' })
73
+ * Type.String({ default: 'Hello', maxLength: 100, title: 'Title' })
74
+ */
75
+ String: (options: {
76
+ default: string;
77
+ title?: string;
78
+ maxLength?: number;
79
+ minLength?: number;
80
+ pattern?: string;
81
+ }) => import('@sinclair/typebox').TString;
82
+ /**
83
+ * Creates a repeatable array of objects.
84
+ * Arrays and objects must always be used together - no standalone arrays or objects.
85
+ * The default array is auto-generated based on minItems.
86
+ *
87
+ * @example
88
+ * Type.RepeatableObject({
89
+ * title: Type.String({ default: 'Item' }),
90
+ * description: Type.String({ default: 'Description' })
91
+ * }, {
92
+ * minItems: 1,
93
+ * maxItems: 10,
94
+ * title: 'Items'
95
+ * })
96
+ */
97
+ RepeatableObject: <T extends Record<string, TSchema>, const TMarkdown extends readonly string[] = readonly string[]>(shape: T, options: {
98
+ minItems: number;
99
+ maxItems: number;
100
+ title?: string;
101
+ } & ([ExtractAllPlaceholders<TMarkdown>] extends [Extract<keyof T, string>] ? {
102
+ toMarkdown?: TMarkdown;
103
+ } : {
104
+ toMarkdown?: readonly [`Invalid toMarkdown placeholder: "{{${Exclude<ExtractAllPlaceholders<TMarkdown>, Extract<keyof T, string>>}}}"`];
105
+ })) => TArray<TObject<T>>;
106
+ /**
107
+ * Creates an enum field with a set of predefined options.
108
+ *
109
+ * @example
110
+ * Type.Enum({
111
+ * default: 'left',
112
+ * options: { left: 'Left', center: 'Center', right: 'Right' },
113
+ * title: 'Alignment'
114
+ * })
115
+ */
116
+ Enum: (options: {
117
+ default: string;
118
+ options: Record<string, string>;
119
+ title?: string;
120
+ }) => TUnsafe<string>;
121
+ /**
122
+ * Creates a boolean toggle field.
123
+ *
124
+ * @example
125
+ * Type.Boolean({ default: false, title: 'Show background' })
126
+ */
127
+ Boolean: (options: {
128
+ default: boolean;
129
+ title?: string;
130
+ }) => import('@sinclair/typebox').TBoolean;
131
+ /**
132
+ * Creates an embed field for URLs matching a specific pattern.
133
+ *
134
+ * @example
135
+ * Type.Embed({
136
+ * pattern: 'https:\\/\\/(www\\.)?youtube\\.com\\/watch\\?v=.+',
137
+ * default: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
138
+ * title: 'YouTube URL'
139
+ * })
140
+ */
141
+ Embed: (options: {
142
+ pattern: string;
143
+ default: string;
144
+ title?: string;
145
+ }) => TUnsafe<EmbedURL>;
146
+ /**
147
+ * Creates a link field with text, href/pageId, and newTab properties.
148
+ * Supports both external URLs and internal page links.
149
+ *
150
+ * @example
151
+ * Type.Link({ default: { text: 'Learn more', href: '/', newTab: false }, title: 'CTA' })
152
+ */
153
+ Link: (options: {
154
+ default: {
155
+ text: string;
156
+ href: string;
157
+ newTab: boolean;
158
+ };
159
+ title?: string;
160
+ }) => TUnsafe<LinkValue>;
161
+ Image: typeof _imageType;
162
+ File: typeof _fileType;
163
+ };
164
+ export {};
165
+ //# sourceMappingURL=contentType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/core/lib/contentType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,OAAO,EACb,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,IAC9C,CAAC,SAAS,GAAG,MAAM,KAAK,MAAM,GAAG,KAAK,MAAM,IAAI,EAAE,GAAG,GAAG,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAE/F,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,IAAI,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAMjG,OAAO,CAAC,MAAM,aAAa,EAAE,OAAO,MAAM,CAAC;AAC3C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAMnE,OAAO,CAAC,MAAM,SAAS,EAAE,OAAO,MAAM,CAAC;AACvC,MAAM,MAAM,SAAS,GAAG,CAAC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG;IAChG,IAAI,EAAE,M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A;KAAE;IAYpF;;;;;OAKG;uBACgB;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAQvD;;;;;;;;;OASG;qBACc;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAerE;;;;;;OAMG;oBACa;QAAE,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,OAAO,CAAA;SAAE,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;;;CAmBxD,CAAC"}
@@ -0,0 +1,148 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ //#region src/core/lib/contentType.ts
3
+ function _imageType(options) {
4
+ const imageDefault = {
5
+ url: `https://placehold.co/1200x800/f4f4f5/a1a1aa.png?text=${options?.title || "image"}`,
6
+ alt: "",
7
+ filename: "placeholder.png",
8
+ mimeType: "image/png"
9
+ };
10
+ const singleSchema = Type.Unsafe({
11
+ type: "object",
12
+ properties: {
13
+ url: { type: "string" },
14
+ alt: { type: "string" },
15
+ filename: { type: "string" },
16
+ mimeType: { type: "string" }
17
+ },
18
+ accept: ["image/*"],
19
+ default: imageDefault,
20
+ title: options.title,
21
+ fieldType: "Image"
22
+ });
23
+ if (!options.multiple) return singleSchema;
24
+ const defaultItems = options.defaultItems ?? 0;
25
+ const itemSchema = Type.Object({ image: singleSchema });
26
+ const defaultArray = Array.from({ length: defaultItems }, () => ({ image: imageDefault }));
27
+ return Type.Array(itemSchema, {
28
+ minItems: 0,
29
+ maxItems: 100,
30
+ default: defaultArray,
31
+ title: options.title,
32
+ fieldType: "RepeatableObject",
33
+ arrayItemType: "Image"
34
+ });
35
+ }
36
+ function _fileType(options) {
37
+ const fileDefault = {
38
+ url: "https://placehold.co/file-placeholder",
39
+ alt: "",
40
+ filename: "placeholder",
41
+ mimeType: "application/octet-stream"
42
+ };
43
+ const singleSchema = Type.Unsafe({
44
+ type: "object",
45
+ properties: {
46
+ url: { type: "string" },
47
+ alt: { type: "string" },
48
+ filename: { type: "string" },
49
+ mimeType: { type: "string" }
50
+ },
51
+ accept: options.accept,
52
+ default: fileDefault,
53
+ title: options.title,
54
+ fieldType: "File"
55
+ });
56
+ if (!options.multiple) return singleSchema;
57
+ const defaultItems = options.defaultItems ?? 0;
58
+ const itemSchema = Type.Object({ file: singleSchema });
59
+ const defaultArray = Array.from({ length: defaultItems }, () => ({ file: fileDefault }));
60
+ return Type.Array(itemSchema, {
61
+ minItems: 0,
62
+ maxItems: 100,
63
+ default: defaultArray,
64
+ title: options.title,
65
+ fieldType: "RepeatableObject",
66
+ arrayItemType: "File"
67
+ });
68
+ }
69
+ /**
70
+ * Type builders for createBlock content schemas.
71
+ * All fields must have default values.
72
+ */
73
+ var Type$1 = {
74
+ String: (options) => {
75
+ return Type.String({
76
+ ...options,
77
+ fieldType: "String"
78
+ });
79
+ },
80
+ RepeatableObject: (shape, options) => {
81
+ if (options.minItems < 1) throw new Error("RepeatableObject requires minItems to be at least 1");
82
+ const objectSchema = Type.Object(shape);
83
+ const defaultItem = {};
84
+ for (const [key, prop] of Object.entries(objectSchema.properties)) if ("default" in prop) defaultItem[key] = prop.default;
85
+ const defaultArray = Array(options.minItems).fill(null).map(() => ({ ...defaultItem }));
86
+ return Type.Array(objectSchema, {
87
+ minItems: options.minItems,
88
+ maxItems: options.maxItems,
89
+ default: defaultArray,
90
+ title: options.title,
91
+ fieldType: "RepeatableObject",
92
+ ..."toMarkdown" in options && options.toMarkdown ? { toMarkdown: options.toMarkdown } : {}
93
+ });
94
+ },
95
+ Enum: (options) => {
96
+ const enumValues = Object.keys(options.options);
97
+ return Type.Unsafe({
98
+ type: "string",
99
+ enum: enumValues,
100
+ default: options.default,
101
+ title: options.title,
102
+ enumLabels: options.options,
103
+ fieldType: "Enum"
104
+ });
105
+ },
106
+ Boolean: (options) => {
107
+ return Type.Boolean({
108
+ default: options.default,
109
+ title: options.title,
110
+ fieldType: "Boolean"
111
+ });
112
+ },
113
+ Embed: (options) => {
114
+ if (!new RegExp(options.pattern).test(options.default)) throw new Error(`Embed default value "${options.default}" does not match pattern "${options.pattern}"`);
115
+ return Type.Unsafe({
116
+ type: "string",
117
+ pattern: options.pattern,
118
+ default: options.default,
119
+ title: options.title,
120
+ fieldType: "Embed"
121
+ });
122
+ },
123
+ Link: (options) => {
124
+ return Type.Unsafe({
125
+ type: "object",
126
+ properties: {
127
+ type: {
128
+ type: "string",
129
+ enum: ["external", "page"]
130
+ },
131
+ text: { type: "string" },
132
+ href: { type: "string" },
133
+ pageId: { type: "string" },
134
+ newTab: { type: "boolean" }
135
+ },
136
+ default: {
137
+ ...options.default,
138
+ type: "external"
139
+ },
140
+ title: options.title,
141
+ fieldType: "Link"
142
+ });
143
+ },
144
+ Image: _imageType,
145
+ File: _fileType
146
+ };
147
+ //#endregion
148
+ export { Type$1 as Type };
@@ -0,0 +1,85 @@
1
+ import { Id } from 'camox/server/dataModel';
2
+ import { LucideProps } from 'lucide-react';
3
+ type FieldLabelMeta = {
4
+ schemaTitle?: string;
5
+ fieldName: string;
6
+ fetchedTitle?: string | null;
7
+ };
8
+ type TreeDoubleClickParams = {
9
+ blockId: Id<"blocks">;
10
+ fieldName: string;
11
+ };
12
+ type SchemaFieldMeta = {
13
+ arrayItemType?: string;
14
+ };
15
+ declare const fieldTypesDictionary: {
16
+ String: {
17
+ label: string;
18
+ isScalar: true;
19
+ isContentEditable: true;
20
+ getIcon: () => (props: LucideProps) => import("react/jsx-runtime").JSX.Element;
21
+ getLabel: (value: unknown) => string;
22
+ onTreeDoubleClick: ({ blockId, fieldName }: TreeDoubleClickParams) => void;
23
+ };
24
+ RepeatableObject: {
25
+ label: string;
26
+ isScalar: false;
27
+ isContentEditable: false;
28
+ getIcon: ({ arrayItemType }: SchemaFieldMeta) => (props: LucideProps) => import("react/jsx-runtime").JSX.Element;
29
+ getLabel: (_value: unknown, { schemaTitle, fieldName }: FieldLabelMeta) => string;
30
+ onTreeDoubleClick: ({ blockId }: TreeDoubleClickParams) => void;
31
+ };
32
+ Enum: {
33
+ label: string;
34
+ isScalar: true;
35
+ isContentEditable: false;
36
+ getIcon: () => (props: LucideProps) => import("react/jsx-runtime").JSX.Element;
37
+ getLabel: (value: unknown) => string;
38
+ onTreeDoubleClick: ({ blockId, fieldName }: TreeDoubleClickParams) => void;
39
+ };
40
+ Boolean: {
41
+ label: string;
42
+ isScalar: true;
43
+ isContentEditable: false;
44
+ getIcon: () => (props: LucideProps) => import("react/jsx-runtime").JSX.Element;
45
+ getLabel: (value: unknown) => string;
46
+ onTreeDoubleClick: ({ blockId, fieldName }: TreeDoubleClickParams) => void;
47
+ };
48
+ Embed: {
49
+ label: string;
50
+ isScalar: true;
51
+ isContentEditable: false;
52
+ getIcon: () => (props: LucideProps) => import("react/jsx-runtime").JSX.Element;
53
+ getLabel: (value: unknown, { schemaTitle, fieldName, fetchedTitle }: FieldLabelMeta) => string;
54
+ onTreeDoubleClick: ({ blockId, fieldName }: TreeDoubleClickParams) => void;
55
+ };
56
+ Link: {
57
+ label: string;
58
+ isScalar: false;
59
+ isContentEditable: false;
60
+ getIcon: () => (props: LucideProps) => import("react/jsx-runtime").JSX.Element;
61
+ getLabel: (value: unknown) => string;
62
+ onTreeDoubleClick: ({ blockId, fieldName }: TreeDoubleClickParams) => void;
63
+ };
64
+ Image: {
65
+ label: string;
66
+ isScalar: false;
67
+ isContentEditable: false;
68
+ getIcon: () => (props: LucideProps) => import("react/jsx-runtime").JSX.Element;
69
+ getLabel: (value: unknown, { schemaTitle, fieldName }: FieldLabelMeta) => string;
70
+ onTreeDoubleClick: ({ blockId, fieldName }: TreeDoubleClickParams) => void;
71
+ };
72
+ File: {
73
+ label: string;
74
+ isScalar: false;
75
+ isContentEditable: false;
76
+ getIcon: () => (props: LucideProps) => import("react/jsx-runtime").JSX.Element;
77
+ getLabel: (value: unknown, { schemaTitle, fieldName }: FieldLabelMeta) => string;
78
+ onTreeDoubleClick: ({ blockId, fieldName }: TreeDoubleClickParams) => void;
79
+ };
80
+ };
81
+ type FieldTypesDictionary = typeof fieldTypesDictionary;
82
+ type FieldType = keyof FieldTypesDictionary;
83
+ export type { FieldType, FieldLabelMeta, SchemaFieldMeta };
84
+ export { fieldTypesDictionary };
85
+ //# sourceMappingURL=fieldTypes.d.ts.map