@bettercms-ai/types 1.61.1 → 1.63.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.js CHANGED
@@ -264,7 +264,7 @@ function formatPropsAttribute(entries) {
264
264
  }
265
265
  function parsePropsAttribute(value) {
266
266
  if (!value) return [];
267
- return value.split(";").map((entry) => entry.split("|")).filter((parts) => parts.length === 3 && parts.every(Boolean)).map(([address, kind, attr]) => ({ address, kind, attr }));
267
+ return value.split(";").map((entry) => entry.split("|")).filter((parts) => parts.length === 3 && parts.every(Boolean)).map(([address, kind, attr2]) => ({ address, kind, attr: attr2 }));
268
268
  }
269
269
  function componentPropTargetKey(prop) {
270
270
  if (!prop?.key || !prop.target?.blockId) return null;
@@ -3162,101 +3162,8 @@ var DOCK_ICON_NAME_SET = new Set(DOCK_ICON_NAMES);
3162
3162
 
3163
3163
  // src/help-catalog.ts
3164
3164
  var HELP_MAX = 160;
3165
- var HELP_LINE_MAX = 48;
3166
- var HELP_WRITE_MAX = 80;
3167
- var ROLE_HELP = {
3168
- // A top-level field's role in its section.
3169
- headline: "The page's main heading, one per page.",
3170
- heading: "The heading of this section.",
3171
- subheading: "Shown under the heading.",
3172
- eyebrow: "Short label shown above the heading.",
3173
- intro: "Shown under the heading. One or two sentences.",
3174
- paragraph: "A paragraph of text.",
3175
- text: "Text shown on the page.",
3176
- "primary-button": "The main call to action.",
3177
- "secondary-button": "The second call to action.",
3178
- button: "Its text, where it goes and how it looks.",
3179
- "button-label": "Button text. Two to four words work best.",
3180
- link: "Text of this link. Say where it leads.",
3181
- "home-link": "Takes visitors back to the home page.",
3182
- destination: "Pick a page or paste a full URL.",
3183
- image: "An image shown on the page.",
3184
- icon: "Optional icon before the label.",
3185
- logo: "An SVG or transparent PNG works best.",
3186
- "background-image": "Text sits on top, so pick a calm image.",
3187
- "video-poster": "Shown before the video plays.",
3188
- video: "Paste a link or upload an MP4.",
3189
- embed: "Paste the share link from the other site.",
3190
- audio: "Paste a link or upload an audio file.",
3191
- body: "Headings, paragraphs, lists and links.",
3192
- content: "Headings, paragraphs, lists and links.",
3193
- copyright: "Shown at the bottom of every page.",
3194
- email: "An email address, such as name@example.com.",
3195
- phone: "A phone number, with its country code.",
3196
- price: "Whole number, no currency symbol.",
3197
- percentage: "A number with its % sign.",
3198
- number: "A figure shown on the page.",
3199
- date: "A date, written as it should appear.",
3200
- "stat-value": "A figure shown large, such as 70k+.",
3201
- "stat-label": "What the figure counts.",
3202
- quote: "Without quote marks.",
3203
- attribution: "Who said it.",
3204
- caption: "Shown under the image.",
3205
- label: "A short label.",
3206
- summary: "Shown in lists and previews.",
3207
- address: "The postal address, as it should appear.",
3208
- code: "Shown exactly as written.",
3209
- term: "The word or phrase being explained.",
3210
- definition: "What the term means.",
3211
- "table-heading": "Heading of a table column.",
3212
- "table-cell": "One cell of the table.",
3213
- "list-item": "One item of the list.",
3214
- list: "One item per row.",
3215
- links: "One link per row.",
3216
- band: "All the text of this section, edited as one.",
3217
- // A column's role in its row.
3218
- title: "The title of this item.",
3219
- subtitle: "Shown under the title.",
3220
- description: "One line under the name.",
3221
- value: "The value shown for this item.",
3222
- // What a band's shape calls an element.
3223
- "plan-name": "Short name, shown at the top of the card.",
3224
- cents: "Digits after the decimal point.",
3225
- "billing-period": "How often the price is charged.",
3226
- // The parts of a plan's price object.
3227
- amount: "Whole number, no currency symbol.",
3228
- period: "How often the price is charged.",
3229
- badge: "Optional. A few words to make it stand out.",
3230
- features: "One feature per row.",
3231
- question: "One question, as a customer would ask it.",
3232
- answer: "Shown when the question is opened.",
3233
- author: "The person's full name.",
3234
- role: "Their job title and company.",
3235
- // What an attribute is, by what carries it.
3236
- tooltip: "Shown when the pointer rests on it.",
3237
- placeholder: "Shown in the empty input.",
3238
- "image-description": "Read by screen readers, not shown on the page.",
3239
- "counter-target": "The number the counter runs up to.",
3240
- attribute: "A setting of this element, not shown as text.",
3241
- "navigation-label": "Read by screen readers, not shown on the page.",
3242
- "link-label": "Read by screen readers, not shown on the page.",
3243
- "image-label": "Read by screen readers, not shown on the page.",
3244
- "field-label": "Read by screen readers, not shown on the page.",
3245
- "header-label": "Read by screen readers, not shown on the page.",
3246
- "footer-label": "Read by screen readers, not shown on the page.",
3247
- "aside-label": "Read by screen readers, not shown on the page.",
3248
- "section-label": "Read by screen readers, not shown on the page.",
3249
- "heading-label": "Read by screen readers, not shown on the page.",
3250
- // What a list's rows are.
3251
- plans: "One plan per card.",
3252
- questions: "One question and its answer per row.",
3253
- quotes: "One quote per row, with who said it.",
3254
- testimonials: "One quote per row, with who said it.",
3255
- stats: "One figure per row, with what it counts.",
3256
- logos: "One logo per row.",
3257
- cards: "One card per row.",
3258
- items: "One item per row."
3259
- };
3165
+ var HELP_LINE_MAX = 80;
3166
+ var HELP_WRITE_MAX = HELP_LINE_MAX;
3260
3167
  var CANVAS_GESTURE_NAMES = ["rows.reorder", "image.replace", "link.popover", "text.inline"];
3261
3168
  var CONTROL_HELP = {
3262
3169
  rows: { text: "Drag to reorder. You can also drag rows on the canvas.", gesture: "rows.reorder" },
@@ -4567,8 +4474,8 @@ var SEGMENTED_MIN = 2;
4567
4474
  var SEGMENTED_MAX = 8;
4568
4475
  var DEPTH_MAX = 10;
4569
4476
  var HELP_CAPS = {
4570
- field: 500,
4571
- prop: 200,
4477
+ field: HELP_LINE_MAX,
4478
+ prop: HELP_LINE_MAX,
4572
4479
  placeholder: 120,
4573
4480
  helpMore: 2e3,
4574
4481
  option: OPTION_DESCRIPTION_MAX,
@@ -4880,6 +4787,112 @@ var referenceCreateRefusal = (code, detail) => ({
4880
4787
  reason: `reference_create.${code}:${detail}`
4881
4788
  });
4882
4789
 
4790
+ // src/embed.ts
4791
+ var EMBED_REASONS = [
4792
+ "EMBED_BODY_NOT_DECLARED",
4793
+ "EMBED_COMPONENT_NOT_DECLARED",
4794
+ "EMBED_VARIANT_NOT_ALLOWED",
4795
+ "EMBED_BOUND_TO_PAGE",
4796
+ "EMBED_SOURCE_NOT_RECORDED",
4797
+ "EMBED_COMPONENT_MISSING",
4798
+ "EMBED_RENDER_FAILED",
4799
+ "EMBED_FRAMEWORK_UNSUPPORTED",
4800
+ "SLOT_NOT_IN_PAGE_CODE",
4801
+ "COMPONENT_PAGE_OWN"
4802
+ ];
4803
+ var COMPONENT_GATE_CODES = [
4804
+ "COMPONENT_NOT_REUSABLE",
4805
+ "COMPONENT_SOURCE_NOT_MOUNTABLE",
4806
+ "PROP_NOT_REPRESENTABLE",
4807
+ "EMBED_WIDTH_FIT_FAILED",
4808
+ "COMPONENT_IS_CHROME",
4809
+ "COMPONENT_HAS_BODY",
4810
+ "AI_EXCLUDED"
4811
+ ];
4812
+ var WIDTH_FIT_FAIL_KINDS = ["overflow", "full-bleed", "unmeasured"];
4813
+ var EMBED_LEDGER_OUTCOMES = ["NOT_RENDERED", "HIDDEN"];
4814
+ function isEmbedReason(code) {
4815
+ return EMBED_REASONS.includes(code);
4816
+ }
4817
+ function isComponentGateCode(code) {
4818
+ return COMPONENT_GATE_CODES.includes(code);
4819
+ }
4820
+ function embedVisible(node) {
4821
+ return node?.fields?.visible !== false;
4822
+ }
4823
+ var esc2 = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
4824
+ var unesc = (s) => s.replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
4825
+ function embedMarkerHtml(m) {
4826
+ return `<div class="bcms-block" data-bcms-schema-key="component" data-bcms-embed="${esc2(m.ptKey)}" data-bcms-component="${esc2(m.componentId)}"` + (m.hidden ? " data-bcms-embed-hidden" : "") + (m.reason ? ` data-bcms-embed-reason="${m.reason}"` : "") + "></div>";
4827
+ }
4828
+ var MARKER_RE = /<div\b([^>]*\bdata-bcms-embed="[^"]*"[^>]*)>\s*<\/div>/g;
4829
+ var attr = (attrs, name) => attrs.match(new RegExp(`\\b${name}="([^"]*)"`))?.[1];
4830
+ function parseEmbedMarkers(html) {
4831
+ const out = [];
4832
+ for (const m of html.matchAll(MARKER_RE)) {
4833
+ const attrs = m[1] ?? "";
4834
+ if (!/\bclass="[^"]*\bbcms-block\b/.test(attrs)) continue;
4835
+ const ptKey = attr(attrs, "data-bcms-embed");
4836
+ const componentId = attr(attrs, "data-bcms-component");
4837
+ if (!ptKey || !componentId) continue;
4838
+ const reason = attr(attrs, "data-bcms-embed-reason");
4839
+ out.push({
4840
+ ptKey: unesc(ptKey),
4841
+ componentId: unesc(componentId),
4842
+ .../\bdata-bcms-embed-hidden\b/.test(attrs) ? { hidden: true } : {},
4843
+ ...isEmbedReason(reason) ? { reason } : {},
4844
+ start: m.index,
4845
+ end: m.index + m[0].length
4846
+ });
4847
+ }
4848
+ return out;
4849
+ }
4850
+ var embedAddress = (field, ptKey) => `${field}#${ptKey}`;
4851
+ var VARIANT_PROP_KEY = "variant";
4852
+ var DEFAULT_VARIANT = "default";
4853
+ function variantPropOf(def) {
4854
+ return def.props?.find((p) => p.key === VARIANT_PROP_KEY && p.type === "select" && p.config?.role === "variant");
4855
+ }
4856
+ function variantOptionsOf(def) {
4857
+ const opts = (variantPropOf(def)?.config?.options ?? []).map((o) => typeof o === "string" ? o : o.value).filter(Boolean);
4858
+ return opts.length ? opts : [DEFAULT_VARIANT];
4859
+ }
4860
+ function variantOptionsFromUnion(typeText) {
4861
+ const parts = (typeText ?? "").split("|").map((s) => s.trim()).filter(Boolean);
4862
+ const lits = parts.map((s) => s.match(/^(["'])([^"']+)\1$/)?.[2]);
4863
+ return parts.length && lits.every(Boolean) ? [...new Set(lits)] : [DEFAULT_VARIANT];
4864
+ }
4865
+ function evaluateShowIf(showIf, values, sourceTypes) {
4866
+ const rules = Array.isArray(showIf?.rules) ? showIf.rules : [];
4867
+ if (!rules.length) return true;
4868
+ const str = (v) => String(v ?? "");
4869
+ const test = (r) => {
4870
+ const type = sourceTypes?.get(r.field);
4871
+ if (sourceTypes && type === void 0) return true;
4872
+ const raw = values[r.field];
4873
+ const set = raw !== void 0 && raw !== null && raw !== "" && !(Array.isArray(raw) && raw.length === 0);
4874
+ if (r.op === "isSet" || r.op === "notEmpty") return set;
4875
+ if (r.op === "empty") return !set;
4876
+ if (r.op === "gt" || r.op === "lt") {
4877
+ if (!set || typeof raw === "boolean") return false;
4878
+ const n = Number(raw), bound = Number(r.value);
4879
+ if (!Number.isFinite(n) || !Number.isFinite(bound)) return false;
4880
+ return r.op === "gt" ? n > bound : n < bound;
4881
+ }
4882
+ const s = type === "boolean" || type === "toggle" ? String(raw === true || raw === "true") : str(raw);
4883
+ if (r.op === "in" || r.op === "notIn") {
4884
+ const hit = (Array.isArray(r.value) ? r.value : [r.value]).map(str).includes(s);
4885
+ return r.op === "in" ? hit : !hit;
4886
+ }
4887
+ if (r.op === "neq") return s !== str(r.value);
4888
+ return s === str(r.value);
4889
+ };
4890
+ return showIf.match === "any" ? rules.some(test) : rules.every(test);
4891
+ }
4892
+ function isVariantVisible(prop, values, props) {
4893
+ return evaluateShowIf(prop.showIf, values, props ? new Map(props.map((p) => [p.key, p.type])) : void 0);
4894
+ }
4895
+
4883
4896
  // src/heading-id.ts
4884
4897
  var slugify = (s) => s.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "section";
4885
4898
  export {
@@ -4900,8 +4913,10 @@ export {
4900
4913
  CATEGORY_ID_MAX,
4901
4914
  CATEGORY_ORDER,
4902
4915
  CODE_SLOT_PREFIX,
4916
+ COMPONENT_GATE_CODES,
4903
4917
  COMPONENT_PROP_TYPES,
4904
4918
  CONTROL_HELP,
4919
+ DEFAULT_VARIANT,
4905
4920
  DEPTH_MAX,
4906
4921
  DERIVE_MINTED_RESERVED,
4907
4922
  DIALOG_SELECTOR,
@@ -4911,6 +4926,8 @@ export {
4911
4926
  DOCK_UI_IMPORTS,
4912
4927
  DOCK_UI_LIMITS,
4913
4928
  DOCK_UI_NAME,
4929
+ EMBED_LEDGER_OUTCOMES,
4930
+ EMBED_REASONS,
4914
4931
  FIELD_SIZE_ZOOM,
4915
4932
  FIELD_STYLE_KEYS,
4916
4933
  FOOTER_SECTION_ID,
@@ -4953,7 +4970,6 @@ export {
4953
4970
  RICHTEXT_HEADING_FEATURES,
4954
4971
  RICHTEXT_MARK_FEATURES,
4955
4972
  RICHTEXT_TOGGLE_FEATURES,
4956
- ROLE_HELP,
4957
4973
  ROLE_KEYS,
4958
4974
  SCHEMA_HASH_INPUTS,
4959
4975
  SECTION_DOCTRINE,
@@ -4984,8 +5000,10 @@ export {
4984
5000
  V2_KEYS,
4985
5001
  V2_PLACEMENTS,
4986
5002
  V2_SHAPES,
5003
+ VARIANT_PROP_KEY,
4987
5004
  VIDEO_TRANSCRIPT_MAX,
4988
5005
  VIDEO_VALUE_KEYS,
5006
+ WIDTH_FIT_FAIL_KINDS,
4989
5007
  allowRuleOf,
4990
5008
  anchorTargetRel,
4991
5009
  blockStyleToColumnCss,
@@ -5010,6 +5028,10 @@ export {
5010
5028
  dockBudget,
5011
5029
  dockScreens,
5012
5030
  dockUiMerkleKey,
5031
+ embedAddress,
5032
+ embedMarkerHtml,
5033
+ embedVisible,
5034
+ evaluateShowIf,
5013
5035
  exampleFor,
5014
5036
  expandBlockBindings,
5015
5037
  fieldGroupOf,
@@ -5027,8 +5049,10 @@ export {
5027
5049
  isButtonLookValue,
5028
5050
  isChromeLandmark,
5029
5051
  isCodeButton,
5052
+ isComponentGateCode,
5030
5053
  isDeriveReservedKey,
5031
5054
  isDockUiImportAllowed,
5055
+ isEmbedReason,
5032
5056
  isLinkObject,
5033
5057
  isReservedKey,
5034
5058
  isRoleKey,
@@ -5037,6 +5061,7 @@ export {
5037
5061
  isSlotChild,
5038
5062
  isTableValue,
5039
5063
  isUiRefusal,
5064
+ isVariantVisible,
5040
5065
  keyWords,
5041
5066
  landmarkRegions,
5042
5067
  linkAnchorOf,
@@ -5050,6 +5075,7 @@ export {
5050
5075
  normalizeLinkValue,
5051
5076
  normalizeTableValue,
5052
5077
  normalizeWindow,
5078
+ parseEmbedMarkers,
5053
5079
  parseNumberText,
5054
5080
  parsePropsAttribute,
5055
5081
  pickFieldStyle,
@@ -5084,6 +5110,9 @@ export {
5084
5110
  topFieldKeyOf,
5085
5111
  uiRefusalId,
5086
5112
  usesHideOn,
5113
+ variantOptionsFromUnion,
5114
+ variantOptionsOf,
5115
+ variantPropOf,
5087
5116
  videoUrlOf,
5088
5117
  videoValueProblem,
5089
5118
  visibleBlocks,