@bettercms-ai/types 1.42.0 → 1.43.1
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 +43 -6
- package/dist/index.js +37 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -721,10 +721,24 @@ type ButtonSizeName = (typeof BUTTON_SIZES)[number];
|
|
|
721
721
|
* carries two.
|
|
722
722
|
*/
|
|
723
723
|
declare function anchorTargetRel(newTab: boolean, rel?: unknown): string;
|
|
724
|
+
/**
|
|
725
|
+
* What a button does when the site's own code decides it: `<button type="button">` opening a
|
|
726
|
+
* dialog, accepting cookies, starting a tour. Such a button has no destination to store, so the
|
|
727
|
+
* value says so outright instead of carrying an empty href nobody can tell from a forgotten one.
|
|
728
|
+
*/
|
|
729
|
+
declare const BUTTON_ACTIONS: readonly ["code"];
|
|
730
|
+
type ButtonAction = (typeof BUTTON_ACTIONS)[number];
|
|
731
|
+
/** Is this stored value a button whose action is the site's code (no href, never an anchor)? */
|
|
732
|
+
declare function isCodeButton(value: unknown): boolean;
|
|
724
733
|
interface ButtonValue {
|
|
725
734
|
label: string;
|
|
726
|
-
/**
|
|
727
|
-
|
|
735
|
+
/**
|
|
736
|
+
* A plain href, or a link object (@see LinkValue) whose newTab / rel apply when the button sets
|
|
737
|
+
* none. Absent (or empty) only beside `action: "code"`.
|
|
738
|
+
*/
|
|
739
|
+
href?: string | LinkValue;
|
|
740
|
+
/** `"code"`: the click is the site's own script. The label and the look are edited; no href, no new tab, no rel. */
|
|
741
|
+
action?: ButtonAction;
|
|
728
742
|
variant?: ButtonVariant;
|
|
729
743
|
size?: ButtonSizeName;
|
|
730
744
|
arrow?: boolean;
|
|
@@ -732,13 +746,28 @@ interface ButtonValue {
|
|
|
732
746
|
newTab?: boolean;
|
|
733
747
|
/** Sponsored, untrusted or user-generated destination. Absent ⇒ no rel beyond a new tab's own. */
|
|
734
748
|
rel?: LinkRel;
|
|
749
|
+
/** Stretch across its column, label centred. Absent ⇒ the button's own width. */
|
|
750
|
+
fullWidth?: boolean;
|
|
735
751
|
}
|
|
736
|
-
/**
|
|
737
|
-
|
|
752
|
+
/**
|
|
753
|
+
* A stored button value as it renders: `rel`, `action` and `fullWidth` stay optional (present only
|
|
754
|
+
* when set, so a value that never named them reads byte-for-byte as before), every other key is filled.
|
|
755
|
+
*/
|
|
756
|
+
type ReadButtonValue = Required<Omit<ButtonValue, "rel" | "href" | "action" | "fullWidth">> & Pick<ButtonValue, "rel" | "action"> & {
|
|
738
757
|
href: string;
|
|
758
|
+
fullWidth?: true;
|
|
739
759
|
};
|
|
740
760
|
/** A stored button value as it renders: every key read through the same allow-lists as a block. */
|
|
741
761
|
declare function readButtonValue(value: unknown): ReadButtonValue;
|
|
762
|
+
/** The named refusal of a `button` value whose `fullWidth` is not true or false. */
|
|
763
|
+
declare const BUTTON_FULL_WIDTH_INVALID = "button_full_width_invalid";
|
|
764
|
+
/**
|
|
765
|
+
* Why a button value's `fullWidth` is refused, or null. Introduced-only: a value whose `fullWidth`
|
|
766
|
+
* is the one `previous` already stored saves (values written before the key was checked keep
|
|
767
|
+
* saving), so only a write that BRINGS a non-boolean is refused. Kept out of `buttonValueProblem`,
|
|
768
|
+
* which also runs baseline-free at readiness and publish.
|
|
769
|
+
*/
|
|
770
|
+
declare function buttonFullWidthProblem(value: unknown, previous?: unknown): string | null;
|
|
742
771
|
/**
|
|
743
772
|
* Why a value is not a button, or null when it is. Look keys are checked only when present.
|
|
744
773
|
* `looks` are the values that pick a look of the project's own Button family (@see
|
|
@@ -746,7 +775,7 @@ declare function readButtonValue(value: unknown): ReadButtonValue;
|
|
|
746
775
|
*/
|
|
747
776
|
declare function buttonValueProblem(value: unknown, looks?: ReadonlySet<string>): string | null;
|
|
748
777
|
/** The look keys an instance of a Button component may override, beside its label and link. */
|
|
749
|
-
declare const BUTTON_LOOK_KEYS: readonly ["variant", "size", "arrow", "icon", "newTab"];
|
|
778
|
+
declare const BUTTON_LOOK_KEYS: readonly ["variant", "size", "arrow", "icon", "newTab", "fullWidth"];
|
|
750
779
|
type ButtonLookKey = (typeof BUTTON_LOOK_KEYS)[number];
|
|
751
780
|
/**
|
|
752
781
|
* A `button` PROP's value as the `button` BLOCK props it writes, for every lane that applies an
|
|
@@ -1040,6 +1069,8 @@ interface ButtonProps {
|
|
|
1040
1069
|
newTab?: boolean;
|
|
1041
1070
|
/** `nofollow`, `sponsored` or `ugc`; joins the anchor's rel. Absent ⇒ none. */
|
|
1042
1071
|
rel?: "nofollow" | "sponsored" | "ugc";
|
|
1072
|
+
/** `"code"`: the click is the site's own script, so it renders `<button type="button">` and `href` is "". Absent ⇒ a link. */
|
|
1073
|
+
action?: "code";
|
|
1043
1074
|
}
|
|
1044
1075
|
interface ButtonBlock {
|
|
1045
1076
|
type: "button";
|
|
@@ -3217,6 +3248,12 @@ type FormFieldUi = {
|
|
|
3217
3248
|
* Windows. They show the country NAME instead, which carries the same information.
|
|
3218
3249
|
*/
|
|
3219
3250
|
showFlags?: boolean;
|
|
3251
|
+
/**
|
|
3252
|
+
* Any field a person answers — the label of the GROUP this field opens: the `<legend>` of the
|
|
3253
|
+
* fieldset it is the first field of ("Your details", "Your message"). Read off a built form by
|
|
3254
|
+
* the import and written back to that form in place; `<BcmsForm>` draws no fieldset yet.
|
|
3255
|
+
*/
|
|
3256
|
+
groupLabel?: string;
|
|
3220
3257
|
};
|
|
3221
3258
|
/**
|
|
3222
3259
|
* FormSubmission — a single form submission submitted by a visitor.
|
|
@@ -3623,4 +3660,4 @@ type SectionPlanItem<B> = {
|
|
|
3623
3660
|
*/
|
|
3624
3661
|
declare function planSections<B>(slots: readonly string[], blocks: readonly B[] | null | undefined): SectionPlanItem<B>[];
|
|
3625
3662
|
|
|
3626
|
-
export { type AlignToken, type ApiError, type ApiKey, type ApiKeyPermission, type ApiKeyTokenType, type ArrayZoneConfig, type AssertEqual, type AuthResponse, type AuthSession, type AuthUser, BLOCK_BINDINGS, BREAKPOINTS, 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 ButtonSiteLook, type ButtonSizeName, type ButtonValue, type ButtonVariant, CODE_SLOT_PREFIX, COMPONENT_PROP_TYPES, type CanonicalInputDefinition, type ChoiceOption, type CollectionBlock, type CollectionFilter, 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_SIZE_ZOOM, FIELD_STYLE_KEYS, FOOTER_SECTION_ID, type FieldConfig, type FieldSize, 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, LINK_RELS, LINK_VALUE_TYPES, 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 LinkRel, type LinkValue, type LinkValueType, type LocatorGrammar, MAIN_SELECTOR, type ManagementLayoutCommand, type MediaAsset, type MediaCaptionTrack, type MediaFieldValue, NAVIGATION_SECTION_ID, type NavLink, type NavbarBlock, type NavbarProps, type NumberFieldFormat, type NumberScale, OPTION_DESCRIPTION_MAX, type OpenMode, 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, RESPONSIVE_CSS, type RadiusToken, type ReadButtonValue, type Redirect, type ReservedLayoutSection, type ResolvedLayoutNode, type RichTextBlock, type RichTextProps, SECTION_DOCTRINE, SECTION_SPACE_TOKENS, SLOT_CHILD_KEYS, SLOT_ITEMS_CAP, SLOT_MAX_ITEMS, SPACE_BOTTOM_TOKENS, SPACE_STEP_TOKENS, type ScaleUnit, type SectionBlock, type SectionPlanItem, type SectionProps, type SectionSpaceToken, type ShadowToken, type ShowIf, type ShowIfRule, type SignInInput, type SignUpInput, type SiteSeoDefaults, type SlideItem, type SliderBlock, type SliderProps, type SlotChild, type SlotItem, type SlotShapeOptions, type SlotShapeProblem, type SlotValue, type SpaceStepToken, type SpaceToken, type SpacerBlock, type SpacerProps, TABLE_COLUMN_TYPES, TABLE_JSONLD_TYPES, TABLE_LIMITS, TABLE_RESPONSIVE, TAG_HEADS, type TabItem, type TableCell, type TableCellObject, type TableCellValue, type TableCheckOptions, type TableColumn, type TableColumnType, type TableFieldOptions, type TableFootnote, type TableGroup, type TableLink, type TableProblem, type TableRef, type TableRefResolved, type TableRow, type TableValue, type TabsBlock, type TabsProps, type TextBlock, type TextProps, type ThemeToken, type UiBefore, type UiOrigin, VIDEO_TRANSCRIPT_MAX, VIDEO_VALUE_KEYS, type VariantInputMapping, type VideoBlock, type VideoProps, type VideoValue, type VisibilityWindow, type WeightToken, type WindowState, type Workspace, type ZoneField, anchorTargetRel, blockStyleToColumnCss, blockStyleToCss, blockStyleToInnerCss, buttonBlockProps, buttonIconOf, buttonIconSvg, buttonLinkPairs, buttonLookValue, buttonSiteLookOf, buttonValueOfInstance, buttonValueProblem, buttonVariantOf, candidateRole, componentInstanceAddresses, componentPropTargetKey, derivedPairs, dockBudget, dockScreens, expandBlockBindings, fieldGroupOf, fieldStyleCssText, fieldStyleToCss, formatNumber, formatPropsAttribute, getBlockType, headingPaintCss, hideOnAttr, inWindow, isBlock, isButtonLookValue, isChromeLandmark, isLinkObject, isScriptHref, isSlotChild, isTableValue, keyWords, landmarkRegions, linkAnchorOf, linkHref, linkRefOf, linkValueProblem, locatorFor, normalizeLinkValue, normalizeTableValue, normalizeWindow, parseNumberText, parsePropsAttribute, pickFieldStyle, placementBindOf, planSections, readButtonValue, readNumberFormat, readPath, regionOf, renderTableHtml, safeCssUrl, slotBindOf, slotChildValues, slotItems, slotPathString, slotShapeProblems, spaceTokenCss, splitButtonStyle, tableCellText, tablePathString, tableRefCells, tableSearchText, tableToMarkdown, tableValueProblems, topFieldKeyOf, usesHideOn, videoUrlOf, videoValueProblem, visibleBlocks, visibleDeliveredLayout, visibleLayoutStructure, windowState, withButtonLookProps };
|
|
3663
|
+
export { type AlignToken, type ApiError, type ApiKey, type ApiKeyPermission, type ApiKeyTokenType, type ArrayZoneConfig, type AssertEqual, type AuthResponse, type AuthSession, type AuthUser, BLOCK_BINDINGS, BREAKPOINTS, BUTTON_ACTIONS, BUTTON_FULL_WIDTH_INVALID, 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 ButtonAction, type ButtonBlock, type ButtonIcon, type ButtonLinkCandidate, type ButtonLookKey, type ButtonProps, type ButtonSiteLook, type ButtonSizeName, type ButtonValue, type ButtonVariant, CODE_SLOT_PREFIX, COMPONENT_PROP_TYPES, type CanonicalInputDefinition, type ChoiceOption, type CollectionBlock, type CollectionFilter, 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_SIZE_ZOOM, FIELD_STYLE_KEYS, FOOTER_SECTION_ID, type FieldConfig, type FieldSize, 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, LINK_RELS, LINK_VALUE_TYPES, 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 LinkRel, type LinkValue, type LinkValueType, type LocatorGrammar, MAIN_SELECTOR, type ManagementLayoutCommand, type MediaAsset, type MediaCaptionTrack, type MediaFieldValue, NAVIGATION_SECTION_ID, type NavLink, type NavbarBlock, type NavbarProps, type NumberFieldFormat, type NumberScale, OPTION_DESCRIPTION_MAX, type OpenMode, 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, RESPONSIVE_CSS, type RadiusToken, type ReadButtonValue, type Redirect, type ReservedLayoutSection, type ResolvedLayoutNode, type RichTextBlock, type RichTextProps, SECTION_DOCTRINE, SECTION_SPACE_TOKENS, SLOT_CHILD_KEYS, SLOT_ITEMS_CAP, SLOT_MAX_ITEMS, SPACE_BOTTOM_TOKENS, SPACE_STEP_TOKENS, type ScaleUnit, type SectionBlock, type SectionPlanItem, type SectionProps, type SectionSpaceToken, type ShadowToken, type ShowIf, type ShowIfRule, type SignInInput, type SignUpInput, type SiteSeoDefaults, type SlideItem, type SliderBlock, type SliderProps, type SlotChild, type SlotItem, type SlotShapeOptions, type SlotShapeProblem, type SlotValue, type SpaceStepToken, type SpaceToken, type SpacerBlock, type SpacerProps, TABLE_COLUMN_TYPES, TABLE_JSONLD_TYPES, TABLE_LIMITS, TABLE_RESPONSIVE, TAG_HEADS, type TabItem, type TableCell, type TableCellObject, type TableCellValue, type TableCheckOptions, type TableColumn, type TableColumnType, type TableFieldOptions, type TableFootnote, type TableGroup, type TableLink, type TableProblem, type TableRef, type TableRefResolved, type TableRow, type TableValue, type TabsBlock, type TabsProps, type TextBlock, type TextProps, type ThemeToken, type UiBefore, type UiOrigin, VIDEO_TRANSCRIPT_MAX, VIDEO_VALUE_KEYS, type VariantInputMapping, type VideoBlock, type VideoProps, type VideoValue, type VisibilityWindow, type WeightToken, type WindowState, type Workspace, type ZoneField, anchorTargetRel, blockStyleToColumnCss, blockStyleToCss, blockStyleToInnerCss, buttonBlockProps, buttonFullWidthProblem, buttonIconOf, buttonIconSvg, buttonLinkPairs, buttonLookValue, buttonSiteLookOf, buttonValueOfInstance, buttonValueProblem, buttonVariantOf, candidateRole, componentInstanceAddresses, componentPropTargetKey, derivedPairs, dockBudget, dockScreens, expandBlockBindings, fieldGroupOf, fieldStyleCssText, fieldStyleToCss, formatNumber, formatPropsAttribute, getBlockType, headingPaintCss, hideOnAttr, inWindow, isBlock, isButtonLookValue, isChromeLandmark, isCodeButton, isLinkObject, isScriptHref, isSlotChild, isTableValue, keyWords, landmarkRegions, linkAnchorOf, linkHref, linkRefOf, linkValueProblem, locatorFor, normalizeLinkValue, normalizeTableValue, normalizeWindow, parseNumberText, parsePropsAttribute, pickFieldStyle, placementBindOf, planSections, readButtonValue, readNumberFormat, readPath, regionOf, renderTableHtml, safeCssUrl, slotBindOf, slotChildValues, slotItems, slotPathString, slotShapeProblems, spaceTokenCss, splitButtonStyle, tableCellText, tablePathString, tableRefCells, tableSearchText, tableToMarkdown, tableValueProblems, topFieldKeyOf, usesHideOn, videoUrlOf, videoValueProblem, visibleBlocks, visibleDeliveredLayout, visibleLayoutStructure, windowState, withButtonLookProps };
|
package/dist/index.js
CHANGED
|
@@ -3433,27 +3433,47 @@ function anchorTargetRel(newTab, rel) {
|
|
|
3433
3433
|
const tokens = [...newTab ? ["noopener", "noreferrer"] : [], ...LINK_RELS.includes(rel) ? [rel] : []];
|
|
3434
3434
|
return `${newTab ? ' target="_blank"' : ""}${tokens.length ? ` rel="${tokens.join(" ")}"` : ""}`;
|
|
3435
3435
|
}
|
|
3436
|
+
var BUTTON_ACTIONS = ["code"];
|
|
3437
|
+
function isCodeButton(value) {
|
|
3438
|
+
return !!value && typeof value === "object" && value.action === "code";
|
|
3439
|
+
}
|
|
3436
3440
|
var hrefOf = linkHref;
|
|
3437
3441
|
function readButtonValue(value) {
|
|
3438
3442
|
const v = value && typeof value === "object" ? value : {};
|
|
3439
3443
|
const link = isLinkObject(v.href) ? linkAnchorOf(v.href) : null;
|
|
3440
3444
|
const rel = v.rel ?? link?.rel;
|
|
3445
|
+
const code = v.action === "code";
|
|
3441
3446
|
return {
|
|
3442
3447
|
label: typeof v.label === "string" ? v.label : "",
|
|
3443
|
-
href: hrefOf(v.href) ?? "",
|
|
3448
|
+
href: code ? "" : hrefOf(v.href) ?? "",
|
|
3444
3449
|
variant: buttonVariantOf(v.variant),
|
|
3445
3450
|
size: BUTTON_SIZES.includes(v.size) ? v.size : "md",
|
|
3446
3451
|
arrow: v.arrow === true,
|
|
3447
3452
|
icon: buttonIconOf(v.icon),
|
|
3448
|
-
newTab: v.newTab === void 0 ? link?.newTab === true : v.newTab === true,
|
|
3449
|
-
|
|
3453
|
+
newTab: code ? false : v.newTab === void 0 ? link?.newTab === true : v.newTab === true,
|
|
3454
|
+
...!code && LINK_RELS.includes(rel) ? { rel } : {},
|
|
3455
|
+
...code ? { action: "code" } : {},
|
|
3456
|
+
...v.fullWidth === true ? { fullWidth: true } : {}
|
|
3450
3457
|
};
|
|
3451
3458
|
}
|
|
3459
|
+
var BUTTON_FULL_WIDTH_INVALID = "button_full_width_invalid";
|
|
3460
|
+
function buttonFullWidthProblem(value, previous) {
|
|
3461
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
3462
|
+
const fullWidth = value.fullWidth;
|
|
3463
|
+
if (fullWidth === void 0 || typeof fullWidth === "boolean") return null;
|
|
3464
|
+
const before = previous && typeof previous === "object" ? previous.fullWidth : void 0;
|
|
3465
|
+
if (before !== void 0 && JSON.stringify(before) === JSON.stringify(fullWidth)) return null;
|
|
3466
|
+
return `${BUTTON_FULL_WIDTH_INVALID}: fullWidth must be true or false`;
|
|
3467
|
+
}
|
|
3452
3468
|
function buttonValueProblem(value, looks) {
|
|
3453
3469
|
if (!value || typeof value !== "object" || Array.isArray(value)) return "must be a { label, href } button";
|
|
3454
3470
|
const v = value;
|
|
3455
3471
|
if (typeof v.label !== "string") return "needs a label";
|
|
3456
|
-
if (
|
|
3472
|
+
if (v.action !== void 0 && !BUTTON_ACTIONS.includes(v.action)) return `has an unknown action "${String(v.action)}" (code, or none for a link)`;
|
|
3473
|
+
if (v.action === "code") {
|
|
3474
|
+
if (v.href !== void 0 && v.href !== null && v.href !== "") return 'takes no href with action "code"';
|
|
3475
|
+
if (v.newTab === true || v.rel !== void 0) return 'takes no newTab or rel with action "code"';
|
|
3476
|
+
} else if (hrefOf(v.href) === null) return `needs an href (or action "code" for a button the site's script handles)`;
|
|
3457
3477
|
if (isLinkObject(v.href)) {
|
|
3458
3478
|
const problem = linkValueProblem(v.href);
|
|
3459
3479
|
if (problem) return `href ${problem}`;
|
|
@@ -3468,12 +3488,18 @@ function buttonValueProblem(value, looks) {
|
|
|
3468
3488
|
if (v.icon !== void 0 && v.icon !== null && buttonIconOf(v.icon) === null) return `has an unknown icon "${String(v.icon)}"`;
|
|
3469
3489
|
return null;
|
|
3470
3490
|
}
|
|
3471
|
-
var BUTTON_LOOK_KEYS = ["variant", "size", "arrow", "icon", "newTab"];
|
|
3491
|
+
var BUTTON_LOOK_KEYS = ["variant", "size", "arrow", "icon", "newTab", "fullWidth"];
|
|
3472
3492
|
function buttonBlockProps(value) {
|
|
3473
3493
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
3474
3494
|
const v = value;
|
|
3475
3495
|
const out = {};
|
|
3476
3496
|
if (typeof v.label === "string") out.text = v.label;
|
|
3497
|
+
if (v.action === "code") {
|
|
3498
|
+
out.action = "code";
|
|
3499
|
+
out.href = "";
|
|
3500
|
+
for (const key of BUTTON_LOOK_KEYS) if (key in v && key !== "newTab") out[key] = v[key];
|
|
3501
|
+
return out;
|
|
3502
|
+
}
|
|
3477
3503
|
const href = hrefOf(v.href);
|
|
3478
3504
|
const script = href !== null && isScriptHref(href);
|
|
3479
3505
|
if (href !== null) out.href = script ? "#" : href;
|
|
@@ -3499,8 +3525,8 @@ function soleButtonId(blockJson) {
|
|
|
3499
3525
|
walk(blockJson);
|
|
3500
3526
|
return ids.length === 1 ? ids[0] : null;
|
|
3501
3527
|
}
|
|
3502
|
-
var LOOK_PROP_TYPE = { variant: "text", size: "text", arrow: "boolean", icon: "text", newTab: "boolean" };
|
|
3503
|
-
var LOOK_PROP_LABEL = { variant: "Style", size: "Size", arrow: "Show arrow", icon: "Leading icon", newTab: "Open in new tab" };
|
|
3528
|
+
var LOOK_PROP_TYPE = { variant: "text", size: "text", arrow: "boolean", icon: "text", newTab: "boolean", fullWidth: "boolean" };
|
|
3529
|
+
var LOOK_PROP_LABEL = { variant: "Style", size: "Size", arrow: "Show arrow", icon: "Leading icon", newTab: "Open in new tab", fullWidth: "Full width" };
|
|
3504
3530
|
function withButtonLookProps(def) {
|
|
3505
3531
|
const props = [...def.props ?? []];
|
|
3506
3532
|
if (def.category !== "button") return props;
|
|
@@ -4219,6 +4245,8 @@ function planSections(slots, blocks) {
|
|
|
4219
4245
|
export {
|
|
4220
4246
|
BLOCK_BINDINGS,
|
|
4221
4247
|
BREAKPOINTS,
|
|
4248
|
+
BUTTON_ACTIONS,
|
|
4249
|
+
BUTTON_FULL_WIDTH_INVALID,
|
|
4222
4250
|
BUTTON_ICONS,
|
|
4223
4251
|
BUTTON_ICON_NAMES,
|
|
4224
4252
|
BUTTON_LOOK_KEYS,
|
|
@@ -4263,6 +4291,7 @@ export {
|
|
|
4263
4291
|
blockStyleToCss,
|
|
4264
4292
|
blockStyleToInnerCss,
|
|
4265
4293
|
buttonBlockProps,
|
|
4294
|
+
buttonFullWidthProblem,
|
|
4266
4295
|
buttonIconOf,
|
|
4267
4296
|
buttonIconSvg,
|
|
4268
4297
|
buttonLinkPairs,
|
|
@@ -4290,6 +4319,7 @@ export {
|
|
|
4290
4319
|
isBlock,
|
|
4291
4320
|
isButtonLookValue,
|
|
4292
4321
|
isChromeLandmark,
|
|
4322
|
+
isCodeButton,
|
|
4293
4323
|
isLinkObject,
|
|
4294
4324
|
isScriptHref,
|
|
4295
4325
|
isSlotChild,
|