@localess/react 3.0.1-dev.20260410070330 → 3.0.1-dev.20260411012947

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.
@@ -39,7 +39,7 @@ var LocalessServerComponent = forwardRef(({ data, links, references, ...restProp
39
39
  import { forwardRef as forwardRef2 } from "react";
40
40
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
41
41
  var LocalessServerDocument = forwardRef2(({ document }, ref) => {
42
- if (!document || !document.data) {
42
+ if (!document.data) {
43
43
  console.error("LocalessServerDocument property %cdocument.data%c is not provided.", FONT_BOLD, FONT_NORMAL);
44
44
  return /* @__PURE__ */ jsxs2("div", { children: [
45
45
  "LocalessServerDocument property ",
@@ -3,7 +3,6 @@ import {
3
3
  FONT_NORMAL,
4
4
  getComponent,
5
5
  getFallbackComponent,
6
- getLocalessClient,
7
6
  isSyncEnabled,
8
7
  localessEditable
9
8
  } from "./chunk-ETSLIILF.mjs";
@@ -41,36 +40,6 @@ var LocalessComponent = forwardRef(
41
40
  }
42
41
  );
43
42
 
44
- // src/core/hooks/use-localess.ts
45
- import { useEffect, useState } from "react";
46
- import { isBrowser } from "@localess/client";
47
- var useLocaless = (slug, options = {}) => {
48
- const [document, setDocument] = useState();
49
- const client = getLocalessClient();
50
- let normalizedSlug;
51
- if (Array.isArray(slug)) {
52
- normalizedSlug = slug.join("/");
53
- } else {
54
- normalizedSlug = slug;
55
- }
56
- useEffect(() => {
57
- async function loadDocument() {
58
- const document2 = await client.getContentBySlug(normalizedSlug, options);
59
- setDocument(document2);
60
- if (isSyncEnabled() && isBrowser()) {
61
- window.localess?.on(["input", "change"], (event) => {
62
- if (event.type === "change" || event.type === "input") {
63
- setDocument({ ...document2, data: event.data });
64
- }
65
- });
66
- }
67
- }
68
- loadDocument();
69
- }, [slug, options, client]);
70
- return document;
71
- };
72
-
73
43
  export {
74
- LocalessComponent,
75
- useLocaless
44
+ LocalessComponent
76
45
  };
package/dist/index.d.mts CHANGED
@@ -1,16 +1,104 @@
1
- export { L as LocalessOptions, f as findLink, g as getComponent, a as getFallbackComponent, b as getLocalessClient, i as isSyncEnabled, l as localessInit, r as registerComponent, c as renderRichTextToReact, d as resolveAsset, s as setComponents, e as setFallbackComponent, u as unregisterComponent } from './richtext-XH7pH80J.mjs';
2
- import * as React from 'react';
3
- import { ContentData, Links, References, ContentFetchParams, Content } from '@localess/client';
1
+ export { L as LocalessOptions, f as findLink, g as getComponent, a as getFallbackComponent, b as getLocalessClient, i as isSyncEnabled, l as localessInit, r as registerComponent, c as renderRichTextToReact, d as resolveAsset, s as setComponents, e as setFallbackComponent, u as unregisterComponent } from './richtext-D6tBmv-7.mjs';
2
+ export { L as LocalessComponent, a as LocalessComponentProps } from './localess-component-DikkO35Z.mjs';
3
+ import * as react from 'react';
4
+ import { ContentData, Content, ContentFetchParams } from '@localess/client';
4
5
  export { Content, ContentAsset, ContentData, ContentDataField, ContentDataSchema, ContentLink, ContentMetadata, ContentReference, ContentRichText, EventCallback, EventToApp, EventToAppType, Links, LocalessClient, LocalessSync, References, Translations, isBrowser, isIframe, isServer, localessEditable, localessEditableField } from '@localess/client';
5
6
 
6
- type LocalessComponentProps<T extends ContentData = ContentData> = {
7
- data: T;
8
- links?: Links;
9
- references?: References;
7
+ /**
8
+ * Props for {@link LocalessDocument}.
9
+ *
10
+ * @template T - The content data shape. Defaults to the base {@link ContentData} type.
11
+ */
12
+ type LocalessDocumentProps<T extends ContentData = ContentData> = {
13
+ /**
14
+ * The full content response object as returned by `getContentBySlug` or `getContentById`.
15
+ * Must contain a `data` field with a valid `_schema` key.
16
+ */
17
+ document: Content<T>;
10
18
  };
11
- declare const LocalessComponent: React.ForwardRefExoticComponent<LocalessComponentProps<ContentData> & React.RefAttributes<HTMLElement>>;
19
+ /**
20
+ * Client Component that renders content and automatically subscribes to Visual Editor sync events.
21
+ *
22
+ * Wraps {@link LocalessComponent} with local state so that live `input` and `change` events
23
+ * from the Localess Visual Editor update the rendered content without a full page reload.
24
+ *
25
+ * **Recommended pattern for Next.js App Router:** fetch data in a Server Component and pass it
26
+ * as props. The page renders immediately with server data; once the client hydrates, live editing
27
+ * activates on top — no loading state needed.
28
+ *
29
+ * Sync only activates when `enableSync: true` was passed to `localessInit` **and** the page
30
+ * is running inside the Visual Editor iframe (`isIframe()` is true).
31
+ *
32
+ * **Requires `'use client'`** — must be used inside a Client Component boundary in Next.js
33
+ * App Router. Available from `@localess/react` (SPA) and `@localess/react/rsc` (RSC).
34
+ * Not available from `@localess/react/ssr`.
35
+ *
36
+ * @template T - The content data shape. Defaults to {@link ContentData}.
37
+ *
38
+ * @example Server Component passes data; Client Component renders with live sync
39
+ * ```tsx
40
+ * // app/[locale]/page.tsx (Server Component)
41
+ * import { getLocalessClient } from '@localess/react/rsc';
42
+ * import PageClient from './page-client';
43
+ *
44
+ * export default async function Page({ params }) {
45
+ * const content = await getLocalessClient().getContentBySlug('home', { locale: params.locale });
46
+ * return <PageClient data={content.data} links={content.links} references={content.references} />;
47
+ * }
48
+ *
49
+ * // app/[locale]/page-client.tsx (Client Component)
50
+ * 'use client';
51
+ * import { LocalessDocument } from '@localess/react/rsc';
52
+ *
53
+ * export default function PageClient({ data, links, references }) {
54
+ * return <LocalessDocument data={data} links={links} references={references} />;
55
+ * }
56
+ * ```
57
+ */
58
+ declare const LocalessDocument: react.ForwardRefExoticComponent<LocalessDocumentProps<ContentData> & react.RefAttributes<HTMLElement>>;
12
59
 
60
+ /**
61
+ * Options for {@link useLocaless}.
62
+ * Extends {@link ContentFetchParams} with any future hook-specific settings.
63
+ */
13
64
  type UseLocalessOptions = ContentFetchParams & {};
65
+ /**
66
+ * React hook for fetching Localess content by slug inside a Client Component.
67
+ *
68
+ * Fetches content on mount using `getLocalessClient().getContentBySlug`, stores it in local state,
69
+ * and — when `enableSync` is active and the page is running inside the Visual Editor iframe —
70
+ * automatically subscribes to `input` and `change` events so content updates live without a reload.
71
+ *
72
+ * **Requires `'use client'`** — must be called inside a Client Component.
73
+ *
74
+ * **Recommended pattern:** fetch data server-side and pass it as `initialContent`, then use the
75
+ * hook result with `?? initialContent` to avoid a loading flash:
76
+ * ```tsx
77
+ * const content = useLocaless('home', { locale }) ?? initialContent;
78
+ * ```
79
+ *
80
+ * @template T - The content data shape. Defaults to {@link ContentData}.
81
+ *
82
+ * @param slug - Content slug string, or an array of path segments that will be joined with `/`.
83
+ * @param options - Optional fetch parameters (locale, version, resolveReference, resolveLink).
84
+ * @returns The fetched {@link Content}<T> object, or `undefined` while the initial fetch is in flight.
85
+ *
86
+ * @example Basic usage
87
+ * ```tsx
88
+ * 'use client';
89
+ * import { useLocaless } from '@localess/react/rsc';
90
+ *
91
+ * export function PageClient({ initialContent, locale }) {
92
+ * const content = useLocaless('home', { locale }) ?? initialContent;
93
+ * return <LocalessComponent data={content.data} links={content.links} />;
94
+ * }
95
+ * ```
96
+ *
97
+ * @example Array slug (joined as 'blog/my-post')
98
+ * ```tsx
99
+ * const content = useLocaless(['blog', 'my-post'], { locale: 'en' });
100
+ * ```
101
+ */
14
102
  declare const useLocaless: <T extends ContentData = ContentData>(slug: string | string[], options?: UseLocalessOptions) => Content<T> | undefined;
15
103
 
16
- export { LocalessComponent, type LocalessComponentProps, type UseLocalessOptions, useLocaless };
104
+ export { LocalessDocument, type LocalessDocumentProps, type UseLocalessOptions, useLocaless };
package/dist/index.d.ts CHANGED
@@ -1,16 +1,104 @@
1
- export { L as LocalessOptions, f as findLink, g as getComponent, a as getFallbackComponent, b as getLocalessClient, i as isSyncEnabled, l as localessInit, r as registerComponent, c as renderRichTextToReact, d as resolveAsset, s as setComponents, e as setFallbackComponent, u as unregisterComponent } from './richtext-XH7pH80J.js';
2
- import * as React from 'react';
3
- import { ContentData, Links, References, ContentFetchParams, Content } from '@localess/client';
1
+ export { L as LocalessOptions, f as findLink, g as getComponent, a as getFallbackComponent, b as getLocalessClient, i as isSyncEnabled, l as localessInit, r as registerComponent, c as renderRichTextToReact, d as resolveAsset, s as setComponents, e as setFallbackComponent, u as unregisterComponent } from './richtext-D6tBmv-7.js';
2
+ export { L as LocalessComponent, a as LocalessComponentProps } from './localess-component-DikkO35Z.js';
3
+ import * as react from 'react';
4
+ import { ContentData, Content, ContentFetchParams } from '@localess/client';
4
5
  export { Content, ContentAsset, ContentData, ContentDataField, ContentDataSchema, ContentLink, ContentMetadata, ContentReference, ContentRichText, EventCallback, EventToApp, EventToAppType, Links, LocalessClient, LocalessSync, References, Translations, isBrowser, isIframe, isServer, localessEditable, localessEditableField } from '@localess/client';
5
6
 
6
- type LocalessComponentProps<T extends ContentData = ContentData> = {
7
- data: T;
8
- links?: Links;
9
- references?: References;
7
+ /**
8
+ * Props for {@link LocalessDocument}.
9
+ *
10
+ * @template T - The content data shape. Defaults to the base {@link ContentData} type.
11
+ */
12
+ type LocalessDocumentProps<T extends ContentData = ContentData> = {
13
+ /**
14
+ * The full content response object as returned by `getContentBySlug` or `getContentById`.
15
+ * Must contain a `data` field with a valid `_schema` key.
16
+ */
17
+ document: Content<T>;
10
18
  };
11
- declare const LocalessComponent: React.ForwardRefExoticComponent<LocalessComponentProps<ContentData> & React.RefAttributes<HTMLElement>>;
19
+ /**
20
+ * Client Component that renders content and automatically subscribes to Visual Editor sync events.
21
+ *
22
+ * Wraps {@link LocalessComponent} with local state so that live `input` and `change` events
23
+ * from the Localess Visual Editor update the rendered content without a full page reload.
24
+ *
25
+ * **Recommended pattern for Next.js App Router:** fetch data in a Server Component and pass it
26
+ * as props. The page renders immediately with server data; once the client hydrates, live editing
27
+ * activates on top — no loading state needed.
28
+ *
29
+ * Sync only activates when `enableSync: true` was passed to `localessInit` **and** the page
30
+ * is running inside the Visual Editor iframe (`isIframe()` is true).
31
+ *
32
+ * **Requires `'use client'`** — must be used inside a Client Component boundary in Next.js
33
+ * App Router. Available from `@localess/react` (SPA) and `@localess/react/rsc` (RSC).
34
+ * Not available from `@localess/react/ssr`.
35
+ *
36
+ * @template T - The content data shape. Defaults to {@link ContentData}.
37
+ *
38
+ * @example Server Component passes data; Client Component renders with live sync
39
+ * ```tsx
40
+ * // app/[locale]/page.tsx (Server Component)
41
+ * import { getLocalessClient } from '@localess/react/rsc';
42
+ * import PageClient from './page-client';
43
+ *
44
+ * export default async function Page({ params }) {
45
+ * const content = await getLocalessClient().getContentBySlug('home', { locale: params.locale });
46
+ * return <PageClient data={content.data} links={content.links} references={content.references} />;
47
+ * }
48
+ *
49
+ * // app/[locale]/page-client.tsx (Client Component)
50
+ * 'use client';
51
+ * import { LocalessDocument } from '@localess/react/rsc';
52
+ *
53
+ * export default function PageClient({ data, links, references }) {
54
+ * return <LocalessDocument data={data} links={links} references={references} />;
55
+ * }
56
+ * ```
57
+ */
58
+ declare const LocalessDocument: react.ForwardRefExoticComponent<LocalessDocumentProps<ContentData> & react.RefAttributes<HTMLElement>>;
12
59
 
60
+ /**
61
+ * Options for {@link useLocaless}.
62
+ * Extends {@link ContentFetchParams} with any future hook-specific settings.
63
+ */
13
64
  type UseLocalessOptions = ContentFetchParams & {};
65
+ /**
66
+ * React hook for fetching Localess content by slug inside a Client Component.
67
+ *
68
+ * Fetches content on mount using `getLocalessClient().getContentBySlug`, stores it in local state,
69
+ * and — when `enableSync` is active and the page is running inside the Visual Editor iframe —
70
+ * automatically subscribes to `input` and `change` events so content updates live without a reload.
71
+ *
72
+ * **Requires `'use client'`** — must be called inside a Client Component.
73
+ *
74
+ * **Recommended pattern:** fetch data server-side and pass it as `initialContent`, then use the
75
+ * hook result with `?? initialContent` to avoid a loading flash:
76
+ * ```tsx
77
+ * const content = useLocaless('home', { locale }) ?? initialContent;
78
+ * ```
79
+ *
80
+ * @template T - The content data shape. Defaults to {@link ContentData}.
81
+ *
82
+ * @param slug - Content slug string, or an array of path segments that will be joined with `/`.
83
+ * @param options - Optional fetch parameters (locale, version, resolveReference, resolveLink).
84
+ * @returns The fetched {@link Content}<T> object, or `undefined` while the initial fetch is in flight.
85
+ *
86
+ * @example Basic usage
87
+ * ```tsx
88
+ * 'use client';
89
+ * import { useLocaless } from '@localess/react/rsc';
90
+ *
91
+ * export function PageClient({ initialContent, locale }) {
92
+ * const content = useLocaless('home', { locale }) ?? initialContent;
93
+ * return <LocalessComponent data={content.data} links={content.links} />;
94
+ * }
95
+ * ```
96
+ *
97
+ * @example Array slug (joined as 'blog/my-post')
98
+ * ```tsx
99
+ * const content = useLocaless(['blog', 'my-post'], { locale: 'en' });
100
+ * ```
101
+ */
14
102
  declare const useLocaless: <T extends ContentData = ContentData>(slug: string | string[], options?: UseLocalessOptions) => Content<T> | undefined;
15
103
 
16
- export { LocalessComponent, type LocalessComponentProps, type UseLocalessOptions, useLocaless };
104
+ export { LocalessDocument, type LocalessDocumentProps, type UseLocalessOptions, useLocaless };
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  LocalessComponent: () => LocalessComponent,
24
+ LocalessDocument: () => LocalessDocument,
24
25
  findLink: () => findLink,
25
26
  getComponent: () => getComponent,
26
27
  getFallbackComponent: () => getFallbackComponent,
@@ -163,11 +164,36 @@ var LocalessComponent = (0, import_react.forwardRef)(
163
164
  }
164
165
  );
165
166
 
166
- // src/core/hooks/use-localess.ts
167
+ // src/core/components/localess-document.tsx
167
168
  var import_react2 = require("react");
169
+ var import_jsx_runtime2 = require("react/jsx-runtime");
170
+ var LocalessDocument = (0, import_react2.forwardRef)(({ document }, ref) => {
171
+ const [contentData, setContentData] = (0, import_react2.useState)(document.data);
172
+ (0, import_react2.useEffect)(() => {
173
+ if (isSyncEnabled() && (0, import_client2.isBrowser)() && (0, import_client2.isIframe)()) {
174
+ window.localess?.on(["input", "change"], (event) => {
175
+ if (event.type === "change" || event.type === "input") {
176
+ setContentData(event.data);
177
+ }
178
+ });
179
+ }
180
+ }, []);
181
+ if (!contentData) {
182
+ console.error("LocalessDocument property %cdocument.data%c is not provided.", FONT_BOLD, FONT_NORMAL);
183
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
184
+ "LocalessDocument property ",
185
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("b", { children: "document.data" }),
186
+ " is not provided."
187
+ ] });
188
+ }
189
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LocalessComponent, { ref, data: contentData, links: document.links, references: document.references });
190
+ });
191
+
192
+ // src/core/hooks/use-localess.ts
193
+ var import_react3 = require("react");
168
194
  var import_client3 = require("@localess/client");
169
195
  var useLocaless = (slug, options = {}) => {
170
- const [document, setDocument] = (0, import_react2.useState)();
196
+ const [document, setDocument] = (0, import_react3.useState)();
171
197
  const client = getLocalessClient();
172
198
  let normalizedSlug;
173
199
  if (Array.isArray(slug)) {
@@ -175,7 +201,7 @@ var useLocaless = (slug, options = {}) => {
175
201
  } else {
176
202
  normalizedSlug = slug;
177
203
  }
178
- (0, import_react2.useEffect)(() => {
204
+ (0, import_react3.useEffect)(() => {
179
205
  async function loadDocument() {
180
206
  const document2 = await client.getContentBySlug(normalizedSlug, options);
181
207
  setDocument(document2);
@@ -193,7 +219,7 @@ var useLocaless = (slug, options = {}) => {
193
219
  };
194
220
 
195
221
  // src/core/richtext.ts
196
- var import_react3 = require("@tiptap/static-renderer/pm/react");
222
+ var import_react4 = require("@tiptap/static-renderer/pm/react");
197
223
  var import_extension_document = require("@tiptap/extension-document");
198
224
  var import_extension_text = require("@tiptap/extension-text");
199
225
  var import_extension_paragraph = require("@tiptap/extension-paragraph");
@@ -210,7 +236,7 @@ var import_extension_code = require("@tiptap/extension-code");
210
236
  var import_extension_code_block_lowlight = require("@tiptap/extension-code-block-lowlight");
211
237
  var import_extension_link = require("@tiptap/extension-link");
212
238
  function renderRichTextToReact(content) {
213
- return (0, import_react3.renderToReactElement)({
239
+ return (0, import_react4.renderToReactElement)({
214
240
  content,
215
241
  extensions: [
216
242
  import_extension_document.Document,
@@ -236,6 +262,7 @@ function renderRichTextToReact(content) {
236
262
  // Annotate the CommonJS export names for ESM import in node:
237
263
  0 && (module.exports = {
238
264
  LocalessComponent,
265
+ LocalessDocument,
239
266
  findLink,
240
267
  getComponent,
241
268
  getFallbackComponent,
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
- LocalessComponent,
3
- useLocaless
4
- } from "./chunk-V6JSXN66.mjs";
2
+ LocalessComponent
3
+ } from "./chunk-UW7OWE53.mjs";
5
4
  import {
5
+ FONT_BOLD,
6
+ FONT_NORMAL,
6
7
  findLink,
7
8
  getComponent,
8
9
  getFallbackComponent,
@@ -21,8 +22,63 @@ import {
21
22
  setFallbackComponent,
22
23
  unregisterComponent
23
24
  } from "./chunk-ETSLIILF.mjs";
25
+
26
+ // src/core/components/localess-document.tsx
27
+ import { forwardRef, useEffect, useState } from "react";
28
+ import { jsx, jsxs } from "react/jsx-runtime";
29
+ var LocalessDocument = forwardRef(({ document }, ref) => {
30
+ const [contentData, setContentData] = useState(document.data);
31
+ useEffect(() => {
32
+ if (isSyncEnabled() && isBrowser() && isIframe()) {
33
+ window.localess?.on(["input", "change"], (event) => {
34
+ if (event.type === "change" || event.type === "input") {
35
+ setContentData(event.data);
36
+ }
37
+ });
38
+ }
39
+ }, []);
40
+ if (!contentData) {
41
+ console.error("LocalessDocument property %cdocument.data%c is not provided.", FONT_BOLD, FONT_NORMAL);
42
+ return /* @__PURE__ */ jsxs("div", { children: [
43
+ "LocalessDocument property ",
44
+ /* @__PURE__ */ jsx("b", { children: "document.data" }),
45
+ " is not provided."
46
+ ] });
47
+ }
48
+ return /* @__PURE__ */ jsx(LocalessComponent, { ref, data: contentData, links: document.links, references: document.references });
49
+ });
50
+
51
+ // src/core/hooks/use-localess.ts
52
+ import { useEffect as useEffect2, useState as useState2 } from "react";
53
+ import { isBrowser as isBrowser2 } from "@localess/client";
54
+ var useLocaless = (slug, options = {}) => {
55
+ const [document, setDocument] = useState2();
56
+ const client = getLocalessClient();
57
+ let normalizedSlug;
58
+ if (Array.isArray(slug)) {
59
+ normalizedSlug = slug.join("/");
60
+ } else {
61
+ normalizedSlug = slug;
62
+ }
63
+ useEffect2(() => {
64
+ async function loadDocument() {
65
+ const document2 = await client.getContentBySlug(normalizedSlug, options);
66
+ setDocument(document2);
67
+ if (isSyncEnabled() && isBrowser2()) {
68
+ window.localess?.on(["input", "change"], (event) => {
69
+ if (event.type === "change" || event.type === "input") {
70
+ setDocument({ ...document2, data: event.data });
71
+ }
72
+ });
73
+ }
74
+ }
75
+ loadDocument();
76
+ }, [slug, options, client]);
77
+ return document;
78
+ };
24
79
  export {
25
80
  LocalessComponent,
81
+ LocalessDocument,
26
82
  findLink,
27
83
  getComponent,
28
84
  getFallbackComponent,
@@ -0,0 +1,58 @@
1
+ import * as react from 'react';
2
+ import { ContentData, Links, References } from '@localess/client';
3
+
4
+ /**
5
+ * Props for {@link LocalessComponent}.
6
+ *
7
+ * @template T - The content data shape. Defaults to the base {@link ContentData} type.
8
+ */
9
+ type LocalessComponentProps<T extends ContentData = ContentData> = {
10
+ /**
11
+ * The content data object to render. Must have a `_schema` field that matches a key
12
+ * in the component registry configured via `localessInit`.
13
+ */
14
+ data: T;
15
+ /**
16
+ * Optional map of content links keyed by link ID.
17
+ * Pass through to child components so they can resolve {@link ContentLink} values with `findLink`.
18
+ */
19
+ links?: Links;
20
+ /**
21
+ * Optional map of resolved content references keyed by reference ID.
22
+ * Pass through to child components that consume referenced content.
23
+ */
24
+ references?: References;
25
+ };
26
+ /**
27
+ * Dynamic schema-to-component renderer for use in SPA and client-side contexts.
28
+ *
29
+ * Looks up `data._schema` in the component registry (set via `localessInit` or `setComponents`),
30
+ * renders the matched component, and — when Visual Editor sync is active — automatically
31
+ * spreads `localessEditable` attributes on the root element for live targeting.
32
+ *
33
+ * Falls back to the `fallbackComponent` (if registered) when the schema key is not found,
34
+ * or renders an inline error message as a last resort.
35
+ *
36
+ * **Server-safe** — does not include a `'use client'` directive and can be used in
37
+ * React Server Components. For SSR / static-export environments use {@link LocalessServerComponent}
38
+ * from `@localess/react/ssr` instead, which omits the sync attribute injection.
39
+ *
40
+ * @template T - The content data shape. Defaults to {@link ContentData}.
41
+ *
42
+ * @example Basic usage
43
+ * ```tsx
44
+ * import { LocalessComponent } from '@localess/react';
45
+ *
46
+ * <LocalessComponent data={content.data} links={content.links} references={content.references} />
47
+ * ```
48
+ *
49
+ * @example Rendering a list of nested blocks
50
+ * ```tsx
51
+ * {data.body.map(item => (
52
+ * <LocalessComponent key={item._id} data={item} links={content.links} references={content.references} />
53
+ * ))}
54
+ * ```
55
+ */
56
+ declare const LocalessComponent: react.ForwardRefExoticComponent<LocalessComponentProps<ContentData> & react.RefAttributes<HTMLElement>>;
57
+
58
+ export { LocalessComponent as L, type LocalessComponentProps as a };
@@ -0,0 +1,58 @@
1
+ import * as react from 'react';
2
+ import { ContentData, Links, References } from '@localess/client';
3
+
4
+ /**
5
+ * Props for {@link LocalessComponent}.
6
+ *
7
+ * @template T - The content data shape. Defaults to the base {@link ContentData} type.
8
+ */
9
+ type LocalessComponentProps<T extends ContentData = ContentData> = {
10
+ /**
11
+ * The content data object to render. Must have a `_schema` field that matches a key
12
+ * in the component registry configured via `localessInit`.
13
+ */
14
+ data: T;
15
+ /**
16
+ * Optional map of content links keyed by link ID.
17
+ * Pass through to child components so they can resolve {@link ContentLink} values with `findLink`.
18
+ */
19
+ links?: Links;
20
+ /**
21
+ * Optional map of resolved content references keyed by reference ID.
22
+ * Pass through to child components that consume referenced content.
23
+ */
24
+ references?: References;
25
+ };
26
+ /**
27
+ * Dynamic schema-to-component renderer for use in SPA and client-side contexts.
28
+ *
29
+ * Looks up `data._schema` in the component registry (set via `localessInit` or `setComponents`),
30
+ * renders the matched component, and — when Visual Editor sync is active — automatically
31
+ * spreads `localessEditable` attributes on the root element for live targeting.
32
+ *
33
+ * Falls back to the `fallbackComponent` (if registered) when the schema key is not found,
34
+ * or renders an inline error message as a last resort.
35
+ *
36
+ * **Server-safe** — does not include a `'use client'` directive and can be used in
37
+ * React Server Components. For SSR / static-export environments use {@link LocalessServerComponent}
38
+ * from `@localess/react/ssr` instead, which omits the sync attribute injection.
39
+ *
40
+ * @template T - The content data shape. Defaults to {@link ContentData}.
41
+ *
42
+ * @example Basic usage
43
+ * ```tsx
44
+ * import { LocalessComponent } from '@localess/react';
45
+ *
46
+ * <LocalessComponent data={content.data} links={content.links} references={content.references} />
47
+ * ```
48
+ *
49
+ * @example Rendering a list of nested blocks
50
+ * ```tsx
51
+ * {data.body.map(item => (
52
+ * <LocalessComponent key={item._id} data={item} links={content.links} references={content.references} />
53
+ * ))}
54
+ * ```
55
+ */
56
+ declare const LocalessComponent: react.ForwardRefExoticComponent<LocalessComponentProps<ContentData> & react.RefAttributes<HTMLElement>>;
57
+
58
+ export { LocalessComponent as L, type LocalessComponentProps as a };