@reacteditor/core 0.0.9 → 0.0.10

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 (37) hide show
  1. package/dist/{Editor-KXEVJBNG.mjs → Editor-3COFH5WN.mjs} +3 -3
  2. package/dist/{actions-2L-1hQ7r.d.mts → actions-B8_EA7vy.d.mts} +1 -1
  3. package/dist/{actions-2L-1hQ7r.d.ts → actions-B8_EA7vy.d.ts} +1 -1
  4. package/dist/{chunk-DU757QEH.mjs → chunk-3IP22OOD.mjs} +307 -33
  5. package/dist/{chunk-AJWRDM22.mjs → chunk-BZ4BQZJR.mjs} +4 -4
  6. package/dist/{chunk-TI3KC54Y.mjs → chunk-PUDWMFBH.mjs} +46 -0
  7. package/dist/{full-ZFZZ626B.mjs → full-QT5KXRDP.mjs} +2 -2
  8. package/dist/{index-BNsSzMCj.d.ts → index-BrHy0cc_.d.ts} +1 -1
  9. package/dist/{index-BXuSeNez.d.mts → index-JoD48fK_.d.mts} +1 -1
  10. package/dist/index.css +84 -84
  11. package/dist/index.d.mts +110 -17
  12. package/dist/index.d.ts +110 -17
  13. package/dist/index.js +990 -663
  14. package/dist/index.mjs +27 -11
  15. package/dist/internal.d.mts +2 -2
  16. package/dist/internal.d.ts +2 -2
  17. package/dist/nextjs.d.mts +38 -0
  18. package/dist/nextjs.d.ts +38 -0
  19. package/dist/nextjs.js +65 -0
  20. package/dist/nextjs.mjs +30 -0
  21. package/dist/no-external.css +84 -84
  22. package/dist/no-external.d.mts +4 -4
  23. package/dist/no-external.d.ts +4 -4
  24. package/dist/no-external.js +990 -663
  25. package/dist/no-external.mjs +27 -11
  26. package/dist/remix.d.mts +33 -0
  27. package/dist/remix.d.ts +33 -0
  28. package/dist/remix.js +65 -0
  29. package/dist/remix.mjs +30 -0
  30. package/dist/rsc.d.mts +2 -2
  31. package/dist/rsc.d.ts +2 -2
  32. package/dist/rsc.js +48 -0
  33. package/dist/rsc.mjs +5 -1
  34. package/dist/{walk-tree-4C3ODO3X.d.mts → walk-tree-BR2XIZ0W.d.mts} +33 -2
  35. package/dist/{walk-tree-C9GrSWsR.d.ts → walk-tree-DpUJ9kDx.d.ts} +33 -2
  36. package/package.json +14 -3
  37. package/dist/{chunk-U7VW3V3W.mjs → chunk-BUR5T7IX.mjs} +3 -3
package/dist/index.css CHANGED
@@ -1686,6 +1686,90 @@ textarea._Input-input_zwh6e_27 {
1686
1686
  padding: 14px 12px;
1687
1687
  }
1688
1688
 
1689
+ /* css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Fields/styles.module.css/#css-module-data */
1690
+ ._EditorFields_3dnua_1 {
1691
+ position: relative;
1692
+ font-family: var(--editor-font-family);
1693
+ }
1694
+ ._EditorFields--isLoading_3dnua_6 {
1695
+ min-height: 48px;
1696
+ }
1697
+ ._EditorFields-loadingOverlay_3dnua_10 {
1698
+ background: var(--editor-surface-panel);
1699
+ display: flex;
1700
+ justify-content: flex-end;
1701
+ align-items: flex-start;
1702
+ height: 100%;
1703
+ width: 100%;
1704
+ top: 0px;
1705
+ position: absolute;
1706
+ z-index: 1;
1707
+ pointer-events: all;
1708
+ box-sizing: border-box;
1709
+ opacity: 0.8;
1710
+ }
1711
+ ._EditorFields-loadingOverlayInner_3dnua_25 {
1712
+ display: flex;
1713
+ padding: 16px;
1714
+ position: sticky;
1715
+ top: 0;
1716
+ }
1717
+ ._EditorFields-field_3dnua_32 * {
1718
+ box-sizing: border-box;
1719
+ }
1720
+ ._EditorFields--wrapFields_3dnua_36 ._EditorFields-field_3dnua_32 {
1721
+ color: var(--editor-text-secondary);
1722
+ padding: 14px 16px;
1723
+ display: block;
1724
+ }
1725
+ ._EditorFields--wrapFields_3dnua_36 ._EditorFields-field_3dnua_32 + ._EditorFields-field_3dnua_32 {
1726
+ border-top: 1px solid var(--editor-border-subtle);
1727
+ }
1728
+ ._EditorFields-syncButton_3dnua_46 {
1729
+ align-items: center;
1730
+ background: transparent;
1731
+ border: 1px solid var(--editor-color-global);
1732
+ border-radius: var(--editor-radius-md);
1733
+ color: var(--editor-color-global);
1734
+ cursor: pointer;
1735
+ display: flex;
1736
+ font: inherit;
1737
+ font-size: var(--editor-font-size-xxs);
1738
+ font-weight: 500;
1739
+ gap: 8px;
1740
+ justify-content: center;
1741
+ margin: 12px 16px;
1742
+ padding: 10px;
1743
+ transition:
1744
+ background-color var(--editor-motion-fast) var(--editor-ease),
1745
+ border-color var(--editor-motion-fast) var(--editor-ease),
1746
+ color var(--editor-motion-fast) var(--editor-ease);
1747
+ width: calc(100% - 32px);
1748
+ }
1749
+ @media (hover: hover) and (pointer: fine) {
1750
+ ._EditorFields-syncButton_3dnua_46:hover {
1751
+ background: var(--editor-color-global-soft);
1752
+ }
1753
+ }
1754
+ ._EditorFields-syncButton_3dnua_46:focus-visible {
1755
+ outline: none;
1756
+ box-shadow: var(--editor-ring);
1757
+ }
1758
+ ._EditorFields-syncButton--unlinked_3dnua_78 {
1759
+ border-color: var(--editor-border-default);
1760
+ color: var(--editor-text-secondary);
1761
+ }
1762
+ @media (hover: hover) and (pointer: fine) {
1763
+ ._EditorFields-syncButton--unlinked_3dnua_78:hover {
1764
+ background: var(--editor-surface-hover);
1765
+ border-color: var(--editor-border-strong);
1766
+ color: var(--editor-text-primary);
1767
+ }
1768
+ }
1769
+ ._EditorFields--wrapFields_3dnua_36 ._EditorFields-syncButton_3dnua_46 + ._EditorFields-field_3dnua_32 {
1770
+ border-top: none;
1771
+ }
1772
+
1689
1773
  /* css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/ComponentList/styles.module.css/#css-module-data */
1690
1774
  ._ComponentList_1mlcu_1 {
1691
1775
  max-width: 100%;
@@ -2051,90 +2135,6 @@ body:has(._DropZone--isAnimating_1h108_70:empty) [data-editor-overlay] {
2051
2135
  display: none;
2052
2136
  }
2053
2137
 
2054
- /* css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Fields/styles.module.css/#css-module-data */
2055
- ._EditorFields_3dnua_1 {
2056
- position: relative;
2057
- font-family: var(--editor-font-family);
2058
- }
2059
- ._EditorFields--isLoading_3dnua_6 {
2060
- min-height: 48px;
2061
- }
2062
- ._EditorFields-loadingOverlay_3dnua_10 {
2063
- background: var(--editor-surface-panel);
2064
- display: flex;
2065
- justify-content: flex-end;
2066
- align-items: flex-start;
2067
- height: 100%;
2068
- width: 100%;
2069
- top: 0px;
2070
- position: absolute;
2071
- z-index: 1;
2072
- pointer-events: all;
2073
- box-sizing: border-box;
2074
- opacity: 0.8;
2075
- }
2076
- ._EditorFields-loadingOverlayInner_3dnua_25 {
2077
- display: flex;
2078
- padding: 16px;
2079
- position: sticky;
2080
- top: 0;
2081
- }
2082
- ._EditorFields-field_3dnua_32 * {
2083
- box-sizing: border-box;
2084
- }
2085
- ._EditorFields--wrapFields_3dnua_36 ._EditorFields-field_3dnua_32 {
2086
- color: var(--editor-text-secondary);
2087
- padding: 14px 16px;
2088
- display: block;
2089
- }
2090
- ._EditorFields--wrapFields_3dnua_36 ._EditorFields-field_3dnua_32 + ._EditorFields-field_3dnua_32 {
2091
- border-top: 1px solid var(--editor-border-subtle);
2092
- }
2093
- ._EditorFields-syncButton_3dnua_46 {
2094
- align-items: center;
2095
- background: transparent;
2096
- border: 1px solid var(--editor-color-global);
2097
- border-radius: var(--editor-radius-md);
2098
- color: var(--editor-color-global);
2099
- cursor: pointer;
2100
- display: flex;
2101
- font: inherit;
2102
- font-size: var(--editor-font-size-xxs);
2103
- font-weight: 500;
2104
- gap: 8px;
2105
- justify-content: center;
2106
- margin: 12px 16px;
2107
- padding: 10px;
2108
- transition:
2109
- background-color var(--editor-motion-fast) var(--editor-ease),
2110
- border-color var(--editor-motion-fast) var(--editor-ease),
2111
- color var(--editor-motion-fast) var(--editor-ease);
2112
- width: calc(100% - 32px);
2113
- }
2114
- @media (hover: hover) and (pointer: fine) {
2115
- ._EditorFields-syncButton_3dnua_46:hover {
2116
- background: var(--editor-color-global-soft);
2117
- }
2118
- }
2119
- ._EditorFields-syncButton_3dnua_46:focus-visible {
2120
- outline: none;
2121
- box-shadow: var(--editor-ring);
2122
- }
2123
- ._EditorFields-syncButton--unlinked_3dnua_78 {
2124
- border-color: var(--editor-border-default);
2125
- color: var(--editor-text-secondary);
2126
- }
2127
- @media (hover: hover) and (pointer: fine) {
2128
- ._EditorFields-syncButton--unlinked_3dnua_78:hover {
2129
- background: var(--editor-surface-hover);
2130
- border-color: var(--editor-border-strong);
2131
- color: var(--editor-text-primary);
2132
- }
2133
- }
2134
- ._EditorFields--wrapFields_3dnua_36 ._EditorFields-syncButton_3dnua_46 + ._EditorFields-field_3dnua_32 {
2135
- border-top: none;
2136
- }
2137
-
2138
2138
  /* css-module:/Users/rami/Documents/apps/react-editor/packages/core/components/Editor/components/Components/styles.module.css/#css-module-data */
2139
2139
  ._Components-search_recer_1 {
2140
2140
  position: relative;
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, d as Plugin, e as Overrides, h as FieldTransforms, M as Metadata, I as IframeConfig, V as Viewports, a as Permissions, f as UiState, O as OnAction, 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-B8_EA7vy.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-B8_EA7vy.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-BR2XIZ0W.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-JoD48fK_.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,90 @@ 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
+ type AppProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = AppProviderProps<UserConfig, G> & {
151
+ /** Called when the editor publishes. `route` is the schema route key. */
152
+ onPublish?: (data: G["UserData"], route?: string) => void;
153
+ onChange?: (data: G["UserData"]) => void;
154
+ /** Pass-through Editor configuration. */
155
+ plugins?: Plugin<UserConfig>[];
156
+ overrides?: Partial<Overrides<UserConfig>>;
157
+ fieldTransforms?: FieldTransforms<UserConfig>;
158
+ metadata?: Metadata;
159
+ iframe?: IframeConfig;
160
+ viewports?: Viewports;
161
+ permissions?: Partial<Permissions>;
162
+ /** Optional custom not-found component — falls back to a built-in. */
163
+ renderNotFound?: () => ReactNode;
164
+ };
165
+ declare function App<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: AppProps<UserConfig, G>): react_jsx_runtime.JSX.Element;
166
+
167
+ /**
168
+ * Returns the schema-named params extracted from the current route.
169
+ *
170
+ * Designed for components rendered *inside* the schema (e.g. a ProductDetails
171
+ * block inside `pages["/products/:handle"]`) — they need `:handle` resolved
172
+ * by name. This is a typed re-export of React Router's `useParams()`.
173
+ *
174
+ * Returns `{}` when no page matched (404).
175
+ */
176
+ declare const useRouteParams: <P extends Record<string, string | undefined> = Record<string, string | undefined>>() => Readonly<P>;
177
+
94
178
  declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
95
179
  children: ReactNode;
96
180
  href?: string;
@@ -161,7 +245,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
161
245
  data: Partial<G["UserData"] | Data>;
162
246
  ui?: Partial<UiState>;
163
247
  onChange?: (data: G["UserData"]) => void;
164
- onPublish?: (data: G["UserData"]) => void;
248
+ onPublish?: (data: G["UserData"], route?: string) => void;
165
249
  onAction?: OnAction<G["UserData"]>;
166
250
  permissions?: Partial<Permissions>;
167
251
  plugins?: Plugin<UserConfig>[];
@@ -180,7 +264,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
180
264
  headerPath?: string;
181
265
  title?: ReactNode;
182
266
  routes?: Route[];
183
- currentPath?: string;
267
+ currentRoute?: string;
184
268
  onRouteChange?: (path: string) => void | Promise<void>;
185
269
  viewports?: Viewports;
186
270
  iframe?: IframeConfig;
@@ -284,6 +368,15 @@ declare const RichTextMenu: {
284
368
  Underline: typeof Underline;
285
369
  };
286
370
 
371
+ /**
372
+ * Returns a structurally-stable reference. Updates only when `value` deep-changes,
373
+ * so referentially-fresh-but-content-equal objects don't re-trigger downstream memos.
374
+ *
375
+ * Used inside `<AppProvider>` so that users passing inline `pages={{ ... }}` don't
376
+ * re-compile the route table on every parent render.
377
+ */
378
+ declare const useStableValue: <T>(value: T) => T;
379
+
287
380
  /**
288
381
  * Framework-agnostic SEO output shape. Mirrors the subset of Next.js's
289
382
  * Metadata type that most page builders care about — title, description,
@@ -413,4 +506,4 @@ declare const outlinePlugin: () => Plugin;
413
506
 
414
507
  declare const legacySideBarPlugin: () => Plugin;
415
508
 
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 };
509
+ export { Action, ActionBar, App, type AppContextValue, type AppMatched, type AppProps, AppProvider, type AppProviderProps, 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, d as Plugin, e as Overrides, h as FieldTransforms, M as Metadata, I as IframeConfig, V as Viewports, a as Permissions, f as UiState, O as OnAction, 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-B8_EA7vy.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-B8_EA7vy.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-DpUJ9kDx.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-BrHy0cc_.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,90 @@ 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
+ type AppProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = AppProviderProps<UserConfig, G> & {
151
+ /** Called when the editor publishes. `route` is the schema route key. */
152
+ onPublish?: (data: G["UserData"], route?: string) => void;
153
+ onChange?: (data: G["UserData"]) => void;
154
+ /** Pass-through Editor configuration. */
155
+ plugins?: Plugin<UserConfig>[];
156
+ overrides?: Partial<Overrides<UserConfig>>;
157
+ fieldTransforms?: FieldTransforms<UserConfig>;
158
+ metadata?: Metadata;
159
+ iframe?: IframeConfig;
160
+ viewports?: Viewports;
161
+ permissions?: Partial<Permissions>;
162
+ /** Optional custom not-found component — falls back to a built-in. */
163
+ renderNotFound?: () => ReactNode;
164
+ };
165
+ declare function App<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: AppProps<UserConfig, G>): react_jsx_runtime.JSX.Element;
166
+
167
+ /**
168
+ * Returns the schema-named params extracted from the current route.
169
+ *
170
+ * Designed for components rendered *inside* the schema (e.g. a ProductDetails
171
+ * block inside `pages["/products/:handle"]`) — they need `:handle` resolved
172
+ * by name. This is a typed re-export of React Router's `useParams()`.
173
+ *
174
+ * Returns `{}` when no page matched (404).
175
+ */
176
+ declare const useRouteParams: <P extends Record<string, string | undefined> = Record<string, string | undefined>>() => Readonly<P>;
177
+
94
178
  declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
95
179
  children: ReactNode;
96
180
  href?: string;
@@ -161,7 +245,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
161
245
  data: Partial<G["UserData"] | Data>;
162
246
  ui?: Partial<UiState>;
163
247
  onChange?: (data: G["UserData"]) => void;
164
- onPublish?: (data: G["UserData"]) => void;
248
+ onPublish?: (data: G["UserData"], route?: string) => void;
165
249
  onAction?: OnAction<G["UserData"]>;
166
250
  permissions?: Partial<Permissions>;
167
251
  plugins?: Plugin<UserConfig>[];
@@ -180,7 +264,7 @@ type EditorProps<UserConfig extends Config = Config, G extends UserGenerics<User
180
264
  headerPath?: string;
181
265
  title?: ReactNode;
182
266
  routes?: Route[];
183
- currentPath?: string;
267
+ currentRoute?: string;
184
268
  onRouteChange?: (path: string) => void | Promise<void>;
185
269
  viewports?: Viewports;
186
270
  iframe?: IframeConfig;
@@ -284,6 +368,15 @@ declare const RichTextMenu: {
284
368
  Underline: typeof Underline;
285
369
  };
286
370
 
371
+ /**
372
+ * Returns a structurally-stable reference. Updates only when `value` deep-changes,
373
+ * so referentially-fresh-but-content-equal objects don't re-trigger downstream memos.
374
+ *
375
+ * Used inside `<AppProvider>` so that users passing inline `pages={{ ... }}` don't
376
+ * re-compile the route table on every parent render.
377
+ */
378
+ declare const useStableValue: <T>(value: T) => T;
379
+
287
380
  /**
288
381
  * Framework-agnostic SEO output shape. Mirrors the subset of Next.js's
289
382
  * Metadata type that most page builders care about — title, description,
@@ -413,4 +506,4 @@ declare const outlinePlugin: () => Plugin;
413
506
 
414
507
  declare const legacySideBarPlugin: () => Plugin;
415
508
 
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 };
509
+ export { Action, ActionBar, App, type AppContextValue, type AppMatched, type AppProps, AppProvider, type AppProviderProps, 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 };