@amplifyup/sdk 0.1.61 → 0.1.63

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.
@@ -60,6 +60,7 @@ declare function selectVariants(options: SelectVariantsOptions): Promise<SelectV
60
60
  * Page resolve covers data known at Deploy. Visitor-triggered data — search,
61
61
  * load more, pickers — runs here: the browser asks AmplifyUp, AmplifyUp asks
62
62
  * the CMS. Only entities published with the page can be queried.
63
+ * Results are plain CMS rows, not Field envelopes, and are not canvas-editable.
63
64
  */
64
65
 
65
66
  type QueryFilterOp = 'eq' | 'neq' | 'in' | 'nin' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'exists';
@@ -60,6 +60,7 @@ declare function selectVariants(options: SelectVariantsOptions): Promise<SelectV
60
60
  * Page resolve covers data known at Deploy. Visitor-triggered data — search,
61
61
  * load more, pickers — runs here: the browser asks AmplifyUp, AmplifyUp asks
62
62
  * the CMS. Only entities published with the page can be queried.
63
+ * Results are plain CMS rows, not Field envelopes, and are not canvas-editable.
63
64
  */
64
65
 
65
66
  type QueryFilterOp = 'eq' | 'neq' | 'in' | 'nin' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'exists';
package/dist/react.d.mts CHANGED
@@ -1,16 +1,17 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { P as PageConfig, c as AmplifyUpConfig, e as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-Db_eLrfU.mjs';
3
3
  export { Z as ZoneConfig } from './types-Db_eLrfU.mjs';
4
- import React__default, { ReactNode } from 'react';
5
- export { AmplifyRenderer } from './AmplifyRenderer.mjs';
6
- export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-DaJlqU-Z.mjs';
4
+ import react__default, { ReactNode } from 'react';
5
+ import { L as LayoutComponentProps, F as Field$1, C as CollectionField, a as Fields } from './AmplifyRenderer-TawbUIKZ.mjs';
6
+ export { A as AmplifyRenderer, I as ImageValue, P as PortableRef, b as isBrandedFields, i as isFieldEnvelope, t as toFieldEnvelopes } from './AmplifyRenderer-TawbUIKZ.mjs';
7
+ export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-DIZjc7st.mjs';
7
8
  export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
8
9
 
9
10
  type RenderComponentContext = {
10
11
  /** Unique layout-tree node id — required when multiple instances share a component type. */
11
12
  layoutNodeId: string;
12
13
  };
13
- type RenderComponentFn = (componentId: string, props: Record<string, any>, slots?: Record<string, ReactNode>, context?: RenderComponentContext) => ReactNode;
14
+ type RenderComponentFn = (componentId: string, props: LayoutComponentProps, slots?: Record<string, ReactNode>, context?: RenderComponentContext) => ReactNode;
14
15
  interface AmplifyPageContentProps {
15
16
  /**
16
17
  * Native page content shown to visitors when no AmplifyUp layout is configured.
@@ -43,12 +44,6 @@ interface AmplifyPageContentProps {
43
44
  */
44
45
  declare function AmplifyPageContent({ fallback, renderComponent, pageConfig: pageConfigProp, forceComposerPreview, previewLoadingComponent, previewEmptyComponent, loadingComponent, emptyComponent, errorComponent, }: AmplifyPageContentProps): react_jsx_runtime.JSX.Element | null;
45
46
 
46
- declare function useLiveComposerProps(layoutNodeId: string | undefined, props: Record<string, any>): Record<string, any>;
47
- /**
48
- * Live props for this layout node (CMS fields + settings).
49
- * Same values `<Field>` reads — use this when you want to render yourself.
50
- */
51
- declare function useComponentProps<T extends Record<string, any> = Record<string, any>>(): T;
52
47
  declare function ComponentContextProvider({ children, slots, props, layoutNodeId, componentId, }: {
53
48
  children: ReactNode;
54
49
  slots?: Record<string, ReactNode>;
@@ -86,45 +81,74 @@ declare function Slot({ name, className, }: {
86
81
  name: string;
87
82
  className?: string;
88
83
  }): react_jsx_runtime.JSX.Element | null;
89
- declare function Field(props: {
90
- /** Field value from your component props. Do not also pass `name`. */
91
- value?: unknown;
92
- /**
93
- * @deprecated Prefer `value={…}`. Still used as the Composer save key when
94
- * the same value appears on more than one prop.
95
- */
84
+ type RejectArray<T> = [T] extends [readonly unknown[]] ? never : T;
85
+ /**
86
+ * Field Component
87
+ *
88
+ * Pass a field envelope: `<Field field={fields.title} />`.
89
+ * For a computed value, pass `value` and `name`.
90
+ *
91
+ * For markdown / rich text fields, use {@link RichText} instead.
92
+ * List fields use {@link Collection} (repeaters) or `.value` (reference lists).
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * function Hero({ fields }: { fields: Fields<{ title: string; description: string }> }) {
97
+ * return (
98
+ * <section className="hero">
99
+ * <h1>
100
+ * <Field field={fields.title} />
101
+ * </h1>
102
+ * <p>{fields.description.value}</p>
103
+ * </section>
104
+ * );
105
+ * }
106
+ * ```
107
+ */
108
+ declare function Field<T = unknown>(props: {
109
+ /** Envelope from `props.fields` (`{ value, name }`). Arrays are not allowed. */
110
+ field?: Field$1<RejectArray<T>>;
111
+ /** Computed value — requires `name`. */
112
+ value?: RejectArray<T>;
113
+ /** Required with `value` for computed values. */
96
114
  name?: string;
97
- fallback?: ReactNode;
98
115
  className?: string;
99
- render?: (value: any) => ReactNode;
100
- }): string | number | true | Iterable<React__default.ReactNode> | react_jsx_runtime.JSX.Element | null;
116
+ }): react_jsx_runtime.JSX.Element | null;
117
+ /**
118
+ * Repeater (inline-authored list). Inside Composer: empty placeholder plus
119
+ * add / remove / reorder. Outside Composer: children only.
120
+ *
121
+ * Reference lists are not canvas-bound — map `fields.posts.value` instead.
122
+ */
123
+ declare function Collection<T extends Record<string, unknown>>({ field, children, className, }: {
124
+ field: CollectionField<T> | Field$1<T[]>;
125
+ children: (item: Fields<T>, index: number) => ReactNode;
126
+ className?: string;
127
+ }): react_jsx_runtime.JSX.Element | null;
101
128
  /**
102
129
  * RichText - Renders a markdown (or HTML string) value as formatted HTML.
103
130
  *
104
- * Pass the field value from your component props (`value={body}`). Values are
105
- * Markdown for portability across CMS platforms.
131
+ * Pass a field envelope: `<RichText field={fields.body} />`.
132
+ * Values are Markdown for portability across CMS platforms.
106
133
  *
107
134
  * @example
108
135
  * ```tsx
109
- * function Article({ title, body }: { title: string; body: string }) {
136
+ * function Article({ fields }: { fields: Fields<{ title: string; body: string }> }) {
110
137
  * return (
111
138
  * <article>
112
- * <h1><Field value={title} /></h1>
113
- * <RichText value={body} className="prose" />
139
+ * <h1><Field field={fields.title} /></h1>
140
+ * <RichText field={fields.body} className="prose" />
114
141
  * </article>
115
142
  * );
116
143
  * }
117
144
  * ```
118
145
  */
119
146
  declare function RichText(props: {
120
- /** Markdown (or HTML) string from your component props. Do not also pass `name`. */
147
+ field?: Field$1<string | null>;
148
+ /** Computed markdown — requires `name`. */
121
149
  value?: string | null;
122
- /**
123
- * @deprecated Prefer `value={…}`. Still used as the Composer save key when
124
- * the same value appears on more than one prop.
125
- */
150
+ /** Required with `value` for computed values. */
126
151
  name?: string;
127
- fallback?: ReactNode;
128
152
  className?: string;
129
153
  as?: keyof JSX.IntrinsicElements;
130
154
  /** String children are treated as the markdown value (same as `value`). */
@@ -133,28 +157,36 @@ declare function RichText(props: {
133
157
  /**
134
158
  * Image — renders a provider-backed image value as `<img>`.
135
159
  *
136
- * Pass the portable `{ url, alt?, width?, height? }` (or URL string) from your
137
- * component props via `value`. AmplifyUp does not host image files.
160
+ * Pass a field envelope: `<Image field={fields.backgroundImage} />`.
161
+ * AmplifyUp does not host image files.
138
162
  *
139
163
  * @example
140
164
  * ```tsx
141
- * function Hero({ backgroundImage }: { backgroundImage: { url: string } }) {
165
+ * function Hero({ fields }: { fields: Fields<{ backgroundImage: ImageValue }> }) {
142
166
  * return (
143
- * <Image value={backgroundImage} className="h-full w-full object-cover" />
167
+ * <Image field={fields.backgroundImage} className="h-full w-full object-cover" />
144
168
  * );
145
169
  * }
146
170
  * ```
147
171
  */
148
172
  declare function Image(props: {
149
- /** Portable image or URL string from your component props. Do not also pass `name`. */
173
+ field?: Field$1<unknown>;
174
+ /** Computed image — requires `name`. */
150
175
  value?: unknown;
151
- /**
152
- * @deprecated Will be removed. Use `value={…}` and omit `name`.
153
- * Do not pass `name` together with `value`.
154
- */
176
+ /** Required with `value` for computed values. */
155
177
  name?: string;
156
178
  alt?: string;
157
- } & Omit<React__default.ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt' | 'name'>): react_jsx_runtime.JSX.Element | null;
179
+ } & Omit<react__default.ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt' | 'name'>): react_jsx_runtime.JSX.Element | null;
180
+
181
+ declare function ComposerProvider({ layoutNodeId, children, }: {
182
+ layoutNodeId?: string;
183
+ children: ReactNode;
184
+ }): react_jsx_runtime.JSX.Element;
185
+ declare function MaybeComposerProvider({ enabled, layoutNodeId, children, }: {
186
+ enabled: boolean;
187
+ layoutNodeId?: string;
188
+ children: ReactNode;
189
+ }): react_jsx_runtime.JSX.Element;
158
190
 
159
191
  interface AmplifyUpContextType {
160
192
  pageConfig: PageConfig | null;
@@ -175,4 +207,4 @@ interface AmplifyUpProviderProps {
175
207
  declare function AmplifyUpProvider({ children, config, pageContext, }: AmplifyUpProviderProps): react_jsx_runtime.JSX.Element;
176
208
  declare function useAmplifyUp(): AmplifyUpContextType;
177
209
 
178
- export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, ComponentContextProvider, ContentSource, Field, Image, PageConfig, RichText, Slot, useAmplifyUp, useComponentProps, useLiveComposerProps };
210
+ export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, Collection, CollectionField, ComponentContextProvider, ComposerProvider, ContentSource, Field, Field$1 as FieldEnvelope, Fields, Image, LayoutComponentProps, MaybeComposerProvider, PageConfig, RichText, Slot, useAmplifyUp };
package/dist/react.d.ts CHANGED
@@ -1,16 +1,17 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { P as PageConfig, c as AmplifyUpConfig, e as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-Db_eLrfU.js';
3
3
  export { Z as ZoneConfig } from './types-Db_eLrfU.js';
4
- import React__default, { ReactNode } from 'react';
5
- export { AmplifyRenderer } from './AmplifyRenderer.js';
6
- export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-BqApXxQi.js';
4
+ import react__default, { ReactNode } from 'react';
5
+ import { L as LayoutComponentProps, F as Field$1, C as CollectionField, a as Fields } from './AmplifyRenderer-Bwob7ICJ.js';
6
+ export { A as AmplifyRenderer, I as ImageValue, P as PortableRef, b as isBrandedFields, i as isFieldEnvelope, t as toFieldEnvelopes } from './AmplifyRenderer-Bwob7ICJ.js';
7
+ export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-3AXnQgzO.js';
7
8
  export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
8
9
 
9
10
  type RenderComponentContext = {
10
11
  /** Unique layout-tree node id — required when multiple instances share a component type. */
11
12
  layoutNodeId: string;
12
13
  };
13
- type RenderComponentFn = (componentId: string, props: Record<string, any>, slots?: Record<string, ReactNode>, context?: RenderComponentContext) => ReactNode;
14
+ type RenderComponentFn = (componentId: string, props: LayoutComponentProps, slots?: Record<string, ReactNode>, context?: RenderComponentContext) => ReactNode;
14
15
  interface AmplifyPageContentProps {
15
16
  /**
16
17
  * Native page content shown to visitors when no AmplifyUp layout is configured.
@@ -43,12 +44,6 @@ interface AmplifyPageContentProps {
43
44
  */
44
45
  declare function AmplifyPageContent({ fallback, renderComponent, pageConfig: pageConfigProp, forceComposerPreview, previewLoadingComponent, previewEmptyComponent, loadingComponent, emptyComponent, errorComponent, }: AmplifyPageContentProps): react_jsx_runtime.JSX.Element | null;
45
46
 
46
- declare function useLiveComposerProps(layoutNodeId: string | undefined, props: Record<string, any>): Record<string, any>;
47
- /**
48
- * Live props for this layout node (CMS fields + settings).
49
- * Same values `<Field>` reads — use this when you want to render yourself.
50
- */
51
- declare function useComponentProps<T extends Record<string, any> = Record<string, any>>(): T;
52
47
  declare function ComponentContextProvider({ children, slots, props, layoutNodeId, componentId, }: {
53
48
  children: ReactNode;
54
49
  slots?: Record<string, ReactNode>;
@@ -86,45 +81,74 @@ declare function Slot({ name, className, }: {
86
81
  name: string;
87
82
  className?: string;
88
83
  }): react_jsx_runtime.JSX.Element | null;
89
- declare function Field(props: {
90
- /** Field value from your component props. Do not also pass `name`. */
91
- value?: unknown;
92
- /**
93
- * @deprecated Prefer `value={…}`. Still used as the Composer save key when
94
- * the same value appears on more than one prop.
95
- */
84
+ type RejectArray<T> = [T] extends [readonly unknown[]] ? never : T;
85
+ /**
86
+ * Field Component
87
+ *
88
+ * Pass a field envelope: `<Field field={fields.title} />`.
89
+ * For a computed value, pass `value` and `name`.
90
+ *
91
+ * For markdown / rich text fields, use {@link RichText} instead.
92
+ * List fields use {@link Collection} (repeaters) or `.value` (reference lists).
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * function Hero({ fields }: { fields: Fields<{ title: string; description: string }> }) {
97
+ * return (
98
+ * <section className="hero">
99
+ * <h1>
100
+ * <Field field={fields.title} />
101
+ * </h1>
102
+ * <p>{fields.description.value}</p>
103
+ * </section>
104
+ * );
105
+ * }
106
+ * ```
107
+ */
108
+ declare function Field<T = unknown>(props: {
109
+ /** Envelope from `props.fields` (`{ value, name }`). Arrays are not allowed. */
110
+ field?: Field$1<RejectArray<T>>;
111
+ /** Computed value — requires `name`. */
112
+ value?: RejectArray<T>;
113
+ /** Required with `value` for computed values. */
96
114
  name?: string;
97
- fallback?: ReactNode;
98
115
  className?: string;
99
- render?: (value: any) => ReactNode;
100
- }): string | number | true | Iterable<React__default.ReactNode> | react_jsx_runtime.JSX.Element | null;
116
+ }): react_jsx_runtime.JSX.Element | null;
117
+ /**
118
+ * Repeater (inline-authored list). Inside Composer: empty placeholder plus
119
+ * add / remove / reorder. Outside Composer: children only.
120
+ *
121
+ * Reference lists are not canvas-bound — map `fields.posts.value` instead.
122
+ */
123
+ declare function Collection<T extends Record<string, unknown>>({ field, children, className, }: {
124
+ field: CollectionField<T> | Field$1<T[]>;
125
+ children: (item: Fields<T>, index: number) => ReactNode;
126
+ className?: string;
127
+ }): react_jsx_runtime.JSX.Element | null;
101
128
  /**
102
129
  * RichText - Renders a markdown (or HTML string) value as formatted HTML.
103
130
  *
104
- * Pass the field value from your component props (`value={body}`). Values are
105
- * Markdown for portability across CMS platforms.
131
+ * Pass a field envelope: `<RichText field={fields.body} />`.
132
+ * Values are Markdown for portability across CMS platforms.
106
133
  *
107
134
  * @example
108
135
  * ```tsx
109
- * function Article({ title, body }: { title: string; body: string }) {
136
+ * function Article({ fields }: { fields: Fields<{ title: string; body: string }> }) {
110
137
  * return (
111
138
  * <article>
112
- * <h1><Field value={title} /></h1>
113
- * <RichText value={body} className="prose" />
139
+ * <h1><Field field={fields.title} /></h1>
140
+ * <RichText field={fields.body} className="prose" />
114
141
  * </article>
115
142
  * );
116
143
  * }
117
144
  * ```
118
145
  */
119
146
  declare function RichText(props: {
120
- /** Markdown (or HTML) string from your component props. Do not also pass `name`. */
147
+ field?: Field$1<string | null>;
148
+ /** Computed markdown — requires `name`. */
121
149
  value?: string | null;
122
- /**
123
- * @deprecated Prefer `value={…}`. Still used as the Composer save key when
124
- * the same value appears on more than one prop.
125
- */
150
+ /** Required with `value` for computed values. */
126
151
  name?: string;
127
- fallback?: ReactNode;
128
152
  className?: string;
129
153
  as?: keyof JSX.IntrinsicElements;
130
154
  /** String children are treated as the markdown value (same as `value`). */
@@ -133,28 +157,36 @@ declare function RichText(props: {
133
157
  /**
134
158
  * Image — renders a provider-backed image value as `<img>`.
135
159
  *
136
- * Pass the portable `{ url, alt?, width?, height? }` (or URL string) from your
137
- * component props via `value`. AmplifyUp does not host image files.
160
+ * Pass a field envelope: `<Image field={fields.backgroundImage} />`.
161
+ * AmplifyUp does not host image files.
138
162
  *
139
163
  * @example
140
164
  * ```tsx
141
- * function Hero({ backgroundImage }: { backgroundImage: { url: string } }) {
165
+ * function Hero({ fields }: { fields: Fields<{ backgroundImage: ImageValue }> }) {
142
166
  * return (
143
- * <Image value={backgroundImage} className="h-full w-full object-cover" />
167
+ * <Image field={fields.backgroundImage} className="h-full w-full object-cover" />
144
168
  * );
145
169
  * }
146
170
  * ```
147
171
  */
148
172
  declare function Image(props: {
149
- /** Portable image or URL string from your component props. Do not also pass `name`. */
173
+ field?: Field$1<unknown>;
174
+ /** Computed image — requires `name`. */
150
175
  value?: unknown;
151
- /**
152
- * @deprecated Will be removed. Use `value={…}` and omit `name`.
153
- * Do not pass `name` together with `value`.
154
- */
176
+ /** Required with `value` for computed values. */
155
177
  name?: string;
156
178
  alt?: string;
157
- } & Omit<React__default.ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt' | 'name'>): react_jsx_runtime.JSX.Element | null;
179
+ } & Omit<react__default.ImgHTMLAttributes<HTMLImageElement>, 'src' | 'alt' | 'name'>): react_jsx_runtime.JSX.Element | null;
180
+
181
+ declare function ComposerProvider({ layoutNodeId, children, }: {
182
+ layoutNodeId?: string;
183
+ children: ReactNode;
184
+ }): react_jsx_runtime.JSX.Element;
185
+ declare function MaybeComposerProvider({ enabled, layoutNodeId, children, }: {
186
+ enabled: boolean;
187
+ layoutNodeId?: string;
188
+ children: ReactNode;
189
+ }): react_jsx_runtime.JSX.Element;
158
190
 
159
191
  interface AmplifyUpContextType {
160
192
  pageConfig: PageConfig | null;
@@ -175,4 +207,4 @@ interface AmplifyUpProviderProps {
175
207
  declare function AmplifyUpProvider({ children, config, pageContext, }: AmplifyUpProviderProps): react_jsx_runtime.JSX.Element;
176
208
  declare function useAmplifyUp(): AmplifyUpContextType;
177
209
 
178
- export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, ComponentContextProvider, ContentSource, Field, Image, PageConfig, RichText, Slot, useAmplifyUp, useComponentProps, useLiveComposerProps };
210
+ export { AmplifyContentMeta, AmplifyPageContent, AmplifyUpProvider, Collection, CollectionField, ComponentContextProvider, ComposerProvider, ContentSource, Field, Field$1 as FieldEnvelope, Fields, Image, LayoutComponentProps, MaybeComposerProvider, PageConfig, RichText, Slot, useAmplifyUp };