@bettercms-ai/types 1.50.2 → 1.52.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
@@ -3159,6 +3159,138 @@ var DOCK_ICON_NAMES = [
3159
3159
  ];
3160
3160
  var DOCK_ICON_NAME_SET = new Set(DOCK_ICON_NAMES);
3161
3161
 
3162
+ // src/help-catalog.ts
3163
+ var HELP_MAX = 160;
3164
+ var ROLE_HELP = {
3165
+ // A top-level field's role in its section.
3166
+ headline: "The page's main heading, one per page.",
3167
+ heading: "The heading of this section.",
3168
+ subheading: "Shown under the heading.",
3169
+ eyebrow: "Short label shown above the heading.",
3170
+ intro: "Shown under the heading. One or two sentences.",
3171
+ paragraph: "A paragraph of text.",
3172
+ text: "Text shown on the page.",
3173
+ "primary-button": "The main call to action.",
3174
+ "secondary-button": "The second call to action.",
3175
+ button: "Its text, where it goes and how it looks.",
3176
+ "button-label": "Text on the button. Two to four words works best.",
3177
+ link: "Text of this link. Say where it leads.",
3178
+ "home-link": "Takes visitors back to the home page.",
3179
+ destination: "Pick a page or paste a full URL.",
3180
+ image: "An image shown on the page.",
3181
+ icon: "Optional icon before the label.",
3182
+ logo: "An SVG or transparent PNG works best.",
3183
+ "background-image": "Text sits on top of it, so a calm image works best.",
3184
+ "video-poster": "Shown before the video plays.",
3185
+ video: "Paste a link or upload an MP4.",
3186
+ embed: "Paste the link the other site gives you to share it.",
3187
+ audio: "Paste a link or upload an audio file.",
3188
+ body: "Headings, paragraphs, lists and links, edited as one.",
3189
+ content: "Headings, paragraphs, lists and links, edited as one.",
3190
+ copyright: "Shown at the bottom of every page.",
3191
+ email: "An email address, such as name@example.com.",
3192
+ phone: "A phone number, with its country code.",
3193
+ price: "Whole number, no currency symbol.",
3194
+ percentage: "A number with its % sign.",
3195
+ number: "A figure shown on the page.",
3196
+ date: "A date, written as it should appear.",
3197
+ "stat-value": "A figure shown large, such as 70k+.",
3198
+ "stat-label": "What the figure counts.",
3199
+ quote: "Without quote marks.",
3200
+ attribution: "Who said it.",
3201
+ caption: "Shown under the image.",
3202
+ label: "A short label.",
3203
+ summary: "Shown in lists and previews.",
3204
+ address: "The postal address, as it should appear.",
3205
+ code: "Shown exactly as written.",
3206
+ term: "The word or phrase being explained.",
3207
+ definition: "What the term means.",
3208
+ "table-heading": "Heading of a table column.",
3209
+ "table-cell": "One cell of the table.",
3210
+ "list-item": "One item of the list.",
3211
+ list: "One item per row.",
3212
+ links: "One link per row.",
3213
+ band: "All the text of this section, edited as one.",
3214
+ // A column's role in its row.
3215
+ title: "The title of this item.",
3216
+ subtitle: "Shown under the title.",
3217
+ description: "One line under the name.",
3218
+ value: "The value shown for this item.",
3219
+ // What a band's shape calls an element.
3220
+ "plan-name": "Short name of this plan, shown at the top of its card.",
3221
+ cents: "Digits after the decimal point.",
3222
+ "billing-period": "How often the price is charged.",
3223
+ // The parts of a plan's price object.
3224
+ amount: "Whole number, no currency symbol.",
3225
+ period: "How often the price is charged.",
3226
+ badge: "Optional. Two or three words that make this plan stand out.",
3227
+ features: "One feature per row.",
3228
+ question: "One question, as a customer would ask it.",
3229
+ answer: "Shown when the question is opened.",
3230
+ author: "The person's full name.",
3231
+ role: "Their job title and company.",
3232
+ // What an attribute is, by what carries it.
3233
+ tooltip: "Shown when the pointer rests on it.",
3234
+ placeholder: "Shown in the empty input.",
3235
+ "image-description": "Read by screen readers, not shown on the page.",
3236
+ "counter-target": "The number the counter runs up to.",
3237
+ attribute: "A setting of this element, not shown as text.",
3238
+ "navigation-label": "Read by screen readers, not shown on the page.",
3239
+ "link-label": "Read by screen readers, not shown on the page.",
3240
+ "image-label": "Read by screen readers, not shown on the page.",
3241
+ "field-label": "Read by screen readers, not shown on the page.",
3242
+ "header-label": "Read by screen readers, not shown on the page.",
3243
+ "footer-label": "Read by screen readers, not shown on the page.",
3244
+ "aside-label": "Read by screen readers, not shown on the page.",
3245
+ "section-label": "Read by screen readers, not shown on the page.",
3246
+ "heading-label": "Read by screen readers, not shown on the page.",
3247
+ // What a list's rows are.
3248
+ plans: "One plan per card.",
3249
+ questions: "One question and its answer per row.",
3250
+ quotes: "One quote per row, with who said it.",
3251
+ testimonials: "One quote per row, with who said it.",
3252
+ stats: "One figure per row, with what it counts.",
3253
+ logos: "One logo per row.",
3254
+ cards: "One card per row.",
3255
+ items: "One item per row."
3256
+ };
3257
+ var CANVAS_GESTURE_NAMES = ["rows.reorder", "image.replace", "link.popover", "text.inline"];
3258
+ var CONTROL_HELP = {
3259
+ rows: { text: "Drag to reorder. You can also drag rows on the canvas.", gesture: "rows.reorder" },
3260
+ image: { text: "You can also click it on the canvas to replace it.", gesture: "image.replace" },
3261
+ link: { text: "Click it on the canvas to change where it goes.", gesture: "link.popover" },
3262
+ text: { text: "You can also edit it on the canvas.", gesture: "text.inline" }
3263
+ };
3264
+ var EXAMPLE_MAX = 40;
3265
+ function sayOf(value) {
3266
+ if (typeof value === "number") return String(value);
3267
+ const v = value;
3268
+ const raw = typeof value === "string" ? value : typeof v?.html === "string" ? v.html : typeof v?.label === "string" ? v.label : typeof v?.text === "string" ? v.text : "";
3269
+ return raw.replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
3270
+ }
3271
+ var quotable = (s) => s !== "" && s.length <= EXAMPLE_MAX && !s.includes('"');
3272
+ function exampleFor(column, rows, i) {
3273
+ const at = (j) => {
3274
+ const row = rows[j];
3275
+ return row && typeof row === "object" ? sayOf(row[column]) : "";
3276
+ };
3277
+ const own2 = at(i);
3278
+ for (let d = 1; d < rows.length; d += 1) {
3279
+ for (const j of [i - d, i + d]) {
3280
+ if (j < 0 || j >= rows.length) continue;
3281
+ const v = at(j);
3282
+ if (v !== own2 && quotable(v)) return `e.g. "${v}"`;
3283
+ }
3284
+ }
3285
+ return quotable(own2) ? `e.g. "${own2}"` : void 0;
3286
+ }
3287
+ function withExample(help, example) {
3288
+ if (!example) return help;
3289
+ if (!help) return example;
3290
+ const joined = `${help} ${example}`;
3291
+ return joined.length <= HELP_MAX ? joined : help;
3292
+ }
3293
+
3162
3294
  // src/dock-budget.ts
3163
3295
  var DOCK_BUDGET = { ungrouped: 8, group: 12, depth: 3, activations: 2 };
3164
3296
  function listItems(f) {
@@ -3408,6 +3540,19 @@ function buttonLinkPairs(candidates) {
3408
3540
  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));
3409
3541
  }
3410
3542
 
3543
+ // src/link-pairs.ts
3544
+ var LINK_TYPES2 = /* @__PURE__ */ new Set(["link", "url"]);
3545
+ var nameOf = (s) => s.name ?? s.key;
3546
+ function rulePartnerOf(labelKey, siblings) {
3547
+ const names = labelKey === "label" ? ["label-href", "href", "url", "link"] : [`${labelKey}-href`];
3548
+ for (const n of names) {
3549
+ const s = siblings.find((f) => nameOf(f) === n);
3550
+ if (s && LINK_TYPES2.has(s.type ?? "")) return n;
3551
+ }
3552
+ return null;
3553
+ }
3554
+ var isRulePaired = (labelKey, siblings) => rulePartnerOf(labelKey, siblings) !== null;
3555
+
3411
3556
  // src/button-look.ts
3412
3557
  import { ICON_MARKUP, iconSvg } from "@bettercms-ai/icons/markup";
3413
3558
 
@@ -4340,7 +4485,9 @@ var ROLE_KEYS = /* @__PURE__ */ new Set([
4340
4485
  "tooltip",
4341
4486
  "placeholder",
4342
4487
  "image-description",
4343
- "counter-target"
4488
+ "counter-target",
4489
+ "amount",
4490
+ "period"
4344
4491
  ]);
4345
4492
  var ROLE_TAILS = /(?:-label)?(?:-[a-z])?(?:-\d+)?(?:-href)?$/;
4346
4493
  function isRoleKey(key) {
@@ -4403,8 +4550,152 @@ function planSections(slots, blocks) {
4403
4550
  });
4404
4551
  return out;
4405
4552
  }
4553
+
4554
+ // src/kit-v2.ts
4555
+ var TAB_MAX = 8;
4556
+ var SEGMENTED_MIN = 2;
4557
+ var SEGMENTED_MAX = 8;
4558
+ var DEPTH_MAX = 10;
4559
+ var HELP_CAPS = {
4560
+ field: 500,
4561
+ prop: 200,
4562
+ placeholder: 120,
4563
+ helpMore: 2e3,
4564
+ option: OPTION_DESCRIPTION_MAX,
4565
+ fieldset: 500,
4566
+ propGroup: 200
4567
+ };
4568
+ var SLOT_SETTINGS_MAX = 12;
4569
+ var SLOT_SETTINGS_TYPES = [
4570
+ "text",
4571
+ "slug",
4572
+ "select",
4573
+ "multiselect",
4574
+ "number",
4575
+ "rating",
4576
+ "date",
4577
+ "datetime",
4578
+ "boolean",
4579
+ "color",
4580
+ "icon",
4581
+ "link"
4582
+ ];
4583
+ var BLOCK_FIELD_TYPES = [
4584
+ "text",
4585
+ "longtext",
4586
+ "richtext",
4587
+ "image",
4588
+ "link",
4589
+ "slug",
4590
+ "email",
4591
+ "phone",
4592
+ "color",
4593
+ "select",
4594
+ "number",
4595
+ "rating",
4596
+ "date",
4597
+ "datetime",
4598
+ "boolean",
4599
+ "video",
4600
+ "object",
4601
+ "array",
4602
+ "reference",
4603
+ "file",
4604
+ "tags"
4605
+ ];
4606
+ var BLOCK_FIELD_TYPES_RENDERABLE_NOW = [
4607
+ "text",
4608
+ "longtext",
4609
+ "richtext",
4610
+ "image",
4611
+ "link",
4612
+ "slug",
4613
+ "email",
4614
+ "phone",
4615
+ "color",
4616
+ "select",
4617
+ "number",
4618
+ "rating",
4619
+ "date",
4620
+ "datetime",
4621
+ "boolean"
4622
+ ];
4623
+ var V2_SHAPES = ["block", "page", "entry", "global", "object"];
4624
+ var V2_PLACEMENTS = ["inline", "section", "page"];
4625
+ var KIT_CATEGORIES = [
4626
+ "Navigation & chrome",
4627
+ "Heroes",
4628
+ "Features & storytelling",
4629
+ "Social proof",
4630
+ "Media & galleries",
4631
+ "Commerce",
4632
+ "Pricing & plans",
4633
+ "Conversion & forms",
4634
+ "Listings & feeds",
4635
+ "Long-form & docs",
4636
+ "Company & people",
4637
+ "Events & places",
4638
+ "Data & interactive",
4639
+ "Advanced patterns"
4640
+ ];
4641
+ var V2_KEYS = {
4642
+ components: ["shape", "placement"],
4643
+ content_models: ["shape", "placement", "category", "variants"],
4644
+ component_variant_groups: ["variants"]
4645
+ };
4646
+ var SOURCE_RANK = { auto: 0, site: 1, agent: 2, human: 3 };
4647
+ var mayOverwrite = (stored, incoming) => SOURCE_RANK[incoming] >= SOURCE_RANK[stored ?? "auto"];
4648
+ var UI_REFUSAL_CODES = {
4649
+ schema: [
4650
+ "facet_unclassified",
4651
+ "excluded_facet",
4652
+ "depth_exceeded",
4653
+ "validation_failed",
4654
+ "hash_mismatch",
4655
+ "shape_kind_mismatch",
4656
+ "block_field_unrenderable"
4657
+ ],
4658
+ build: ["peer_missing", "kit_major_unsupported", "compile_error", "nondeterministic", "size_exceeded"],
4659
+ protocol: ["unsupported", "handshake_timeout", "origin_mismatch", "write_denied"],
4660
+ runtime: ["crashed", "blank", "csp_violation"],
4661
+ policy: ["confirmation_required", "flag_off"]
4662
+ };
4663
+ var uiRefusalId = (r) => `${r.family}.${r.code}`;
4664
+ var isUiRefusal = (v) => {
4665
+ if (typeof v !== "object" || v === null) return false;
4666
+ const { family, code, message } = v;
4667
+ return typeof family === "string" && Object.hasOwn(UI_REFUSAL_CODES, family) && UI_REFUSAL_CODES[family].includes(code) && typeof message === "string";
4668
+ };
4669
+ function canonicalNumber(value) {
4670
+ if (!Number.isFinite(value)) throw new TypeError("Canonical JSON only supports finite numbers");
4671
+ if (Object.is(value, -0)) return "0";
4672
+ const encoded = JSON.stringify(value);
4673
+ const scientific = /^(-?)(\d+)(?:\.(\d+))?[eE]([+-]?\d+)$/.exec(encoded);
4674
+ if (!scientific) return encoded;
4675
+ const [, sign, integer, fraction = "", exponentText] = scientific;
4676
+ const digits = `${integer}${fraction}`;
4677
+ const decimalPoint = integer.length + Number(exponentText);
4678
+ if (decimalPoint <= 0) return `${sign}0.${"0".repeat(-decimalPoint)}${digits}`;
4679
+ if (decimalPoint >= digits.length) return `${sign}${digits}${"0".repeat(decimalPoint - digits.length)}`;
4680
+ return `${sign}${digits.slice(0, decimalPoint)}.${digits.slice(decimalPoint)}`;
4681
+ }
4682
+ var skipped = (v) => v === void 0 || typeof v === "function" || typeof v === "symbol";
4683
+ function canonicalJson(value) {
4684
+ if (value === null) return "null";
4685
+ if (typeof value === "number") return canonicalNumber(value);
4686
+ if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
4687
+ if (Array.isArray(value)) return `[${value.map((child) => skipped(child) ? "null" : canonicalJson(child)).join(",")}]`;
4688
+ if (typeof value === "object") {
4689
+ const record = value;
4690
+ const keys = Object.keys(record).filter((key) => !skipped(record[key])).sort();
4691
+ return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(",")}}`;
4692
+ }
4693
+ throw new TypeError(`Unsupported canonical JSON value: ${typeof value}`);
4694
+ }
4406
4695
  export {
4407
4696
  BLOCK_BINDINGS,
4697
+ BLOCK_FIELD_TYPES,
4698
+ BLOCK_FIELD_TYPES_RENDERABLE_NOW,
4408
4699
  BODY_SCHEMA_ORIGINS,
4409
4700
  BREAKPOINTS,
4410
4701
  BUTTON_ACTIONS,
@@ -4415,8 +4706,11 @@ export {
4415
4706
  BUTTON_PLACEMENT_KEYS,
4416
4707
  BUTTON_SIZES,
4417
4708
  BUTTON_VARIANTS,
4709
+ CANVAS_GESTURE_NAMES,
4418
4710
  CODE_SLOT_PREFIX,
4419
4711
  COMPONENT_PROP_TYPES,
4712
+ CONTROL_HELP,
4713
+ DEPTH_MAX,
4420
4714
  DIALOG_SELECTOR,
4421
4715
  DOCK_BUDGET,
4422
4716
  DOCK_ICON_NAMES,
@@ -4424,8 +4718,11 @@ export {
4424
4718
  FIELD_SIZE_ZOOM,
4425
4719
  FIELD_STYLE_KEYS,
4426
4720
  FOOTER_SECTION_ID,
4721
+ HELP_CAPS,
4722
+ HELP_MAX,
4427
4723
  IMAGE_ASPECTS,
4428
4724
  IMAGE_FRAME_RADIUS,
4725
+ KIT_CATEGORIES,
4429
4726
  LANDMARK_SELECTOR,
4430
4727
  LAYOUT_SECTION_ICONS,
4431
4728
  LAYOUT_SECTION_ICON_SET,
@@ -4438,21 +4735,32 @@ export {
4438
4735
  OPTION_DESCRIPTION_MAX,
4439
4736
  PAGE_CONTENT_ANCHOR_ID,
4440
4737
  RESPONSIVE_CSS,
4738
+ ROLE_HELP,
4441
4739
  ROLE_KEYS,
4442
4740
  SECTION_DOCTRINE,
4443
4741
  SECTION_SPACE_TOKENS,
4742
+ SEGMENTED_MAX,
4743
+ SEGMENTED_MIN,
4444
4744
  SIDE_SPACE_MIN_PX,
4445
4745
  SIDE_SPACE_TOKENS,
4446
4746
  SLOT_CHILD_KEYS,
4447
4747
  SLOT_ITEMS_CAP,
4448
4748
  SLOT_MAX_ITEMS,
4749
+ SLOT_SETTINGS_MAX,
4750
+ SLOT_SETTINGS_TYPES,
4751
+ SOURCE_RANK,
4449
4752
  SPACE_BOTTOM_TOKENS,
4450
4753
  SPACE_STEP_TOKENS,
4451
4754
  TABLE_COLUMN_TYPES,
4452
4755
  TABLE_JSONLD_TYPES,
4453
4756
  TABLE_LIMITS,
4454
4757
  TABLE_RESPONSIVE,
4758
+ TAB_MAX,
4455
4759
  TAG_HEADS,
4760
+ UI_REFUSAL_CODES,
4761
+ V2_KEYS,
4762
+ V2_PLACEMENTS,
4763
+ V2_SHAPES,
4456
4764
  VIDEO_TRANSCRIPT_MAX,
4457
4765
  VIDEO_VALUE_KEYS,
4458
4766
  allowRuleOf,
@@ -4472,11 +4780,13 @@ export {
4472
4780
  buttonValueProblem,
4473
4781
  buttonVariantOf,
4474
4782
  candidateRole,
4783
+ canonicalJson,
4475
4784
  componentInstanceAddresses,
4476
4785
  componentPropTargetKey,
4477
4786
  derivedPairs,
4478
4787
  dockBudget,
4479
4788
  dockScreens,
4789
+ exampleFor,
4480
4790
  expandBlockBindings,
4481
4791
  fieldGroupOf,
4482
4792
  fieldStyleCssText,
@@ -4495,9 +4805,11 @@ export {
4495
4805
  isCodeButton,
4496
4806
  isLinkObject,
4497
4807
  isRoleKey,
4808
+ isRulePaired,
4498
4809
  isScriptHref,
4499
4810
  isSlotChild,
4500
4811
  isTableValue,
4812
+ isUiRefusal,
4501
4813
  keyWords,
4502
4814
  landmarkRegions,
4503
4815
  linkAnchorOf,
@@ -4506,6 +4818,7 @@ export {
4506
4818
  linkValueProblem,
4507
4819
  locatorFor,
4508
4820
  locatorPath,
4821
+ mayOverwrite,
4509
4822
  normalizeLinkValue,
4510
4823
  normalizeTableValue,
4511
4824
  normalizeWindow,
@@ -4519,6 +4832,7 @@ export {
4519
4832
  readPath,
4520
4833
  regionOf,
4521
4834
  renderTableHtml,
4835
+ rulePartnerOf,
4522
4836
  safeCssUrl,
4523
4837
  sideFloorApplies,
4524
4838
  sideSpaceCss,
@@ -4536,6 +4850,7 @@ export {
4536
4850
  tableToMarkdown,
4537
4851
  tableValueProblems,
4538
4852
  topFieldKeyOf,
4853
+ uiRefusalId,
4539
4854
  usesHideOn,
4540
4855
  videoUrlOf,
4541
4856
  videoValueProblem,
@@ -4543,6 +4858,7 @@ export {
4543
4858
  visibleDeliveredLayout,
4544
4859
  visibleLayoutStructure,
4545
4860
  windowState,
4546
- withButtonLookProps
4861
+ withButtonLookProps,
4862
+ withExample
4547
4863
  };
4548
4864
  //# sourceMappingURL=index.js.map