@bettercms-ai/types 1.36.0 → 1.37.0
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/dist/index.d.ts +41 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1101,6 +1101,41 @@ declare function splitButtonStyle(style: BlockStyle | undefined): {
|
|
|
1101
1101
|
placement: BlockStyle | undefined;
|
|
1102
1102
|
paint: Record<string, string | number> | undefined;
|
|
1103
1103
|
};
|
|
1104
|
+
/**
|
|
1105
|
+
* The style keys a PAGE FIELD takes (`pages.field_styles`, keyed by field path): its width and
|
|
1106
|
+
* placement, the space above and below it, and its text alignment, size and weight. A subset of
|
|
1107
|
+
* `BlockStyle`, so every key keeps the token set and the CSS table it already has — a field never
|
|
1108
|
+
* gets a second scale. 🔴 Twin: `FIELD_STYLE_KEYS` in the dashboard's fieldStyle.ts.
|
|
1109
|
+
*/
|
|
1110
|
+
declare const FIELD_STYLE_KEYS: readonly ["contentWidth", "contentAlign", "marginTop", "marginBottom", "align", "fontSize", "weight"];
|
|
1111
|
+
type FieldStyleKey = (typeof FIELD_STYLE_KEYS)[number];
|
|
1112
|
+
/** One field's style. */
|
|
1113
|
+
type FieldStyle = Pick<BlockStyle, FieldStyleKey>;
|
|
1114
|
+
/** A page's field styles, keyed by field path (the `data-bcms-field` address). */
|
|
1115
|
+
type FieldStyles = Record<string, FieldStyle>;
|
|
1116
|
+
/** Only the field keys of `style` (an empty object for none). */
|
|
1117
|
+
declare function pickFieldStyle(style: BlockStyle | Record<string, unknown> | null | undefined): FieldStyle;
|
|
1118
|
+
/**
|
|
1119
|
+
* A field's declarations, for its OWN element (`fieldAttrs`). Spacing, alignment, size and weight are
|
|
1120
|
+
* `blockStyleToCss`'s. The width is `blockStyleToInnerCss`'s column, drawn on the element itself —
|
|
1121
|
+
* a field has no wrapper to nest a column in — so its placement becomes left/right margins, and
|
|
1122
|
+
* the vertical margins the spacing set stay. `undefined` when nothing applies (no `style` at all).
|
|
1123
|
+
*/
|
|
1124
|
+
declare function fieldStyleToCss(style: BlockStyle | Record<string, unknown> | null | undefined): Record<string, string | number> | undefined;
|
|
1125
|
+
/**
|
|
1126
|
+
* The content column (`contentWidth` placed by `contentAlign`, falling back to `align`) as the
|
|
1127
|
+
* declarations for a box that IS the column — a site's own inner container (`sectionColumnAttrs`)
|
|
1128
|
+
* or a field's own element (`fieldStyleToCss`). Same max-width table as `blockStyleToInnerCss`;
|
|
1129
|
+
* the placement is left/right margins only, never the `margin` shorthand, so the box keeps its
|
|
1130
|
+
* own vertical margins. `undefined` when there is no column (unset, `full`, unknown).
|
|
1131
|
+
*/
|
|
1132
|
+
declare function blockStyleToColumnCss(style: BlockStyle | undefined): {
|
|
1133
|
+
maxWidth: string;
|
|
1134
|
+
marginLeft: string;
|
|
1135
|
+
marginRight: string;
|
|
1136
|
+
} | undefined;
|
|
1137
|
+
/** `fieldStyleToCss` as an inline `style` string (`paddingTop` → `padding-top`), "" when empty. */
|
|
1138
|
+
declare function fieldStyleCssText(style: BlockStyle | Record<string, unknown> | null | undefined): string;
|
|
1104
1139
|
|
|
1105
1140
|
/**
|
|
1106
1141
|
* Generated from lucide-react@1.8.0 dynamic icon names.
|
|
@@ -2115,6 +2150,11 @@ interface DeliveryPage {
|
|
|
2115
2150
|
metaJson: PageMetaJson | null;
|
|
2116
2151
|
blocks: ContentBlock[];
|
|
2117
2152
|
layout?: DeliveredLayout | null;
|
|
2153
|
+
/**
|
|
2154
|
+
* C3 — the page's field styles, keyed by field path (`pages.published_field_styles`; the draft
|
|
2155
|
+
* copy on a preview read). Absent when the page styles no field. Feed to `fieldAttrs`.
|
|
2156
|
+
*/
|
|
2157
|
+
fieldStyles?: FieldStyles;
|
|
2118
2158
|
updatedAt: string | null;
|
|
2119
2159
|
publishedAt: string | null;
|
|
2120
2160
|
/** The page's language (`null`: the site's default) and, on a translation, the page it translates. */
|
|
@@ -2547,4 +2587,4 @@ declare function regionOf<E extends {
|
|
|
2547
2587
|
el: E;
|
|
2548
2588
|
}[], el: unknown): string | null;
|
|
2549
2589
|
|
|
2550
|
-
export { type AlignToken, type ApiError, type ApiKey, type ApiKeyPermission, type ApiKeyTokenType, type ArrayZoneConfig, type AssertEqual, type AuthResponse, type AuthSession, type AuthUser, BLOCK_BINDINGS, BUTTON_ICONS, BUTTON_ICON_NAMES, BUTTON_LOOK_KEYS, BUTTON_PLACEMENT_KEYS, BUTTON_SIZES, BUTTON_VARIANTS, type BetterCMSErrorCode, type BgToken, type BindingKind, type BlockBinding, type BlockHoverStyle, type BlockStyle, type BlockType, type ButtonBlock, type ButtonIcon, type ButtonLinkCandidate, type ButtonLookKey, type ButtonProps, type ButtonSizeName, type ButtonValue, type ButtonVariant, COMPONENT_PROP_TYPES, type CanonicalInputDefinition, type CollectionBlock, type CollectionProps, type ColorToken, type ColumnsBlock, type ColumnsProps, type Component, type ComponentBlock, type ComponentCategory, type ComponentFormPropRef, type ComponentPropDef, type ComponentPropType, type ComponentPropUi, type ComponentProps, type ComponentSubField, type ComponentVariantGroup, type Content, type ContentBlock, type ContentEntry, type ContentModel, type ContentModelField, type ContentModelFieldType, type ContentModelFieldUi, type ContentPageResult, type ContentResponse, type ContentWidthToken, type CornerToken, DIALOG_SELECTOR, DOCK_BUDGET, DOCK_ICON_NAMES, DOCK_ICON_NAME_SET, type DeepReadonly, type DeliveredLayout, type DeliveryComponent, type DeliveryEntry, type DeliveryEntrySeo, type DeliveryList, type DeliveryPage, type DerivedLocator, type DockBudget, type DockFieldLike, type DockFieldsetLike, type DockIconName, type DockInputRef, type DockLane, type DockNode, type DockPropGroupLike, type DockScreen, type ElementLike, type ExpandedBinding, FOOTER_SECTION_ID, type FieldConfig, type Fieldset, type FieldsetKind, type FieldsetUiBefore, type FontSizeToken, type FooterBlock, type FooterColumn, type FooterProps, type Form, type FormBlock, type FormField, type FormProps, type FormSubmission, type HeadingBlock, type HeadingProps, type ImageBlock, type ImageProps, LANDMARK_SELECTOR, LAYOUT_SECTION_ICONS, LAYOUT_SECTION_ICON_SET, type LandmarkChainElement, type LandmarkElement, type LayoutComponentItem, type LayoutDataDocument, type LayoutFieldDefinition, type LayoutFieldItem, type LayoutFieldType, type LayoutScalarFieldType, type LayoutSection, type LayoutSectionIcon, type LayoutSectionItem, type LayoutStructureDocument, type LayoutZone, type LocatorGrammar, MAIN_SELECTOR, type ManagementLayoutCommand, type MediaAsset, type MediaCaptionTrack, type MediaFieldValue, NAVIGATION_SECTION_ID, type NavLink, type NavbarBlock, type NavbarProps, PAGE_CONTENT_ANCHOR_ID, type Page, type PageLayoutOverrideDataDocument, type PageLayoutOverrideDocument, type PageLayoutOverrideState, type PageLayoutOverrideStructureDocument, type PageLayoutSectionOverride, type PageLayoutSectionStructureOverride, type PageMetaJson, type PageOnlyLayoutSection, type PageSectionPlacement, type PaginatedResult, type Perspective, type PortableTextDocument, type PortableTextNode, type PropGroup, type RadiusToken, type Redirect, type ReservedLayoutSection, type ResolvedLayoutNode, type RichTextBlock, type RichTextProps, SECTION_DOCTRINE, SECTION_SPACE_TOKENS, SPACE_BOTTOM_TOKENS, SPACE_STEP_TOKENS, type SectionBlock, type SectionProps, type SectionSpaceToken, type ShadowToken, type SignInInput, type SignUpInput, type SiteSeoDefaults, type SlideItem, type SliderBlock, type SliderProps, type SpaceStepToken, type SpaceToken, type SpacerBlock, type SpacerProps, type TabItem, type TabsBlock, type TabsProps, type TextBlock, type TextProps, type ThemeToken, type UiBefore, type UiOrigin, type VariantInputMapping, type VideoBlock, type VideoProps, type WeightToken, type Workspace, type ZoneField, blockStyleToCss, blockStyleToInnerCss, buttonIconOf, buttonIconSvg, buttonLinkPairs, buttonValueOfInstance, buttonValueProblem, buttonVariantOf, candidateRole, componentInstanceAddresses, componentPropTargetKey, derivedPairs, dockBudget, dockScreens, expandBlockBindings, formatPropsAttribute, getBlockType, headingPaintCss, isBlock, isChromeLandmark, keyWords, landmarkRegions, locatorFor, parsePropsAttribute, readButtonValue, readPath, regionOf, safeCssUrl, spaceTokenCss, splitButtonStyle, withButtonLookProps };
|
|
2590
|
+
export { type AlignToken, type ApiError, type ApiKey, type ApiKeyPermission, type ApiKeyTokenType, type ArrayZoneConfig, type AssertEqual, type AuthResponse, type AuthSession, type AuthUser, BLOCK_BINDINGS, BUTTON_ICONS, BUTTON_ICON_NAMES, BUTTON_LOOK_KEYS, BUTTON_PLACEMENT_KEYS, BUTTON_SIZES, BUTTON_VARIANTS, type BetterCMSErrorCode, type BgToken, type BindingKind, type BlockBinding, type BlockHoverStyle, type BlockStyle, type BlockType, type ButtonBlock, type ButtonIcon, type ButtonLinkCandidate, type ButtonLookKey, type ButtonProps, type ButtonSizeName, type ButtonValue, type ButtonVariant, COMPONENT_PROP_TYPES, type CanonicalInputDefinition, type CollectionBlock, type CollectionProps, type ColorToken, type ColumnsBlock, type ColumnsProps, type Component, type ComponentBlock, type ComponentCategory, type ComponentFormPropRef, type ComponentPropDef, type ComponentPropType, type ComponentPropUi, type ComponentProps, type ComponentSubField, type ComponentVariantGroup, type Content, type ContentBlock, type ContentEntry, type ContentModel, type ContentModelField, type ContentModelFieldType, type ContentModelFieldUi, type ContentPageResult, type ContentResponse, type ContentWidthToken, type CornerToken, DIALOG_SELECTOR, DOCK_BUDGET, DOCK_ICON_NAMES, DOCK_ICON_NAME_SET, type DeepReadonly, type DeliveredLayout, type DeliveryComponent, type DeliveryEntry, type DeliveryEntrySeo, type DeliveryList, type DeliveryPage, type DerivedLocator, type DockBudget, type DockFieldLike, type DockFieldsetLike, type DockIconName, type DockInputRef, type DockLane, type DockNode, type DockPropGroupLike, type DockScreen, type ElementLike, type ExpandedBinding, FIELD_STYLE_KEYS, FOOTER_SECTION_ID, type FieldConfig, type FieldStyle, type FieldStyleKey, type FieldStyles, type Fieldset, type FieldsetKind, type FieldsetUiBefore, type FontSizeToken, type FooterBlock, type FooterColumn, type FooterProps, type Form, type FormBlock, type FormField, type FormProps, type FormSubmission, type HeadingBlock, type HeadingProps, type ImageBlock, type ImageProps, LANDMARK_SELECTOR, LAYOUT_SECTION_ICONS, LAYOUT_SECTION_ICON_SET, type LandmarkChainElement, type LandmarkElement, type LayoutComponentItem, type LayoutDataDocument, type LayoutFieldDefinition, type LayoutFieldItem, type LayoutFieldType, type LayoutScalarFieldType, type LayoutSection, type LayoutSectionIcon, type LayoutSectionItem, type LayoutStructureDocument, type LayoutZone, type LocatorGrammar, MAIN_SELECTOR, type ManagementLayoutCommand, type MediaAsset, type MediaCaptionTrack, type MediaFieldValue, NAVIGATION_SECTION_ID, type NavLink, type NavbarBlock, type NavbarProps, PAGE_CONTENT_ANCHOR_ID, type Page, type PageLayoutOverrideDataDocument, type PageLayoutOverrideDocument, type PageLayoutOverrideState, type PageLayoutOverrideStructureDocument, type PageLayoutSectionOverride, type PageLayoutSectionStructureOverride, type PageMetaJson, type PageOnlyLayoutSection, type PageSectionPlacement, type PaginatedResult, type Perspective, type PortableTextDocument, type PortableTextNode, type PropGroup, type RadiusToken, type Redirect, type ReservedLayoutSection, type ResolvedLayoutNode, type RichTextBlock, type RichTextProps, SECTION_DOCTRINE, SECTION_SPACE_TOKENS, SPACE_BOTTOM_TOKENS, SPACE_STEP_TOKENS, type SectionBlock, type SectionProps, type SectionSpaceToken, type ShadowToken, type SignInInput, type SignUpInput, type SiteSeoDefaults, type SlideItem, type SliderBlock, type SliderProps, type SpaceStepToken, type SpaceToken, type SpacerBlock, type SpacerProps, type TabItem, type TabsBlock, type TabsProps, type TextBlock, type TextProps, type ThemeToken, type UiBefore, type UiOrigin, type VariantInputMapping, type VideoBlock, type VideoProps, type WeightToken, type Workspace, type ZoneField, blockStyleToColumnCss, blockStyleToCss, blockStyleToInnerCss, buttonIconOf, buttonIconSvg, buttonLinkPairs, buttonValueOfInstance, buttonValueProblem, buttonVariantOf, candidateRole, componentInstanceAddresses, componentPropTargetKey, derivedPairs, dockBudget, dockScreens, expandBlockBindings, fieldStyleCssText, fieldStyleToCss, formatPropsAttribute, getBlockType, headingPaintCss, isBlock, isChromeLandmark, keyWords, landmarkRegions, locatorFor, parsePropsAttribute, pickFieldStyle, readButtonValue, readPath, regionOf, safeCssUrl, spaceTokenCss, splitButtonStyle, withButtonLookProps };
|
package/dist/index.js
CHANGED
|
@@ -297,6 +297,30 @@ function splitButtonStyle(style) {
|
|
|
297
297
|
paint: Object.keys(paint).length ? paint : void 0
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
|
+
var FIELD_STYLE_KEYS = ["contentWidth", "contentAlign", "marginTop", "marginBottom", "align", "fontSize", "weight"];
|
|
301
|
+
var FIELD_KEY_SET = new Set(FIELD_STYLE_KEYS);
|
|
302
|
+
function pickFieldStyle(style) {
|
|
303
|
+
const out = {};
|
|
304
|
+
if (!style || typeof style !== "object") return out;
|
|
305
|
+
for (const [k, v] of Object.entries(style)) if (FIELD_KEY_SET.has(k) && v != null) out[k] = v;
|
|
306
|
+
return out;
|
|
307
|
+
}
|
|
308
|
+
function fieldStyleToCss(style) {
|
|
309
|
+
const picked = pickFieldStyle(style);
|
|
310
|
+
const css = { ...blockStyleToCss(picked) };
|
|
311
|
+
Object.assign(css, blockStyleToColumnCss(picked));
|
|
312
|
+
return Object.keys(css).length ? css : void 0;
|
|
313
|
+
}
|
|
314
|
+
function blockStyleToColumnCss(style) {
|
|
315
|
+
const column = blockStyleToInnerCss(style);
|
|
316
|
+
if (!column || !style) return void 0;
|
|
317
|
+
const placement = style.contentAlign ?? style.align;
|
|
318
|
+
return { maxWidth: column.maxWidth, marginLeft: placement === "left" ? "0" : "auto", marginRight: placement === "right" ? "0" : "auto" };
|
|
319
|
+
}
|
|
320
|
+
function fieldStyleCssText(style) {
|
|
321
|
+
const css = fieldStyleToCss(style);
|
|
322
|
+
return css ? Object.entries(css).map(([k, v]) => `${k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}:${v}`).join(";") : "";
|
|
323
|
+
}
|
|
300
324
|
|
|
301
325
|
// src/component.ts
|
|
302
326
|
var SECTION_DOCTRINE = "STRUCTURE (separate from schema): a page is composed of SECTIONS. NEVER build a page out of loose top-level heading/text/image/button/spacer blocks \u2014 they cannot be moved, duplicated or swapped as a unit, the visual editor cannot outline or name them, and every one of them becomes its own section in the editor. A hero of a headline, a lede and two CTAs is ONE section, not four. TWO SHAPES, and the choice is about REUSE. (1) A band that appears on more than one page, or that needs layout variants, is a COMPONENT with a `sectionType` \u2014 see create_component. Components sharing a `sectionType` are that section's VARIANTS (one Hero: 'Centered' for the home page and 'Two-column' for about, same prop keys so a swap keeps the content). This is also the only shape the editor's 'Add a section' picker can insert, and the only one that gets a family name and a variant switcher. (2) A genuinely one-off band on a single page is a `section` BLOCK whose `props.children` hold its blocks. THE TRADEOFF, stated in the present tense because it is real today: inside a component, ONLY the leaves a declared prop TARGETS are click-to-edit on the canvas \u2014 each declared prop's `target` is re-keyed to that PLACEMENT's own override address, so editing it changes this page and not the shared definition. A prop with no `target` still SHOWS as a dock control, but its override reaches no rendered slot, so editing it changes nothing on the page. Copy that no prop points at is worse still: no binding and no control, unreachable from click-to-edit AND from the dock, changeable only by editing the component definition, which rewrites every page that places it. A `section` block's children stay click-to-edit unconditionally. So when you choose a component, DECLARE A PROP \u2014 WITH A `target` \u2014 for every string, link and image a marketer will ever touch; a component with un-propped editable copy is the defect, not the component. In the dock an unset prop shows EMPTY and inherits the definition's default, so set props explicitly when you want the current copy visible there. An IMPORTED site's components are its own (read the repo); its nav, footer and modals are the Layout. On a blank site, do not hand-write a band's JSON: start from a built-in section blueprint (list_components returns locked `builtin:*` blueprints with no projectId \u2014 hero-centered, hero-split, feature-grid-three, cta-banner and nine more), each already rooted in a `section` block with its editable leaves declared as props. INLINE its blockJson as a `section` block for a one-off band; for a recurring band, materialize the blueprint with create_component so it becomes project-scoped before implementation validation, Output or publication. Direct `builtin:*` component references exist only for legacy delivery compatibility. Two consecutive call-to-action buttons are two sibling `button` blocks inside the same section \u2014 never a `columns` block, which is a `repeat(N,1fr)` grid and would stretch each CTA to half the container. Buttons are inline-level and flow side by side on their own.";
|
|
@@ -2933,6 +2957,7 @@ export {
|
|
|
2933
2957
|
DOCK_BUDGET,
|
|
2934
2958
|
DOCK_ICON_NAMES,
|
|
2935
2959
|
DOCK_ICON_NAME_SET,
|
|
2960
|
+
FIELD_STYLE_KEYS,
|
|
2936
2961
|
FOOTER_SECTION_ID,
|
|
2937
2962
|
LANDMARK_SELECTOR,
|
|
2938
2963
|
LAYOUT_SECTION_ICONS,
|
|
@@ -2944,6 +2969,7 @@ export {
|
|
|
2944
2969
|
SECTION_SPACE_TOKENS,
|
|
2945
2970
|
SPACE_BOTTOM_TOKENS,
|
|
2946
2971
|
SPACE_STEP_TOKENS,
|
|
2972
|
+
blockStyleToColumnCss,
|
|
2947
2973
|
blockStyleToCss,
|
|
2948
2974
|
blockStyleToInnerCss,
|
|
2949
2975
|
buttonIconOf,
|
|
@@ -2959,6 +2985,8 @@ export {
|
|
|
2959
2985
|
dockBudget,
|
|
2960
2986
|
dockScreens,
|
|
2961
2987
|
expandBlockBindings,
|
|
2988
|
+
fieldStyleCssText,
|
|
2989
|
+
fieldStyleToCss,
|
|
2962
2990
|
formatPropsAttribute,
|
|
2963
2991
|
getBlockType,
|
|
2964
2992
|
headingPaintCss,
|
|
@@ -2968,6 +2996,7 @@ export {
|
|
|
2968
2996
|
landmarkRegions,
|
|
2969
2997
|
locatorFor,
|
|
2970
2998
|
parsePropsAttribute,
|
|
2999
|
+
pickFieldStyle,
|
|
2971
3000
|
readButtonValue,
|
|
2972
3001
|
readPath,
|
|
2973
3002
|
regionOf,
|