@bettercms-ai/types 1.63.0 → 1.66.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 +106 -7
- package/dist/index.js +113 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ type V2Shape = (typeof V2_SHAPES)[number];
|
|
|
91
91
|
declare const V2_PLACEMENTS: readonly ["inline", "section", "page"];
|
|
92
92
|
/** Where a block may be placed. */
|
|
93
93
|
type V2Placement = (typeof V2_PLACEMENTS)[number];
|
|
94
|
-
/** The kit catalogue's categories, verbatim (
|
|
94
|
+
/** The kit catalogue's categories, verbatim (packages/kit/src/library/catalog.ts CATEGORY_ORDER). */
|
|
95
95
|
declare const KIT_CATEGORIES: readonly ["Navigation & chrome", "Heroes", "Features & storytelling", "Social proof", "Media & galleries", "Commerce", "Pricing & plans", "Conversion & forms", "Listings & feeds", "Long-form & docs", "Company & people", "Events & places", "Data & interactive", "Advanced patterns"];
|
|
96
96
|
type KitCategory = (typeof KIT_CATEGORIES)[number];
|
|
97
97
|
/** The catalogue's order, by the name the facet table bounds `category` with. */
|
|
@@ -1157,9 +1157,12 @@ type AlignToken = "left" | "center" | "right";
|
|
|
1157
1157
|
type FontSizeToken = "sm" | "base" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl";
|
|
1158
1158
|
type WeightToken = "normal" | "medium" | "semibold" | "bold";
|
|
1159
1159
|
type RadiusToken = "none" | "sm" | "md" | "lg" | "full";
|
|
1160
|
-
|
|
1161
|
-
type
|
|
1162
|
-
|
|
1160
|
+
declare const THEME_TOKENS: readonly ["inherit", "light", "dark"];
|
|
1161
|
+
type ThemeToken = (typeof THEME_TOKENS)[number];
|
|
1162
|
+
declare const BG_TOKENS: readonly ["none", "surface", "muted", "accent", "dark", "custom"];
|
|
1163
|
+
type BgToken = (typeof BG_TOKENS)[number];
|
|
1164
|
+
declare const CONTENT_WIDTH_TOKENS: readonly ["narrow", "default", "wide", "full"];
|
|
1165
|
+
type ContentWidthToken = (typeof CONTENT_WIDTH_TOKENS)[number];
|
|
1163
1166
|
type CornerToken = "0" | "s" | "m" | "l" | "xl" | "2xl";
|
|
1164
1167
|
type ShadowToken = "0" | "s" | "m" | "l" | "xl";
|
|
1165
1168
|
interface BlockStyle {
|
|
@@ -2627,7 +2630,8 @@ interface ComponentPropDef {
|
|
|
2627
2630
|
* date → `YYYY-MM-DD`
|
|
2628
2631
|
* color → a hex colour (`#RGB`, `#RRGGBB`, `#RRGGBBAA`)
|
|
2629
2632
|
* file → `{ url, name?, size? }`, or a bare URL string
|
|
2630
|
-
* icon → a BetterCMS icon name (`DOCK_ICON_NAMES`),
|
|
2633
|
+
* icon → a BetterCMS icon name (`DOCK_ICON_NAMES`), an uploaded icon as an image value, or a D65 icon object
|
|
2634
|
+
* (`{ source: pack | library | upload, …, label? }`, icon-value.ts); `config.icons` says which sources a field offers
|
|
2631
2635
|
* multiselect → a `string[]`, each one of `config.options`
|
|
2632
2636
|
* object → ONE `{ [childKey]: value }` keyed by `config.fields` (the V2 model-field `object`)
|
|
2633
2637
|
* datetime · slug · email · phone · json · location → what the same-named model FIELD stores
|
|
@@ -4329,7 +4333,7 @@ declare function fieldGroupOf(topKey: string, flat?: boolean): {
|
|
|
4329
4333
|
* section added from the library carries neither, which is how it is told apart: the site's code
|
|
4330
4334
|
* has nothing to draw it with.
|
|
4331
4335
|
*/
|
|
4332
|
-
declare function placementBindOf(block: unknown): string | null;
|
|
4336
|
+
declare function placementBindOf(block: unknown, groupOf?: (topKey: string) => string | undefined): string | null;
|
|
4333
4337
|
/**
|
|
4334
4338
|
* A slot the CMS was not known to hold when the page was wrapped is spelled `code:<bind>`.
|
|
4335
4339
|
* It matches a block bound to `<bind>` like the bare spelling does; it differs only when no block
|
|
@@ -4788,4 +4792,99 @@ declare function isVariantVisible(prop: PropLike, values: Record<string, unknown
|
|
|
4788
4792
|
*/
|
|
4789
4793
|
declare const slugify: (s: string) => string;
|
|
4790
4794
|
|
|
4791
|
-
|
|
4795
|
+
/**
|
|
4796
|
+
* ICON (V2 D65): an `icon` field's options and its stored value. Pure: no React, no I/O.
|
|
4797
|
+
*
|
|
4798
|
+
* Where an icon may come from is the field's choice (`config.icons`, V2 `FieldSchema.icons`):
|
|
4799
|
+
* pack a name from the BetterCMS icon set (DOCK_ICON_NAMES)
|
|
4800
|
+
* library an SVG from the project's icon library (brand kit), sanitised on upload
|
|
4801
|
+
* upload an image from the media library
|
|
4802
|
+
* With no `icons`, a field offers the pack and an upload: what the icon field always offered.
|
|
4803
|
+
*
|
|
4804
|
+
* Stored values, every one of them read:
|
|
4805
|
+
* "arrow-right" pack (the short form)
|
|
4806
|
+
* "https://…/logo.svg" · { url, alt? } upload, as stored before D65
|
|
4807
|
+
* { source: "pack", name, label? }
|
|
4808
|
+
* { source: "library", id, url, followsText?, label? }
|
|
4809
|
+
* { source: "upload", url, assetId?, label? }
|
|
4810
|
+
* A library or upload value carries its resolved `url`, so a site draws it with no lookup. `label` is the
|
|
4811
|
+
* accessible name; none = decorative. A write keeps the oldest form that says the same thing (compactIcon), so a
|
|
4812
|
+
* field that never opts in stores exactly what it did before.
|
|
4813
|
+
*/
|
|
4814
|
+
type IconSource = "pack" | "library" | "upload";
|
|
4815
|
+
interface IconFieldOptions {
|
|
4816
|
+
/** Where an icon may come from, in tab order. Default ["pack", "upload"]. */
|
|
4817
|
+
sources?: IconSource[];
|
|
4818
|
+
/** Library sets (ids) the Library tab offers. Default: the whole library. */
|
|
4819
|
+
sets?: string[];
|
|
4820
|
+
/** false = only icons that follow the text colour (no multicolour SVG, no images). Default true. */
|
|
4821
|
+
allowColor?: boolean;
|
|
4822
|
+
/** "always" (default) = decorative, aria-hidden. "ask" = a "Describe this icon" input under the picker. */
|
|
4823
|
+
decorative?: "always" | "ask";
|
|
4824
|
+
}
|
|
4825
|
+
interface PackIconValue {
|
|
4826
|
+
source: "pack";
|
|
4827
|
+
name: string;
|
|
4828
|
+
label?: string;
|
|
4829
|
+
}
|
|
4830
|
+
interface LibraryIconValue {
|
|
4831
|
+
source: "library";
|
|
4832
|
+
id: string;
|
|
4833
|
+
url: string;
|
|
4834
|
+
/** a single-colour SVG drawn in the text colour (a CSS mask), not as an image */
|
|
4835
|
+
followsText?: boolean;
|
|
4836
|
+
label?: string;
|
|
4837
|
+
}
|
|
4838
|
+
interface UploadIconValue {
|
|
4839
|
+
source: "upload";
|
|
4840
|
+
url: string;
|
|
4841
|
+
assetId?: string;
|
|
4842
|
+
label?: string;
|
|
4843
|
+
}
|
|
4844
|
+
type IconObjectValue = PackIconValue | LibraryIconValue | UploadIconValue;
|
|
4845
|
+
/** What an icon field stores. */
|
|
4846
|
+
type IconValue = string | IconObjectValue | {
|
|
4847
|
+
url: string;
|
|
4848
|
+
alt?: string;
|
|
4849
|
+
};
|
|
4850
|
+
declare const ICON_SOURCES: readonly IconSource[];
|
|
4851
|
+
declare const DEFAULT_ICON_SOURCES: readonly IconSource[];
|
|
4852
|
+
/** An icon's accessible name, at most this long (the platform's help line). */
|
|
4853
|
+
declare const ICON_LABEL_MAX = 80;
|
|
4854
|
+
interface ResolvedIconOptions {
|
|
4855
|
+
sources: IconSource[];
|
|
4856
|
+
sets?: string[];
|
|
4857
|
+
allowColor: boolean;
|
|
4858
|
+
decorative: "always" | "ask";
|
|
4859
|
+
}
|
|
4860
|
+
declare function resolveIconOptions(o?: IconFieldOptions): ResolvedIconOptions;
|
|
4861
|
+
/** Any stored value (string, object, junk) → the object form, or null when there is no icon. */
|
|
4862
|
+
declare function normalizeIcon(v: unknown): IconObjectValue | null;
|
|
4863
|
+
/** The oldest form that means the same thing: a pack name or an upload URL with nothing else stays a bare string. */
|
|
4864
|
+
declare function compactIcon(v: IconObjectValue | null): IconValue | "";
|
|
4865
|
+
/** Whether a value needs an object form (D65's labels, library or a media asset id). */
|
|
4866
|
+
declare const isIconObjectForm: (v: unknown) => boolean;
|
|
4867
|
+
/** The icon itself, ignoring its label: "pack:flame", "library:ic_1", "upload:https://…". "" for none. */
|
|
4868
|
+
declare function iconIdentity(v: unknown): string;
|
|
4869
|
+
/** Same icon, new accessible name. "" removes the label (decorative). */
|
|
4870
|
+
declare function withIconLabel(v: unknown, label: string): IconValue | "";
|
|
4871
|
+
/** What a renderer draws: a set name, or a URL (masked in the text colour when it follows the text). */
|
|
4872
|
+
type IconSrc = {
|
|
4873
|
+
name: string;
|
|
4874
|
+
label?: string;
|
|
4875
|
+
} | {
|
|
4876
|
+
url: string;
|
|
4877
|
+
followsText: boolean;
|
|
4878
|
+
label?: string;
|
|
4879
|
+
};
|
|
4880
|
+
declare function iconSrc(v: unknown): IconSrc | null;
|
|
4881
|
+
/** Why a stored icon value is refused, or null. `knownName` is the icon-set check; `isUrl` the fetchable-URL check. */
|
|
4882
|
+
declare function iconValueProblem(v: unknown, knownName: (name: string) => boolean, isUrl: (url: string) => boolean): string | null;
|
|
4883
|
+
/**
|
|
4884
|
+
* An icon value as HTML (the string renderers: the Astro SDK's <BcmsIcon>): a set name as the shipped <svg>, a library
|
|
4885
|
+
* icon that follows the text as a span masked in currentColor, any other url as an <img>. A label names it; without one
|
|
4886
|
+
* it is decorative. "" when there is no icon, or a name the set does not have.
|
|
4887
|
+
*/
|
|
4888
|
+
declare function iconHtml(v: unknown, className?: string): string;
|
|
4889
|
+
|
|
4890
|
+
export { type AlignToken, type AllowRule, type ApiError, type ApiKey, type ApiKeyPermission, type ApiKeyTokenType, type ApproveDockUiInput, type ApproveDockUiOutput, type ArrayZoneConfig, type AssertEqual, type AuthResponse, type AuthSession, type AuthUser, BG_TOKENS, BLOCK_BINDINGS, BLOCK_FIELD_TYPES, BLOCK_FIELD_TYPES_RENDERABLE_NOW, BODY_SCHEMA_ORIGINS, 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 BodiesState, type BodyDeclaration, type BodySchema, type BodySchemaOrigin, type ButtonAction, type ButtonBlock, type ButtonIcon, type ButtonLinkCandidate, type ButtonLookKey, type ButtonProps, type ButtonSiteLook, type ButtonSizeName, type ButtonValue, type ButtonVariant, CANVAS_GESTURE_NAMES, CATEGORY_ID_MAX, CATEGORY_ORDER, CODE_SLOT_PREFIX, COMPONENT_GATE_CODES, COMPONENT_PROP_TYPES, CONTENT_WIDTH_TOKENS, CONTROL_HELP, type CanonicalInputDefinition, type CanvasGesture, type ChoiceOption, type CollectionBlock, type CollectionFilter, type CollectionProps, type ColorToken, type ColumnsBlock, type ColumnsProps, type Component, type ComponentBlock, type ComponentCategory, type ComponentCategoryId, type ComponentEmbedNode, type ComponentFormPropRef, type ComponentGateCode, type ComponentPreview, type ComponentPropDef, type ComponentPropType, type ComponentPropUi, type ComponentProps, type ComponentSubField, type ComponentTab, type ComponentV2, type ComponentVariantGroup, type Content, type ContentBlock, type ContentEntry, type ContentModel, type ContentModelField, type ContentModelFieldType, type ContentModelFieldUi, type ContentModelV2, type ContentPageResult, type ContentResponse, type ContentWidthToken, type ControlKind, type CornerToken, DEFAULT_ICON_SOURCES, DEFAULT_VARIANT, DEPTH_MAX, DERIVE_MINTED_RESERVED, DIALOG_SELECTOR, DOCK_BUDGET, DOCK_ICON_NAMES, DOCK_ICON_NAME_SET, DOCK_UI_IMPORTS, DOCK_UI_LIMITS, DOCK_UI_NAME, type DeclaredSlot, type DeepReadonly, type DefSources, 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 DockUiBuildReceipt, type DockUiKind, type DockUiOrigin, type DockUiScope, type DockUiSource, type DockUiStatus, type DockUiVersion, EMBED_LEDGER_OUTCOMES, EMBED_REASONS, type ElementLike, type EmbedCapability, type EmbedCard, type EmbedLedgerOutcome, type EmbedMarker, type EmbedMarkerMatch, type EmbedNotRenderedWarning, type EmbedReason, type ExpandedBinding, FIELD_SIZE_ZOOM, FIELD_STYLE_KEYS, FOOTER_SECTION_ID, FRAME_REFUSALS, 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, HELP_CAPS, HELP_LINE_MAX, HELP_MAX, HELP_WRITE_MAX, type HeadingBlock, type HeadingProps, ICON_LABEL_MAX, ICON_SOURCES, IMAGE_ASPECTS, IMAGE_FRAME_RADIUS, type IconFieldOptions, type IconObjectValue, type IconSource, type IconSrc, type IconValue, type ImageAspect, type ImageBlock, type ImageProps, KEY_FORBIDDEN, KEY_FORMAT, KEY_RESERVED, KEY_RESERVED_PREFIX, KIT_CATEGORIES, type KitCategory, LANDMARK_SELECTOR, LAYOUT_SECTION_ICONS, LAYOUT_SECTION_ICON_SET, LINK_RELS, LINK_VALUE_TYPES, LIST_ITEMS_CAP, LIST_PREVIEW_SLOTS, LOCATOR_PATH, type LandmarkChainElement, type LandmarkElement, type LayoutComponentItem, type LayoutDataDocument, type LayoutFieldDefinition, type LayoutFieldItem, type LayoutFieldType, type LayoutScalarFieldType, type LayoutSection, type LayoutSectionDesign, type LayoutSectionIcon, type LayoutSectionItem, type LayoutStructureDocument, type LayoutZone, type LibraryIconValue, type LinkPairSibling, type LinkRel, type LinkValue, type LinkValueType, type ListDockUiInput, type ListDockUiOutput, 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, OPEN_MODES, OPEN_MODE_TYPES, OPTION_DESCRIPTION_MAX, type OpenMode, PAGE_CONTENT_ANCHOR_ID, PRIMITIVE_ARRAY_RULE, type PackIconValue, 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 PropTab, type PublishDockUiInput, type PublishDockUiOutput, REFERENCE_CREATE_REFUSAL_CODES, RESPONSIVE_CSS, RICHTEXT_ADVANCED_ELEMENTS, RICHTEXT_BLOCK_ELEMENTS, RICHTEXT_BLOCK_FEATURES, RICHTEXT_CORE_ELEMENTS, RICHTEXT_ELEMENTS, RICHTEXT_FEATURES, RICHTEXT_FEATURE_ALIASES, RICHTEXT_HEADING_FEATURES, RICHTEXT_MARK_FEATURES, RICHTEXT_TOGGLE_FEATURES, ROLE_KEYS, type RadiusToken, type ReadButtonValue, type Redirect, type ReferenceCreateCapability, type ReferenceCreateRefusal, type ReferenceCreateRefusalCode, type ReferenceCreateResult, type ReferenceCreatedOption, type ReservedLayoutSection, type ResolvedAuthor, type ResolvedIconOptions, type ResolvedLayoutNode, type ResolvedPost, type RichTextBlock, type RichTextElementName, type RichTextEmbeds, type RichTextFeature, type RichTextProps, type RichTextRefusalCode, type RichTextResolved, SCHEMA_HASH_INPUTS, SECTION_DOCTRINE, SECTION_SPACE_TOKENS, SEGMENTED_MAX, SEGMENTED_MIN, SHOW_IF_SCOPES, SIDE_SPACE_MIN_PX, SIDE_SPACE_TOKENS, SLOT_CHILD_KEYS, SLOT_ITEMS_CAP, SLOT_MAX_ITEMS, SLOT_SETTINGS_MAX, SLOT_SETTINGS_TYPES, SOURCE_RANK, SPACE_BOTTOM_TOKENS, SPACE_STEP_TOKENS, type ScaleUnit, type SchemaHashTable, type SchemaSource, 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 SourcedFacet, type SpaceStepToken, type SpaceToken, type SpacerBlock, type SpacerProps, TABLE_COLUMN_TYPES, TABLE_JSONLD_TYPES, TABLE_LIMITS, TABLE_RESPONSIVE, TAB_MAX, TAB_MAX_RENDERABLE_NOW, TAG_HEADS, THEME_TOKENS, 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, UI_PROTOCOLS, UI_REFUSAL_CODES, UI_REFUSAL_IDS, type UiBefore, type UiManifestEntry, type UiManifestV2, type UiOrigin, type UiProtocol, type UiRefusal, type UiRefusalFamily, type UiRefusalId, type UploadIconValue, type V2Placement, type V2Shape, type V2VariantMeta, V2_KEYS, V2_PLACEMENTS, V2_SHAPES, VARIANT_PROP_KEY, VIDEO_TRANSCRIPT_MAX, VIDEO_VALUE_KEYS, type ValidateDockUiInput, type ValidateDockUiOutput, type VariantGroupV2, type VariantInputMapping, type VideoBlock, type VideoProps, type VideoValue, type VisibilityWindow, WIDTH_FIT_FAIL_KINDS, type WeightToken, type WidthFitFailKind, type WidthFitResult, type WindowState, type Workspace, type WriteDockUiInput, type WriteDockUiOutput, type ZoneField, allowRuleOf, anchorTargetRel, blockStyleToColumnCss, blockStyleToCss, blockStyleToInnerCss, bodySchemaOf, buttonBlockProps, buttonFullWidthProblem, buttonIconOf, buttonIconSvg, buttonLinkPairs, buttonLookValue, buttonSiteLookOf, buttonValueOfInstance, buttonValueProblem, buttonVariantOf, candidateRole, canonicalJson, compactIcon, componentInstanceAddresses, componentPropTargetKey, derivedPairs, dockBudget, dockScreens, dockUiMerkleKey, embedAddress, embedMarkerHtml, embedVisible, evaluateShowIf, exampleFor, expandBlockBindings, fieldGroupOf, fieldStyleCssText, fieldStyleToCss, formatNumber, formatPropsAttribute, getBlockType, headingPaintCss, hiddenEverywhere, hideOnAttr, iconHtml, iconIdentity, iconSrc, iconValueProblem, imageFrameCss, inWindow, isBlock, isButtonLookValue, isChromeLandmark, isCodeButton, isComponentGateCode, isDeriveReservedKey, isDockUiImportAllowed, isEmbedReason, isIconObjectForm, isLinkObject, isReservedKey, isRoleKey, isRulePaired, isScriptHref, isSlotChild, isTableValue, isUiRefusal, isVariantVisible, keyWords, landmarkRegions, linkAnchorOf, linkHref, linkRefOf, linkValueProblem, locatorFor, locatorPath, mayOverwrite, normaliseRichTextFeatures, normalizeIcon, normalizeLinkValue, normalizeTableValue, normalizeWindow, parseEmbedMarkers, parseNumberText, parsePropsAttribute, pickFieldStyle, placementBindOf, planSections, readButtonValue, readNumberFormat, readPath, referenceCreateRefusal, regionOf, renderTableHtml, resolveIconOptions, richTextRefusal, rulePartnerOf, safeCssUrl, schemaHashInput, sideFloorApplies, sideSpaceCss, slotBindOf, slotChildValues, slotItems, slotPathString, slotShapeProblems, slugify, spaceTokenCss, splitButtonStyle, tableCellText, tablePathString, tableRefCells, tableSearchText, tableToMarkdown, tableValueProblems, topFieldKeyOf, uiRefusalId, usesHideOn, variantOptionsFromUnion, variantOptionsOf, variantPropOf, videoUrlOf, videoValueProblem, visibleBlocks, visibleDeliveredLayout, visibleLayoutStructure, windowState, withButtonLookProps, withExample, withIconLabel };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,9 @@ function bodySchemaOf(value) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// src/block.ts
|
|
29
|
+
var THEME_TOKENS = ["inherit", "light", "dark"];
|
|
30
|
+
var BG_TOKENS = ["none", "surface", "muted", "accent", "dark", "custom"];
|
|
31
|
+
var CONTENT_WIDTH_TOKENS = ["narrow", "default", "wide", "full"];
|
|
29
32
|
var WINDOW_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/;
|
|
30
33
|
function normalizeWindow(value) {
|
|
31
34
|
if (value == null) return { window: null };
|
|
@@ -110,14 +113,14 @@ var UNIT = "(?:[kKmMbBxsdgh]|bn|hr|hrs|min|ms|kg|mg|lb|lbs|oz|km|cm|mm|mi|ft|[kK
|
|
|
110
113
|
var SUFFIX = new RegExp(`^(?:\\s?(?:\\p{Sc}|[%\u2030\xD7]|${UNIT}))?\\+?(?:\\s?/\\s?\\p{L}{1,10}){0,2}[)\\]*\u2020]?$`, "u");
|
|
111
114
|
var PREFIX = /^(?:[^\p{L}\p{N}\s.,'\u2019#№\-−–—]{1,3}\s?)?$/u;
|
|
112
115
|
var fractionDigits = (value) => {
|
|
113
|
-
const
|
|
114
|
-
return
|
|
116
|
+
const text2 = value.toFixed(6).replace(/0+$/, "");
|
|
117
|
+
return text2.length - text2.indexOf(".") - 1;
|
|
115
118
|
};
|
|
116
119
|
function readNumberFormat(raw) {
|
|
117
120
|
const o = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
118
|
-
const
|
|
119
|
-
const prefix =
|
|
120
|
-
const suffix =
|
|
121
|
+
const text2 = (v, max) => typeof v === "string" && v.length <= max && !new RegExp("\\p{Nd}", "u").test(v) ? v : void 0;
|
|
122
|
+
const prefix = text2(o.prefix, 8);
|
|
123
|
+
const suffix = text2(o.suffix, 24);
|
|
121
124
|
const group = typeof o.group === "string" && GROUPS.includes(o.group) ? o.group : void 0;
|
|
122
125
|
const decimal = o.decimal === "," ? "," : void 0;
|
|
123
126
|
const decimals = typeof o.decimals === "number" && Number.isInteger(o.decimals) && o.decimals > 0 && o.decimals <= 6 ? o.decimals : void 0;
|
|
@@ -140,14 +143,14 @@ function formatNumber(value, format = {}) {
|
|
|
140
143
|
const grouped = format.group ? groupDigits(int, format.group, format.grouping) : int;
|
|
141
144
|
return `${value < 0 ? "-" : ""}${format.prefix ?? ""}${grouped}${frac ? `${format.decimal ?? "."}${frac}` : ""}${format.suffix ?? ""}`;
|
|
142
145
|
}
|
|
143
|
-
function parseNumberText(
|
|
144
|
-
if (typeof
|
|
145
|
-
const digits = /\d/.exec(
|
|
146
|
+
function parseNumberText(text2, opts = {}) {
|
|
147
|
+
if (typeof text2 !== "string" || text2.length === 0 || text2.length > 40) return null;
|
|
148
|
+
const digits = /\d/.exec(text2);
|
|
146
149
|
if (!digits) return null;
|
|
147
150
|
const start = digits.index;
|
|
148
|
-
const body = /^\d[\d.,'\u2019 \u00a0\u202f]*\d|^\d/.exec(
|
|
149
|
-
const prefix =
|
|
150
|
-
const suffix =
|
|
151
|
+
const body = /^\d[\d.,'\u2019 \u00a0\u202f]*\d|^\d/.exec(text2.slice(start))[0];
|
|
152
|
+
const prefix = text2.slice(0, start);
|
|
153
|
+
const suffix = text2.slice(start + body.length);
|
|
151
154
|
if (/\d/.test(suffix) || !PREFIX.test(prefix) || !SUFFIX.test(suffix)) return null;
|
|
152
155
|
if (opts.machine && (prefix || suffix || !/^\d+(\.\d+)?$/.test(body))) return null;
|
|
153
156
|
if (/[)\]]$/.test(suffix) !== /^[([]/.test(prefix)) return null;
|
|
@@ -187,7 +190,7 @@ function parseNumberText(text, opts = {}) {
|
|
|
187
190
|
...decimal === "," ? { decimal } : {},
|
|
188
191
|
...frac ? { decimals: frac.length } : {}
|
|
189
192
|
};
|
|
190
|
-
return Number.isFinite(value) && frac.length <= 6 && formatNumber(value, format) ===
|
|
193
|
+
return Number.isFinite(value) && frac.length <= 6 && formatNumber(value, format) === text2 ? { value, format } : null;
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
// src/block-bindings.ts
|
|
@@ -264,7 +267,7 @@ function formatPropsAttribute(entries) {
|
|
|
264
267
|
}
|
|
265
268
|
function parsePropsAttribute(value) {
|
|
266
269
|
if (!value) return [];
|
|
267
|
-
return value.split(";").map((entry) => entry.split("|")).filter((parts) => parts.length === 3 && parts.every(Boolean)).map(([address, kind,
|
|
270
|
+
return value.split(";").map((entry) => entry.split("|")).filter((parts) => parts.length === 3 && parts.every(Boolean)).map(([address, kind, attr3]) => ({ address, kind, attr: attr3 }));
|
|
268
271
|
}
|
|
269
272
|
function componentPropTargetKey(prop) {
|
|
270
273
|
if (!prop?.key || !prop.target?.blockId) return null;
|
|
@@ -3405,8 +3408,8 @@ function derivedPairs(candidates) {
|
|
|
3405
3408
|
if (!suffix) return;
|
|
3406
3409
|
const stem = key.slice(0, suffix.index);
|
|
3407
3410
|
const parent = link.key.slice(0, link.key.length - key.length);
|
|
3408
|
-
const texts = candidates.map((
|
|
3409
|
-
({ text, textIndex }) => textIndex !== linkIndex && !out.has(textIndex) && isText(
|
|
3411
|
+
const texts = candidates.map((text2, textIndex) => ({ text: text2, textIndex })).filter(
|
|
3412
|
+
({ text: text2, textIndex }) => textIndex !== linkIndex && !out.has(textIndex) && isText(text2) && text2.key.startsWith(parent) && sameButTag(leaf(text2.key), stem)
|
|
3410
3413
|
);
|
|
3411
3414
|
if (texts.length !== 1) return;
|
|
3412
3415
|
const pair = `${texts[0].textIndex}:${linkIndex}`;
|
|
@@ -3443,8 +3446,8 @@ function buttonLinkPairs(candidates) {
|
|
|
3443
3446
|
}
|
|
3444
3447
|
}
|
|
3445
3448
|
const uses = /* @__PURE__ */ new Map();
|
|
3446
|
-
for (const [
|
|
3447
|
-
uses.set(
|
|
3449
|
+
for (const [text2, link] of proposals.values()) {
|
|
3450
|
+
uses.set(text2, (uses.get(text2) ?? 0) + 1);
|
|
3448
3451
|
uses.set(link, (uses.get(link) ?? 0) + 1);
|
|
3449
3452
|
}
|
|
3450
3453
|
return [...proposals.values()].filter(([t, l]) => !ambiguous.has(t) && !ambiguous.has(l) && uses.get(t) === 1 && uses.get(l) === 1).sort((a, b) => Math.min(...a) - Math.min(...b));
|
|
@@ -4421,14 +4424,14 @@ function fieldGroupOf(topKey, flat = false) {
|
|
|
4421
4424
|
if (TAG_HEADS.has(head)) return { groupKey: topKey, rooted: false };
|
|
4422
4425
|
return { groupKey: head, rooted: true };
|
|
4423
4426
|
}
|
|
4424
|
-
function placementBindOf(block) {
|
|
4427
|
+
function placementBindOf(block, groupOf) {
|
|
4425
4428
|
if (!block || typeof block !== "object" || block.type !== "component") return null;
|
|
4426
4429
|
const props = block.props;
|
|
4427
4430
|
const bind = props?.bind;
|
|
4428
4431
|
if (typeof bind === "string" && bind) return bind;
|
|
4429
4432
|
const source = props?.source;
|
|
4430
4433
|
if (!source || typeof source !== "object") return null;
|
|
4431
|
-
const groups = Object.values(source).filter((path) => typeof path === "string" && path.length > 0).map((path) => ({ top: topFieldKeyOf(path), group: fieldGroupOf(topFieldKeyOf(path), path === topFieldKeyOf(path)).groupKey }));
|
|
4434
|
+
const groups = Object.values(source).filter((path) => typeof path === "string" && path.length > 0).map((path) => ({ top: topFieldKeyOf(path), group: groupOf?.(topFieldKeyOf(path)) ?? fieldGroupOf(topFieldKeyOf(path), path === topFieldKeyOf(path)).groupKey }));
|
|
4432
4435
|
return (groups.find((g) => g.group !== g.top) ?? groups[0])?.group ?? null;
|
|
4433
4436
|
}
|
|
4434
4437
|
var CODE_SLOT_PREFIX = "code:";
|
|
@@ -4895,7 +4898,83 @@ function isVariantVisible(prop, values, props) {
|
|
|
4895
4898
|
|
|
4896
4899
|
// src/heading-id.ts
|
|
4897
4900
|
var slugify = (s) => s.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "section";
|
|
4901
|
+
|
|
4902
|
+
// src/icon-value.ts
|
|
4903
|
+
import { iconSvg as iconSvg2 } from "@bettercms-ai/icons/markup";
|
|
4904
|
+
var ICON_SOURCES = ["pack", "library", "upload"];
|
|
4905
|
+
var DEFAULT_ICON_SOURCES = ["pack", "upload"];
|
|
4906
|
+
var ICON_LABEL_MAX = 80;
|
|
4907
|
+
function resolveIconOptions(o) {
|
|
4908
|
+
const sources = (o?.sources?.length ? o.sources : DEFAULT_ICON_SOURCES).filter((s, i, a) => ICON_SOURCES.includes(s) && a.indexOf(s) === i);
|
|
4909
|
+
return { sources, sets: o?.sets?.length ? o.sets : void 0, allowColor: o?.allowColor !== false, decorative: o?.decorative ?? "always" };
|
|
4910
|
+
}
|
|
4911
|
+
var isObj2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
4912
|
+
var text = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
4913
|
+
var isUrlish = (s) => /[/.]/.test(s);
|
|
4914
|
+
function normalizeIcon(v) {
|
|
4915
|
+
if (typeof v === "string") {
|
|
4916
|
+
const s = v.trim();
|
|
4917
|
+
return !s ? null : isUrlish(s) ? { source: "upload", url: s } : { source: "pack", name: s };
|
|
4918
|
+
}
|
|
4919
|
+
if (!isObj2(v)) return null;
|
|
4920
|
+
const label = text(v.label) ?? (v.source === void 0 ? text(v.alt) : void 0);
|
|
4921
|
+
const withLabel = (x) => label ? { ...x, label } : x;
|
|
4922
|
+
const url = text(v.url);
|
|
4923
|
+
if (v.source === "pack") return text(v.name) ? withLabel({ source: "pack", name: text(v.name) }) : null;
|
|
4924
|
+
if (v.source === "library") return text(v.id) && url ? withLabel({ source: "library", id: text(v.id), url, ...v.followsText === true ? { followsText: true } : {} }) : null;
|
|
4925
|
+
if (v.source === "upload" || v.source === void 0) return url ? withLabel({ source: "upload", url, ...text(v.assetId) ? { assetId: text(v.assetId) } : {} }) : null;
|
|
4926
|
+
return null;
|
|
4927
|
+
}
|
|
4928
|
+
function compactIcon(v) {
|
|
4929
|
+
if (!v) return "";
|
|
4930
|
+
if (v.source === "pack" && !v.label) return v.name;
|
|
4931
|
+
if (v.source === "upload" && !v.label && !v.assetId) return v.url;
|
|
4932
|
+
return v;
|
|
4933
|
+
}
|
|
4934
|
+
var isIconObjectForm = (v) => isObj2(v) && typeof v.source === "string";
|
|
4935
|
+
function iconIdentity(v) {
|
|
4936
|
+
const n = normalizeIcon(v);
|
|
4937
|
+
if (!n) return "";
|
|
4938
|
+
return n.source === "pack" ? `pack:${n.name}` : n.source === "library" ? `library:${n.id}` : `upload:${n.assetId ?? n.url}`;
|
|
4939
|
+
}
|
|
4940
|
+
function withIconLabel(v, label) {
|
|
4941
|
+
const n = normalizeIcon(v);
|
|
4942
|
+
if (!n) return "";
|
|
4943
|
+
const { label: _old, ...rest } = n;
|
|
4944
|
+
return compactIcon(label.trim() ? { ...rest, label } : rest);
|
|
4945
|
+
}
|
|
4946
|
+
function iconSrc(v) {
|
|
4947
|
+
const n = normalizeIcon(v);
|
|
4948
|
+
if (!n) return null;
|
|
4949
|
+
const label = n.label ? { label: n.label } : {};
|
|
4950
|
+
if (n.source === "pack") return { name: n.name, ...label };
|
|
4951
|
+
return { url: n.url, followsText: n.source === "library" && n.followsText === true, ...label };
|
|
4952
|
+
}
|
|
4953
|
+
function iconValueProblem(v, knownName, isUrl) {
|
|
4954
|
+
const n = normalizeIcon(v);
|
|
4955
|
+
if (!n) return "must be an icon name (bettercms://icons/dock), an image url, or an icon object";
|
|
4956
|
+
if (n.label && n.label.length > ICON_LABEL_MAX) return `label must be at most ${ICON_LABEL_MAX} characters`;
|
|
4957
|
+
if (n.source === "pack") return knownName(n.name) ? null : `must be an icon name (bettercms://icons/dock): "${n.name}" is not in the icon set`;
|
|
4958
|
+
return isUrl(n.url) ? null : "must carry a fetchable url";
|
|
4959
|
+
}
|
|
4960
|
+
var attr2 = (v) => v.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
4961
|
+
function iconHtml(v, className = "") {
|
|
4962
|
+
const src = iconSrc(v);
|
|
4963
|
+
if (!src) return "";
|
|
4964
|
+
const cls = className ? ` class="${attr2(className)}"` : "";
|
|
4965
|
+
const named = src.label ? ` role="img" aria-label="${attr2(src.label)}"` : ` aria-hidden="true"`;
|
|
4966
|
+
if ("name" in src) {
|
|
4967
|
+
const svg = iconSvg2(src.name, className);
|
|
4968
|
+
return svg && src.label ? `<span${named}>${svg}</span>` : svg;
|
|
4969
|
+
}
|
|
4970
|
+
if (src.followsText) {
|
|
4971
|
+
const mask = `url("${attr2(src.url)}") center / contain no-repeat`;
|
|
4972
|
+
return `<span data-bcms-icon-url="${attr2(src.url)}"${cls}${named} style="display:inline-block;width:1em;height:1em;background-color:currentColor;mask:${mask};-webkit-mask:${mask}"></span>`;
|
|
4973
|
+
}
|
|
4974
|
+
return `<img src="${attr2(src.url)}" alt="${attr2(src.label ?? "")}"${cls} width="16" height="16" style="width:1em;height:1em;object-fit:contain">`;
|
|
4975
|
+
}
|
|
4898
4976
|
export {
|
|
4977
|
+
BG_TOKENS,
|
|
4899
4978
|
BLOCK_BINDINGS,
|
|
4900
4979
|
BLOCK_FIELD_TYPES,
|
|
4901
4980
|
BLOCK_FIELD_TYPES_RENDERABLE_NOW,
|
|
@@ -4915,7 +4994,9 @@ export {
|
|
|
4915
4994
|
CODE_SLOT_PREFIX,
|
|
4916
4995
|
COMPONENT_GATE_CODES,
|
|
4917
4996
|
COMPONENT_PROP_TYPES,
|
|
4997
|
+
CONTENT_WIDTH_TOKENS,
|
|
4918
4998
|
CONTROL_HELP,
|
|
4999
|
+
DEFAULT_ICON_SOURCES,
|
|
4919
5000
|
DEFAULT_VARIANT,
|
|
4920
5001
|
DEPTH_MAX,
|
|
4921
5002
|
DERIVE_MINTED_RESERVED,
|
|
@@ -4936,6 +5017,8 @@ export {
|
|
|
4936
5017
|
HELP_LINE_MAX,
|
|
4937
5018
|
HELP_MAX,
|
|
4938
5019
|
HELP_WRITE_MAX,
|
|
5020
|
+
ICON_LABEL_MAX,
|
|
5021
|
+
ICON_SOURCES,
|
|
4939
5022
|
IMAGE_ASPECTS,
|
|
4940
5023
|
IMAGE_FRAME_RADIUS,
|
|
4941
5024
|
KEY_FORBIDDEN,
|
|
@@ -4994,6 +5077,7 @@ export {
|
|
|
4994
5077
|
TAB_MAX,
|
|
4995
5078
|
TAB_MAX_RENDERABLE_NOW,
|
|
4996
5079
|
TAG_HEADS,
|
|
5080
|
+
THEME_TOKENS,
|
|
4997
5081
|
UI_PROTOCOLS,
|
|
4998
5082
|
UI_REFUSAL_CODES,
|
|
4999
5083
|
UI_REFUSAL_IDS,
|
|
@@ -5022,6 +5106,7 @@ export {
|
|
|
5022
5106
|
buttonVariantOf,
|
|
5023
5107
|
candidateRole,
|
|
5024
5108
|
canonicalJson,
|
|
5109
|
+
compactIcon,
|
|
5025
5110
|
componentInstanceAddresses,
|
|
5026
5111
|
componentPropTargetKey,
|
|
5027
5112
|
derivedPairs,
|
|
@@ -5043,6 +5128,10 @@ export {
|
|
|
5043
5128
|
headingPaintCss,
|
|
5044
5129
|
hiddenEverywhere,
|
|
5045
5130
|
hideOnAttr,
|
|
5131
|
+
iconHtml,
|
|
5132
|
+
iconIdentity,
|
|
5133
|
+
iconSrc,
|
|
5134
|
+
iconValueProblem,
|
|
5046
5135
|
imageFrameCss,
|
|
5047
5136
|
inWindow,
|
|
5048
5137
|
isBlock,
|
|
@@ -5053,6 +5142,7 @@ export {
|
|
|
5053
5142
|
isDeriveReservedKey,
|
|
5054
5143
|
isDockUiImportAllowed,
|
|
5055
5144
|
isEmbedReason,
|
|
5145
|
+
isIconObjectForm,
|
|
5056
5146
|
isLinkObject,
|
|
5057
5147
|
isReservedKey,
|
|
5058
5148
|
isRoleKey,
|
|
@@ -5072,6 +5162,7 @@ export {
|
|
|
5072
5162
|
locatorPath,
|
|
5073
5163
|
mayOverwrite,
|
|
5074
5164
|
normaliseRichTextFeatures,
|
|
5165
|
+
normalizeIcon,
|
|
5075
5166
|
normalizeLinkValue,
|
|
5076
5167
|
normalizeTableValue,
|
|
5077
5168
|
normalizeWindow,
|
|
@@ -5087,6 +5178,7 @@ export {
|
|
|
5087
5178
|
referenceCreateRefusal,
|
|
5088
5179
|
regionOf,
|
|
5089
5180
|
renderTableHtml,
|
|
5181
|
+
resolveIconOptions,
|
|
5090
5182
|
richTextRefusal,
|
|
5091
5183
|
rulePartnerOf,
|
|
5092
5184
|
safeCssUrl,
|
|
@@ -5120,6 +5212,7 @@ export {
|
|
|
5120
5212
|
visibleLayoutStructure,
|
|
5121
5213
|
windowState,
|
|
5122
5214
|
withButtonLookProps,
|
|
5123
|
-
withExample
|
|
5215
|
+
withExample,
|
|
5216
|
+
withIconLabel
|
|
5124
5217
|
};
|
|
5125
5218
|
//# sourceMappingURL=index.js.map
|