@reacteditor/core 0.0.9 → 0.0.11

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 (46) hide show
  1. package/README.md +7 -7
  2. package/dist/{Editor-KXEVJBNG.mjs → Editor-GK6JTUPD.mjs} +7 -7
  3. package/dist/{actions-2L-1hQ7r.d.mts → actions-C0LX6bI4.d.mts} +2 -1
  4. package/dist/{actions-2L-1hQ7r.d.ts → actions-C0LX6bI4.d.ts} +2 -1
  5. package/dist/{chunk-LRFRIIKG.mjs → chunk-56I7ST5F.mjs} +1 -1
  6. package/dist/{chunk-DU757QEH.mjs → chunk-74TOLW7F.mjs} +1561 -1266
  7. package/dist/{chunk-IIRJMJFU.mjs → chunk-ERNSJXVF.mjs} +1 -0
  8. package/dist/{chunk-TI3KC54Y.mjs → chunk-II42EKFK.mjs} +47 -1
  9. package/dist/{chunk-AD7BMXAA.mjs → chunk-MJJPWASL.mjs} +1 -1
  10. package/dist/{chunk-U7VW3V3W.mjs → chunk-TGVAC3JP.mjs} +9 -9
  11. package/dist/{chunk-FT6UFK7G.mjs → chunk-X4EUZIHA.mjs} +1 -1
  12. package/dist/{chunk-OIFPBVSF.mjs → chunk-XLVEWZWT.mjs} +1 -1
  13. package/dist/{chunk-AJWRDM22.mjs → chunk-YBG2RYVF.mjs} +5 -5
  14. package/dist/{full-ZFZZ626B.mjs → full-IUPXFMQP.mjs} +6 -6
  15. package/dist/{index-BXuSeNez.d.mts → index-DMbFEg8G.d.mts} +1 -1
  16. package/dist/{index-BNsSzMCj.d.ts → index-DmThy7vE.d.ts} +1 -1
  17. package/dist/index.css +109 -109
  18. package/dist/index.d.mts +155 -17
  19. package/dist/index.d.ts +155 -17
  20. package/dist/index.js +1080 -731
  21. package/dist/index.mjs +31 -15
  22. package/dist/internal.d.mts +2 -2
  23. package/dist/internal.d.ts +2 -2
  24. package/dist/{loaded-GLBLMTBL.mjs → loaded-BT7NIVEO.mjs} +3 -3
  25. package/dist/{loaded-O4QHGE26.mjs → loaded-HVOKDVC3.mjs} +3 -3
  26. package/dist/{loaded-R34BR6I5.mjs → loaded-YFYCF5F4.mjs} +3 -3
  27. package/dist/nextjs.d.mts +38 -0
  28. package/dist/nextjs.d.ts +38 -0
  29. package/dist/nextjs.js +65 -0
  30. package/dist/nextjs.mjs +30 -0
  31. package/dist/no-external.css +109 -109
  32. package/dist/no-external.d.mts +4 -4
  33. package/dist/no-external.d.ts +4 -4
  34. package/dist/no-external.js +1080 -731
  35. package/dist/no-external.mjs +31 -15
  36. package/dist/remix.d.mts +33 -0
  37. package/dist/remix.d.ts +33 -0
  38. package/dist/remix.js +65 -0
  39. package/dist/remix.mjs +30 -0
  40. package/dist/rsc.d.mts +2 -2
  41. package/dist/rsc.d.ts +2 -2
  42. package/dist/rsc.js +49 -0
  43. package/dist/rsc.mjs +6 -2
  44. package/dist/{walk-tree-C9GrSWsR.d.ts → walk-tree-5oDs6qOL.d.mts} +33 -2
  45. package/dist/{walk-tree-4C3ODO3X.d.mts → walk-tree-B1q6t5Jp.d.ts} +33 -2
  46. package/package.json +17 -6
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
- import { D as Data, o as Field, p as FieldProps, C as Config, U as UserGenerics, k as UiState, O as OnAction, f as Permissions, i as Plugin, j as Overrides, m as FieldTransforms, E as EditorAction, V as Viewports, I as IframeConfig, q as InitialHistory, M as Metadata, b as ComponentData, d as DefaultComponentProps, e as DefaultRootFieldProps, h as ResolveDataTrigger, r as ItemSelector, s as PluginInternal } from './actions-2L-1hQ7r.mjs';
2
- export { t as Adaptor, A as AppState, u as ArrayField, v as ArrayState, w as AsFieldProps, B as BaseData, x as BaseField, y as CacheOpts, z as ColorField, l as ComponentConfig, G as ComponentConfigExtensions, J as ComponentConfigParams, K as ComponentDataMap, L as ComponentDataOptionalId, N as ComponentMetadata, Q as ConfigParams, a as Content, S as CustomField, T as CustomFieldRender, c as DefaultComponents, X as DefaultRootProps, Y as DefaultRootRenderProps, Z as Direction, _ as DragAxis, $ as EditorComponent, a0 as EditorContext, a1 as EditorMetadata, a2 as ExternalField, a3 as ExternalFieldWithAdaptor, a4 as ExtractConfigParams, a5 as ExtractField, a6 as FieldMetadata, a7 as FieldRenderFunctions, a8 as FieldTransformFn, a9 as FieldTransformFnParams, F as Fields, H as History, aa as ItemWithId, ab as MappedItem, ac as NumberField, ad as ObjectField, ae as OverrideKey, af as RadioField, ag as RichText, n as RichtextField, ah as RootConfig, R as RootData, g as RootDataWithProps, ai as RootDataWithoutProps, aj as SelectField, ak as Slot, al as SlotComponent, am as SlotField, an as TextField, ao as TextareaField, ap as Viewport, aq as WithChildren, ar as WithEditorProps, W as WithId, as as WithSlotProps, at as overrideKeys } from './actions-2L-1hQ7r.mjs';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-4C3ODO3X.mjs';
1
+ import { D as Data, o as Field, p as FieldProps, C as Config, U as UserGenerics, O as OnAction, f as UiState, d as Plugin, e as Overrides, h as FieldTransforms, M as Metadata, I as IframeConfig, V as Viewports, a as Permissions, E as EditorAction, q as InitialHistory, b as ComponentData, l as DefaultComponentProps, m as DefaultRootFieldProps, c as ResolveDataTrigger, r as ItemSelector, s as PluginInternal } from './actions-C0LX6bI4.mjs';
2
+ export { t as Adaptor, A as AppState, u as ArrayField, v as ArrayState, w as AsFieldProps, B as BaseData, x as BaseField, y as CacheOpts, z as ColorField, g as ComponentConfig, G as ComponentConfigExtensions, J as ComponentConfigParams, K as ComponentDataMap, L as ComponentDataOptionalId, N as ComponentMetadata, Q as ConfigParams, j as Content, S as CustomField, T as CustomFieldRender, k as DefaultComponents, X as DefaultRootProps, Y as DefaultRootRenderProps, Z as Direction, _ as DragAxis, $ as EditorComponent, a0 as EditorContext, a1 as EditorMetadata, a2 as ExternalField, a3 as ExternalFieldWithAdaptor, a4 as ExtractConfigParams, a5 as ExtractField, a6 as FieldMetadata, a7 as FieldRenderFunctions, a8 as FieldTransformFn, a9 as FieldTransformFnParams, F as Fields, H as History, aa as ItemWithId, ab as MappedItem, ac as NumberField, ad as ObjectField, ae as OverrideKey, af as RadioField, ag as RichText, i as RichtextField, ah as RootConfig, n as RootData, R as RootDataWithProps, ai as RootDataWithoutProps, aj as SelectField, ak as Slot, al as SlotComponent, am as SlotField, an as TextField, ao as TextareaField, ap as Viewport, aq as WithChildren, ar as WithEditorProps, W as WithId, as as WithSlotProps, at as overrideKeys } from './actions-C0LX6bI4.mjs';
3
+ export { G as GetRoutePropsOptions, g as getRouteProps, m as migrate, r as resolveAllData, a as resolveRouteFromString, t as transformProps, w as walkTree } from './walk-tree-5oDs6qOL.mjs';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import * as react from 'react';
6
6
  import react__default, { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
7
- import { A as AppStore, G as GetPermissions, R as RefreshPermissions, H as HistorySlice } from './index-BXuSeNez.mjs';
7
+ import { A as AppStore, G as GetPermissions, R as RefreshPermissions, H as HistorySlice } from './index-DMbFEg8G.mjs';
8
8
  import '@tiptap/react';
9
9
  import '@tiptap/extension-blockquote';
10
10
  import '@tiptap/extension-bold';
@@ -30,17 +30,17 @@ import '@tiptap/extension-underline';
30
30
  type GlobalsMap = NonNullable<Data["globals"]>;
31
31
 
32
32
  /**
33
- * A concrete page destination surfaced in the editor's page switcher.
34
- * `path` is the stable identifier AND the URL; `title` is the display
35
- * label. Keep this type light full page content lives in separate
36
- * per-page data blobs owned by the consumer. When Editor eventually
37
- * introduces a richer `Page` type (data + metadata + path + title),
38
- * `Route` can stay as the summary / reference projection of it.
33
+ * A route key the literal string used as a `pages` key in `<App>` and
34
+ * the picker entry in `<Editor routes>`. The same string flows through:
35
+ * - `pages={{ [routeKey]: pageData }}` declares the schema
36
+ * - `<Editor routes={[routeKey, ...]}>` powers the page picker
37
+ * - `<Editor currentPath={routeKey}>` marks the selected page
38
+ * - `onPublish(data, routeKey)` returns it for persistence
39
+ *
40
+ * Patterns follow path-to-regexp v8 / Express 5 syntax: "/", "/about",
41
+ * "/products/:handle", "/docs/*splat".
39
42
  */
40
- type Route = {
41
- path: string;
42
- title: string;
43
- };
43
+ type Route = string;
44
44
 
45
45
  declare const ActionBar: {
46
46
  ({ label, children, }: {
@@ -91,6 +91,135 @@ declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<Value
91
91
  value: any;
92
92
  }): react_jsx_runtime.JSX.Element | null;
93
93
 
94
+ /** A route key — the literal pattern used in `pages`. */
95
+ type RouteKey = string;
96
+ type AppMatched<Data = unknown> = {
97
+ /** The route key string — stable persistence identifier. */
98
+ route: RouteKey;
99
+ /** Concrete params extracted from the URL (e.g. { handle: "abc" }). */
100
+ params: Readonly<Record<string, string | undefined>>;
101
+ /** The page's data. */
102
+ data: Data;
103
+ };
104
+ type AppConfigContext<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
105
+ config: UserConfig;
106
+ pages: Record<RouteKey, Partial<G["UserData"] | Data>>;
107
+ /** "/edit" by default; null disables editor mode entirely. */
108
+ editorPath: string | null;
109
+ };
110
+ declare const appConfigContext: react.Context<AppConfigContext<Config, UserGenerics<Config>> | null>;
111
+ type AppContextValue<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = AppConfigContext<UserConfig, G> & {
112
+ /** All page route keys, in declaration order. */
113
+ routes: RouteKey[];
114
+ /** Resolved current pathname from React Router. */
115
+ currentPath: string;
116
+ /** True when currentPath starts with editorPath. */
117
+ isEditing: boolean;
118
+ /** The URL relative to editorPath when isEditing — what pages are matched against. */
119
+ matchRoute: string;
120
+ /** Result of matching matchRoute against pages. Null = 404. */
121
+ matched: AppMatched<Partial<G["UserData"] | Data>> | null;
122
+ /** Navigate to a route key. Wraps with editorPath when editing. */
123
+ navigate: (route: RouteKey) => void;
124
+ };
125
+ /**
126
+ * Read the resolved route context. Combines config + pages + editorPath
127
+ * (from `<AppProvider>`) with the live location/navigation (from React Router).
128
+ */
129
+ declare const useApp: <UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>() => AppContextValue<UserConfig, G>;
130
+
131
+ /** Which RR router variant to use on the client. SSR always uses StaticRouter. */
132
+ type AppRouterVariant = "browser" | "hash" | "memory";
133
+ type AppProviderProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
134
+ config: UserConfig;
135
+ pages: Record<RouteKey, Partial<G["UserData"] | Data>>;
136
+ /** Defaults to "/editor". Pass null to disable editor mode. */
137
+ editorPath?: string | null;
138
+ /** Client-side router variant. Defaults to "browser". */
139
+ router?: AppRouterVariant;
140
+ /**
141
+ * Initial pathname for SSR (StaticRouter) or MemoryRouter.
142
+ * Required during SSR so the first paint matches the requested URL.
143
+ * Ignored for BrowserRouter and HashRouter on the client (they read window).
144
+ */
145
+ currentPath?: string;
146
+ children?: ReactNode;
147
+ };
148
+ declare function AppProvider<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, pages, editorPath, router, currentPath, children, }: AppProviderProps<UserConfig, G>): react_jsx_runtime.JSX.Element;
149
+
150
+ /** Editor pass-through props shared by <App> (default layout) and <App.Editor>. */
151
+ type EditorPassthroughProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
152
+ /** Called when the editor publishes. `route` is the schema route key. */
153
+ onPublish?: (data: G["UserData"], route?: string) => void;
154
+ onChange?: (data: G["UserData"]) => void;
155
+ onAction?: OnAction<G["UserData"]>;
156
+ ui?: Partial<UiState>;
157
+ plugins?: Plugin<UserConfig>[];
158
+ overrides?: Partial<Overrides<UserConfig>>;
159
+ fieldTransforms?: FieldTransforms<UserConfig>;
160
+ metadata?: Metadata;
161
+ iframe?: IframeConfig;
162
+ viewports?: Viewports;
163
+ permissions?: Partial<Permissions>;
164
+ renderHeader?: (props: {
165
+ children: ReactNode;
166
+ dispatch: (action: EditorAction) => void;
167
+ state: G["UserAppState"];
168
+ }) => ReactElement;
169
+ renderHeaderActions?: (props: {
170
+ state: G["UserAppState"];
171
+ dispatch: (action: EditorAction) => void;
172
+ }) => ReactElement;
173
+ title?: ReactNode;
174
+ dnd?: {
175
+ disableAutoScroll?: boolean;
176
+ };
177
+ initialHistory?: InitialHistory;
178
+ height?: CSSProperties["height"];
179
+ fullScreenCanvas?: boolean;
180
+ disableZoomControls?: boolean;
181
+ _experimentalVirtualization?: boolean;
182
+ };
183
+ type AppProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = AppProviderProps<UserConfig, G> & EditorPassthroughProps<UserConfig, G> & {
184
+ /** Optional custom not-found component — falls back to a built-in. */
185
+ renderNotFound?: () => ReactNode;
186
+ };
187
+ type AppRenderProps = {
188
+ metadata?: Metadata;
189
+ renderNotFound?: () => ReactNode;
190
+ };
191
+ /**
192
+ * Mounts <Render> for the current page when the URL is *not* under editorPath.
193
+ * Returns null while editing — safe to place anywhere inside <App>.
194
+ */
195
+ declare function AppRender<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ metadata, renderNotFound }: AppRenderProps): react_jsx_runtime.JSX.Element | null;
196
+ type AppEditorProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = EditorPassthroughProps<UserConfig, G> & {
197
+ children?: ReactNode;
198
+ renderNotFound?: () => ReactNode;
199
+ };
200
+ /**
201
+ * Mounts <Editor> for the current page when the URL is under editorPath.
202
+ * Returns null otherwise. Children are forwarded to <Editor> for compositional
203
+ * UI (e.g. <Editor.Preview />, <Editor.Fields />).
204
+ */
205
+ declare function AppEditor<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: AppEditorProps<UserConfig, G>): react_jsx_runtime.JSX.Element | null;
206
+ declare function App<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: AppProps<UserConfig, G>): react_jsx_runtime.JSX.Element;
207
+ declare namespace App {
208
+ var Render: typeof AppRender;
209
+ var Editor: typeof AppEditor;
210
+ }
211
+
212
+ /**
213
+ * Returns the schema-named params extracted from the current route.
214
+ *
215
+ * Designed for components rendered *inside* the schema (e.g. a ProductDetails
216
+ * block inside `pages["/products/:handle"]`) — they need `:handle` resolved
217
+ * by name. This is a typed re-export of React Router's `useParams()`.
218
+ *
219
+ * Returns `{}` when no page matched (404).
220
+ */
221
+ declare const useRouteParams: <P extends Record<string, string | undefined> = Record<string, string | undefined>>() => Readonly<P>;
222
+
94
223
  declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
95
224
  children: ReactNode;
96
225
  href?: string;
@@ -161,7 +290,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
161
290
  data: Partial<G["UserData"] | Data>;
162
291
  ui?: Partial<UiState>;
163
292
  onChange?: (data: G["UserData"]) => void;
164
- onPublish?: (data: G["UserData"]) => void;
293
+ onPublish?: (data: G["UserData"], route?: string) => void;
165
294
  onAction?: OnAction<G["UserData"]>;
166
295
  permissions?: Partial<Permissions>;
167
296
  plugins?: Plugin<UserConfig>[];
@@ -180,7 +309,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
180
309
  headerPath?: string;
181
310
  title?: ReactNode;
182
311
  routes?: Route[];
183
- currentPath?: string;
312
+ currentRoute?: string;
184
313
  onRouteChange?: (path: string) => void | Promise<void>;
185
314
  viewports?: Viewports;
186
315
  iframe?: IframeConfig;
@@ -284,6 +413,15 @@ declare const RichTextMenu: {
284
413
  Underline: typeof Underline;
285
414
  };
286
415
 
416
+ /**
417
+ * Returns a structurally-stable reference. Updates only when `value` deep-changes,
418
+ * so referentially-fresh-but-content-equal objects don't re-trigger downstream memos.
419
+ *
420
+ * Used inside `<AppProvider>` so that users passing inline `pages={{ ... }}` don't
421
+ * re-compile the route table on every parent render.
422
+ */
423
+ declare const useStableValue: <T>(value: T) => T;
424
+
287
425
  /**
288
426
  * Framework-agnostic SEO output shape. Mirrors the subset of Next.js's
289
427
  * Metadata type that most page builders care about — title, description,
@@ -413,4 +551,4 @@ declare const outlinePlugin: () => Plugin;
413
551
 
414
552
  declare const legacySideBarPlugin: () => Plugin;
415
553
 
416
- export { Action, ActionBar, AutoField, Button, ComponentData, ComponentList, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, Editor, EditorAction, type EditorApi, type EditorCommands, Field, FieldLabel, FieldProps, FieldTransforms, type GlobalsMap, Group, IconButton, IframeConfig, InitialHistory, type InsertComponentArgs, Label, Metadata, type MoveDestination, OnAction, Overrides, type PageMetadata, type Parent, Permissions, Plugin, Render, ResolveDataTrigger, RichTextMenu, type Route, Separator, UiState, type UseEditorData, UserGenerics, Viewports, blocksPlugin, createUseEditor, fieldsPlugin, legacySideBarPlugin, outlinePlugin, pageMetadata, registerOverlayPortal, renderContext, setDeep, useEditor, useGetEditor, usePropsContext };
554
+ export { Action, ActionBar, App, type AppContextValue, type AppEditorProps, type AppMatched, type AppProps, AppProvider, type AppProviderProps, type AppRenderProps, type AppRouterVariant, AutoField, Button, ComponentData, ComponentList, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, Editor, EditorAction, type EditorApi, type EditorCommands, Field, FieldLabel, FieldProps, FieldTransforms, type GlobalsMap, Group, IconButton, IframeConfig, InitialHistory, type InsertComponentArgs, Label, Metadata, type MoveDestination, OnAction, Overrides, type PageMetadata, type Parent, Permissions, Plugin, Render, ResolveDataTrigger, RichTextMenu, type Route, type RouteKey, Separator, UiState, type UseEditorData, UserGenerics, Viewports, appConfigContext, blocksPlugin, createUseEditor, fieldsPlugin, legacySideBarPlugin, outlinePlugin, pageMetadata, registerOverlayPortal, renderContext, setDeep, useApp, useEditor, useGetEditor, usePropsContext, useRouteParams, useStableValue };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { D as Data, o as Field, p as FieldProps, C as Config, U as UserGenerics, k as UiState, O as OnAction, f as Permissions, i as Plugin, j as Overrides, m as FieldTransforms, E as EditorAction, V as Viewports, I as IframeConfig, q as InitialHistory, M as Metadata, b as ComponentData, d as DefaultComponentProps, e as DefaultRootFieldProps, h as ResolveDataTrigger, r as ItemSelector, s as PluginInternal } from './actions-2L-1hQ7r.js';
2
- export { t as Adaptor, A as AppState, u as ArrayField, v as ArrayState, w as AsFieldProps, B as BaseData, x as BaseField, y as CacheOpts, z as ColorField, l as ComponentConfig, G as ComponentConfigExtensions, J as ComponentConfigParams, K as ComponentDataMap, L as ComponentDataOptionalId, N as ComponentMetadata, Q as ConfigParams, a as Content, S as CustomField, T as CustomFieldRender, c as DefaultComponents, X as DefaultRootProps, Y as DefaultRootRenderProps, Z as Direction, _ as DragAxis, $ as EditorComponent, a0 as EditorContext, a1 as EditorMetadata, a2 as ExternalField, a3 as ExternalFieldWithAdaptor, a4 as ExtractConfigParams, a5 as ExtractField, a6 as FieldMetadata, a7 as FieldRenderFunctions, a8 as FieldTransformFn, a9 as FieldTransformFnParams, F as Fields, H as History, aa as ItemWithId, ab as MappedItem, ac as NumberField, ad as ObjectField, ae as OverrideKey, af as RadioField, ag as RichText, n as RichtextField, ah as RootConfig, R as RootData, g as RootDataWithProps, ai as RootDataWithoutProps, aj as SelectField, ak as Slot, al as SlotComponent, am as SlotField, an as TextField, ao as TextareaField, ap as Viewport, aq as WithChildren, ar as WithEditorProps, W as WithId, as as WithSlotProps, at as overrideKeys } from './actions-2L-1hQ7r.js';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-C9GrSWsR.js';
1
+ import { D as Data, o as Field, p as FieldProps, C as Config, U as UserGenerics, O as OnAction, f as UiState, d as Plugin, e as Overrides, h as FieldTransforms, M as Metadata, I as IframeConfig, V as Viewports, a as Permissions, E as EditorAction, q as InitialHistory, b as ComponentData, l as DefaultComponentProps, m as DefaultRootFieldProps, c as ResolveDataTrigger, r as ItemSelector, s as PluginInternal } from './actions-C0LX6bI4.js';
2
+ export { t as Adaptor, A as AppState, u as ArrayField, v as ArrayState, w as AsFieldProps, B as BaseData, x as BaseField, y as CacheOpts, z as ColorField, g as ComponentConfig, G as ComponentConfigExtensions, J as ComponentConfigParams, K as ComponentDataMap, L as ComponentDataOptionalId, N as ComponentMetadata, Q as ConfigParams, j as Content, S as CustomField, T as CustomFieldRender, k as DefaultComponents, X as DefaultRootProps, Y as DefaultRootRenderProps, Z as Direction, _ as DragAxis, $ as EditorComponent, a0 as EditorContext, a1 as EditorMetadata, a2 as ExternalField, a3 as ExternalFieldWithAdaptor, a4 as ExtractConfigParams, a5 as ExtractField, a6 as FieldMetadata, a7 as FieldRenderFunctions, a8 as FieldTransformFn, a9 as FieldTransformFnParams, F as Fields, H as History, aa as ItemWithId, ab as MappedItem, ac as NumberField, ad as ObjectField, ae as OverrideKey, af as RadioField, ag as RichText, i as RichtextField, ah as RootConfig, n as RootData, R as RootDataWithProps, ai as RootDataWithoutProps, aj as SelectField, ak as Slot, al as SlotComponent, am as SlotField, an as TextField, ao as TextareaField, ap as Viewport, aq as WithChildren, ar as WithEditorProps, W as WithId, as as WithSlotProps, at as overrideKeys } from './actions-C0LX6bI4.js';
3
+ export { G as GetRoutePropsOptions, g as getRouteProps, m as migrate, r as resolveAllData, a as resolveRouteFromString, t as transformProps, w as walkTree } from './walk-tree-B1q6t5Jp.js';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import * as react from 'react';
6
6
  import react__default, { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
7
- import { A as AppStore, G as GetPermissions, R as RefreshPermissions, H as HistorySlice } from './index-BNsSzMCj.js';
7
+ import { A as AppStore, G as GetPermissions, R as RefreshPermissions, H as HistorySlice } from './index-DmThy7vE.js';
8
8
  import '@tiptap/react';
9
9
  import '@tiptap/extension-blockquote';
10
10
  import '@tiptap/extension-bold';
@@ -30,17 +30,17 @@ import '@tiptap/extension-underline';
30
30
  type GlobalsMap = NonNullable<Data["globals"]>;
31
31
 
32
32
  /**
33
- * A concrete page destination surfaced in the editor's page switcher.
34
- * `path` is the stable identifier AND the URL; `title` is the display
35
- * label. Keep this type light full page content lives in separate
36
- * per-page data blobs owned by the consumer. When Editor eventually
37
- * introduces a richer `Page` type (data + metadata + path + title),
38
- * `Route` can stay as the summary / reference projection of it.
33
+ * A route key the literal string used as a `pages` key in `<App>` and
34
+ * the picker entry in `<Editor routes>`. The same string flows through:
35
+ * - `pages={{ [routeKey]: pageData }}` declares the schema
36
+ * - `<Editor routes={[routeKey, ...]}>` powers the page picker
37
+ * - `<Editor currentPath={routeKey}>` marks the selected page
38
+ * - `onPublish(data, routeKey)` returns it for persistence
39
+ *
40
+ * Patterns follow path-to-regexp v8 / Express 5 syntax: "/", "/about",
41
+ * "/products/:handle", "/docs/*splat".
39
42
  */
40
- type Route = {
41
- path: string;
42
- title: string;
43
- };
43
+ type Route = string;
44
44
 
45
45
  declare const ActionBar: {
46
46
  ({ label, children, }: {
@@ -91,6 +91,135 @@ declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<Value
91
91
  value: any;
92
92
  }): react_jsx_runtime.JSX.Element | null;
93
93
 
94
+ /** A route key — the literal pattern used in `pages`. */
95
+ type RouteKey = string;
96
+ type AppMatched<Data = unknown> = {
97
+ /** The route key string — stable persistence identifier. */
98
+ route: RouteKey;
99
+ /** Concrete params extracted from the URL (e.g. { handle: "abc" }). */
100
+ params: Readonly<Record<string, string | undefined>>;
101
+ /** The page's data. */
102
+ data: Data;
103
+ };
104
+ type AppConfigContext<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
105
+ config: UserConfig;
106
+ pages: Record<RouteKey, Partial<G["UserData"] | Data>>;
107
+ /** "/edit" by default; null disables editor mode entirely. */
108
+ editorPath: string | null;
109
+ };
110
+ declare const appConfigContext: react.Context<AppConfigContext<Config, UserGenerics<Config>> | null>;
111
+ type AppContextValue<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = AppConfigContext<UserConfig, G> & {
112
+ /** All page route keys, in declaration order. */
113
+ routes: RouteKey[];
114
+ /** Resolved current pathname from React Router. */
115
+ currentPath: string;
116
+ /** True when currentPath starts with editorPath. */
117
+ isEditing: boolean;
118
+ /** The URL relative to editorPath when isEditing — what pages are matched against. */
119
+ matchRoute: string;
120
+ /** Result of matching matchRoute against pages. Null = 404. */
121
+ matched: AppMatched<Partial<G["UserData"] | Data>> | null;
122
+ /** Navigate to a route key. Wraps with editorPath when editing. */
123
+ navigate: (route: RouteKey) => void;
124
+ };
125
+ /**
126
+ * Read the resolved route context. Combines config + pages + editorPath
127
+ * (from `<AppProvider>`) with the live location/navigation (from React Router).
128
+ */
129
+ declare const useApp: <UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>() => AppContextValue<UserConfig, G>;
130
+
131
+ /** Which RR router variant to use on the client. SSR always uses StaticRouter. */
132
+ type AppRouterVariant = "browser" | "hash" | "memory";
133
+ type AppProviderProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
134
+ config: UserConfig;
135
+ pages: Record<RouteKey, Partial<G["UserData"] | Data>>;
136
+ /** Defaults to "/editor". Pass null to disable editor mode. */
137
+ editorPath?: string | null;
138
+ /** Client-side router variant. Defaults to "browser". */
139
+ router?: AppRouterVariant;
140
+ /**
141
+ * Initial pathname for SSR (StaticRouter) or MemoryRouter.
142
+ * Required during SSR so the first paint matches the requested URL.
143
+ * Ignored for BrowserRouter and HashRouter on the client (they read window).
144
+ */
145
+ currentPath?: string;
146
+ children?: ReactNode;
147
+ };
148
+ declare function AppProvider<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, pages, editorPath, router, currentPath, children, }: AppProviderProps<UserConfig, G>): react_jsx_runtime.JSX.Element;
149
+
150
+ /** Editor pass-through props shared by <App> (default layout) and <App.Editor>. */
151
+ type EditorPassthroughProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
152
+ /** Called when the editor publishes. `route` is the schema route key. */
153
+ onPublish?: (data: G["UserData"], route?: string) => void;
154
+ onChange?: (data: G["UserData"]) => void;
155
+ onAction?: OnAction<G["UserData"]>;
156
+ ui?: Partial<UiState>;
157
+ plugins?: Plugin<UserConfig>[];
158
+ overrides?: Partial<Overrides<UserConfig>>;
159
+ fieldTransforms?: FieldTransforms<UserConfig>;
160
+ metadata?: Metadata;
161
+ iframe?: IframeConfig;
162
+ viewports?: Viewports;
163
+ permissions?: Partial<Permissions>;
164
+ renderHeader?: (props: {
165
+ children: ReactNode;
166
+ dispatch: (action: EditorAction) => void;
167
+ state: G["UserAppState"];
168
+ }) => ReactElement;
169
+ renderHeaderActions?: (props: {
170
+ state: G["UserAppState"];
171
+ dispatch: (action: EditorAction) => void;
172
+ }) => ReactElement;
173
+ title?: ReactNode;
174
+ dnd?: {
175
+ disableAutoScroll?: boolean;
176
+ };
177
+ initialHistory?: InitialHistory;
178
+ height?: CSSProperties["height"];
179
+ fullScreenCanvas?: boolean;
180
+ disableZoomControls?: boolean;
181
+ _experimentalVirtualization?: boolean;
182
+ };
183
+ type AppProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = AppProviderProps<UserConfig, G> & EditorPassthroughProps<UserConfig, G> & {
184
+ /** Optional custom not-found component — falls back to a built-in. */
185
+ renderNotFound?: () => ReactNode;
186
+ };
187
+ type AppRenderProps = {
188
+ metadata?: Metadata;
189
+ renderNotFound?: () => ReactNode;
190
+ };
191
+ /**
192
+ * Mounts <Render> for the current page when the URL is *not* under editorPath.
193
+ * Returns null while editing — safe to place anywhere inside <App>.
194
+ */
195
+ declare function AppRender<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ metadata, renderNotFound }: AppRenderProps): react_jsx_runtime.JSX.Element | null;
196
+ type AppEditorProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = EditorPassthroughProps<UserConfig, G> & {
197
+ children?: ReactNode;
198
+ renderNotFound?: () => ReactNode;
199
+ };
200
+ /**
201
+ * Mounts <Editor> for the current page when the URL is under editorPath.
202
+ * Returns null otherwise. Children are forwarded to <Editor> for compositional
203
+ * UI (e.g. <Editor.Preview />, <Editor.Fields />).
204
+ */
205
+ declare function AppEditor<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: AppEditorProps<UserConfig, G>): react_jsx_runtime.JSX.Element | null;
206
+ declare function App<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: AppProps<UserConfig, G>): react_jsx_runtime.JSX.Element;
207
+ declare namespace App {
208
+ var Render: typeof AppRender;
209
+ var Editor: typeof AppEditor;
210
+ }
211
+
212
+ /**
213
+ * Returns the schema-named params extracted from the current route.
214
+ *
215
+ * Designed for components rendered *inside* the schema (e.g. a ProductDetails
216
+ * block inside `pages["/products/:handle"]`) — they need `:handle` resolved
217
+ * by name. This is a typed re-export of React Router's `useParams()`.
218
+ *
219
+ * Returns `{}` when no page matched (404).
220
+ */
221
+ declare const useRouteParams: <P extends Record<string, string | undefined> = Record<string, string | undefined>>() => Readonly<P>;
222
+
94
223
  declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
95
224
  children: ReactNode;
96
225
  href?: string;
@@ -161,7 +290,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
161
290
  data: Partial<G["UserData"] | Data>;
162
291
  ui?: Partial<UiState>;
163
292
  onChange?: (data: G["UserData"]) => void;
164
- onPublish?: (data: G["UserData"]) => void;
293
+ onPublish?: (data: G["UserData"], route?: string) => void;
165
294
  onAction?: OnAction<G["UserData"]>;
166
295
  permissions?: Partial<Permissions>;
167
296
  plugins?: Plugin<UserConfig>[];
@@ -180,7 +309,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
180
309
  headerPath?: string;
181
310
  title?: ReactNode;
182
311
  routes?: Route[];
183
- currentPath?: string;
312
+ currentRoute?: string;
184
313
  onRouteChange?: (path: string) => void | Promise<void>;
185
314
  viewports?: Viewports;
186
315
  iframe?: IframeConfig;
@@ -284,6 +413,15 @@ declare const RichTextMenu: {
284
413
  Underline: typeof Underline;
285
414
  };
286
415
 
416
+ /**
417
+ * Returns a structurally-stable reference. Updates only when `value` deep-changes,
418
+ * so referentially-fresh-but-content-equal objects don't re-trigger downstream memos.
419
+ *
420
+ * Used inside `<AppProvider>` so that users passing inline `pages={{ ... }}` don't
421
+ * re-compile the route table on every parent render.
422
+ */
423
+ declare const useStableValue: <T>(value: T) => T;
424
+
287
425
  /**
288
426
  * Framework-agnostic SEO output shape. Mirrors the subset of Next.js's
289
427
  * Metadata type that most page builders care about — title, description,
@@ -413,4 +551,4 @@ declare const outlinePlugin: () => Plugin;
413
551
 
414
552
  declare const legacySideBarPlugin: () => Plugin;
415
553
 
416
- export { Action, ActionBar, AutoField, Button, ComponentData, ComponentList, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, Editor, EditorAction, type EditorApi, type EditorCommands, Field, FieldLabel, FieldProps, FieldTransforms, type GlobalsMap, Group, IconButton, IframeConfig, InitialHistory, type InsertComponentArgs, Label, Metadata, type MoveDestination, OnAction, Overrides, type PageMetadata, type Parent, Permissions, Plugin, Render, ResolveDataTrigger, RichTextMenu, type Route, Separator, UiState, type UseEditorData, UserGenerics, Viewports, blocksPlugin, createUseEditor, fieldsPlugin, legacySideBarPlugin, outlinePlugin, pageMetadata, registerOverlayPortal, renderContext, setDeep, useEditor, useGetEditor, usePropsContext };
554
+ export { Action, ActionBar, App, type AppContextValue, type AppEditorProps, type AppMatched, type AppProps, AppProvider, type AppProviderProps, type AppRenderProps, type AppRouterVariant, AutoField, Button, ComponentData, ComponentList, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, Editor, EditorAction, type EditorApi, type EditorCommands, Field, FieldLabel, FieldProps, FieldTransforms, type GlobalsMap, Group, IconButton, IframeConfig, InitialHistory, type InsertComponentArgs, Label, Metadata, type MoveDestination, OnAction, Overrides, type PageMetadata, type Parent, Permissions, Plugin, Render, ResolveDataTrigger, RichTextMenu, type Route, type RouteKey, Separator, UiState, type UseEditorData, UserGenerics, Viewports, appConfigContext, blocksPlugin, createUseEditor, fieldsPlugin, legacySideBarPlugin, outlinePlugin, pageMetadata, registerOverlayPortal, renderContext, setDeep, useApp, useEditor, useGetEditor, usePropsContext, useRouteParams, useStableValue };