@perkyzz/emvb 1.2.0 → 1.4.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.
Files changed (150) hide show
  1. package/README.md +2 -2
  2. package/THIRD_PARTY_NOTICES.md +2 -2
  3. package/package.json +4 -4
  4. package/src/admin/bulk-api.ts +5 -1
  5. package/src/admin/editor/A11yCopilot.tsx +3 -1
  6. package/src/admin/editor/Editor.tsx +22 -2
  7. package/src/admin/editor/Timeline.tsx +1 -8
  8. package/src/admin/editor/canvas/DeviceBar.tsx +7 -2
  9. package/src/admin/editor/canvas/EmptyCanvas.tsx +11 -2
  10. package/src/admin/editor/canvas/use-canvas-dnd.ts +1 -20
  11. package/src/admin/editor/canvas/vnode-react.tsx +5 -0
  12. package/src/admin/editor/co-design.ts +36 -1
  13. package/src/admin/editor/dnd/dragged-source.ts +22 -0
  14. package/src/admin/editor/dnd/layer-drop.ts +141 -0
  15. package/src/admin/editor/dnd/new-element.ts +76 -0
  16. package/src/admin/editor/editor-css.ts +9 -1
  17. package/src/admin/editor/element-chrome.ts +34 -0
  18. package/src/admin/editor/feature-css.ts +22 -0
  19. package/src/admin/editor/inert-links.ts +8 -0
  20. package/src/admin/editor/panels/ColorControl.tsx +2 -2
  21. package/src/admin/editor/panels/FontFaces.tsx +342 -0
  22. package/src/admin/editor/panels/LayersPanel.tsx +56 -6
  23. package/src/admin/editor/panels/LeftPanel.tsx +153 -29
  24. package/src/admin/editor/panels/SettingsPanel.tsx +1 -0
  25. package/src/admin/editor/panels/SiteStylesDrawer.tsx +5 -0
  26. package/src/admin/editor/panels/TemplatesPanel.tsx +205 -0
  27. package/src/admin/editor/panels/TokenScales.tsx +2 -0
  28. package/src/admin/editor/panels/TriggersEditor.tsx +203 -9
  29. package/src/admin/editor/panels/VariableSection.tsx +111 -7
  30. package/src/admin/editor/panels/color-space.ts +71 -6
  31. package/src/admin/editor/panels/settings/AudienceEditor.tsx +3 -0
  32. package/src/admin/editor/panels/settings/FieldControl.tsx +18 -0
  33. package/src/admin/editor/panels/settings/ItemList.tsx +33 -0
  34. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +9 -3
  35. package/src/admin/editor/panels/settings/StickyControl.tsx +97 -0
  36. package/src/admin/editor/panels/settings/StyleRow.tsx +14 -0
  37. package/src/admin/editor/panels/settings/style-sections.ts +19 -2
  38. package/src/admin/editor/panels/url-rules.ts +43 -0
  39. package/src/admin/editor/panels/use-layers-drop.ts +232 -0
  40. package/src/admin/editor/store.ts +4 -2
  41. package/src/admin/editor/useExtensions.ts +3 -1
  42. package/src/admin/editor/useNodeActions.ts +74 -1
  43. package/src/admin/editor/useSave.ts +116 -85
  44. package/src/admin/export-api.ts +25 -2
  45. package/src/admin/extension-outputs.ts +179 -0
  46. package/src/admin/font-files-api.ts +38 -0
  47. package/src/admin/pages/ImportButton.tsx +15 -4
  48. package/src/admin/pages/ImportElementorDialog.tsx +22 -188
  49. package/src/admin/pages/ImportHtmlDialog.tsx +209 -0
  50. package/src/admin/pages/ImportImageCopies.tsx +167 -0
  51. package/src/admin/pages/ImportReport.tsx +63 -0
  52. package/src/admin/pages/NewPageDialog.tsx +54 -32
  53. package/src/admin/pages/PageList.tsx +9 -0
  54. package/src/admin/pages/ThemePartList.tsx +9 -0
  55. package/src/astro/EmVBPage.astro +5 -2
  56. package/src/astro/extension-styles.ts +35 -0
  57. package/src/astro/forms/EmVBFormsClient.astro +3 -0
  58. package/src/astro/forms/enhance.ts +107 -0
  59. package/src/astro/popups/runtime.ts +47 -2
  60. package/src/astro/render.ts +19 -4
  61. package/src/astro/request-data.ts +6 -0
  62. package/src/astro/resolve-theme.ts +11 -4
  63. package/src/astro/resolve.ts +9 -0
  64. package/src/astro/widgets/EmVBCountdownRuntime.astro +8 -0
  65. package/src/astro/widgets/EmVBCounterRuntime.astro +8 -0
  66. package/src/astro/widgets/EmVBHeadlineRuntime.astro +9 -0
  67. package/src/astro/widgets/EmVBMapRuntime.astro +8 -0
  68. package/src/astro/widgets/EmVBShareRuntime.astro +9 -0
  69. package/src/astro/widgets/EmVBStickyRuntime.astro +9 -0
  70. package/src/astro/widgets/EmVBThemeRuntime.astro +9 -0
  71. package/src/astro/widgets/EmVBWidgetRuntimes.astro +22 -0
  72. package/src/astro/widgets/alerts.ts +16 -2
  73. package/src/astro/widgets/carousel.ts +65 -24
  74. package/src/astro/widgets/countdown.ts +91 -0
  75. package/src/astro/widgets/counter.ts +98 -0
  76. package/src/astro/widgets/extension-runtimes.ts +27 -0
  77. package/src/astro/widgets/headline.ts +99 -0
  78. package/src/astro/widgets/map.ts +37 -0
  79. package/src/astro/widgets/share.ts +21 -0
  80. package/src/astro/widgets/sticky.ts +87 -0
  81. package/src/astro/widgets/theme.ts +52 -0
  82. package/src/constants.ts +1 -1
  83. package/src/core/a11y/audit.ts +177 -6
  84. package/src/core/arrange.ts +71 -1
  85. package/src/core/canvas-collections.ts +28 -0
  86. package/src/core/css/font-face.ts +72 -0
  87. package/src/core/css/generate.ts +35 -1
  88. package/src/core/elements/counter-format.ts +15 -0
  89. package/src/core/elements/form-elements.ts +119 -9
  90. package/src/core/elements/icon-svg.ts +14 -0
  91. package/src/core/elements/index.ts +54 -4
  92. package/src/core/elements/input-limits.ts +44 -0
  93. package/src/core/elements/marketing.ts +1490 -0
  94. package/src/core/elements/menu.ts +109 -47
  95. package/src/core/elements/site.ts +108 -0
  96. package/src/core/elements/widgets.ts +40 -5
  97. package/src/core/export/runtimes.generated.ts +10 -3
  98. package/src/core/export/site.ts +55 -4
  99. package/src/core/extensions/classes.ts +114 -0
  100. package/src/core/extensions/index.ts +17 -2
  101. package/src/core/extensions/normalize.ts +13 -0
  102. package/src/core/extensions/registry.ts +134 -10
  103. package/src/core/extensions/render-ext.ts +66 -21
  104. package/src/core/extensions/safe-nodes.ts +67 -11
  105. package/src/core/extensions/types.ts +48 -1
  106. package/src/core/fonts/files.ts +74 -0
  107. package/src/core/fonts/google.ts +112 -0
  108. package/src/core/fonts/test-font.ts +9 -0
  109. package/src/core/import/elementor/context.ts +13 -4
  110. package/src/core/import/elementor/index.ts +32 -21
  111. package/src/core/import/elementor/widgets.ts +532 -293
  112. package/src/core/import/html/blocks.ts +602 -0
  113. package/src/core/import/html/index.ts +155 -0
  114. package/src/core/import/html/map.ts +958 -0
  115. package/src/core/import/html/parse.ts +430 -0
  116. package/src/core/index.ts +45 -0
  117. package/src/core/limits.ts +6 -0
  118. package/src/core/migrate/v18.ts +3 -0
  119. package/src/core/public-attributes.ts +17 -0
  120. package/src/core/render/extras.ts +31 -7
  121. package/src/core/render/form.ts +103 -10
  122. package/src/core/render/index.ts +172 -16
  123. package/src/core/render/section.ts +31 -1
  124. package/src/core/render/spacer-basis.ts +102 -0
  125. package/src/core/render/theme-boot.ts +16 -0
  126. package/src/core/render/vnode.ts +1 -1
  127. package/src/core/sanitize/css.ts +68 -3
  128. package/src/core/sanitize/motion.ts +12 -0
  129. package/src/core/schema/design.ts +40 -0
  130. package/src/core/schema/layout.ts +534 -22
  131. package/src/core/schema/style.ts +28 -0
  132. package/src/core/templates/index.ts +218 -0
  133. package/src/core/templates/pages.ts +29 -0
  134. package/src/core/templates/sections.ts +794 -0
  135. package/src/core/templates/types.ts +9 -0
  136. package/src/core/theme/dynamic.ts +11 -6
  137. package/src/core/theme/popup-markup.ts +21 -2
  138. package/src/core/theme/popup-rules.ts +36 -0
  139. package/src/core/theme/triggers.ts +64 -5
  140. package/src/core/translatable.ts +5 -2
  141. package/src/extension-build.ts +331 -0
  142. package/src/index.ts +25 -3
  143. package/src/mcp/brief.ts +191 -0
  144. package/src/mcp/prompts.ts +33 -0
  145. package/src/mcp/read.ts +29 -1
  146. package/src/mcp/tools.ts +40 -1
  147. package/src/mcp/write.ts +41 -1
  148. package/src/server/extension-routes.ts +73 -0
  149. package/src/server/font-routes.ts +301 -0
  150. package/src/server/plugin.ts +11 -1
@@ -5,7 +5,7 @@
5
5
  * EmVB's sanitizers before it lands in a node.
6
6
  */
7
7
  import { MAX_TABS, MAX_TEXT_LENGTH } from "../../limits.ts";
8
- import { FIELD_NAME_PATTERN, ICON_SVG_MAX } from "../../schema/layout.ts";
8
+ import { FIELD_NAME_PATTERN, ICON_SVG_MAX, MAX_INPUT_NUMBER } from "../../schema/layout.ts";
9
9
  import { sanitizeHref } from "../../sanitize/href.ts";
10
10
  import { sanitizeMediaUrl } from "../../sanitize/media-url.ts";
11
11
  import { type ImportContext, type MenuLink, svgFileId } from "./context.ts";
@@ -887,107 +887,71 @@ const video: Widget = (s, ctx, el) => {
887
887
  return [node(ctx, "video", { url: safe, title: "Video" })];
888
888
  };
889
889
 
890
+ /** A number a Counter can show. */
891
+ const clamp = (n: number) => Math.min(1e12, Math.max(-1e12, n));
892
+
893
+ /** W-1049: Elementor's Counter → a Counter that counts up as it does (5 s at most). */
890
894
  const counter: Widget = (s, ctx, el) => {
891
- const end = num(s["ending_number"]) ?? 100;
895
+ const end = clamp(num(s["ending_number"]) ?? 100);
896
+ const start = clamp(num(s["starting_number"]) ?? 0);
897
+ const sep = str(s["thousand_separator_char"]);
892
898
  const separator =
893
- str(s["thousand_separator"]) !== "" && s["thousand_separator"] !== undefined
894
- ? (str(s["thousand_separator_char"]) ?? ",")
895
- : "";
896
- const digits = String(Math.trunc(Math.abs(end))).replace(
897
- /\B(?=(\d{3})+(?!\d))/g,
898
- separator === "space" ? " " : separator,
899
- );
900
- const number = `${plain(s["prefix"]).text}${end < 0 ? "-" : ""}${digits}${plain(s["suffix"]).text}`;
901
- ctx.note("approximated", el, "Counters show their final number, without the counting animation.");
902
- const children = [
903
- styled(
904
- node(
905
- ctx,
906
- "text",
907
- { text: short(number), tag: "div" },
908
- { style: { fontSize: { value: 69, unit: "px" }, fontWeight: 600, lineHeight: 1 } },
909
- ),
910
- deviceStyles(s, ctx, el, [
911
- typographyReader("typography_number", "primary"),
912
- textReader("number_color", "primary"),
913
- ]),
914
- ),
915
- ];
899
+ s["thousand_separator"] === "yes" || (s["thousand_separator"] === undefined && sep)
900
+ ? sep === "." || sep === "'"
901
+ ? sep
902
+ : sep === " " || sep === "space"
903
+ ? " "
904
+ : ","
905
+ : undefined;
906
+ const decimals = (String(end).split(".")[1] ?? "").length;
907
+ const duration = num(s["duration"]) ?? 2000;
908
+ if (duration > 5000) ctx.note("approximated", el, "Counters count up in 5 seconds at most.");
916
909
  const title = plain(s["title"]).text;
917
- if (title) {
918
- children.push(
919
- styled(
920
- node(
921
- ctx,
922
- "text",
923
- { text: short(title), tag: "div" },
924
- { style: { fontSize: { value: 19, unit: "px" } } },
925
- ),
926
- deviceStyles(s, ctx, el, [
927
- typographyReader("typography_title", "secondary"),
928
- textReader("title_color", "secondary"),
929
- ]),
930
- ),
931
- );
932
- }
933
910
  return [
934
- box(ctx, children, {
935
- alignItems: "center",
936
- textAlign: "center",
937
- gap: { value: 5, unit: "px" },
938
- }),
911
+ styled(
912
+ node(ctx, "counter", {
913
+ value: end,
914
+ ...(start !== 0 ? { start } : {}),
915
+ ...(decimals ? { decimals: Math.min(3, decimals) } : {}),
916
+ ...(separator ? { separator } : {}),
917
+ ...(plain(s["prefix"]).text ? { prefix: plain(s["prefix"]).text.slice(0, 20) } : {}),
918
+ ...(plain(s["suffix"]).text ? { suffix: plain(s["suffix"]).text.slice(0, 20) } : {}),
919
+ ...(title ? { title: title.slice(0, 200) } : {}),
920
+ countUp: true,
921
+ duration: Math.min(5000, Math.max(300, Math.round(duration))),
922
+ }),
923
+ deviceStyles(s, ctx, el, [textReader("number_color", "primary")]),
924
+ ),
939
925
  ];
940
926
  };
941
927
 
928
+ /** W-1049: Elementor's Progress Bar → a Progress bar that grows in, as Elementor's does. */
942
929
  const progress: Widget = (s, ctx, el) => {
943
930
  const percent = Math.min(
944
931
  100,
945
- Math.max(
946
- 0,
947
- Math.round(num(isRecord(s["percent"]) ? s["percent"]["size"] : s["percent"]) ?? 50),
948
- ),
932
+ Math.max(0, num(isRecord(s["percent"]) ? s["percent"]["size"] : s["percent"]) ?? 50),
949
933
  );
934
+ const title = plain(s["title"]).text;
935
+ if (plain(s["inner_text"]).text)
936
+ ctx.note("approximated", el, "Text inside progress bars was left out; the title stays.");
950
937
  const bar =
951
938
  colorAt(s, "bar_color", ctx) ??
952
939
  (ctx.useDefaults ? ctx.globalColor("primary") : undefined) ??
953
940
  "#6ec1e4";
954
- const children: N[] = [];
955
- const title = plain(s["title"]).text;
956
- if (title) children.push(node(ctx, "text", { text: short(title), tag: "div" }));
957
- const inner = plain(s["inner_text"]).text;
958
- const fill = box(
959
- ctx,
960
- inner
961
- ? [
962
- node(
963
- ctx,
964
- "text",
965
- { text: short(inner), tag: "div" },
966
- {
967
- style: {
968
- color: "#ffffff",
969
- paddingLeft: { value: 15, unit: "px" },
970
- lineHeight: { value: 30, unit: "px" },
971
- },
972
- },
973
- ),
974
- ]
975
- : [],
976
- {
977
- width: { value: percent, unit: "%" },
978
- minHeight: { value: 30, unit: "px" },
979
- backgroundColor: bar,
980
- justifyContent: "center",
981
- },
982
- );
983
- children.push(
984
- box(ctx, [fill], {
985
- backgroundColor: colorAt(s, "bar_bg_color", ctx) ?? "#eeeeee",
986
- minHeight: { value: 30, unit: "px" },
987
- }),
988
- );
989
- ctx.note("approximated", el, "Progress bars are shown filled, without their animation.");
990
- return [box(ctx, children, { gap: { value: 8, unit: "px" } })];
941
+ return [
942
+ node(
943
+ ctx,
944
+ "progress",
945
+ {
946
+ value: Math.round(percent * 100) / 100,
947
+ ...(title ? { label: title.slice(0, 120) } : {}),
948
+ ...(str(s["display_percentage"]) === "hide" ? {} : { showValue: true }),
949
+ thickness: 30,
950
+ grow: true,
951
+ },
952
+ { style: { color: bar } },
953
+ ),
954
+ ];
991
955
  };
992
956
 
993
957
  /** W-1022: Elementor's Testimonial → a Testimonial: quote, photo, name and job. */
@@ -1028,6 +992,24 @@ const testimonial: Widget = (s, ctx, el) => {
1028
992
  ];
1029
993
  };
1030
994
 
995
+ /**
996
+ * W-1073: Elementor Pro's Search Form becomes EmVB's, sending `?q=` to the site's /search page
997
+ * (WordPress's `?s=` doesn't apply on EmDash). The icon-only button and the full-screen skin
998
+ * become a field and a text button.
999
+ */
1000
+ const searchForm: Widget = (s, ctx, el) => {
1001
+ const placeholder = plain(s["placeholder"]).text;
1002
+ const buttonText = plain(s["button_text"]).text;
1003
+ if (s["skin"] === "full_screen" || s["button_type"] === "icon")
1004
+ ctx.note("approximated", el, "Search forms show a field and a Search button.");
1005
+ return [
1006
+ node(ctx, "search-form", {
1007
+ ...(placeholder ? { placeholder: placeholder.slice(0, 120) } : {}),
1008
+ ...(buttonText && s["button_type"] !== "icon" ? { buttonText: buttonText.slice(0, 40) } : {}),
1009
+ }),
1010
+ ];
1011
+ };
1012
+
1031
1013
  /** W-1023: Elementor's Star Rating → a Rating, with its title as text beside it. */
1032
1014
  const starRating: Widget = (s, ctx, el) => {
1033
1015
  const scale = Math.min(10, Math.max(1, Math.round(num(s["rating_scale"]) ?? 5)));
@@ -1119,15 +1101,24 @@ const menuAnchor: Widget = (s, ctx, el) => {
1119
1101
  return [box(ctx, [], {}, { htmlId: anchor, editorLabel: `Anchor ${anchor}`.slice(0, 80) })];
1120
1102
  };
1121
1103
 
1104
+ /** W-1049: Elementor's Google Maps → a Map that loads Google's map when a visitor asks. */
1122
1105
  const googleMaps: Widget = (s, ctx, el) => {
1123
- const address = plain(s["address"]).text;
1124
- ctx.note("approximated", el, "Google Maps embeds became a link to the map.");
1106
+ const address = plain(s["address"]).text.slice(0, 300);
1125
1107
  if (!address) return [];
1108
+ const zoom = num(isRecord(s["zoom"]) ? s["zoom"]["size"] : s["zoom"]);
1109
+ const height = num(isRecord(s["height"]) ? s["height"]["size"] : s["height"]);
1110
+ ctx.note(
1111
+ "approximated",
1112
+ el,
1113
+ "Google Maps load when a visitor presses Show the map, so Google isn't contacted before.",
1114
+ );
1126
1115
  return [
1127
- node(ctx, "link", {
1128
- text: short(`View map: ${address}`),
1129
- href: `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(address.slice(0, 500))}`,
1130
- newTab: true,
1116
+ node(ctx, "map", {
1117
+ address,
1118
+ provider: "google",
1119
+ embed: true,
1120
+ ...(zoom ? { zoom: Math.min(19, Math.max(1, Math.round(zoom))) } : {}),
1121
+ ...(height ? { height: Math.min(800, Math.max(150, Math.round(height))) } : {}),
1131
1122
  }),
1132
1123
  ];
1133
1124
  };
@@ -1207,35 +1198,7 @@ function carouselWidget(
1207
1198
  img["style"] = { width: { value: 100, unit: "%" }, height: "auto" };
1208
1199
  slides.push(node(ctx, "carousel-slide", {}, { children: [img] }));
1209
1200
  }
1210
- if (slides.length === 0) return [];
1211
- const navigation = str(s["navigation"]) ?? "both";
1212
- const autoplay = str(s["autoplay"]);
1213
- if (autoplay !== "yes" && autoplay !== "no")
1214
- ctx.note(
1215
- "approximated",
1216
- el,
1217
- "Carousels don't play by themselves unless you turn on Play automatically.",
1218
- );
1219
- const speed = num(s["autoplay_speed"]);
1220
- return [
1221
- node(
1222
- ctx,
1223
- "carousel",
1224
- {
1225
- perView: Math.min(4, Math.max(1, Math.round(perView))),
1226
- ...(navigation === "both" || navigation === "arrows" ? { arrows: true } : {}),
1227
- ...(navigation === "both" || navigation === "dots" ? { dots: true } : {}),
1228
- ...(autoplay === "yes"
1229
- ? {
1230
- autoplay: true,
1231
- ...(speed ? { interval: Math.min(30, Math.max(3, Math.round(speed / 1000))) } : {}),
1232
- }
1233
- : {}),
1234
- ...(str(s["infinite"]) === "no" ? {} : { loop: true }),
1235
- },
1236
- { children: slides },
1237
- ),
1238
- ];
1201
+ return carouselFrom(slides, perView, s, ctx, el);
1239
1202
  }
1240
1203
 
1241
1204
  const imageCarousel: Widget = (s, ctx, el) =>
@@ -1527,13 +1490,60 @@ const FIELD_TYPES: Record<string, string> = {
1527
1490
  acceptance: "checkbox",
1528
1491
  };
1529
1492
 
1493
+ /** W-1065: an Elementor date limit as YYYY-MM-DD (its date picker also allows "today"). */
1494
+ const ELEMENTOR_DATE = /^[1-9]\d{3}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
1495
+ const isoDate = (value: unknown) => {
1496
+ const text = str(value)?.trim() ?? "";
1497
+ if (!ELEMENTOR_DATE.test(text)) return undefined;
1498
+ const [y, m, d] = text.split("-").map(Number) as [number, number, number];
1499
+ const day = new Date(Date.UTC(y, m - 1, d));
1500
+ return day.getUTCMonth() === m - 1 && day.getUTCDate() === d ? text : undefined;
1501
+ };
1502
+ const inputNumber = (value: unknown) => {
1503
+ const n = num(value);
1504
+ return n !== undefined && Math.abs(n) <= MAX_INPUT_NUMBER ? n : undefined;
1505
+ };
1506
+
1507
+ const defined = (props: Record<string, unknown>) =>
1508
+ Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
1509
+
1510
+ /** W-1065: a number or date field's own box and limits. */
1511
+ function typedField(type: string, raw: Settings): Record<string, unknown> {
1512
+ if (type === "number") {
1513
+ const min = inputNumber(raw["field_min"]);
1514
+ const max = inputNumber(raw["field_max"]);
1515
+ const range = min !== undefined && max !== undefined && min > max ? {} : { min, max };
1516
+ return defined({ inputType: "number", ...range });
1517
+ }
1518
+ if (type === "date") {
1519
+ const minDate = isoDate(raw["min_date"]);
1520
+ const maxDate = isoDate(raw["max_date"]);
1521
+ const range = minDate && maxDate && minDate > maxDate ? {} : { minDate, maxDate };
1522
+ return defined({ inputType: "date", ...range });
1523
+ }
1524
+ return {};
1525
+ }
1526
+
1527
+ const MAX_FORM_STEPS = 20;
1528
+
1530
1529
  const form: Widget = (s, ctx, el) => {
1531
1530
  const fields = Array.isArray(s["form_fields"]) ? s["form_fields"].slice(0, 100) : [];
1532
- const children: N[] = [];
1531
+ const loose: N[] = [];
1532
+ const steps: { title: string; children: N[] }[] = [];
1533
1533
  const names = new Set<string>();
1534
+ let nextLabel = "";
1535
+ let prevLabel = "";
1534
1536
  fields.forEach((raw, i) => {
1535
1537
  if (!isRecord(raw)) return;
1536
1538
  const type = str(raw["field_type"]) ?? "text";
1539
+ // W-1065: a Step field starts a step; the fields after it, up to the next, are its fields.
1540
+ if (type === "step") {
1541
+ if (steps.length >= MAX_FORM_STEPS) return;
1542
+ steps.push({ title: plain(raw["field_label"]).text.slice(0, 200), children: [] });
1543
+ nextLabel ||= plain(raw["next_button"]).text.slice(0, 80);
1544
+ prevLabel ||= plain(raw["previous_button"]).text.slice(0, 80);
1545
+ return;
1546
+ }
1537
1547
  const nodeType = FIELD_TYPES[type];
1538
1548
  if (!nodeType) {
1539
1549
  ctx.note("skipped", el, `Form field type "${type}" was left out.`);
@@ -1547,14 +1557,24 @@ const form: Widget = (s, ctx, el) => {
1547
1557
  plain(raw["field_label"]).text.slice(0, 200) ||
1548
1558
  (type === "acceptance" ? plain(raw["acceptance_text"]).text.slice(0, 200) : "");
1549
1559
  const placeholder = plain(raw["placeholder"]).text.slice(0, 200);
1550
- children.push(
1551
- node(ctx, nodeType, {
1552
- field: name,
1553
- ...(label ? { label } : {}),
1554
- ...(placeholder && nodeType !== "checkbox" ? { placeholder } : {}),
1555
- }),
1556
- );
1560
+ const field = node(ctx, nodeType, {
1561
+ field: name,
1562
+ ...(label ? { label } : {}),
1563
+ ...(placeholder && nodeType !== "checkbox" ? { placeholder } : {}),
1564
+ ...typedField(type, raw),
1565
+ });
1566
+ const step = steps[steps.length - 1];
1567
+ if (step) step.children.push(field);
1568
+ else loose.push(field);
1557
1569
  });
1570
+ // Fields before the first Step field are a step of their own, as Elementor shows them.
1571
+ if (steps.length > 0 && loose.length > 0) steps.unshift({ title: "", children: loose.splice(0) });
1572
+ const children: N[] = [
1573
+ ...loose,
1574
+ ...steps.map((step) =>
1575
+ node(ctx, "form-step", step.title ? { title: step.title } : {}, { children: step.children }),
1576
+ ),
1577
+ ];
1558
1578
  const label = plain(s["button_text"]).text.slice(0, 80) || "Send";
1559
1579
  children.push(node(ctx, "submit", { label }));
1560
1580
  ctx.note(
@@ -1562,8 +1582,24 @@ const form: Widget = (s, ctx, el) => {
1562
1582
  el,
1563
1583
  "Connect each imported form to a form in the forms plugin; field options and email actions weren't imported.",
1564
1584
  );
1585
+ if (steps.length > 0) {
1586
+ ctx.note(
1587
+ "approximated",
1588
+ el,
1589
+ 'Form steps became EmVB form steps; one Next and one Previous label serve every step, and the step indicator is EmDash\'s "Step 1 of 3".',
1590
+ );
1591
+ }
1592
+ const labels = {
1593
+ ...(steps.length > 0 && nextLabel ? { nextLabel } : {}),
1594
+ ...(steps.length > 0 && prevLabel ? { prevLabel } : {}),
1595
+ };
1565
1596
  return [
1566
- node(ctx, "form", { formId: "" }, { style: { gap: { value: 10, unit: "px" } }, children }),
1597
+ node(
1598
+ ctx,
1599
+ "form",
1600
+ { formId: "", ...labels },
1601
+ { style: { gap: { value: 10, unit: "px" } }, children },
1602
+ ),
1567
1603
  ];
1568
1604
  };
1569
1605
 
@@ -1609,11 +1645,18 @@ const navMenu: Widget = (s, ctx, el) => {
1609
1645
  ];
1610
1646
  };
1611
1647
 
1648
+ /**
1649
+ * Elementor's Mega Menu → a Menu whose items hold their dropdown content. W-1069: Elementor's
1650
+ * dropdowns span the menu unless Content width is Fit to content, so those panels are wide. The
1651
+ * content stays in the item (Elementor keeps it in the widget, not in a shared template), so it
1652
+ * isn't turned into a Section theme part.
1653
+ */
1612
1654
  const megaMenu: Widget = (s, ctx, _el, env, raw) => {
1613
1655
  const items = (Array.isArray(s["menu_items"]) ? s["menu_items"] : [])
1614
1656
  .filter(isRecord)
1615
1657
  .slice(0, 50);
1616
1658
  const kids = Array.isArray(raw["elements"]) ? raw["elements"] : [];
1659
+ const wide = str(s["content_width"]) !== "fit_to_content";
1617
1660
  const children = items.map((item, i) => {
1618
1661
  const text = plain(item["item_title"]).text || "Item";
1619
1662
  const panel =
@@ -1623,149 +1666,164 @@ const megaMenu: Widget = (s, ctx, _el, env, raw) => {
1623
1666
  return node(
1624
1667
  ctx,
1625
1668
  "menu-item",
1626
- { text: short(text), ...href(item["item_link"], ctx) },
1669
+ {
1670
+ text: short(text),
1671
+ ...href(item["item_link"], ctx),
1672
+ ...(wide && panel.length > 0 ? { wide: true } : {}),
1673
+ },
1627
1674
  { children: panel },
1628
1675
  );
1629
1676
  });
1630
1677
  return [node(ctx, "menu", { direction: "row" }, { children })];
1631
1678
  };
1632
1679
 
1680
+ /** W-1049: Elementor's Call to Action → a Call to action: picture, title, text, button, ribbon. */
1633
1681
  const callToAction: Widget = (s, ctx, el) => {
1634
- const children: N[] = [];
1635
- const style: Style = {
1636
- gap: { value: 15, unit: "px" },
1637
- paddingTop: { value: 35, unit: "px" },
1638
- paddingBottom: { value: 35, unit: "px" },
1639
- paddingLeft: { value: 35, unit: "px" },
1640
- paddingRight: { value: 35, unit: "px" },
1641
- alignItems: "center",
1642
- textAlign: "center",
1643
- };
1682
+ const title = plain(s["title"]).text.slice(0, 200);
1683
+ if (!title) return [];
1684
+ const level = Number(/^h([2-6])$/.exec(str(s["title_tag"]) ?? "h2")?.[1] ?? 2);
1644
1685
  const bg = image(s["bg_image"]);
1645
- if (bg && !/[()\\\s"'`]/.test(bg.url)) {
1646
- style["backgroundImage"] = bg.url;
1647
- style["backgroundSize"] = "cover";
1648
- style["backgroundPosition"] = "center";
1649
- }
1650
- const fill = colorAt(s, "background_color", ctx);
1651
- if (fill) style["backgroundColor"] = fill;
1652
- const title = plain(s["title"]).text;
1653
- const level = Number(/^h([1-6])$/.exec(str(s["title_tag"]) ?? "h2")?.[1] ?? 2);
1654
- if (title) children.push(node(ctx, "heading", { text: short(title), level }));
1686
+ if (bg) ctx.externalImage(bg.url);
1687
+ const layout = str(s["layout"]);
1688
+ const where =
1689
+ str(s["skin"]) === "cover"
1690
+ ? "behind"
1691
+ : layout === "left"
1692
+ ? "left"
1693
+ : layout === "right"
1694
+ ? "right"
1695
+ : "top";
1696
+ const target = href(s["link"], ctx);
1697
+ const btn = plain(s["button"]).text.slice(0, 80);
1655
1698
  const description = plain(s["description"]).text;
1656
- if (description) children.push(node(ctx, "text", { text: short(description) }));
1657
- const btn = buttonNode(s, ctx, el, { text: "button", link: "link", icon: "selected_icon" });
1658
- if (btn) children.push(btn);
1659
- ctx.note(
1660
- "approximated",
1661
- el,
1662
- "Call to Action boxes keep their text, image and button, not their hover effects.",
1663
- );
1664
- return children.length > 0 ? [box(ctx, children, style)] : [];
1699
+ const ribbon = plain(s["ribbon_title"]).text.slice(0, 30);
1700
+ ctx.note("approximated", el, "Call to Action boxes keep their content, not their hover effects.");
1701
+ const fill = colorAt(s, "background_color", ctx);
1702
+ return [
1703
+ node(
1704
+ ctx,
1705
+ "cta",
1706
+ {
1707
+ title,
1708
+ ...(level !== 3 ? { titleLevel: level } : {}),
1709
+ ...(description ? { text: short(description) } : {}),
1710
+ ...(bg ? { src: bg.url, alt: bg.alt ?? "" } : {}),
1711
+ layout: where,
1712
+ ...(btn && target.href ? { buttonText: btn } : {}),
1713
+ ...target,
1714
+ ...(ribbon ? { ribbon } : {}),
1715
+ },
1716
+ fill ? { style: { backgroundColor: fill } } : {},
1717
+ ),
1718
+ ];
1719
+ };
1720
+
1721
+ const CURRENCY_SYMBOLS: Record<string, string> = {
1722
+ dollar: "$",
1723
+ euro: "€",
1724
+ pound: "£",
1725
+ yen: "¥",
1726
+ rupee: "₹",
1727
+ franc: "₣",
1728
+ real: "R$",
1729
+ baht: "฿",
1730
+ krona: "kr",
1731
+ lira: "₺",
1732
+ peseta: "₧",
1733
+ peso: "₱",
1734
+ shekel: "₪",
1735
+ won: "₩",
1736
+ guilder: "ƒ",
1665
1737
  };
1666
1738
 
1739
+ /** W-1049: Elementor's Price Table → a Price table: price, sale price, features, button, ribbon. */
1667
1740
  const priceTable: Widget = (s, ctx, el) => {
1668
- const children: N[] = [];
1669
- const headingText = plain(s["heading"]).text;
1670
- if (headingText)
1671
- children.push(
1672
- node(ctx, "heading", {
1673
- text: short(headingText),
1674
- level: Number(/^h([1-6])$/.exec(str(s["heading_tag"]) ?? "h3")?.[1] ?? 3),
1675
- }),
1676
- );
1677
- const sub = plain(s["sub_heading"]).text;
1678
- if (sub) children.push(node(ctx, "text", { text: short(sub) }));
1679
- const symbols: Record<string, string> = {
1680
- dollar: "$",
1681
- euro: "€",
1682
- pound: "£",
1683
- yen: "¥",
1684
- rupee: "₹",
1685
- franc: "₣",
1686
- real: "R$",
1687
- baht: "฿",
1688
- krona: "kr",
1689
- lira: "₺",
1690
- peseta: "₧",
1691
- peso: "₱",
1692
- shekel: "₪",
1693
- won: "₩",
1694
- guilder: "ƒ",
1695
- };
1696
- const currency =
1741
+ const title = plain(s["heading"]).text.slice(0, 120);
1742
+ const price = plain(s["price"]).text.slice(0, 20);
1743
+ if (!title && !price) return [];
1744
+ const currency = (
1697
1745
  str(s["currency_symbol"]) === "custom"
1698
1746
  ? plain(s["currency_symbol_custom"]).text
1699
- : (symbols[str(s["currency_symbol"]) ?? "dollar"] ?? "");
1700
- const price = plain(s["price"]).text;
1701
- if (price) {
1702
- const period = plain(s["period"]).text;
1703
- children.push(
1704
- node(
1705
- ctx,
1706
- "text",
1707
- { text: short(`${currency}${price}${period ? ` / ${period}` : ""}`), tag: "div" },
1708
- { style: { fontSize: { value: 2.5, unit: "em" }, fontWeight: 600 } },
1709
- ),
1710
- );
1711
- }
1747
+ : (CURRENCY_SYMBOLS[str(s["currency_symbol"]) ?? "dollar"] ?? "")
1748
+ ).slice(0, 5);
1749
+ const regular = s["sale"] === "yes" ? plain(s["original_price"]).text.slice(0, 20) : "";
1712
1750
  const features = (Array.isArray(s["features_list"]) ? s["features_list"] : [])
1713
1751
  .filter(isRecord)
1714
- .map((f) => short(plain(f["item_text"]).text))
1752
+ .map((f) => plain(f["item_text"]).text.slice(0, 200))
1715
1753
  .filter(Boolean)
1716
- .slice(0, 200);
1717
- if (features.length > 0) children.push(node(ctx, "list", { items: features }));
1718
- const btn = buttonNode(s, ctx, el, { text: "button_text", link: "link" });
1719
- if (btn) children.push(btn);
1754
+ .slice(0, 30);
1755
+ const sub = plain(s["sub_heading"]).text;
1720
1756
  const footer = plain(s["footer_additional_info"]).text;
1721
- if (footer) children.push(node(ctx, "text", { text: short(footer) }));
1722
- ctx.note(
1723
- "approximated",
1724
- el,
1725
- "Price tables keep their content in EmVB's default look; ribbons are left out.",
1726
- );
1727
- return children.length > 0
1728
- ? [
1729
- box(ctx, children, {
1730
- gap: { value: 12, unit: "px" },
1731
- alignItems: "center",
1732
- textAlign: "center",
1733
- }),
1734
- ]
1735
- : [];
1757
+ const description = [sub, footer].filter(Boolean).join("\n").slice(0, 500);
1758
+ const target = href(s["link"], ctx);
1759
+ const btn = plain(s["button_text"]).text.slice(0, 80);
1760
+ const ribbon = s["show_ribbon"] === "yes" ? plain(s["ribbon_title"]).text.slice(0, 30) : "";
1761
+ if (footer) ctx.note("approximated", el, "A price table's footer text joined its description.");
1762
+ const level = Number(/^h([2-6])$/.exec(str(s["heading_tag"]) ?? "h3")?.[1] ?? 3);
1763
+ return [
1764
+ node(ctx, "price-table", {
1765
+ title: title || price,
1766
+ ...(level !== 3 ? { titleLevel: level } : {}),
1767
+ ...(description ? { description } : {}),
1768
+ price: price || "0",
1769
+ ...(currency ? { currency } : {}),
1770
+ ...(plain(s["period"]).text ? { period: plain(s["period"]).text.slice(0, 40) } : {}),
1771
+ ...(regular ? { regularPrice: regular } : {}),
1772
+ ...(features.length > 0 ? { features } : {}),
1773
+ ...(btn && target.href ? { buttonText: btn, buttonHref: target.href } : {}),
1774
+ ...(target.newTab && btn ? { newTab: true } : {}),
1775
+ ...(s["show_ribbon"] === "yes" ? { featured: true, ...(ribbon ? { ribbon } : {}) } : {}),
1776
+ }),
1777
+ ];
1736
1778
  };
1737
1779
 
1780
+ /** W-1049: Elementor's Price List → a Price list, one item per row with its picture and link. */
1781
+ const priceList: Widget = (s, ctx, el) => {
1782
+ const rows = (Array.isArray(s["price_list"]) ? s["price_list"] : []).filter(isRecord);
1783
+ if (rows.length > 50) ctx.note("skipped", el, "Price lists keep their first 50 items.");
1784
+ const items: N[] = [];
1785
+ for (const row of rows.slice(0, 50)) {
1786
+ const title = plain(row["title"]).text.slice(0, 120);
1787
+ if (!title) continue;
1788
+ const img = image(row["image"]);
1789
+ if (img) ctx.externalImage(img.url);
1790
+ const target = href(row["link"], ctx);
1791
+ const description = plain(row["item_description"]).text.slice(0, 500);
1792
+ items.push(
1793
+ node(ctx, "price-list-item", {
1794
+ title,
1795
+ price: plain(row["price"]).text.slice(0, 20),
1796
+ ...(description ? { description } : {}),
1797
+ ...(img ? { src: img.url, ...(img.alt ? { alt: img.alt } : {}) } : {}),
1798
+ ...target,
1799
+ }),
1800
+ );
1801
+ }
1802
+ return items.length > 0 ? [node(ctx, "price-list", {}, { children: items })] : [];
1803
+ };
1804
+
1805
+ /** W-1049: Elementor's Flip Box → a Flip box: front and back, its direction and button. */
1738
1806
  const flipBox: Widget = (s, ctx, el) => {
1739
- const side = (suffix: "a" | "b") => {
1740
- const parts: N[] = [];
1741
- const title = plain(s[`title_text_${suffix}`]).text;
1742
- if (title) parts.push(node(ctx, "heading", { text: short(title), level: 3 }));
1743
- const text = plain(s[`description_text_${suffix}`]).text;
1744
- if (text) parts.push(node(ctx, "text", { text: short(text) }));
1745
- const fill = colorAt(s, `background_color_${suffix}`, ctx);
1746
- return parts.length > 0
1747
- ? box(ctx, parts, {
1748
- gap: { value: 10, unit: "px" },
1749
- alignItems: "center",
1750
- textAlign: "center",
1751
- ...(fill ? { backgroundColor: fill } : {}),
1752
- paddingTop: { value: 35, unit: "px" },
1753
- paddingBottom: { value: 35, unit: "px" },
1754
- paddingLeft: { value: 35, unit: "px" },
1755
- paddingRight: { value: 35, unit: "px" },
1756
- })
1757
- : undefined;
1758
- };
1759
- const front = side("a");
1760
- const back = side("b");
1761
- const btn = buttonNode(s, ctx, el, { text: "button_text", link: "link" });
1762
- if (back && btn) (back["children"] as N[]).push(btn);
1763
- ctx.note(
1764
- "approximated",
1765
- el,
1766
- "Flip boxes show their back side below the front, without the flip.",
1767
- );
1768
- return [front, back].filter((n): n is N => n !== undefined);
1807
+ const frontTitle = plain(s["title_text_a"]).text.slice(0, 200);
1808
+ const backTitle = plain(s["title_text_b"]).text.slice(0, 200);
1809
+ if (!frontTitle && !backTitle) return [];
1810
+ const frontText = plain(s["description_text_a"]).text;
1811
+ const backText = plain(s["description_text_b"]).text;
1812
+ const target = href(s["link"], ctx);
1813
+ const btn = plain(s["button_text"]).text.slice(0, 80);
1814
+ const direction = str(s["flip_direction"]);
1815
+ if (image(s["image"]) || isRecord(s["selected_icon"]))
1816
+ ctx.note("approximated", el, "A flip box's front image or icon was left out.");
1817
+ return [
1818
+ node(ctx, "flip-box", {
1819
+ frontTitle: frontTitle || backTitle,
1820
+ ...(frontText ? { frontText: short(frontText) } : {}),
1821
+ ...(backTitle ? { backTitle } : {}),
1822
+ ...(backText ? { backText: short(backText) } : {}),
1823
+ ...(btn && target.href ? { buttonText: btn, ...target } : {}),
1824
+ ...(direction === "left" || direction === "up" || direction === "down" ? { direction } : {}),
1825
+ }),
1826
+ ];
1769
1827
  };
1770
1828
 
1771
1829
  const blockquote: Widget = (s, ctx) => {
@@ -1794,25 +1852,45 @@ const blockquote: Widget = (s, ctx) => {
1794
1852
  ];
1795
1853
  };
1796
1854
 
1855
+ /** Elementor's highlight shapes → the closest Animated headline mark. */
1856
+ const HEADLINE_MARKERS: Record<string, "underline" | "circle" | "strike"> = {
1857
+ circle: "circle",
1858
+ curly: "underline",
1859
+ underline: "underline",
1860
+ double: "underline",
1861
+ double_underline: "underline",
1862
+ underline_zigzag: "underline",
1863
+ diagonal: "strike",
1864
+ strikethrough: "strike",
1865
+ x: "strike",
1866
+ };
1867
+
1868
+ /** W-1049: Elementor's Animated Headline → an Animated headline with its mark or rotating words. */
1797
1869
  const animatedHeadline: Widget = (s, ctx, el) => {
1798
- const rotating = (str(s["rotating_text"]) ?? "").split("\n")[0] ?? "";
1799
- const middle =
1800
- str(s["headline_style"]) === "rotate" ? rotating : (str(s["highlighted_text"]) ?? "");
1801
- const text = cleanText(
1802
- [plain(s["before_text"]).text, plain(middle).text, plain(s["after_text"]).text]
1803
- .filter(Boolean)
1804
- .join(" "),
1805
- );
1806
- if (!text) return [];
1807
- ctx.note(
1808
- "approximated",
1809
- el,
1810
- "Animated headlines are shown without their animation (rotating headlines show their first word).",
1811
- );
1870
+ const rotate = str(s["headline_style"]) === "rotate";
1871
+ const words = (str(s["rotating_text"]) ?? "")
1872
+ .split("\n")
1873
+ .map((w) => plain(w).text.slice(0, 120))
1874
+ .filter(Boolean);
1875
+ const highlight = (rotate ? words[0] : plain(s["highlighted_text"]).text)?.slice(0, 120) ?? "";
1876
+ const before = plain(s["before_text"]).text.slice(0, 200);
1877
+ const after = plain(s["after_text"]).text.slice(0, 200);
1878
+ if (!highlight && !before && !after) return [];
1812
1879
  const level = Number(/^h([1-6])$/.exec(str(s["tag"]) ?? "h3")?.[1] ?? 3);
1880
+ if (link(s["link"])) ctx.note("approximated", el, "An animated headline's link was left out.");
1881
+ const marker = HEADLINE_MARKERS[str(s["marker"]) ?? "circle"] ?? "underline";
1813
1882
  return [
1814
1883
  styled(
1815
- node(ctx, "heading", { text: short(text), level, ...href(s["link"], ctx) }),
1884
+ node(ctx, "headline", {
1885
+ level,
1886
+ ...(before ? { before } : {}),
1887
+ highlight: highlight || before || after,
1888
+ ...(after && highlight ? { after } : {}),
1889
+ mark: rotate ? "none" : marker,
1890
+ ...(rotate && words.length > 1
1891
+ ? { rotate: words.slice(1, 11), rotating: true, turns: s["loop"] === "yes" ? 5 : 1 }
1892
+ : {}),
1893
+ }),
1816
1894
  deviceStyles(s, ctx, el, [
1817
1895
  typographyReader("title_typography", "primary"),
1818
1896
  textReader("title_color", "secondary", "alignment"),
@@ -1871,11 +1949,55 @@ const siteLogo: Widget = (s, ctx, el, env) => {
1871
1949
  return [align(n, s["align"], env, "center")];
1872
1950
  };
1873
1951
 
1952
+ /**
1953
+ * W-1018 carousel settings from an Elementor carousel-like widget: arrows and dots from
1954
+ * `navigation`, autoplay and its speed, looping.
1955
+ */
1956
+ function carouselFrom(
1957
+ slides: N[],
1958
+ perView: number,
1959
+ s: Settings,
1960
+ ctx: ImportContext,
1961
+ el: string,
1962
+ ): N[] {
1963
+ if (slides.length === 0) return [];
1964
+ const navigation = str(s["navigation"]) ?? "both";
1965
+ const autoplay = str(s["autoplay"]);
1966
+ if (autoplay !== "yes" && autoplay !== "no")
1967
+ ctx.note(
1968
+ "approximated",
1969
+ el,
1970
+ "Carousels don't play by themselves unless you turn on Play automatically.",
1971
+ );
1972
+ const speed = num(s["autoplay_speed"]);
1973
+ return [
1974
+ node(
1975
+ ctx,
1976
+ "carousel",
1977
+ {
1978
+ perView: Math.min(4, Math.max(1, Math.round(perView))),
1979
+ ...(navigation === "both" || navigation === "arrows" ? { arrows: true } : {}),
1980
+ ...(navigation === "both" || navigation === "dots" ? { dots: true } : {}),
1981
+ ...(autoplay === "yes"
1982
+ ? {
1983
+ autoplay: true,
1984
+ ...(speed ? { interval: Math.min(30, Math.max(3, Math.round(speed / 1000))) } : {}),
1985
+ }
1986
+ : {}),
1987
+ ...(str(s["infinite"]) === "no" ? {} : { loop: true }),
1988
+ },
1989
+ { children: slides },
1990
+ ),
1991
+ ];
1992
+ }
1993
+
1994
+ /** W-1049: Elementor's Slides → a Carousel, one slide per Elementor slide with its content. */
1874
1995
  const slides: Widget = (s, ctx, el) => {
1875
- const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord).slice(0, 20);
1996
+ const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord);
1997
+ if (list.length > 20) ctx.note("skipped", el, "Carousels keep their first 20 slides.");
1876
1998
  const height = slider(s["slides_height"]) ?? { value: 400, unit: "px" as const };
1877
1999
  const out: N[] = [];
1878
- for (const slide of list) {
2000
+ for (const slide of list.slice(0, 20)) {
1879
2001
  const parts: N[] = [];
1880
2002
  const title = plain(slide["heading"]).text;
1881
2003
  if (title) parts.push(node(ctx, "heading", { text: short(title), level: 2 }));
@@ -1898,16 +2020,18 @@ const slides: Widget = (s, ctx, el) => {
1898
2020
  style["backgroundImage"] = bg.url;
1899
2021
  style["backgroundSize"] = "cover";
1900
2022
  }
1901
- out.push(box(ctx, parts, style));
2023
+ out.push(node(ctx, "carousel-slide", {}, { children: [box(ctx, parts, style)] }));
1902
2024
  }
1903
- if (out.length > 0) ctx.note("approximated", el, "Slides are shown stacked, one after another.");
1904
- return out;
2025
+ return carouselFrom(out, 1, s, ctx, el);
1905
2026
  };
1906
2027
 
2028
+ /** W-1049: Elementor's Testimonial Carousel and Reviews → a Carousel of Testimonials. */
1907
2029
  const testimonialCarousel: Widget = (s, ctx, el, env, raw) => {
1908
- const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord).slice(0, 30);
1909
- const out = list.flatMap((slide) =>
1910
- testimonial(
2030
+ const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord);
2031
+ if (list.length > 20) ctx.note("skipped", el, "Carousels keep their first 20 slides.");
2032
+ const out: N[] = [];
2033
+ for (const slide of list.slice(0, 20)) {
2034
+ const quote = testimonial(
1911
2035
  {
1912
2036
  testimonial_content: slide["content"],
1913
2037
  testimonial_name: slide["name"],
@@ -1918,20 +2042,134 @@ const testimonialCarousel: Widget = (s, ctx, el, env, raw) => {
1918
2042
  el,
1919
2043
  env,
1920
2044
  raw,
1921
- ),
2045
+ );
2046
+ if (quote.length > 0) out.push(node(ctx, "carousel-slide", {}, { children: quote }));
2047
+ }
2048
+ return carouselFrom(out, num(s["slides_per_view"]) ?? 1, s, ctx, el);
2049
+ };
2050
+
2051
+ /** Elementor's Countdown time (site time, no zone) as a Countdown target in UTC. */
2052
+ function countdownTarget(value: unknown): string | undefined {
2053
+ const m = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}):(\d{2})/.exec(str(value) ?? "");
2054
+ return m ? `${m[1]}T${m[2]}:${m[3]}Z` : undefined;
2055
+ }
2056
+
2057
+ /** W-1049: Elementor's Countdown (due date) → a live Countdown with its ending action. */
2058
+ const countdown: Widget = (s, ctx, el) => {
2059
+ if (str(s["countdown_type"]) === "evergreen") {
2060
+ ctx.note("skipped", el, "Evergreen countdowns (a timer per visitor) weren't imported.");
2061
+ return [];
2062
+ }
2063
+ const target = countdownTarget(s["due_date"]);
2064
+ if (!target) return [];
2065
+ ctx.note(
2066
+ "approximated",
2067
+ el,
2068
+ "Countdown dates have no time zone in Elementor; they were read as UTC. Check the time.",
1922
2069
  );
1923
- if (out.length > 0)
1924
- ctx.note("approximated", el, "Carousels are shown as a grid of their slides.");
1925
- return out.length > 0
1926
- ? [
1927
- node(
1928
- ctx,
1929
- "grid",
1930
- { columns: Math.min(12, Math.max(1, num(s["slides_per_view"]) ?? 3)) },
1931
- { style: { gap: { value: 20, unit: "px" } }, children: out },
1932
- ),
1933
- ]
1934
- : [];
2070
+ const actions = Array.isArray(s["expire_actions"]) ? s["expire_actions"].map(String) : [];
2071
+ const message = plain(s["message_after_expire"]).text.slice(0, 200);
2072
+ const redirect = href(s["expire_redirect_url"], ctx).href;
2073
+ const expired = actions.includes("hide")
2074
+ ? { expired: "hide" }
2075
+ : redirect
2076
+ ? { expired: "link", expiredHref: redirect, ...(message ? { expiredText: message } : {}) }
2077
+ : message
2078
+ ? { expiredText: message }
2079
+ : {};
2080
+ if (actions.includes("redirect"))
2081
+ ctx.note("approximated", el, "A countdown that redirected now shows a link instead.");
2082
+ return [
2083
+ node(ctx, "countdown", {
2084
+ target,
2085
+ ticking: true,
2086
+ ...(s["show_seconds"] === "" || s["show_seconds"] === "no" ? { hideSeconds: true } : {}),
2087
+ ...expired,
2088
+ }),
2089
+ ];
2090
+ };
2091
+
2092
+ /** Elementor's share buttons → EmVB's Share link services. */
2093
+ const SHARE_FROM_ELEMENTOR: Record<string, string> = {
2094
+ facebook: "facebook",
2095
+ twitter: "x",
2096
+ "x-twitter": "x",
2097
+ linkedin: "linkedin",
2098
+ whatsapp: "whatsapp",
2099
+ telegram: "telegram",
2100
+ reddit: "reddit",
2101
+ threads: "threads",
2102
+ bluesky: "bluesky",
2103
+ email: "email",
2104
+ };
2105
+
2106
+ /** W-1049: Elementor's Share Buttons → Share buttons with the services EmVB has. */
2107
+ const shareButtons: Widget = (s, ctx, el) => {
2108
+ const list = (Array.isArray(s["share_buttons"]) ? s["share_buttons"] : []).filter(isRecord);
2109
+ const networks = list.map((b) => SHARE_FROM_ELEMENTOR[str(b["button"]) ?? ""]);
2110
+ if (networks.some((n) => !n))
2111
+ ctx.note("skipped", el, "Share buttons for services EmVB has no link for were left out.");
2112
+ const links = [...new Set(networks.filter((n): n is string => Boolean(n)))]
2113
+ .slice(0, 12)
2114
+ .map((network) => node(ctx, "share-link", { network }));
2115
+ if (links.length === 0) return [];
2116
+ const shape = str(s["shape"]);
2117
+ return [
2118
+ node(
2119
+ ctx,
2120
+ "share-buttons",
2121
+ {
2122
+ shape: shape === "circle" || shape === "rounded" ? shape : "square",
2123
+ ...(str(s["color_source"]) === "custom" ? {} : { brandColors: true }),
2124
+ },
2125
+ { children: links },
2126
+ ),
2127
+ ];
2128
+ };
2129
+
2130
+ /** One hotspot offset (Elementor's slider in %). */
2131
+ const offset = (value: unknown): number | undefined => {
2132
+ const n = num(isRecord(value) ? value["size"] : value);
2133
+ return n === undefined ? undefined : Math.min(100, Math.max(0, Math.round(n * 100) / 100));
2134
+ };
2135
+
2136
+ /** W-1049: Elementor's Hotspot → Hotspots: its picture and a marker per hotspot, per device. */
2137
+ const hotspotWidget: Widget = (s, ctx, el) => {
2138
+ const img = image(s["image"]);
2139
+ if (!img) return [];
2140
+ ctx.externalImage(img.url);
2141
+ const list = (Array.isArray(s["hotspot"]) ? s["hotspot"] : []).filter(isRecord);
2142
+ if (list.length > 20) ctx.note("skipped", el, "Hotspots keep their first 20 markers.");
2143
+ const markers = list.slice(0, 20).map((spot, i) => {
2144
+ const title = plain(spot["hotspot_label"]).text.slice(0, 120) || `Point ${i + 1}`;
2145
+ const text = plain(spot["hotspot_tooltip_content"]).text.slice(0, 1000);
2146
+ const at = (key: string) => offset(spot[key]);
2147
+ const place: Record<string, number> = {};
2148
+ for (const [prop, key] of [
2149
+ ["xTablet", "hotspot_offset_x_tablet"],
2150
+ ["yTablet", "hotspot_offset_y_tablet"],
2151
+ ["xMobile", "hotspot_offset_x_mobile"],
2152
+ ["yMobile", "hotspot_offset_y_mobile"],
2153
+ ] as const) {
2154
+ const v = at(key);
2155
+ if (v !== undefined) place[prop] = v;
2156
+ }
2157
+ return node(ctx, "hotspot", {
2158
+ title,
2159
+ ...(text ? { text } : {}),
2160
+ x: at("hotspot_offset_x") ?? 50,
2161
+ y: at("hotspot_offset_y") ?? 50,
2162
+ ...place,
2163
+ });
2164
+ });
2165
+ return [
2166
+ node(
2167
+ ctx,
2168
+ "hotspots",
2169
+ { src: img.url, alt: img.alt ?? altFromUrl(img.url) },
2170
+ { children: markers },
2171
+ ),
2172
+ ];
1935
2173
  };
1936
2174
 
1937
2175
  const codeHighlight: Widget = (s, ctx, el) => {
@@ -2007,6 +2245,7 @@ export const WIDGETS: Record<string, Widget> = {
2007
2245
  "mega-menu": megaMenu,
2008
2246
  "call-to-action": callToAction,
2009
2247
  "price-table": priceTable,
2248
+ "price-list": priceList,
2010
2249
  "flip-box": flipBox,
2011
2250
  blockquote,
2012
2251
  "animated-headline": animatedHeadline,
@@ -2046,12 +2285,12 @@ export const WIDGETS: Record<string, Widget> = {
2046
2285
  "theme-site-title": skip("The site title comes from WordPress settings; add it as a Heading."),
2047
2286
  "read-more": skip("WordPress's Read More tag has no EmVB equivalent."),
2048
2287
  sidebar: skip("WordPress sidebars weren't imported."),
2049
- countdown: skip("Countdown timers weren't imported."),
2050
- "share-buttons": skip("Share buttons weren't imported; add Icon links instead."),
2051
- "search-form": skip("Search forms weren't imported."),
2288
+ countdown,
2289
+ "share-buttons": shareButtons,
2290
+ "search-form": searchForm,
2052
2291
  login: skip("Login forms weren't imported."),
2053
2292
  lottie: skip("Lottie animations weren't imported."),
2054
- hotspot: skip("Hotspots weren't imported."),
2293
+ hotspot: hotspotWidget,
2055
2294
  "paypal-button": skip("PayPal buttons weren't imported."),
2056
2295
  "progress-tracker": skip("Reading progress bars weren't imported."),
2057
2296
  posts: skip(LOOPS),