@perkyzz/emvb 1.2.0 → 1.3.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 (36) hide show
  1. package/THIRD_PARTY_NOTICES.md +2 -2
  2. package/package.json +4 -4
  3. package/src/admin/editor/canvas/vnode-react.tsx +3 -0
  4. package/src/admin/editor/dnd/new-element.ts +60 -0
  5. package/src/admin/editor/element-chrome.ts +28 -0
  6. package/src/admin/editor/panels/settings/ItemList.tsx +33 -0
  7. package/src/astro/request-data.ts +6 -0
  8. package/src/astro/resolve.ts +9 -0
  9. package/src/astro/widgets/EmVBCountdownRuntime.astro +8 -0
  10. package/src/astro/widgets/EmVBCounterRuntime.astro +8 -0
  11. package/src/astro/widgets/EmVBHeadlineRuntime.astro +9 -0
  12. package/src/astro/widgets/EmVBMapRuntime.astro +8 -0
  13. package/src/astro/widgets/EmVBShareRuntime.astro +9 -0
  14. package/src/astro/widgets/EmVBWidgetRuntimes.astro +10 -0
  15. package/src/astro/widgets/countdown.ts +80 -0
  16. package/src/astro/widgets/counter.ts +98 -0
  17. package/src/astro/widgets/headline.ts +90 -0
  18. package/src/astro/widgets/map.ts +37 -0
  19. package/src/astro/widgets/share.ts +21 -0
  20. package/src/constants.ts +1 -1
  21. package/src/core/a11y/audit.ts +28 -5
  22. package/src/core/arrange.ts +52 -0
  23. package/src/core/canvas-collections.ts +28 -0
  24. package/src/core/elements/counter-format.ts +15 -0
  25. package/src/core/elements/index.ts +30 -0
  26. package/src/core/elements/marketing.ts +1490 -0
  27. package/src/core/elements/widgets.ts +28 -3
  28. package/src/core/export/runtimes.generated.ts +5 -0
  29. package/src/core/export/site.ts +5 -0
  30. package/src/core/import/elementor/widgets.ts +418 -281
  31. package/src/core/limits.ts +6 -0
  32. package/src/core/render/index.ts +21 -1
  33. package/src/core/render/vnode.ts +1 -1
  34. package/src/core/schema/layout.ts +420 -17
  35. package/src/core/theme/dynamic.ts +2 -0
  36. package/src/server/plugin.ts +2 -1
@@ -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. */
@@ -1119,15 +1083,24 @@ const menuAnchor: Widget = (s, ctx, el) => {
1119
1083
  return [box(ctx, [], {}, { htmlId: anchor, editorLabel: `Anchor ${anchor}`.slice(0, 80) })];
1120
1084
  };
1121
1085
 
1086
+ /** W-1049: Elementor's Google Maps → a Map that loads Google's map when a visitor asks. */
1122
1087
  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.");
1088
+ const address = plain(s["address"]).text.slice(0, 300);
1125
1089
  if (!address) return [];
1090
+ const zoom = num(isRecord(s["zoom"]) ? s["zoom"]["size"] : s["zoom"]);
1091
+ const height = num(isRecord(s["height"]) ? s["height"]["size"] : s["height"]);
1092
+ ctx.note(
1093
+ "approximated",
1094
+ el,
1095
+ "Google Maps load when a visitor presses Show the map, so Google isn't contacted before.",
1096
+ );
1126
1097
  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,
1098
+ node(ctx, "map", {
1099
+ address,
1100
+ provider: "google",
1101
+ embed: true,
1102
+ ...(zoom ? { zoom: Math.min(19, Math.max(1, Math.round(zoom))) } : {}),
1103
+ ...(height ? { height: Math.min(800, Math.max(150, Math.round(height))) } : {}),
1131
1104
  }),
1132
1105
  ];
1133
1106
  };
@@ -1207,35 +1180,7 @@ function carouselWidget(
1207
1180
  img["style"] = { width: { value: 100, unit: "%" }, height: "auto" };
1208
1181
  slides.push(node(ctx, "carousel-slide", {}, { children: [img] }));
1209
1182
  }
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
- ];
1183
+ return carouselFrom(slides, perView, s, ctx, el);
1239
1184
  }
1240
1185
 
1241
1186
  const imageCarousel: Widget = (s, ctx, el) =>
@@ -1630,142 +1575,153 @@ const megaMenu: Widget = (s, ctx, _el, env, raw) => {
1630
1575
  return [node(ctx, "menu", { direction: "row" }, { children })];
1631
1576
  };
1632
1577
 
1578
+ /** W-1049: Elementor's Call to Action → a Call to action: picture, title, text, button, ribbon. */
1633
1579
  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
- };
1580
+ const title = plain(s["title"]).text.slice(0, 200);
1581
+ if (!title) return [];
1582
+ const level = Number(/^h([2-6])$/.exec(str(s["title_tag"]) ?? "h2")?.[1] ?? 2);
1644
1583
  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 }));
1584
+ if (bg) ctx.externalImage(bg.url);
1585
+ const layout = str(s["layout"]);
1586
+ const where =
1587
+ str(s["skin"]) === "cover"
1588
+ ? "behind"
1589
+ : layout === "left"
1590
+ ? "left"
1591
+ : layout === "right"
1592
+ ? "right"
1593
+ : "top";
1594
+ const target = href(s["link"], ctx);
1595
+ const btn = plain(s["button"]).text.slice(0, 80);
1655
1596
  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)] : [];
1597
+ const ribbon = plain(s["ribbon_title"]).text.slice(0, 30);
1598
+ ctx.note("approximated", el, "Call to Action boxes keep their content, not their hover effects.");
1599
+ const fill = colorAt(s, "background_color", ctx);
1600
+ return [
1601
+ node(
1602
+ ctx,
1603
+ "cta",
1604
+ {
1605
+ title,
1606
+ ...(level !== 3 ? { titleLevel: level } : {}),
1607
+ ...(description ? { text: short(description) } : {}),
1608
+ ...(bg ? { src: bg.url, alt: bg.alt ?? "" } : {}),
1609
+ layout: where,
1610
+ ...(btn && target.href ? { buttonText: btn } : {}),
1611
+ ...target,
1612
+ ...(ribbon ? { ribbon } : {}),
1613
+ },
1614
+ fill ? { style: { backgroundColor: fill } } : {},
1615
+ ),
1616
+ ];
1617
+ };
1618
+
1619
+ const CURRENCY_SYMBOLS: Record<string, string> = {
1620
+ dollar: "$",
1621
+ euro: "€",
1622
+ pound: "£",
1623
+ yen: "¥",
1624
+ rupee: "₹",
1625
+ franc: "₣",
1626
+ real: "R$",
1627
+ baht: "฿",
1628
+ krona: "kr",
1629
+ lira: "₺",
1630
+ peseta: "₧",
1631
+ peso: "₱",
1632
+ shekel: "₪",
1633
+ won: "₩",
1634
+ guilder: "ƒ",
1665
1635
  };
1666
1636
 
1637
+ /** W-1049: Elementor's Price Table → a Price table: price, sale price, features, button, ribbon. */
1667
1638
  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 =
1639
+ const title = plain(s["heading"]).text.slice(0, 120);
1640
+ const price = plain(s["price"]).text.slice(0, 20);
1641
+ if (!title && !price) return [];
1642
+ const currency = (
1697
1643
  str(s["currency_symbol"]) === "custom"
1698
1644
  ? 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
- }
1645
+ : (CURRENCY_SYMBOLS[str(s["currency_symbol"]) ?? "dollar"] ?? "")
1646
+ ).slice(0, 5);
1647
+ const regular = s["sale"] === "yes" ? plain(s["original_price"]).text.slice(0, 20) : "";
1712
1648
  const features = (Array.isArray(s["features_list"]) ? s["features_list"] : [])
1713
1649
  .filter(isRecord)
1714
- .map((f) => short(plain(f["item_text"]).text))
1650
+ .map((f) => plain(f["item_text"]).text.slice(0, 200))
1715
1651
  .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);
1652
+ .slice(0, 30);
1653
+ const sub = plain(s["sub_heading"]).text;
1720
1654
  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
- : [];
1655
+ const description = [sub, footer].filter(Boolean).join("\n").slice(0, 500);
1656
+ const target = href(s["link"], ctx);
1657
+ const btn = plain(s["button_text"]).text.slice(0, 80);
1658
+ const ribbon = s["show_ribbon"] === "yes" ? plain(s["ribbon_title"]).text.slice(0, 30) : "";
1659
+ if (footer) ctx.note("approximated", el, "A price table's footer text joined its description.");
1660
+ const level = Number(/^h([2-6])$/.exec(str(s["heading_tag"]) ?? "h3")?.[1] ?? 3);
1661
+ return [
1662
+ node(ctx, "price-table", {
1663
+ title: title || price,
1664
+ ...(level !== 3 ? { titleLevel: level } : {}),
1665
+ ...(description ? { description } : {}),
1666
+ price: price || "0",
1667
+ ...(currency ? { currency } : {}),
1668
+ ...(plain(s["period"]).text ? { period: plain(s["period"]).text.slice(0, 40) } : {}),
1669
+ ...(regular ? { regularPrice: regular } : {}),
1670
+ ...(features.length > 0 ? { features } : {}),
1671
+ ...(btn && target.href ? { buttonText: btn, buttonHref: target.href } : {}),
1672
+ ...(target.newTab && btn ? { newTab: true } : {}),
1673
+ ...(s["show_ribbon"] === "yes" ? { featured: true, ...(ribbon ? { ribbon } : {}) } : {}),
1674
+ }),
1675
+ ];
1676
+ };
1677
+
1678
+ /** W-1049: Elementor's Price List → a Price list, one item per row with its picture and link. */
1679
+ const priceList: Widget = (s, ctx, el) => {
1680
+ const rows = (Array.isArray(s["price_list"]) ? s["price_list"] : []).filter(isRecord);
1681
+ if (rows.length > 50) ctx.note("skipped", el, "Price lists keep their first 50 items.");
1682
+ const items: N[] = [];
1683
+ for (const row of rows.slice(0, 50)) {
1684
+ const title = plain(row["title"]).text.slice(0, 120);
1685
+ if (!title) continue;
1686
+ const img = image(row["image"]);
1687
+ if (img) ctx.externalImage(img.url);
1688
+ const target = href(row["link"], ctx);
1689
+ const description = plain(row["item_description"]).text.slice(0, 500);
1690
+ items.push(
1691
+ node(ctx, "price-list-item", {
1692
+ title,
1693
+ price: plain(row["price"]).text.slice(0, 20),
1694
+ ...(description ? { description } : {}),
1695
+ ...(img ? { src: img.url, ...(img.alt ? { alt: img.alt } : {}) } : {}),
1696
+ ...target,
1697
+ }),
1698
+ );
1699
+ }
1700
+ return items.length > 0 ? [node(ctx, "price-list", {}, { children: items })] : [];
1736
1701
  };
1737
1702
 
1703
+ /** W-1049: Elementor's Flip Box → a Flip box: front and back, its direction and button. */
1738
1704
  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);
1705
+ const frontTitle = plain(s["title_text_a"]).text.slice(0, 200);
1706
+ const backTitle = plain(s["title_text_b"]).text.slice(0, 200);
1707
+ if (!frontTitle && !backTitle) return [];
1708
+ const frontText = plain(s["description_text_a"]).text;
1709
+ const backText = plain(s["description_text_b"]).text;
1710
+ const target = href(s["link"], ctx);
1711
+ const btn = plain(s["button_text"]).text.slice(0, 80);
1712
+ const direction = str(s["flip_direction"]);
1713
+ if (image(s["image"]) || isRecord(s["selected_icon"]))
1714
+ ctx.note("approximated", el, "A flip box's front image or icon was left out.");
1715
+ return [
1716
+ node(ctx, "flip-box", {
1717
+ frontTitle: frontTitle || backTitle,
1718
+ ...(frontText ? { frontText: short(frontText) } : {}),
1719
+ ...(backTitle ? { backTitle } : {}),
1720
+ ...(backText ? { backText: short(backText) } : {}),
1721
+ ...(btn && target.href ? { buttonText: btn, ...target } : {}),
1722
+ ...(direction === "left" || direction === "up" || direction === "down" ? { direction } : {}),
1723
+ }),
1724
+ ];
1769
1725
  };
1770
1726
 
1771
1727
  const blockquote: Widget = (s, ctx) => {
@@ -1794,25 +1750,45 @@ const blockquote: Widget = (s, ctx) => {
1794
1750
  ];
1795
1751
  };
1796
1752
 
1753
+ /** Elementor's highlight shapes → the closest Animated headline mark. */
1754
+ const HEADLINE_MARKERS: Record<string, "underline" | "circle" | "strike"> = {
1755
+ circle: "circle",
1756
+ curly: "underline",
1757
+ underline: "underline",
1758
+ double: "underline",
1759
+ double_underline: "underline",
1760
+ underline_zigzag: "underline",
1761
+ diagonal: "strike",
1762
+ strikethrough: "strike",
1763
+ x: "strike",
1764
+ };
1765
+
1766
+ /** W-1049: Elementor's Animated Headline → an Animated headline with its mark or rotating words. */
1797
1767
  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
- );
1768
+ const rotate = str(s["headline_style"]) === "rotate";
1769
+ const words = (str(s["rotating_text"]) ?? "")
1770
+ .split("\n")
1771
+ .map((w) => plain(w).text.slice(0, 120))
1772
+ .filter(Boolean);
1773
+ const highlight = (rotate ? words[0] : plain(s["highlighted_text"]).text)?.slice(0, 120) ?? "";
1774
+ const before = plain(s["before_text"]).text.slice(0, 200);
1775
+ const after = plain(s["after_text"]).text.slice(0, 200);
1776
+ if (!highlight && !before && !after) return [];
1812
1777
  const level = Number(/^h([1-6])$/.exec(str(s["tag"]) ?? "h3")?.[1] ?? 3);
1778
+ if (link(s["link"])) ctx.note("approximated", el, "An animated headline's link was left out.");
1779
+ const marker = HEADLINE_MARKERS[str(s["marker"]) ?? "circle"] ?? "underline";
1813
1780
  return [
1814
1781
  styled(
1815
- node(ctx, "heading", { text: short(text), level, ...href(s["link"], ctx) }),
1782
+ node(ctx, "headline", {
1783
+ level,
1784
+ ...(before ? { before } : {}),
1785
+ highlight: highlight || before || after,
1786
+ ...(after && highlight ? { after } : {}),
1787
+ mark: rotate ? "none" : marker,
1788
+ ...(rotate && words.length > 1
1789
+ ? { rotate: words.slice(1, 11), rotating: true, turns: s["loop"] === "yes" ? 5 : 1 }
1790
+ : {}),
1791
+ }),
1816
1792
  deviceStyles(s, ctx, el, [
1817
1793
  typographyReader("title_typography", "primary"),
1818
1794
  textReader("title_color", "secondary", "alignment"),
@@ -1871,11 +1847,55 @@ const siteLogo: Widget = (s, ctx, el, env) => {
1871
1847
  return [align(n, s["align"], env, "center")];
1872
1848
  };
1873
1849
 
1850
+ /**
1851
+ * W-1018 carousel settings from an Elementor carousel-like widget: arrows and dots from
1852
+ * `navigation`, autoplay and its speed, looping.
1853
+ */
1854
+ function carouselFrom(
1855
+ slides: N[],
1856
+ perView: number,
1857
+ s: Settings,
1858
+ ctx: ImportContext,
1859
+ el: string,
1860
+ ): N[] {
1861
+ if (slides.length === 0) return [];
1862
+ const navigation = str(s["navigation"]) ?? "both";
1863
+ const autoplay = str(s["autoplay"]);
1864
+ if (autoplay !== "yes" && autoplay !== "no")
1865
+ ctx.note(
1866
+ "approximated",
1867
+ el,
1868
+ "Carousels don't play by themselves unless you turn on Play automatically.",
1869
+ );
1870
+ const speed = num(s["autoplay_speed"]);
1871
+ return [
1872
+ node(
1873
+ ctx,
1874
+ "carousel",
1875
+ {
1876
+ perView: Math.min(4, Math.max(1, Math.round(perView))),
1877
+ ...(navigation === "both" || navigation === "arrows" ? { arrows: true } : {}),
1878
+ ...(navigation === "both" || navigation === "dots" ? { dots: true } : {}),
1879
+ ...(autoplay === "yes"
1880
+ ? {
1881
+ autoplay: true,
1882
+ ...(speed ? { interval: Math.min(30, Math.max(3, Math.round(speed / 1000))) } : {}),
1883
+ }
1884
+ : {}),
1885
+ ...(str(s["infinite"]) === "no" ? {} : { loop: true }),
1886
+ },
1887
+ { children: slides },
1888
+ ),
1889
+ ];
1890
+ }
1891
+
1892
+ /** W-1049: Elementor's Slides → a Carousel, one slide per Elementor slide with its content. */
1874
1893
  const slides: Widget = (s, ctx, el) => {
1875
- const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord).slice(0, 20);
1894
+ const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord);
1895
+ if (list.length > 20) ctx.note("skipped", el, "Carousels keep their first 20 slides.");
1876
1896
  const height = slider(s["slides_height"]) ?? { value: 400, unit: "px" as const };
1877
1897
  const out: N[] = [];
1878
- for (const slide of list) {
1898
+ for (const slide of list.slice(0, 20)) {
1879
1899
  const parts: N[] = [];
1880
1900
  const title = plain(slide["heading"]).text;
1881
1901
  if (title) parts.push(node(ctx, "heading", { text: short(title), level: 2 }));
@@ -1898,16 +1918,18 @@ const slides: Widget = (s, ctx, el) => {
1898
1918
  style["backgroundImage"] = bg.url;
1899
1919
  style["backgroundSize"] = "cover";
1900
1920
  }
1901
- out.push(box(ctx, parts, style));
1921
+ out.push(node(ctx, "carousel-slide", {}, { children: [box(ctx, parts, style)] }));
1902
1922
  }
1903
- if (out.length > 0) ctx.note("approximated", el, "Slides are shown stacked, one after another.");
1904
- return out;
1923
+ return carouselFrom(out, 1, s, ctx, el);
1905
1924
  };
1906
1925
 
1926
+ /** W-1049: Elementor's Testimonial Carousel and Reviews → a Carousel of Testimonials. */
1907
1927
  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(
1928
+ const list = (Array.isArray(s["slides"]) ? s["slides"] : []).filter(isRecord);
1929
+ if (list.length > 20) ctx.note("skipped", el, "Carousels keep their first 20 slides.");
1930
+ const out: N[] = [];
1931
+ for (const slide of list.slice(0, 20)) {
1932
+ const quote = testimonial(
1911
1933
  {
1912
1934
  testimonial_content: slide["content"],
1913
1935
  testimonial_name: slide["name"],
@@ -1918,20 +1940,134 @@ const testimonialCarousel: Widget = (s, ctx, el, env, raw) => {
1918
1940
  el,
1919
1941
  env,
1920
1942
  raw,
1921
- ),
1943
+ );
1944
+ if (quote.length > 0) out.push(node(ctx, "carousel-slide", {}, { children: quote }));
1945
+ }
1946
+ return carouselFrom(out, num(s["slides_per_view"]) ?? 1, s, ctx, el);
1947
+ };
1948
+
1949
+ /** Elementor's Countdown time (site time, no zone) as a Countdown target in UTC. */
1950
+ function countdownTarget(value: unknown): string | undefined {
1951
+ const m = /^(\d{4}-\d{2}-\d{2})[ T](\d{2}):(\d{2})/.exec(str(value) ?? "");
1952
+ return m ? `${m[1]}T${m[2]}:${m[3]}Z` : undefined;
1953
+ }
1954
+
1955
+ /** W-1049: Elementor's Countdown (due date) → a live Countdown with its ending action. */
1956
+ const countdown: Widget = (s, ctx, el) => {
1957
+ if (str(s["countdown_type"]) === "evergreen") {
1958
+ ctx.note("skipped", el, "Evergreen countdowns (a timer per visitor) weren't imported.");
1959
+ return [];
1960
+ }
1961
+ const target = countdownTarget(s["due_date"]);
1962
+ if (!target) return [];
1963
+ ctx.note(
1964
+ "approximated",
1965
+ el,
1966
+ "Countdown dates have no time zone in Elementor; they were read as UTC. Check the time.",
1922
1967
  );
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
- : [];
1968
+ const actions = Array.isArray(s["expire_actions"]) ? s["expire_actions"].map(String) : [];
1969
+ const message = plain(s["message_after_expire"]).text.slice(0, 200);
1970
+ const redirect = href(s["expire_redirect_url"], ctx).href;
1971
+ const expired = actions.includes("hide")
1972
+ ? { expired: "hide" }
1973
+ : redirect
1974
+ ? { expired: "link", expiredHref: redirect, ...(message ? { expiredText: message } : {}) }
1975
+ : message
1976
+ ? { expiredText: message }
1977
+ : {};
1978
+ if (actions.includes("redirect"))
1979
+ ctx.note("approximated", el, "A countdown that redirected now shows a link instead.");
1980
+ return [
1981
+ node(ctx, "countdown", {
1982
+ target,
1983
+ ticking: true,
1984
+ ...(s["show_seconds"] === "" || s["show_seconds"] === "no" ? { hideSeconds: true } : {}),
1985
+ ...expired,
1986
+ }),
1987
+ ];
1988
+ };
1989
+
1990
+ /** Elementor's share buttons → EmVB's Share link services. */
1991
+ const SHARE_FROM_ELEMENTOR: Record<string, string> = {
1992
+ facebook: "facebook",
1993
+ twitter: "x",
1994
+ "x-twitter": "x",
1995
+ linkedin: "linkedin",
1996
+ whatsapp: "whatsapp",
1997
+ telegram: "telegram",
1998
+ reddit: "reddit",
1999
+ threads: "threads",
2000
+ bluesky: "bluesky",
2001
+ email: "email",
2002
+ };
2003
+
2004
+ /** W-1049: Elementor's Share Buttons → Share buttons with the services EmVB has. */
2005
+ const shareButtons: Widget = (s, ctx, el) => {
2006
+ const list = (Array.isArray(s["share_buttons"]) ? s["share_buttons"] : []).filter(isRecord);
2007
+ const networks = list.map((b) => SHARE_FROM_ELEMENTOR[str(b["button"]) ?? ""]);
2008
+ if (networks.some((n) => !n))
2009
+ ctx.note("skipped", el, "Share buttons for services EmVB has no link for were left out.");
2010
+ const links = [...new Set(networks.filter((n): n is string => Boolean(n)))]
2011
+ .slice(0, 12)
2012
+ .map((network) => node(ctx, "share-link", { network }));
2013
+ if (links.length === 0) return [];
2014
+ const shape = str(s["shape"]);
2015
+ return [
2016
+ node(
2017
+ ctx,
2018
+ "share-buttons",
2019
+ {
2020
+ shape: shape === "circle" || shape === "rounded" ? shape : "square",
2021
+ ...(str(s["color_source"]) === "custom" ? {} : { brandColors: true }),
2022
+ },
2023
+ { children: links },
2024
+ ),
2025
+ ];
2026
+ };
2027
+
2028
+ /** One hotspot offset (Elementor's slider in %). */
2029
+ const offset = (value: unknown): number | undefined => {
2030
+ const n = num(isRecord(value) ? value["size"] : value);
2031
+ return n === undefined ? undefined : Math.min(100, Math.max(0, Math.round(n * 100) / 100));
2032
+ };
2033
+
2034
+ /** W-1049: Elementor's Hotspot → Hotspots: its picture and a marker per hotspot, per device. */
2035
+ const hotspotWidget: Widget = (s, ctx, el) => {
2036
+ const img = image(s["image"]);
2037
+ if (!img) return [];
2038
+ ctx.externalImage(img.url);
2039
+ const list = (Array.isArray(s["hotspot"]) ? s["hotspot"] : []).filter(isRecord);
2040
+ if (list.length > 20) ctx.note("skipped", el, "Hotspots keep their first 20 markers.");
2041
+ const markers = list.slice(0, 20).map((spot, i) => {
2042
+ const title = plain(spot["hotspot_label"]).text.slice(0, 120) || `Point ${i + 1}`;
2043
+ const text = plain(spot["hotspot_tooltip_content"]).text.slice(0, 1000);
2044
+ const at = (key: string) => offset(spot[key]);
2045
+ const place: Record<string, number> = {};
2046
+ for (const [prop, key] of [
2047
+ ["xTablet", "hotspot_offset_x_tablet"],
2048
+ ["yTablet", "hotspot_offset_y_tablet"],
2049
+ ["xMobile", "hotspot_offset_x_mobile"],
2050
+ ["yMobile", "hotspot_offset_y_mobile"],
2051
+ ] as const) {
2052
+ const v = at(key);
2053
+ if (v !== undefined) place[prop] = v;
2054
+ }
2055
+ return node(ctx, "hotspot", {
2056
+ title,
2057
+ ...(text ? { text } : {}),
2058
+ x: at("hotspot_offset_x") ?? 50,
2059
+ y: at("hotspot_offset_y") ?? 50,
2060
+ ...place,
2061
+ });
2062
+ });
2063
+ return [
2064
+ node(
2065
+ ctx,
2066
+ "hotspots",
2067
+ { src: img.url, alt: img.alt ?? altFromUrl(img.url) },
2068
+ { children: markers },
2069
+ ),
2070
+ ];
1935
2071
  };
1936
2072
 
1937
2073
  const codeHighlight: Widget = (s, ctx, el) => {
@@ -2007,6 +2143,7 @@ export const WIDGETS: Record<string, Widget> = {
2007
2143
  "mega-menu": megaMenu,
2008
2144
  "call-to-action": callToAction,
2009
2145
  "price-table": priceTable,
2146
+ "price-list": priceList,
2010
2147
  "flip-box": flipBox,
2011
2148
  blockquote,
2012
2149
  "animated-headline": animatedHeadline,
@@ -2046,12 +2183,12 @@ export const WIDGETS: Record<string, Widget> = {
2046
2183
  "theme-site-title": skip("The site title comes from WordPress settings; add it as a Heading."),
2047
2184
  "read-more": skip("WordPress's Read More tag has no EmVB equivalent."),
2048
2185
  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."),
2186
+ countdown,
2187
+ "share-buttons": shareButtons,
2051
2188
  "search-form": skip("Search forms weren't imported."),
2052
2189
  login: skip("Login forms weren't imported."),
2053
2190
  lottie: skip("Lottie animations weren't imported."),
2054
- hotspot: skip("Hotspots weren't imported."),
2191
+ hotspot: hotspotWidget,
2055
2192
  "paypal-button": skip("PayPal buttons weren't imported."),
2056
2193
  "progress-tracker": skip("Reading progress bars weren't imported."),
2057
2194
  posts: skip(LOOPS),