soinproduction-gutenberg 0.1.10 → 0.1.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.
- package/README.md +15 -0
- package/adapters/wordpress/blueprint.ts +5 -3
- package/adapters/wordpress/renderer.php +1 -1
- package/core/fields/context.ts +7 -0
- package/core/fields/render.tsx +3 -3
- package/core/markup/element.ts +6 -0
- package/core/markup/only.tsx +22 -0
- package/dist/adapters/wordpress/blueprint.js +5 -3
- package/dist/adapters/wordpress/blueprint.js.map +2 -2
- package/dist/adapters/wordpress/renderer.php +1 -1
- package/dist/core/fields/context.d.ts +4 -0
- package/dist/core/fields/context.js +9 -0
- package/dist/core/fields/context.js.map +7 -0
- package/dist/core/fields/render.d.ts +2 -3
- package/dist/core/fields/render.js +3 -3
- package/dist/core/fields/render.js.map +3 -3
- package/dist/core/markup/element.d.ts +17 -0
- package/dist/core/markup/element.js +9 -0
- package/dist/core/markup/element.js.map +7 -0
- package/dist/core/markup/only.d.ts +20 -0
- package/dist/core/markup/only.js +12 -0
- package/dist/core/markup/only.js.map +7 -0
- package/dist/jsx-dev-runtime.d.ts +4 -0
- package/dist/jsx-dev-runtime.js +12 -0
- package/dist/jsx-dev-runtime.js.map +7 -0
- package/dist/jsx-runtime.d.ts +5 -0
- package/dist/jsx-runtime.js +17 -0
- package/dist/jsx-runtime.js.map +7 -0
- package/dist/tooling/jsx-only.mjs +17 -0
- package/dist/tooling/prepare-project.mjs +4 -2
- package/dist/tooling/smoke-package.mjs +3 -1
- package/jsx-dev-runtime.ts +12 -0
- package/jsx-runtime.ts +14 -0
- package/package.json +4 -2
- package/tooling/jsx-only.mjs +17 -0
- package/tooling/prepare-project.mjs +4 -2
- package/tooling/smoke-package.mjs +3 -1
- package/tsconfig.json +3 -1
package/README.md
CHANGED
|
@@ -158,3 +158,18 @@ Set `"sectionStyles": "isolated"` in `kit.config.json` to compile each section's
|
|
|
158
158
|
The existing `Section` root receives `data-site-section="site/slug"`. Compiled selectors are guarded by that owner without increasing specificity; keyframe names are unique to the section. Document state ancestors such as `html[data-motion]` still work. Keep reset rules, fonts and global custom properties in the shared entry. Use unique names for section `@theme` tokens; global directives such as `@font-face`, `@property`, `@utility` and `@apply` are rejected inside isolated section styles.
|
|
159
159
|
|
|
160
160
|
In a custom React block renderer, look up the actual block name in the generated manifest and render `<link rel="stylesheet" href={asset.href} precedence="site-sections" />` beside its View. React hoists and deduplicates the stylesheet and waits for it before revealing the section. For WordPress browser islands use `site.runtime.sectionStyleBase + asset.file` when that base is supplied. Do not import every section stylesheet from a registry. Gutenberg receives all isolated section styles so newly inserted sections work immediately; the WordPress build copies the assets and enqueues only section names found in the current page and its layout slots, including synced blocks.
|
|
161
|
+
|
|
162
|
+
## View-specific native wrappers
|
|
163
|
+
|
|
164
|
+
Enable `"jsxOnly": true` in `kit.config.json` and run Kit preparation once. It connects the Kit JSX runtime through the project's `jsxImportSource`. Existing consumers stay on their current runtime unless opted in; an unrelated custom runtime is never replaced automatically.
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
<div only="admin" className="relative">
|
|
168
|
+
<Background name="background" />
|
|
169
|
+
</div>
|
|
170
|
+
<a only="front" href="/services">
|
|
171
|
+
<span>Services</span>
|
|
172
|
+
</a>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`only="admin"` keeps the native HTML/SVG tag in the Gutenberg canvas and unwraps it on the frontend. `only="front"` does the reverse. Children remain in both views; the attribute never appears in rendered HTML. This changes wrappers, not field names or saved data. Ordinary tags without `only` retain standard React behavior, including keys and refs. The production and development JSX runtimes and the portable PHP renderer share these semantics.
|
|
@@ -15,15 +15,17 @@ function describe(node: ReactNode): any[] {
|
|
|
15
15
|
return Children.toArray(node).flatMap(child => {
|
|
16
16
|
if (!isValidElement(child)) return [{type: '#text', value: String(child)}];
|
|
17
17
|
if (child.type === Fragment) return describe((child.props as any).children);
|
|
18
|
-
const
|
|
18
|
+
const onlyTag = (child.type as any).kitOnlyTag === true;
|
|
19
|
+
const sourceProps = onlyTag ? (child.props as any).elementProps : child.props;
|
|
20
|
+
const props = {...sourceProps as any};
|
|
19
21
|
delete props.children;
|
|
20
|
-
const type = typeof child.type === 'string' ? child.type : (child.type as any).kitName;
|
|
22
|
+
const type = onlyTag ? (child.props as any).tag : typeof child.type === 'string' ? child.type : (child.type as any).kitName;
|
|
21
23
|
// Stateful project components mount through the existing browser island.
|
|
22
24
|
// Preserve declarative children as the PHP fallback, without serializing callback props.
|
|
23
25
|
if (!type) return [{type: 'ClientComponent', props: {}, children: describe((child.props as any).children)}];
|
|
24
26
|
if (type === 'Categories' && props.tab !== undefined) props.tab = describe(props.tab);
|
|
25
27
|
for (const [key, value] of Object.entries(props)) if (typeof value === 'function') throw new Error(`WordPress compiler: callback ${key} cannot be serialized`);
|
|
26
|
-
return [{type, props, children: describe((
|
|
28
|
+
return [{type, props, children: describe((sourceProps as any).children)}];
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -197,7 +197,7 @@ function node(array $node,array $context): string {
|
|
|
197
197
|
$value=$data[$p['name']??'']??null;$class=classes($p);
|
|
198
198
|
if($type==='ClientComponent')return nodes($children,$context);
|
|
199
199
|
if($type==='#text')return esc_html($node['value']);
|
|
200
|
-
if(ctype_lower(substr($type,0,1))){$attributes=$p;unset($attributes['children'],$attributes['className'],$attributes['adminClassName'],$attributes['frontClassName'],$attributes['initial']);if($class)$attributes['class']=$class;return tag($type,$attributes,nodes($children,$context));}
|
|
200
|
+
if(ctype_lower(substr($type,0,1))){if(($p['only']??'')==='admin')return nodes($children,$context);$attributes=$p;unset($attributes['only'],$attributes['children'],$attributes['className'],$attributes['adminClassName'],$attributes['frontClassName'],$attributes['initial']);if($class)$attributes['class']=$class;return tag($type,$attributes,nodes($children,$context));}
|
|
201
201
|
switch($type){
|
|
202
202
|
case 'Accordion':return tag('div',['class'=>$class,'data-disclosure-mode'=>$p['mode']??'accordion','data-icon-position'=>$p['iconPosition']??'after'],tag('div',['data-disclosure-items'=>true],nodes($children,array_replace($context,['disclosure'=>$p]))));
|
|
203
203
|
case 'AccordionItem':return tag('details',['class'=>$class,'data-disclosure-item'=>true,'open'=>($context['disclosure']['mode']??'')==='static'],nodes($children,$context));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import type { Scope } from './render.js';
|
|
4
|
+
|
|
5
|
+
/** Shared by field controls and the small view-specific JSX wrapper. */
|
|
6
|
+
export const FieldContext = createContext<Scope>({ schema: [], value: {}, site: {} });
|
|
7
|
+
export const useFieldScope = () => useContext(FieldContext);
|
package/core/fields/render.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { viewClasses, type ViewClasses } from './view-classes.js';
|
|
3
|
+
import { FieldContext, useFieldScope } from './context.js';
|
|
4
|
+
export { useFieldScope } from './context.js';
|
|
3
5
|
import type { ButtonAppearance } from '../ui/button-appearance.js';
|
|
4
6
|
import { LoadedCollection, type ListLoading } from '../ui/loaded-collection.js';
|
|
5
7
|
import { reorderListItems } from './list-order.js';
|
|
@@ -40,7 +42,7 @@ export type ContentRendererProps = {
|
|
|
40
42
|
blocks: ContentBlock[];
|
|
41
43
|
options?: { fixedLayout?: boolean };
|
|
42
44
|
};
|
|
43
|
-
type Scope = {
|
|
45
|
+
export type Scope = {
|
|
44
46
|
Content?: ComponentType<ContentRendererProps>;
|
|
45
47
|
resolvedValue?: Record<string, any>;
|
|
46
48
|
schema: FieldDefinition[];
|
|
@@ -74,7 +76,6 @@ export type EditField = (
|
|
|
74
76
|
nested?: boolean;
|
|
75
77
|
}
|
|
76
78
|
) => ReactNode;
|
|
77
|
-
const FieldContext = createContext<Scope>({ schema: [], value: {}, site: {} });
|
|
78
79
|
const RecordContext = createContext<any>({});
|
|
79
80
|
const RecordLinkContext = createContext<{ url: string; setUrl?: (url: string) => void } | null>(null);
|
|
80
81
|
/** Rich-text link tools inside RecordLink target its outer URL. */
|
|
@@ -89,7 +90,6 @@ export function FieldScope({ children, ...scope }: Scope & { children: ReactNode
|
|
|
89
90
|
<FieldContext.Provider value={{ ...scope, resolvedValue }}>{children}</FieldContext.Provider>
|
|
90
91
|
);
|
|
91
92
|
}
|
|
92
|
-
export const useFieldScope = () => useContext(FieldContext);
|
|
93
93
|
export function useValues() {
|
|
94
94
|
const scope = useContext(FieldContext);
|
|
95
95
|
return scope.resolvedValue ?? valuesFor(scope.schema, scope.value, scope.site, scope.record);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OnlyTag } from './only.js';
|
|
2
|
+
|
|
3
|
+
export function onlyElement(type: any, props: any, key?: any) {
|
|
4
|
+
if (typeof type !== 'string' || (props?.only !== 'admin' && props?.only !== 'front')) return null;
|
|
5
|
+
return { type: OnlyTag, props: { tag: type, elementProps: props, children: props.children }, key: props.key !== undefined ? props.key : key };
|
|
6
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createElement, type ReactNode } from 'react';
|
|
3
|
+
import { useFieldScope } from '../fields/context.js';
|
|
4
|
+
|
|
5
|
+
export type OnlyView = 'admin' | 'front';
|
|
6
|
+
declare module 'react' {
|
|
7
|
+
interface HTMLAttributes<T> { only?: OnlyView; }
|
|
8
|
+
interface SVGAttributes<T> { only?: OnlyView; }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The opposite view keeps children, without mounting an extra DOM wrapper. */
|
|
12
|
+
export const OnlyTag = Object.assign(function OnlyTag({ tag, elementProps }: {
|
|
13
|
+
tag: string;
|
|
14
|
+
elementProps: Record<string, any> & { only: OnlyView; children?: ReactNode };
|
|
15
|
+
}) {
|
|
16
|
+
const { edit } = useFieldScope();
|
|
17
|
+
const { only, children, ...attributes } = elementProps;
|
|
18
|
+
return only === (edit ? 'admin' : 'front')
|
|
19
|
+
? createElement(tag, attributes, children)
|
|
20
|
+
: children ?? null;
|
|
21
|
+
}, { kitOnlyTag: true });
|
|
22
|
+
|
|
@@ -5,13 +5,15 @@ function describe(node) {
|
|
|
5
5
|
return Children.toArray(node).flatMap((child) => {
|
|
6
6
|
if (!isValidElement(child)) return [{ type: "#text", value: String(child) }];
|
|
7
7
|
if (child.type === Fragment) return describe(child.props.children);
|
|
8
|
-
const
|
|
8
|
+
const onlyTag = child.type.kitOnlyTag === true;
|
|
9
|
+
const sourceProps = onlyTag ? child.props.elementProps : child.props;
|
|
10
|
+
const props = { ...sourceProps };
|
|
9
11
|
delete props.children;
|
|
10
|
-
const type = typeof child.type === "string" ? child.type : child.type.kitName;
|
|
12
|
+
const type = onlyTag ? child.props.tag : typeof child.type === "string" ? child.type : child.type.kitName;
|
|
11
13
|
if (!type) return [{ type: "ClientComponent", props: {}, children: describe(child.props.children) }];
|
|
12
14
|
if (type === "Categories" && props.tab !== void 0) props.tab = describe(props.tab);
|
|
13
15
|
for (const [key, value] of Object.entries(props)) if (typeof value === "function") throw new Error(`WordPress compiler: callback ${key} cannot be serialized`);
|
|
14
|
-
return [{ type, props, children: describe(
|
|
16
|
+
return [{ type, props, children: describe(sourceProps.children) }];
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
19
|
function section(meta, View) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../adapters/wordpress/blueprint.ts"],
|
|
4
|
-
"sourcesContent": ["import {Children, Fragment, isValidElement, type ReactNode} from 'react';\n\nconst marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});\nexport const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),\n Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),\n Background = marker('Background'), Buttons = marker('Buttons'), SocialLinks = marker('SocialLinks'), Button = marker('Button'), List = marker('List'),\n PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), Categories = marker('Categories'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),\n RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),\n RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),\n Choice = marker('Choice'), Show = marker('Show'), Area = marker('Area'), Gallery = marker('Gallery'),\n Accordion = marker('Accordion'), AccordionItem = marker('AccordionItem'), AccordionTrigger = marker('AccordionTrigger'), AccordionContent = marker('AccordionContent'), AccordionProgress = marker('AccordionProgress'),\n Slider = marker('Slider'), SliderButton = marker('SliderButton'), SliderPagination = marker('SliderPagination'), RecordText = marker('RecordText'), RecordContent = marker('RecordContent'), Media = marker('Media');\n\nfunction describe(node: ReactNode): any[] {\n return Children.toArray(node).flatMap(child => {\n if (!isValidElement(child)) return [{type: '#text', value: String(child)}];\n if (child.type === Fragment) return describe((child.props as any).children);\n const
|
|
5
|
-
"mappings": "AAAA,SAAQ,UAAU,UAAU,sBAAqC;AAEjE,MAAM,SAAS,CAAC,SAAiB,OAAO,OAAO,CAAC,WAAgB,MAAM,EAAC,SAAS,KAAI,CAAC;AAC9E,MAAM,UAAU,OAAO,SAAS,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACvF,aAAa,OAAO,YAAY,GAAG,QAAQ,OAAO,OAAO,GAAG,OAAO,OAAO,MAAM,GAChF,aAAa,OAAO,YAAY,GAAG,UAAU,OAAO,SAAS,GAAG,cAAc,OAAO,aAAa,GAAG,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GACpJ,eAAe,OAAO,cAAc,GAAG,kBAAkB,OAAO,iBAAiB,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GAAG,aAAa,OAAO,YAAY,GAAG,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAChP,aAAa,OAAO,YAAY,GAAG,cAAc,OAAO,aAAa,GAAG,gBAAgB,OAAO,eAAe,GAAG,aAAa,OAAO,YAAY,GACjJ,cAAc,OAAO,aAAa,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,SAAS,OAAO,QAAQ,GAC3G,SAAS,OAAO,QAAQ,GAAG,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,UAAU,OAAO,SAAS,GACnG,YAAY,OAAO,WAAW,GAAG,gBAAgB,OAAO,eAAe,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,oBAAoB,OAAO,mBAAmB,GACtN,SAAS,OAAO,QAAQ,GAAG,eAAe,OAAO,cAAc,GAAG,mBAAmB,OAAO,kBAAkB,GAAG,aAAa,OAAO,YAAY,GAAG,gBAAgB,OAAO,eAAe,GAAG,QAAQ,OAAO,OAAO;AAEvN,SAAS,SAAS,MAAwB;AACtC,SAAO,SAAS,QAAQ,IAAI,EAAE,QAAQ,WAAS;AAC3C,QAAI,CAAC,eAAe,KAAK,EAAG,QAAO,CAAC,EAAC,MAAM,SAAS,OAAO,OAAO,KAAK,EAAC,CAAC;AACzE,QAAI,MAAM,SAAS,SAAU,QAAO,SAAU,MAAM,MAAc,QAAQ;AAC1E,UAAM,QAAQ,EAAC,GAAG,
|
|
4
|
+
"sourcesContent": ["import {Children, Fragment, isValidElement, type ReactNode} from 'react';\n\nconst marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});\nexport const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),\n Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),\n Background = marker('Background'), Buttons = marker('Buttons'), SocialLinks = marker('SocialLinks'), Button = marker('Button'), List = marker('List'),\n PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), Categories = marker('Categories'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),\n RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),\n RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),\n Choice = marker('Choice'), Show = marker('Show'), Area = marker('Area'), Gallery = marker('Gallery'),\n Accordion = marker('Accordion'), AccordionItem = marker('AccordionItem'), AccordionTrigger = marker('AccordionTrigger'), AccordionContent = marker('AccordionContent'), AccordionProgress = marker('AccordionProgress'),\n Slider = marker('Slider'), SliderButton = marker('SliderButton'), SliderPagination = marker('SliderPagination'), RecordText = marker('RecordText'), RecordContent = marker('RecordContent'), Media = marker('Media');\n\nfunction describe(node: ReactNode): any[] {\n return Children.toArray(node).flatMap(child => {\n if (!isValidElement(child)) return [{type: '#text', value: String(child)}];\n if (child.type === Fragment) return describe((child.props as any).children);\n const onlyTag = (child.type as any).kitOnlyTag === true;\n const sourceProps = onlyTag ? (child.props as any).elementProps : child.props;\n const props = {...sourceProps as any};\n delete props.children;\n const type = onlyTag ? (child.props as any).tag : typeof child.type === 'string' ? child.type : (child.type as any).kitName;\n // Stateful project components mount through the existing browser island.\n // Preserve declarative children as the PHP fallback, without serializing callback props.\n if (!type) return [{type: 'ClientComponent', props: {}, children: describe((child.props as any).children)}];\n if (type === 'Categories' && props.tab !== undefined) props.tab = describe(props.tab);\n for (const [key, value] of Object.entries(props)) if (typeof value === 'function') throw new Error(`WordPress compiler: callback ${key} cannot be serialized`);\n return [{type, props, children: describe((sourceProps as any).children)}];\n });\n}\n\nexport function section(meta: any, View: () => ReactNode) {\n const template = describe(View());\n const mark=(nodes:any[])=>{for(const node of nodes){if(node.type==='Section')node.props['data-site-section']='site/'+meta.slug;mark(node.children??[]);}};mark(template);\n const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','SocialLinks','Button','Show','Toggle','Choice']);\n const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^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,SAAQ,WAAU,QAAO,WAAU,cAAa,SAAQ,QAAO,cAAa,WAAU,eAAc,UAAS,QAAO,UAAS,QAAQ,CAAC;AACnK,QAAM,WAAW,CAAC,UAAwB,MAAM,MAAM,WAAS,YAAY,IAAI,KAAK,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI,MAAM,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC;AACvJ,SAAO,EAAC,MAAM,UAAU,KAAK,MAAM,OAAO,KAAK,OAAO,UAAU,QAAQ,SAAS,QAAQ,EAAC;AAC9F;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -197,7 +197,7 @@ function node(array $node,array $context): string {
|
|
|
197
197
|
$value=$data[$p['name']??'']??null;$class=classes($p);
|
|
198
198
|
if($type==='ClientComponent')return nodes($children,$context);
|
|
199
199
|
if($type==='#text')return esc_html($node['value']);
|
|
200
|
-
if(ctype_lower(substr($type,0,1))){$attributes=$p;unset($attributes['children'],$attributes['className'],$attributes['adminClassName'],$attributes['frontClassName'],$attributes['initial']);if($class)$attributes['class']=$class;return tag($type,$attributes,nodes($children,$context));}
|
|
200
|
+
if(ctype_lower(substr($type,0,1))){if(($p['only']??'')==='admin')return nodes($children,$context);$attributes=$p;unset($attributes['only'],$attributes['children'],$attributes['className'],$attributes['adminClassName'],$attributes['frontClassName'],$attributes['initial']);if($class)$attributes['class']=$class;return tag($type,$attributes,nodes($children,$context));}
|
|
201
201
|
switch($type){
|
|
202
202
|
case 'Accordion':return tag('div',['class'=>$class,'data-disclosure-mode'=>$p['mode']??'accordion','data-icon-position'=>$p['iconPosition']??'after'],tag('div',['data-disclosure-items'=>true],nodes($children,array_replace($context,['disclosure'=>$p]))));
|
|
203
203
|
case 'AccordionItem':return tag('details',['class'=>$class,'data-disclosure-item'=>true,'open'=>($context['disclosure']['mode']??'')==='static'],nodes($children,$context));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const FieldContext = createContext({ schema: [], value: {}, site: {} });
|
|
4
|
+
const useFieldScope = () => useContext(FieldContext);
|
|
5
|
+
export {
|
|
6
|
+
FieldContext,
|
|
7
|
+
useFieldScope
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../core/fields/context.ts"],
|
|
4
|
+
"sourcesContent": ["'use client';\nimport { createContext, useContext } from 'react';\nimport type { Scope } from './render.js';\n\n/** Shared by field controls and the small view-specific JSX wrapper. */\nexport const FieldContext = createContext<Scope>({ schema: [], value: {}, site: {} });\nexport const useFieldScope = () => useContext(FieldContext);\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,eAAe,kBAAkB;AAInC,MAAM,eAAe,cAAqB,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC;AAC7E,MAAM,gBAAgB,MAAM,WAAW,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ViewClasses } from './view-classes.js';
|
|
2
|
+
export { useFieldScope } from './context.js';
|
|
2
3
|
import type { ButtonAppearance } from '../ui/button-appearance.js';
|
|
3
4
|
import { type ListLoading } from '../ui/loaded-collection.js';
|
|
4
5
|
import type { ContentBlock } from '../content/context.js';
|
|
@@ -10,7 +11,7 @@ export type ContentRendererProps = {
|
|
|
10
11
|
fixedLayout?: boolean;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
|
-
type Scope = {
|
|
14
|
+
export type Scope = {
|
|
14
15
|
Content?: ComponentType<ContentRendererProps>;
|
|
15
16
|
resolvedValue?: Record<string, any>;
|
|
16
17
|
schema: FieldDefinition[];
|
|
@@ -51,7 +52,6 @@ export declare function useRelatedRecord(): any;
|
|
|
51
52
|
export declare function FieldScope({ children, ...scope }: Scope & {
|
|
52
53
|
children: ReactNode;
|
|
53
54
|
}): import("react").JSX.Element;
|
|
54
|
-
export declare const useFieldScope: () => Scope;
|
|
55
55
|
export declare function useValues(): any;
|
|
56
56
|
export declare function useField(name: FieldProps['name']): {
|
|
57
57
|
field: FieldDefinition;
|
|
@@ -146,4 +146,3 @@ export declare function ContentArea({ name, className, children, as: Tag, style,
|
|
|
146
146
|
};
|
|
147
147
|
children?: (content: ReactNode) => ReactNode;
|
|
148
148
|
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
149
|
-
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { viewClasses } from "./view-classes.js";
|
|
4
|
+
import { FieldContext, useFieldScope } from "./context.js";
|
|
5
|
+
import { useFieldScope as useFieldScope2 } from "./context.js";
|
|
4
6
|
import { LoadedCollection } from "../ui/loaded-collection.js";
|
|
5
7
|
import { reorderListItems } from "./list-order.js";
|
|
6
8
|
import { ParagraphFlow } from "../content/paragraphs.js";
|
|
@@ -31,7 +33,6 @@ import {
|
|
|
31
33
|
useRef,
|
|
32
34
|
useState
|
|
33
35
|
} from "react";
|
|
34
|
-
const FieldContext = createContext({ schema: [], value: {}, site: {} });
|
|
35
36
|
const RecordContext = createContext({});
|
|
36
37
|
const RecordLinkContext = createContext(null);
|
|
37
38
|
const useRecordLink = () => useContext(RecordLinkContext);
|
|
@@ -45,7 +46,6 @@ function FieldScope({ children, ...scope }) {
|
|
|
45
46
|
);
|
|
46
47
|
return /* @__PURE__ */ jsx(FieldContext.Provider, { value: { ...scope, resolvedValue }, children });
|
|
47
48
|
}
|
|
48
|
-
const useFieldScope = () => useContext(FieldContext);
|
|
49
49
|
function useValues() {
|
|
50
50
|
const scope = useContext(FieldContext);
|
|
51
51
|
return scope.resolvedValue ?? valuesFor(scope.schema, scope.value, scope.site, scope.record);
|
|
@@ -519,7 +519,7 @@ export {
|
|
|
519
519
|
renderField,
|
|
520
520
|
renderFields,
|
|
521
521
|
useField,
|
|
522
|
-
useFieldScope,
|
|
522
|
+
useFieldScope2 as useFieldScope,
|
|
523
523
|
useRecordLink,
|
|
524
524
|
useRelatedRecord,
|
|
525
525
|
useValues
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../core/fields/render.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\nimport { viewClasses, type ViewClasses } from './view-classes.js';\nimport type { ButtonAppearance } from '../ui/button-appearance.js';\nimport { LoadedCollection, type ListLoading } from '../ui/loaded-collection.js';\nimport { reorderListItems } from './list-order.js';\nimport { ParagraphFlow } from '../content/paragraphs.js';\nimport { UniversalMedia } from '../media/universal/component.js';\nimport { recordUrl } from '../content/links.js';\nimport { areaBlocks } from '../content/areas/data.js';\nimport { NativeAreaContent } from '../content/areas/render.js';\nimport type { ContentBlock } from '../content/context.js';\nimport { ContentContext } from '../content/context.js';\nimport { richText as richNodes } from '../content/rich-text.js';\nimport { relationshipRecords, latestRecords, recordDate, safeUrl } from './records.js';\nimport type { FieldDefinition } from './schema.js';\nimport { emptyValue } from './schema.js';\nimport { fieldAt, valuesFor } from './values.js';\nimport { ButtonLabel } from '../icons/button.js';\nimport { Icon } from '../icons/icon.js';\nimport { LibraryImage } from '../media/image.js';\nimport { selectedRecords } from '../relationships/selection.js';\nimport { recordTitleAffixes, updateRecordTitleAffixes, recordTitleHtml, splitRecordTitleLabel } from './record-title.js';\nimport { recordLinkUrl, withoutRecordLinks } from './record-link.js';\nimport { atPath, setPath } from '../utils/path.js';\nimport { modalHref } from '../utils/url.js';\nimport {\n createContext,\n createElement,\n useContext,\n useMemo,\n useId,\n useEffect,\n useRef,\n useState,\n type ComponentType,\n type ElementType,\n type ReactNode,\n} from 'react';\nexport type ContentRendererProps = {\n blocks: ContentBlock[];\n options?: { fixedLayout?: boolean };\n};\ntype Scope = {\n Content?: ComponentType<ContentRendererProps>;\n resolvedValue?: Record<string, any>;\n schema: FieldDefinition[];\n value: Record<string, any>;\n site: any;\n onChange?: (next: any) => void;\n edit?: EditField;\n record?: any;\n blockName?: string;\n extensions?: Record<string, any>;\n renderCustomField?: (props: any, scope: any) => ReactNode;\n};\nexport type FieldProps = {\n name: string | (string | number)[];\n inline?: boolean;\n editor?: boolean;\n value?: any;\n localized?: boolean | string;\n imageProps?: React.ImgHTMLAttributes<HTMLImageElement>;\n options?: any;\n as?: ElementType;\n className?: string;\n children?: ReactNode;\n};\nexport type EditField = (\n props: FieldProps & {\n field: FieldDefinition;\n value: any;\n setValue: (value: any) => void;\n site: any;\n nested?: boolean;\n }\n) => ReactNode;\nconst FieldContext = createContext<Scope>({ schema: [], value: {}, site: {} });\nconst RecordContext = createContext<any>({});\nconst RecordLinkContext = createContext<{ url: string; setUrl?: (url: string) => void } | null>(null);\n/** Rich-text link tools inside RecordLink target its outer URL. */\nexport const useRecordLink = () => useContext(RecordLinkContext);\nexport function useRelatedRecord(){ return useContext(RecordContext); }\nexport function FieldScope({ children, ...scope }: Scope & { children: ReactNode }) {\n const resolvedValue = useMemo(\n () => scope.resolvedValue ?? valuesFor(scope.schema, scope.value, scope.site, scope.record),\n [scope.resolvedValue, scope.schema, scope.value, scope.site, scope.record]\n );\n return (\n <FieldContext.Provider value={{ ...scope, resolvedValue }}>{children}</FieldContext.Provider>\n );\n}\nexport const useFieldScope = () => useContext(FieldContext);\nexport function useValues() {\n const scope = useContext(FieldContext);\n return scope.resolvedValue ?? valuesFor(scope.schema, scope.value, scope.site, scope.record);\n}\nexport function useField(name: FieldProps['name']) {\n const scope = useContext(FieldContext),\n path = Array.isArray(name) ? name : [name];\n const root = scope.schema.find((f) => f.name === path[0]);\n const field =\n fieldAt(scope.schema, path) ??\n (root && path.length > 1\n ? { name: String(path.at(-1)), type: 'richText' as const }\n : undefined);\n if (!field) throw new Error(`Field \"${path.join('.')}\" is missing from schema.ts`);\n const data =\n scope.resolvedValue ?? valuesFor(scope.schema, scope.value, scope.site, scope.record);\n const value =\n atPath(path.length > 1 || field.recordField || field.recordMeta ? data : scope.value, path) ??\n (path.length === 1 ? data[path[0]] : emptyValue(field));\n const stored = { ...scope.value };\n for (const definition of scope.schema)\n if (definition.recordField || definition.recordMeta)\n stored[definition.name] = data[definition.name];\n const setValue = (next: any) => {\n if (root?.type === 'relationship' && root.resolveRecords && typeof path[1] === 'number') {\n const record = data[path[0]]?.[path[1]],\n selection = scope.value[path[0]] ?? { mode: 'all' };\n if (selection.mode === 'manual') {\n scope.onChange?.(setPath(stored, [path[0], 'items', ...path.slice(1)], next));\n return;\n }\n if (record?.id) {\n scope.onChange?.(\n setPath(stored, [path[0], 'overrides', String(record.id), ...path.slice(2)], next)\n );\n return;\n }\n }\n scope.onChange?.(setPath(stored, path, next));\n };\n return { ...scope, field, value, setValue };\n}\nexport function ListActions({ name, index }: { name: FieldProps['name']; index?: number }) {\n const scope = useField(name);\n if ((scope.field.type === 'relationship' && scope.field.resolveRecords) || scope.field.readOnly)\n return null;\n return scope.edit\n ? scope.edit({\n name,\n field: { ...scope.field, type: 'custom', control: 'list-actions' },\n value: scope.value,\n setValue: scope.setValue,\n site: scope.site,\n options: { index, itemType: scope.field.itemType, fields: scope.field.fields },\n })\n : null;\n}\nexport function EditorRecordLink({ id, label, className }: { id: number; label: string; className?: string }) {\n const scope = useContext(FieldContext);\n return scope.edit\n ? scope.edit({\n name: '',\n className,\n field: { name: '', type: 'custom', control: 'edit-record' },\n value: id,\n setValue: () => {},\n site: scope.site,\n options: { label },\n })\n : null;\n}\nexport function actionUrl(value: any, site: any) {\n const modal = (site.modals ?? []).find((m: any) => Number(m.id) === Number(value?.modalId));\n return value?.modalId\n ? modal\n ? modalHref(modal)\n : ''\n : safeUrl(value?.linkId ? recordUrl(site, value.linkId) : value?.url);\n}\nexport function Action({ value, site = {}, className = '' }: any) {\n const url = actionUrl(value, site);\n if (!url || !value?.text) return null;\n return (\n <a\n href={url}\n className={'wp-block-button__link ' + className}\n data-modal-plan={value.plan || undefined}\n >\n <ButtonLabel\n attributes={{\n metadata: {\n siteButtonIcon: value.icon,\n siteButtonIconPosition: value.iconPosition,\n },\n }}\n >\n {richNodes(value.text)}\n </ButtonLabel>\n </a>\n );\n}\nexport function renderField(\n field: FieldDefinition,\n value: any,\n site: any = {},\n props: Omit<FieldProps, 'name'> = {}\n): ReactNode {\n const Tag = props.as ?? field.tag ?? (field.type === 'richText' ? 'div' : 'span');\n const className = props.className;\n switch (field.type) {\n case 'group':\n return <div className={className}>{renderFields(field.fields ?? [], value ?? {}, site)}</div>;\n case 'repeater':\n return (\n <div className={className ?? 'grid gap-6 for-small-tablet:grid-cols-3'}>\n {(Array.isArray(value) ? value : []).map((row: any, index: number) => (\n <article key={index}>{renderFields(field.fields ?? [], row, site)}</article>\n ))}\n </div>\n );\n case 'relationship':\n return (\n <FieldScope schema={[field]} value={{ [field.name]: value }} site={site}>\n <Relationship name={field.name} className={className}>\n <article>\n <RecordImage />\n <RecordTitle />\n <RecordExcerpt />\n <RecordLink>Read more</RecordLink>\n </article>\n </Relationship>\n </FieldScope>\n );\n\n case 'content':\n case 'custom':\n return props.children ?? null;\n case 'media':\n return <UniversalMedia value={value} className={className} editor={!!props.editor} />;\n case 'image': {\n const image =\n typeof value === 'string' ? { url: value, alt: props.imageProps?.alt ?? '' } : value;\n return image?.url ? (\n <LibraryImage\n {...props.imageProps}\n src={image.url}\n alt={image.alt ?? ''}\n className={className ?? props.imageProps?.className}\n />\n ) : null;\n }\n case 'gallery':\n return (\n <div className={className ?? 'grid gap-4 for-small-tablet:grid-cols-3'}>\n {(Array.isArray(value) ? value : []).map((image: any, i: number) => (\n <LibraryImage\n key={image.id ?? i}\n src={image.url}\n alt={image.alt ?? ''}\n className=\"w-full object-cover\"\n />\n ))}\n </div>\n );\n case 'icon':\n return value ? (\n <span className={className}>\n <Icon icon={{ type: value }} />\n </span>\n ) : null;\n case 'wysiwyg':\n return (\n <ParagraphFlow\n value={Array.isArray(value) ? value : []}\n className={className}\n paragraphClass={props.options?.paragraphClass}\n />\n );\n case 'buttons':\n return (\n <div className={'site-actions ' + (className ?? 'flex flex-wrap gap-3')}>\n {(Array.isArray(value) ? value : []).map((button: any, i: number) => (\n <Action key={i} value={button} site={site} />\n ))}\n </div>\n );\n case 'link':\n return <Action value={value} site={site} className={className} />;\n case 'toggle':\n return value\n ? createElement(Tag, { className }, props.children ?? field.label ?? field.name)\n : null;\n case 'color':\n return null;\n case 'richText':\n return props.inline ? (\n <>{richNodes(props.value ?? value)}</>\n ) : (\n createElement(Tag, { className }, richNodes(value))\n );\n default: {\n const text = props.localized\n ? Number(props.value ?? value ?? 0).toLocaleString(\n typeof props.localized === 'string' ? props.localized : undefined\n )\n : String(value ?? '');\n return props.inline ? <>{text}</> : createElement(Tag, { className }, text);\n }\n }\n}\nexport function Field(props: FieldProps) {\n const { field, value, setValue, edit, site } = useField(props.name);\n const definition = props.imageProps\n ? { ...field, type: 'image' as const, storage: 'url' as const }\n : props.inline\n ? { ...field, type: props.localized ? ('number' as const) : ('richText' as const) }\n : field;\n const current = props.imageProps?.src ?? props.value ?? value;\n return (\n <>\n {edit\n ? edit({ ...props, field: definition, value: current, setValue, site })\n : renderField(definition, current, site, props)}\n </>\n );\n}\nexport function Group({ name, children, className }: FieldProps) {\n const scope = useField(name);\n return (\n <div className={className}>\n <FieldScope\n {...scope}\n schema={scope.field.fields ?? []}\n value={scope.value}\n onChange={scope.setValue}\n >\n {children}\n </FieldScope>\n </div>\n );\n}\nexport function Repeater({ name, children, className, renderRow, addText, appender, offset = 0, limit, itemFocusKey, perPage, loading, loadMoreButton }: FieldProps & { loadMoreButton?: ButtonAppearance; perPage?: number; loading?: ListLoading; itemFocusKey?: string; offset?: number; limit?: number; appender?: ReactNode; renderRow?: (row: ReactNode, index: number) => ReactNode; addText?: string }) {\n const scope = useField(name);\n const rows = Array.isArray(scope.value) ? scope.value : [];\n const grouped = Boolean(scope.field.controlOptions?.itemPanels);\n const settings = scope.field.fields?.filter(field => field.settings || (grouped && ['image','link'].includes(field.type))) ?? [];\n const id=useId().replace(/[^a-zA-Z0-9_-]/g,'');\n const root=useFieldScope();\n const render=(offset:number,limit?:number) => (\n <>\n <div className={className ?? 'grid gap-6 for-small-tablet:grid-cols-3'}>\n {rows.slice(offset, limit === undefined ? undefined : offset + limit).map((row: any, visibleIndex: number) => {\n const index = offset + visibleIndex;\n return (\n <FieldScope\n key={index}\n {...scope}\n resolvedValue={undefined}\n schema={scope.field.fields ?? []}\n value={row}\n edit={scope.edit ? (props) => scope.edit!({ ...props, nested: true, options: { ...props.options, itemPanel: grouped, itemFocusKey: itemFocusKey ? `${itemFocusKey}-${index}` : undefined } }) : undefined}\n onChange={(next) =>\n scope.setValue(rows.map((old: any, i: number) => (i === index ? next : old)))\n }\n >\n {renderRow ? renderRow(children, index) : children}\n {scope.edit && settings.length > 0 && scope.edit({\n name,\n options: {\n itemFocusKey: itemFocusKey ? `${itemFocusKey}-${index}` : undefined,\n listKey: itemFocusKey, index, total: rows.length,\n onMove: (from: number, target: number) => scope.setValue(reorderListItems(rows, from, target)),\n },\n field: { name: scope.field.name, type: 'custom', control: 'row-settings', label: `Item ${index + 1}`, fields: settings },\n value: row,\n setValue: next => scope.setValue(rows.map((old: any, i: number) => i === index ? next : old)),\n site: scope.site,\n })}\n </FieldScope>\n ); })}\n {appender}\n </div>\n {scope.edit && appender === undefined &&\n scope.edit({\n name,\n field: scope.field,\n value: rows,\n setValue: scope.setValue,\n site: scope.site,\n options: { addText },\n })}\n </>\n );\n return !scope.edit && loading ? <LoadedCollection pageKey={`list-${root.value.sectionId||id}-${name}`} total={rows.length} perPage={perPage} loading={loading} loadMoreButton={loadMoreButton}>{window=>render(window.offset,window.limit)}</LoadedCollection> : render(offset,limit);\n}\nexport function Relationship({ name, children, className, options, perPage, loading, loadMoreButton }: FieldProps & { loadMoreButton?: ButtonAppearance; perPage?: number; loading?: ListLoading }) {\n const scope = useField(name);\n const library=relationshipRecords(scope.field,scope.site);\n const source=scope.field.controlOptions??{};\n const latest=Number(source.latest)>0&&useValues()[String(source.modeField)]!=='manual';\n const records = latest?latestRecords(library,Number(source.latest)):selectedRecords(scope.value,library);\n const update = (record: any, patch: any, transform?: (data: any) => any) => {\n const rows = scope.value.map((item: any) => item === record ? { ...item, ...patch } : item);\n if (!transform) return scope.setValue(rows);\n root.onChange?.(transform(setPath(root.value, Array.isArray(name) ? name : [name], rows)));\n };\n const id=useId().replace(/[^a-zA-Z0-9_-]/g,'');\n const root=useFieldScope();\n const render=(offset=0,limit=records.length) => (\n <div {...options?.containerProps} ref={options?.rootRef} className={className ?? 'grid gap-6 for-small-tablet:grid-cols-3'}>\n {records.slice(offset,offset+limit).map((record, visibleIndex) => (\n <RecordContext.Provider\n key={record.id}\n value={{ ...record, index:offset+visibleIndex, update: (patch: any, transform?: (data: any) => any) => update(record, patch, transform) }}\n >\n {children}\n </RecordContext.Provider>\n ))}\n {scope.edit &&\n scope.edit({\n name,\n field: scope.field,\n value: scope.value,\n setValue: scope.setValue,\n site: scope.site,\n options: {\n ...options,\n // An empty copy of the record's markup gives the add tile the exact card size.\n shape: options?.shape ?? (\n <RecordContext.Provider value={{ index: records.length, title: '', excerpt: '' }}>\n {children}\n </RecordContext.Provider>\n ),\n },\n })}\n </div>\n );\n return !scope.edit && loading ? <LoadedCollection pageKey={`list-${root.value.sectionId||id}-${name}`} total={records.length} perPage={perPage} loading={loading} loadMoreButton={loadMoreButton}>{window=>render(window.offset,window.limit)}</LoadedCollection> : render();\n}\nexport function RecordImage({ replay = false, ...classes }: ViewClasses & { replay?: boolean }) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record = useContext(RecordContext);\n const { edit, site } = useContext(FieldContext);\n const imageRef = useRef<HTMLImageElement>(null), [version, setVersion] = useState(0);\n useEffect(() => {\n if (!replay || edit) return;\n const item = imageRef.current?.closest('[data-record-item]');\n const restart = () => setVersion(value => value + 1);\n item?.addEventListener('kit:record-replay', restart);\n return () => item?.removeEventListener('kit:record-replay', restart);\n }, [replay, Boolean(edit), record.id, record.image]);\n const image = record.image ? (\n <LibraryImage key={version} ref={imageRef} src={record.image} alt={record.alt ?? ''} className={className} />\n ) : null;\n if (!record.manual || !edit) return image;\n return (\n <>\n {image}\n {edit({\n name: 'image',\n field: { name: 'image', type: 'custom', control: 'record-tools' },\n value: record,\n setValue: record.update,\n site,\n })}\n </>\n );\n}\n/** A hand-written record is edited on the canvas like any other text. */\nfunction ManualText({ name, label, as, className }: { name: string; label: string; as: ElementType; className?: string }) {\n const record = useContext(RecordContext);\n const scope = useContext(FieldContext), link = useRecordLink();\n return scope.edit!({\n name,\n as,\n className,\n nested: true,\n field: { name, label, type: 'richText' },\n value: link ? withoutRecordLinks(record[name]) : record[name],\n setValue: (value) => record.update({ [name]: link ? withoutRecordLinks(value) : value }),\n site: scope.site,\n });\n}\n/** The whole label has one cursor and toolbar; affixes remain defaults that can be erased. */\nexport function RecordTitle({ as = 'h3', name = 'title', label = 'Title text', beforeText: defaultBefore, afterText: defaultAfter, ...classes }: ViewClasses & { as?: ElementType; name?: string; label?: string; beforeText?: string; afterText?: string }) {\n const scope = useFieldScope(), className = viewClasses(classes, Boolean(scope.edit)), link = useRecordLink();\n const record = useContext(RecordContext);\n const configurable = defaultBefore !== undefined || defaultAfter !== undefined;\n const { beforeText = '', afterText = '' } = configurable ? recordTitleAffixes(scope.value, name, { beforeText: defaultBefore, afterText: defaultAfter }) : {};\n const saved = configurable ? scope.value.__recordTitles?.[name] ?? {} : {};\n const beforeHtml = typeof saved.beforeHtml === 'string' ? saved.beforeHtml : recordTitleHtml(beforeText);\n const afterHtml = typeof saved.afterHtml === 'string' ? saved.afterHtml : recordTitleHtml(afterText);\n const sourceTitle = typeof record.title === 'object' ? record.title?.rendered : record.title;\n const title = configurable && !record.manual ? scope.value.__recordTitles?.[name]?.titles?.[String(record.id)] ?? sourceTitle : sourceTitle;\n if (scope.edit && configurable && record.id) {\n const text = link ? withoutRecordLinks(title) : String(title ?? '');\n return scope.edit({\n name: ['__recordTitles', name], as, inline: as === 'span', nested: true, className,\n field: { name, label, type: 'richText', placeholder: label + '\u2026' },\n value: beforeHtml + text + afterHtml,\n setValue: html => {\n const next = splitRecordTitleLabel(beforeText, text, afterText, link ? withoutRecordLinks(html) : html);\n const save = (data: any) => updateRecordTitleAffixes(data, name, {\n beforeText: next.beforeText, afterText: next.afterText, beforeHtml: next.beforeHtml, afterHtml: next.afterHtml,\n ...(!record.manual && next.title !== text ? { titles: { ...data.__recordTitles?.[name]?.titles, [String(record.id)]: next.title } } : {}),\n });\n if (record.update) record.update(record.manual ? { title: next.title } : {}, save);\n else scope.onChange?.(save(scope.value));\n }, site: scope.site,\n });\n }\n if (record.manual && scope.edit) return <ManualText name=\"title\" label=\"Title\" as={as} className={className} />;\n return createElement(as, { className}, richNodes(beforeHtml, { links: !link }), richNodes(title, { links: !link }), richNodes(afterHtml, { links: !link }));\n}\nexport function RecordExcerpt(classes: ViewClasses) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record = useContext(RecordContext);\n const { edit } = useContext(FieldContext);\n if (record.manual && edit) return <ManualText name=\"excerpt\" label=\"Description\" as=\"p\" className={className} />;\n return <p className={className}>{richNodes(record.excerpt)}</p>;\n}\n/** Text from the current linked/manual record without a project-specific card renderer. */\nexport function RecordText({field,as='p',...classes}:ViewClasses & {field:string;as?:'p'|'span'|'div'|'blockquote'}) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record=useContext(RecordContext);\n const {edit}=useContext(FieldContext);\n const Wrapper=as==='span'?'span':'div';\n if(record.manual&&edit)return <Wrapper style={{display:'contents'}} onClick={event=>{if(event.currentTarget.closest('summary'))event.preventDefault();}}><ManualText name={field} label={field.replace(/([A-Z])/g,' $1').replace(/^./,letter=>letter.toUpperCase())} as={as} className={className} /></Wrapper>;\n const value=record[field];\n return value?createElement(as,{className},richNodes(value)):null;\n}\n/** Additional native content stored on the current record. */\nexport function RecordDate(classes: ViewClasses) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record=useContext(RecordContext),date=recordDate(record.publishedAt??record.date);\n return date?<time className={className} dateTime={date.dateTime}>{date.text}</time>:null;\n}\nexport function RecordContent({ field, ...classes }: ViewClasses & { field: string }) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record=useContext(RecordContext);\n const Content=useFieldScope().Content??NativeAreaContent;\n if (!Array.isArray(record[field]) || !record[field].length) return null;\n const content = <Content blocks={record[field]} />;\n return className ? <div className={className}>{content}</div> : content;\n}\nexport function RecordLink({ children, icon, ...classes }: ViewClasses & { children: ReactNode; icon?: string }) {\n const scope = useFieldScope(), className = viewClasses(classes, Boolean(scope.edit));\n const record = useContext(RecordContext), url = recordLinkUrl(record);\n const setUrl = record.manual && scope.edit && record.update ? (value: string) => record.update({ url: safeUrl(value), title: withoutRecordLinks(record.title) }) : undefined;\n const content = icon ? <ButtonLabel attributes={{ metadata: { siteButtonIcon: icon } }}>{children}</ButtonLabel> : children;\n return <RecordLinkContext.Provider value={{ url, setUrl }}>\n {url ? <a href={url} className={className}>{content}</a> : <div className={className}>{content}</div>}\n </RecordLinkContext.Provider>;\n}\n/** Position in the list, 01, 02\u2026 */\nexport function RecordIndex(classes: ViewClasses) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record = useContext(RecordContext);\n return <span className={className}>{String(record.index + 1).padStart(2, '0')}</span>;\n}\nexport function RecordEdit({ label, ...classes }: ViewClasses & { label: string }) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record = useContext(RecordContext);\n return record.manual || !record.id ? null : <EditorRecordLink id={record.id} label={label} className={className} />;\n}\n\nexport function renderFields(\n schema: FieldDefinition[],\n value: Record<string, any>,\n site: any = {}\n) {\n return schema.map((field) => (\n <div key={field.name}>{renderField(field, value[field.name] ?? emptyValue(field), site)}</div>\n ));\n}\n\nexport function RecordScope({\n schema,\n children,\n}: {\n schema: FieldDefinition[];\n children: ReactNode;\n}) {\n const context = useContext(ContentContext),\n parent = useFieldScope();\n return (\n <FieldScope\n schema={schema}\n value={context.data}\n site={context.site}\n record={context.record}\n onChange={context.editor ? parent.onChange : undefined}\n edit={context.editor ? parent.edit : undefined}\n extensions={parent.extensions}\n blockName={parent.blockName}\n >\n {children}\n </FieldScope>\n );\n}\n\n/** A shared layout around a content slot: the same children run in Next and Gutenberg. */\nexport function ContentArea({\n name,\n className,\n children,\n as: Tag = 'div',\n style,\n options,\n}: {\n name: string;\n className?: string;\n as?: ElementType | null;\n style?: React.CSSProperties;\n options?: { template?: any[]; fixedLayout?: boolean };\n children?: (content: ReactNode) => ReactNode;\n}) {\n const scope = useField(name),\n data = useValues(),\n context = useContext(ContentContext);\n if (scope.field.type !== 'content' || !scope.field.area)\n throw new Error('ContentArea requires an addContentArea declaration');\n const layout = (content: ReactNode, hostProps: Record<string, any> = { className, style }) => {\n const body = children ? children(content) : content;\n return Tag ? <Tag {...hostProps}>{body}</Tag> : <>{body}</>;\n };\n if (scope.edit)\n return scope.edit({\n name,\n field: scope.field,\n value: scope.value,\n setValue: scope.setValue,\n site: scope.site,\n options: {\n ...options,\n className,\n style,\n render: ({ children: content, ...hostProps }: Record<string, any>) =>\n layout(content, hostProps),\n },\n });\n const blocks = areaBlocks(scope.field.area, data, context.innerBlocks ?? [], scope.site);\n const Content = scope.Content ?? NativeAreaContent;\n return layout(<Content blocks={blocks} options={options} />);\n}\n"],
|
|
5
|
-
"mappings": ";AAwFI,SAwMI,UAxMJ,KAgIQ,YAhIR;AAvFJ,SAAS,mBAAqC;AAE9C,SAAS,wBAA0C;AACnD,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAElC,SAAS,sBAAsB;A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IAAI,MAAM,oDAAoD;AACtE,QAAM,SAAS,CAAC,SAAoB,YAAiC,EAAE,WAAW,MAAM,MAAM;AAC5F,UAAM,OAAO,WAAW,SAAS,OAAO,IAAI;AAC5C,WAAO,MAAM,oBAAC,OAAK,GAAG,WAAY,gBAAK,IAAS,gCAAG,gBAAK;AAAA,EAC1D;AACA,MAAI,MAAM;AACR,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,OAAO,MAAM;AAAA,MACb,OAAO,MAAM;AAAA,MACb,UAAU,MAAM;AAAA,MAChB,MAAM,MAAM;AAAA,MACZ,SAAS;AAAA,QACP,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,QAAQ,CAAC,EAAE,UAAU,SAAS,GAAG,UAAU,MACzC,OAAO,SAAS,SAAS;AAAA,MAC7B;AAAA,IACF,CAAC;AACH,QAAM,SAAS,WAAW,MAAM,MAAM,MAAM,MAAM,QAAQ,eAAe,CAAC,GAAG,MAAM,IAAI;AACvF,QAAM,UAAU,MAAM,WAAW;AACjC,SAAO,OAAO,oBAAC,WAAQ,QAAgB,SAAkB,CAAE;AAC7D;",
|
|
6
|
-
"names": ["offset", "limit"]
|
|
4
|
+
"sourcesContent": ["'use client';\nimport { viewClasses, type ViewClasses } from './view-classes.js';\nimport { FieldContext, useFieldScope } from './context.js';\nexport { useFieldScope } from './context.js';\nimport type { ButtonAppearance } from '../ui/button-appearance.js';\nimport { LoadedCollection, type ListLoading } from '../ui/loaded-collection.js';\nimport { reorderListItems } from './list-order.js';\nimport { ParagraphFlow } from '../content/paragraphs.js';\nimport { UniversalMedia } from '../media/universal/component.js';\nimport { recordUrl } from '../content/links.js';\nimport { areaBlocks } from '../content/areas/data.js';\nimport { NativeAreaContent } from '../content/areas/render.js';\nimport type { ContentBlock } from '../content/context.js';\nimport { ContentContext } from '../content/context.js';\nimport { richText as richNodes } from '../content/rich-text.js';\nimport { relationshipRecords, latestRecords, recordDate, safeUrl } from './records.js';\nimport type { FieldDefinition } from './schema.js';\nimport { emptyValue } from './schema.js';\nimport { fieldAt, valuesFor } from './values.js';\nimport { ButtonLabel } from '../icons/button.js';\nimport { Icon } from '../icons/icon.js';\nimport { LibraryImage } from '../media/image.js';\nimport { selectedRecords } from '../relationships/selection.js';\nimport { recordTitleAffixes, updateRecordTitleAffixes, recordTitleHtml, splitRecordTitleLabel } from './record-title.js';\nimport { recordLinkUrl, withoutRecordLinks } from './record-link.js';\nimport { atPath, setPath } from '../utils/path.js';\nimport { modalHref } from '../utils/url.js';\nimport {\n createContext,\n createElement,\n useContext,\n useMemo,\n useId,\n useEffect,\n useRef,\n useState,\n type ComponentType,\n type ElementType,\n type ReactNode,\n} from 'react';\nexport type ContentRendererProps = {\n blocks: ContentBlock[];\n options?: { fixedLayout?: boolean };\n};\nexport type Scope = {\n Content?: ComponentType<ContentRendererProps>;\n resolvedValue?: Record<string, any>;\n schema: FieldDefinition[];\n value: Record<string, any>;\n site: any;\n onChange?: (next: any) => void;\n edit?: EditField;\n record?: any;\n blockName?: string;\n extensions?: Record<string, any>;\n renderCustomField?: (props: any, scope: any) => ReactNode;\n};\nexport type FieldProps = {\n name: string | (string | number)[];\n inline?: boolean;\n editor?: boolean;\n value?: any;\n localized?: boolean | string;\n imageProps?: React.ImgHTMLAttributes<HTMLImageElement>;\n options?: any;\n as?: ElementType;\n className?: string;\n children?: ReactNode;\n};\nexport type EditField = (\n props: FieldProps & {\n field: FieldDefinition;\n value: any;\n setValue: (value: any) => void;\n site: any;\n nested?: boolean;\n }\n) => ReactNode;\nconst RecordContext = createContext<any>({});\nconst RecordLinkContext = createContext<{ url: string; setUrl?: (url: string) => void } | null>(null);\n/** Rich-text link tools inside RecordLink target its outer URL. */\nexport const useRecordLink = () => useContext(RecordLinkContext);\nexport function useRelatedRecord(){ return useContext(RecordContext); }\nexport function FieldScope({ children, ...scope }: Scope & { children: ReactNode }) {\n const resolvedValue = useMemo(\n () => scope.resolvedValue ?? valuesFor(scope.schema, scope.value, scope.site, scope.record),\n [scope.resolvedValue, scope.schema, scope.value, scope.site, scope.record]\n );\n return (\n <FieldContext.Provider value={{ ...scope, resolvedValue }}>{children}</FieldContext.Provider>\n );\n}\nexport function useValues() {\n const scope = useContext(FieldContext);\n return scope.resolvedValue ?? valuesFor(scope.schema, scope.value, scope.site, scope.record);\n}\nexport function useField(name: FieldProps['name']) {\n const scope = useContext(FieldContext),\n path = Array.isArray(name) ? name : [name];\n const root = scope.schema.find((f) => f.name === path[0]);\n const field =\n fieldAt(scope.schema, path) ??\n (root && path.length > 1\n ? { name: String(path.at(-1)), type: 'richText' as const }\n : undefined);\n if (!field) throw new Error(`Field \"${path.join('.')}\" is missing from schema.ts`);\n const data =\n scope.resolvedValue ?? valuesFor(scope.schema, scope.value, scope.site, scope.record);\n const value =\n atPath(path.length > 1 || field.recordField || field.recordMeta ? data : scope.value, path) ??\n (path.length === 1 ? data[path[0]] : emptyValue(field));\n const stored = { ...scope.value };\n for (const definition of scope.schema)\n if (definition.recordField || definition.recordMeta)\n stored[definition.name] = data[definition.name];\n const setValue = (next: any) => {\n if (root?.type === 'relationship' && root.resolveRecords && typeof path[1] === 'number') {\n const record = data[path[0]]?.[path[1]],\n selection = scope.value[path[0]] ?? { mode: 'all' };\n if (selection.mode === 'manual') {\n scope.onChange?.(setPath(stored, [path[0], 'items', ...path.slice(1)], next));\n return;\n }\n if (record?.id) {\n scope.onChange?.(\n setPath(stored, [path[0], 'overrides', String(record.id), ...path.slice(2)], next)\n );\n return;\n }\n }\n scope.onChange?.(setPath(stored, path, next));\n };\n return { ...scope, field, value, setValue };\n}\nexport function ListActions({ name, index }: { name: FieldProps['name']; index?: number }) {\n const scope = useField(name);\n if ((scope.field.type === 'relationship' && scope.field.resolveRecords) || scope.field.readOnly)\n return null;\n return scope.edit\n ? scope.edit({\n name,\n field: { ...scope.field, type: 'custom', control: 'list-actions' },\n value: scope.value,\n setValue: scope.setValue,\n site: scope.site,\n options: { index, itemType: scope.field.itemType, fields: scope.field.fields },\n })\n : null;\n}\nexport function EditorRecordLink({ id, label, className }: { id: number; label: string; className?: string }) {\n const scope = useContext(FieldContext);\n return scope.edit\n ? scope.edit({\n name: '',\n className,\n field: { name: '', type: 'custom', control: 'edit-record' },\n value: id,\n setValue: () => {},\n site: scope.site,\n options: { label },\n })\n : null;\n}\nexport function actionUrl(value: any, site: any) {\n const modal = (site.modals ?? []).find((m: any) => Number(m.id) === Number(value?.modalId));\n return value?.modalId\n ? modal\n ? modalHref(modal)\n : ''\n : safeUrl(value?.linkId ? recordUrl(site, value.linkId) : value?.url);\n}\nexport function Action({ value, site = {}, className = '' }: any) {\n const url = actionUrl(value, site);\n if (!url || !value?.text) return null;\n return (\n <a\n href={url}\n className={'wp-block-button__link ' + className}\n data-modal-plan={value.plan || undefined}\n >\n <ButtonLabel\n attributes={{\n metadata: {\n siteButtonIcon: value.icon,\n siteButtonIconPosition: value.iconPosition,\n },\n }}\n >\n {richNodes(value.text)}\n </ButtonLabel>\n </a>\n );\n}\nexport function renderField(\n field: FieldDefinition,\n value: any,\n site: any = {},\n props: Omit<FieldProps, 'name'> = {}\n): ReactNode {\n const Tag = props.as ?? field.tag ?? (field.type === 'richText' ? 'div' : 'span');\n const className = props.className;\n switch (field.type) {\n case 'group':\n return <div className={className}>{renderFields(field.fields ?? [], value ?? {}, site)}</div>;\n case 'repeater':\n return (\n <div className={className ?? 'grid gap-6 for-small-tablet:grid-cols-3'}>\n {(Array.isArray(value) ? value : []).map((row: any, index: number) => (\n <article key={index}>{renderFields(field.fields ?? [], row, site)}</article>\n ))}\n </div>\n );\n case 'relationship':\n return (\n <FieldScope schema={[field]} value={{ [field.name]: value }} site={site}>\n <Relationship name={field.name} className={className}>\n <article>\n <RecordImage />\n <RecordTitle />\n <RecordExcerpt />\n <RecordLink>Read more</RecordLink>\n </article>\n </Relationship>\n </FieldScope>\n );\n\n case 'content':\n case 'custom':\n return props.children ?? null;\n case 'media':\n return <UniversalMedia value={value} className={className} editor={!!props.editor} />;\n case 'image': {\n const image =\n typeof value === 'string' ? { url: value, alt: props.imageProps?.alt ?? '' } : value;\n return image?.url ? (\n <LibraryImage\n {...props.imageProps}\n src={image.url}\n alt={image.alt ?? ''}\n className={className ?? props.imageProps?.className}\n />\n ) : null;\n }\n case 'gallery':\n return (\n <div className={className ?? 'grid gap-4 for-small-tablet:grid-cols-3'}>\n {(Array.isArray(value) ? value : []).map((image: any, i: number) => (\n <LibraryImage\n key={image.id ?? i}\n src={image.url}\n alt={image.alt ?? ''}\n className=\"w-full object-cover\"\n />\n ))}\n </div>\n );\n case 'icon':\n return value ? (\n <span className={className}>\n <Icon icon={{ type: value }} />\n </span>\n ) : null;\n case 'wysiwyg':\n return (\n <ParagraphFlow\n value={Array.isArray(value) ? value : []}\n className={className}\n paragraphClass={props.options?.paragraphClass}\n />\n );\n case 'buttons':\n return (\n <div className={'site-actions ' + (className ?? 'flex flex-wrap gap-3')}>\n {(Array.isArray(value) ? value : []).map((button: any, i: number) => (\n <Action key={i} value={button} site={site} />\n ))}\n </div>\n );\n case 'link':\n return <Action value={value} site={site} className={className} />;\n case 'toggle':\n return value\n ? createElement(Tag, { className }, props.children ?? field.label ?? field.name)\n : null;\n case 'color':\n return null;\n case 'richText':\n return props.inline ? (\n <>{richNodes(props.value ?? value)}</>\n ) : (\n createElement(Tag, { className }, richNodes(value))\n );\n default: {\n const text = props.localized\n ? Number(props.value ?? value ?? 0).toLocaleString(\n typeof props.localized === 'string' ? props.localized : undefined\n )\n : String(value ?? '');\n return props.inline ? <>{text}</> : createElement(Tag, { className }, text);\n }\n }\n}\nexport function Field(props: FieldProps) {\n const { field, value, setValue, edit, site } = useField(props.name);\n const definition = props.imageProps\n ? { ...field, type: 'image' as const, storage: 'url' as const }\n : props.inline\n ? { ...field, type: props.localized ? ('number' as const) : ('richText' as const) }\n : field;\n const current = props.imageProps?.src ?? props.value ?? value;\n return (\n <>\n {edit\n ? edit({ ...props, field: definition, value: current, setValue, site })\n : renderField(definition, current, site, props)}\n </>\n );\n}\nexport function Group({ name, children, className }: FieldProps) {\n const scope = useField(name);\n return (\n <div className={className}>\n <FieldScope\n {...scope}\n schema={scope.field.fields ?? []}\n value={scope.value}\n onChange={scope.setValue}\n >\n {children}\n </FieldScope>\n </div>\n );\n}\nexport function Repeater({ name, children, className, renderRow, addText, appender, offset = 0, limit, itemFocusKey, perPage, loading, loadMoreButton }: FieldProps & { loadMoreButton?: ButtonAppearance; perPage?: number; loading?: ListLoading; itemFocusKey?: string; offset?: number; limit?: number; appender?: ReactNode; renderRow?: (row: ReactNode, index: number) => ReactNode; addText?: string }) {\n const scope = useField(name);\n const rows = Array.isArray(scope.value) ? scope.value : [];\n const grouped = Boolean(scope.field.controlOptions?.itemPanels);\n const settings = scope.field.fields?.filter(field => field.settings || (grouped && ['image','link'].includes(field.type))) ?? [];\n const id=useId().replace(/[^a-zA-Z0-9_-]/g,'');\n const root=useFieldScope();\n const render=(offset:number,limit?:number) => (\n <>\n <div className={className ?? 'grid gap-6 for-small-tablet:grid-cols-3'}>\n {rows.slice(offset, limit === undefined ? undefined : offset + limit).map((row: any, visibleIndex: number) => {\n const index = offset + visibleIndex;\n return (\n <FieldScope\n key={index}\n {...scope}\n resolvedValue={undefined}\n schema={scope.field.fields ?? []}\n value={row}\n edit={scope.edit ? (props) => scope.edit!({ ...props, nested: true, options: { ...props.options, itemPanel: grouped, itemFocusKey: itemFocusKey ? `${itemFocusKey}-${index}` : undefined } }) : undefined}\n onChange={(next) =>\n scope.setValue(rows.map((old: any, i: number) => (i === index ? next : old)))\n }\n >\n {renderRow ? renderRow(children, index) : children}\n {scope.edit && settings.length > 0 && scope.edit({\n name,\n options: {\n itemFocusKey: itemFocusKey ? `${itemFocusKey}-${index}` : undefined,\n listKey: itemFocusKey, index, total: rows.length,\n onMove: (from: number, target: number) => scope.setValue(reorderListItems(rows, from, target)),\n },\n field: { name: scope.field.name, type: 'custom', control: 'row-settings', label: `Item ${index + 1}`, fields: settings },\n value: row,\n setValue: next => scope.setValue(rows.map((old: any, i: number) => i === index ? next : old)),\n site: scope.site,\n })}\n </FieldScope>\n ); })}\n {appender}\n </div>\n {scope.edit && appender === undefined &&\n scope.edit({\n name,\n field: scope.field,\n value: rows,\n setValue: scope.setValue,\n site: scope.site,\n options: { addText },\n })}\n </>\n );\n return !scope.edit && loading ? <LoadedCollection pageKey={`list-${root.value.sectionId||id}-${name}`} total={rows.length} perPage={perPage} loading={loading} loadMoreButton={loadMoreButton}>{window=>render(window.offset,window.limit)}</LoadedCollection> : render(offset,limit);\n}\nexport function Relationship({ name, children, className, options, perPage, loading, loadMoreButton }: FieldProps & { loadMoreButton?: ButtonAppearance; perPage?: number; loading?: ListLoading }) {\n const scope = useField(name);\n const library=relationshipRecords(scope.field,scope.site);\n const source=scope.field.controlOptions??{};\n const latest=Number(source.latest)>0&&useValues()[String(source.modeField)]!=='manual';\n const records = latest?latestRecords(library,Number(source.latest)):selectedRecords(scope.value,library);\n const update = (record: any, patch: any, transform?: (data: any) => any) => {\n const rows = scope.value.map((item: any) => item === record ? { ...item, ...patch } : item);\n if (!transform) return scope.setValue(rows);\n root.onChange?.(transform(setPath(root.value, Array.isArray(name) ? name : [name], rows)));\n };\n const id=useId().replace(/[^a-zA-Z0-9_-]/g,'');\n const root=useFieldScope();\n const render=(offset=0,limit=records.length) => (\n <div {...options?.containerProps} ref={options?.rootRef} className={className ?? 'grid gap-6 for-small-tablet:grid-cols-3'}>\n {records.slice(offset,offset+limit).map((record, visibleIndex) => (\n <RecordContext.Provider\n key={record.id}\n value={{ ...record, index:offset+visibleIndex, update: (patch: any, transform?: (data: any) => any) => update(record, patch, transform) }}\n >\n {children}\n </RecordContext.Provider>\n ))}\n {scope.edit &&\n scope.edit({\n name,\n field: scope.field,\n value: scope.value,\n setValue: scope.setValue,\n site: scope.site,\n options: {\n ...options,\n // An empty copy of the record's markup gives the add tile the exact card size.\n shape: options?.shape ?? (\n <RecordContext.Provider value={{ index: records.length, title: '', excerpt: '' }}>\n {children}\n </RecordContext.Provider>\n ),\n },\n })}\n </div>\n );\n return !scope.edit && loading ? <LoadedCollection pageKey={`list-${root.value.sectionId||id}-${name}`} total={records.length} perPage={perPage} loading={loading} loadMoreButton={loadMoreButton}>{window=>render(window.offset,window.limit)}</LoadedCollection> : render();\n}\nexport function RecordImage({ replay = false, ...classes }: ViewClasses & { replay?: boolean }) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record = useContext(RecordContext);\n const { edit, site } = useContext(FieldContext);\n const imageRef = useRef<HTMLImageElement>(null), [version, setVersion] = useState(0);\n useEffect(() => {\n if (!replay || edit) return;\n const item = imageRef.current?.closest('[data-record-item]');\n const restart = () => setVersion(value => value + 1);\n item?.addEventListener('kit:record-replay', restart);\n return () => item?.removeEventListener('kit:record-replay', restart);\n }, [replay, Boolean(edit), record.id, record.image]);\n const image = record.image ? (\n <LibraryImage key={version} ref={imageRef} src={record.image} alt={record.alt ?? ''} className={className} />\n ) : null;\n if (!record.manual || !edit) return image;\n return (\n <>\n {image}\n {edit({\n name: 'image',\n field: { name: 'image', type: 'custom', control: 'record-tools' },\n value: record,\n setValue: record.update,\n site,\n })}\n </>\n );\n}\n/** A hand-written record is edited on the canvas like any other text. */\nfunction ManualText({ name, label, as, className }: { name: string; label: string; as: ElementType; className?: string }) {\n const record = useContext(RecordContext);\n const scope = useContext(FieldContext), link = useRecordLink();\n return scope.edit!({\n name,\n as,\n className,\n nested: true,\n field: { name, label, type: 'richText' },\n value: link ? withoutRecordLinks(record[name]) : record[name],\n setValue: (value) => record.update({ [name]: link ? withoutRecordLinks(value) : value }),\n site: scope.site,\n });\n}\n/** The whole label has one cursor and toolbar; affixes remain defaults that can be erased. */\nexport function RecordTitle({ as = 'h3', name = 'title', label = 'Title text', beforeText: defaultBefore, afterText: defaultAfter, ...classes }: ViewClasses & { as?: ElementType; name?: string; label?: string; beforeText?: string; afterText?: string }) {\n const scope = useFieldScope(), className = viewClasses(classes, Boolean(scope.edit)), link = useRecordLink();\n const record = useContext(RecordContext);\n const configurable = defaultBefore !== undefined || defaultAfter !== undefined;\n const { beforeText = '', afterText = '' } = configurable ? recordTitleAffixes(scope.value, name, { beforeText: defaultBefore, afterText: defaultAfter }) : {};\n const saved = configurable ? scope.value.__recordTitles?.[name] ?? {} : {};\n const beforeHtml = typeof saved.beforeHtml === 'string' ? saved.beforeHtml : recordTitleHtml(beforeText);\n const afterHtml = typeof saved.afterHtml === 'string' ? saved.afterHtml : recordTitleHtml(afterText);\n const sourceTitle = typeof record.title === 'object' ? record.title?.rendered : record.title;\n const title = configurable && !record.manual ? scope.value.__recordTitles?.[name]?.titles?.[String(record.id)] ?? sourceTitle : sourceTitle;\n if (scope.edit && configurable && record.id) {\n const text = link ? withoutRecordLinks(title) : String(title ?? '');\n return scope.edit({\n name: ['__recordTitles', name], as, inline: as === 'span', nested: true, className,\n field: { name, label, type: 'richText', placeholder: label + '\u2026' },\n value: beforeHtml + text + afterHtml,\n setValue: html => {\n const next = splitRecordTitleLabel(beforeText, text, afterText, link ? withoutRecordLinks(html) : html);\n const save = (data: any) => updateRecordTitleAffixes(data, name, {\n beforeText: next.beforeText, afterText: next.afterText, beforeHtml: next.beforeHtml, afterHtml: next.afterHtml,\n ...(!record.manual && next.title !== text ? { titles: { ...data.__recordTitles?.[name]?.titles, [String(record.id)]: next.title } } : {}),\n });\n if (record.update) record.update(record.manual ? { title: next.title } : {}, save);\n else scope.onChange?.(save(scope.value));\n }, site: scope.site,\n });\n }\n if (record.manual && scope.edit) return <ManualText name=\"title\" label=\"Title\" as={as} className={className} />;\n return createElement(as, { className}, richNodes(beforeHtml, { links: !link }), richNodes(title, { links: !link }), richNodes(afterHtml, { links: !link }));\n}\nexport function RecordExcerpt(classes: ViewClasses) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record = useContext(RecordContext);\n const { edit } = useContext(FieldContext);\n if (record.manual && edit) return <ManualText name=\"excerpt\" label=\"Description\" as=\"p\" className={className} />;\n return <p className={className}>{richNodes(record.excerpt)}</p>;\n}\n/** Text from the current linked/manual record without a project-specific card renderer. */\nexport function RecordText({field,as='p',...classes}:ViewClasses & {field:string;as?:'p'|'span'|'div'|'blockquote'}) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record=useContext(RecordContext);\n const {edit}=useContext(FieldContext);\n const Wrapper=as==='span'?'span':'div';\n if(record.manual&&edit)return <Wrapper style={{display:'contents'}} onClick={event=>{if(event.currentTarget.closest('summary'))event.preventDefault();}}><ManualText name={field} label={field.replace(/([A-Z])/g,' $1').replace(/^./,letter=>letter.toUpperCase())} as={as} className={className} /></Wrapper>;\n const value=record[field];\n return value?createElement(as,{className},richNodes(value)):null;\n}\n/** Additional native content stored on the current record. */\nexport function RecordDate(classes: ViewClasses) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record=useContext(RecordContext),date=recordDate(record.publishedAt??record.date);\n return date?<time className={className} dateTime={date.dateTime}>{date.text}</time>:null;\n}\nexport function RecordContent({ field, ...classes }: ViewClasses & { field: string }) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record=useContext(RecordContext);\n const Content=useFieldScope().Content??NativeAreaContent;\n if (!Array.isArray(record[field]) || !record[field].length) return null;\n const content = <Content blocks={record[field]} />;\n return className ? <div className={className}>{content}</div> : content;\n}\nexport function RecordLink({ children, icon, ...classes }: ViewClasses & { children: ReactNode; icon?: string }) {\n const scope = useFieldScope(), className = viewClasses(classes, Boolean(scope.edit));\n const record = useContext(RecordContext), url = recordLinkUrl(record);\n const setUrl = record.manual && scope.edit && record.update ? (value: string) => record.update({ url: safeUrl(value), title: withoutRecordLinks(record.title) }) : undefined;\n const content = icon ? <ButtonLabel attributes={{ metadata: { siteButtonIcon: icon } }}>{children}</ButtonLabel> : children;\n return <RecordLinkContext.Provider value={{ url, setUrl }}>\n {url ? <a href={url} className={className}>{content}</a> : <div className={className}>{content}</div>}\n </RecordLinkContext.Provider>;\n}\n/** Position in the list, 01, 02\u2026 */\nexport function RecordIndex(classes: ViewClasses) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record = useContext(RecordContext);\n return <span className={className}>{String(record.index + 1).padStart(2, '0')}</span>;\n}\nexport function RecordEdit({ label, ...classes }: ViewClasses & { label: string }) {\n const className = viewClasses(classes, Boolean(useFieldScope().edit));\n const record = useContext(RecordContext);\n return record.manual || !record.id ? null : <EditorRecordLink id={record.id} label={label} className={className} />;\n}\n\nexport function renderFields(\n schema: FieldDefinition[],\n value: Record<string, any>,\n site: any = {}\n) {\n return schema.map((field) => (\n <div key={field.name}>{renderField(field, value[field.name] ?? emptyValue(field), site)}</div>\n ));\n}\n\nexport function RecordScope({\n schema,\n children,\n}: {\n schema: FieldDefinition[];\n children: ReactNode;\n}) {\n const context = useContext(ContentContext),\n parent = useFieldScope();\n return (\n <FieldScope\n schema={schema}\n value={context.data}\n site={context.site}\n record={context.record}\n onChange={context.editor ? parent.onChange : undefined}\n edit={context.editor ? parent.edit : undefined}\n extensions={parent.extensions}\n blockName={parent.blockName}\n >\n {children}\n </FieldScope>\n );\n}\n\n/** A shared layout around a content slot: the same children run in Next and Gutenberg. */\nexport function ContentArea({\n name,\n className,\n children,\n as: Tag = 'div',\n style,\n options,\n}: {\n name: string;\n className?: string;\n as?: ElementType | null;\n style?: React.CSSProperties;\n options?: { template?: any[]; fixedLayout?: boolean };\n children?: (content: ReactNode) => ReactNode;\n}) {\n const scope = useField(name),\n data = useValues(),\n context = useContext(ContentContext);\n if (scope.field.type !== 'content' || !scope.field.area)\n throw new Error('ContentArea requires an addContentArea declaration');\n const layout = (content: ReactNode, hostProps: Record<string, any> = { className, style }) => {\n const body = children ? children(content) : content;\n return Tag ? <Tag {...hostProps}>{body}</Tag> : <>{body}</>;\n };\n if (scope.edit)\n return scope.edit({\n name,\n field: scope.field,\n value: scope.value,\n setValue: scope.setValue,\n site: scope.site,\n options: {\n ...options,\n className,\n style,\n render: ({ children: content, ...hostProps }: Record<string, any>) =>\n layout(content, hostProps),\n },\n });\n const blocks = areaBlocks(scope.field.area, data, context.innerBlocks ?? [], scope.site);\n const Content = scope.Content ?? NativeAreaContent;\n return layout(<Content blocks={blocks} options={options} />);\n}\n"],
|
|
5
|
+
"mappings": ";AAyFI,SAuMI,UAvMJ,KA+HQ,YA/HR;AAxFJ,SAAS,mBAAqC;AAC9C,SAAS,cAAc,qBAAqB;AAC5C,SAAS,iBAAAA,sBAAqB;AAE9B,SAAS,wBAA0C;AACnD,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAElC,SAAS,sBAAsB;AAC/B,SAAS,YAAY,iBAAiB;AACtC,SAAS,qBAAqB,eAAe,YAAY,eAAe;AAExE,SAAS,kBAAkB;AAC3B,SAAS,SAAS,iBAAiB;AACnC,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB,0BAA0B,iBAAiB,6BAA6B;AACrG,SAAS,eAAe,0BAA0B;AAClD,SAAS,QAAQ,eAAe;AAChC,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAuCP,MAAM,gBAAgB,cAAmB,CAAC,CAAC;AAC3C,MAAM,oBAAoB,cAAsE,IAAI;AAE7F,MAAM,gBAAgB,MAAM,WAAW,iBAAiB;AACxD,SAAS,mBAAkB;AAAE,SAAO,WAAW,aAAa;AAAG;AAC/D,SAAS,WAAW,EAAE,UAAU,GAAG,MAAM,GAAoC;AAClF,QAAM,gBAAgB;AAAA,IACpB,MAAM,MAAM,iBAAiB,UAAU,MAAM,QAAQ,MAAM,OAAO,MAAM,MAAM,MAAM,MAAM;AAAA,IAC1F,CAAC,MAAM,eAAe,MAAM,QAAQ,MAAM,OAAO,MAAM,MAAM,MAAM,MAAM;AAAA,E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;AAAA,EACH;AAEJ;AAGO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,IAAI,MAAM;AAAA,EACV;AAAA,EACA;AACF,GAOG;AACD,QAAM,QAAQ,SAAS,IAAI,GACzB,OAAO,UAAU,GACjB,UAAU,WAAW,cAAc;AACrC,MAAI,MAAM,MAAM,SAAS,aAAa,CAAC,MAAM,MAAM;AACjD,UAAM,IAAI,MAAM,oDAAoD;AACtE,QAAM,SAAS,CAAC,SAAoB,YAAiC,EAAE,WAAW,MAAM,MAAM;AAC5F,UAAM,OAAO,WAAW,SAAS,OAAO,IAAI;AAC5C,WAAO,MAAM,oBAAC,OAAK,GAAG,WAAY,gBAAK,IAAS,gCAAG,gBAAK;AAAA,EAC1D;AACA,MAAI,MAAM;AACR,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA,OAAO,MAAM;AAAA,MACb,OAAO,MAAM;AAAA,MACb,UAAU,MAAM;AAAA,MAChB,MAAM,MAAM;AAAA,MACZ,SAAS;AAAA,QACP,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,QAAQ,CAAC,EAAE,UAAU,SAAS,GAAG,UAAU,MACzC,OAAO,SAAS,SAAS;AAAA,MAC7B;AAAA,IACF,CAAC;AACH,QAAM,SAAS,WAAW,MAAM,MAAM,MAAM,MAAM,QAAQ,eAAe,CAAC,GAAG,MAAM,IAAI;AACvF,QAAM,UAAU,MAAM,WAAW;AACjC,SAAO,OAAO,oBAAC,WAAQ,QAAgB,SAAkB,CAAE;AAC7D;",
|
|
6
|
+
"names": ["useFieldScope", "offset", "limit"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function onlyElement(type: any, props: any, key?: any): {
|
|
2
|
+
type: (({ tag, elementProps }: {
|
|
3
|
+
tag: string;
|
|
4
|
+
elementProps: Record<string, any> & {
|
|
5
|
+
only: import("./only.js").OnlyView;
|
|
6
|
+
children?: import("react").ReactNode;
|
|
7
|
+
};
|
|
8
|
+
}) => string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null) & {
|
|
9
|
+
kitOnlyTag: boolean;
|
|
10
|
+
};
|
|
11
|
+
props: {
|
|
12
|
+
tag: string;
|
|
13
|
+
elementProps: any;
|
|
14
|
+
children: any;
|
|
15
|
+
};
|
|
16
|
+
key: any;
|
|
17
|
+
} | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OnlyTag } from "./only.js";
|
|
2
|
+
function onlyElement(type, props, key) {
|
|
3
|
+
if (typeof type !== "string" || props?.only !== "admin" && props?.only !== "front") return null;
|
|
4
|
+
return { type: OnlyTag, props: { tag: type, elementProps: props, children: props.children }, key: props.key !== void 0 ? props.key : key };
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
onlyElement
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../core/markup/element.ts"],
|
|
4
|
+
"sourcesContent": ["import { OnlyTag } from './only.js';\n\nexport function onlyElement(type: any, props: any, key?: any) {\n if (typeof type !== 'string' || (props?.only !== 'admin' && props?.only !== 'front')) return null;\n return { type: OnlyTag, props: { tag: type, elementProps: props, children: props.children }, key: props.key !== undefined ? props.key : key };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAEjB,SAAS,YAAY,MAAW,OAAY,KAAW;AAC5D,MAAI,OAAO,SAAS,YAAa,OAAO,SAAS,WAAW,OAAO,SAAS,QAAU,QAAO;AAC7F,SAAO,EAAE,MAAM,SAAS,OAAO,EAAE,KAAK,MAAM,cAAc,OAAO,UAAU,MAAM,SAAS,GAAG,KAAK,MAAM,QAAQ,SAAY,MAAM,MAAM,IAAI;AAC9I;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type OnlyView = 'admin' | 'front';
|
|
3
|
+
declare module 'react' {
|
|
4
|
+
interface HTMLAttributes<T> {
|
|
5
|
+
only?: OnlyView;
|
|
6
|
+
}
|
|
7
|
+
interface SVGAttributes<T> {
|
|
8
|
+
only?: OnlyView;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** The opposite view keeps children, without mounting an extra DOM wrapper. */
|
|
12
|
+
export declare const OnlyTag: (({ tag, elementProps }: {
|
|
13
|
+
tag: string;
|
|
14
|
+
elementProps: Record<string, any> & {
|
|
15
|
+
only: OnlyView;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
}) => string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null) & {
|
|
19
|
+
kitOnlyTag: boolean;
|
|
20
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { useFieldScope } from "../fields/context.js";
|
|
4
|
+
const OnlyTag = Object.assign(function OnlyTag2({ tag, elementProps }) {
|
|
5
|
+
const { edit } = useFieldScope();
|
|
6
|
+
const { only, children, ...attributes } = elementProps;
|
|
7
|
+
return only === (edit ? "admin" : "front") ? createElement(tag, attributes, children) : children ?? null;
|
|
8
|
+
}, { kitOnlyTag: true });
|
|
9
|
+
export {
|
|
10
|
+
OnlyTag
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=only.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../core/markup/only.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client';\nimport { createElement, type ReactNode } from 'react';\nimport { useFieldScope } from '../fields/context.js';\n\nexport type OnlyView = 'admin' | 'front';\ndeclare module 'react' {\n interface HTMLAttributes<T> { only?: OnlyView; }\n interface SVGAttributes<T> { only?: OnlyView; }\n}\n\n/** The opposite view keeps children, without mounting an extra DOM wrapper. */\nexport const OnlyTag = Object.assign(function OnlyTag({ tag, elementProps }: {\n tag: string;\n elementProps: Record<string, any> & { only: OnlyView; children?: ReactNode };\n}) {\n const { edit } = useFieldScope();\n const { only, children, ...attributes } = elementProps;\n return only === (edit ? 'admin' : 'front')\n ? createElement(tag, attributes, children)\n : children ?? null;\n}, { kitOnlyTag: true });\n\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,qBAAqC;AAC9C,SAAS,qBAAqB;AASvB,MAAM,UAAU,OAAO,OAAO,SAASA,SAAQ,EAAE,KAAK,aAAa,GAGvE;AACD,QAAM,EAAE,KAAK,IAAI,cAAc;AAC/B,QAAM,EAAE,MAAM,UAAU,GAAG,WAAW,IAAI;AAC1C,SAAO,UAAU,OAAO,UAAU,WAC9B,cAAc,KAAK,YAAY,QAAQ,IACvC,YAAY;AAClB,GAAG,EAAE,YAAY,KAAK,CAAC;",
|
|
6
|
+
"names": ["OnlyTag"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Fragment } from 'react/jsx-dev-runtime';
|
|
2
|
+
export type { JSX } from 'react/jsx-dev-runtime';
|
|
3
|
+
export declare function jsxDEV(type: any, props: any, key: any, isStaticChildren: boolean, source: any, self: any): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
4
|
+
export type { OnlyView } from './core/markup/only.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsxDEV as reactJsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { onlyElement } from "./core/markup/element.js";
|
|
3
|
+
import { Fragment } from "react/jsx-dev-runtime";
|
|
4
|
+
function jsxDEV(type, props, key, isStaticChildren, source, self) {
|
|
5
|
+
const element = onlyElement(type, props, key);
|
|
6
|
+
return element ? reactJsxDEV(element.type, element.props, element.key, isStaticChildren, source, self) : reactJsxDEV(type, props, key, isStaticChildren, source, self);
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
Fragment,
|
|
10
|
+
jsxDEV
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../jsx-dev-runtime.ts"],
|
|
4
|
+
"sourcesContent": ["import { jsxDEV as reactJsxDEV } from 'react/jsx-dev-runtime';\nimport { onlyElement } from './core/markup/element.js';\nexport { Fragment } from 'react/jsx-dev-runtime';\nexport type { JSX } from 'react/jsx-dev-runtime';\n\nexport function jsxDEV(type: any, props: any, key: any, isStaticChildren: boolean, source: any, self: any) {\n const element = onlyElement(type, props, key);\n return element\n ? reactJsxDEV(element.type, element.props, element.key, isStaticChildren, source, self)\n : reactJsxDEV(type, props, key, isStaticChildren, source, self);\n}\nexport type { OnlyView } from './core/markup/only.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,UAAU,mBAAmB;AACtC,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAGlB,SAAS,OAAO,MAAW,OAAY,KAAU,kBAA2B,QAAa,MAAW;AACzG,QAAM,UAAU,YAAY,MAAM,OAAO,GAAG;AAC5C,SAAO,UACH,YAAY,QAAQ,MAAM,QAAQ,OAAO,QAAQ,KAAK,kBAAkB,QAAQ,IAAI,IACpF,YAAY,MAAM,OAAO,KAAK,kBAAkB,QAAQ,IAAI;AAClE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Fragment } from 'react/jsx-runtime';
|
|
2
|
+
export type { JSX } from 'react/jsx-runtime';
|
|
3
|
+
export declare function jsx(type: any, props: any, key?: any): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
4
|
+
export declare function jsxs(type: any, props: any, key?: any): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
5
|
+
export type { OnlyView } from './core/markup/only.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as reactJsx, jsxs as reactJsxs } from "react/jsx-runtime";
|
|
2
|
+
import { onlyElement } from "./core/markup/element.js";
|
|
3
|
+
import { Fragment } from "react/jsx-runtime";
|
|
4
|
+
function jsx(type, props, key) {
|
|
5
|
+
const element = onlyElement(type, props, key);
|
|
6
|
+
return element ? reactJsx(element.type, element.props, element.key) : reactJsx(type, props, key);
|
|
7
|
+
}
|
|
8
|
+
function jsxs(type, props, key) {
|
|
9
|
+
const element = onlyElement(type, props, key);
|
|
10
|
+
return element ? reactJsxs(element.type, element.props, element.key) : reactJsxs(type, props, key);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
Fragment,
|
|
14
|
+
jsx,
|
|
15
|
+
jsxs
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../jsx-runtime.ts"],
|
|
4
|
+
"sourcesContent": ["import { jsx as reactJsx, jsxs as reactJsxs } from 'react/jsx-runtime';\nimport { onlyElement } from './core/markup/element.js';\nexport { Fragment } from 'react/jsx-runtime';\nexport type { JSX } from 'react/jsx-runtime';\n\nexport function jsx(type: any, props: any, key?: any) {\n const element = onlyElement(type, props, key);\n return element ? reactJsx(element.type, element.props, element.key) : reactJsx(type, props, key);\n}\nexport function jsxs(type: any, props: any, key?: any) {\n const element = onlyElement(type, props, key);\n return element ? reactJsxs(element.type, element.props, element.key) : reactJsxs(type, props, key);\n}\nexport type { OnlyView } from './core/markup/only.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,OAAO,UAAU,QAAQ,iBAAiB;AACnD,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAGlB,SAAS,IAAI,MAAW,OAAY,KAAW;AACpD,QAAM,UAAU,YAAY,MAAM,OAAO,GAAG;AAC5C,SAAO,UAAU,SAAS,QAAQ,MAAM,QAAQ,OAAO,QAAQ,GAAG,IAAI,SAAS,MAAM,OAAO,GAAG;AACjG;AACO,SAAS,KAAK,MAAW,OAAY,KAAW;AACrD,QAAM,UAAU,YAAY,MAAM,OAAO,GAAG;AAC5C,SAAO,UAAU,UAAU,QAAQ,MAAM,QAAQ,OAAO,QAAQ,GAAG,IAAI,UAAU,MAAM,OAAO,GAAG;AACnG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/** One project opt-in; other JSX runtimes and unconfigured consumers stay untouched. */
|
|
5
|
+
export function connectOnlyMarkup(root) {
|
|
6
|
+
const configFile = path.join(root, 'kit.config.json');
|
|
7
|
+
if (!fs.existsSync(configFile) || !JSON.parse(fs.readFileSync(configFile, 'utf8')).jsxOnly) return;
|
|
8
|
+
const file = path.join(root, 'tsconfig.json');
|
|
9
|
+
const config = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
10
|
+
const options = config.compilerOptions ??= {};
|
|
11
|
+
const current = options.jsxImportSource;
|
|
12
|
+
if (current && current !== 'react' && current !== '@kit')
|
|
13
|
+
throw new Error(`jsxOnly cannot replace the configured JSX runtime "${current}". Keep it or explicitly connect the Kit runtime.`);
|
|
14
|
+
if (current === '@kit') return;
|
|
15
|
+
options.jsxImportSource = '@kit';
|
|
16
|
+
fs.writeFileSync(file, JSON.stringify(config, null, 2) + '\n');
|
|
17
|
+
}
|
|
@@ -5,6 +5,7 @@ import {syncSections} from './sync-sections.mjs';
|
|
|
5
5
|
import {syncKit} from './sync-kit.mjs';
|
|
6
6
|
import {syncBlocks} from './sync-blocks.mjs';
|
|
7
7
|
import {normalizeSourceImports} from './materialize-source.mjs';
|
|
8
|
+
import {connectOnlyMarkup} from './jsx-only.mjs';
|
|
8
9
|
export const packageRoot=path.resolve(fileURLToPath(new URL('..',import.meta.url)));
|
|
9
10
|
const hasFiles=folder=>fs.readdirSync(folder,{withFileTypes:true}).some(entry=>entry.isDirectory()?hasFiles(path.join(folder,entry.name)):true);
|
|
10
11
|
|
|
@@ -13,17 +14,18 @@ export function prepareProject(project=process.cwd(),{force=false}={}){
|
|
|
13
14
|
const root=path.resolve(project),destination=path.join(root,'kit'),markerFile=path.join(destination,'.kit-package.json');
|
|
14
15
|
const metadata=JSON.parse(fs.readFileSync(path.join(packageRoot,'package.json'),'utf8'));
|
|
15
16
|
let marker;try{marker=JSON.parse(fs.readFileSync(markerFile,'utf8'));}catch{}
|
|
16
|
-
const required=['index.tsx','core/fields/render.tsx','editor/seo.ts','tooling/sync-sections.mjs','tooling/sync-kit.mjs','wordpress/bootstrap.php'];
|
|
17
|
+
const required=['jsx-runtime.ts','jsx-dev-runtime.ts','index.tsx','core/fields/render.tsx','editor/seo.ts','tooling/sync-sections.mjs','tooling/sync-kit.mjs','wordpress/bootstrap.php'];
|
|
17
18
|
const reusable=!force&&marker?.name===metadata.name&&marker?.version===metadata.version&&required.every(file=>fs.existsSync(path.join(destination,file)));
|
|
18
19
|
if(!reusable&&destination!==packageRoot){
|
|
19
20
|
if(fs.existsSync(destination)&&!marker&&hasFiles(destination))throw new Error('kit/ is authored source. Move it aside before preparing the npm-managed kit copy.');
|
|
20
21
|
fs.mkdirSync(destination,{recursive:true});
|
|
21
22
|
const folders=['components','editor','core','ui','admin-ui','modules','adapters','wordpress','hooks','styles','schema','shared','tooling'];
|
|
22
23
|
for(const folder of folders){fs.rmSync(path.join(destination,folder),{recursive:true,force:true});fs.cpSync(path.join(packageRoot,folder),path.join(destination,folder),{recursive:true});}
|
|
23
|
-
for(const file of ['index.tsx','bootstrap.php'])fs.copyFileSync(path.join(packageRoot,file),path.join(destination,file));
|
|
24
|
+
for(const file of ['index.tsx','jsx-runtime.ts','jsx-dev-runtime.ts','bootstrap.php'])fs.copyFileSync(path.join(packageRoot,file),path.join(destination,file));
|
|
24
25
|
normalizeSourceImports(destination);
|
|
25
26
|
fs.writeFileSync(markerFile,JSON.stringify({name:metadata.name,version:metadata.version},null,2)+'\n');
|
|
26
27
|
}
|
|
28
|
+
connectOnlyMarkup(root);
|
|
27
29
|
syncSections(root);syncKit(root,{directory:destination});syncBlocks(root);
|
|
28
30
|
return {root,directory:destination,version:metadata.version,refreshed:!reusable};
|
|
29
31
|
}
|
|
@@ -9,7 +9,9 @@ try{
|
|
|
9
9
|
const consumer=path.join(temporary,'consumer');fs.mkdirSync(consumer);
|
|
10
10
|
fs.writeFileSync(path.join(consumer,'package.json'),JSON.stringify({name:'kit-smoke-consumer',version:'1.0.0',private:true,type:'module'}));
|
|
11
11
|
execFileSync('npm',['install',path.join(temporary,archive),'--ignore-scripts','--no-audit','--no-fund'],{cwd:consumer,stdio:'pipe',env:{...process.env,npm_config_userconfig:os.devNull}});
|
|
12
|
-
execFileSync(process.execPath,['--input-type=module','-e',"import {Background,Heading,Drag,SocialLinks} from 'soinproduction-gutenberg'; if([Background,Heading,Drag,SocialLinks].some(value=>typeof value!=='function'))throw new Error('Missing public exports');"],{cwd:consumer,stdio:'pipe'});
|
|
12
|
+
execFileSync(process.execPath,['--input-type=module','-e',"import {Background,Heading,Drag,SocialLinks} from 'soinproduction-gutenberg'; if([Background,Heading,Drag,SocialLinks].some(value=>typeof value!=='function'))throw new Error('Missing public exports');import {jsx} from 'soinproduction-gutenberg/jsx-runtime';import {renderToStaticMarkup} from 'react-dom/server';if(renderToStaticMarkup(jsx('div',{only:'admin',children:'Shared'}))!=='Shared')throw new Error('Broken public JSX runtime');"],{cwd:consumer,stdio:'pipe'});
|
|
13
|
+
fs.writeFileSync(path.join(consumer,'only-types.tsx'),'<div only="admin"><svg only="front"/></div>;');
|
|
14
|
+
execFileSync(process.execPath,['--input-type=module','-e',"import ts from 'typescript';const program=ts.createProgram(['only-types.tsx'],{jsx:ts.JsxEmit.ReactJSX,jsxImportSource:'soinproduction-gutenberg',module:ts.ModuleKind.ESNext,moduleResolution:ts.ModuleResolutionKind.Bundler,target:ts.ScriptTarget.ES2020,skipLibCheck:true,noEmit:true});const errors=ts.getPreEmitDiagnostics(program);if(errors.length)throw new Error(ts.formatDiagnosticsWithColorAndContext(errors,{getCanonicalFileName:f=>f,getCurrentDirectory:()=>process.cwd(),getNewLine:()=>String.fromCharCode(10)}));"],{cwd:consumer,stdio:'pipe'});
|
|
13
15
|
fs.mkdirSync(path.join(consumer,'config'));fs.mkdirSync(path.join(consumer,'src/sections/section-example'),{recursive:true});
|
|
14
16
|
fs.writeFileSync(path.join(consumer,'tsconfig.json'),JSON.stringify({compilerOptions:{paths:{'@kit':['./kit/index.tsx'],'@kit/*':['./kit/*']}}}));
|
|
15
17
|
fs.writeFileSync(path.join(consumer,'kit.config.json'),JSON.stringify({modules:[]}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsxDEV as reactJsxDEV } from 'react/jsx-dev-runtime';
|
|
2
|
+
import { onlyElement } from './core/markup/element.js';
|
|
3
|
+
export { Fragment } from 'react/jsx-dev-runtime';
|
|
4
|
+
export type { JSX } from 'react/jsx-dev-runtime';
|
|
5
|
+
|
|
6
|
+
export function jsxDEV(type: any, props: any, key: any, isStaticChildren: boolean, source: any, self: any) {
|
|
7
|
+
const element = onlyElement(type, props, key);
|
|
8
|
+
return element
|
|
9
|
+
? reactJsxDEV(element.type, element.props, element.key, isStaticChildren, source, self)
|
|
10
|
+
: reactJsxDEV(type, props, key, isStaticChildren, source, self);
|
|
11
|
+
}
|
|
12
|
+
export type { OnlyView } from './core/markup/only.js';
|
package/jsx-runtime.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as reactJsx, jsxs as reactJsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { onlyElement } from './core/markup/element.js';
|
|
3
|
+
export { Fragment } from 'react/jsx-runtime';
|
|
4
|
+
export type { JSX } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
export function jsx(type: any, props: any, key?: any) {
|
|
7
|
+
const element = onlyElement(type, props, key);
|
|
8
|
+
return element ? reactJsx(element.type, element.props, element.key) : reactJsx(type, props, key);
|
|
9
|
+
}
|
|
10
|
+
export function jsxs(type: any, props: any, key?: any) {
|
|
11
|
+
const element = onlyElement(type, props, key);
|
|
12
|
+
return element ? reactJsxs(element.type, element.props, element.key) : reactJsxs(type, props, key);
|
|
13
|
+
}
|
|
14
|
+
export type { OnlyView } from './core/markup/only.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soinproduction-gutenberg",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -98,7 +98,9 @@
|
|
|
98
98
|
"index.tsx",
|
|
99
99
|
"README.md",
|
|
100
100
|
"RELEASING.md",
|
|
101
|
-
"tsconfig.json"
|
|
101
|
+
"tsconfig.json",
|
|
102
|
+
"jsx-runtime.ts",
|
|
103
|
+
"jsx-dev-runtime.ts"
|
|
102
104
|
],
|
|
103
105
|
"bin": {
|
|
104
106
|
"soinproduction-kit": "tooling/cli.mjs"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
/** One project opt-in; other JSX runtimes and unconfigured consumers stay untouched. */
|
|
5
|
+
export function connectOnlyMarkup(root) {
|
|
6
|
+
const configFile = path.join(root, 'kit.config.json');
|
|
7
|
+
if (!fs.existsSync(configFile) || !JSON.parse(fs.readFileSync(configFile, 'utf8')).jsxOnly) return;
|
|
8
|
+
const file = path.join(root, 'tsconfig.json');
|
|
9
|
+
const config = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
10
|
+
const options = config.compilerOptions ??= {};
|
|
11
|
+
const current = options.jsxImportSource;
|
|
12
|
+
if (current && current !== 'react' && current !== '@kit')
|
|
13
|
+
throw new Error(`jsxOnly cannot replace the configured JSX runtime "${current}". Keep it or explicitly connect the Kit runtime.`);
|
|
14
|
+
if (current === '@kit') return;
|
|
15
|
+
options.jsxImportSource = '@kit';
|
|
16
|
+
fs.writeFileSync(file, JSON.stringify(config, null, 2) + '\n');
|
|
17
|
+
}
|
|
@@ -5,6 +5,7 @@ import {syncSections} from './sync-sections.mjs';
|
|
|
5
5
|
import {syncKit} from './sync-kit.mjs';
|
|
6
6
|
import {syncBlocks} from './sync-blocks.mjs';
|
|
7
7
|
import {normalizeSourceImports} from './materialize-source.mjs';
|
|
8
|
+
import {connectOnlyMarkup} from './jsx-only.mjs';
|
|
8
9
|
export const packageRoot=path.resolve(fileURLToPath(new URL('..',import.meta.url)));
|
|
9
10
|
const hasFiles=folder=>fs.readdirSync(folder,{withFileTypes:true}).some(entry=>entry.isDirectory()?hasFiles(path.join(folder,entry.name)):true);
|
|
10
11
|
|
|
@@ -13,17 +14,18 @@ export function prepareProject(project=process.cwd(),{force=false}={}){
|
|
|
13
14
|
const root=path.resolve(project),destination=path.join(root,'kit'),markerFile=path.join(destination,'.kit-package.json');
|
|
14
15
|
const metadata=JSON.parse(fs.readFileSync(path.join(packageRoot,'package.json'),'utf8'));
|
|
15
16
|
let marker;try{marker=JSON.parse(fs.readFileSync(markerFile,'utf8'));}catch{}
|
|
16
|
-
const required=['index.tsx','core/fields/render.tsx','editor/seo.ts','tooling/sync-sections.mjs','tooling/sync-kit.mjs','wordpress/bootstrap.php'];
|
|
17
|
+
const required=['jsx-runtime.ts','jsx-dev-runtime.ts','index.tsx','core/fields/render.tsx','editor/seo.ts','tooling/sync-sections.mjs','tooling/sync-kit.mjs','wordpress/bootstrap.php'];
|
|
17
18
|
const reusable=!force&&marker?.name===metadata.name&&marker?.version===metadata.version&&required.every(file=>fs.existsSync(path.join(destination,file)));
|
|
18
19
|
if(!reusable&&destination!==packageRoot){
|
|
19
20
|
if(fs.existsSync(destination)&&!marker&&hasFiles(destination))throw new Error('kit/ is authored source. Move it aside before preparing the npm-managed kit copy.');
|
|
20
21
|
fs.mkdirSync(destination,{recursive:true});
|
|
21
22
|
const folders=['components','editor','core','ui','admin-ui','modules','adapters','wordpress','hooks','styles','schema','shared','tooling'];
|
|
22
23
|
for(const folder of folders){fs.rmSync(path.join(destination,folder),{recursive:true,force:true});fs.cpSync(path.join(packageRoot,folder),path.join(destination,folder),{recursive:true});}
|
|
23
|
-
for(const file of ['index.tsx','bootstrap.php'])fs.copyFileSync(path.join(packageRoot,file),path.join(destination,file));
|
|
24
|
+
for(const file of ['index.tsx','jsx-runtime.ts','jsx-dev-runtime.ts','bootstrap.php'])fs.copyFileSync(path.join(packageRoot,file),path.join(destination,file));
|
|
24
25
|
normalizeSourceImports(destination);
|
|
25
26
|
fs.writeFileSync(markerFile,JSON.stringify({name:metadata.name,version:metadata.version},null,2)+'\n');
|
|
26
27
|
}
|
|
28
|
+
connectOnlyMarkup(root);
|
|
27
29
|
syncSections(root);syncKit(root,{directory:destination});syncBlocks(root);
|
|
28
30
|
return {root,directory:destination,version:metadata.version,refreshed:!reusable};
|
|
29
31
|
}
|
|
@@ -9,7 +9,9 @@ try{
|
|
|
9
9
|
const consumer=path.join(temporary,'consumer');fs.mkdirSync(consumer);
|
|
10
10
|
fs.writeFileSync(path.join(consumer,'package.json'),JSON.stringify({name:'kit-smoke-consumer',version:'1.0.0',private:true,type:'module'}));
|
|
11
11
|
execFileSync('npm',['install',path.join(temporary,archive),'--ignore-scripts','--no-audit','--no-fund'],{cwd:consumer,stdio:'pipe',env:{...process.env,npm_config_userconfig:os.devNull}});
|
|
12
|
-
execFileSync(process.execPath,['--input-type=module','-e',"import {Background,Heading,Drag,SocialLinks} from 'soinproduction-gutenberg'; if([Background,Heading,Drag,SocialLinks].some(value=>typeof value!=='function'))throw new Error('Missing public exports');"],{cwd:consumer,stdio:'pipe'});
|
|
12
|
+
execFileSync(process.execPath,['--input-type=module','-e',"import {Background,Heading,Drag,SocialLinks} from 'soinproduction-gutenberg'; if([Background,Heading,Drag,SocialLinks].some(value=>typeof value!=='function'))throw new Error('Missing public exports');import {jsx} from 'soinproduction-gutenberg/jsx-runtime';import {renderToStaticMarkup} from 'react-dom/server';if(renderToStaticMarkup(jsx('div',{only:'admin',children:'Shared'}))!=='Shared')throw new Error('Broken public JSX runtime');"],{cwd:consumer,stdio:'pipe'});
|
|
13
|
+
fs.writeFileSync(path.join(consumer,'only-types.tsx'),'<div only="admin"><svg only="front"/></div>;');
|
|
14
|
+
execFileSync(process.execPath,['--input-type=module','-e',"import ts from 'typescript';const program=ts.createProgram(['only-types.tsx'],{jsx:ts.JsxEmit.ReactJSX,jsxImportSource:'soinproduction-gutenberg',module:ts.ModuleKind.ESNext,moduleResolution:ts.ModuleResolutionKind.Bundler,target:ts.ScriptTarget.ES2020,skipLibCheck:true,noEmit:true});const errors=ts.getPreEmitDiagnostics(program);if(errors.length)throw new Error(ts.formatDiagnosticsWithColorAndContext(errors,{getCanonicalFileName:f=>f,getCurrentDirectory:()=>process.cwd(),getNewLine:()=>String.fromCharCode(10)}));"],{cwd:consumer,stdio:'pipe'});
|
|
13
15
|
fs.mkdirSync(path.join(consumer,'config'));fs.mkdirSync(path.join(consumer,'src/sections/section-example'),{recursive:true});
|
|
14
16
|
fs.writeFileSync(path.join(consumer,'tsconfig.json'),JSON.stringify({compilerOptions:{paths:{'@kit':['./kit/index.tsx'],'@kit/*':['./kit/*']}}}));
|
|
15
17
|
fs.writeFileSync(path.join(consumer,'kit.config.json'),JSON.stringify({modules:[]}));
|