@usethrottle/builder-react 0.4.2 → 0.5.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/CLAUDE.md +23 -2
- package/dist/{chunk-SYXZO5H2.js → chunk-G6I4RIXU.js} +2109 -332
- package/dist/{chunk-XHTZWZPN.cjs → chunk-UNL4JWZS.cjs} +2003 -226
- package/dist/index.cjs +2301 -605
- package/dist/index.d.cts +245 -62
- package/dist/index.d.ts +245 -62
- package/dist/index.js +2264 -567
- package/dist/next.cjs +383 -13
- package/dist/next.d.cts +92 -3
- package/dist/next.d.ts +92 -3
- package/dist/next.js +385 -15
- package/dist/{seo-CNZ9DrlU.d.cts → seo-iX2POfOp.d.cts} +87 -2
- package/dist/{seo-CNZ9DrlU.d.ts → seo-iX2POfOp.d.ts} +87 -2
- package/dist/server.cjs +191 -24
- package/dist/server.d.cts +172 -8
- package/dist/server.d.ts +172 -8
- package/dist/server.js +174 -7
- package/package.json +4 -4
|
@@ -2,6 +2,76 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
|
|
5
|
+
// src/server/jsonld.ts
|
|
6
|
+
var CONTEXT = "https://schema.org";
|
|
7
|
+
var isHttp = (value) => typeof value === "string" && /^https?:\/\/[^\s]+$/iu.test(value);
|
|
8
|
+
function organizationJsonLd(input) {
|
|
9
|
+
const sameAs = (input.sameAs ?? []).filter(isHttp).slice(0, 10);
|
|
10
|
+
return {
|
|
11
|
+
"@context": CONTEXT,
|
|
12
|
+
"@type": "Organization",
|
|
13
|
+
name: input.name,
|
|
14
|
+
url: input.url,
|
|
15
|
+
...isHttp(input.logo) ? { logo: input.logo } : {},
|
|
16
|
+
...sameAs.length === 0 ? {} : { sameAs }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function webSiteJsonLd(input) {
|
|
20
|
+
const base = input.url.replace(/\/+$/u, "");
|
|
21
|
+
return {
|
|
22
|
+
"@context": CONTEXT,
|
|
23
|
+
"@type": "WebSite",
|
|
24
|
+
name: input.name,
|
|
25
|
+
url: input.url,
|
|
26
|
+
potentialAction: {
|
|
27
|
+
"@type": "SearchAction",
|
|
28
|
+
target: {
|
|
29
|
+
"@type": "EntryPoint",
|
|
30
|
+
urlTemplate: `${base}${input.searchPath ?? "/search"}?q={search_term_string}`
|
|
31
|
+
},
|
|
32
|
+
"query-input": "required name=search_term_string"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function breadcrumbJsonLd(items) {
|
|
37
|
+
return {
|
|
38
|
+
"@context": CONTEXT,
|
|
39
|
+
"@type": "BreadcrumbList",
|
|
40
|
+
itemListElement: items.map((item, index) => ({
|
|
41
|
+
"@type": "ListItem",
|
|
42
|
+
position: index + 1,
|
|
43
|
+
name: item.name,
|
|
44
|
+
item: item.url
|
|
45
|
+
}))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function faqJsonLd(items) {
|
|
49
|
+
return {
|
|
50
|
+
"@context": CONTEXT,
|
|
51
|
+
"@type": "FAQPage",
|
|
52
|
+
mainEntity: items.map((item) => ({
|
|
53
|
+
"@type": "Question",
|
|
54
|
+
name: item.question,
|
|
55
|
+
acceptedAnswer: { "@type": "Answer", text: item.answer }
|
|
56
|
+
}))
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function localBusinessJsonLd(input) {
|
|
60
|
+
const hours = (input.openingHours ?? []).filter((line) => line !== "");
|
|
61
|
+
return {
|
|
62
|
+
"@context": CONTEXT,
|
|
63
|
+
"@type": input.type ?? "LocalBusiness",
|
|
64
|
+
name: input.name,
|
|
65
|
+
url: input.url,
|
|
66
|
+
address: input.address,
|
|
67
|
+
...input.phone === void 0 || input.phone === "" ? {} : { telephone: input.phone },
|
|
68
|
+
...hours.length === 0 ? {} : { openingHours: hours }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function jsonLdString(value) {
|
|
72
|
+
return JSON.stringify(value).replaceAll("<", "\\u003c");
|
|
73
|
+
}
|
|
74
|
+
|
|
5
75
|
// src/data.ts
|
|
6
76
|
import { walkNodes } from "@usethrottle/builder-schema";
|
|
7
77
|
|
|
@@ -75,7 +145,7 @@ async function resolveBindings(bindings, registry, ctx, options) {
|
|
|
75
145
|
import { ANCHOR_RE as ANCHOR_RE2, anyCustomWidgetSnapshotSchema, sectionNodeSchema, walkNodes as walkNodes2 } from "@usethrottle/builder-schema";
|
|
76
146
|
|
|
77
147
|
// src/node-wrapper.tsx
|
|
78
|
-
import { ANCHOR_RE } from "@usethrottle/builder-schema";
|
|
148
|
+
import { ANCHOR_RE, cssClassSchema } from "@usethrottle/builder-schema";
|
|
79
149
|
import { jsx } from "react/jsx-runtime";
|
|
80
150
|
var CUSTOM_WIDGET_CONTAINMENT = {
|
|
81
151
|
contain: "layout paint",
|
|
@@ -88,12 +158,14 @@ var PART_NAME = {
|
|
|
88
158
|
widget: "builder-widget"
|
|
89
159
|
};
|
|
90
160
|
function NodeWrapper(props) {
|
|
91
|
-
const { id, part, type,
|
|
161
|
+
const { id, part: part2, type, anchor, copyAnchor, custom, missing, attributes, edit, entrance, children } = props;
|
|
92
162
|
const Tag = props.as ?? "div";
|
|
163
|
+
const tokens = props.cssClass !== void 0 && cssClassSchema.safeParse(props.cssClass).success ? props.cssClass : [];
|
|
164
|
+
const className = tokens.length === 0 ? props.className : `${props.className} ${tokens.join(" ")}`;
|
|
93
165
|
const handlers = edit === void 0 ? {} : {
|
|
94
166
|
onClickCapture: (event) => {
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
167
|
+
const target2 = event.target;
|
|
168
|
+
if (target2?.closest?.("a[href]") != null) event.preventDefault();
|
|
97
169
|
},
|
|
98
170
|
onClick: (event) => {
|
|
99
171
|
event.stopPropagation();
|
|
@@ -114,7 +186,7 @@ function NodeWrapper(props) {
|
|
|
114
186
|
{
|
|
115
187
|
className,
|
|
116
188
|
"data-b-id": id,
|
|
117
|
-
"data-throttle-part": PART_NAME[
|
|
189
|
+
"data-throttle-part": PART_NAME[part2],
|
|
118
190
|
...type === void 0 ? {} : { "data-b-type": type },
|
|
119
191
|
...custom === true && type !== void 0 ? { "data-b-w": type } : {},
|
|
120
192
|
...missing === true ? { "data-b-missing": "" } : {},
|
|
@@ -243,10 +315,10 @@ function MissingSavedSection({ node }) {
|
|
|
243
315
|
|
|
244
316
|
// src/load.ts
|
|
245
317
|
function pageOf(raw, initialData) {
|
|
246
|
-
const { document: document2, id: _id, slug, title, path, generation, pageType: _type, updatedAt: _updated, savedSections, code, ...meta } = raw;
|
|
318
|
+
const { document: document2, id: _id, slug: slug2, title, path, generation, pageType: _type, updatedAt: _updated, savedSections, code, ...meta } = raw;
|
|
247
319
|
return {
|
|
248
320
|
kind: "page",
|
|
249
|
-
slug,
|
|
321
|
+
slug: slug2,
|
|
250
322
|
title,
|
|
251
323
|
path,
|
|
252
324
|
generation,
|
|
@@ -340,7 +412,7 @@ function clientOf(options) {
|
|
|
340
412
|
import { createRegistry } from "@usethrottle/builder-schema";
|
|
341
413
|
|
|
342
414
|
// src/basics/index.ts
|
|
343
|
-
import { BASIC_WIDGET_DEFINITIONS as
|
|
415
|
+
import { BASIC_WIDGET_DEFINITIONS as BASIC_WIDGET_DEFINITIONS3 } from "@usethrottle/builder-schema";
|
|
344
416
|
|
|
345
417
|
// src/basics/announcement.tsx
|
|
346
418
|
import { useEffect, useState } from "react";
|
|
@@ -432,7 +504,7 @@ function Placeholder({ editMode, children }) {
|
|
|
432
504
|
var ID_RE = /^[a-z0-9]{8,24}(-[a-z0-9]{8,24})?$/;
|
|
433
505
|
var DEVICES = ["desktop", "tablet", "phone"];
|
|
434
506
|
function defaultOf(type, key) {
|
|
435
|
-
const def = BASIC_WIDGET_DEFINITIONS.
|
|
507
|
+
const def = BASIC_WIDGET_DEFINITIONS.filter((d) => d.type === type).sort((a, b) => b.v - a.v)[0];
|
|
436
508
|
return def?.settings.find((f) => f.key === key)?.default ?? null;
|
|
437
509
|
}
|
|
438
510
|
function enumCss(node, rules) {
|
|
@@ -586,8 +658,8 @@ var seen2 = /* @__PURE__ */ new WeakSet();
|
|
|
586
658
|
var autoplay = /* @__PURE__ */ new Map();
|
|
587
659
|
var all = (selector) => Array.from(document.querySelectorAll(selector));
|
|
588
660
|
var reduced = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
|
|
589
|
-
function selectTab(
|
|
590
|
-
const tabs = Array.from(
|
|
661
|
+
function selectTab(list2, index, focus = false) {
|
|
662
|
+
const tabs = Array.from(list2.querySelectorAll("[role=tab]"));
|
|
591
663
|
tabs.forEach((tab, i) => {
|
|
592
664
|
const on = i === index;
|
|
593
665
|
tab.setAttribute("aria-selected", String(on));
|
|
@@ -661,7 +733,7 @@ function scan() {
|
|
|
661
733
|
});
|
|
662
734
|
document.documentElement.setAttribute("data-b-js", "");
|
|
663
735
|
const fresh = (selector) => all(selector).filter((el) => !seen2.has(el) && seen2.add(el));
|
|
664
|
-
fresh("[data-b-tabs]").forEach((
|
|
736
|
+
fresh("[data-b-tabs]").forEach((list2) => selectTab(list2, 0));
|
|
665
737
|
fresh("[data-b-car]").forEach((root) => setupCarousel(root));
|
|
666
738
|
const counts = fresh("[data-b-cd]");
|
|
667
739
|
counts.forEach((el) => tick(el, true));
|
|
@@ -695,30 +767,30 @@ var decoded = (hash) => {
|
|
|
695
767
|
};
|
|
696
768
|
var onHash = () => void goAnchor(decoded(location.hash));
|
|
697
769
|
function onClick(event) {
|
|
698
|
-
const
|
|
699
|
-
const href =
|
|
770
|
+
const target2 = event.target;
|
|
771
|
+
const href = target2?.closest('a[href^="#"]')?.getAttribute("href");
|
|
700
772
|
if (href && !event.defaultPrevented && !event.button && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) && goAnchor(decoded(href))) {
|
|
701
773
|
event.preventDefault();
|
|
702
774
|
history.pushState(null, "", href);
|
|
703
775
|
}
|
|
704
|
-
const tab =
|
|
705
|
-
const
|
|
706
|
-
if (tab &&
|
|
707
|
-
const button =
|
|
776
|
+
const tab = target2?.closest("[role=tab]");
|
|
777
|
+
const list2 = tab?.closest("[data-b-tabs]");
|
|
778
|
+
if (tab && list2) return selectTab(list2, Array.from(list2.querySelectorAll("[role=tab]")).indexOf(tab));
|
|
779
|
+
const button = target2?.closest("[data-b-act]");
|
|
708
780
|
const act = button?.getAttribute("data-b-act");
|
|
709
781
|
const root = button?.closest("[data-b-car]");
|
|
710
782
|
if (root && (act === "prev" || act === "next")) slideTo(root, act === "next" ? 1 : -1);
|
|
711
783
|
}
|
|
712
784
|
function onKey(event) {
|
|
713
785
|
const tab = event.target?.closest("[role=tab]");
|
|
714
|
-
const
|
|
715
|
-
if (!tab || !
|
|
716
|
-
const count =
|
|
717
|
-
const at = Array.from(
|
|
786
|
+
const list2 = tab?.closest("[data-b-tabs]");
|
|
787
|
+
if (!tab || !list2) return;
|
|
788
|
+
const count = list2.querySelectorAll("[role=tab]").length;
|
|
789
|
+
const at = Array.from(list2.querySelectorAll("[role=tab]")).indexOf(tab);
|
|
718
790
|
const to = event.key === "ArrowRight" ? (at + 1) % count : event.key === "ArrowLeft" ? (at + count - 1) % count : event.key === "Home" ? 0 : event.key === "End" ? count - 1 : -1;
|
|
719
791
|
if (to < 0) return;
|
|
720
792
|
event.preventDefault();
|
|
721
|
-
selectTab(
|
|
793
|
+
selectTab(list2, to, true);
|
|
722
794
|
}
|
|
723
795
|
function startRuntime() {
|
|
724
796
|
if (typeof document === "undefined") return () => void 0;
|
|
@@ -800,8 +872,8 @@ function targetText(date) {
|
|
|
800
872
|
}
|
|
801
873
|
function Countdown({ props, editMode, interactive, locale }) {
|
|
802
874
|
void locale;
|
|
803
|
-
const
|
|
804
|
-
const when =
|
|
875
|
+
const target2 = str(props.target);
|
|
876
|
+
const when = target2 === void 0 ? null : new Date(target2);
|
|
805
877
|
if (when === null || Number.isNaN(when.getTime())) {
|
|
806
878
|
return /* @__PURE__ */ jsx8(Placeholder, { editMode, children: "Set the date and time the countdown ends" });
|
|
807
879
|
}
|
|
@@ -857,14 +929,87 @@ function Divider({ node }) {
|
|
|
857
929
|
] });
|
|
858
930
|
}
|
|
859
931
|
|
|
860
|
-
// src/basics/
|
|
932
|
+
// src/basics/v2/styles.tsx
|
|
861
933
|
import { Fragment as Fragment6, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
934
|
+
var BASICS_V2_CSS = `@layer throttle{
|
|
935
|
+
.tb-b-faq{color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.6}
|
|
936
|
+
.tb-b-faq-item{border-block-end:1px solid var(--tb-color-border,currentColor)}
|
|
937
|
+
.tb-b-faq-q{margin:0;padding:var(--tb-space-s) 0;font-weight:600;cursor:pointer}
|
|
938
|
+
h3.tb-b-faq-q{cursor:auto;font-size:inherit}
|
|
939
|
+
.tb-b-faq-a{padding-block-end:var(--tb-space-s)}
|
|
940
|
+
.tb-b-faq-a>:first-child{margin-block-start:0}
|
|
941
|
+
.tb-b-faq-all{margin-block-end:var(--tb-space-s);padding:.4rem .9rem;border:1px solid var(--tb-color-border-control,currentColor);border-radius:var(--throttle-radius,8px);background:transparent;color:inherit;font:inherit;cursor:pointer}
|
|
942
|
+
.tb-b-faq summary:focus-visible,.tb-b-faq-all:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
943
|
+
.tb-b-rich{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.7;overflow-wrap:anywhere}
|
|
944
|
+
.tb-b-rich>:first-child{margin-block-start:0}
|
|
945
|
+
.tb-b-rich h1,.tb-b-rich h2,.tb-b-rich h3,.tb-b-rich h4,.tb-b-rich h5,.tb-b-rich h6{font-family:var(--throttle-font-family-heading,inherit);line-height:1.25;scroll-margin-block-start:var(--tb-space-l)}
|
|
946
|
+
.tb-b-rich table{border-collapse:collapse;max-inline-size:100%;display:block;overflow-x:auto}
|
|
947
|
+
.tb-b-rich th,.tb-b-rich td{padding:var(--tb-space-xs) var(--tb-space-s);border:1px solid var(--tb-color-border,currentColor);text-align:start}
|
|
948
|
+
.tb-b-rich figure{margin-inline:0}
|
|
949
|
+
.tb-b-rich img{max-inline-size:100%;block-size:auto}
|
|
950
|
+
.tb-b-rich pre{overflow-x:auto;padding:var(--tb-space-s);background:var(--tb-color-muted,#eee)}
|
|
951
|
+
.tb-b-rich code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}
|
|
952
|
+
.tb-b-rich blockquote{margin-inline:0;padding-inline-start:var(--tb-space-m);border-inline-start:3px solid var(--tb-color-border,currentColor)}
|
|
953
|
+
.tb-b-toc{margin-block-end:var(--tb-space-m);padding:var(--tb-space-s) var(--tb-space-m);border:1px solid var(--tb-color-border,currentColor);border-radius:var(--throttle-radius,8px)}
|
|
954
|
+
.tb-b-toc-title{margin:0 0 var(--tb-space-xs);font-weight:600}
|
|
955
|
+
.tb-b-toc ol{margin:0;padding:0;list-style:none}
|
|
956
|
+
.tb-b-toc-l3{padding-inline-start:var(--tb-space-m)}
|
|
957
|
+
.tb-b-toc a{color:inherit}
|
|
958
|
+
.tb-b-svg{display:block;text-align:var(--b-align,left);color:var(--b-color,inherit);line-height:0}
|
|
959
|
+
.tb-b-svg>svg,.tb-b-svg>img{display:inline-block;max-inline-size:100%;block-size:auto;inline-size:calc(var(--b-width)*1px)}
|
|
960
|
+
.tb-b-icons{margin:0;padding:0;list-style:none;color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.5}
|
|
961
|
+
.tb-b-icons li{display:flex;gap:var(--tb-space-s);align-items:flex-start;padding-block:var(--tb-space-xs)}
|
|
962
|
+
.tb-b-icons-icon{flex:0 0 auto;display:inline-flex;color:var(--b-iconColor,var(--tb-color-primary,currentColor))}
|
|
963
|
+
.tb-b-icons-icon svg,.tb-b-icons-icon img{inline-size:calc(var(--b-iconSize,20)*1px);block-size:calc(var(--b-iconSize,20)*1px)}
|
|
964
|
+
.tb-b-quote{margin:0;text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l))}
|
|
965
|
+
.tb-b-quote blockquote{margin:0;font-family:var(--throttle-font-family-heading,inherit);line-height:1.4}
|
|
966
|
+
.tb-b-quote figcaption{display:flex;align-items:center;gap:var(--tb-space-s);margin-block-start:var(--tb-space-s);font-size:var(--tb-text-s)}
|
|
967
|
+
.tb-b-quote-photo{inline-size:48px;block-size:48px;border-radius:50%;object-fit:cover}
|
|
968
|
+
.tb-b-quote-by{display:flex;flex-direction:column}
|
|
969
|
+
.tb-b-quote-name{font-weight:600}
|
|
970
|
+
.tb-b-quote-role{color:var(--tb-color-muted-foreground,inherit)}
|
|
971
|
+
.tb-b-heading-wrap{text-align:var(--b-align,left)}
|
|
972
|
+
.tb-b-kicker{display:flex;align-items:center;gap:var(--tb-space-s);margin:0 0 var(--tb-space-xs);justify-content:var(--b-align,flex-start);font-size:var(--tb-text-s);letter-spacing:.08em;text-transform:uppercase;color:var(--b-color,var(--tb-color-muted-foreground,inherit))}
|
|
973
|
+
.tb-b-kicker-rule{flex:0 0 auto;inline-size:2rem;block-size:1px;background:currentColor}
|
|
974
|
+
.tb-b-crumbs{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-s))}
|
|
975
|
+
.tb-b-crumbs ol{display:flex;flex-wrap:wrap;gap:var(--tb-space-xs);margin:0;padding:0;list-style:none}
|
|
976
|
+
.tb-b-crumbs li{display:inline-flex;align-items:center;gap:var(--tb-space-xs)}
|
|
977
|
+
.tb-b-crumbs a{color:inherit;text-decoration:none}
|
|
978
|
+
.tb-b-crumbs a:hover{text-decoration:underline}
|
|
979
|
+
.tb-b-crumbs a:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
980
|
+
.tb-b-crumbs [aria-current]{font-weight:600}
|
|
981
|
+
}`;
|
|
982
|
+
function BasicV2Styles() {
|
|
983
|
+
return /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
984
|
+
/* @__PURE__ */ jsx11(BasicStyles, {}),
|
|
985
|
+
/* @__PURE__ */ jsx11("style", { href: "tb-basics-v2", precedence: "throttle", children: BASICS_V2_CSS })
|
|
986
|
+
] });
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// src/basics/heading.tsx
|
|
990
|
+
import { Fragment as Fragment7, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
862
991
|
var LEVELS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
863
992
|
function Heading({ props, inlineEdit }) {
|
|
864
993
|
const Tag = oneOf(props.level, LEVELS, "h2");
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
994
|
+
const heading = /* @__PURE__ */ jsx12(Tag, { className: "tb-b-heading", children: inlineEdit?.("text") ?? str(props.text) ?? "" });
|
|
995
|
+
const kicker = inlineEdit?.("kicker") ?? str(props.kicker);
|
|
996
|
+
const rule = props.rule === true;
|
|
997
|
+
if (kicker === void 0 && !rule) {
|
|
998
|
+
return /* @__PURE__ */ jsxs7(Fragment7, { children: [
|
|
999
|
+
/* @__PURE__ */ jsx12(BasicStyles, {}),
|
|
1000
|
+
heading
|
|
1001
|
+
] });
|
|
1002
|
+
}
|
|
1003
|
+
return /* @__PURE__ */ jsxs7(Fragment7, { children: [
|
|
1004
|
+
/* @__PURE__ */ jsx12(BasicStyles, {}),
|
|
1005
|
+
/* @__PURE__ */ jsx12(BasicV2Styles, {}),
|
|
1006
|
+
/* @__PURE__ */ jsxs7("div", { className: "tb-b-heading-wrap", children: [
|
|
1007
|
+
/* @__PURE__ */ jsxs7("p", { className: "tb-b-kicker", children: [
|
|
1008
|
+
rule && /* @__PURE__ */ jsx12("span", { className: "tb-b-kicker-rule", "aria-hidden": "true" }),
|
|
1009
|
+
kicker
|
|
1010
|
+
] }),
|
|
1011
|
+
heading
|
|
1012
|
+
] })
|
|
868
1013
|
] });
|
|
869
1014
|
}
|
|
870
1015
|
|
|
@@ -873,7 +1018,7 @@ import { safeUrl as safeUrl4 } from "@usethrottle/builder-schema";
|
|
|
873
1018
|
|
|
874
1019
|
// src/asset-image.tsx
|
|
875
1020
|
import { safeUrl as safeUrl3 } from "@usethrottle/builder-schema";
|
|
876
|
-
import { jsx as
|
|
1021
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
877
1022
|
function isFrozenAsset(value) {
|
|
878
1023
|
if (typeof value !== "object" || value === null) return false;
|
|
879
1024
|
const v = value;
|
|
@@ -889,7 +1034,7 @@ function AssetImage(props) {
|
|
|
889
1034
|
const url = href(variant.url);
|
|
890
1035
|
return url === null || url.includes(",") ? [] : [`${url} ${String(variant.width)}w`];
|
|
891
1036
|
}).join(", ");
|
|
892
|
-
return /* @__PURE__ */
|
|
1037
|
+
return /* @__PURE__ */ jsx13(
|
|
893
1038
|
"img",
|
|
894
1039
|
{
|
|
895
1040
|
src,
|
|
@@ -906,7 +1051,7 @@ function AssetImage(props) {
|
|
|
906
1051
|
}
|
|
907
1052
|
|
|
908
1053
|
// src/basics/image.tsx
|
|
909
|
-
import { Fragment as
|
|
1054
|
+
import { Fragment as Fragment8, jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
910
1055
|
var RULES2 = [
|
|
911
1056
|
{ key: "radius", property: "--bx-radius", values: { none: "0", s: "4px", m: "8px", l: "16px", full: "9999px" } },
|
|
912
1057
|
{ key: "fit", property: "--bx-fit", values: { cover: "cover", contain: "contain" } }
|
|
@@ -916,19 +1061,19 @@ function Image({ node, props, mediaOrigin, editMode }) {
|
|
|
916
1061
|
const decorative = props.decorative === true;
|
|
917
1062
|
const alt = decorative ? "" : typeof props.alt === "string" ? props.alt : "";
|
|
918
1063
|
const asset = isFrozenAsset(props.image) ? props.image : void 0;
|
|
919
|
-
const image = /* @__PURE__ */
|
|
1064
|
+
const image = /* @__PURE__ */ jsx14(AssetImage, { asset, mediaOrigin, alt, className: "tb-b-img", sizes: "(max-width: 767px) 100vw, 50vw" });
|
|
920
1065
|
const shown2 = asset !== void 0 && safeUrl4(asset.url, "src", { mediaOrigin }) !== null;
|
|
921
|
-
return /* @__PURE__ */
|
|
922
|
-
/* @__PURE__ */
|
|
923
|
-
/* @__PURE__ */
|
|
924
|
-
shown2 ? /* @__PURE__ */
|
|
1066
|
+
return /* @__PURE__ */ jsxs8(Fragment8, { children: [
|
|
1067
|
+
/* @__PURE__ */ jsx14(BasicStyles, {}),
|
|
1068
|
+
/* @__PURE__ */ jsx14(WidgetStyle, { css: enumCss(node, RULES2) }),
|
|
1069
|
+
shown2 ? /* @__PURE__ */ jsx14("div", { className: "tb-b-image", children: /* @__PURE__ */ jsx14("div", { className: "tb-b-image-box", children: href === null ? image : /* @__PURE__ */ jsx14("a", { href, children: image }) }) }) : /* @__PURE__ */ jsx14(Placeholder, { editMode, children: asset === void 0 ? "Choose an image" : "Image unavailable" })
|
|
925
1070
|
] });
|
|
926
1071
|
}
|
|
927
1072
|
|
|
928
1073
|
// src/basics/logo.tsx
|
|
929
1074
|
import { useSiteDesign as useSiteDesign3 } from "@usethrottle/ui";
|
|
930
1075
|
import { safeUrl as safeUrl5 } from "@usethrottle/builder-schema";
|
|
931
|
-
import { Fragment as
|
|
1076
|
+
import { Fragment as Fragment9, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
932
1077
|
function Logo({ props, mediaOrigin, editMode }) {
|
|
933
1078
|
const design = useSiteDesign3();
|
|
934
1079
|
const scheme = design?.theme?.colorScheme ?? "auto";
|
|
@@ -941,17 +1086,17 @@ function Logo({ props, mediaOrigin, editMode }) {
|
|
|
941
1086
|
const alt = name ?? "";
|
|
942
1087
|
let content = null;
|
|
943
1088
|
if (main !== void 0) {
|
|
944
|
-
const img = /* @__PURE__ */
|
|
945
|
-
content = scheme === "auto" && light !== void 0 && dark !== void 0 ? /* @__PURE__ */
|
|
946
|
-
/* @__PURE__ */
|
|
1089
|
+
const img = /* @__PURE__ */ jsx15("img", { src: main, alt, decoding: "async" });
|
|
1090
|
+
content = scheme === "auto" && light !== void 0 && dark !== void 0 ? /* @__PURE__ */ jsxs9("picture", { children: [
|
|
1091
|
+
/* @__PURE__ */ jsx15("source", { media: "(prefers-color-scheme: dark)", srcSet: dark }),
|
|
947
1092
|
img
|
|
948
1093
|
] }) : img;
|
|
949
1094
|
} else if (name !== void 0) {
|
|
950
|
-
content = /* @__PURE__ */
|
|
1095
|
+
content = /* @__PURE__ */ jsx15("span", { className: "tb-b-logo-name", children: name });
|
|
951
1096
|
}
|
|
952
|
-
return /* @__PURE__ */
|
|
953
|
-
/* @__PURE__ */
|
|
954
|
-
content === null ? /* @__PURE__ */
|
|
1097
|
+
return /* @__PURE__ */ jsxs9(Fragment9, { children: [
|
|
1098
|
+
/* @__PURE__ */ jsx15(BasicStyles, {}),
|
|
1099
|
+
content === null ? /* @__PURE__ */ jsx15(Placeholder, { editMode, children: "Logo: add one in Site settings" }) : /* @__PURE__ */ jsx15("div", { className: "tb-b-logo", children: /* @__PURE__ */ jsx15("a", { href, children: content }) })
|
|
955
1100
|
] });
|
|
956
1101
|
}
|
|
957
1102
|
|
|
@@ -959,7 +1104,7 @@ function Logo({ props, mediaOrigin, editMode }) {
|
|
|
959
1104
|
import { useId, useRef, useState as useState2 } from "react";
|
|
960
1105
|
import { Icon as Icon2, useSiteDesign as useSiteDesign4 } from "@usethrottle/ui";
|
|
961
1106
|
import { SITE_STRING_DEFAULTS as SITE_STRING_DEFAULTS3, safeUrl as safeUrl6 } from "@usethrottle/builder-schema";
|
|
962
|
-
import { Fragment as
|
|
1107
|
+
import { Fragment as Fragment10, jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
963
1108
|
var LAYOUTS = ["horizontal", "vertical", "drawer-on-phone"];
|
|
964
1109
|
var MAX_DEPTH = 3;
|
|
965
1110
|
function List({ items, mediaOrigin, depth = 0, id, onNavigate }) {
|
|
@@ -968,16 +1113,16 @@ function List({ items, mediaOrigin, depth = 0, id, onNavigate }) {
|
|
|
968
1113
|
return href === null ? [] : [{ item, href }];
|
|
969
1114
|
});
|
|
970
1115
|
if (shown2.length === 0) return null;
|
|
971
|
-
return /* @__PURE__ */
|
|
972
|
-
/* @__PURE__ */
|
|
973
|
-
depth + 1 < MAX_DEPTH && item.children !== void 0 && /* @__PURE__ */
|
|
1116
|
+
return /* @__PURE__ */ jsx16("ul", { ...id === void 0 ? {} : { id }, ...onNavigate === void 0 ? {} : { onClick: onNavigate }, children: shown2.map(({ item, href }, index) => /* @__PURE__ */ jsxs10("li", { children: [
|
|
1117
|
+
/* @__PURE__ */ jsx16("a", { href, children: item.label }),
|
|
1118
|
+
depth + 1 < MAX_DEPTH && item.children !== void 0 && /* @__PURE__ */ jsx16(List, { items: item.children, mediaOrigin, depth: depth + 1 })
|
|
974
1119
|
] }, `${String(index)}:${href}`)) });
|
|
975
1120
|
}
|
|
976
1121
|
function Menu({ props, mediaOrigin, editMode }) {
|
|
977
1122
|
const design = useSiteDesign4();
|
|
978
1123
|
const listId = useId();
|
|
979
1124
|
const toggle = useRef(null);
|
|
980
|
-
const [open,
|
|
1125
|
+
const [open, setOpen2] = useState2(false);
|
|
981
1126
|
const name = str(props.menu) ?? "header";
|
|
982
1127
|
const layout = oneOf(props.layout, LAYOUTS, "horizontal");
|
|
983
1128
|
const menus = design?.menus;
|
|
@@ -985,21 +1130,21 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
985
1130
|
const strings = design?.strings;
|
|
986
1131
|
const label = (strings !== void 0 && Object.hasOwn(strings, "nav.menu") ? str(strings["nav.menu"]) : void 0) ?? SITE_STRING_DEFAULTS3["nav.menu"];
|
|
987
1132
|
if (items === void 0 || items.length === 0) {
|
|
988
|
-
return /* @__PURE__ */
|
|
989
|
-
/* @__PURE__ */
|
|
990
|
-
/* @__PURE__ */
|
|
1133
|
+
return /* @__PURE__ */ jsxs10(Fragment10, { children: [
|
|
1134
|
+
/* @__PURE__ */ jsx16(BasicStyles, {}),
|
|
1135
|
+
/* @__PURE__ */ jsx16(Placeholder, { editMode, children: `Menu "${name}" is empty: add links in Site settings` })
|
|
991
1136
|
] });
|
|
992
1137
|
}
|
|
993
1138
|
const drawer = layout === "drawer-on-phone";
|
|
994
1139
|
const onKeyDown = (event) => {
|
|
995
1140
|
if (event.key === "Escape" && open) {
|
|
996
|
-
|
|
1141
|
+
setOpen2(false);
|
|
997
1142
|
toggle.current?.focus();
|
|
998
1143
|
}
|
|
999
1144
|
};
|
|
1000
|
-
return /* @__PURE__ */
|
|
1001
|
-
/* @__PURE__ */
|
|
1002
|
-
/* @__PURE__ */
|
|
1145
|
+
return /* @__PURE__ */ jsxs10(Fragment10, { children: [
|
|
1146
|
+
/* @__PURE__ */ jsx16(BasicStyles, {}),
|
|
1147
|
+
/* @__PURE__ */ jsxs10(
|
|
1003
1148
|
"nav",
|
|
1004
1149
|
{
|
|
1005
1150
|
className: `tb-b-menu tb-b-menu--${layout}${layout === "vertical" ? "" : " tb-b-menu--h"}`,
|
|
@@ -1007,7 +1152,7 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
1007
1152
|
"data-open": drawer ? String(open) : void 0,
|
|
1008
1153
|
onKeyDown: drawer ? onKeyDown : void 0,
|
|
1009
1154
|
children: [
|
|
1010
|
-
drawer && /* @__PURE__ */
|
|
1155
|
+
drawer && /* @__PURE__ */ jsx16(
|
|
1011
1156
|
"button",
|
|
1012
1157
|
{
|
|
1013
1158
|
ref: toggle,
|
|
@@ -1015,11 +1160,11 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
1015
1160
|
className: "tb-b-menu-toggle",
|
|
1016
1161
|
"aria-expanded": open,
|
|
1017
1162
|
"aria-controls": listId,
|
|
1018
|
-
onClick: () =>
|
|
1019
|
-
children: /* @__PURE__ */
|
|
1163
|
+
onClick: () => setOpen2((value) => !value),
|
|
1164
|
+
children: /* @__PURE__ */ jsx16(Icon2, { name: open ? "close" : "menu", size: 24, label })
|
|
1020
1165
|
}
|
|
1021
1166
|
),
|
|
1022
|
-
/* @__PURE__ */
|
|
1167
|
+
/* @__PURE__ */ jsx16(List, { items, mediaOrigin, id: listId, ...drawer ? { onNavigate: () => setOpen2(false) } : {} })
|
|
1023
1168
|
]
|
|
1024
1169
|
}
|
|
1025
1170
|
)
|
|
@@ -1027,18 +1172,18 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
1027
1172
|
}
|
|
1028
1173
|
|
|
1029
1174
|
// src/basics/spacer.tsx
|
|
1030
|
-
import { Fragment as
|
|
1175
|
+
import { Fragment as Fragment11, jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1031
1176
|
function Spacer() {
|
|
1032
|
-
return /* @__PURE__ */
|
|
1033
|
-
/* @__PURE__ */
|
|
1034
|
-
/* @__PURE__ */
|
|
1177
|
+
return /* @__PURE__ */ jsxs11(Fragment11, { children: [
|
|
1178
|
+
/* @__PURE__ */ jsx17(BasicStyles, {}),
|
|
1179
|
+
/* @__PURE__ */ jsx17("div", { className: "tb-b-spacer", "aria-hidden": "true" })
|
|
1035
1180
|
] });
|
|
1036
1181
|
}
|
|
1037
1182
|
|
|
1038
1183
|
// src/basics/rich-text.tsx
|
|
1039
|
-
import { Fragment as
|
|
1184
|
+
import { Fragment as Fragment12, createElement } from "react";
|
|
1040
1185
|
import { safeUrl as safeUrl7 } from "@usethrottle/builder-schema";
|
|
1041
|
-
import { jsx as
|
|
1186
|
+
import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1042
1187
|
var ALLOWED = /* @__PURE__ */ new Set(["p", "br", "strong", "em", "u", "s", "a", "ul", "ol", "li", "h2", "h3", "h4", "blockquote", "code"]);
|
|
1043
1188
|
var ALIAS = { b: "strong", i: "em", strike: "s", del: "s" };
|
|
1044
1189
|
var DROP_WITH_CONTENT = /* @__PURE__ */ new Set([
|
|
@@ -1197,11 +1342,11 @@ function parseRichText(source, mediaOrigin) {
|
|
|
1197
1342
|
}
|
|
1198
1343
|
}
|
|
1199
1344
|
if (name === "li") {
|
|
1200
|
-
let
|
|
1201
|
-
while (
|
|
1202
|
-
if (
|
|
1203
|
-
if (
|
|
1204
|
-
stack.length =
|
|
1345
|
+
let list2 = stack.length - 1;
|
|
1346
|
+
while (list2 > 0 && stack[list2].tag !== "ul" && stack[list2].tag !== "ol") list2 -= 1;
|
|
1347
|
+
if (list2 === 0) list2 = -1;
|
|
1348
|
+
if (list2 === -1) continue;
|
|
1349
|
+
stack.length = list2 + 1;
|
|
1205
1350
|
}
|
|
1206
1351
|
if (name === "a") closeTo("a");
|
|
1207
1352
|
const el = { tag: name, children: [] };
|
|
@@ -1218,10 +1363,10 @@ function parseRichText(source, mediaOrigin) {
|
|
|
1218
1363
|
}
|
|
1219
1364
|
function toReact(el, key) {
|
|
1220
1365
|
const children = el.children.map((child, index) => typeof child === "string" ? child : toReact(child, index));
|
|
1221
|
-
if (el.tag === "br") return /* @__PURE__ */
|
|
1366
|
+
if (el.tag === "br") return /* @__PURE__ */ jsx18("br", {}, key);
|
|
1222
1367
|
if (el.tag === "a") {
|
|
1223
|
-
if (el.href === null || el.href === void 0) return /* @__PURE__ */
|
|
1224
|
-
return /* @__PURE__ */
|
|
1368
|
+
if (el.href === null || el.href === void 0) return /* @__PURE__ */ jsx18(Fragment12, { children }, key);
|
|
1369
|
+
return /* @__PURE__ */ jsx18("a", { href: el.href, rel: "noopener noreferrer", className: "tb-b-link", children }, key);
|
|
1225
1370
|
}
|
|
1226
1371
|
return createElement(el.tag, { key }, ...children);
|
|
1227
1372
|
}
|
|
@@ -1232,26 +1377,26 @@ function RichText({
|
|
|
1232
1377
|
editMode = false
|
|
1233
1378
|
}) {
|
|
1234
1379
|
const tree = parseRichText(html, mediaOrigin);
|
|
1235
|
-
return /* @__PURE__ */
|
|
1380
|
+
return /* @__PURE__ */ jsxs12("div", { className, children: [
|
|
1236
1381
|
tree.children.map((child, index) => typeof child === "string" ? child : toReact(child, index)),
|
|
1237
|
-
editMode && tree.truncated === true && /* @__PURE__ */
|
|
1382
|
+
editMode && tree.truncated === true && /* @__PURE__ */ jsx18("div", { className: "tb-b-empty", role: "alert", children: "Part of this text was not shown: a tag is not closed (check the quotes in links), or the text is too long." })
|
|
1238
1383
|
] });
|
|
1239
1384
|
}
|
|
1240
1385
|
|
|
1241
1386
|
// src/basics/text.tsx
|
|
1242
|
-
import { Fragment as
|
|
1387
|
+
import { Fragment as Fragment13, jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1243
1388
|
function Text({ props, mediaOrigin, editMode, inlineEdit }) {
|
|
1244
1389
|
const editor = inlineEdit?.("html") ?? null;
|
|
1245
|
-
return /* @__PURE__ */
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
editor === null ? /* @__PURE__ */
|
|
1390
|
+
return /* @__PURE__ */ jsxs13(Fragment13, { children: [
|
|
1391
|
+
/* @__PURE__ */ jsx19(BasicStyles, {}),
|
|
1392
|
+
editor === null ? /* @__PURE__ */ jsx19(RichText, { html: str(props.html) ?? "", mediaOrigin, className: "tb-b-text", editMode }) : /* @__PURE__ */ jsx19("div", { className: "tb-b-text", children: editor })
|
|
1248
1393
|
] });
|
|
1249
1394
|
}
|
|
1250
1395
|
|
|
1251
1396
|
// src/basics/video.tsx
|
|
1252
1397
|
import { useState as useState3 } from "react";
|
|
1253
1398
|
import { Icon as Icon3 } from "@usethrottle/ui";
|
|
1254
|
-
import { Fragment as
|
|
1399
|
+
import { Fragment as Fragment14, jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1255
1400
|
var RULES3 = [
|
|
1256
1401
|
{ key: "ratio", property: "--bx-ratio", values: { "16:9": "16 / 9", "4:3": "4 / 3", "1:1": "1 / 1", "9:16": "9 / 16" } }
|
|
1257
1402
|
];
|
|
@@ -1268,7 +1413,7 @@ function parseVideoUrl(input) {
|
|
|
1268
1413
|
}
|
|
1269
1414
|
if (url.protocol !== "https:" || url.username !== "" || url.password !== "" || url.port !== "" && url.port !== "443") return null;
|
|
1270
1415
|
const host = url.hostname.toLowerCase();
|
|
1271
|
-
const parts = url.pathname.split("/").filter((
|
|
1416
|
+
const parts = url.pathname.split("/").filter((part2) => part2 !== "");
|
|
1272
1417
|
if (host === "youtu.be") {
|
|
1273
1418
|
const id = parts[0];
|
|
1274
1419
|
return parts.length === 1 && id !== void 0 && YOUTUBE_ID.test(id) ? { provider: "youtube", id } : null;
|
|
@@ -1293,10 +1438,10 @@ function embedSrc(video, muted) {
|
|
|
1293
1438
|
function Video({ node, props, editMode }) {
|
|
1294
1439
|
const [loaded, setLoaded] = useState3(false);
|
|
1295
1440
|
const video = parseVideoUrl(str(props.url) ?? "");
|
|
1296
|
-
return /* @__PURE__ */
|
|
1297
|
-
/* @__PURE__ */
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
video === null ? /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ jsxs14(Fragment14, { children: [
|
|
1442
|
+
/* @__PURE__ */ jsx20(BasicStyles, {}),
|
|
1443
|
+
/* @__PURE__ */ jsx20(WidgetStyle, { css: enumCss(node, RULES3) }),
|
|
1444
|
+
video === null ? /* @__PURE__ */ jsx20(Placeholder, { editMode, children: "Paste a YouTube or Vimeo link" }) : /* @__PURE__ */ jsx20("div", { className: "tb-b-video", "data-provider": video.provider, children: loaded && !editMode ? /* @__PURE__ */ jsx20(
|
|
1300
1445
|
"iframe",
|
|
1301
1446
|
{
|
|
1302
1447
|
src: embedSrc(video, props.autoplayMuted === true),
|
|
@@ -1305,36 +1450,268 @@ function Video({ node, props, editMode }) {
|
|
|
1305
1450
|
referrerPolicy: "strict-origin-when-cross-origin",
|
|
1306
1451
|
sandbox: "allow-scripts allow-same-origin allow-presentation allow-popups"
|
|
1307
1452
|
}
|
|
1308
|
-
) : /* @__PURE__ */
|
|
1453
|
+
) : /* @__PURE__ */ jsx20("button", { type: "button", className: "tb-b-play", "aria-label": "Play video", onClick: () => setLoaded(true), children: /* @__PURE__ */ jsx20("span", { children: /* @__PURE__ */ jsx20(Icon3, { name: "play", size: 28 }) }) }) })
|
|
1309
1454
|
] });
|
|
1310
1455
|
}
|
|
1311
1456
|
|
|
1312
|
-
// src/basics/
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
"basic.image": Image,
|
|
1317
|
-
"basic.button": Button,
|
|
1318
|
-
"basic.spacer": Spacer,
|
|
1319
|
-
"basic.divider": Divider,
|
|
1320
|
-
"basic.video": Video,
|
|
1321
|
-
"basic.logo": Logo,
|
|
1322
|
-
"basic.menu": Menu,
|
|
1323
|
-
"basic.announcement": Announcement,
|
|
1324
|
-
"basic.copyright": Copyright,
|
|
1325
|
-
"basic.countdown": Countdown
|
|
1326
|
-
};
|
|
1327
|
-
var widgets = BASIC_WIDGET_DEFINITIONS2.flatMap(
|
|
1328
|
-
(definition) => Object.hasOwn(BASIC_COMPONENTS, definition.type) ? [{ ...definition, Component: BASIC_COMPONENTS[definition.type] }] : []
|
|
1329
|
-
);
|
|
1330
|
-
var basicPack = { id: "basic", version: "0.0.0", widgets, dataSources: [] };
|
|
1457
|
+
// src/basics/v2/announcement-v2.tsx
|
|
1458
|
+
import { Fragment as Fragment21, createElement as createElement3, useEffect as useEffect7, useMemo, useRef as useRef3, useState as useState5 } from "react";
|
|
1459
|
+
import { Icon as Icon5, useSiteDesign as useSiteDesign6 } from "@usethrottle/ui";
|
|
1460
|
+
import { BASIC_WIDGET_DEFINITIONS as BASIC_WIDGET_DEFINITIONS2, SITE_STRING_DEFAULTS as SITE_STRING_DEFAULTS6 } from "@usethrottle/builder-schema";
|
|
1331
1461
|
|
|
1332
|
-
// src/
|
|
1333
|
-
import {
|
|
1462
|
+
// src/context.ts
|
|
1463
|
+
import { createContext, useContext } from "react";
|
|
1464
|
+
var BuilderContext = typeof createContext === "function" ? createContext(null) : null;
|
|
1465
|
+
var useBuilder = () => useContext(BuilderContext);
|
|
1334
1466
|
|
|
1335
|
-
// src/
|
|
1336
|
-
import {
|
|
1337
|
-
import {
|
|
1467
|
+
// src/theme.ts
|
|
1468
|
+
import { SITE_FONTS, eligibleMessages, safeUrl as safeUrl8, sanitizeSiteCss } from "@usethrottle/builder-schema";
|
|
1469
|
+
import { PRESET_NAMES, PRESET_TOKENS } from "@usethrottle/ui/presets";
|
|
1470
|
+
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1471
|
+
var str2 = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
1472
|
+
var PALETTE_KEYS = Object.keys(PRESET_TOKENS.clean.light);
|
|
1473
|
+
var DEVICES2 = ["desktop", "tablet", "phone"];
|
|
1474
|
+
function normalizeMessages(messages) {
|
|
1475
|
+
const out = [];
|
|
1476
|
+
messages.forEach((m, index) => {
|
|
1477
|
+
if (!isRecord2(m)) return;
|
|
1478
|
+
const pages = isRecord2(m.pages) ? m.pages : {};
|
|
1479
|
+
out.push({
|
|
1480
|
+
...m,
|
|
1481
|
+
id: str2(m.id) ?? `m${String(index)}`,
|
|
1482
|
+
target: isRecord2(m.target) ? m.target : null,
|
|
1483
|
+
startsAt: str2(m.startsAt) ?? null,
|
|
1484
|
+
endsAt: str2(m.endsAt) ?? null,
|
|
1485
|
+
audience: m.audience === "guest" || m.audience === "signed-in" ? m.audience : "all",
|
|
1486
|
+
devices: Array.isArray(m.devices) ? m.devices.filter((d) => DEVICES2.some((x) => x === d)) : [...DEVICES2],
|
|
1487
|
+
pages: {
|
|
1488
|
+
mode: pages.mode === "include" || pages.mode === "exclude" ? pages.mode : "all",
|
|
1489
|
+
list: Array.isArray(pages.list) ? pages.list.filter((p) => typeof p === "string") : []
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
});
|
|
1493
|
+
return out;
|
|
1494
|
+
}
|
|
1495
|
+
function eligibleOnAnyDevice(messages, now, audience, page) {
|
|
1496
|
+
const ids = /* @__PURE__ */ new Set();
|
|
1497
|
+
for (const device of DEVICES2) for (const m of eligibleMessages(messages, { now, device, audience, page })) ids.add(m.id);
|
|
1498
|
+
return messages.filter((m) => ids.has(m.id));
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
// src/viewer.ts
|
|
1502
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
1503
|
+
var ViewerContext = typeof createContext2 === "function" ? createContext2(void 0) : null;
|
|
1504
|
+
var useViewer = () => useContext2(ViewerContext);
|
|
1505
|
+
|
|
1506
|
+
// src/basics/v2/menu-v2.tsx
|
|
1507
|
+
import { useEffect as useEffect6, useId as useId2 } from "react";
|
|
1508
|
+
import { Icon as Icon4, useSiteDesign as useSiteDesign5 } from "@usethrottle/ui";
|
|
1509
|
+
import { MB_BASIC_WIDGET_DEFINITIONS, SITE_STRING_DEFAULTS as SITE_STRING_DEFAULTS5, expandMenu, safeUrl as safeUrl12, sectionNodeSchema as sectionNodeSchema2 } from "@usethrottle/builder-schema";
|
|
1510
|
+
|
|
1511
|
+
// src/interactions/focus-trap.ts
|
|
1512
|
+
var FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
1513
|
+
var focusablesOf = (root) => Array.from(root.querySelectorAll(FOCUSABLE));
|
|
1514
|
+
function trapTab(event, items) {
|
|
1515
|
+
if (event.key !== "Tab") return false;
|
|
1516
|
+
const first = items[0];
|
|
1517
|
+
const last = items[items.length - 1];
|
|
1518
|
+
if (first === void 0 || last === void 0) return false;
|
|
1519
|
+
const active = document.activeElement;
|
|
1520
|
+
const inside = active !== null && items.includes(active);
|
|
1521
|
+
if (event.shiftKey && (active === first || !inside)) {
|
|
1522
|
+
event.preventDefault();
|
|
1523
|
+
last.focus();
|
|
1524
|
+
return true;
|
|
1525
|
+
}
|
|
1526
|
+
if (!event.shiftKey && (active === last || !inside)) {
|
|
1527
|
+
event.preventDefault();
|
|
1528
|
+
first.focus();
|
|
1529
|
+
return true;
|
|
1530
|
+
}
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
// src/interactions/menu-runtime.ts
|
|
1535
|
+
var holds2 = 0;
|
|
1536
|
+
var release;
|
|
1537
|
+
var ITEM = "[data-tb-i]";
|
|
1538
|
+
var hovers = () => window.matchMedia?.("(hover:none)").matches !== true;
|
|
1539
|
+
function toggleOf(item) {
|
|
1540
|
+
return item.querySelector(":scope > [data-tb-t]");
|
|
1541
|
+
}
|
|
1542
|
+
function setItem(item, open) {
|
|
1543
|
+
if (open) item.setAttribute("data-open", "true");
|
|
1544
|
+
else item.removeAttribute("data-open");
|
|
1545
|
+
toggleOf(item)?.setAttribute("aria-expanded", String(open));
|
|
1546
|
+
item.querySelector(":scope > [data-nav-panel]")?.toggleAttribute("hidden", !open);
|
|
1547
|
+
}
|
|
1548
|
+
function closeOthers(keep) {
|
|
1549
|
+
for (const item of document.querySelectorAll(`${ITEM}[data-open]`)) {
|
|
1550
|
+
if (keep === null || !item.contains(keep)) setItem(item, false);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
var NAV_TOP = "[data-nav-top]";
|
|
1554
|
+
var PANEL = "[data-nav-panel]";
|
|
1555
|
+
function navKey(event, el) {
|
|
1556
|
+
const entry = el.closest(NAV_TOP);
|
|
1557
|
+
if (entry === null) return false;
|
|
1558
|
+
const focus = (links, at2) => links[(at2 + links.length) % links.length]?.focus();
|
|
1559
|
+
const top = entry.querySelector(":scope > a");
|
|
1560
|
+
if (event.key === "Escape" && entry.hasAttribute("data-open")) {
|
|
1561
|
+
event.preventDefault();
|
|
1562
|
+
setItem(entry, false);
|
|
1563
|
+
top?.focus();
|
|
1564
|
+
return true;
|
|
1565
|
+
}
|
|
1566
|
+
const panel = el.closest(PANEL);
|
|
1567
|
+
if (panel !== null) {
|
|
1568
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return false;
|
|
1569
|
+
event.preventDefault();
|
|
1570
|
+
const links = [...panel.querySelectorAll("a")];
|
|
1571
|
+
focus(links, links.indexOf(el) + (event.key === "ArrowDown" ? 1 : -1));
|
|
1572
|
+
return true;
|
|
1573
|
+
}
|
|
1574
|
+
if (el !== top) return false;
|
|
1575
|
+
const list2 = entry.parentElement;
|
|
1576
|
+
const tops = [...list2?.querySelectorAll(":scope > li > a") ?? []];
|
|
1577
|
+
const at = tops.indexOf(el);
|
|
1578
|
+
const rtl = list2 !== null && getComputedStyle(list2).direction === "rtl";
|
|
1579
|
+
const forward = rtl ? "ArrowLeft" : "ArrowRight";
|
|
1580
|
+
const back = rtl ? "ArrowRight" : "ArrowLeft";
|
|
1581
|
+
if (event.key === forward || event.key === back) focus(tops, at + (event.key === forward ? 1 : -1));
|
|
1582
|
+
else if (event.key === "Home") focus(tops, 0);
|
|
1583
|
+
else if (event.key === "End") focus(tops, -1);
|
|
1584
|
+
else if (event.key === "ArrowDown" && entry.querySelector(":scope > " + PANEL) !== null) {
|
|
1585
|
+
if (!entry.hasAttribute("data-open")) setItem(entry, true);
|
|
1586
|
+
entry.querySelector(":scope > " + PANEL + " a")?.focus();
|
|
1587
|
+
} else return false;
|
|
1588
|
+
event.preventDefault();
|
|
1589
|
+
return true;
|
|
1590
|
+
}
|
|
1591
|
+
var drawerToggle = (nav) => nav.querySelector(":scope > [data-tb-drawer]");
|
|
1592
|
+
function setDrawer(nav, open) {
|
|
1593
|
+
nav.setAttribute("data-open", String(open));
|
|
1594
|
+
drawerToggle(nav)?.setAttribute("aria-expanded", String(open));
|
|
1595
|
+
const list2 = nav.querySelector(":scope > ul");
|
|
1596
|
+
if (list2 === null) return;
|
|
1597
|
+
if (open) {
|
|
1598
|
+
list2.setAttribute("role", "dialog");
|
|
1599
|
+
list2.setAttribute("aria-modal", "true");
|
|
1600
|
+
const label = nav.getAttribute("aria-label");
|
|
1601
|
+
if (label !== null) list2.setAttribute("aria-label", label);
|
|
1602
|
+
focusablesOf(list2)[0]?.focus();
|
|
1603
|
+
} else {
|
|
1604
|
+
list2.removeAttribute("role");
|
|
1605
|
+
list2.removeAttribute("aria-modal");
|
|
1606
|
+
list2.removeAttribute("aria-label");
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
var target = (event) => event.target instanceof Element ? event.target : null;
|
|
1610
|
+
function install() {
|
|
1611
|
+
const over = (event) => {
|
|
1612
|
+
const el = target(event);
|
|
1613
|
+
if (el === null || !hovers()) return;
|
|
1614
|
+
closeOthers(el);
|
|
1615
|
+
for (let item = el.closest(ITEM); item !== null; item = item.parentElement?.closest(ITEM) ?? null) setItem(item, true);
|
|
1616
|
+
};
|
|
1617
|
+
const out = (event) => {
|
|
1618
|
+
if (!hovers()) return;
|
|
1619
|
+
const to = event.relatedTarget instanceof Node ? event.relatedTarget : null;
|
|
1620
|
+
closeOthers(to);
|
|
1621
|
+
};
|
|
1622
|
+
const focusin = (event) => {
|
|
1623
|
+
const el = target(event);
|
|
1624
|
+
if (el === null) return;
|
|
1625
|
+
closeOthers(el);
|
|
1626
|
+
if (el.closest("[data-tb-t]") !== null || el.closest(NAV_TOP) !== null) return;
|
|
1627
|
+
for (let item = el.closest(ITEM); item !== null; item = item.parentElement?.closest(ITEM) ?? null) setItem(item, true);
|
|
1628
|
+
};
|
|
1629
|
+
const click = (event) => {
|
|
1630
|
+
const el = target(event);
|
|
1631
|
+
if (el === null) return;
|
|
1632
|
+
const opener = el.closest("[data-tb-drawer]");
|
|
1633
|
+
if (opener !== null) {
|
|
1634
|
+
const nav2 = opener.closest("nav");
|
|
1635
|
+
if (nav2 !== null) setDrawer(nav2, nav2.getAttribute("data-open") !== "true");
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1638
|
+
const toggle = el.closest("[data-tb-t]");
|
|
1639
|
+
const item = toggle?.closest(ITEM) ?? null;
|
|
1640
|
+
if (item !== null) {
|
|
1641
|
+
closeOthers(item);
|
|
1642
|
+
setItem(item, item.getAttribute("data-open") !== "true");
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
closeOthers(el);
|
|
1646
|
+
const nav = el.closest("nav[data-open=true]");
|
|
1647
|
+
if (nav !== null && el.closest("a") !== null) setDrawer(nav, false);
|
|
1648
|
+
};
|
|
1649
|
+
const keydown = (event) => {
|
|
1650
|
+
const el = target(event);
|
|
1651
|
+
const drawer = document.querySelector("nav[data-open=true]");
|
|
1652
|
+
if (event.key === "Tab" && drawer !== null) {
|
|
1653
|
+
const toggle = drawerToggle(drawer);
|
|
1654
|
+
const list2 = drawer.querySelector(":scope > ul");
|
|
1655
|
+
if (list2 !== null) trapTab(event, [...toggle === null ? [] : [toggle], ...focusablesOf(list2)]);
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
if (drawer === null && el !== null && navKey(event, el)) return;
|
|
1659
|
+
if (event.key !== "Escape") return;
|
|
1660
|
+
if (drawer !== null) {
|
|
1661
|
+
closeOthers(null);
|
|
1662
|
+
setDrawer(drawer, false);
|
|
1663
|
+
drawerToggle(drawer)?.focus();
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
const open = document.querySelector(`${ITEM}[data-open]`);
|
|
1667
|
+
if (open !== null) {
|
|
1668
|
+
const focusInside = el !== null && open.contains(el);
|
|
1669
|
+
const back = toggleOf(open);
|
|
1670
|
+
closeOthers(null);
|
|
1671
|
+
if (focusInside) back?.focus();
|
|
1672
|
+
}
|
|
1673
|
+
};
|
|
1674
|
+
document.addEventListener("mouseover", over);
|
|
1675
|
+
document.addEventListener("mouseout", out);
|
|
1676
|
+
document.addEventListener("focusin", focusin);
|
|
1677
|
+
document.addEventListener("click", click);
|
|
1678
|
+
document.addEventListener("keydown", keydown);
|
|
1679
|
+
return () => {
|
|
1680
|
+
document.removeEventListener("mouseover", over);
|
|
1681
|
+
document.removeEventListener("mouseout", out);
|
|
1682
|
+
document.removeEventListener("focusin", focusin);
|
|
1683
|
+
document.removeEventListener("click", click);
|
|
1684
|
+
document.removeEventListener("keydown", keydown);
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
function startMenuRuntime() {
|
|
1688
|
+
if (holds2++ === 0) release = install();
|
|
1689
|
+
let done = false;
|
|
1690
|
+
return () => {
|
|
1691
|
+
if (done) return;
|
|
1692
|
+
done = true;
|
|
1693
|
+
if (--holds2 === 0) {
|
|
1694
|
+
release?.();
|
|
1695
|
+
release = void 0;
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
// src/renderer.tsx
|
|
1701
|
+
import { Fragment as Fragment19 } from "react";
|
|
1702
|
+
import {
|
|
1703
|
+
ANCHOR_RE as ANCHOR_RE3,
|
|
1704
|
+
COMMON_WIDGET_SETTINGS as COMMON_WIDGET_SETTINGS2,
|
|
1705
|
+
SITE_STRING_DEFAULTS as SITE_STRING_DEFAULTS4,
|
|
1706
|
+
resolveEntrance,
|
|
1707
|
+
resolveInteraction,
|
|
1708
|
+
codeWidgetSnapshotSchema,
|
|
1709
|
+
resolveResponsive as resolveResponsive4,
|
|
1710
|
+
safeUrl as safeUrl11,
|
|
1711
|
+
upgradeNodes,
|
|
1712
|
+
validateSettingValue as validateSettingValue2,
|
|
1713
|
+
walkNodes as walkNodes3
|
|
1714
|
+
} from "@usethrottle/builder-schema";
|
|
1338
1715
|
|
|
1339
1716
|
// src/budget.ts
|
|
1340
1717
|
import { MAX_TEMPLATE_WEIGHT, templateWeight } from "@usethrottle/builder-schema";
|
|
@@ -1359,31 +1736,13 @@ var RenderBudget = class {
|
|
|
1359
1736
|
};
|
|
1360
1737
|
var fitsBudget = (ast, limit = MAX_RENDERED_NODES) => templateWeight(ast) <= limit;
|
|
1361
1738
|
|
|
1362
|
-
// src/part-view.tsx
|
|
1363
|
-
import { Component } from "react";
|
|
1364
|
-
|
|
1365
|
-
// src/renderer.tsx
|
|
1366
|
-
import { Fragment as Fragment16 } from "react";
|
|
1367
|
-
import {
|
|
1368
|
-
ANCHOR_RE as ANCHOR_RE3,
|
|
1369
|
-
COMMON_WIDGET_SETTINGS as COMMON_WIDGET_SETTINGS2,
|
|
1370
|
-
resolveEntrance,
|
|
1371
|
-
resolveInteraction,
|
|
1372
|
-
codeWidgetSnapshotSchema,
|
|
1373
|
-
resolveResponsive as resolveResponsive3,
|
|
1374
|
-
safeUrl as safeUrl10,
|
|
1375
|
-
upgradeNodes,
|
|
1376
|
-
validateSettingValue as validateSettingValue2,
|
|
1377
|
-
walkNodes as walkNodes3
|
|
1378
|
-
} from "@usethrottle/builder-schema";
|
|
1379
|
-
|
|
1380
1739
|
// src/code/code-widget.tsx
|
|
1381
1740
|
import { Suspense as Suspense2 } from "react";
|
|
1382
1741
|
import { LIMITS } from "@usethrottle/builder-schema";
|
|
1383
1742
|
|
|
1384
1743
|
// src/custom/custom-css.tsx
|
|
1385
1744
|
import { sanitizeWidgetCss } from "@usethrottle/builder-schema";
|
|
1386
|
-
import { jsx as
|
|
1745
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1387
1746
|
function scopedCss(source, type) {
|
|
1388
1747
|
if (source === void 0 || source === "") return "";
|
|
1389
1748
|
if (typeof source !== "string") return null;
|
|
@@ -1391,11 +1750,11 @@ function scopedCss(source, type) {
|
|
|
1391
1750
|
return result.ok ? result.css : null;
|
|
1392
1751
|
}
|
|
1393
1752
|
function CustomCss({ css }) {
|
|
1394
|
-
return /* @__PURE__ */
|
|
1753
|
+
return /* @__PURE__ */ jsx21(WidgetStyle, { css });
|
|
1395
1754
|
}
|
|
1396
1755
|
|
|
1397
1756
|
// src/custom/interpreter.tsx
|
|
1398
|
-
import { Fragment as
|
|
1757
|
+
import { Fragment as Fragment15, createElement as createElement2 } from "react";
|
|
1399
1758
|
import {
|
|
1400
1759
|
ALLOWED_ATTRS,
|
|
1401
1760
|
ALLOWED_ELEMENTS,
|
|
@@ -1406,9 +1765,9 @@ import {
|
|
|
1406
1765
|
RESERVED_DATA_PREFIX,
|
|
1407
1766
|
VOID_ELEMENTS,
|
|
1408
1767
|
isReservedClass,
|
|
1409
|
-
safeUrl as
|
|
1768
|
+
safeUrl as safeUrl9
|
|
1410
1769
|
} from "@usethrottle/builder-schema";
|
|
1411
|
-
import { jsx as
|
|
1770
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
1412
1771
|
var MAX_OUTPUT_CHARS = 1e6;
|
|
1413
1772
|
var MAX_ATTR_CHARS = 2e3;
|
|
1414
1773
|
var MAX_DEPTH3 = 24;
|
|
@@ -1491,7 +1850,7 @@ function attrAllowed(tag, name) {
|
|
|
1491
1850
|
return (ALLOWED_ATTRS["*"]?.includes(name) ?? false) || (own?.includes(name) ?? false);
|
|
1492
1851
|
}
|
|
1493
1852
|
function attrText(attr, env, scope) {
|
|
1494
|
-
return attr.value.map((
|
|
1853
|
+
return attr.value.map((part2) => part2.type === "text" ? part2.value : filtered(lookup(part2.path, env, scope), part2.filters)).join("");
|
|
1495
1854
|
}
|
|
1496
1855
|
function urlSource(attr, env, scope) {
|
|
1497
1856
|
const [only] = attr.value;
|
|
@@ -1508,7 +1867,7 @@ function attrProp(tag, attr, env, scope) {
|
|
|
1508
1867
|
const { name } = attr;
|
|
1509
1868
|
if (!attrAllowed(tag, name)) return null;
|
|
1510
1869
|
if (name === "href" || name === "src") {
|
|
1511
|
-
const safe =
|
|
1870
|
+
const safe = safeUrl9(urlSource(attr, env, scope), name, { mediaOrigin: env.mediaOrigin });
|
|
1512
1871
|
return safe === null || !spend(env, safe.length) ? null : [name, safe];
|
|
1513
1872
|
}
|
|
1514
1873
|
const text2 = attrText(attr, env, scope);
|
|
@@ -1557,21 +1916,21 @@ function renderNodes(nodes, env, scope, depth) {
|
|
|
1557
1916
|
}
|
|
1558
1917
|
case "if": {
|
|
1559
1918
|
const branch = truthy(lookup(node.path, env, scope)) ? node.then : node.else;
|
|
1560
|
-
out.push(/* @__PURE__ */
|
|
1919
|
+
out.push(/* @__PURE__ */ jsx22(Fragment15, { children: renderNodes(branch, env, scope, depth + 1) }, out.length));
|
|
1561
1920
|
break;
|
|
1562
1921
|
}
|
|
1563
1922
|
case "unless":
|
|
1564
1923
|
if (!truthy(lookup(node.path, env, scope))) {
|
|
1565
|
-
out.push(/* @__PURE__ */
|
|
1924
|
+
out.push(/* @__PURE__ */ jsx22(Fragment15, { children: renderNodes(node.body, env, scope, depth + 1) }, out.length));
|
|
1566
1925
|
}
|
|
1567
1926
|
break;
|
|
1568
1927
|
case "each": {
|
|
1569
|
-
const
|
|
1570
|
-
if (!Array.isArray(
|
|
1571
|
-
const count = Math.min(
|
|
1928
|
+
const list2 = lookup(node.path, env, scope);
|
|
1929
|
+
if (!Array.isArray(list2)) break;
|
|
1930
|
+
const count = Math.min(list2.length, EACH_ITERATION_CAP);
|
|
1572
1931
|
for (let i = 0; i < count && !env.stopped; i += 1) {
|
|
1573
|
-
const inner = new Map(scope).set(node.as,
|
|
1574
|
-
out.push(/* @__PURE__ */
|
|
1932
|
+
const inner = new Map(scope).set(node.as, list2[i]);
|
|
1933
|
+
out.push(/* @__PURE__ */ jsx22(Fragment15, { children: renderNodes(node.body, env, inner, depth + 1) }, out.length));
|
|
1575
1934
|
}
|
|
1576
1935
|
break;
|
|
1577
1936
|
}
|
|
@@ -1589,7 +1948,46 @@ function renderTemplate(ast, env) {
|
|
|
1589
1948
|
// src/custom/template-widget.tsx
|
|
1590
1949
|
import { Suspense } from "react";
|
|
1591
1950
|
import { MAX_TEMPLATE_WEIGHT as MAX_TEMPLATE_WEIGHT2, parseTemplate, templateWeight as templateWeight2, validateTemplate } from "@usethrottle/builder-schema";
|
|
1592
|
-
|
|
1951
|
+
|
|
1952
|
+
// src/part-view.tsx
|
|
1953
|
+
import { Component } from "react";
|
|
1954
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1955
|
+
var BoundaryBase = Component ?? class {
|
|
1956
|
+
};
|
|
1957
|
+
var Boundary = class extends BoundaryBase {
|
|
1958
|
+
constructor() {
|
|
1959
|
+
super(...arguments);
|
|
1960
|
+
__publicField(this, "state", { failed: false });
|
|
1961
|
+
}
|
|
1962
|
+
static getDerivedStateFromError() {
|
|
1963
|
+
return { failed: true };
|
|
1964
|
+
}
|
|
1965
|
+
componentDidCatch(error, _info) {
|
|
1966
|
+
warnOnce(`part:${this.props.label}`, `${this.props.label} failed to render (${String(error)}); rendering nothing for it`);
|
|
1967
|
+
try {
|
|
1968
|
+
this.props.onError?.(error, { part: this.props.label });
|
|
1969
|
+
} catch {
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
componentDidUpdate(previous) {
|
|
1973
|
+
const moved = previous.resetKeys.length !== this.props.resetKeys.length || previous.resetKeys.some((key, i) => !Object.is(key, this.props.resetKeys[i]));
|
|
1974
|
+
if (moved && this.state.failed) this.setState({ failed: false });
|
|
1975
|
+
}
|
|
1976
|
+
render() {
|
|
1977
|
+
return this.state.failed ? null : this.props.children;
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
function PartBoundary({
|
|
1981
|
+
label,
|
|
1982
|
+
resetKey,
|
|
1983
|
+
children
|
|
1984
|
+
}) {
|
|
1985
|
+
const builder = useBuilder();
|
|
1986
|
+
return /* @__PURE__ */ jsx23(Boundary, { label, resetKeys: [builder?.site, resetKey], onError: builder?.onError, children });
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
// src/custom/template-widget.tsx
|
|
1990
|
+
import { Fragment as Fragment16, jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1593
1991
|
var componentWeights = /* @__PURE__ */ new WeakMap();
|
|
1594
1992
|
var compiled = /* @__PURE__ */ new WeakMap();
|
|
1595
1993
|
function compileTemplate(snapshot, registry) {
|
|
@@ -1630,19 +2028,20 @@ function TemplateBody({ snapshot, registry, props, data, locale, mediaOrigin, bu
|
|
|
1630
2028
|
const template = compileTemplate(snapshot, registry);
|
|
1631
2029
|
if (template === null) return null;
|
|
1632
2030
|
const env = newEnv({ settings: props, data, locale, mediaOrigin, budget: budget ?? new RenderBudget() });
|
|
1633
|
-
return /* @__PURE__ */
|
|
1634
|
-
template.css === "" ? null : /* @__PURE__ */
|
|
2031
|
+
return /* @__PURE__ */ jsxs15(Fragment16, { children: [
|
|
2032
|
+
template.css === "" ? null : /* @__PURE__ */ jsx24(CustomCss, { css: template.css }),
|
|
1635
2033
|
renderTemplate(template.ast, env)
|
|
1636
2034
|
] });
|
|
1637
2035
|
}
|
|
1638
2036
|
function TemplateWidget(props) {
|
|
1639
|
-
return /* @__PURE__ */
|
|
2037
|
+
return /* @__PURE__ */ jsx24(PartBoundary, { label: `${props.snapshot.type}@${String(props.snapshot.v)}`, children: /* @__PURE__ */ jsx24(Suspense, { fallback: null, children: /* @__PURE__ */ jsx24(TemplateBody, { ...props }) }) });
|
|
1640
2038
|
}
|
|
1641
2039
|
|
|
1642
2040
|
// src/code/leave.ts
|
|
1643
2041
|
import { useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
1644
2042
|
|
|
1645
2043
|
// src/code/routes.ts
|
|
2044
|
+
import { CODE_TEMPLATE_DENY } from "@usethrottle/builder-schema";
|
|
1646
2045
|
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)?$|^(confirm|thank|receipt|invoice|quote).*$|^order[-_].*$/i;
|
|
1647
2046
|
var DEFAULT_CATALOG_ROUTES = [
|
|
1648
2047
|
"/p/{handle}",
|
|
@@ -1689,7 +2088,7 @@ function matcherOf(template) {
|
|
|
1689
2088
|
if (known !== void 0) return known;
|
|
1690
2089
|
let regex = null;
|
|
1691
2090
|
if (template.startsWith("/")) {
|
|
1692
|
-
const pattern = template.split(/(\{[A-Za-z][A-Za-z0-9]*\})/).map((
|
|
2091
|
+
const pattern = template.split(/(\{[A-Za-z][A-Za-z0-9]*\})/).map((part2) => /^\{[A-Za-z][A-Za-z0-9]*\}$/.test(part2) ? "[^/]+" : escapeRegExp(part2)).join("").replace(/\/+$/, "");
|
|
1693
2092
|
regex = new RegExp(`^${pattern === "" ? "/" : pattern}$`);
|
|
1694
2093
|
}
|
|
1695
2094
|
if (compiled2.size >= MAX_COMPILED) compiled2.clear();
|
|
@@ -1697,13 +2096,27 @@ function matcherOf(template) {
|
|
|
1697
2096
|
return regex;
|
|
1698
2097
|
}
|
|
1699
2098
|
var matchesTemplate = (path, template) => matcherOf(template)?.test(path) ?? false;
|
|
2099
|
+
function buildRouteTable(store, catalog = {}) {
|
|
2100
|
+
return { ...catalog, ...store };
|
|
2101
|
+
}
|
|
2102
|
+
var isDeniedTemplate = (name) => CODE_TEMPLATE_DENY.includes(name);
|
|
2103
|
+
function isDeniedByRouteTable(path, routeTable) {
|
|
2104
|
+
if (routeTable === void 0) return false;
|
|
2105
|
+
return Object.entries(routeTable).some(([name, template]) => {
|
|
2106
|
+
if (!isDeniedTemplate(name) || typeof template !== "string") return false;
|
|
2107
|
+
const base = template.replace(/\/+$/, "");
|
|
2108
|
+
return matchesTemplate(path, template) || path.startsWith(`${base}/`);
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
1700
2111
|
function isCodeRoute(pathname, routes) {
|
|
1701
2112
|
if (pathname === void 0) return false;
|
|
2113
|
+
if (routes.templateName !== void 0 && isDeniedTemplate(routes.templateName)) return false;
|
|
1702
2114
|
const path = normalizePath(pathname);
|
|
1703
2115
|
if (path === null) return false;
|
|
2116
|
+
if (isDeniedByRouteTable(path, routes.routeTable)) return false;
|
|
1704
2117
|
if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
|
|
1705
2118
|
if (path === "/") return true;
|
|
1706
|
-
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some(
|
|
2119
|
+
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES, ...routes.allow ?? []].some(
|
|
1707
2120
|
(template) => matchesTemplate(path, template)
|
|
1708
2121
|
);
|
|
1709
2122
|
}
|
|
@@ -1715,13 +2128,13 @@ function markCodeEmitted() {
|
|
|
1715
2128
|
}
|
|
1716
2129
|
|
|
1717
2130
|
// src/code/code-widget.tsx
|
|
1718
|
-
import { jsx as
|
|
2131
|
+
import { jsx as jsx25, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1719
2132
|
var SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
1720
2133
|
var CUSTOM_TYPE = /^custom\.[a-z][a-z0-9-]{0,63}$/;
|
|
1721
2134
|
var SCRIPT_ORIGIN = /^https:\/\/[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[0-9]{1,5})?$/i;
|
|
1722
2135
|
var SITE_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
1723
2136
|
var MAX_INPUT_CHARS = 2e5;
|
|
1724
|
-
var
|
|
2137
|
+
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1725
2138
|
var checked = /* @__PURE__ */ new WeakMap();
|
|
1726
2139
|
function check(raw, registry) {
|
|
1727
2140
|
let perRegistry = checked.get(raw);
|
|
@@ -1755,7 +2168,7 @@ function verify(raw, registry) {
|
|
|
1755
2168
|
return { status: "ok", snapshot: raw, template };
|
|
1756
2169
|
}
|
|
1757
2170
|
function codeScriptUrl(runtime, jsHash) {
|
|
1758
|
-
if (!
|
|
2171
|
+
if (!isRecord3(runtime) || runtime.enabled !== true) return null;
|
|
1759
2172
|
const { scriptOrigin, codeSiteId } = runtime;
|
|
1760
2173
|
if (typeof scriptOrigin !== "string" || !SCRIPT_ORIGIN.test(scriptOrigin)) return null;
|
|
1761
2174
|
if (typeof codeSiteId !== "string" || !SITE_ID.test(codeSiteId)) return null;
|
|
@@ -1778,21 +2191,21 @@ var BADGE = {
|
|
|
1778
2191
|
function runs(props, jsHash) {
|
|
1779
2192
|
const { code, edit, interactive } = props;
|
|
1780
2193
|
if (edit !== void 0 || interactive === false || code === void 0 || code.preview === true) return null;
|
|
1781
|
-
if (!isCodeRoute(code.pathname, code.routes)) return null;
|
|
2194
|
+
if (!isCodeRoute(code.pathname, { ...code.routes, templateName: code.templateName })) return null;
|
|
1782
2195
|
return codeScriptUrl(code.runtime, jsHash);
|
|
1783
2196
|
}
|
|
1784
2197
|
function CodeWidget(props) {
|
|
1785
2198
|
const { node, snapshot, registry, edit, anchor, copyAnchor, entrance } = props;
|
|
1786
2199
|
const result = check(snapshot, registry);
|
|
1787
2200
|
if (result.status !== "ok") {
|
|
1788
|
-
return result.status === "disabled" && edit !== void 0 ? /* @__PURE__ */
|
|
2201
|
+
return result.status === "disabled" && edit !== void 0 ? /* @__PURE__ */ jsx25(NodeWrapper, { id: node.id, part: "widget", type: node.type, className: "tb-w", edit, children: /* @__PURE__ */ jsx25("div", { className: "tb-missing", children: "This code widget is disabled" }) }) : null;
|
|
1789
2202
|
}
|
|
1790
2203
|
const template = compileTemplate(result.template, registry);
|
|
1791
2204
|
const src = runs(props, result.snapshot.jsHash);
|
|
1792
2205
|
if (src !== null) markCodeEmitted();
|
|
1793
2206
|
const env = newEnv({ settings: props.props, data: props.data, locale: props.locale, mediaOrigin: props.mediaOrigin, budget: new RenderBudget() });
|
|
1794
2207
|
const label = `${node.type}@${String(node.v)}`;
|
|
1795
|
-
return /* @__PURE__ */
|
|
2208
|
+
return /* @__PURE__ */ jsxs16(
|
|
1796
2209
|
NodeWrapper,
|
|
1797
2210
|
{
|
|
1798
2211
|
id: node.id,
|
|
@@ -1806,13 +2219,13 @@ function CodeWidget(props) {
|
|
|
1806
2219
|
entrance,
|
|
1807
2220
|
attributes: src === null ? { "data-b-code-inert": "" } : { "data-b-code": result.snapshot.jsHash },
|
|
1808
2221
|
children: [
|
|
1809
|
-
/* @__PURE__ */
|
|
1810
|
-
template.css === "" ? null : /* @__PURE__ */
|
|
2222
|
+
/* @__PURE__ */ jsx25(PartBoundary, { label, children: /* @__PURE__ */ jsxs16(Suspense2, { fallback: null, children: [
|
|
2223
|
+
template.css === "" ? null : /* @__PURE__ */ jsx25(CustomCss, { css: template.css }),
|
|
1811
2224
|
renderTemplate(template.ast, env)
|
|
1812
2225
|
] }) }),
|
|
1813
|
-
src === null && (edit !== void 0 || props.code?.preview === true) ? /* @__PURE__ */
|
|
1814
|
-
src === null ? null : /* @__PURE__ */
|
|
1815
|
-
src === null ? null : /* @__PURE__ */
|
|
2226
|
+
src === null && (edit !== void 0 || props.code?.preview === true) ? /* @__PURE__ */ jsx25("div", { "data-b-code-badge": "", style: BADGE, children: "Runs on your store" }) : null,
|
|
2227
|
+
src === null ? null : /* @__PURE__ */ jsx25(CodeInput, { props: props.props, data: props.data, label }),
|
|
2228
|
+
src === null ? null : /* @__PURE__ */ jsx25("script", { async: true, src })
|
|
1816
2229
|
]
|
|
1817
2230
|
}
|
|
1818
2231
|
);
|
|
@@ -1829,7 +2242,7 @@ function CodeInput({ props, data, label }) {
|
|
|
1829
2242
|
warnOnce(`code-input:${label}`, `The input of ${label} cannot be written as JSON; it gets none`);
|
|
1830
2243
|
json = jsonForScript({ props: {}, data: {} });
|
|
1831
2244
|
}
|
|
1832
|
-
return /* @__PURE__ */
|
|
2245
|
+
return /* @__PURE__ */ jsx25("script", { type: "application/json", "data-b-code-input": "", children: json });
|
|
1833
2246
|
}
|
|
1834
2247
|
|
|
1835
2248
|
// src/css-compiler.ts
|
|
@@ -1838,7 +2251,7 @@ import {
|
|
|
1838
2251
|
resolveColumnProps,
|
|
1839
2252
|
resolveColumnWidths,
|
|
1840
2253
|
resolveResponsive as resolveResponsive2,
|
|
1841
|
-
safeUrl as
|
|
2254
|
+
safeUrl as safeUrl10,
|
|
1842
2255
|
validateSettingValue,
|
|
1843
2256
|
wrapColumnRows
|
|
1844
2257
|
} from "@usethrottle/builder-schema";
|
|
@@ -1947,7 +2360,7 @@ function backgroundDecls(out, bg, assets, mediaOrigin) {
|
|
|
1947
2360
|
if (bg.position !== void 0 && BG_POSITION.has(bg.position)) put(out, "--tb-bgpos", bg.position);
|
|
1948
2361
|
if (bg.size !== void 0 && BG_SIZE.has(bg.size)) put(out, "--tb-bgsize", bg.size);
|
|
1949
2362
|
const asset = bg.image === void 0 || assets === void 0 || !Object.hasOwn(assets, bg.image) ? void 0 : assets[bg.image];
|
|
1950
|
-
if (asset !== void 0 &&
|
|
2363
|
+
if (asset !== void 0 && safeUrl10(asset.url, "src", { mediaOrigin }) !== null && URL_QUOTE_SAFE.test(asset.url)) {
|
|
1951
2364
|
out.set("--tb-bgimg", `url("${asset.url}")`);
|
|
1952
2365
|
}
|
|
1953
2366
|
}
|
|
@@ -2055,22 +2468,22 @@ function compileResponsiveCss(doc, registry, assets = doc.assets, mediaOrigin =
|
|
|
2055
2468
|
}
|
|
2056
2469
|
|
|
2057
2470
|
// src/interactions/accordion.tsx
|
|
2058
|
-
import { jsx as
|
|
2471
|
+
import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2059
2472
|
function Accordion({
|
|
2060
2473
|
id,
|
|
2061
2474
|
panels,
|
|
2062
2475
|
multiple,
|
|
2063
2476
|
openFirst
|
|
2064
2477
|
}) {
|
|
2065
|
-
return /* @__PURE__ */
|
|
2478
|
+
return /* @__PURE__ */ jsx26("div", { className: "tb-accordion", children: panels.map((panel, i) => /* @__PURE__ */ jsxs17(
|
|
2066
2479
|
"details",
|
|
2067
2480
|
{
|
|
2068
2481
|
className: "tb-acc-item",
|
|
2069
2482
|
...multiple ? {} : { name: `${id}-acc` },
|
|
2070
2483
|
...openFirst && i === 0 ? { open: true } : {},
|
|
2071
2484
|
children: [
|
|
2072
|
-
/* @__PURE__ */
|
|
2073
|
-
/* @__PURE__ */
|
|
2485
|
+
/* @__PURE__ */ jsx26("summary", { className: "tb-acc-sum", children: panel.title }),
|
|
2486
|
+
/* @__PURE__ */ jsx26("div", { className: "tb-acc-body", children: panel.node })
|
|
2074
2487
|
]
|
|
2075
2488
|
},
|
|
2076
2489
|
panel.key
|
|
@@ -2078,13 +2491,13 @@ function Accordion({
|
|
|
2078
2491
|
}
|
|
2079
2492
|
|
|
2080
2493
|
// src/interactions/carousel.tsx
|
|
2081
|
-
import { jsx as
|
|
2494
|
+
import { jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2082
2495
|
function Carousel({
|
|
2083
2496
|
panels,
|
|
2084
2497
|
autoplayMs,
|
|
2085
2498
|
loop
|
|
2086
2499
|
}) {
|
|
2087
|
-
return /* @__PURE__ */
|
|
2500
|
+
return /* @__PURE__ */ jsxs18(
|
|
2088
2501
|
"div",
|
|
2089
2502
|
{
|
|
2090
2503
|
className: "tb-car",
|
|
@@ -2095,7 +2508,7 @@ function Carousel({
|
|
|
2095
2508
|
...loop ? { "data-b-loop": "" } : {},
|
|
2096
2509
|
...autoplayMs === null ? {} : { "data-b-autoplay": String(autoplayMs) },
|
|
2097
2510
|
children: [
|
|
2098
|
-
/* @__PURE__ */
|
|
2511
|
+
/* @__PURE__ */ jsx27("div", { className: "tb-car-track", tabIndex: 0, children: panels.map((panel, i) => /* @__PURE__ */ jsx27(
|
|
2099
2512
|
"div",
|
|
2100
2513
|
{
|
|
2101
2514
|
className: "tb-slide",
|
|
@@ -2106,21 +2519,137 @@ function Carousel({
|
|
|
2106
2519
|
},
|
|
2107
2520
|
panel.key
|
|
2108
2521
|
)) }),
|
|
2109
|
-
/* @__PURE__ */
|
|
2110
|
-
/* @__PURE__ */
|
|
2111
|
-
autoplayMs === null ? null : /* @__PURE__ */
|
|
2112
|
-
/* @__PURE__ */
|
|
2522
|
+
/* @__PURE__ */ jsxs18("div", { className: "tb-car-ctrl", children: [
|
|
2523
|
+
/* @__PURE__ */ jsx27("button", { type: "button", className: "tb-car-btn", "data-b-act": "prev", "aria-label": "Previous slide", children: "\u2039" }),
|
|
2524
|
+
autoplayMs === null ? null : /* @__PURE__ */ jsx27("button", { type: "button", className: "tb-car-btn tb-car-pause", "data-b-act": "pause", hidden: true, children: "Pause" }),
|
|
2525
|
+
/* @__PURE__ */ jsx27("button", { type: "button", className: "tb-car-btn", "data-b-act": "next", "aria-label": "Next slide", children: "\u203A" })
|
|
2113
2526
|
] })
|
|
2114
2527
|
]
|
|
2115
2528
|
}
|
|
2116
2529
|
);
|
|
2117
2530
|
}
|
|
2118
2531
|
|
|
2532
|
+
// src/interactions/frame.tsx
|
|
2533
|
+
import { useEffect as useEffect4 } from "react";
|
|
2534
|
+
|
|
2535
|
+
// src/interactions/drawer.ts
|
|
2536
|
+
var holds3 = 0;
|
|
2537
|
+
var release2;
|
|
2538
|
+
var rootOf = (el) => el?.closest("[data-tb-collapse]") ?? null;
|
|
2539
|
+
function setOpen(root, open) {
|
|
2540
|
+
const opener = root.querySelector("[data-tb-drawer-open]");
|
|
2541
|
+
const body = root.querySelector(".tb-fr-body");
|
|
2542
|
+
if (open) root.setAttribute("data-open", "true");
|
|
2543
|
+
else root.removeAttribute("data-open");
|
|
2544
|
+
opener?.setAttribute("aria-expanded", String(open));
|
|
2545
|
+
if (body !== null) {
|
|
2546
|
+
if (open) {
|
|
2547
|
+
body.setAttribute("role", "dialog");
|
|
2548
|
+
body.setAttribute("aria-modal", "true");
|
|
2549
|
+
const name = opener?.textContent?.trim();
|
|
2550
|
+
if (name !== void 0 && name !== "") body.setAttribute("aria-label", name);
|
|
2551
|
+
} else {
|
|
2552
|
+
body.removeAttribute("role");
|
|
2553
|
+
body.removeAttribute("aria-modal");
|
|
2554
|
+
body.removeAttribute("aria-label");
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
if (open) root.querySelector("[data-tb-drawer-close]")?.focus();
|
|
2558
|
+
else opener?.focus();
|
|
2559
|
+
}
|
|
2560
|
+
var openRoot = () => document.querySelector("[data-tb-collapse][data-open=true]");
|
|
2561
|
+
function install2() {
|
|
2562
|
+
const click = (event) => {
|
|
2563
|
+
const el = event.target instanceof Element ? event.target : null;
|
|
2564
|
+
if (el === null) return;
|
|
2565
|
+
const root = rootOf(el);
|
|
2566
|
+
if (root === null) return;
|
|
2567
|
+
if (el.closest("[data-tb-drawer-open]") !== null) setOpen(root, root.getAttribute("data-open") !== "true");
|
|
2568
|
+
else if (el.closest("[data-tb-drawer-close]") !== null) setOpen(root, false);
|
|
2569
|
+
else if (root.getAttribute("data-open") === "true" && el.closest(".tb-fr-body a[href]") !== null) setOpen(root, false);
|
|
2570
|
+
};
|
|
2571
|
+
const keydown = (event) => {
|
|
2572
|
+
const root = openRoot();
|
|
2573
|
+
if (root === null) return;
|
|
2574
|
+
if (event.key === "Escape") {
|
|
2575
|
+
setOpen(root, false);
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2578
|
+
const body = root.querySelector(".tb-fr-body");
|
|
2579
|
+
if (body !== null) trapTab(event, focusablesOf(body));
|
|
2580
|
+
};
|
|
2581
|
+
document.addEventListener("click", click);
|
|
2582
|
+
document.addEventListener("keydown", keydown);
|
|
2583
|
+
return () => {
|
|
2584
|
+
document.removeEventListener("click", click);
|
|
2585
|
+
document.removeEventListener("keydown", keydown);
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
function startDrawer() {
|
|
2589
|
+
if (holds3++ === 0) release2 = install2();
|
|
2590
|
+
let done = false;
|
|
2591
|
+
return () => {
|
|
2592
|
+
if (done) return;
|
|
2593
|
+
done = true;
|
|
2594
|
+
if (--holds3 === 0) {
|
|
2595
|
+
release2?.();
|
|
2596
|
+
release2 = void 0;
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
// src/interactions/frame.tsx
|
|
2602
|
+
import { Fragment as Fragment17, jsx as jsx28, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2603
|
+
var SECTION_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
2604
|
+
var TABLET_PX = 1024;
|
|
2605
|
+
var PHONE_PX = 768;
|
|
2606
|
+
var isRecord4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2607
|
+
function frameOf(section) {
|
|
2608
|
+
const raw = section.frame;
|
|
2609
|
+
if (!isRecord4(raw)) return null;
|
|
2610
|
+
const sticky = raw.sticky === "top";
|
|
2611
|
+
const c = raw.collapse;
|
|
2612
|
+
let collapse = null;
|
|
2613
|
+
if (isRecord4(c) && SECTION_ID_RE.test(section.id)) {
|
|
2614
|
+
const at = typeof c.belowPx === "number" && Number.isInteger(c.belowPx) && c.belowPx >= 768 && c.belowPx <= 1280 ? c.belowPx : c.below === "tablet" ? TABLET_PX : c.below === "phone" ? PHONE_PX : null;
|
|
2615
|
+
if (at !== null) collapse = { px: (at - 0.02).toFixed(2), label: isRecord4(c.label) ? c.label : {} };
|
|
2616
|
+
}
|
|
2617
|
+
return sticky || collapse !== null ? { sticky, collapse } : null;
|
|
2618
|
+
}
|
|
2619
|
+
var FRAME_CSS = `@layer throttle{
|
|
2620
|
+
.tb-sticky{position:sticky;inset-block-start:0;z-index:40}
|
|
2621
|
+
[data-throttle-part=builder-header]:has(.tb-sticky){position:sticky;inset-block-start:0;z-index:40}
|
|
2622
|
+
.tb-fr-open,.tb-fr-close{display:none;align-items:center;justify-content:center;min-inline-size:44px;min-block-size:44px;padding:0 var(--tb-space-s);border:0;background:transparent;color:inherit;font:inherit;cursor:pointer}
|
|
2623
|
+
.tb-fr-open:focus-visible,.tb-fr-close:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
2624
|
+
}`;
|
|
2625
|
+
function collapseCss(sectionId, px2) {
|
|
2626
|
+
const s = `[data-b-id="${sectionId}"]`;
|
|
2627
|
+
return `@layer throttle{@media (max-width: ${px2}px){@media (scripting: enabled){${s} .tb-fr-open{display:inline-flex}${s} .tb-fr-body{display:none}${s} .tb-fr[data-open=true] .tb-fr-body{display:block;position:fixed;inset:0;z-index:60;overflow:auto;padding:4.5rem var(--tb-space-m) var(--tb-space-m);background:var(--tb-color-background,#fff);color:var(--tb-color-foreground,#111)}${s} .tb-fr[data-open=true] .tb-fr-close{display:inline-flex;position:fixed;inset-block-start:var(--tb-space-s);inset-inline-end:var(--tb-space-s);z-index:61}}}}`;
|
|
2628
|
+
}
|
|
2629
|
+
function DrawerRuntime() {
|
|
2630
|
+
useEffect4(() => startDrawer(), []);
|
|
2631
|
+
return null;
|
|
2632
|
+
}
|
|
2633
|
+
function Collapse(props) {
|
|
2634
|
+
const { sectionId, id, px: px2, label, children } = props;
|
|
2635
|
+
return /* @__PURE__ */ jsxs19(Fragment17, { children: [
|
|
2636
|
+
/* @__PURE__ */ jsx28("style", { href: `tb-fr-${sectionId}`, precedence: "throttle", children: collapseCss(sectionId, px2) }),
|
|
2637
|
+
/* @__PURE__ */ jsxs19("div", { className: "tb-fr", "data-tb-collapse": "", children: [
|
|
2638
|
+
/* @__PURE__ */ jsx28("button", { type: "button", className: "tb-fr-open", "data-tb-drawer-open": "", "aria-expanded": "false", "aria-controls": id, children: label }),
|
|
2639
|
+
/* @__PURE__ */ jsxs19("div", { id, className: "tb-fr-body", children: [
|
|
2640
|
+
/* @__PURE__ */ jsx28("button", { type: "button", className: "tb-fr-close", "data-tb-drawer-close": "", "aria-label": "Close", children: /* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: "\xD7" }) }),
|
|
2641
|
+
children
|
|
2642
|
+
] }),
|
|
2643
|
+
/* @__PURE__ */ jsx28(DrawerRuntime, {})
|
|
2644
|
+
] })
|
|
2645
|
+
] });
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2119
2648
|
// src/interactions/tabs.tsx
|
|
2120
|
-
import { jsx as
|
|
2649
|
+
import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2121
2650
|
function Tabs({ id, panels }) {
|
|
2122
|
-
return /* @__PURE__ */
|
|
2123
|
-
/* @__PURE__ */
|
|
2651
|
+
return /* @__PURE__ */ jsxs20("div", { className: "tb-tabs", children: [
|
|
2652
|
+
/* @__PURE__ */ jsx29("div", { role: "tablist", className: "tb-tablist", "data-b-tabs": "", children: panels.map((panel, i) => /* @__PURE__ */ jsx29(
|
|
2124
2653
|
"button",
|
|
2125
2654
|
{
|
|
2126
2655
|
type: "button",
|
|
@@ -2134,7 +2663,7 @@ function Tabs({ id, panels }) {
|
|
|
2134
2663
|
},
|
|
2135
2664
|
panel.key
|
|
2136
2665
|
)) }),
|
|
2137
|
-
panels.map((panel, i) => /* @__PURE__ */
|
|
2666
|
+
panels.map((panel, i) => /* @__PURE__ */ jsxs20(
|
|
2138
2667
|
"div",
|
|
2139
2668
|
{
|
|
2140
2669
|
role: "tabpanel",
|
|
@@ -2143,7 +2672,7 @@ function Tabs({ id, panels }) {
|
|
|
2143
2672
|
"aria-labelledby": `${id}-t${String(i)}`,
|
|
2144
2673
|
tabIndex: 0,
|
|
2145
2674
|
children: [
|
|
2146
|
-
/* @__PURE__ */
|
|
2675
|
+
/* @__PURE__ */ jsx29("p", { className: "tb-panel-title", children: panel.title }),
|
|
2147
2676
|
panel.node
|
|
2148
2677
|
]
|
|
2149
2678
|
},
|
|
@@ -2153,19 +2682,94 @@ function Tabs({ id, panels }) {
|
|
|
2153
2682
|
}
|
|
2154
2683
|
|
|
2155
2684
|
// src/interactions/toggle.tsx
|
|
2156
|
-
import { jsx as
|
|
2685
|
+
import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2157
2686
|
function Toggle({
|
|
2158
2687
|
labelOpen,
|
|
2159
2688
|
labelClosed,
|
|
2160
2689
|
startOpen,
|
|
2161
2690
|
children
|
|
2162
2691
|
}) {
|
|
2163
|
-
return /* @__PURE__ */
|
|
2164
|
-
/* @__PURE__ */
|
|
2165
|
-
/* @__PURE__ */
|
|
2166
|
-
/* @__PURE__ */
|
|
2692
|
+
return /* @__PURE__ */ jsxs21("details", { className: "tb-toggle", ...startOpen ? { open: true } : {}, children: [
|
|
2693
|
+
/* @__PURE__ */ jsxs21("summary", { className: "tb-toggle-sum", children: [
|
|
2694
|
+
/* @__PURE__ */ jsx30("span", { className: "tb-toggle-closed", children: labelClosed }),
|
|
2695
|
+
/* @__PURE__ */ jsx30("span", { className: "tb-toggle-open", children: labelOpen })
|
|
2167
2696
|
] }),
|
|
2168
|
-
/* @__PURE__ */
|
|
2697
|
+
/* @__PURE__ */ jsx30("div", { className: "tb-row", children })
|
|
2698
|
+
] });
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
// src/show-when.tsx
|
|
2702
|
+
import { useEffect as useEffect5, useState as useState4 } from "react";
|
|
2703
|
+
import { SPACING_TOKENS, resolveResponsive as resolveResponsive3, showWhenSchema } from "@usethrottle/builder-schema";
|
|
2704
|
+
import { Fragment as Fragment18, jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2705
|
+
function parseShowWhen(value) {
|
|
2706
|
+
if (value === void 0) return null;
|
|
2707
|
+
const parsed2 = showWhenSchema.safeParse(value);
|
|
2708
|
+
if (!parsed2.success) return null;
|
|
2709
|
+
return parsed2.data.audience === "all" && parsed2.data.cart === "any" ? null : parsed2.data;
|
|
2710
|
+
}
|
|
2711
|
+
function showWhenState(when, viewer, mounted) {
|
|
2712
|
+
if (!mounted) return when.audience === "signed-in" || when.cart === "has-items" ? "placeholder" : "show";
|
|
2713
|
+
const known = viewer === null ? { signedIn: null, cartItemCount: null } : viewer ?? { signedIn: false, cartItemCount: 0 };
|
|
2714
|
+
let pending = false;
|
|
2715
|
+
if (when.audience !== "all") {
|
|
2716
|
+
if (known.signedIn === null) pending = pending || when.audience === "signed-in";
|
|
2717
|
+
else if ((known.signedIn ? "signed-in" : "guest") !== when.audience) return "hide";
|
|
2718
|
+
}
|
|
2719
|
+
if (when.cart !== "any") {
|
|
2720
|
+
if (known.cartItemCount === null) pending = pending || when.cart === "has-items";
|
|
2721
|
+
else if ((known.cartItemCount > 0 ? "has-items" : "empty") !== when.cart) return "hide";
|
|
2722
|
+
}
|
|
2723
|
+
return pending ? "placeholder" : "show";
|
|
2724
|
+
}
|
|
2725
|
+
var DEVICES3 = ["desktop", "tablet", "phone"];
|
|
2726
|
+
var isRec = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2727
|
+
var list = (v) => Array.isArray(v) ? v.filter(isRec) : [];
|
|
2728
|
+
function lengthOf(value) {
|
|
2729
|
+
if (typeof value === "number") return Number.isFinite(value) && value > 0 ? `${String(Math.min(Math.round(value), 2e3))}px` : null;
|
|
2730
|
+
if (typeof value === "string" && value !== "none" && SPACING_TOKENS.includes(value)) return `var(--tb-space-${value})`;
|
|
2731
|
+
return null;
|
|
2732
|
+
}
|
|
2733
|
+
function heightAt(node, device) {
|
|
2734
|
+
const resolved = resolveResponsive3(isRec(node.props) ? node.props : {}, node.responsive, device);
|
|
2735
|
+
if (resolved.hidden === true) return null;
|
|
2736
|
+
const own = lengthOf(resolved.minHeight) ?? lengthOf(resolved.height);
|
|
2737
|
+
if (own !== null) return own;
|
|
2738
|
+
const columns = list(node.columns).map((c) => heightAt(c, device)).filter((h) => h !== null);
|
|
2739
|
+
if (columns.length > 0) return columns.length === 1 ? columns[0] : `max(${columns.join(",")})`;
|
|
2740
|
+
const stacked = list(node.children).map((c) => heightAt(c, device)).filter((h) => h !== null);
|
|
2741
|
+
if (stacked.length > 0) return stacked.length === 1 ? stacked[0] : `calc(${stacked.join(" + ")})`;
|
|
2742
|
+
return null;
|
|
2743
|
+
}
|
|
2744
|
+
function reservedHeights(node) {
|
|
2745
|
+
const found = DEVICES3.map((device) => [device, heightAt(node, device)]);
|
|
2746
|
+
if (found.every(([, h]) => h === null)) return {};
|
|
2747
|
+
return Object.fromEntries(found.map(([device, h]) => [device, h ?? "0px"]));
|
|
2748
|
+
}
|
|
2749
|
+
var SHOW_WHEN_CSS = "@layer throttle{.tb-sw{visibility:hidden;pointer-events:none;min-block-size:var(--tb-sw-h,0)}@media (max-width:1024px){.tb-sw{min-block-size:var(--tb-sw-ht,var(--tb-sw-h,0))}}@media (max-width:767px){.tb-sw{min-block-size:var(--tb-sw-hp,var(--tb-sw-ht,var(--tb-sw-h,0)))}}}";
|
|
2750
|
+
function ShowWhen({ when, heights, children }) {
|
|
2751
|
+
const viewer = useViewer();
|
|
2752
|
+
const [mounted, setMounted] = useState4(false);
|
|
2753
|
+
useEffect5(() => setMounted(true), []);
|
|
2754
|
+
const state = showWhenState(when, viewer, mounted);
|
|
2755
|
+
if (state === "show") return children;
|
|
2756
|
+
if (state === "hide") return null;
|
|
2757
|
+
const style = {
|
|
2758
|
+
...heights.desktop === void 0 ? {} : { "--tb-sw-h": heights.desktop },
|
|
2759
|
+
...heights.tablet === void 0 ? {} : { "--tb-sw-ht": heights.tablet },
|
|
2760
|
+
...heights.phone === void 0 ? {} : { "--tb-sw-hp": heights.phone }
|
|
2761
|
+
};
|
|
2762
|
+
return /* @__PURE__ */ jsxs22(Fragment18, { children: [
|
|
2763
|
+
/* @__PURE__ */ jsx31("style", { href: "tb-showwhen", precedence: "throttle", children: SHOW_WHEN_CSS }),
|
|
2764
|
+
/* @__PURE__ */ jsx31(
|
|
2765
|
+
"div",
|
|
2766
|
+
{
|
|
2767
|
+
className: "tb-sw",
|
|
2768
|
+
"aria-hidden": "true",
|
|
2769
|
+
"data-b-showwhen": when.audience === "signed-in" ? "signed-in" : "has-items",
|
|
2770
|
+
...Object.keys(style).length === 0 ? {} : { style }
|
|
2771
|
+
}
|
|
2772
|
+
)
|
|
2169
2773
|
] });
|
|
2170
2774
|
}
|
|
2171
2775
|
|
|
@@ -2191,8 +2795,8 @@ var BASE_CSS = `@layer throttle{
|
|
|
2191
2795
|
}`;
|
|
2192
2796
|
|
|
2193
2797
|
// src/renderer.tsx
|
|
2194
|
-
import { jsx as
|
|
2195
|
-
var
|
|
2798
|
+
import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2799
|
+
var DEVICES4 = ["desktop", "tablet", "phone"];
|
|
2196
2800
|
var COMMON_BY_KEY2 = new Map(COMMON_WIDGET_SETTINGS2.map((f) => [f.key, f]));
|
|
2197
2801
|
var withCustomCache = /* @__PURE__ */ new WeakMap();
|
|
2198
2802
|
function registryFor(doc, base) {
|
|
@@ -2219,7 +2823,7 @@ function registryFor(doc, base) {
|
|
|
2219
2823
|
}
|
|
2220
2824
|
return registry;
|
|
2221
2825
|
}
|
|
2222
|
-
var
|
|
2826
|
+
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2223
2827
|
function pickLocale(value, locale) {
|
|
2224
2828
|
const lang = locale.split("-")[0] ?? locale;
|
|
2225
2829
|
for (const key of [locale, lang, "en"]) {
|
|
@@ -2230,25 +2834,36 @@ function pickLocale(value, locale) {
|
|
|
2230
2834
|
return "";
|
|
2231
2835
|
}
|
|
2232
2836
|
function onOrigin(asset, mediaOrigin) {
|
|
2233
|
-
if (
|
|
2234
|
-
return { ...asset, variants: asset.variants.filter((v) =>
|
|
2837
|
+
if (safeUrl11(asset.url, "src", { mediaOrigin }) === null) return null;
|
|
2838
|
+
return { ...asset, variants: asset.variants.filter((v) => safeUrl11(v.url, "src", { mediaOrigin }) !== null) };
|
|
2839
|
+
}
|
|
2840
|
+
function prepareItem(field, item, ctx) {
|
|
2841
|
+
if (!isRecord5(item)) return item;
|
|
2842
|
+
const out = { ...item };
|
|
2843
|
+
for (const itemField of field.itemFields ?? []) {
|
|
2844
|
+
if (!Object.hasOwn(out, itemField.key)) continue;
|
|
2845
|
+
const prepared = prepare(itemField, out[itemField.key], ctx);
|
|
2846
|
+
out[itemField.key] = prepared;
|
|
2847
|
+
}
|
|
2848
|
+
return out;
|
|
2235
2849
|
}
|
|
2236
2850
|
function prepare(field, value, ctx) {
|
|
2237
2851
|
if (field === void 0 || value === null) return value;
|
|
2238
|
-
if (field.
|
|
2852
|
+
if (field.control === "list" && Array.isArray(value)) return value.map((item) => prepareItem(field, item, ctx));
|
|
2853
|
+
if (field.translatable === true && isRecord5(value)) return pickLocale(value, ctx.locale);
|
|
2239
2854
|
if (field.control === "image" && typeof value === "string") {
|
|
2240
2855
|
const asset = Object.hasOwn(ctx.assets, value) ? ctx.assets[value] : void 0;
|
|
2241
2856
|
return asset === void 0 ? null : onOrigin(asset, ctx.mediaOrigin);
|
|
2242
2857
|
}
|
|
2243
|
-
if (field.control === "link" &&
|
|
2244
|
-
const
|
|
2245
|
-
const raw = ctx.resolveLink?.(
|
|
2246
|
-
return { ...value, href:
|
|
2858
|
+
if (field.control === "link" && isRecord5(value) && typeof value.kind === "string") {
|
|
2859
|
+
const target2 = value;
|
|
2860
|
+
const raw = ctx.resolveLink?.(target2) ?? (target2.kind === "url" ? target2.href : null);
|
|
2861
|
+
return { ...value, href: safeUrl11(raw, "href", { mediaOrigin: ctx.mediaOrigin }) };
|
|
2247
2862
|
}
|
|
2248
2863
|
return value;
|
|
2249
2864
|
}
|
|
2250
2865
|
function storedLinkPart(value) {
|
|
2251
|
-
if (!
|
|
2866
|
+
if (!isRecord5(value) || value.kind !== "page") return value;
|
|
2252
2867
|
const { slug: _slug, href: _href, ...stored } = value;
|
|
2253
2868
|
void _slug;
|
|
2254
2869
|
void _href;
|
|
@@ -2257,7 +2872,7 @@ function storedLinkPart(value) {
|
|
|
2257
2872
|
function settingsAt(node, fields, device, ctx) {
|
|
2258
2873
|
const base = {};
|
|
2259
2874
|
for (const field of fields.values()) base[field.key] = field.default;
|
|
2260
|
-
const resolved =
|
|
2875
|
+
const resolved = resolveResponsive4({ ...base, ...node.props }, node.responsive, device);
|
|
2261
2876
|
const out = {};
|
|
2262
2877
|
for (const [key, value] of Object.entries(resolved)) {
|
|
2263
2878
|
const field = fields.get(key);
|
|
@@ -2271,7 +2886,7 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
2271
2886
|
function variantsOf(node, def, fields, ctx) {
|
|
2272
2887
|
const markup = [...fields.values()].filter((f) => f.output === "markup").map((f) => f.key);
|
|
2273
2888
|
const groups = /* @__PURE__ */ new Map();
|
|
2274
|
-
for (const device of
|
|
2889
|
+
for (const device of DEVICES4) {
|
|
2275
2890
|
const props = settingsAt(node, fields, device, ctx);
|
|
2276
2891
|
const signature = stable(markup.map((key) => props[key] ?? null));
|
|
2277
2892
|
const group = groups.get(signature);
|
|
@@ -2282,8 +2897,8 @@ function variantsOf(node, def, fields, ctx) {
|
|
|
2282
2897
|
return [...groups.values()];
|
|
2283
2898
|
}
|
|
2284
2899
|
function hiddenEverywhere(props, responsive) {
|
|
2285
|
-
return
|
|
2286
|
-
(device) =>
|
|
2900
|
+
return DEVICES4.every(
|
|
2901
|
+
(device) => resolveResponsive4({ hidden: props.hidden ?? false }, responsive, device).hidden === true
|
|
2287
2902
|
);
|
|
2288
2903
|
}
|
|
2289
2904
|
var variantClass = (variant) => `tb-v ${variant.devices.map((d) => `tb-only-${d}`).join(" ")}`;
|
|
@@ -2299,7 +2914,7 @@ function renderCodeWidget(node, snapshot, ctx, registry) {
|
|
|
2299
2914
|
}
|
|
2300
2915
|
const props = settingsAt(node, fields, "desktop", ctx);
|
|
2301
2916
|
const anchor = props.anchor;
|
|
2302
|
-
return /* @__PURE__ */
|
|
2917
|
+
return /* @__PURE__ */ jsx32(
|
|
2303
2918
|
CodeWidget,
|
|
2304
2919
|
{
|
|
2305
2920
|
node,
|
|
@@ -2328,7 +2943,7 @@ function renderWidget(node, ctx, registry) {
|
|
|
2328
2943
|
if (isDevelopment()) {
|
|
2329
2944
|
warnOnce(`missing:${node.type}@${String(node.v)}`, `Unknown widget ${node.type} v${String(node.v)}; rendering nothing for it`);
|
|
2330
2945
|
}
|
|
2331
|
-
return /* @__PURE__ */
|
|
2946
|
+
return /* @__PURE__ */ jsx32(NodeWrapper, { id: node.id, part: "widget", type: node.type, className: "tb-w", missing: true, children: ctx.edit !== void 0 && /* @__PURE__ */ jsx32("div", { className: "tb-missing", children: "Widget unavailable: update @usethrottle/storefront-react" }) });
|
|
2332
2947
|
}
|
|
2333
2948
|
if (ctx.edit === void 0 && hiddenEverywhere(node.props, node.responsive)) return null;
|
|
2334
2949
|
const fields = new Map([...COMMON_BY_KEY2, ...def.settings.map((f) => [f.key, f])]);
|
|
@@ -2341,21 +2956,22 @@ function renderWidget(node, ctx, registry) {
|
|
|
2341
2956
|
}
|
|
2342
2957
|
const custom = node.type.startsWith("custom.");
|
|
2343
2958
|
const edit = ctx.edit;
|
|
2344
|
-
|
|
2959
|
+
const copies = variants.map((variant, index) => {
|
|
2345
2960
|
const anchor = variant.props.anchor;
|
|
2346
|
-
return /* @__PURE__ */
|
|
2961
|
+
return /* @__PURE__ */ jsx32(
|
|
2347
2962
|
NodeWrapper,
|
|
2348
2963
|
{
|
|
2349
2964
|
id: node.id,
|
|
2350
2965
|
part: "widget",
|
|
2351
2966
|
type: node.type,
|
|
2352
2967
|
custom,
|
|
2968
|
+
cssClass: node.cssClass,
|
|
2353
2969
|
edit,
|
|
2354
2970
|
className: variants.length > 1 ? `tb-w ${variantClass(variant)}` : "tb-w",
|
|
2355
2971
|
anchor: index === 0 && !ctx.dupe && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
2356
2972
|
copyAnchor: ctx.vpath !== "" && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
2357
2973
|
entrance: entranceOf(variant.props.entrance, variant.props.entranceDelayMs, ctx.interactive),
|
|
2358
|
-
children: /* @__PURE__ */
|
|
2974
|
+
children: /* @__PURE__ */ jsx32(
|
|
2359
2975
|
Component2,
|
|
2360
2976
|
{
|
|
2361
2977
|
node,
|
|
@@ -2375,15 +2991,23 @@ function renderWidget(node, ctx, registry) {
|
|
|
2375
2991
|
variant.devices.join("-")
|
|
2376
2992
|
);
|
|
2377
2993
|
});
|
|
2994
|
+
return gated(node, ctx, copies);
|
|
2995
|
+
}
|
|
2996
|
+
function gated(node, ctx, content) {
|
|
2997
|
+
if (ctx.edit !== void 0) return content;
|
|
2998
|
+
const when = parseShowWhen(node.showWhen);
|
|
2999
|
+
if (when === null) return content;
|
|
3000
|
+
return /* @__PURE__ */ jsx32(ShowWhen, { when, heights: reservedHeights(node), children: content });
|
|
2378
3001
|
}
|
|
2379
3002
|
function renderColumn(column, ctx, registry) {
|
|
2380
3003
|
if (ctx.edit === void 0 && hiddenEverywhere(column.props, column.responsive)) return null;
|
|
2381
|
-
|
|
3004
|
+
const drawn = /* @__PURE__ */ jsx32(
|
|
2382
3005
|
NodeWrapper,
|
|
2383
3006
|
{
|
|
2384
3007
|
id: column.id,
|
|
2385
3008
|
part: "column",
|
|
2386
3009
|
className: "tb-col",
|
|
3010
|
+
cssClass: column.cssClass,
|
|
2387
3011
|
anchor: ctx.dupe ? void 0 : column.props.anchor,
|
|
2388
3012
|
copyAnchor: ctx.vpath === "" ? void 0 : column.props.anchor,
|
|
2389
3013
|
edit: ctx.edit,
|
|
@@ -2393,16 +3017,17 @@ function renderColumn(column, ctx, registry) {
|
|
|
2393
3017
|
ctx.interactive
|
|
2394
3018
|
),
|
|
2395
3019
|
children: column.children.map(
|
|
2396
|
-
(child) => child.type === "inner-section" ? /* @__PURE__ */
|
|
3020
|
+
(child) => child.type === "inner-section" ? /* @__PURE__ */ jsx32(Fragment19, { children: renderSection(child, ctx, registry, true) }, child.id) : /* @__PURE__ */ jsx32(Fragment19, { children: renderWidget(child, ctx, registry) }, child.id)
|
|
2397
3021
|
)
|
|
2398
3022
|
},
|
|
2399
3023
|
column.id
|
|
2400
3024
|
);
|
|
3025
|
+
return gated(column, ctx, drawn);
|
|
2401
3026
|
}
|
|
2402
3027
|
var PLAIN = resolveInteraction({ props: {}, responsive: void 0 }, "desktop");
|
|
2403
3028
|
function sectionVariants(section, ctx) {
|
|
2404
3029
|
const groups = /* @__PURE__ */ new Map();
|
|
2405
|
-
for (const device of
|
|
3030
|
+
for (const device of DEVICES4) {
|
|
2406
3031
|
const interaction = ctx.interactive ? resolveInteraction(section, device) : PLAIN;
|
|
2407
3032
|
const entrance = ctx.interactive ? resolveEntrance(section, device) : { entrance: "none", entranceDelayMs: 0 };
|
|
2408
3033
|
const signature = stable([interaction, entrance]);
|
|
@@ -2422,7 +3047,8 @@ function panelsOf(section, ctx, registry, fallback) {
|
|
|
2422
3047
|
function renderSection(section, ctx, registry, nested = false) {
|
|
2423
3048
|
if (ctx.edit === void 0 && hiddenEverywhere(section.props, section.responsive)) return null;
|
|
2424
3049
|
const variants = sectionVariants(section, ctx);
|
|
2425
|
-
const
|
|
3050
|
+
const frame = nested || !ctx.interactive || ctx.edit !== void 0 ? null : frameOf(section);
|
|
3051
|
+
const marker = variants.length > 1 && !ctx.dupe && section.props.anchor !== void 0 && ANCHOR_RE3.test(section.props.anchor) ? /* @__PURE__ */ jsx32("div", { id: section.props.anchor, className: "tb-anchor" }, "anchor") : null;
|
|
2426
3052
|
const copies = variants.map((variant, index) => {
|
|
2427
3053
|
const { interaction } = variant;
|
|
2428
3054
|
const id = `ix-${section.id}-${ctx.vpath}${String(index)}`;
|
|
@@ -2430,9 +3056,9 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
2430
3056
|
const columns = () => section.columns.map((column) => renderColumn(column, own, registry));
|
|
2431
3057
|
let body;
|
|
2432
3058
|
if (interaction.interaction === "tabs") {
|
|
2433
|
-
body = /* @__PURE__ */
|
|
3059
|
+
body = /* @__PURE__ */ jsx32(Tabs, { id, panels: panelsOf(section, own, registry, (n) => `Tab ${String(n)}`) });
|
|
2434
3060
|
} else if (interaction.interaction === "accordion") {
|
|
2435
|
-
body = /* @__PURE__ */
|
|
3061
|
+
body = /* @__PURE__ */ jsx32(
|
|
2436
3062
|
Accordion,
|
|
2437
3063
|
{
|
|
2438
3064
|
id,
|
|
@@ -2442,7 +3068,7 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
2442
3068
|
}
|
|
2443
3069
|
);
|
|
2444
3070
|
} else if (interaction.interaction === "carousel") {
|
|
2445
|
-
body = /* @__PURE__ */
|
|
3071
|
+
body = /* @__PURE__ */ jsx32(
|
|
2446
3072
|
Carousel,
|
|
2447
3073
|
{
|
|
2448
3074
|
panels: panelsOf(section, own, registry, () => ""),
|
|
@@ -2451,7 +3077,7 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
2451
3077
|
}
|
|
2452
3078
|
);
|
|
2453
3079
|
} else if (interaction.interaction === "toggle") {
|
|
2454
|
-
body = /* @__PURE__ */
|
|
3080
|
+
body = /* @__PURE__ */ jsx32(
|
|
2455
3081
|
Toggle,
|
|
2456
3082
|
{
|
|
2457
3083
|
labelOpen: pickLocale(interaction.toggleLabelOpen, ctx.locale),
|
|
@@ -2461,39 +3087,55 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
2461
3087
|
}
|
|
2462
3088
|
);
|
|
2463
3089
|
} else {
|
|
2464
|
-
body = /* @__PURE__ */
|
|
3090
|
+
body = /* @__PURE__ */ jsx32("div", { className: "tb-row", children: columns() });
|
|
3091
|
+
}
|
|
3092
|
+
if (frame?.collapse != null) {
|
|
3093
|
+
body = /* @__PURE__ */ jsx32(
|
|
3094
|
+
Collapse,
|
|
3095
|
+
{
|
|
3096
|
+
sectionId: section.id,
|
|
3097
|
+
id: `fr-${section.id}-${ctx.vpath}${String(index)}`,
|
|
3098
|
+
px: frame.collapse.px,
|
|
3099
|
+
label: pickLocale(frame.collapse.label, ctx.locale) || SITE_STRING_DEFAULTS4["nav.menu"],
|
|
3100
|
+
children: body
|
|
3101
|
+
}
|
|
3102
|
+
);
|
|
2465
3103
|
}
|
|
2466
|
-
return /* @__PURE__ */
|
|
3104
|
+
return /* @__PURE__ */ jsxs23(
|
|
2467
3105
|
NodeWrapper,
|
|
2468
3106
|
{
|
|
2469
3107
|
id: section.id,
|
|
2470
3108
|
part: "section",
|
|
3109
|
+
cssClass: section.cssClass,
|
|
2471
3110
|
as: nested ? "div" : "section",
|
|
2472
|
-
className: `${nested ? "tb-section tb-nested" : "tb-section"}${variants.length > 1 ? ` ${variantClass({ devices: variant.devices, props: {} })}` : ""}`,
|
|
3111
|
+
className: `${nested ? "tb-section tb-nested" : "tb-section"}${frame?.sticky === true ? " tb-sticky" : ""}${variants.length > 1 ? ` ${variantClass({ devices: variant.devices, props: {} })}` : ""}`,
|
|
2473
3112
|
anchor: variants.length === 1 && !ctx.dupe ? section.props.anchor : void 0,
|
|
2474
3113
|
copyAnchor: variants.length > 1 || ctx.vpath !== "" ? section.props.anchor : void 0,
|
|
2475
3114
|
edit: ctx.edit,
|
|
2476
3115
|
entrance: entranceOf(variant.entrance.entrance, variant.entrance.entranceDelayMs, ctx.interactive),
|
|
2477
|
-
children:
|
|
3116
|
+
children: [
|
|
3117
|
+
frame !== null ? /* @__PURE__ */ jsx32("style", { href: "tb-frame", precedence: "throttle", children: FRAME_CSS }) : null,
|
|
3118
|
+
/* @__PURE__ */ jsx32("div", { className: "tb-inner", children: body })
|
|
3119
|
+
]
|
|
2478
3120
|
},
|
|
2479
3121
|
variant.devices.join("-")
|
|
2480
3122
|
);
|
|
2481
3123
|
});
|
|
2482
|
-
return marker === null ? copies : [marker, ...copies];
|
|
3124
|
+
return gated(section, ctx, marker === null ? copies : [marker, ...copies]);
|
|
2483
3125
|
}
|
|
2484
3126
|
function needsRuntime(doc) {
|
|
2485
3127
|
let found = false;
|
|
2486
3128
|
walkNodes3(doc, (node) => {
|
|
2487
3129
|
if (found || node.type === "saved-section") return;
|
|
2488
3130
|
if (node.type === "section" || node.type === "inner-section") {
|
|
2489
|
-
found =
|
|
3131
|
+
found = DEVICES4.some(
|
|
2490
3132
|
(device) => resolveInteraction(node, device).interaction !== "none" || resolveEntrance(node, device).entrance !== "none"
|
|
2491
3133
|
);
|
|
2492
3134
|
} else if (node.type === "column") {
|
|
2493
|
-
found =
|
|
3135
|
+
found = DEVICES4.some((device) => resolveEntrance(node, device).entrance !== "none");
|
|
2494
3136
|
} else {
|
|
2495
|
-
found =
|
|
2496
|
-
const entrance =
|
|
3137
|
+
found = DEVICES4.some((device) => {
|
|
3138
|
+
const entrance = resolveResponsive4(node.props, node.responsive, device).entrance;
|
|
2497
3139
|
return entrance !== void 0 && entrance !== "none";
|
|
2498
3140
|
});
|
|
2499
3141
|
}
|
|
@@ -2511,79 +3153,1084 @@ function BuilderRenderer(props) {
|
|
|
2511
3153
|
const ctx = { registry, data, locale, assets, mediaOrigin, resolveLink, code, edit: editMode, interactive, vpath: props.idScope?.vpath ?? "", dupe: props.idScope?.dupe ?? false, snapshots: source.customWidgets };
|
|
2512
3154
|
const css = compileResponsiveCss(doc, registry, assets, mediaOrigin);
|
|
2513
3155
|
const upgraded = new Map(doc.sections.map((section) => [section.id, section]));
|
|
2514
|
-
return /* @__PURE__ */
|
|
2515
|
-
interactive && needsRuntime(doc) ? /* @__PURE__ */
|
|
2516
|
-
/* @__PURE__ */
|
|
2517
|
-
css === "" ? null : /* @__PURE__ */
|
|
3156
|
+
return /* @__PURE__ */ jsxs23("div", { className: "tb-root", "data-throttle-part": "builder-root", ...props.scopeCustomCss === true ? { "data-b-root": "" } : {}, children: [
|
|
3157
|
+
interactive && needsRuntime(doc) ? /* @__PURE__ */ jsx32(InteractionRuntime, {}) : null,
|
|
3158
|
+
/* @__PURE__ */ jsx32("style", { href: "tb-base", precedence: "throttle", children: BASE_CSS }),
|
|
3159
|
+
css === "" ? null : /* @__PURE__ */ jsx32("style", { children: css }),
|
|
2518
3160
|
(expansion.roots ?? doc.sections.map((section) => ({ kind: "section", id: section.id }))).map((root) => {
|
|
2519
3161
|
if (root.kind === "section") {
|
|
2520
3162
|
const section2 = upgraded.get(root.id);
|
|
2521
|
-
return section2?.type === "section" ? /* @__PURE__ */
|
|
3163
|
+
return section2?.type === "section" ? /* @__PURE__ */ jsx32(Fragment19, { children: renderSection(section2, ctx, registry) }, root.id) : null;
|
|
2522
3164
|
}
|
|
2523
3165
|
const section = root.sectionId === null ? void 0 : upgraded.get(root.sectionId);
|
|
2524
3166
|
if (section?.type === "section") {
|
|
2525
|
-
return root.ref.props.hidden === true && ctx.edit === void 0 ? null : /* @__PURE__ */
|
|
3167
|
+
return root.ref.props.hidden === true && ctx.edit === void 0 ? null : /* @__PURE__ */ jsx32(Fragment19, { children: renderSection(section, ctx, registry) }, root.ref.id);
|
|
2526
3168
|
}
|
|
2527
|
-
return /* @__PURE__ */
|
|
3169
|
+
return /* @__PURE__ */ jsx32(MissingSavedSection, { node: root.ref }, root.ref.id);
|
|
2528
3170
|
})
|
|
2529
3171
|
] });
|
|
2530
3172
|
}
|
|
2531
3173
|
|
|
2532
|
-
// src/
|
|
2533
|
-
import {
|
|
2534
|
-
var
|
|
2535
|
-
var
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
3174
|
+
// src/basics/v2/menu-v2.tsx
|
|
3175
|
+
import { Fragment as Fragment20, jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
3176
|
+
var MODES = ["horizontal", "vertical", "drawer", "mega"];
|
|
3177
|
+
var MAX_LEVEL = 3;
|
|
3178
|
+
var CLASS_RE = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;
|
|
3179
|
+
var SUBMENU_DEFAULT = "Show submenu for {label}";
|
|
3180
|
+
function localized(value, locale) {
|
|
3181
|
+
if (!isRecord(value)) return str(value);
|
|
3182
|
+
for (const key of [locale, "en"]) {
|
|
3183
|
+
if (Object.hasOwn(value, key)) {
|
|
3184
|
+
const own = str(value[key]);
|
|
3185
|
+
if (own !== void 0) return own;
|
|
3186
|
+
}
|
|
2545
3187
|
}
|
|
2546
|
-
|
|
2547
|
-
|
|
3188
|
+
return Object.values(value).map(str).find((s) => s !== void 0);
|
|
3189
|
+
}
|
|
3190
|
+
function makeLink(builder, own, mediaOrigin) {
|
|
3191
|
+
const targets = builder?.linkTargets;
|
|
3192
|
+
const fallback = own ?? builder?.resolveLink;
|
|
3193
|
+
return (target2) => {
|
|
3194
|
+
if (target2.kind === "url") return safeUrl12(target2.href, "href", { mediaOrigin });
|
|
3195
|
+
if (targets !== void 0 && typeof target2.id === "string") {
|
|
3196
|
+
const key = `${String(target2.kind)}:${target2.id}`;
|
|
3197
|
+
if (Object.hasOwn(targets, key)) {
|
|
3198
|
+
const known = targets[key];
|
|
3199
|
+
return typeof known === "string" ? safeUrl12(known, "href", { mediaOrigin }) : null;
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
const raw = fallback?.(target2) ?? null;
|
|
3203
|
+
return raw === null ? null : safeUrl12(raw, "href", { mediaOrigin });
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
function megaOf(value, locale) {
|
|
3207
|
+
if (!isRecord(value) || value.enabled !== true) return void 0;
|
|
3208
|
+
const columns = typeof value.columns === "number" ? Math.min(6, Math.max(2, Math.round(value.columns))) : 3;
|
|
3209
|
+
const f = value.featured;
|
|
3210
|
+
let featured = null;
|
|
3211
|
+
if (isRecord(f) && f.kind === "section" && typeof f.id === "string") featured = { kind: "section", id: f.id };
|
|
3212
|
+
else if (isRecord(f) && f.kind === "image" && typeof f.asset === "string") {
|
|
3213
|
+
featured = { kind: "image", asset: f.asset, link: isRecord(f.link) ? f.link : null, caption: localized(f.caption, locale) ?? "" };
|
|
2548
3214
|
}
|
|
2549
|
-
|
|
2550
|
-
|
|
3215
|
+
return { columns, featured };
|
|
3216
|
+
}
|
|
3217
|
+
function build(raw, level, b) {
|
|
3218
|
+
if (!Array.isArray(raw)) return [];
|
|
3219
|
+
const out = [];
|
|
3220
|
+
raw.forEach((entry, index) => {
|
|
3221
|
+
if (!isRecord(entry) || !isRecord(entry.target)) return;
|
|
3222
|
+
const target2 = entry.target;
|
|
3223
|
+
const label = localized(entry.label, b.r.locale);
|
|
3224
|
+
if (label === void 0) return;
|
|
3225
|
+
out.push({
|
|
3226
|
+
key: typeof entry.id === "string" ? entry.id : String(index),
|
|
3227
|
+
label,
|
|
3228
|
+
href: target2.kind === "category" && typeof entry.url === "string" ? safeUrl12(entry.url, "href", { mediaOrigin: b.r.mediaOrigin }) : b.r.link(target2),
|
|
3229
|
+
newTab: entry.newTab === true,
|
|
3230
|
+
classes: Array.isArray(entry.cssClass) ? entry.cssClass.filter((c) => typeof c === "string" && CLASS_RE.test(c)) : [],
|
|
3231
|
+
description: localized(entry.description, b.r.locale),
|
|
3232
|
+
badge: localized(entry.badge, b.r.locale),
|
|
3233
|
+
// Mega is only for a top-level item of the header menu, in mega mode.
|
|
3234
|
+
mega: b.mega && level === 1 && b.menu === "header" ? megaOf(entry.mega, b.r.locale) : void 0,
|
|
3235
|
+
children: level < MAX_LEVEL ? build(entry.children, level + 1, b) : [],
|
|
3236
|
+
...target2.kind === "category" && typeof entry.handle === "string" ? { handle: entry.handle } : {}
|
|
3237
|
+
});
|
|
3238
|
+
});
|
|
3239
|
+
return out;
|
|
3240
|
+
}
|
|
3241
|
+
function fromDesign(items, level, r) {
|
|
3242
|
+
return items.map((item, index) => ({
|
|
3243
|
+
key: String(index),
|
|
3244
|
+
label: item.label,
|
|
3245
|
+
href: safeUrl12(item.href, "href", { mediaOrigin: r.mediaOrigin }),
|
|
3246
|
+
newTab: false,
|
|
3247
|
+
classes: [],
|
|
3248
|
+
description: void 0,
|
|
3249
|
+
badge: void 0,
|
|
3250
|
+
mega: void 0,
|
|
3251
|
+
children: level < MAX_LEVEL && item.children !== void 0 ? fromDesign(item.children, level + 1, r) : []
|
|
3252
|
+
}));
|
|
3253
|
+
}
|
|
3254
|
+
function Anchor({ item }) {
|
|
3255
|
+
return item.href === null ? /* @__PURE__ */ jsx33("span", { className: "tb-mm-text", children: item.label }) : /* @__PURE__ */ jsx33("a", { href: item.href, ...item.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}, children: item.label });
|
|
3256
|
+
}
|
|
3257
|
+
var Extras = ({ item, describe }) => /* @__PURE__ */ jsxs24(Fragment20, { children: [
|
|
3258
|
+
item.badge === void 0 ? null : /* @__PURE__ */ jsx33("span", { className: "tb-mm-badge", children: item.badge }),
|
|
3259
|
+
describe && item.description !== void 0 ? /* @__PURE__ */ jsx33("span", { className: "tb-mm-desc", children: item.description }) : null
|
|
3260
|
+
] });
|
|
3261
|
+
function FeaturedPanel({ featured, label, ctx }) {
|
|
3262
|
+
const { builder, props } = ctx;
|
|
3263
|
+
const site = builder?.site;
|
|
3264
|
+
if (builder === null || site === void 0 || site.status !== "ok") return null;
|
|
3265
|
+
const parts = [site.header, site.footer];
|
|
3266
|
+
if (featured.kind === "section") {
|
|
3267
|
+
let answer;
|
|
3268
|
+
for (const part2 of parts) {
|
|
3269
|
+
const all2 = part2.savedSections;
|
|
3270
|
+
if (answer === void 0 && all2 !== void 0 && Object.hasOwn(all2, featured.id)) answer = all2[featured.id];
|
|
3271
|
+
}
|
|
3272
|
+
const parsed2 = answer === void 0 ? null : sectionNodeSchema2.safeParse(answer.section);
|
|
3273
|
+
if (answer === void 0 || parsed2 === null || !parsed2.success) return null;
|
|
3274
|
+
const assets = { ...site.footer.assets, ...site.header.assets };
|
|
3275
|
+
return /* @__PURE__ */ jsx33("div", { className: "tb-mm-feat", children: /* @__PURE__ */ jsx33(
|
|
3276
|
+
BuilderRenderer,
|
|
3277
|
+
{
|
|
3278
|
+
document: { schemaVersion: 1, sections: [parsed2.data] },
|
|
3279
|
+
registry: builder.registry,
|
|
3280
|
+
data: {},
|
|
3281
|
+
locale: props.locale,
|
|
3282
|
+
assets,
|
|
3283
|
+
mediaOrigin: props.mediaOrigin,
|
|
3284
|
+
interactive: props.interactive,
|
|
3285
|
+
resolveLink: props.resolveLink ?? builder.resolveLink
|
|
3286
|
+
}
|
|
3287
|
+
) });
|
|
3288
|
+
}
|
|
3289
|
+
let asset;
|
|
3290
|
+
for (const part2 of parts) {
|
|
3291
|
+
if (asset === void 0 && Object.hasOwn(part2.assets, featured.asset)) asset = part2.assets[featured.asset];
|
|
3292
|
+
}
|
|
3293
|
+
if (!isFrozenAsset(asset)) return null;
|
|
3294
|
+
const href = featured.link === null ? null : makeLink(builder, props.resolveLink, props.mediaOrigin)(featured.link);
|
|
3295
|
+
const image = /* @__PURE__ */ jsx33(AssetImage, { asset, mediaOrigin: props.mediaOrigin, alt: href === null ? featured.caption : featured.caption || label });
|
|
3296
|
+
return /* @__PURE__ */ jsxs24("figure", { className: "tb-mm-feat", children: [
|
|
3297
|
+
href === null ? image : /* @__PURE__ */ jsx33("a", { href, children: image }),
|
|
3298
|
+
featured.caption === "" ? null : /* @__PURE__ */ jsx33("figcaption", { children: featured.caption })
|
|
3299
|
+
] });
|
|
3300
|
+
}
|
|
3301
|
+
function List2({ items, top, ctx }) {
|
|
3302
|
+
if (items.length === 0) return null;
|
|
3303
|
+
return /* @__PURE__ */ jsx33("ul", { ...top === void 0 ? { className: "tb-mm-sub" } : { id: top.id, className: "tb-mm-list" }, children: items.map((item) => /* @__PURE__ */ jsx33(Entry, { item, level: top === void 0 ? 2 : 1, ctx }, item.key)) });
|
|
3304
|
+
}
|
|
3305
|
+
function Entry({ item, level, ctx }) {
|
|
3306
|
+
const hasPanel = item.mega !== void 0 && (item.children.length > 0 || item.mega.featured !== null);
|
|
3307
|
+
const sub = item.children.length > 0 || hasPanel;
|
|
3308
|
+
const toggle = sub && level === 1 && ctx.mode !== "vertical";
|
|
3309
|
+
const cls = ["tb-mm-i", ...item.classes].join(" ");
|
|
3310
|
+
const subId = `${ctx.listId}-${item.key.replace(/[^A-Za-z0-9_-]/g, "_")}`;
|
|
3311
|
+
let below = null;
|
|
3312
|
+
if (hasPanel && item.mega !== void 0) {
|
|
3313
|
+
below = /* @__PURE__ */ jsxs24("div", { id: subId, className: "tb-mm-panel", style: { "--tb-mm-cols": item.mega.columns }, children: [
|
|
3314
|
+
item.children.length === 0 ? null : /* @__PURE__ */ jsx33("ul", { className: "tb-mm-cols", children: item.children.map((child) => /* @__PURE__ */ jsxs24("li", { className: "tb-mm-col", children: [
|
|
3315
|
+
/* @__PURE__ */ jsx33(Anchor, { item: child }),
|
|
3316
|
+
/* @__PURE__ */ jsx33(Extras, { item: child, describe: true }),
|
|
3317
|
+
/* @__PURE__ */ jsx33(List2, { items: child.children, ctx })
|
|
3318
|
+
] }, child.key)) }),
|
|
3319
|
+
item.mega.featured === null ? null : /* @__PURE__ */ jsx33(FeaturedPanel, { featured: item.mega.featured, label: item.label, ctx })
|
|
3320
|
+
] });
|
|
3321
|
+
} else if (sub) {
|
|
3322
|
+
below = /* @__PURE__ */ jsx33("ul", { id: subId, className: "tb-mm-sub", children: item.children.map((child) => /* @__PURE__ */ jsx33(Entry, { item: child, level: 2, ctx }, child.key)) });
|
|
3323
|
+
}
|
|
3324
|
+
return /* @__PURE__ */ jsxs24("li", { className: cls, ...sub && level === 1 ? { "data-tb-i": "" } : {}, children: [
|
|
3325
|
+
/* @__PURE__ */ jsx33(Anchor, { item }),
|
|
3326
|
+
/* @__PURE__ */ jsx33(Extras, { item, describe: false }),
|
|
3327
|
+
toggle ? /* @__PURE__ */ jsx33(
|
|
3328
|
+
"button",
|
|
3329
|
+
{
|
|
3330
|
+
type: "button",
|
|
3331
|
+
className: "tb-mm-t",
|
|
3332
|
+
"data-tb-t": "",
|
|
3333
|
+
"aria-expanded": "false",
|
|
3334
|
+
"aria-controls": subId,
|
|
3335
|
+
"aria-label": ctx.submenu.replace("{label}", () => item.label),
|
|
3336
|
+
children: /* @__PURE__ */ jsx33("svg", { viewBox: "0 0 24 24", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsx33("path", { d: "M6 9l6 6 6-6", fill: "none", stroke: "currentColor", strokeWidth: "2" }) })
|
|
3337
|
+
}
|
|
3338
|
+
) : null,
|
|
3339
|
+
below
|
|
3340
|
+
] });
|
|
3341
|
+
}
|
|
3342
|
+
function MenuRuntime() {
|
|
3343
|
+
useEffect6(() => startMenuRuntime(), []);
|
|
3344
|
+
return null;
|
|
3345
|
+
}
|
|
3346
|
+
var part = (key, extra) => ({
|
|
3347
|
+
className: [`tsf-${key}`, extra].filter(Boolean).join(" "),
|
|
3348
|
+
"data-throttle-part": key
|
|
3349
|
+
});
|
|
3350
|
+
function StorefrontNav({ items, label, listId, ctx, className, menu }) {
|
|
3351
|
+
const categories = items.some((item) => item.handle !== void 0);
|
|
3352
|
+
const handle = (item, parent) => item.handle === void 0 ? {} : { "data-category-handle": item.handle, ...categories ? { "data-category-parent": parent } : {} };
|
|
3353
|
+
const link = (item) => item.href === null ? /* @__PURE__ */ jsx33("span", { ...part("category-nav-link", "tb-mm-text"), children: item.label }) : /* @__PURE__ */ jsx33("a", { ...part("category-nav-link"), href: item.href, ...item.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}, children: item.label });
|
|
3354
|
+
return /* @__PURE__ */ jsx33("nav", { ...part("category-nav", className), "aria-label": label, ...categories ? {} : { "data-menu": menu }, children: /* @__PURE__ */ jsx33("ul", { ...part("category-nav-list"), children: items.map((item) => {
|
|
3355
|
+
const sub = item.children.length > 0;
|
|
3356
|
+
const panelId = `${listId}-${item.key.replace(/[^A-Za-z0-9_-]/g, "_")}`;
|
|
3357
|
+
return /* @__PURE__ */ jsxs24("li", { ...part("category-nav-item", item.classes.join(" ")), "data-nav-top": "", ...sub ? { "data-tb-i": "" } : {}, ...handle(item, ""), children: [
|
|
3358
|
+
link(item),
|
|
3359
|
+
sub ? /* @__PURE__ */ jsx33(
|
|
3360
|
+
"button",
|
|
3361
|
+
{
|
|
3362
|
+
type: "button",
|
|
3363
|
+
...part("category-nav-toggle"),
|
|
3364
|
+
"data-tb-t": "",
|
|
3365
|
+
"aria-expanded": "false",
|
|
3366
|
+
"aria-controls": panelId,
|
|
3367
|
+
"aria-label": ctx.submenu.replace("{label}", () => item.label),
|
|
3368
|
+
children: /* @__PURE__ */ jsx33(Icon4, { name: "chevron-down", size: 14 })
|
|
3369
|
+
}
|
|
3370
|
+
) : null,
|
|
3371
|
+
sub ? /* @__PURE__ */ jsx33("ul", { ...part("category-nav-panel"), id: panelId, "data-nav-panel": "", hidden: true, children: item.children.map((child) => /* @__PURE__ */ jsx33("li", { ...part("category-nav-child", child.classes.join(" ")), ...handle(child, item.handle ?? ""), children: link(child) }, child.key)) }) : null
|
|
3372
|
+
] }, item.key);
|
|
3373
|
+
}) }) });
|
|
3374
|
+
}
|
|
3375
|
+
function Nav({ items, label, listId, ctx, className, menu }) {
|
|
3376
|
+
if (ctx.variant === "storefront") return /* @__PURE__ */ jsx33(StorefrontNav, { items, label, listId, ctx, menu, ...className === void 0 ? {} : { className } });
|
|
3377
|
+
const full = { ...ctx, listId };
|
|
3378
|
+
return /* @__PURE__ */ jsxs24("nav", { className: `tb-mm tb-mm--${ctx.mode}${className === void 0 ? "" : ` ${className}`}`, "aria-label": label, children: [
|
|
3379
|
+
ctx.mode === "drawer" && /* @__PURE__ */ jsx33("button", { type: "button", className: "tb-mm-drawer", "data-tb-drawer": "", "aria-expanded": "false", "aria-controls": listId, children: /* @__PURE__ */ jsx33(Icon4, { name: "menu", size: 24, label }) }),
|
|
3380
|
+
/* @__PURE__ */ jsx33(List2, { items, top: { id: listId }, ctx: full })
|
|
3381
|
+
] });
|
|
3382
|
+
}
|
|
3383
|
+
function MenuV2(props) {
|
|
3384
|
+
const { props: settings, data, mediaOrigin, editMode, locale } = props;
|
|
3385
|
+
const builder = useBuilder();
|
|
3386
|
+
const design = useSiteDesign5();
|
|
3387
|
+
const listId = useId2();
|
|
3388
|
+
const mobileId = useId2();
|
|
3389
|
+
const name = str(settings.menu) ?? "header";
|
|
3390
|
+
const mode = oneOf(settings.mode, MODES, "horizontal");
|
|
3391
|
+
const r = { mediaOrigin, locale, link: makeLink(builder, props.resolveLink, mediaOrigin) };
|
|
3392
|
+
const categories = Array.isArray(data.categories) ? data.categories : [];
|
|
3393
|
+
const forMenu = (menu, raw) => build(expandMenu(Array.isArray(raw) ? raw : [], categories).menu, 1, { r, menu, mega: mode === "mega" });
|
|
3394
|
+
let items = [];
|
|
3395
|
+
let mobile = [];
|
|
3396
|
+
const site = builder?.site;
|
|
3397
|
+
const menus = site?.status === "ok" && isRecord(site.settings.menus) ? site.settings.menus : void 0;
|
|
3398
|
+
if (menus !== void 0) {
|
|
3399
|
+
items = Object.hasOwn(menus, name) ? forMenu(name, menus[name]) : [];
|
|
3400
|
+
if (name === "header" && Object.hasOwn(menus, "mobile")) mobile = forMenu("mobile", menus.mobile);
|
|
3401
|
+
} else if (design?.menus !== void 0 && Object.hasOwn(design.menus, name)) {
|
|
3402
|
+
items = fromDesign(design.menus[name] ?? [], 1, r);
|
|
3403
|
+
}
|
|
3404
|
+
const word = (key, fallback) => {
|
|
3405
|
+
for (const strings of [site?.status === "ok" ? site.settings.strings : void 0, design?.strings]) {
|
|
3406
|
+
if (isRecord(strings) && Object.hasOwn(strings, key) && str(strings[key]) !== void 0) return strings[key];
|
|
3407
|
+
}
|
|
3408
|
+
return fallback;
|
|
3409
|
+
};
|
|
3410
|
+
const label = word("nav.menu", SITE_STRING_DEFAULTS5["nav.menu"]);
|
|
3411
|
+
if (items.length === 0 && mobile.length === 0) {
|
|
3412
|
+
return /* @__PURE__ */ jsxs24(Fragment20, { children: [
|
|
3413
|
+
/* @__PURE__ */ jsx33(BasicStyles, {}),
|
|
3414
|
+
/* @__PURE__ */ jsx33(Placeholder, { editMode, children: `Menu "${name}" is empty: add links in Site settings` })
|
|
3415
|
+
] });
|
|
3416
|
+
}
|
|
3417
|
+
const ctx = { builder, props, mode, variant: oneOf(settings.variant, ["default", "storefront"], "default"), submenu: word("nav.submenu", SUBMENU_DEFAULT) };
|
|
3418
|
+
const nameOf = (menu) => menu === "header" ? label : `${label} (${menu})`;
|
|
3419
|
+
return /* @__PURE__ */ jsxs24(Fragment20, { children: [
|
|
3420
|
+
/* @__PURE__ */ jsx33(BasicStyles, {}),
|
|
3421
|
+
/* @__PURE__ */ jsx33("style", { href: "tb-menu-v2", precedence: "throttle", children: MENU_V2_CSS }),
|
|
3422
|
+
items.length === 0 ? null : /* @__PURE__ */ jsx33(Nav, { items, menu: name, label: nameOf(name), listId, ctx, ...mobile.length > 0 ? { className: "tb-mm-hide-phone" } : {} }),
|
|
3423
|
+
mobile.length === 0 ? null : /* @__PURE__ */ jsx33(Nav, { items: mobile, menu: "mobile", label: nameOf("mobile"), listId: mobileId, ctx, className: "tb-mm-only-phone" }),
|
|
3424
|
+
props.interactive === false ? null : /* @__PURE__ */ jsx33(MenuRuntime, {})
|
|
3425
|
+
] });
|
|
3426
|
+
}
|
|
3427
|
+
var MENU_V2_CSS = `@layer throttle{
|
|
3428
|
+
.tb-mm{position:relative;color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));text-align:var(--b-align,start)}
|
|
3429
|
+
.tb-mm ul{margin:0;padding:0;list-style:none}
|
|
3430
|
+
.tb-mm li{position:relative;min-inline-size:0}
|
|
3431
|
+
.tb-mm a,.tb-mm-text{display:block;min-inline-size:0;padding:var(--tb-space-xs) var(--tb-space-s);color:inherit;text-decoration:none;overflow-wrap:anywhere}
|
|
3432
|
+
.tb-mm a:hover{text-decoration:underline}
|
|
3433
|
+
.tb-mm a:focus-visible,.tb-mm-t:focus-visible,.tb-mm-drawer:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
3434
|
+
.tb-mm-badge{display:inline-block;margin-inline-start:var(--tb-space-xs);padding-inline:.5em;border-radius:99px;font-size:.75em;background:var(--tb-color-primary,#111);color:var(--tb-color-primary-foreground,#fff)}
|
|
3435
|
+
.tb-mm-desc{display:block;padding-inline:var(--tb-space-s);font-size:.85em;opacity:.75;overflow-wrap:anywhere}
|
|
3436
|
+
.tb-mm-t{display:inline-flex;align-items:center;justify-content:center;min-inline-size:32px;min-block-size:32px;padding:0;border:0;background:transparent;color:inherit;cursor:pointer}
|
|
3437
|
+
.tb-mm-t svg{transition:transform .15s}
|
|
3438
|
+
.tb-mm-i[data-open]>.tb-mm-t svg{transform:rotate(180deg)}
|
|
3439
|
+
.tb-mm-drawer{display:none;align-items:center;justify-content:center;min-inline-size:44px;min-block-size:44px;padding:0;border:0;background:transparent;color:inherit;cursor:pointer}
|
|
3440
|
+
.tb-mm-only-phone{display:none}
|
|
3441
|
+
.tb-mm--horizontal>ul,.tb-mm--drawer>ul,.tb-mm--mega>ul{display:flex;flex-wrap:wrap;align-items:center}
|
|
3442
|
+
.tb-mm--horizontal>ul>li,.tb-mm--drawer>ul>li,.tb-mm--mega>ul>li{display:inline-flex;align-items:center}
|
|
3443
|
+
.tb-mm-sub,.tb-mm-panel{display:none}
|
|
3444
|
+
.tb-mm-i>.tb-mm-sub{position:absolute;inset-block-start:100%;inset-inline-start:0;z-index:20;min-inline-size:12rem;padding:var(--tb-space-xs);text-align:start;background:var(--tb-color-background,#fff);color:var(--tb-color-foreground,#111);border:1px solid var(--tb-color-border,#ddd);border-radius:var(--throttle-radius,8px)}
|
|
3445
|
+
.tb-mm-sub .tb-mm-sub{position:static;min-inline-size:0;padding:0;padding-inline-start:var(--tb-space-m);border:0}
|
|
3446
|
+
.tb-mm-sub>li{display:block}
|
|
3447
|
+
.tb-mm-i[data-open]>.tb-mm-sub{display:block}
|
|
3448
|
+
.tb-mm-sub .tb-mm-sub{display:block}
|
|
3449
|
+
.tb-mm--vertical .tb-mm-t{display:none}
|
|
3450
|
+
.tb-mm--vertical .tb-mm-sub{display:block;position:static;min-inline-size:0;padding:0;padding-inline-start:var(--tb-space-m);border:0}
|
|
3451
|
+
.tb-mm--mega>ul>li{position:static}
|
|
3452
|
+
.tb-mm--mega>ul>li>.tb-mm-panel{position:absolute;inset-inline:0;inset-block-start:100%;z-index:20;padding:var(--tb-space-m);text-align:start;background:var(--tb-color-background,#fff);color:var(--tb-color-foreground,#111);border:1px solid var(--tb-color-border,#ddd);border-radius:var(--throttle-radius,8px)}
|
|
3453
|
+
.tb-mm-i[data-open]>.tb-mm-panel{display:flex;gap:var(--tb-space-m)}
|
|
3454
|
+
.tb-mm-cols{display:grid;grid-template-columns:repeat(var(--tb-mm-cols,3),minmax(0,1fr));gap:var(--tb-space-m);flex:1 1 0;min-inline-size:0}
|
|
3455
|
+
.tb-mm-col>.tb-mm-sub{display:block;position:static;min-inline-size:0;padding:0;border:0}
|
|
3456
|
+
.tb-mm-feat{flex:0 1 16rem;min-inline-size:0;margin:0}
|
|
3457
|
+
.tb-mm-feat img{display:block;max-inline-size:100%;block-size:auto}
|
|
3458
|
+
@media (max-width:767.98px){
|
|
3459
|
+
.tb-mm-hide-phone{display:none}
|
|
3460
|
+
.tb-mm-only-phone{display:block}
|
|
3461
|
+
.tb-mm--mega>ul{display:block}
|
|
3462
|
+
.tb-mm--mega>ul>li{display:flex;flex-wrap:wrap;align-items:center}
|
|
3463
|
+
.tb-mm--mega>ul>li>a,.tb-mm--mega>ul>li>.tb-mm-text{flex:1 1 0}
|
|
3464
|
+
.tb-mm--mega>ul>li>.tb-mm-sub,.tb-mm--mega>ul>li>.tb-mm-panel{flex:1 0 100%}
|
|
3465
|
+
.tb-mm-panel{position:static;inset:auto;border:0;padding:0;background:transparent}
|
|
3466
|
+
.tb-mm-cols{display:block}
|
|
3467
|
+
.tb-mm-feat{display:none}
|
|
3468
|
+
.tb-mm--mega>ul>li>.tb-mm-panel{position:static;border:0;padding:0}
|
|
3469
|
+
.tb-mm-i>.tb-mm-sub{position:static;min-inline-size:0;border:0;padding:0;padding-inline-start:var(--tb-space-m)}
|
|
3470
|
+
.tb-mm--drawer>.tb-mm-drawer{display:inline-flex;position:relative;z-index:61}
|
|
3471
|
+
.tb-mm--drawer[data-open=true]>.tb-mm-drawer{position:fixed;inset-block-start:var(--tb-space-s);inset-inline-end:var(--tb-space-s)}
|
|
3472
|
+
.tb-mm--drawer>ul{display:none}
|
|
3473
|
+
.tb-mm--drawer[data-open=true]>ul{display:block;position:fixed;inset:0;z-index:60;overflow:auto;padding:4.5rem var(--tb-space-m) var(--tb-space-m);text-align:start;background:var(--tb-color-background,#fff);color:var(--tb-color-foreground,#111);font-size:var(--tb-text-l)}
|
|
3474
|
+
.tb-mm--drawer[data-open=true]>ul>li{display:flex;flex-wrap:wrap}
|
|
3475
|
+
.tb-mm--drawer[data-open=true] .tb-mm-sub{display:block;position:static;border:0}
|
|
3476
|
+
}
|
|
3477
|
+
@media (scripting: none){
|
|
3478
|
+
.tb-mm-t{display:none}
|
|
3479
|
+
.tb-mm-i:hover>.tb-mm-sub,.tb-mm-i:focus-within>.tb-mm-sub{display:block}
|
|
3480
|
+
.tb-mm-i:hover>.tb-mm-panel,.tb-mm-i:focus-within>.tb-mm-panel{display:flex;gap:var(--tb-space-m)}
|
|
3481
|
+
@media (max-width:767.98px){
|
|
3482
|
+
.tb-mm-sub,.tb-mm-panel{display:block}
|
|
3483
|
+
.tb-mm--drawer>.tb-mm-drawer{display:none}
|
|
3484
|
+
.tb-mm--drawer>ul{display:block}
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
}`;
|
|
3488
|
+
var definition = MB_BASIC_WIDGET_DEFINITIONS.find((d) => d.type === "basic.menu" && d.v === 2);
|
|
3489
|
+
if (definition === void 0) throw new Error("builder-schema has no basic.menu v2 definition");
|
|
3490
|
+
var menuV2Widgets = [{ ...definition, Component: MenuV2 }];
|
|
3491
|
+
|
|
3492
|
+
// src/basics/v2/announcement-v2.tsx
|
|
3493
|
+
import { Fragment as Fragment22, jsx as jsx34, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3494
|
+
var DEVICES5 = ["desktop", "tablet", "phone"];
|
|
3495
|
+
var DISMISS_PREFIX = "tb-an-dismissed:";
|
|
3496
|
+
var COLOR_HEX = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
3497
|
+
var COLOR_TOKEN2 = /^token:([a-z][a-z-]{0,30})$/;
|
|
3498
|
+
var REDUCED = "(prefers-reduced-motion: reduce)";
|
|
3499
|
+
function readDismissed(ids) {
|
|
3500
|
+
const out = [];
|
|
3501
|
+
for (const id of ids) {
|
|
2551
3502
|
try {
|
|
2552
|
-
|
|
3503
|
+
if (window.localStorage.getItem(`${DISMISS_PREFIX}${id}`) === "1") out.push(id);
|
|
2553
3504
|
} catch {
|
|
2554
3505
|
}
|
|
2555
3506
|
}
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
3507
|
+
return out;
|
|
3508
|
+
}
|
|
3509
|
+
function writeDismissed(id) {
|
|
3510
|
+
try {
|
|
3511
|
+
window.localStorage.setItem(`${DISMISS_PREFIX}${id}`, "1");
|
|
3512
|
+
} catch {
|
|
2559
3513
|
}
|
|
2560
|
-
|
|
2561
|
-
|
|
3514
|
+
}
|
|
3515
|
+
var matches = (query) => window.matchMedia?.(query).matches === true;
|
|
3516
|
+
function deviceNow() {
|
|
3517
|
+
return matches("(max-width:767.98px)") ? "phone" : matches("(max-width:1024.98px)") ? "tablet" : "desktop";
|
|
3518
|
+
}
|
|
3519
|
+
function colorOf(value) {
|
|
3520
|
+
if (typeof value !== "string") return void 0;
|
|
3521
|
+
if (COLOR_HEX.test(value)) return value;
|
|
3522
|
+
const token = COLOR_TOKEN2.exec(value);
|
|
3523
|
+
return token === null ? void 0 : `var(--tb-color-${token[1]})`;
|
|
3524
|
+
}
|
|
3525
|
+
var textOf = (tree) => tree.children.map((child) => typeof child === "string" ? child : textOf(child)).join("");
|
|
3526
|
+
function inline(children) {
|
|
3527
|
+
return children.map((child, index) => {
|
|
3528
|
+
if (typeof child === "string") return child;
|
|
3529
|
+
const inner = inline(child.children);
|
|
3530
|
+
if (child.tag === "strong" || child.tag === "em") return createElement3(child.tag, { key: index }, ...inner);
|
|
3531
|
+
if (child.tag === "a" && typeof child.href === "string") {
|
|
3532
|
+
return /* @__PURE__ */ jsx34("a", { href: child.href, rel: "noopener noreferrer", children: inner }, index);
|
|
3533
|
+
}
|
|
3534
|
+
return /* @__PURE__ */ jsx34(Fragment21, { children: inner }, index);
|
|
3535
|
+
});
|
|
3536
|
+
}
|
|
3537
|
+
function MessageText({ message, locale, mediaOrigin, href }) {
|
|
3538
|
+
const tree = parseRichText(localized(message.text, locale) ?? "", mediaOrigin);
|
|
3539
|
+
if (href !== null) return /* @__PURE__ */ jsx34("a", { href, children: textOf(tree) });
|
|
3540
|
+
return /* @__PURE__ */ jsx34("span", { className: "tb-an-text", children: inline(tree.children) });
|
|
3541
|
+
}
|
|
3542
|
+
function pageOf2(builder) {
|
|
3543
|
+
const given = builder?.page;
|
|
3544
|
+
if (given !== void 0) return given;
|
|
3545
|
+
return { home: builder?.pathname === "/" };
|
|
3546
|
+
}
|
|
3547
|
+
function audienceOf(ready, viewer) {
|
|
3548
|
+
if (!ready || viewer === null || viewer?.signedIn === null) return "all";
|
|
3549
|
+
return viewer?.signedIn === true ? "signed-in" : "guest";
|
|
3550
|
+
}
|
|
3551
|
+
function Bar({ raw, props, builder }) {
|
|
3552
|
+
const { props: settings, mediaOrigin, locale, editMode } = props;
|
|
3553
|
+
const design = useSiteDesign6();
|
|
3554
|
+
const viewer = useViewer();
|
|
3555
|
+
const all2 = useMemo(() => normalizeMessages(Array.isArray(raw.messages) ? raw.messages : []), [raw]);
|
|
3556
|
+
const style = isRecord(raw.style) ? raw.style : {};
|
|
3557
|
+
const rotate = isRecord(raw.rotate) ? raw.rotate : {};
|
|
3558
|
+
const [ready, setReady] = useState5(false);
|
|
3559
|
+
const [dismissed, setDismissed] = useState5(() => /* @__PURE__ */ new Set());
|
|
3560
|
+
const [at, setAt] = useState5(0);
|
|
3561
|
+
const [hover, setHover] = useState5(false);
|
|
3562
|
+
const [focus, setFocus] = useState5(false);
|
|
3563
|
+
const [reduced2, setReduced] = useState5(false);
|
|
3564
|
+
const site = builder?.site;
|
|
3565
|
+
const loadedAt = site?.status === "ok" && site.loadedAt !== void 0 ? Date.parse(site.loadedAt) : Number.NaN;
|
|
3566
|
+
const now = ready || Number.isNaN(loadedAt) ? Date.now() : loadedAt;
|
|
3567
|
+
const page = pageOf2(builder);
|
|
3568
|
+
const eligible = eligibleOnAnyDevice(all2, now, audienceOf(ready, viewer), page);
|
|
3569
|
+
const shown2 = eligible.filter((m) => editMode || !dismissed.has(m.id));
|
|
3570
|
+
const forEveryone = new Set(eligibleOnAnyDevice(all2, now, "all", page).map((m) => m.id));
|
|
3571
|
+
const waiting = [...eligibleOnAnyDevice(all2, now, "guest", page), ...eligibleOnAnyDevice(all2, now, "signed-in", page)].some(
|
|
3572
|
+
(m) => !forEveryone.has(m.id)
|
|
3573
|
+
);
|
|
3574
|
+
const interactive = props.interactive !== false && !editMode;
|
|
3575
|
+
const rotating = interactive && rotate.enabled === true && shown2.length > 1;
|
|
3576
|
+
const current = Math.min(at, Math.max(0, shown2.length - 1));
|
|
3577
|
+
const intervalS = typeof rotate.intervalS === "number" ? Math.min(15, Math.max(3, rotate.intervalS)) : 6;
|
|
3578
|
+
const shownRef = useRef3(shown2);
|
|
3579
|
+
shownRef.current = shown2;
|
|
3580
|
+
useEffect7(() => {
|
|
3581
|
+
setReady(true);
|
|
3582
|
+
setDismissed(new Set(readDismissed(all2.map((m) => m.id))));
|
|
3583
|
+
}, [all2]);
|
|
3584
|
+
useEffect7(() => {
|
|
3585
|
+
const query = window.matchMedia?.(REDUCED);
|
|
3586
|
+
if (query === void 0) return void 0;
|
|
3587
|
+
const sync = () => setReduced(query.matches);
|
|
3588
|
+
sync();
|
|
3589
|
+
query.addEventListener?.("change", sync);
|
|
3590
|
+
return () => query.removeEventListener?.("change", sync);
|
|
3591
|
+
}, []);
|
|
3592
|
+
const step2 = (direction) => setAt((from) => {
|
|
3593
|
+
const list2 = shownRef.current;
|
|
3594
|
+
const device = deviceNow();
|
|
3595
|
+
let i = Math.min(from, list2.length - 1);
|
|
3596
|
+
for (let tries = 0; tries < list2.length; tries += 1) {
|
|
3597
|
+
i = (i + direction + list2.length) % list2.length;
|
|
3598
|
+
if (list2[i].devices.includes(device)) return i;
|
|
3599
|
+
}
|
|
3600
|
+
return from;
|
|
3601
|
+
});
|
|
3602
|
+
useEffect7(() => {
|
|
3603
|
+
const list2 = shownRef.current;
|
|
3604
|
+
if (list2.length > 1 && list2[0] !== void 0 && !list2[0].devices.includes(deviceNow())) step2(1);
|
|
3605
|
+
}, [ready]);
|
|
3606
|
+
useEffect7(() => {
|
|
3607
|
+
if (!rotating || hover || focus || reduced2) return void 0;
|
|
3608
|
+
const timer = setInterval(() => step2(1), intervalS * 1e3);
|
|
3609
|
+
return () => clearInterval(timer);
|
|
3610
|
+
}, [rotating, hover, focus, reduced2, intervalS]);
|
|
3611
|
+
if (raw.enabled !== true) return /* @__PURE__ */ jsx34(Placeholder, { editMode, children: "No announcement: turn one on in Site settings" });
|
|
3612
|
+
const reserve = eligible.length === 0 && waiting;
|
|
3613
|
+
if (shown2.length === 0 && !reserve) return /* @__PURE__ */ jsx34(Placeholder, { editMode, children: "No announcement is showing now" });
|
|
3614
|
+
const link = makeLink(builder, props.resolveLink, mediaOrigin);
|
|
3615
|
+
const word = (key, fallback) => {
|
|
3616
|
+
for (const strings of [site?.status === "ok" ? site.settings.strings : void 0, design?.strings]) {
|
|
3617
|
+
if (isRecord(strings) && Object.hasOwn(strings, key) && str(strings[key]) !== void 0) return strings[key];
|
|
3618
|
+
}
|
|
3619
|
+
return fallback;
|
|
3620
|
+
};
|
|
3621
|
+
const dismissLabel = word("announcement.dismiss", SITE_STRING_DEFAULTS6["announcement.dismiss"]);
|
|
3622
|
+
const dismissible = interactive && style.dismissible === true && settings.dismissible !== false;
|
|
3623
|
+
const dismiss = (id) => {
|
|
3624
|
+
writeDismissed(id);
|
|
3625
|
+
setDismissed((previous) => new Set(previous).add(id));
|
|
3626
|
+
};
|
|
3627
|
+
const height = isRecord(style.height) ? style.height : {};
|
|
3628
|
+
const vars = {};
|
|
3629
|
+
for (const [device, key] of [["desktop", "--tb-an-hd"], ["tablet", "--tb-an-ht"], ["phone", "--tb-an-hp"]]) {
|
|
3630
|
+
const value = Object.hasOwn(height, device) ? height[device] : null;
|
|
3631
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 200) vars[key] = `${String(value)}px`;
|
|
3632
|
+
}
|
|
3633
|
+
const background = colorOf(style.background);
|
|
3634
|
+
const foreground = colorOf(style.text);
|
|
3635
|
+
if (background !== void 0) vars["--tb-an-bg"] = background;
|
|
3636
|
+
if (foreground !== void 0) vars["--tb-an-fg"] = foreground;
|
|
3637
|
+
const align = style.align === "left" || style.align === "right" ? style.align : "center";
|
|
3638
|
+
const size = style.size === "m" ? "m" : "s";
|
|
3639
|
+
const transition = rotate.transition === "slide" ? "slide" : "fade";
|
|
3640
|
+
const activeMessage = shown2[current];
|
|
3641
|
+
const live = rotating && !hover && !focus && !reduced2 ? "off" : "polite";
|
|
3642
|
+
const dismissButton = (id) => /* @__PURE__ */ jsx34("button", { type: "button", className: "tb-b-dismiss", onClick: () => dismiss(id), children: /* @__PURE__ */ jsx34(Icon5, { name: "close", size: 16, label: dismissLabel }) });
|
|
3643
|
+
return /* @__PURE__ */ jsxs25(Fragment22, { children: [
|
|
3644
|
+
/* @__PURE__ */ jsx34(BasicStyles, {}),
|
|
3645
|
+
/* @__PURE__ */ jsx34("style", { href: "tb-an", precedence: "throttle", children: ANNOUNCEMENT_V2_CSS }),
|
|
3646
|
+
/* @__PURE__ */ jsxs25(
|
|
3647
|
+
"div",
|
|
3648
|
+
{
|
|
3649
|
+
className: `tb-an tb-an--${size} tb-an--${transition}${rotating ? " tb-an--rot" : ""}${reserve ? " tb-an--reserve" : ""}`,
|
|
3650
|
+
role: "region",
|
|
3651
|
+
"aria-label": word("announcement.label", "Announcement"),
|
|
3652
|
+
"data-align": align,
|
|
3653
|
+
style: vars,
|
|
3654
|
+
onMouseEnter: () => setHover(true),
|
|
3655
|
+
onMouseLeave: () => setHover(false),
|
|
3656
|
+
onFocus: () => setFocus(true),
|
|
3657
|
+
onBlur: () => setFocus(false),
|
|
3658
|
+
children: [
|
|
3659
|
+
rotating && /* @__PURE__ */ jsx34("button", { type: "button", className: "tb-an-step", "data-tb-an-prev": "", "aria-label": word("announcement.previous", "Previous announcement"), onClick: () => step2(-1), children: /* @__PURE__ */ jsx34("span", { "aria-hidden": "true", children: "\u2039" }) }),
|
|
3660
|
+
/* @__PURE__ */ jsx34("div", { className: "tb-an-track", ...rotating ? { "aria-live": live } : {}, children: shown2.map((m, index) => {
|
|
3661
|
+
const target2 = isRecord(m.target) ? m.target : null;
|
|
3662
|
+
const hidden = DEVICES5.filter((d) => !m.devices.includes(d)).map((d) => ` tb-an-hide-${d}`).join("");
|
|
3663
|
+
return /* @__PURE__ */ jsxs25(
|
|
3664
|
+
"div",
|
|
3665
|
+
{
|
|
3666
|
+
className: `tb-b-announcement tb-an-msg${hidden}`,
|
|
3667
|
+
...rotating && index === current ? { "data-active": "" } : {},
|
|
3668
|
+
children: [
|
|
3669
|
+
/* @__PURE__ */ jsx34("span", { className: "tb-b-announcement-text", children: /* @__PURE__ */ jsx34(MessageText, { message: m, locale, mediaOrigin, href: target2 === null ? null : link(target2) }) }),
|
|
3670
|
+
!rotating && dismissible && dismissButton(m.id)
|
|
3671
|
+
]
|
|
3672
|
+
},
|
|
3673
|
+
m.id
|
|
3674
|
+
);
|
|
3675
|
+
}) }),
|
|
3676
|
+
rotating && /* @__PURE__ */ jsx34("button", { type: "button", className: "tb-an-step", "data-tb-an-next": "", "aria-label": word("announcement.next", "Next announcement"), onClick: () => step2(1), children: /* @__PURE__ */ jsx34("span", { "aria-hidden": "true", children: "\u203A" }) }),
|
|
3677
|
+
rotating && dismissible && activeMessage !== void 0 && dismissButton(activeMessage.id)
|
|
3678
|
+
]
|
|
3679
|
+
}
|
|
3680
|
+
)
|
|
3681
|
+
] });
|
|
3682
|
+
}
|
|
3683
|
+
function AnnouncementV2(props) {
|
|
3684
|
+
const builder = useBuilder();
|
|
3685
|
+
const site = builder?.site;
|
|
3686
|
+
const raw = site?.status === "ok" && isRecord(site.settings.announcement) ? site.settings.announcement : null;
|
|
3687
|
+
if (raw === null || !Array.isArray(raw.messages)) return /* @__PURE__ */ jsx34(Announcement, { ...props });
|
|
3688
|
+
return /* @__PURE__ */ jsx34(Bar, { raw, props, builder });
|
|
3689
|
+
}
|
|
3690
|
+
var ANNOUNCEMENT_V2_CSS = `@layer throttle{
|
|
3691
|
+
.tb-an{--tb-an-rf:0px;display:flex;align-items:stretch;box-sizing:border-box;min-block-size:var(--tb-an-hd,var(--tb-an-rf));background:var(--b-background,var(--tb-an-bg,var(--tb-color-primary,#111)))}
|
|
3692
|
+
.tb-an--reserve,.tb-an--rot{--tb-an-rf:2.5rem}
|
|
3693
|
+
.tb-an-track{flex:1 1 auto;min-inline-size:0}
|
|
3694
|
+
.tb-an .tb-b-announcement{background:var(--b-background,var(--tb-an-bg,var(--tb-color-primary,#111)));color:var(--b-color,var(--tb-an-fg,var(--tb-color-primary-foreground,#fff)));text-align:var(--b-align,center);overflow-wrap:anywhere}
|
|
3695
|
+
.tb-an[data-align=left] .tb-b-announcement{text-align:var(--b-align,start);justify-content:flex-start}
|
|
3696
|
+
.tb-an[data-align=right] .tb-b-announcement{text-align:var(--b-align,end);justify-content:flex-end}
|
|
3697
|
+
.tb-an--m .tb-b-announcement{font-size:var(--tb-text-m)}
|
|
3698
|
+
.tb-an-text{display:inline}
|
|
3699
|
+
.tb-an-step{flex:0 0 auto;min-inline-size:32px;padding:0;border:0;background:transparent;color:var(--b-color,var(--tb-an-fg,var(--tb-color-primary-foreground,#fff)));font:inherit;cursor:pointer}
|
|
3700
|
+
.tb-an-step:focus-visible{outline:2px solid currentColor;outline-offset:-2px}
|
|
3701
|
+
[dir=rtl] .tb-an-step span{display:inline-block;transform:scaleX(-1)}
|
|
3702
|
+
.tb-an--rot .tb-an-track{display:grid}
|
|
3703
|
+
.tb-an--rot .tb-an-msg{grid-area:1/1}
|
|
3704
|
+
.tb-an--rot .tb-an-msg:not([data-active]){visibility:hidden}
|
|
3705
|
+
@media (prefers-reduced-motion:no-preference){.tb-an--fade .tb-an-msg[data-active]{animation:tb-an-fade .4s ease}.tb-an--slide .tb-an-msg[data-active]{animation:tb-an-slide .4s ease}}
|
|
3706
|
+
@keyframes tb-an-fade{from{opacity:0}to{opacity:1}}
|
|
3707
|
+
@keyframes tb-an-slide{from{opacity:0;transform:translateY(-.75rem)}to{opacity:1;transform:none}}
|
|
3708
|
+
@media (max-width:1024.98px){.tb-an{min-block-size:var(--tb-an-ht,var(--tb-an-hd,var(--tb-an-rf)))}}
|
|
3709
|
+
@media (max-width:767.98px){.tb-an{min-block-size:var(--tb-an-hp,var(--tb-an-ht,var(--tb-an-hd,var(--tb-an-rf))))}}
|
|
3710
|
+
@media (min-width:1024.99px){.tb-an-hide-desktop{display:none}}
|
|
3711
|
+
@media (min-width:767.99px) and (max-width:1024.98px){.tb-an-hide-tablet{display:none}}
|
|
3712
|
+
@media (max-width:767.98px){.tb-an-hide-phone{display:none}}
|
|
3713
|
+
}`;
|
|
3714
|
+
var definition2 = BASIC_WIDGET_DEFINITIONS2.find((d) => d.type === "basic.announcement");
|
|
3715
|
+
if (definition2 === void 0) throw new Error("builder-schema has no basic.announcement definition");
|
|
3716
|
+
var announcementV2Widgets = [{ ...definition2, Component: AnnouncementV2 }];
|
|
3717
|
+
|
|
3718
|
+
// src/basics/v2/breadcrumbs.tsx
|
|
3719
|
+
import { useSiteDesign as useSiteDesign7 } from "@usethrottle/ui";
|
|
3720
|
+
import { safeUrl as safeUrl13 } from "@usethrottle/builder-schema";
|
|
3721
|
+
|
|
3722
|
+
// src/basics/v2/definitions.ts
|
|
3723
|
+
import { MB_BASIC_WIDGET_DEFINITIONS as MB_BASIC_WIDGET_DEFINITIONS2 } from "@usethrottle/builder-schema";
|
|
3724
|
+
function mbDefinition(type) {
|
|
3725
|
+
const found = MB_BASIC_WIDGET_DEFINITIONS2.filter((d) => d.type === type).sort((a, b) => b.v - a.v)[0];
|
|
3726
|
+
if (found === void 0) throw new Error(`No MB definition of ${type}`);
|
|
3727
|
+
return found;
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
// src/basics/v2/breadcrumbs.tsx
|
|
3731
|
+
import { Fragment as Fragment23, jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
3732
|
+
var SEPARATORS = { slash: "/", chevron: "\u203A", dot: "\xB7", arrow: "\u2192" };
|
|
3733
|
+
function jsonLdOn(settings) {
|
|
3734
|
+
if (!isRecord(settings) || !isRecord(settings.seo) || !isRecord(settings.seo.structuredData)) return false;
|
|
3735
|
+
return settings.seo.structuredData.breadcrumbs === true;
|
|
3736
|
+
}
|
|
3737
|
+
function Breadcrumbs({ props, data, mediaOrigin, resolveLink, editMode }) {
|
|
3738
|
+
const design = useSiteDesign7();
|
|
3739
|
+
const builder = useBuilder();
|
|
3740
|
+
const product = isRecord(data.product) ? data.product : null;
|
|
3741
|
+
const title = product === null ? void 0 : str(product.title) ?? str(product.handle);
|
|
3742
|
+
if (product === null || title === void 0) {
|
|
3743
|
+
return /* @__PURE__ */ jsxs26(Fragment23, { children: [
|
|
3744
|
+
/* @__PURE__ */ jsx35(BasicV2Styles, {}),
|
|
3745
|
+
/* @__PURE__ */ jsx35(Placeholder, { editMode, children: "The trail appears on a product page" })
|
|
3746
|
+
] });
|
|
3747
|
+
}
|
|
3748
|
+
const href = (target2) => safeUrl13(resolveLink?.(target2), "href", { mediaOrigin });
|
|
3749
|
+
const trail = [{ name: str(design?.brand?.storeName?.trim()) ?? "Home", href: "/" }];
|
|
3750
|
+
for (const step2 of Array.isArray(product.breadcrumbs) ? product.breadcrumbs : []) {
|
|
3751
|
+
if (!isRecord(step2) || str(step2.name) === void 0) continue;
|
|
3752
|
+
const handle2 = str(step2.handle);
|
|
3753
|
+
trail.push({ name: step2.name, href: handle2 === void 0 ? null : href({ kind: "category", handle: handle2 }) });
|
|
2562
3754
|
}
|
|
3755
|
+
const handle = str(product.handle);
|
|
3756
|
+
const current = { name: title, href: handle === void 0 ? null : href({ kind: "product", handle }) };
|
|
3757
|
+
const shown2 = props.showCurrent === false ? trail : [...trail, current];
|
|
3758
|
+
const separator = SEPARATORS[oneOf(props.separator, ["slash", "chevron", "dot", "arrow"], "slash")];
|
|
3759
|
+
const jsonLd = builder !== null && builder.site.status === "ok" && jsonLdOn(builder.site.settings) ? jsonLdString(breadcrumbJsonLd(shown2.flatMap((crumb) => crumb.href === null ? [] : [{ name: crumb.name, url: crumb.href }]))) : null;
|
|
3760
|
+
return /* @__PURE__ */ jsxs26(Fragment23, { children: [
|
|
3761
|
+
/* @__PURE__ */ jsx35(BasicV2Styles, {}),
|
|
3762
|
+
/* @__PURE__ */ jsxs26("nav", { className: "tb-b-crumbs", "aria-label": "Breadcrumb", children: [
|
|
3763
|
+
/* @__PURE__ */ jsx35("ol", { children: shown2.map((crumb, index) => {
|
|
3764
|
+
const last = index === shown2.length - 1 && props.showCurrent !== false;
|
|
3765
|
+
return /* @__PURE__ */ jsxs26("li", { children: [
|
|
3766
|
+
index > 0 && /* @__PURE__ */ jsx35("span", { className: "tb-b-crumbs-sep", "aria-hidden": "true", children: separator }),
|
|
3767
|
+
last ? /* @__PURE__ */ jsx35("span", { "aria-current": "page", children: crumb.name }) : crumb.href === null ? /* @__PURE__ */ jsx35("span", { children: crumb.name }) : /* @__PURE__ */ jsx35("a", { href: crumb.href, children: crumb.name })
|
|
3768
|
+
] }, `${String(index)}:${crumb.name}`);
|
|
3769
|
+
}) }),
|
|
3770
|
+
jsonLd !== null && /* @__PURE__ */ jsx35("script", { type: "application/ld+json", children: jsonLd })
|
|
3771
|
+
] })
|
|
3772
|
+
] });
|
|
3773
|
+
}
|
|
3774
|
+
var breadcrumbsWidgets = [{ ...mbDefinition("basic.breadcrumbs"), Component: Breadcrumbs }];
|
|
3775
|
+
|
|
3776
|
+
// src/basics/v2/faq.tsx
|
|
3777
|
+
import { useId as useId3, useRef as useRef4, useState as useState7 } from "react";
|
|
3778
|
+
import { sanitizeRichContent } from "@usethrottle/builder-schema";
|
|
3779
|
+
|
|
3780
|
+
// src/basics/v2/markup.tsx
|
|
3781
|
+
import { createElement as createElement4, useEffect as useEffect8, useState as useState6 } from "react";
|
|
3782
|
+
import { RICH_CONTENT_ALLOWED_TAGS, SVG_ALLOWED_TAGS, SVG_MAX_BYTES, safeUrl as safeUrl14, sanitizeSvg } from "@usethrottle/builder-schema";
|
|
3783
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
3784
|
+
var RICH = new Set(RICH_CONTENT_ALLOWED_TAGS);
|
|
3785
|
+
var SVG = new Set(SVG_ALLOWED_TAGS);
|
|
3786
|
+
var VOID2 = /* @__PURE__ */ new Set(["br", "hr", "img"]);
|
|
3787
|
+
var MAX_DEPTH4 = 24;
|
|
3788
|
+
var TOKEN = /<(\/?)([A-Za-z][A-Za-z0-9]*)((?:\s+[^\s="'<>/]+(?:="[^"]*")?)*)\s*(\/?)>|([^<]+)|</gu;
|
|
3789
|
+
var ATTR = /\s+([^\s="'<>/]+)(?:="([^"]*)")?/gu;
|
|
3790
|
+
var ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\xA0" };
|
|
3791
|
+
function decode2(value) {
|
|
3792
|
+
return value.replace(/&(?:#x([0-9a-f]{1,6})|#(\d{1,7})|([a-z]{2,6}));/giu, (whole, hex, dec, name) => {
|
|
3793
|
+
if (name !== void 0) return Object.hasOwn(ENTITIES, name.toLowerCase()) ? ENTITIES[name.toLowerCase()] : whole;
|
|
3794
|
+
const code = hex !== void 0 ? Number.parseInt(hex, 16) : Number.parseInt(dec ?? "", 10);
|
|
3795
|
+
return code > 0 && code <= 1114111 && !(code >= 55296 && code <= 57343) ? String.fromCodePoint(code) : "";
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
function parseMarkup(markup, kind) {
|
|
3799
|
+
const allowed = kind === "rich" ? RICH : SVG;
|
|
3800
|
+
const root = { tag: "#root", attrs: [], children: [] };
|
|
3801
|
+
const stack = [root];
|
|
3802
|
+
let skipping = 0;
|
|
3803
|
+
for (const match of markup.matchAll(TOKEN)) {
|
|
3804
|
+
const [, closing, name, attrText2, selfClose, text2] = match;
|
|
3805
|
+
const top = stack[stack.length - 1];
|
|
3806
|
+
if (name === void 0) {
|
|
3807
|
+
if (skipping === 0 && text2 !== void 0) top.children.push(decode2(text2));
|
|
3808
|
+
continue;
|
|
3809
|
+
}
|
|
3810
|
+
const tag = [...allowed].find((candidate) => candidate.toLowerCase() === name.toLowerCase());
|
|
3811
|
+
if (closing === "/") {
|
|
3812
|
+
if (skipping > 0) skipping -= 1;
|
|
3813
|
+
else if (tag !== void 0 && stack.length > 1 && top.tag === tag) stack.pop();
|
|
3814
|
+
continue;
|
|
3815
|
+
}
|
|
3816
|
+
const isVoid = VOID2.has(name.toLowerCase());
|
|
3817
|
+
if (tag === void 0 || stack.length > MAX_DEPTH4) {
|
|
3818
|
+
if (selfClose !== "/" && !isVoid) skipping += 1;
|
|
3819
|
+
continue;
|
|
3820
|
+
}
|
|
3821
|
+
if (skipping > 0) {
|
|
3822
|
+
if (selfClose !== "/" && !isVoid) skipping += 1;
|
|
3823
|
+
continue;
|
|
3824
|
+
}
|
|
3825
|
+
const attrs = [];
|
|
3826
|
+
for (const a of (attrText2 ?? "").matchAll(ATTR)) attrs.push([a[1], decode2(a[2] ?? "")]);
|
|
3827
|
+
const element = { tag, attrs, children: [] };
|
|
3828
|
+
top.children.push(element);
|
|
3829
|
+
if (selfClose !== "/" && !isVoid) stack.push(element);
|
|
3830
|
+
}
|
|
3831
|
+
return root.children;
|
|
3832
|
+
}
|
|
3833
|
+
function textOf2(nodes) {
|
|
3834
|
+
return nodes.map((n) => typeof n === "string" ? n : n.tag === "br" ? " " : textOf2(n.children)).join("");
|
|
3835
|
+
}
|
|
3836
|
+
var SPECIAL = {
|
|
3837
|
+
class: "className",
|
|
3838
|
+
colspan: "colSpan",
|
|
3839
|
+
rowspan: "rowSpan",
|
|
3840
|
+
"xlink:href": "xlinkHref",
|
|
3841
|
+
"xml:space": "xmlSpace",
|
|
3842
|
+
"xmlns:xlink": "xmlnsXlink"
|
|
2563
3843
|
};
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
3844
|
+
var camel = (name) => name.replace(/-([a-z])/gu, (_m, c) => c.toUpperCase());
|
|
3845
|
+
function styleOf(value) {
|
|
3846
|
+
const out = {};
|
|
3847
|
+
for (const declaration of value.split(";")) {
|
|
3848
|
+
const colon = declaration.indexOf(":");
|
|
3849
|
+
if (colon === -1) continue;
|
|
3850
|
+
const property = declaration.slice(0, colon).trim();
|
|
3851
|
+
const v = declaration.slice(colon + 1).trim();
|
|
3852
|
+
if (/^[a-z][a-z-]*$/u.test(property) && v !== "") out[camel(property)] = v;
|
|
3853
|
+
}
|
|
3854
|
+
return out;
|
|
3855
|
+
}
|
|
3856
|
+
var HYPHENATED = /* @__PURE__ */ new Set([
|
|
3857
|
+
"alignment-baseline",
|
|
3858
|
+
"baseline-shift",
|
|
3859
|
+
"clip-path",
|
|
3860
|
+
"clip-rule",
|
|
3861
|
+
"color-interpolation",
|
|
3862
|
+
"color-interpolation-filters",
|
|
3863
|
+
"dominant-baseline",
|
|
3864
|
+
"fill-opacity",
|
|
3865
|
+
"fill-rule",
|
|
3866
|
+
"flood-color",
|
|
3867
|
+
"flood-opacity",
|
|
3868
|
+
"font-family",
|
|
3869
|
+
"font-size",
|
|
3870
|
+
"font-size-adjust",
|
|
3871
|
+
"font-stretch",
|
|
3872
|
+
"font-style",
|
|
3873
|
+
"font-variant",
|
|
3874
|
+
"font-weight",
|
|
3875
|
+
"letter-spacing",
|
|
3876
|
+
"lighting-color",
|
|
3877
|
+
"marker-end",
|
|
3878
|
+
"marker-mid",
|
|
3879
|
+
"marker-start",
|
|
3880
|
+
"paint-order",
|
|
3881
|
+
"shape-rendering",
|
|
3882
|
+
"stop-color",
|
|
3883
|
+
"stop-opacity",
|
|
3884
|
+
"stroke-dasharray",
|
|
3885
|
+
"stroke-dashoffset",
|
|
3886
|
+
"stroke-linecap",
|
|
3887
|
+
"stroke-linejoin",
|
|
3888
|
+
"stroke-miterlimit",
|
|
3889
|
+
"stroke-opacity",
|
|
3890
|
+
"stroke-width",
|
|
3891
|
+
"text-anchor",
|
|
3892
|
+
"text-decoration",
|
|
3893
|
+
"text-rendering",
|
|
3894
|
+
"vector-effect",
|
|
3895
|
+
"word-spacing",
|
|
3896
|
+
"writing-mode"
|
|
3897
|
+
]);
|
|
3898
|
+
var DENIED_PROP = /^(?:children|key|ref|dangerously|innerhtml|outerhtml|suppress|on)/iu;
|
|
3899
|
+
function propName(name) {
|
|
3900
|
+
if (Object.hasOwn(SPECIAL, name)) return SPECIAL[name];
|
|
3901
|
+
if (/^(?:aria|data)-[a-z0-9-]{1,60}$/u.test(name)) return name;
|
|
3902
|
+
const prop = HYPHENATED.has(name) ? camel(name) : name;
|
|
3903
|
+
if (!/^[a-z][a-zA-Z0-9]*$/u.test(prop) || DENIED_PROP.test(prop)) return null;
|
|
3904
|
+
return prop;
|
|
3905
|
+
}
|
|
3906
|
+
function propsOf(element, key) {
|
|
3907
|
+
const props = { key };
|
|
3908
|
+
for (const [name, value] of element.attrs) {
|
|
3909
|
+
if (name === "style") {
|
|
3910
|
+
props.style = styleOf(value);
|
|
3911
|
+
continue;
|
|
3912
|
+
}
|
|
3913
|
+
const prop = propName(name);
|
|
3914
|
+
if (prop !== null) props[prop] = value;
|
|
3915
|
+
}
|
|
3916
|
+
return props;
|
|
3917
|
+
}
|
|
3918
|
+
var FRAGMENT = /^#[A-Za-z_][\w:.-]{0,99}$/u;
|
|
3919
|
+
function checkUrls(tag, props, mediaOrigin) {
|
|
3920
|
+
for (const key of ["href", "xlinkHref", "src"]) {
|
|
3921
|
+
if (!Object.hasOwn(props, key)) continue;
|
|
3922
|
+
const value = props[key];
|
|
3923
|
+
const safe = SVG.has(tag) ? typeof value === "string" && FRAGMENT.test(value) ? value : null : safeUrl14(value, key === "src" ? "src" : "href", { mediaOrigin });
|
|
3924
|
+
if (safe !== null) {
|
|
3925
|
+
props[key] = safe;
|
|
3926
|
+
continue;
|
|
3927
|
+
}
|
|
3928
|
+
if (tag === "a" || tag === "img") return false;
|
|
3929
|
+
delete props[key];
|
|
3930
|
+
}
|
|
3931
|
+
return true;
|
|
3932
|
+
}
|
|
3933
|
+
function renderMarkup(nodes, options = {}) {
|
|
3934
|
+
return nodes.map((node, index) => {
|
|
3935
|
+
if (typeof node === "string") return node;
|
|
3936
|
+
const props = { ...propsOf(node, index), ...options.extra?.(node) ?? {} };
|
|
3937
|
+
if (!checkUrls(node.tag, props, options.mediaOrigin ?? "")) return null;
|
|
3938
|
+
if (VOID2.has(node.tag)) return createElement4(node.tag, props);
|
|
3939
|
+
return createElement4(node.tag, props, ...renderMarkup(node.children, options));
|
|
3940
|
+
});
|
|
3941
|
+
}
|
|
3942
|
+
function svgElement(svg) {
|
|
3943
|
+
const clean = sanitizeSvg(svg).svg;
|
|
3944
|
+
if (clean === "") return null;
|
|
3945
|
+
const root = parseMarkup(clean, "svg")[0];
|
|
3946
|
+
if (root === void 0 || typeof root === "string" || root.tag !== "svg") return null;
|
|
3947
|
+
const withFill = root.attrs.some(([name]) => name === "fill") ? root : { ...root, attrs: [...root.attrs, ["fill", "currentColor"]] };
|
|
3948
|
+
return renderMarkup([withFill])[0] ?? null;
|
|
3949
|
+
}
|
|
3950
|
+
async function readSvg(response, mediaOrigin) {
|
|
3951
|
+
if (!response.ok || safeUrl14(response.url, "src", { mediaOrigin }) === null) return null;
|
|
3952
|
+
if (!/^image\/svg\+xml(?:\s*;|$)/iu.test(response.headers.get("content-type") ?? "")) return null;
|
|
3953
|
+
const reader = response.body?.getReader();
|
|
3954
|
+
if (reader === void 0) {
|
|
3955
|
+
const text3 = await response.text();
|
|
3956
|
+
return new TextEncoder().encode(text3).length > SVG_MAX_BYTES ? null : text3;
|
|
3957
|
+
}
|
|
3958
|
+
const decoder = new TextDecoder();
|
|
3959
|
+
let total = 0;
|
|
3960
|
+
let text2 = "";
|
|
3961
|
+
for (; ; ) {
|
|
3962
|
+
const { done, value } = await reader.read();
|
|
3963
|
+
if (done) return text2 + decoder.decode();
|
|
3964
|
+
total += value.length;
|
|
3965
|
+
if (total > SVG_MAX_BYTES) {
|
|
3966
|
+
await reader.cancel();
|
|
3967
|
+
return null;
|
|
3968
|
+
}
|
|
3969
|
+
text2 += decoder.decode(value, { stream: true });
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
function SvgFromAsset({ asset, mediaOrigin, label }) {
|
|
3973
|
+
const src = isFrozenAsset(asset) ? safeUrl14(asset.url, "src", { mediaOrigin }) : null;
|
|
3974
|
+
const [source, setSource] = useState6(null);
|
|
3975
|
+
useEffect8(() => {
|
|
3976
|
+
if (src === null) return;
|
|
3977
|
+
const controller = new AbortController();
|
|
3978
|
+
fetch(src, { credentials: "omit", redirect: "error", signal: controller.signal }).then((response) => readSvg(response, mediaOrigin)).then((text2) => {
|
|
3979
|
+
if (text2 !== null && !controller.signal.aborted) setSource(text2);
|
|
3980
|
+
}).catch(() => void 0);
|
|
3981
|
+
return () => controller.abort();
|
|
3982
|
+
}, [src]);
|
|
3983
|
+
if (src === null) return null;
|
|
3984
|
+
const inline2 = source === null ? null : svgElement(source);
|
|
3985
|
+
if (inline2 !== null) return inline2;
|
|
3986
|
+
return /* @__PURE__ */ jsx36(AssetImage, { asset, mediaOrigin, alt: label ?? "", loading: "eager" });
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
// src/basics/v2/faq.tsx
|
|
3990
|
+
import { Fragment as Fragment24, jsx as jsx37, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3991
|
+
function itemsOf(value) {
|
|
3992
|
+
if (!Array.isArray(value)) return [];
|
|
3993
|
+
return value.flatMap((row) => {
|
|
3994
|
+
if (!isRecord(row)) return [];
|
|
3995
|
+
const question = str(row.question);
|
|
3996
|
+
return question === void 0 ? [] : [{ question, answer: typeof row.answer === "string" ? row.answer : "" }];
|
|
3997
|
+
});
|
|
3998
|
+
}
|
|
3999
|
+
function faqJsonLdOn(settings) {
|
|
4000
|
+
if (!isRecord(settings) || !isRecord(settings.seo) || !isRecord(settings.seo.structuredData)) return false;
|
|
4001
|
+
return settings.seo.structuredData.faq === true;
|
|
4002
|
+
}
|
|
4003
|
+
function Faq({ props, mediaOrigin, editMode }) {
|
|
2569
4004
|
const builder = useBuilder();
|
|
2570
|
-
|
|
4005
|
+
const group = useId3();
|
|
4006
|
+
const root = useRef4(null);
|
|
4007
|
+
const [all2, setAll] = useState7(false);
|
|
4008
|
+
const items = itemsOf(props.items);
|
|
4009
|
+
if (items.length === 0) {
|
|
4010
|
+
return /* @__PURE__ */ jsxs27(Fragment24, { children: [
|
|
4011
|
+
/* @__PURE__ */ jsx37(BasicV2Styles, {}),
|
|
4012
|
+
/* @__PURE__ */ jsx37(Placeholder, { editMode, children: "Add questions in the settings" })
|
|
4013
|
+
] });
|
|
4014
|
+
}
|
|
4015
|
+
const answers = items.map((item) => parseMarkup(sanitizeRichContent(item.answer, mediaOrigin).html, "rich"));
|
|
4016
|
+
const open = props.mode === "open";
|
|
4017
|
+
const oneOpen = props.oneOpen === true;
|
|
4018
|
+
const showAll = !open && props.expandAll === true && !oneOpen;
|
|
4019
|
+
const jsonLd = builder !== null && builder.site.status === "ok" && faqJsonLdOn(builder.site.settings) ? jsonLdString(faqJsonLd(items.map((item, index) => ({ question: item.question, answer: textOf2(answers[index] ?? []).trim() })))) : null;
|
|
4020
|
+
const toggleAll = () => {
|
|
4021
|
+
const next = !all2;
|
|
4022
|
+
for (const details of root.current?.querySelectorAll("details") ?? []) details.open = next;
|
|
4023
|
+
setAll(next);
|
|
4024
|
+
};
|
|
4025
|
+
return /* @__PURE__ */ jsxs27(Fragment24, { children: [
|
|
4026
|
+
/* @__PURE__ */ jsx37(BasicV2Styles, {}),
|
|
4027
|
+
/* @__PURE__ */ jsxs27("div", { className: "tb-b-faq", ref: root, children: [
|
|
4028
|
+
showAll && /* @__PURE__ */ jsx37("button", { type: "button", className: "tb-b-faq-all", "aria-expanded": all2, onClick: toggleAll, children: all2 ? "Collapse all" : "Expand all" }),
|
|
4029
|
+
items.map(
|
|
4030
|
+
(item, index) => open ? /* @__PURE__ */ jsxs27("div", { className: "tb-b-faq-item", children: [
|
|
4031
|
+
/* @__PURE__ */ jsx37("h3", { className: "tb-b-faq-q", children: item.question }),
|
|
4032
|
+
/* @__PURE__ */ jsx37("div", { className: "tb-b-faq-a", children: renderMarkup(answers[index] ?? [], { mediaOrigin }) })
|
|
4033
|
+
] }, `${String(index)}:${item.question}`) : /* @__PURE__ */ jsxs27("details", { className: "tb-b-faq-item", ...oneOpen ? { name: `faq-${group}` } : {}, children: [
|
|
4034
|
+
/* @__PURE__ */ jsx37("summary", { className: "tb-b-faq-q", children: item.question }),
|
|
4035
|
+
/* @__PURE__ */ jsx37("div", { className: "tb-b-faq-a", children: renderMarkup(answers[index] ?? [], { mediaOrigin }) })
|
|
4036
|
+
] }, `${String(index)}:${item.question}`)
|
|
4037
|
+
),
|
|
4038
|
+
jsonLd !== null && /* @__PURE__ */ jsx37("script", { type: "application/ld+json", children: jsonLd })
|
|
4039
|
+
] })
|
|
4040
|
+
] });
|
|
4041
|
+
}
|
|
4042
|
+
var faqWidgets = [{ ...mbDefinition("basic.faq"), Component: Faq }];
|
|
4043
|
+
|
|
4044
|
+
// src/basics/v2/heading-v2.tsx
|
|
4045
|
+
var headingV2Widgets = [{ ...mbDefinition("basic.heading"), Component: Heading }];
|
|
4046
|
+
|
|
4047
|
+
// src/basics/v2/icon-list.tsx
|
|
4048
|
+
import { ICON_NAMES, Icon as Icon6 } from "@usethrottle/ui";
|
|
4049
|
+
import { Fragment as Fragment25, jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
4050
|
+
var isIconName = (name) => typeof name === "string" && ICON_NAMES.includes(name);
|
|
4051
|
+
function IconList({ props, mediaOrigin, editMode }) {
|
|
4052
|
+
const rows = Array.isArray(props.items) ? props.items.flatMap((row) => isRecord(row) ? [row] : []) : [];
|
|
4053
|
+
if (rows.length === 0) {
|
|
4054
|
+
return /* @__PURE__ */ jsxs28(Fragment25, { children: [
|
|
4055
|
+
/* @__PURE__ */ jsx38(BasicV2Styles, {}),
|
|
4056
|
+
/* @__PURE__ */ jsx38(Placeholder, { editMode, children: "Add rows in the settings" })
|
|
4057
|
+
] });
|
|
4058
|
+
}
|
|
4059
|
+
return /* @__PURE__ */ jsxs28(Fragment25, { children: [
|
|
4060
|
+
/* @__PURE__ */ jsx38(BasicV2Styles, {}),
|
|
4061
|
+
/* @__PURE__ */ jsx38("ul", { className: "tb-b-icons", children: rows.map((row, index) => /* @__PURE__ */ jsxs28("li", { children: [
|
|
4062
|
+
/* @__PURE__ */ jsx38("span", { className: "tb-b-icons-icon", "aria-hidden": "true", children: isFrozenAsset(row.svgAsset) ? /* @__PURE__ */ jsx38(SvgFromAsset, { asset: row.svgAsset, mediaOrigin }) : isIconName(row.icon) ? /* @__PURE__ */ jsx38(Icon6, { name: row.icon }) : null }),
|
|
4063
|
+
/* @__PURE__ */ jsx38("span", { className: "tb-b-icons-text", children: str(row.text) ?? "" })
|
|
4064
|
+
] }, `${String(index)}:${str(row.text) ?? ""}`)) })
|
|
4065
|
+
] });
|
|
4066
|
+
}
|
|
4067
|
+
var iconListWidgets = [{ ...mbDefinition("basic.icon-list"), Component: IconList }];
|
|
4068
|
+
|
|
4069
|
+
// src/basics/v2/merge.ts
|
|
4070
|
+
function mergeV2Widgets(v1, v2) {
|
|
4071
|
+
const replacement = /* @__PURE__ */ new Map();
|
|
4072
|
+
for (const widget of v2) {
|
|
4073
|
+
if (replacement.has(widget.type)) throw new Error(`Two v2 widgets of type ${widget.type}`);
|
|
4074
|
+
replacement.set(widget.type, widget);
|
|
4075
|
+
}
|
|
4076
|
+
const v1Types = new Set(v1.map((widget) => widget.type));
|
|
4077
|
+
return [
|
|
4078
|
+
...v1.map((widget) => replacement.get(widget.type) ?? widget),
|
|
4079
|
+
...[...replacement.values()].filter((widget) => !v1Types.has(widget.type))
|
|
4080
|
+
];
|
|
4081
|
+
}
|
|
4082
|
+
|
|
4083
|
+
// src/basics/v2/quote.tsx
|
|
4084
|
+
import { Fragment as Fragment26, jsx as jsx39, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
4085
|
+
function Quote({ props, mediaOrigin, editMode, inlineEdit }) {
|
|
4086
|
+
const quote = inlineEdit?.("quote") ?? str(props.quote);
|
|
4087
|
+
if (quote === void 0) {
|
|
4088
|
+
return /* @__PURE__ */ jsxs29(Fragment26, { children: [
|
|
4089
|
+
/* @__PURE__ */ jsx39(BasicV2Styles, {}),
|
|
4090
|
+
/* @__PURE__ */ jsx39(Placeholder, { editMode, children: "Write the quote in the settings" })
|
|
4091
|
+
] });
|
|
4092
|
+
}
|
|
4093
|
+
const name = str(props.name);
|
|
4094
|
+
const role = str(props.role);
|
|
4095
|
+
const image = isFrozenAsset(props.image) ? props.image : null;
|
|
4096
|
+
return /* @__PURE__ */ jsxs29(Fragment26, { children: [
|
|
4097
|
+
/* @__PURE__ */ jsx39(BasicV2Styles, {}),
|
|
4098
|
+
/* @__PURE__ */ jsxs29("figure", { className: "tb-b-quote", children: [
|
|
4099
|
+
/* @__PURE__ */ jsx39("blockquote", { children: quote }),
|
|
4100
|
+
(name !== void 0 || role !== void 0 || image !== null) && /* @__PURE__ */ jsxs29("figcaption", { children: [
|
|
4101
|
+
image !== null && /* @__PURE__ */ jsx39(AssetImage, { asset: image, mediaOrigin, alt: "", className: "tb-b-quote-photo" }),
|
|
4102
|
+
/* @__PURE__ */ jsxs29("span", { className: "tb-b-quote-by", children: [
|
|
4103
|
+
name !== void 0 && /* @__PURE__ */ jsx39("span", { className: "tb-b-quote-name", children: name }),
|
|
4104
|
+
role !== void 0 && /* @__PURE__ */ jsx39("span", { className: "tb-b-quote-role", children: role })
|
|
4105
|
+
] })
|
|
4106
|
+
] })
|
|
4107
|
+
] })
|
|
4108
|
+
] });
|
|
2571
4109
|
}
|
|
4110
|
+
var quoteWidgets = [{ ...mbDefinition("basic.quote"), Component: Quote }];
|
|
4111
|
+
|
|
4112
|
+
// src/basics/v2/rich-content.tsx
|
|
4113
|
+
import { sanitizeRichContent as sanitizeRichContent2 } from "@usethrottle/builder-schema";
|
|
4114
|
+
import { Fragment as Fragment27, jsx as jsx40, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
4115
|
+
var slug = (text2) => text2.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/gu, "-").replace(/^-+|-+$/gu, "").slice(0, 40);
|
|
4116
|
+
function headings(nodes, nodeId) {
|
|
4117
|
+
const found = /* @__PURE__ */ new Map();
|
|
4118
|
+
const visit = (list2) => {
|
|
4119
|
+
for (const node of list2) {
|
|
4120
|
+
if (typeof node === "string") continue;
|
|
4121
|
+
if (node.tag === "h2" || node.tag === "h3") {
|
|
4122
|
+
const label = textOf2(node.children).replace(/\s+/gu, " ").trim();
|
|
4123
|
+
const n = found.size + 1;
|
|
4124
|
+
found.set(node, { id: `${nodeId}-${String(n)}${slug(label) === "" ? "" : `-${slug(label)}`}`, level: node.tag === "h2" ? 2 : 3, label });
|
|
4125
|
+
}
|
|
4126
|
+
visit(node.children);
|
|
4127
|
+
}
|
|
4128
|
+
};
|
|
4129
|
+
visit(nodes);
|
|
4130
|
+
return found;
|
|
4131
|
+
}
|
|
4132
|
+
function RichContent({ node, props, mediaOrigin, editMode }) {
|
|
4133
|
+
const html = str(props.html);
|
|
4134
|
+
if (html === void 0) {
|
|
4135
|
+
return /* @__PURE__ */ jsxs30(Fragment27, { children: [
|
|
4136
|
+
/* @__PURE__ */ jsx40(BasicV2Styles, {}),
|
|
4137
|
+
/* @__PURE__ */ jsx40(Placeholder, { editMode, children: "Add content in the settings" })
|
|
4138
|
+
] });
|
|
4139
|
+
}
|
|
4140
|
+
const tree = parseMarkup(sanitizeRichContent2(html, mediaOrigin).html, "rich");
|
|
4141
|
+
const entries = headings(tree, node.id);
|
|
4142
|
+
const toc = props.toc === true ? [...entries.values()].filter((e) => e.label !== "") : [];
|
|
4143
|
+
return /* @__PURE__ */ jsxs30(Fragment27, { children: [
|
|
4144
|
+
/* @__PURE__ */ jsx40(BasicV2Styles, {}),
|
|
4145
|
+
/* @__PURE__ */ jsxs30("div", { className: "tb-b-rich", children: [
|
|
4146
|
+
toc.length > 0 && /* @__PURE__ */ jsxs30("nav", { className: "tb-b-toc", "aria-label": str(props.tocTitle) ?? "Contents", children: [
|
|
4147
|
+
/* @__PURE__ */ jsx40("p", { className: "tb-b-toc-title", children: str(props.tocTitle) ?? "Contents" }),
|
|
4148
|
+
/* @__PURE__ */ jsx40("ol", { children: toc.map((entry) => /* @__PURE__ */ jsx40("li", { className: `tb-b-toc-l${String(entry.level)}`, children: /* @__PURE__ */ jsx40("a", { href: `#${entry.id}`, children: entry.label }) }, entry.id)) })
|
|
4149
|
+
] }),
|
|
4150
|
+
renderMarkup(tree, {
|
|
4151
|
+
mediaOrigin,
|
|
4152
|
+
extra: (element) => {
|
|
4153
|
+
const entry = entries.get(element);
|
|
4154
|
+
return entry === void 0 ? void 0 : { id: entry.id };
|
|
4155
|
+
}
|
|
4156
|
+
})
|
|
4157
|
+
] })
|
|
4158
|
+
] });
|
|
4159
|
+
}
|
|
4160
|
+
var richContentWidgets = [{ ...mbDefinition("basic.rich-content"), Component: RichContent }];
|
|
4161
|
+
|
|
4162
|
+
// src/basics/v2/svg.tsx
|
|
4163
|
+
import { Fragment as Fragment28, jsx as jsx41, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
4164
|
+
function Svg({ props, mediaOrigin, editMode }) {
|
|
4165
|
+
const pasted = str(props.svg);
|
|
4166
|
+
const label = str(props.label);
|
|
4167
|
+
const inline2 = pasted === void 0 ? null : svgElement(pasted);
|
|
4168
|
+
const asset = pasted === void 0 && props.asset !== null && props.asset !== void 0 ? props.asset : null;
|
|
4169
|
+
if (inline2 === null && asset === null) {
|
|
4170
|
+
return /* @__PURE__ */ jsxs31(Fragment28, { children: [
|
|
4171
|
+
/* @__PURE__ */ jsx41(BasicV2Styles, {}),
|
|
4172
|
+
/* @__PURE__ */ jsx41(Placeholder, { editMode, children: "Paste an SVG or pick one from the media library" })
|
|
4173
|
+
] });
|
|
4174
|
+
}
|
|
4175
|
+
const decorative = props.decorative !== false;
|
|
4176
|
+
const access = decorative ? { "aria-hidden": true } : label === void 0 ? {} : { role: "img", "aria-label": label };
|
|
4177
|
+
return /* @__PURE__ */ jsxs31(Fragment28, { children: [
|
|
4178
|
+
/* @__PURE__ */ jsx41(BasicV2Styles, {}),
|
|
4179
|
+
/* @__PURE__ */ jsx41("div", { className: "tb-b-svg", ...access, children: inline2 ?? /* @__PURE__ */ jsx41(SvgFromAsset, { asset, mediaOrigin, ...label === void 0 || decorative ? {} : { label } }) })
|
|
4180
|
+
] });
|
|
4181
|
+
}
|
|
4182
|
+
var svgWidgets = [{ ...mbDefinition("basic.svg"), Component: Svg }];
|
|
4183
|
+
|
|
4184
|
+
// src/basics/index.ts
|
|
4185
|
+
var BASIC_COMPONENTS = {
|
|
4186
|
+
"basic.heading": Heading,
|
|
4187
|
+
"basic.text": Text,
|
|
4188
|
+
"basic.image": Image,
|
|
4189
|
+
"basic.button": Button,
|
|
4190
|
+
"basic.spacer": Spacer,
|
|
4191
|
+
"basic.divider": Divider,
|
|
4192
|
+
"basic.video": Video,
|
|
4193
|
+
"basic.logo": Logo,
|
|
4194
|
+
"basic.menu": Menu,
|
|
4195
|
+
"basic.announcement": Announcement,
|
|
4196
|
+
"basic.copyright": Copyright,
|
|
4197
|
+
"basic.countdown": Countdown
|
|
4198
|
+
};
|
|
4199
|
+
var v1Widgets = BASIC_WIDGET_DEFINITIONS3.flatMap(
|
|
4200
|
+
(definition3) => definition3.v === 1 && Object.hasOwn(BASIC_COMPONENTS, definition3.type) ? [{ ...definition3, Component: BASIC_COMPONENTS[definition3.type] }] : []
|
|
4201
|
+
);
|
|
4202
|
+
var widgets = mergeV2Widgets(v1Widgets, [
|
|
4203
|
+
...faqWidgets,
|
|
4204
|
+
...richContentWidgets,
|
|
4205
|
+
...breadcrumbsWidgets,
|
|
4206
|
+
...svgWidgets,
|
|
4207
|
+
...iconListWidgets,
|
|
4208
|
+
...quoteWidgets,
|
|
4209
|
+
...menuV2Widgets,
|
|
4210
|
+
...announcementV2Widgets,
|
|
4211
|
+
...headingV2Widgets
|
|
4212
|
+
]);
|
|
4213
|
+
var basicPack = { id: "basic", version: "0.0.0", widgets, dataSources: [] };
|
|
4214
|
+
|
|
4215
|
+
// src/custom/factory.ts
|
|
4216
|
+
import { createElement as createElement5 } from "react";
|
|
2572
4217
|
|
|
2573
4218
|
// src/custom/composite-widget.tsx
|
|
2574
|
-
import {
|
|
4219
|
+
import { Suspense as Suspense3 } from "react";
|
|
4220
|
+
import { pageDocumentSchema, validateSettingValue as validateSettingValue3 } from "@usethrottle/builder-schema";
|
|
4221
|
+
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
2575
4222
|
var SETTING_KEY_RE = /^[a-z][A-Za-z0-9]{0,39}$/;
|
|
2576
4223
|
var NODE_ID_RE = /^[a-z0-9]{8,24}$/;
|
|
2577
4224
|
var WRAP = { section: "zzcompsec001", column: "zzcompcol001", inner: "zzcompinr001" };
|
|
2578
|
-
var
|
|
4225
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2579
4226
|
var compiled3 = /* @__PURE__ */ new WeakMap();
|
|
2580
4227
|
function parseBody(raw) {
|
|
2581
|
-
if (!
|
|
4228
|
+
if (!isRecord6(raw)) return null;
|
|
2582
4229
|
const columns = Array.isArray(raw.columns) ? raw.columns : void 0;
|
|
2583
4230
|
const stack = Array.isArray(raw.stack) ? raw.stack : void 0;
|
|
2584
4231
|
if (columns === void 0 === (stack === void 0)) return null;
|
|
2585
4232
|
const children = columns !== void 0 ? [{ id: WRAP.inner, type: "inner-section", props: {}, columns }] : stack ?? [];
|
|
2586
|
-
if (stack?.some((node) =>
|
|
4233
|
+
if (stack?.some((node) => isRecord6(node) && node.type === "inner-section")) return null;
|
|
2587
4234
|
const parsed2 = pageDocumentSchema.safeParse({
|
|
2588
4235
|
schemaVersion: 1,
|
|
2589
4236
|
sections: [{ id: WRAP.section, type: "section", props: {}, columns: [{ id: WRAP.column, type: "column", props: { width: 100 }, children }] }]
|
|
@@ -2616,38 +4263,38 @@ function compile2(snapshot) {
|
|
|
2616
4263
|
const bindings = [];
|
|
2617
4264
|
if (extra.bindings !== void 0 && !Array.isArray(extra.bindings)) return refuse("bindings is not a list");
|
|
2618
4265
|
for (const raw of extra.bindings ?? []) {
|
|
2619
|
-
if (!
|
|
4266
|
+
if (!isRecord6(raw) || typeof raw.setting !== "string" || !SETTING_KEY_RE.test(raw.setting) || !Array.isArray(raw.targets)) {
|
|
2620
4267
|
return refuse("a binding is malformed");
|
|
2621
4268
|
}
|
|
2622
4269
|
const targets = [];
|
|
2623
|
-
for (const
|
|
2624
|
-
if (!
|
|
4270
|
+
for (const target2 of raw.targets) {
|
|
4271
|
+
if (!isRecord6(target2) || typeof target2.node !== "string" || !NODE_ID_RE.test(target2.node) || typeof target2.prop !== "string" || !SETTING_KEY_RE.test(target2.prop)) {
|
|
2625
4272
|
return refuse("a binding target is malformed");
|
|
2626
4273
|
}
|
|
2627
|
-
targets.push({ node:
|
|
4274
|
+
targets.push({ node: target2.node, prop: target2.prop });
|
|
2628
4275
|
}
|
|
2629
4276
|
bindings.push({ setting: raw.setting, targets });
|
|
2630
4277
|
}
|
|
2631
4278
|
const data = [];
|
|
2632
|
-
if (extra.data !== void 0 && !
|
|
4279
|
+
if (extra.data !== void 0 && !isRecord6(extra.data)) return refuse("data is not a record");
|
|
2633
4280
|
for (const [name, raw] of Object.entries(extra.data ?? {})) {
|
|
2634
|
-
if (!SETTING_KEY_RE.test(name) || !
|
|
4281
|
+
if (!SETTING_KEY_RE.test(name) || !isRecord6(raw) || !Array.isArray(raw.targets)) return refuse("a data input is malformed");
|
|
2635
4282
|
const targets = [];
|
|
2636
|
-
for (const
|
|
2637
|
-
if (!
|
|
4283
|
+
for (const target2 of raw.targets) {
|
|
4284
|
+
if (!isRecord6(target2) || typeof target2.node !== "string" || !NODE_ID_RE.test(target2.node) || typeof target2.input !== "string" || !SETTING_KEY_RE.test(target2.input)) {
|
|
2638
4285
|
return refuse("a data target is malformed");
|
|
2639
4286
|
}
|
|
2640
|
-
targets.push({ node:
|
|
4287
|
+
targets.push({ node: target2.node, input: target2.input });
|
|
2641
4288
|
}
|
|
2642
4289
|
data.push([name, { targets }]);
|
|
2643
4290
|
}
|
|
2644
4291
|
return { body, bindings, data };
|
|
2645
4292
|
}
|
|
2646
|
-
var
|
|
4293
|
+
var DEVICES6 = ["tablet", "phone"];
|
|
2647
4294
|
function withoutAnchor(node) {
|
|
2648
4295
|
delete node.props.anchor;
|
|
2649
4296
|
const responsive = node.responsive;
|
|
2650
|
-
for (const device of
|
|
4297
|
+
for (const device of DEVICES6) if (responsive?.[device] !== void 0) delete responsive[device].anchor;
|
|
2651
4298
|
}
|
|
2652
4299
|
function instanceId(outer, inner) {
|
|
2653
4300
|
let a = 3735928559;
|
|
@@ -2661,7 +4308,7 @@ function instanceId(outer, inner) {
|
|
|
2661
4308
|
b = Math.imul(b ^ b >>> 16, 2246822507) ^ Math.imul(a ^ a >>> 13, 3266489909);
|
|
2662
4309
|
return `i${(a >>> 0).toString(36).padStart(7, "0")}${(b >>> 0).toString(36).padStart(7, "0")}${(outer.length + inner.length).toString(36)}`;
|
|
2663
4310
|
}
|
|
2664
|
-
function
|
|
4311
|
+
function build2(input) {
|
|
2665
4312
|
const { snapshot, registry, node: outer, props, data } = input;
|
|
2666
4313
|
const body = structuredClone(input.compiled.body);
|
|
2667
4314
|
const assets = {};
|
|
@@ -2690,11 +4337,11 @@ function build(input) {
|
|
|
2690
4337
|
return id;
|
|
2691
4338
|
}
|
|
2692
4339
|
if (field.control === "link") {
|
|
2693
|
-
if (!
|
|
2694
|
-
const { href, ...
|
|
2695
|
-
if (
|
|
2696
|
-
hrefs.set(JSON.stringify(
|
|
2697
|
-
return
|
|
4340
|
+
if (!isRecord6(value) || typeof value.kind !== "string") return null;
|
|
4341
|
+
const { href, ...target2 } = value;
|
|
4342
|
+
if (target2.kind === "url") return typeof href === "string" ? { kind: "url", href } : null;
|
|
4343
|
+
hrefs.set(JSON.stringify(target2), typeof href === "string" ? href : null);
|
|
4344
|
+
return target2;
|
|
2698
4345
|
}
|
|
2699
4346
|
return value;
|
|
2700
4347
|
};
|
|
@@ -2702,21 +4349,21 @@ function build(input) {
|
|
|
2702
4349
|
const field = fields.get(binding.setting);
|
|
2703
4350
|
if (field === void 0 || !Object.hasOwn(props, binding.setting)) continue;
|
|
2704
4351
|
const value = props[binding.setting];
|
|
2705
|
-
for (const
|
|
2706
|
-
const inner = byId.get(
|
|
2707
|
-
const innerField = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v)?.settings.find((f) => f.key ===
|
|
4352
|
+
for (const target2 of binding.targets) {
|
|
4353
|
+
const inner = byId.get(target2.node);
|
|
4354
|
+
const innerField = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v)?.settings.find((f) => f.key === target2.prop);
|
|
2708
4355
|
if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
|
|
2709
4356
|
const converted = convert(field, value);
|
|
2710
4357
|
if (validateSettingValue3(innerField, converted) !== null) continue;
|
|
2711
|
-
inner.props[
|
|
4358
|
+
inner.props[target2.prop] = converted;
|
|
2712
4359
|
const responsive = inner.responsive;
|
|
2713
|
-
for (const device of
|
|
2714
|
-
if (responsive?.[device] !== void 0) delete responsive[device][
|
|
4360
|
+
for (const device of DEVICES6) {
|
|
4361
|
+
if (responsive?.[device] !== void 0) delete responsive[device][target2.prop];
|
|
2715
4362
|
const raw = outer.responsive?.[device];
|
|
2716
4363
|
const plain = field.output === "css" && field.translatable !== true && field.control !== "image" && field.control !== "link";
|
|
2717
4364
|
if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && validateSettingValue3(innerField, raw[binding.setting]) === null) {
|
|
2718
4365
|
const target$ = inner.responsive ?? (inner.responsive = {});
|
|
2719
|
-
(target$[device] ?? (target$[device] = {}))[
|
|
4366
|
+
(target$[device] ?? (target$[device] = {}))[target2.prop] = raw[binding.setting];
|
|
2720
4367
|
}
|
|
2721
4368
|
}
|
|
2722
4369
|
}
|
|
@@ -2724,11 +4371,11 @@ function build(input) {
|
|
|
2724
4371
|
for (const [name, input$] of input.compiled.data) {
|
|
2725
4372
|
if (!Object.hasOwn(data, name) || data[name] === void 0) continue;
|
|
2726
4373
|
const key = `composite.${name}`;
|
|
2727
|
-
for (const
|
|
2728
|
-
const inner = byId.get(
|
|
4374
|
+
for (const target2 of input$.targets) {
|
|
4375
|
+
const inner = byId.get(target2.node);
|
|
2729
4376
|
const def = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v);
|
|
2730
|
-
if (inner === void 0 || def?.data === void 0 || !Object.hasOwn(def.data,
|
|
2731
|
-
inner.data = { ...inner.data ?? {}, [
|
|
4377
|
+
if (inner === void 0 || def?.data === void 0 || !Object.hasOwn(def.data, target2.input)) continue;
|
|
4378
|
+
inner.data = { ...inner.data ?? {}, [target2.input]: { source: key } };
|
|
2732
4379
|
innerData[key] = data[name];
|
|
2733
4380
|
}
|
|
2734
4381
|
}
|
|
@@ -2756,12 +4403,12 @@ function CompositeBody(props) {
|
|
|
2756
4403
|
const { snapshot, registry, node, data, locale, mediaOrigin, budget, resolveLink, interactive, idScope } = props;
|
|
2757
4404
|
const composite = compileComposite(snapshot);
|
|
2758
4405
|
if (composite === null) return null;
|
|
2759
|
-
const built =
|
|
4406
|
+
const built = build2({ snapshot, compiled: composite, registry, node, props: props.props, data });
|
|
2760
4407
|
if (!(budget ?? new RenderBudget()).take(built.weight)) {
|
|
2761
4408
|
warnOnce(`composite-weight:${snapshot.type}@${String(snapshot.v)}`, `${snapshot.type} would render too many nodes; rendering nothing for it`);
|
|
2762
4409
|
return null;
|
|
2763
4410
|
}
|
|
2764
|
-
return /* @__PURE__ */
|
|
4411
|
+
return /* @__PURE__ */ jsx42(
|
|
2765
4412
|
BuilderRenderer,
|
|
2766
4413
|
{
|
|
2767
4414
|
document: built.document,
|
|
@@ -2772,28 +4419,28 @@ function CompositeBody(props) {
|
|
|
2772
4419
|
mediaOrigin,
|
|
2773
4420
|
interactive,
|
|
2774
4421
|
idScope,
|
|
2775
|
-
resolveLink: (
|
|
4422
|
+
resolveLink: (target2) => built.hrefs.get(JSON.stringify(target2)) ?? resolveLink?.(target2) ?? null
|
|
2776
4423
|
}
|
|
2777
4424
|
);
|
|
2778
4425
|
}
|
|
2779
4426
|
function CompositeWidget(props) {
|
|
2780
|
-
return /* @__PURE__ */
|
|
4427
|
+
return /* @__PURE__ */ jsx42(PartBoundary, { label: `${props.snapshot.type}@${String(props.snapshot.v)}`, children: /* @__PURE__ */ jsx42(Suspense3, { fallback: null, children: /* @__PURE__ */ jsx42(CompositeBody, { ...props }) }) });
|
|
2781
4428
|
}
|
|
2782
4429
|
|
|
2783
4430
|
// src/custom/factory.ts
|
|
2784
4431
|
var isDisabled = (snapshot) => snapshot.status === "disabled";
|
|
2785
|
-
var Disabled = ({ editMode }) => editMode ?
|
|
4432
|
+
var Disabled = ({ editMode }) => editMode ? createElement5("div", { className: "tb-missing" }, "This custom widget is disabled") : null;
|
|
2786
4433
|
var customWidgetFactory = (snapshot, registry) => {
|
|
2787
4434
|
if (isDisabled(snapshot)) return Disabled;
|
|
2788
4435
|
if (snapshot.kind === "template") {
|
|
2789
4436
|
const template = compileTemplate(snapshot, registry);
|
|
2790
4437
|
if (template === null) return null;
|
|
2791
|
-
const Component2 = (props) =>
|
|
4438
|
+
const Component2 = (props) => createElement5(TemplateWidget, { ...props, snapshot, registry });
|
|
2792
4439
|
componentWeights.set(Component2, template.weight);
|
|
2793
4440
|
return Component2;
|
|
2794
4441
|
}
|
|
2795
4442
|
if (compileComposite(snapshot) === null) return null;
|
|
2796
|
-
return (props) =>
|
|
4443
|
+
return (props) => createElement5(CompositeWidget, { ...props, snapshot, registry });
|
|
2797
4444
|
};
|
|
2798
4445
|
|
|
2799
4446
|
// src/registry.ts
|
|
@@ -2807,11 +4454,11 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
2807
4454
|
const sources = [];
|
|
2808
4455
|
const resolvers = /* @__PURE__ */ new Map();
|
|
2809
4456
|
for (const pack of all2) {
|
|
2810
|
-
for (const { Component: Component2, ...
|
|
2811
|
-
const key = customKey(
|
|
4457
|
+
for (const { Component: Component2, ...definition3 } of pack.widgets) {
|
|
4458
|
+
const key = customKey(definition3.type, definition3.v);
|
|
2812
4459
|
if (components.has(key)) continue;
|
|
2813
4460
|
components.set(key, Component2);
|
|
2814
|
-
definitions.push(
|
|
4461
|
+
definitions.push(definition3);
|
|
2815
4462
|
}
|
|
2816
4463
|
for (const { resolve, ...descriptor } of pack.dataSources) {
|
|
2817
4464
|
if (resolvers.has(descriptor.id)) continue;
|
|
@@ -2820,7 +4467,7 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
2820
4467
|
}
|
|
2821
4468
|
}
|
|
2822
4469
|
const factory = options.customWidget ?? DEFAULT_CUSTOM_WIDGET;
|
|
2823
|
-
const
|
|
4470
|
+
const build3 = (custom) => {
|
|
2824
4471
|
const schema = createRegistry(definitions, sources, custom);
|
|
2825
4472
|
const snapshots = new Map(custom.map((snapshot) => [customKey(snapshot.type, snapshot.v), snapshot]));
|
|
2826
4473
|
const built = /* @__PURE__ */ new Map();
|
|
@@ -2841,49 +4488,102 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
2841
4488
|
if (!built.has(key)) built.set(key, factory(snapshot, registry));
|
|
2842
4489
|
return built.get(key) ?? void 0;
|
|
2843
4490
|
},
|
|
2844
|
-
withCustom: (more) =>
|
|
4491
|
+
withCustom: (more) => build3([...custom, ...more])
|
|
2845
4492
|
};
|
|
2846
4493
|
return registry;
|
|
2847
4494
|
};
|
|
2848
|
-
return
|
|
4495
|
+
return build3([]);
|
|
2849
4496
|
}
|
|
2850
4497
|
|
|
2851
4498
|
// src/server/load-page.ts
|
|
2852
4499
|
import { BuilderNotFoundError } from "@usethrottle/builder";
|
|
4500
|
+
var isOwnPath = (path) => typeof path === "string" && path !== "/" && path.startsWith("/") && !path.startsWith("/pages/");
|
|
4501
|
+
async function loadBuilderPageByPath(options) {
|
|
4502
|
+
const { path, locale } = options;
|
|
4503
|
+
const client = clientOf(options);
|
|
4504
|
+
if (client.pages.getByPath !== void 0) {
|
|
4505
|
+
const found = await client.pages.getByPath(path, { locale });
|
|
4506
|
+
if (isRedirect(found)) return { kind: "redirect", redirectTo: found.redirectTo };
|
|
4507
|
+
return loadBuilderPage({ ...options, slug: found.slug });
|
|
4508
|
+
}
|
|
4509
|
+
const summaries = await client.pages.list();
|
|
4510
|
+
const summary = summaries.find((entry) => entry.path === path && isOwnPath(entry.path));
|
|
4511
|
+
if (summary !== void 0) return loadBuilderPage({ ...options, slug: summary.slug });
|
|
4512
|
+
const bySlug = summaries.find((entry) => `/${entry.slug}` === path);
|
|
4513
|
+
if (bySlug !== void 0 && isOwnPath(bySlug.path) && bySlug.path !== path)
|
|
4514
|
+
return { kind: "redirect", redirectTo: bySlug.path };
|
|
4515
|
+
throw new BuilderNotFoundError(path);
|
|
4516
|
+
}
|
|
4517
|
+
async function loadOwnPagePaths(options) {
|
|
4518
|
+
return (await clientOf(options).pages.list()).map((entry) => entry.path).filter(isOwnPath);
|
|
4519
|
+
}
|
|
2853
4520
|
async function loadBuilderPage(options) {
|
|
2854
|
-
const { slug, locale, packs = [], slots, currency } = options;
|
|
2855
|
-
const bundle = await getBundle({ client: clientOf(options), locale, page:
|
|
4521
|
+
const { slug: slug2, locale, packs = [], slots, currency } = options;
|
|
4522
|
+
const bundle = await getBundle({ client: clientOf(options), locale, page: slug2, slots });
|
|
2856
4523
|
const found = bundle.page;
|
|
2857
|
-
if (found === void 0) throw new BuilderNotFoundError(
|
|
4524
|
+
if (found === void 0) throw new BuilderNotFoundError(slug2);
|
|
2858
4525
|
if (isRedirect(found)) return { kind: "redirect", redirectTo: found.redirectTo };
|
|
2859
4526
|
const shared = { ...found, savedSections: found.savedSections ?? bundle.savedSections, code: found.code ?? bundle.code };
|
|
2860
4527
|
const data = await staticDataFor([shared], createRendererRegistry(packs), locale, currency);
|
|
2861
4528
|
return pageOf(shared, data);
|
|
2862
4529
|
}
|
|
2863
4530
|
|
|
4531
|
+
// src/server/load-template.ts
|
|
4532
|
+
function templateRootOf(packs, name) {
|
|
4533
|
+
for (const pack of packs ?? []) {
|
|
4534
|
+
const found = pack.templates?.find((entry) => entry.name === name);
|
|
4535
|
+
if (found !== void 0) return found.Root;
|
|
4536
|
+
}
|
|
4537
|
+
return void 0;
|
|
4538
|
+
}
|
|
4539
|
+
async function loadBuilderTemplate(options) {
|
|
4540
|
+
const { name, locale, packs = [], currency, shared } = options;
|
|
4541
|
+
const answer = await clientOf(options).getTemplate(name, { locale });
|
|
4542
|
+
const document2 = answer.customWidgets === void 0 ? answer.document : {
|
|
4543
|
+
...answer.document,
|
|
4544
|
+
customWidgets: { ...answer.customWidgets, ...answer.document.customWidgets }
|
|
4545
|
+
};
|
|
4546
|
+
const loaded = { ...answer, generation: answer.generation ?? 0, document: document2 };
|
|
4547
|
+
const data = await staticDataFor([loaded], createRendererRegistry(packs), locale, currency);
|
|
4548
|
+
return { part: partOf(loaded, data, shared), meta: answer.meta };
|
|
4549
|
+
}
|
|
4550
|
+
|
|
2864
4551
|
// src/next/seo.ts
|
|
2865
|
-
import { safeUrl as
|
|
2866
|
-
var
|
|
4552
|
+
import { TEMPLATE_NOINDEX_DEFAULT, safeUrl as safeUrl15 } from "@usethrottle/builder-schema";
|
|
4553
|
+
var isRec2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2867
4554
|
var text = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
2868
4555
|
var ORIGIN_RE = /^https?:\/\/[^\s/\\]+$/iu;
|
|
2869
4556
|
var DEFAULT_PAGE_ROUTE = "/pages/{handle}";
|
|
2870
4557
|
var LOCALE_SEGMENT_RE = /^[A-Za-z0-9-]+$/u;
|
|
2871
4558
|
function pageSeoOf(page) {
|
|
2872
|
-
const seo =
|
|
4559
|
+
const seo = isRec2(page.seo) ? page.seo : {};
|
|
2873
4560
|
const title = text(seo.title);
|
|
2874
4561
|
const description = text(seo.description);
|
|
4562
|
+
const canonical = text(seo.canonical);
|
|
2875
4563
|
return {
|
|
2876
4564
|
...title === void 0 ? {} : { title },
|
|
2877
4565
|
...description === void 0 ? {} : { description },
|
|
4566
|
+
...canonical === void 0 ? {} : { canonical },
|
|
2878
4567
|
shareImage: seo.shareImage,
|
|
2879
4568
|
noindex: seo.noindex === true
|
|
2880
4569
|
};
|
|
2881
4570
|
}
|
|
4571
|
+
function canonicalOverrideOf(value) {
|
|
4572
|
+
return value !== void 0 && /^https?:\/\/[^\s\\]+$/iu.test(value) ? value : void 0;
|
|
4573
|
+
}
|
|
4574
|
+
function canonicalFor(url, kind) {
|
|
4575
|
+
const parsed2 = new URL(url);
|
|
4576
|
+
const page = kind === "listing" ? parsed2.searchParams.get("page") : null;
|
|
4577
|
+
parsed2.hash = "";
|
|
4578
|
+
parsed2.search = "";
|
|
4579
|
+
if (page !== null && /^\d{1,6}$/u.test(page)) parsed2.searchParams.set("page", page);
|
|
4580
|
+
return parsed2.toString();
|
|
4581
|
+
}
|
|
2882
4582
|
function imageOf(value, mediaOrigin) {
|
|
2883
|
-
const raw =
|
|
2884
|
-
const url =
|
|
4583
|
+
const raw = isRec2(value) ? value.url : value;
|
|
4584
|
+
const url = safeUrl15(raw, "src", { mediaOrigin });
|
|
2885
4585
|
if (url === null) return void 0;
|
|
2886
|
-
const frozen =
|
|
4586
|
+
const frozen = isRec2(value) ? value : {};
|
|
2887
4587
|
return {
|
|
2888
4588
|
url,
|
|
2889
4589
|
...typeof frozen.width === "number" ? { width: frozen.width } : {},
|
|
@@ -2891,51 +4591,113 @@ function imageOf(value, mediaOrigin) {
|
|
|
2891
4591
|
};
|
|
2892
4592
|
}
|
|
2893
4593
|
function pagePathOf(settings, page, resolve) {
|
|
2894
|
-
const routes =
|
|
4594
|
+
const routes = isRec2(settings.routes) ? settings.routes : {};
|
|
2895
4595
|
const pattern = text(routes.page) ?? DEFAULT_PAGE_ROUTE;
|
|
2896
|
-
const
|
|
4596
|
+
const own = page.path !== void 0 && page.path !== "/" && !page.path.startsWith("/pages/") ? safeUrl15(page.path, "href", { mediaOrigin: "" }) : null;
|
|
4597
|
+
const path = own ?? safeUrl15(pattern.replaceAll("{handle}", () => page.slug), "href", { mediaOrigin: "" });
|
|
2897
4598
|
if (path === null || resolve === void 0) return path;
|
|
2898
|
-
return
|
|
4599
|
+
return safeUrl15(resolve({ ...page, path }), "href", { mediaOrigin: "" }) ?? path;
|
|
2899
4600
|
}
|
|
2900
4601
|
function originOf(storeUrl) {
|
|
2901
4602
|
const origin = storeUrl?.replace(/\/+$/u, "");
|
|
2902
4603
|
return origin !== void 0 && ORIGIN_RE.test(origin) ? origin : void 0;
|
|
2903
4604
|
}
|
|
2904
4605
|
function siteLocales(settings) {
|
|
2905
|
-
const locales =
|
|
2906
|
-
const
|
|
2907
|
-
return { list, fallback: typeof locales.default === "string" &&
|
|
4606
|
+
const locales = isRec2(settings.locales) ? settings.locales : {};
|
|
4607
|
+
const list2 = Array.isArray(locales.list) ? locales.list.filter((locale) => typeof locale === "string" && LOCALE_SEGMENT_RE.test(locale)) : [];
|
|
4608
|
+
return { list: list2, fallback: typeof locales.default === "string" && list2.includes(locales.default) ? locales.default : void 0 };
|
|
4609
|
+
}
|
|
4610
|
+
var localized2 = (path, locale) => locale === void 0 ? path : path === "/" ? `/${locale}` : `/${locale}${path}`;
|
|
4611
|
+
var LISTING_TEMPLATES = ["shop", "collection", "category", "tag"];
|
|
4612
|
+
var DEFAULT_TITLE = {
|
|
4613
|
+
product: "{product.title} \u2013 {store}",
|
|
4614
|
+
shop: "{listing.title} \u2013 {store}",
|
|
4615
|
+
collection: "{listing.title} \u2013 {store}",
|
|
4616
|
+
category: "{listing.title} \u2013 {store}",
|
|
4617
|
+
tag: "{listing.title} \u2013 {store}"
|
|
4618
|
+
};
|
|
4619
|
+
var titleOf = (value) => isRec2(value) ? text(value.title) ?? "" : "";
|
|
4620
|
+
function localizedOf(value) {
|
|
4621
|
+
if (typeof value === "string") return text(value);
|
|
4622
|
+
if (!isRec2(value)) return void 0;
|
|
4623
|
+
return text(value.en) ?? Object.values(value).map(text).find((entry) => entry !== void 0);
|
|
4624
|
+
}
|
|
4625
|
+
function templateMetadataOf(name, input) {
|
|
4626
|
+
const { settings, context } = input;
|
|
4627
|
+
const site = isRec2(settings.seo) ? settings.seo : {};
|
|
4628
|
+
const brand = isRec2(settings.brand) ? settings.brand : {};
|
|
4629
|
+
const store = text(brand.storeName) ?? "";
|
|
4630
|
+
const query = context?.route?.query?.q;
|
|
4631
|
+
const tokens = {
|
|
4632
|
+
"{product.title}": titleOf(context?.product),
|
|
4633
|
+
"{listing.title}": titleOf(context?.listing),
|
|
4634
|
+
"{query}": (Array.isArray(query) ? query[0] : query) ?? "",
|
|
4635
|
+
"{store}": store
|
|
4636
|
+
};
|
|
4637
|
+
const pattern = text(input.meta?.seo?.titleTemplate) ?? DEFAULT_TITLE[name] ?? "{store}";
|
|
4638
|
+
let title = pattern;
|
|
4639
|
+
for (const [token, value] of Object.entries(tokens)) title = title.replaceAll(token, () => value);
|
|
4640
|
+
title = title.replace(/^[\s–—|·:-]+|[\s–—|·:-]+$/gu, "");
|
|
4641
|
+
if (title === "") title = store;
|
|
4642
|
+
const description = localizedOf(input.meta?.seo?.description) ?? localizedOf(site.defaultDescription);
|
|
4643
|
+
const mediaOrigin = input.mediaOrigin ?? "";
|
|
4644
|
+
const image = imageOf(input.meta?.seo?.shareImage, mediaOrigin) ?? imageOf(site.shareImage, mediaOrigin);
|
|
4645
|
+
const noindex = input.noindex === true || name === "search" || (input.meta?.noindex ?? TEMPLATE_NOINDEX_DEFAULT[name]) || site.noindex === true;
|
|
4646
|
+
const origin = originOf(text(site.canonicalBase)) ?? originOf(input.storeUrl);
|
|
4647
|
+
const kind = name === "product" ? "product" : name === "search" ? "search" : LISTING_TEMPLATES.includes(name) ? "listing" : "page";
|
|
4648
|
+
const canonical = noindex || origin === void 0 ? void 0 : canonicalFor(`${origin}${input.path}${input.search ?? ""}`, kind);
|
|
4649
|
+
return {
|
|
4650
|
+
title,
|
|
4651
|
+
...description === void 0 ? {} : { description },
|
|
4652
|
+
...noindex ? { robots: name === "search" ? { index: false, follow: true } : { index: false } } : {},
|
|
4653
|
+
...canonical === void 0 ? {} : { alternates: { canonical } },
|
|
4654
|
+
openGraph: {
|
|
4655
|
+
type: "website",
|
|
4656
|
+
...store === "" ? {} : { siteName: store },
|
|
4657
|
+
title,
|
|
4658
|
+
...description === void 0 ? {} : { description },
|
|
4659
|
+
...image === void 0 ? {} : { images: [image] }
|
|
4660
|
+
},
|
|
4661
|
+
twitter: {
|
|
4662
|
+
card: image === void 0 ? "summary" : "summary_large_image",
|
|
4663
|
+
title,
|
|
4664
|
+
...description === void 0 ? {} : { description },
|
|
4665
|
+
...image === void 0 ? {} : { images: [image.url] }
|
|
4666
|
+
}
|
|
4667
|
+
};
|
|
2908
4668
|
}
|
|
2909
|
-
var localized = (path, locale) => locale === void 0 ? path : path === "/" ? `/${locale}` : `/${locale}${path}`;
|
|
2910
4669
|
function metadataOf(page, context) {
|
|
2911
4670
|
const { settings, mediaOrigin, routeLocale } = context;
|
|
2912
|
-
const site =
|
|
2913
|
-
const brand =
|
|
4671
|
+
const site = isRec2(settings.seo) ? settings.seo : {};
|
|
4672
|
+
const brand = isRec2(settings.brand) ? settings.brand : {};
|
|
2914
4673
|
const own = pageSeoOf(page);
|
|
2915
4674
|
const template = text(site.titleTemplate) ?? "{page}";
|
|
2916
4675
|
const store = text(brand.storeName) ?? "";
|
|
2917
4676
|
const title = template.replaceAll("{page}", () => own.title ?? page.title).replaceAll("{store}", () => store);
|
|
2918
4677
|
const description = own.description ?? text(site.defaultDescription);
|
|
2919
4678
|
const image = imageOf(own.shareImage, mediaOrigin) ?? imageOf(site.shareImage, mediaOrigin);
|
|
2920
|
-
if (image === void 0 && mediaOrigin === "" && (
|
|
4679
|
+
if (image === void 0 && mediaOrigin === "" && (isRec2(own.shareImage) || isRec2(site.shareImage)))
|
|
2921
4680
|
warnOnce("share-image-origin", "A share image is set but createBuilderPage has no mediaOrigin, so the page has no og:image: pass the same mediaOrigin as loadSite");
|
|
2922
|
-
const origin = originOf(context.storeUrl);
|
|
4681
|
+
const origin = originOf(text(site.canonicalBase)) ?? originOf(context.storeUrl);
|
|
2923
4682
|
if (origin === void 0)
|
|
2924
4683
|
warnOnce("canonical-origin", "No canonical link: pass storeUrl (https://shop.example.com) to createBuilderPage. The Builder does not publish the store URL.");
|
|
2925
|
-
const path = pagePathOf(settings, { slug: page.slug, pageType: page.pageType }, context.pagePath);
|
|
2926
|
-
const
|
|
2927
|
-
const
|
|
2928
|
-
const
|
|
2929
|
-
|
|
2930
|
-
...
|
|
4684
|
+
const path = pagePathOf(settings, { slug: page.slug, pageType: page.pageType, path: text(page.path) }, context.pagePath);
|
|
4685
|
+
const override = canonicalOverrideOf(own.canonical);
|
|
4686
|
+
const canonical = override ?? (origin === void 0 || path === null ? void 0 : `${origin}${localized2(path, routeLocale)}`);
|
|
4687
|
+
const { list: list2, fallback } = siteLocales(settings);
|
|
4688
|
+
const languages = origin !== void 0 && path !== null && routeLocale !== void 0 && list2.length > 1 ? {
|
|
4689
|
+
...Object.fromEntries(list2.map((locale) => [locale, `${origin}${localized2(path, locale)}`])),
|
|
4690
|
+
...fallback === void 0 ? {} : { "x-default": `${origin}${localized2(path, fallback)}` }
|
|
2931
4691
|
} : void 0;
|
|
2932
4692
|
return {
|
|
2933
4693
|
title,
|
|
2934
4694
|
...description === void 0 ? {} : { description },
|
|
2935
|
-
|
|
4695
|
+
// Site-wide noindex (v2 `seo.noindex`, for staging) is on every page, as the page's own is.
|
|
4696
|
+
...own.noindex || site.noindex === true ? { robots: { index: false } } : {},
|
|
2936
4697
|
...canonical === void 0 ? {} : { alternates: { canonical, ...languages === void 0 ? {} : { languages } } },
|
|
2937
4698
|
openGraph: {
|
|
2938
4699
|
type: "website",
|
|
4700
|
+
...store === "" ? {} : { siteName: store },
|
|
2939
4701
|
title,
|
|
2940
4702
|
...description === void 0 ? {} : { description },
|
|
2941
4703
|
...canonical === void 0 ? {} : { url: canonical },
|
|
@@ -2951,18 +4713,33 @@ function metadataOf(page, context) {
|
|
|
2951
4713
|
}
|
|
2952
4714
|
|
|
2953
4715
|
export {
|
|
4716
|
+
__publicField,
|
|
2954
4717
|
warnOnce,
|
|
4718
|
+
buildRouteTable,
|
|
4719
|
+
organizationJsonLd,
|
|
4720
|
+
webSiteJsonLd,
|
|
4721
|
+
breadcrumbJsonLd,
|
|
4722
|
+
faqJsonLd,
|
|
4723
|
+
localBusinessJsonLd,
|
|
4724
|
+
jsonLdString,
|
|
2955
4725
|
createRendererRegistry,
|
|
2956
4726
|
staticDataFor,
|
|
2957
4727
|
partOf,
|
|
2958
4728
|
isRedirect,
|
|
2959
4729
|
getBundle,
|
|
2960
4730
|
clientOf,
|
|
4731
|
+
isOwnPath,
|
|
4732
|
+
loadBuilderPageByPath,
|
|
4733
|
+
loadOwnPagePaths,
|
|
2961
4734
|
loadBuilderPage,
|
|
4735
|
+
templateRootOf,
|
|
4736
|
+
loadBuilderTemplate,
|
|
2962
4737
|
pageSeoOf,
|
|
4738
|
+
canonicalFor,
|
|
2963
4739
|
pagePathOf,
|
|
2964
4740
|
originOf,
|
|
2965
4741
|
siteLocales,
|
|
2966
|
-
localized,
|
|
4742
|
+
localized2 as localized,
|
|
4743
|
+
templateMetadataOf,
|
|
2967
4744
|
metadataOf
|
|
2968
4745
|
};
|