@usethrottle/builder-react 0.4.3 → 0.5.1
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-C57AQKJI.js → chunk-G6I4RIXU.js} +2122 -393
- package/dist/{chunk-E7SRVAFV.cjs → chunk-UNL4JWZS.cjs} +1992 -263
- package/dist/index.cjs +2251 -603
- package/dist/index.d.cts +186 -61
- package/dist/index.d.ts +186 -61
- package/dist/index.js +2218 -569
- 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-BYBk3Sya.d.cts → seo-iX2POfOp.d.cts} +39 -2
- package/dist/{seo-BYBk3Sya.d.ts → seo-iX2POfOp.d.ts} +39 -2
- package/dist/server.cjs +193 -24
- package/dist/server.d.cts +187 -8
- package/dist/server.d.ts +187 -8
- package/dist/server.js +176 -7
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -5,9 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __export = (
|
|
8
|
+
var __export = (target2, all2) => {
|
|
9
9
|
for (var name in all2)
|
|
10
|
-
__defProp(
|
|
10
|
+
__defProp(target2, name, { get: all2[name], enumerable: true });
|
|
11
11
|
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -34,7 +34,9 @@ __export(src_exports, {
|
|
|
34
34
|
BuilderPageView: () => BuilderPageView,
|
|
35
35
|
BuilderProvider: () => BuilderProvider,
|
|
36
36
|
BuilderRenderer: () => BuilderRenderer,
|
|
37
|
+
BuilderRouteScope: () => BuilderRouteScope,
|
|
37
38
|
BuilderSlot: () => BuilderSlot,
|
|
39
|
+
BuilderTemplateView: () => BuilderTemplateView,
|
|
38
40
|
BuilderUnavailableError: () => import_builder3.BuilderUnavailableError,
|
|
39
41
|
CODE_ROUTE_DENY: () => CODE_ROUTE_DENY,
|
|
40
42
|
CUSTOM_WIDGET_CONTAINMENT: () => CUSTOM_WIDGET_CONTAINMENT,
|
|
@@ -51,6 +53,7 @@ __export(src_exports, {
|
|
|
51
53
|
basicPack: () => basicPack,
|
|
52
54
|
bindingKey: () => bindingKey,
|
|
53
55
|
bindingsOf: () => bindingsOf,
|
|
56
|
+
buildRouteTable: () => buildRouteTable,
|
|
54
57
|
codeScriptUrl: () => codeScriptUrl,
|
|
55
58
|
collectBindings: () => collectBindings,
|
|
56
59
|
compileResponsiveCss: () => compileResponsiveCss,
|
|
@@ -68,13 +71,14 @@ __export(src_exports, {
|
|
|
68
71
|
pickLocale: () => pickLocale,
|
|
69
72
|
resolveBindings: () => resolveBindings,
|
|
70
73
|
useBuilder: () => useBuilder,
|
|
74
|
+
useViewer: () => useViewer,
|
|
71
75
|
validateRender: () => validateRender
|
|
72
76
|
});
|
|
73
77
|
module.exports = __toCommonJS(src_exports);
|
|
74
78
|
|
|
75
79
|
// src/renderer.tsx
|
|
76
|
-
var
|
|
77
|
-
var
|
|
80
|
+
var import_react12 = require("react");
|
|
81
|
+
var import_builder_schema13 = require("@usethrottle/builder-schema");
|
|
78
82
|
|
|
79
83
|
// src/budget.ts
|
|
80
84
|
var import_builder_schema = require("@usethrottle/builder-schema");
|
|
@@ -101,7 +105,7 @@ var fitsBudget = (ast, limit = MAX_RENDERED_NODES) => (0, import_builder_schema.
|
|
|
101
105
|
|
|
102
106
|
// src/code/code-widget.tsx
|
|
103
107
|
var import_react7 = require("react");
|
|
104
|
-
var
|
|
108
|
+
var import_builder_schema9 = require("@usethrottle/builder-schema");
|
|
105
109
|
|
|
106
110
|
// src/custom/custom-css.tsx
|
|
107
111
|
var import_builder_schema2 = require("@usethrottle/builder-schema");
|
|
@@ -211,7 +215,7 @@ function attrAllowed(tag, name) {
|
|
|
211
215
|
return (import_builder_schema3.ALLOWED_ATTRS["*"]?.includes(name) ?? false) || (own?.includes(name) ?? false);
|
|
212
216
|
}
|
|
213
217
|
function attrText(attr, env, scope) {
|
|
214
|
-
return attr.value.map((
|
|
218
|
+
return attr.value.map((part2) => part2.type === "text" ? part2.value : filtered(lookup(part2.path, env, scope), part2.filters)).join("");
|
|
215
219
|
}
|
|
216
220
|
function urlSource(attr, env, scope) {
|
|
217
221
|
const [only] = attr.value;
|
|
@@ -286,11 +290,11 @@ function renderNodes(nodes, env, scope, depth) {
|
|
|
286
290
|
}
|
|
287
291
|
break;
|
|
288
292
|
case "each": {
|
|
289
|
-
const
|
|
290
|
-
if (!Array.isArray(
|
|
291
|
-
const count = Math.min(
|
|
293
|
+
const list2 = lookup(node.path, env, scope);
|
|
294
|
+
if (!Array.isArray(list2)) break;
|
|
295
|
+
const count = Math.min(list2.length, import_builder_schema3.EACH_ITERATION_CAP);
|
|
292
296
|
for (let i = 0; i < count && !env.stopped; i += 1) {
|
|
293
|
-
const inner = new Map(scope).set(node.as,
|
|
297
|
+
const inner = new Map(scope).set(node.as, list2[i]);
|
|
294
298
|
out.push(/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react.Fragment, { children: renderNodes(node.body, env, inner, depth + 1) }, out.length));
|
|
295
299
|
}
|
|
296
300
|
break;
|
|
@@ -316,7 +320,7 @@ var import_react4 = require("react");
|
|
|
316
320
|
// src/context.ts
|
|
317
321
|
var import_react2 = require("react");
|
|
318
322
|
function codeRenderOf(builder, runtime) {
|
|
319
|
-
return { runtime, pathname: builder.pathname, routes: builder.codeRoutes, preview: builder.mode === "preview" };
|
|
323
|
+
return { runtime, pathname: builder.pathname, routes: builder.codeRoutes, templateName: builder.templateName, preview: builder.mode === "preview" };
|
|
320
324
|
}
|
|
321
325
|
var BuilderContext = typeof import_react2.createContext === "function" ? (0, import_react2.createContext)(null) : null;
|
|
322
326
|
var useBuilder = () => (0, import_react2.useContext)(BuilderContext);
|
|
@@ -338,12 +342,14 @@ var PART_NAME = {
|
|
|
338
342
|
widget: "builder-widget"
|
|
339
343
|
};
|
|
340
344
|
function NodeWrapper(props) {
|
|
341
|
-
const { id, part, type,
|
|
345
|
+
const { id, part: part2, type, anchor, copyAnchor, custom, missing, attributes, edit, entrance, children } = props;
|
|
342
346
|
const Tag = props.as ?? "div";
|
|
347
|
+
const tokens = props.cssClass !== void 0 && import_builder_schema4.cssClassSchema.safeParse(props.cssClass).success ? props.cssClass : [];
|
|
348
|
+
const className = tokens.length === 0 ? props.className : `${props.className} ${tokens.join(" ")}`;
|
|
343
349
|
const handlers = edit === void 0 ? {} : {
|
|
344
350
|
onClickCapture: (event) => {
|
|
345
|
-
const
|
|
346
|
-
if (
|
|
351
|
+
const target2 = event.target;
|
|
352
|
+
if (target2?.closest?.("a[href]") != null) event.preventDefault();
|
|
347
353
|
},
|
|
348
354
|
onClick: (event) => {
|
|
349
355
|
event.stopPropagation();
|
|
@@ -364,7 +370,7 @@ function NodeWrapper(props) {
|
|
|
364
370
|
{
|
|
365
371
|
className,
|
|
366
372
|
"data-b-id": id,
|
|
367
|
-
"data-throttle-part": PART_NAME[
|
|
373
|
+
"data-throttle-part": PART_NAME[part2],
|
|
368
374
|
...type === void 0 ? {} : { "data-b-type": type },
|
|
369
375
|
...custom === true && type !== void 0 ? { "data-b-w": type } : {},
|
|
370
376
|
...missing === true ? { "data-b-missing": "" } : {},
|
|
@@ -620,32 +626,32 @@ function contextData(context) {
|
|
|
620
626
|
if (typeof context !== "object" || context === null) return {};
|
|
621
627
|
return Object.fromEntries(Object.entries(context).map(([key, value]) => [`context.${key}`, value]));
|
|
622
628
|
}
|
|
623
|
-
function PartView({ part, context }) {
|
|
629
|
+
function PartView({ part: part2, context }) {
|
|
624
630
|
const builder = useBuilder();
|
|
625
631
|
if (builder === null) return null;
|
|
626
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PartBody, { part, context, builder });
|
|
632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PartBody, { part: part2, context, builder });
|
|
627
633
|
}
|
|
628
634
|
function PartBody({
|
|
629
|
-
part,
|
|
635
|
+
part: part2,
|
|
630
636
|
context,
|
|
631
637
|
builder
|
|
632
638
|
}) {
|
|
633
|
-
const expanded = expandSavedSections(
|
|
639
|
+
const expanded = expandSavedSections(part2.document, part2.savedSections).doc;
|
|
634
640
|
const shopper = useResolvedData(expanded, builder.registry, builder.locale, "shopper", context);
|
|
635
641
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
636
642
|
BuilderRenderer,
|
|
637
643
|
{
|
|
638
|
-
document:
|
|
644
|
+
document: part2.document,
|
|
639
645
|
registry: builder.registry,
|
|
640
|
-
data: { ...
|
|
646
|
+
data: { ...part2.initialData, ...contextData(context), ...shopper },
|
|
641
647
|
locale: builder.locale,
|
|
642
|
-
assets:
|
|
648
|
+
assets: part2.assets,
|
|
643
649
|
mediaOrigin: builder.mediaOrigin,
|
|
644
650
|
resolveLink: builder.resolveLink,
|
|
645
651
|
interactive: builder.interactive,
|
|
646
652
|
scopeCustomCss: builder.customCss !== "",
|
|
647
|
-
savedSections:
|
|
648
|
-
code: codeRenderOf(builder,
|
|
653
|
+
savedSections: part2.savedSections,
|
|
654
|
+
code: codeRenderOf(builder, part2.code)
|
|
649
655
|
}
|
|
650
656
|
);
|
|
651
657
|
}
|
|
@@ -710,6 +716,7 @@ function reloadHere() {
|
|
|
710
716
|
}
|
|
711
717
|
|
|
712
718
|
// src/code/routes.ts
|
|
719
|
+
var import_builder_schema8 = require("@usethrottle/builder-schema");
|
|
713
720
|
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;
|
|
714
721
|
var DEFAULT_CATALOG_ROUTES = [
|
|
715
722
|
"/p/{handle}",
|
|
@@ -756,7 +763,7 @@ function matcherOf(template) {
|
|
|
756
763
|
if (known !== void 0) return known;
|
|
757
764
|
let regex = null;
|
|
758
765
|
if (template.startsWith("/")) {
|
|
759
|
-
const pattern = template.split(/(\{[A-Za-z][A-Za-z0-9]*\})/).map((
|
|
766
|
+
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(/\/+$/, "");
|
|
760
767
|
regex = new RegExp(`^${pattern === "" ? "/" : pattern}$`);
|
|
761
768
|
}
|
|
762
769
|
if (compiled2.size >= MAX_COMPILED) compiled2.clear();
|
|
@@ -764,24 +771,43 @@ function matcherOf(template) {
|
|
|
764
771
|
return regex;
|
|
765
772
|
}
|
|
766
773
|
var matchesTemplate = (path, template) => matcherOf(template)?.test(path) ?? false;
|
|
774
|
+
function buildRouteTable(store, catalog = {}) {
|
|
775
|
+
return { ...catalog, ...store };
|
|
776
|
+
}
|
|
777
|
+
var isDeniedTemplate = (name) => import_builder_schema8.CODE_TEMPLATE_DENY.includes(name);
|
|
778
|
+
function isDeniedByRouteTable(path, routeTable) {
|
|
779
|
+
if (routeTable === void 0) return false;
|
|
780
|
+
return Object.entries(routeTable).some(([name, template]) => {
|
|
781
|
+
if (!isDeniedTemplate(name) || typeof template !== "string") return false;
|
|
782
|
+
const base = template.replace(/\/+$/, "");
|
|
783
|
+
return matchesTemplate(path, template) || path.startsWith(`${base}/`);
|
|
784
|
+
});
|
|
785
|
+
}
|
|
767
786
|
function isCodeRoute(pathname, routes) {
|
|
768
787
|
if (pathname === void 0) return false;
|
|
788
|
+
if (routes.templateName !== void 0 && isDeniedTemplate(routes.templateName)) return false;
|
|
769
789
|
const path = normalizePath(pathname);
|
|
770
790
|
if (path === null) return false;
|
|
791
|
+
if (isDeniedByRouteTable(path, routes.routeTable)) return false;
|
|
771
792
|
if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
|
|
772
793
|
if (path === "/") return true;
|
|
773
|
-
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES].some(
|
|
794
|
+
return [routes.page, ...routes.catalog ?? DEFAULT_CATALOG_ROUTES, ...routes.allow ?? []].some(
|
|
774
795
|
(template) => matchesTemplate(path, template)
|
|
775
796
|
);
|
|
776
797
|
}
|
|
777
798
|
|
|
778
799
|
// src/code/leave.ts
|
|
800
|
+
var ownPages = /* @__PURE__ */ new Set();
|
|
801
|
+
function allowCodePath(path) {
|
|
802
|
+
if (typeof window !== "undefined") ownPages.add(path);
|
|
803
|
+
}
|
|
779
804
|
var emitted = false;
|
|
780
805
|
function markCodeEmitted() {
|
|
781
806
|
emitted = true;
|
|
782
807
|
}
|
|
783
808
|
function mustLeave(pathname, routes) {
|
|
784
|
-
|
|
809
|
+
if (!emitted || typeof window === "undefined" || pathname === void 0) return false;
|
|
810
|
+
return !isCodeRoute(pathname, ownPages.size === 0 ? routes : { ...routes, allow: [...routes.allow ?? [], ...ownPages] });
|
|
785
811
|
}
|
|
786
812
|
function useLeaveCodeRoutes(pathname, routes) {
|
|
787
813
|
(0, import_react6.useEffect)(() => {
|
|
@@ -831,8 +857,8 @@ function verify(raw, registry) {
|
|
|
831
857
|
if (snapshot.disabled !== void 0) return refuse("bad disabled flag");
|
|
832
858
|
if ("js" in snapshot) return refuse("it carries a script");
|
|
833
859
|
if (typeof snapshot.jsHash !== "string" || !SHA256_HEX.test(snapshot.jsHash)) return refuse("bad script hash");
|
|
834
|
-
if (typeof snapshot.html !== "string" || snapshot.html.length >
|
|
835
|
-
if (typeof snapshot.css !== "string" || snapshot.css.length >
|
|
860
|
+
if (typeof snapshot.html !== "string" || snapshot.html.length > import_builder_schema9.LIMITS.codeHtmlBytes) return refuse("bad html");
|
|
861
|
+
if (typeof snapshot.css !== "string" || snapshot.css.length > import_builder_schema9.LIMITS.codeCssBytes) return refuse("bad css");
|
|
836
862
|
const template = { ...snapshot, kind: "template", template: snapshot.html };
|
|
837
863
|
if (compileTemplate(template, registry) === null) return refuse("its markup or css does not validate");
|
|
838
864
|
return { status: "ok", snapshot: raw, template };
|
|
@@ -861,7 +887,7 @@ var BADGE = {
|
|
|
861
887
|
function runs(props, jsHash) {
|
|
862
888
|
const { code, edit, interactive } = props;
|
|
863
889
|
if (edit !== void 0 || interactive === false || code === void 0 || code.preview === true) return null;
|
|
864
|
-
if (!isCodeRoute(code.pathname, code.routes)) return null;
|
|
890
|
+
if (!isCodeRoute(code.pathname, { ...code.routes, templateName: code.templateName })) return null;
|
|
865
891
|
return codeScriptUrl(code.runtime, jsHash);
|
|
866
892
|
}
|
|
867
893
|
function CodeWidget(props) {
|
|
@@ -916,7 +942,7 @@ function CodeInput({ props, data, label }) {
|
|
|
916
942
|
}
|
|
917
943
|
|
|
918
944
|
// src/css-compiler.ts
|
|
919
|
-
var
|
|
945
|
+
var import_builder_schema10 = require("@usethrottle/builder-schema");
|
|
920
946
|
var TABLET_QUERY = "(max-width:1024px)";
|
|
921
947
|
var PHONE_QUERY = "(max-width:767px)";
|
|
922
948
|
var SAFE_VALUE = /^[A-Za-z0-9#%.,()\-+*/_: ]{1,200}$/;
|
|
@@ -989,7 +1015,7 @@ function put(out, property, value) {
|
|
|
989
1015
|
}
|
|
990
1016
|
out.set(property, value);
|
|
991
1017
|
}
|
|
992
|
-
var COMMON_BY_KEY = new Map(
|
|
1018
|
+
var COMMON_BY_KEY = new Map(import_builder_schema10.COMMON_WIDGET_SETTINGS.map((field) => [field.key, field]));
|
|
993
1019
|
function widgetDecls(node, device, registry) {
|
|
994
1020
|
const out = /* @__PURE__ */ new Map();
|
|
995
1021
|
const def = registry.widget(node.type, node.v);
|
|
@@ -997,12 +1023,12 @@ function widgetDecls(node, device, registry) {
|
|
|
997
1023
|
const fields = new Map([...COMMON_BY_KEY, ...def.settings.map((f) => [f.key, f])]);
|
|
998
1024
|
const defaults = {};
|
|
999
1025
|
for (const field of fields.values()) if (field.output === "css") defaults[field.key] = field.default;
|
|
1000
|
-
const resolved = (0,
|
|
1026
|
+
const resolved = (0, import_builder_schema10.resolveResponsive)({ ...defaults, ...node.props }, node.responsive, device);
|
|
1001
1027
|
const prefix = node.type.startsWith("custom.") ? "--w-" : "--b-";
|
|
1002
1028
|
for (const field of fields.values()) {
|
|
1003
1029
|
if (field.output !== "css") continue;
|
|
1004
1030
|
const raw = resolved[field.key];
|
|
1005
|
-
const value = raw === void 0 || (0,
|
|
1031
|
+
const value = raw === void 0 || (0, import_builder_schema10.validateSettingValue)(field, raw) === null ? raw : field.default;
|
|
1006
1032
|
if (value === null || value === void 0) continue;
|
|
1007
1033
|
if (field.key === "hidden") {
|
|
1008
1034
|
if (value === true) put(out, "--tb-hide", "none");
|
|
@@ -1022,13 +1048,13 @@ function backgroundDecls(out, bg, assets, mediaOrigin) {
|
|
|
1022
1048
|
if (bg.position !== void 0 && BG_POSITION.has(bg.position)) put(out, "--tb-bgpos", bg.position);
|
|
1023
1049
|
if (bg.size !== void 0 && BG_SIZE.has(bg.size)) put(out, "--tb-bgsize", bg.size);
|
|
1024
1050
|
const asset = bg.image === void 0 || assets === void 0 || !Object.hasOwn(assets, bg.image) ? void 0 : assets[bg.image];
|
|
1025
|
-
if (asset !== void 0 && (0,
|
|
1051
|
+
if (asset !== void 0 && (0, import_builder_schema10.safeUrl)(asset.url, "src", { mediaOrigin }) !== null && URL_QUOTE_SAFE.test(asset.url)) {
|
|
1026
1052
|
out.set("--tb-bgimg", `url("${asset.url}")`);
|
|
1027
1053
|
}
|
|
1028
1054
|
}
|
|
1029
1055
|
function sectionDecls(section, device, assets, mediaOrigin) {
|
|
1030
1056
|
const out = /* @__PURE__ */ new Map();
|
|
1031
|
-
const p = (0,
|
|
1057
|
+
const p = (0, import_builder_schema10.resolveResponsive)(section.props, section.responsive, device);
|
|
1032
1058
|
if (p.hidden === true) put(out, "--tb-hide", "none");
|
|
1033
1059
|
const full = p.width === "full";
|
|
1034
1060
|
put(out, "--tb-maxw", full ? "none" : px(typeof p.contentWidth === "number" ? p.contentWidth : 1200));
|
|
@@ -1038,16 +1064,16 @@ function sectionDecls(section, device, assets, mediaOrigin) {
|
|
|
1038
1064
|
if (typeof p.minHeight === "number" && p.minHeight > 0 && p.minHeight <= 2e3) put(out, "--tb-minh", px(p.minHeight));
|
|
1039
1065
|
if (typeof p.verticalAlign === "string" && Object.hasOwn(ALIGN_ITEMS, p.verticalAlign)) put(out, "--tb-valign", ALIGN_ITEMS[p.verticalAlign]);
|
|
1040
1066
|
backgroundDecls(out, p.background, assets, mediaOrigin);
|
|
1041
|
-
const widths = (0,
|
|
1042
|
-
const rows = (0,
|
|
1067
|
+
const widths = (0, import_builder_schema10.resolveColumnWidths)(section, device);
|
|
1068
|
+
const rows = (0, import_builder_schema10.wrapColumnRows)(widths);
|
|
1043
1069
|
const stacked = rows.every((row) => row.length === 1);
|
|
1044
1070
|
put(out, "--tb-flow", stacked && p.stackOrder === "reverse" ? "column-reverse nowrap" : "row wrap");
|
|
1045
1071
|
return out;
|
|
1046
1072
|
}
|
|
1047
1073
|
function columnWidthDecls(section, device) {
|
|
1048
|
-
const widths = (0,
|
|
1074
|
+
const widths = (0, import_builder_schema10.resolveColumnWidths)(section, device);
|
|
1049
1075
|
const result = section.columns.map(() => /* @__PURE__ */ new Map());
|
|
1050
|
-
for (const row of (0,
|
|
1076
|
+
for (const row of (0, import_builder_schema10.wrapColumnRows)(widths)) {
|
|
1051
1077
|
for (const index of row) {
|
|
1052
1078
|
put(result[index], "--tb-cw", String(Math.round(widths[index] / 100 * 1e4) / 1e4));
|
|
1053
1079
|
put(result[index], "--tb-cn", String(row.length - 1));
|
|
@@ -1058,7 +1084,7 @@ function columnWidthDecls(section, device) {
|
|
|
1058
1084
|
function columnDecls(section, index, device, assets, mediaOrigin, widths) {
|
|
1059
1085
|
const column = section.columns[index];
|
|
1060
1086
|
const out = new Map(widths);
|
|
1061
|
-
const p = (0,
|
|
1087
|
+
const p = (0, import_builder_schema10.resolveColumnProps)(column.props, column.responsive, device);
|
|
1062
1088
|
if (p.hidden === true) put(out, "--tb-hide", "none");
|
|
1063
1089
|
if (typeof p.verticalAlign === "string" && Object.hasOwn(ALIGN_ITEMS, p.verticalAlign)) put(out, "--tb-self", ALIGN_ITEMS[p.verticalAlign]);
|
|
1064
1090
|
put(out, "--tb-pad", p.padding === void 0 ? null : spacing(p.padding));
|
|
@@ -1193,7 +1219,7 @@ function Carousel({
|
|
|
1193
1219
|
|
|
1194
1220
|
// src/interactions/entrance.tsx
|
|
1195
1221
|
var import_react8 = require("react");
|
|
1196
|
-
var
|
|
1222
|
+
var import_builder_schema11 = require("@usethrottle/builder-schema");
|
|
1197
1223
|
|
|
1198
1224
|
// src/interactions/styles.ts
|
|
1199
1225
|
var INTERACTIONS_CSS = `@layer throttle{
|
|
@@ -1239,8 +1265,8 @@ var seen2 = /* @__PURE__ */ new WeakSet();
|
|
|
1239
1265
|
var autoplay = /* @__PURE__ */ new Map();
|
|
1240
1266
|
var all = (selector) => Array.from(document.querySelectorAll(selector));
|
|
1241
1267
|
var reduced = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
|
|
1242
|
-
function selectTab(
|
|
1243
|
-
const tabs = Array.from(
|
|
1268
|
+
function selectTab(list2, index, focus = false) {
|
|
1269
|
+
const tabs = Array.from(list2.querySelectorAll("[role=tab]"));
|
|
1244
1270
|
tabs.forEach((tab, i) => {
|
|
1245
1271
|
const on = i === index;
|
|
1246
1272
|
tab.setAttribute("aria-selected", String(on));
|
|
@@ -1314,7 +1340,7 @@ function scan() {
|
|
|
1314
1340
|
});
|
|
1315
1341
|
document.documentElement.setAttribute("data-b-js", "");
|
|
1316
1342
|
const fresh = (selector) => all(selector).filter((el) => !seen2.has(el) && seen2.add(el));
|
|
1317
|
-
fresh("[data-b-tabs]").forEach((
|
|
1343
|
+
fresh("[data-b-tabs]").forEach((list2) => selectTab(list2, 0));
|
|
1318
1344
|
fresh("[data-b-car]").forEach((root) => setupCarousel(root));
|
|
1319
1345
|
const counts = fresh("[data-b-cd]");
|
|
1320
1346
|
counts.forEach((el) => tick(el, true));
|
|
@@ -1348,30 +1374,30 @@ var decoded = (hash) => {
|
|
|
1348
1374
|
};
|
|
1349
1375
|
var onHash = () => void goAnchor(decoded(location.hash));
|
|
1350
1376
|
function onClick(event) {
|
|
1351
|
-
const
|
|
1352
|
-
const href =
|
|
1377
|
+
const target2 = event.target;
|
|
1378
|
+
const href = target2?.closest('a[href^="#"]')?.getAttribute("href");
|
|
1353
1379
|
if (href && !event.defaultPrevented && !event.button && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) && goAnchor(decoded(href))) {
|
|
1354
1380
|
event.preventDefault();
|
|
1355
1381
|
history.pushState(null, "", href);
|
|
1356
1382
|
}
|
|
1357
|
-
const tab =
|
|
1358
|
-
const
|
|
1359
|
-
if (tab &&
|
|
1360
|
-
const button =
|
|
1383
|
+
const tab = target2?.closest("[role=tab]");
|
|
1384
|
+
const list2 = tab?.closest("[data-b-tabs]");
|
|
1385
|
+
if (tab && list2) return selectTab(list2, Array.from(list2.querySelectorAll("[role=tab]")).indexOf(tab));
|
|
1386
|
+
const button = target2?.closest("[data-b-act]");
|
|
1361
1387
|
const act = button?.getAttribute("data-b-act");
|
|
1362
1388
|
const root = button?.closest("[data-b-car]");
|
|
1363
1389
|
if (root && (act === "prev" || act === "next")) slideTo(root, act === "next" ? 1 : -1);
|
|
1364
1390
|
}
|
|
1365
1391
|
function onKey(event) {
|
|
1366
1392
|
const tab = event.target?.closest("[role=tab]");
|
|
1367
|
-
const
|
|
1368
|
-
if (!tab || !
|
|
1369
|
-
const count =
|
|
1370
|
-
const at = Array.from(
|
|
1393
|
+
const list2 = tab?.closest("[data-b-tabs]");
|
|
1394
|
+
if (!tab || !list2) return;
|
|
1395
|
+
const count = list2.querySelectorAll("[role=tab]").length;
|
|
1396
|
+
const at = Array.from(list2.querySelectorAll("[role=tab]")).indexOf(tab);
|
|
1371
1397
|
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;
|
|
1372
1398
|
if (to < 0) return;
|
|
1373
1399
|
event.preventDefault();
|
|
1374
|
-
selectTab(
|
|
1400
|
+
selectTab(list2, to, true);
|
|
1375
1401
|
}
|
|
1376
1402
|
function startRuntime() {
|
|
1377
1403
|
if (typeof document === "undefined") return () => void 0;
|
|
@@ -1417,7 +1443,7 @@ function startRuntime() {
|
|
|
1417
1443
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1418
1444
|
function entranceOf(entrance, delayMs, interactive) {
|
|
1419
1445
|
if (!interactive || typeof entrance !== "string" || entrance === "none") return void 0;
|
|
1420
|
-
if (!
|
|
1446
|
+
if (!import_builder_schema11.ENTRANCES.includes(entrance)) return void 0;
|
|
1421
1447
|
const delay = typeof delayMs === "number" && Number.isFinite(delayMs) ? Math.min(2e3, Math.max(0, Math.round(delayMs))) : 0;
|
|
1422
1448
|
return { name: entrance, delayMs: delay };
|
|
1423
1449
|
}
|
|
@@ -1426,11 +1452,150 @@ function InteractionRuntime() {
|
|
|
1426
1452
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("style", { href: "tb-interactions", precedence: "throttle", children: INTERACTIONS_CSS });
|
|
1427
1453
|
}
|
|
1428
1454
|
|
|
1429
|
-
// src/interactions/
|
|
1455
|
+
// src/interactions/frame.tsx
|
|
1456
|
+
var import_react9 = require("react");
|
|
1457
|
+
|
|
1458
|
+
// src/interactions/focus-trap.ts
|
|
1459
|
+
var FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
1460
|
+
var focusablesOf = (root) => Array.from(root.querySelectorAll(FOCUSABLE));
|
|
1461
|
+
function trapTab(event, items) {
|
|
1462
|
+
if (event.key !== "Tab") return false;
|
|
1463
|
+
const first = items[0];
|
|
1464
|
+
const last = items[items.length - 1];
|
|
1465
|
+
if (first === void 0 || last === void 0) return false;
|
|
1466
|
+
const active = document.activeElement;
|
|
1467
|
+
const inside = active !== null && items.includes(active);
|
|
1468
|
+
if (event.shiftKey && (active === first || !inside)) {
|
|
1469
|
+
event.preventDefault();
|
|
1470
|
+
last.focus();
|
|
1471
|
+
return true;
|
|
1472
|
+
}
|
|
1473
|
+
if (!event.shiftKey && (active === last || !inside)) {
|
|
1474
|
+
event.preventDefault();
|
|
1475
|
+
first.focus();
|
|
1476
|
+
return true;
|
|
1477
|
+
}
|
|
1478
|
+
return false;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// src/interactions/drawer.ts
|
|
1482
|
+
var holds2 = 0;
|
|
1483
|
+
var release;
|
|
1484
|
+
var rootOf = (el) => el?.closest("[data-tb-collapse]") ?? null;
|
|
1485
|
+
function setOpen(root, open) {
|
|
1486
|
+
const opener = root.querySelector("[data-tb-drawer-open]");
|
|
1487
|
+
const body = root.querySelector(".tb-fr-body");
|
|
1488
|
+
if (open) root.setAttribute("data-open", "true");
|
|
1489
|
+
else root.removeAttribute("data-open");
|
|
1490
|
+
opener?.setAttribute("aria-expanded", String(open));
|
|
1491
|
+
if (body !== null) {
|
|
1492
|
+
if (open) {
|
|
1493
|
+
body.setAttribute("role", "dialog");
|
|
1494
|
+
body.setAttribute("aria-modal", "true");
|
|
1495
|
+
const name = opener?.textContent?.trim();
|
|
1496
|
+
if (name !== void 0 && name !== "") body.setAttribute("aria-label", name);
|
|
1497
|
+
} else {
|
|
1498
|
+
body.removeAttribute("role");
|
|
1499
|
+
body.removeAttribute("aria-modal");
|
|
1500
|
+
body.removeAttribute("aria-label");
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (open) root.querySelector("[data-tb-drawer-close]")?.focus();
|
|
1504
|
+
else opener?.focus();
|
|
1505
|
+
}
|
|
1506
|
+
var openRoot = () => document.querySelector("[data-tb-collapse][data-open=true]");
|
|
1507
|
+
function install() {
|
|
1508
|
+
const click = (event) => {
|
|
1509
|
+
const el = event.target instanceof Element ? event.target : null;
|
|
1510
|
+
if (el === null) return;
|
|
1511
|
+
const root = rootOf(el);
|
|
1512
|
+
if (root === null) return;
|
|
1513
|
+
if (el.closest("[data-tb-drawer-open]") !== null) setOpen(root, root.getAttribute("data-open") !== "true");
|
|
1514
|
+
else if (el.closest("[data-tb-drawer-close]") !== null) setOpen(root, false);
|
|
1515
|
+
else if (root.getAttribute("data-open") === "true" && el.closest(".tb-fr-body a[href]") !== null) setOpen(root, false);
|
|
1516
|
+
};
|
|
1517
|
+
const keydown = (event) => {
|
|
1518
|
+
const root = openRoot();
|
|
1519
|
+
if (root === null) return;
|
|
1520
|
+
if (event.key === "Escape") {
|
|
1521
|
+
setOpen(root, false);
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
const body = root.querySelector(".tb-fr-body");
|
|
1525
|
+
if (body !== null) trapTab(event, focusablesOf(body));
|
|
1526
|
+
};
|
|
1527
|
+
document.addEventListener("click", click);
|
|
1528
|
+
document.addEventListener("keydown", keydown);
|
|
1529
|
+
return () => {
|
|
1530
|
+
document.removeEventListener("click", click);
|
|
1531
|
+
document.removeEventListener("keydown", keydown);
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
function startDrawer() {
|
|
1535
|
+
if (holds2++ === 0) release = install();
|
|
1536
|
+
let done = false;
|
|
1537
|
+
return () => {
|
|
1538
|
+
if (done) return;
|
|
1539
|
+
done = true;
|
|
1540
|
+
if (--holds2 === 0) {
|
|
1541
|
+
release?.();
|
|
1542
|
+
release = void 0;
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
// src/interactions/frame.tsx
|
|
1430
1548
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1549
|
+
var SECTION_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
1550
|
+
var TABLET_PX = 1024;
|
|
1551
|
+
var PHONE_PX = 768;
|
|
1552
|
+
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1553
|
+
function frameOf(section) {
|
|
1554
|
+
const raw = section.frame;
|
|
1555
|
+
if (!isRecord2(raw)) return null;
|
|
1556
|
+
const sticky = raw.sticky === "top";
|
|
1557
|
+
const c = raw.collapse;
|
|
1558
|
+
let collapse = null;
|
|
1559
|
+
if (isRecord2(c) && SECTION_ID_RE.test(section.id)) {
|
|
1560
|
+
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;
|
|
1561
|
+
if (at !== null) collapse = { px: (at - 0.02).toFixed(2), label: isRecord2(c.label) ? c.label : {} };
|
|
1562
|
+
}
|
|
1563
|
+
return sticky || collapse !== null ? { sticky, collapse } : null;
|
|
1564
|
+
}
|
|
1565
|
+
var FRAME_CSS = `@layer throttle{
|
|
1566
|
+
.tb-sticky{position:sticky;inset-block-start:0;z-index:40}
|
|
1567
|
+
[data-throttle-part=builder-header]:has(.tb-sticky){position:sticky;inset-block-start:0;z-index:40}
|
|
1568
|
+
.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}
|
|
1569
|
+
.tb-fr-open:focus-visible,.tb-fr-close:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
1570
|
+
}`;
|
|
1571
|
+
function collapseCss(sectionId, px2) {
|
|
1572
|
+
const s = `[data-b-id="${sectionId}"]`;
|
|
1573
|
+
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}}}}`;
|
|
1574
|
+
}
|
|
1575
|
+
function DrawerRuntime() {
|
|
1576
|
+
(0, import_react9.useEffect)(() => startDrawer(), []);
|
|
1577
|
+
return null;
|
|
1578
|
+
}
|
|
1579
|
+
function Collapse(props) {
|
|
1580
|
+
const { sectionId, id, px: px2, label, children } = props;
|
|
1581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1582
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("style", { href: `tb-fr-${sectionId}`, precedence: "throttle", children: collapseCss(sectionId, px2) }),
|
|
1583
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "tb-fr", "data-tb-collapse": "", children: [
|
|
1584
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "tb-fr-open", "data-tb-drawer-open": "", "aria-expanded": "false", "aria-controls": id, children: label }),
|
|
1585
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { id, className: "tb-fr-body", children: [
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: "tb-fr-close", "data-tb-drawer-close": "", "aria-label": "Close", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { "aria-hidden": "true", children: "\xD7" }) }),
|
|
1587
|
+
children
|
|
1588
|
+
] }),
|
|
1589
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DrawerRuntime, {})
|
|
1590
|
+
] })
|
|
1591
|
+
] });
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
// src/interactions/tabs.tsx
|
|
1595
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1431
1596
|
function Tabs({ id, panels }) {
|
|
1432
|
-
return /* @__PURE__ */ (0,
|
|
1433
|
-
/* @__PURE__ */ (0,
|
|
1597
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "tb-tabs", children: [
|
|
1598
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { role: "tablist", className: "tb-tablist", "data-b-tabs": "", children: panels.map((panel, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1434
1599
|
"button",
|
|
1435
1600
|
{
|
|
1436
1601
|
type: "button",
|
|
@@ -1444,7 +1609,7 @@ function Tabs({ id, panels }) {
|
|
|
1444
1609
|
},
|
|
1445
1610
|
panel.key
|
|
1446
1611
|
)) }),
|
|
1447
|
-
panels.map((panel, i) => /* @__PURE__ */ (0,
|
|
1612
|
+
panels.map((panel, i) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1448
1613
|
"div",
|
|
1449
1614
|
{
|
|
1450
1615
|
role: "tabpanel",
|
|
@@ -1453,7 +1618,7 @@ function Tabs({ id, panels }) {
|
|
|
1453
1618
|
"aria-labelledby": `${id}-t${String(i)}`,
|
|
1454
1619
|
tabIndex: 0,
|
|
1455
1620
|
children: [
|
|
1456
|
-
/* @__PURE__ */ (0,
|
|
1621
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "tb-panel-title", children: panel.title }),
|
|
1457
1622
|
panel.node
|
|
1458
1623
|
]
|
|
1459
1624
|
},
|
|
@@ -1463,19 +1628,101 @@ function Tabs({ id, panels }) {
|
|
|
1463
1628
|
}
|
|
1464
1629
|
|
|
1465
1630
|
// src/interactions/toggle.tsx
|
|
1466
|
-
var
|
|
1631
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1467
1632
|
function Toggle({
|
|
1468
1633
|
labelOpen,
|
|
1469
1634
|
labelClosed,
|
|
1470
1635
|
startOpen,
|
|
1471
1636
|
children
|
|
1472
1637
|
}) {
|
|
1473
|
-
return /* @__PURE__ */ (0,
|
|
1474
|
-
/* @__PURE__ */ (0,
|
|
1475
|
-
/* @__PURE__ */ (0,
|
|
1476
|
-
/* @__PURE__ */ (0,
|
|
1638
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("details", { className: "tb-toggle", ...startOpen ? { open: true } : {}, children: [
|
|
1639
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("summary", { className: "tb-toggle-sum", children: [
|
|
1640
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "tb-toggle-closed", children: labelClosed }),
|
|
1641
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "tb-toggle-open", children: labelOpen })
|
|
1477
1642
|
] }),
|
|
1478
|
-
/* @__PURE__ */ (0,
|
|
1643
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "tb-row", children })
|
|
1644
|
+
] });
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
// src/show-when.tsx
|
|
1648
|
+
var import_react11 = require("react");
|
|
1649
|
+
var import_builder_schema12 = require("@usethrottle/builder-schema");
|
|
1650
|
+
|
|
1651
|
+
// src/viewer.ts
|
|
1652
|
+
var import_react10 = require("react");
|
|
1653
|
+
var ViewerContext = typeof import_react10.createContext === "function" ? (0, import_react10.createContext)(void 0) : null;
|
|
1654
|
+
var useViewer = () => (0, import_react10.useContext)(ViewerContext);
|
|
1655
|
+
|
|
1656
|
+
// src/show-when.tsx
|
|
1657
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1658
|
+
function parseShowWhen(value) {
|
|
1659
|
+
if (value === void 0) return null;
|
|
1660
|
+
const parsed2 = import_builder_schema12.showWhenSchema.safeParse(value);
|
|
1661
|
+
if (!parsed2.success) return null;
|
|
1662
|
+
return parsed2.data.audience === "all" && parsed2.data.cart === "any" ? null : parsed2.data;
|
|
1663
|
+
}
|
|
1664
|
+
function showWhenState(when, viewer, mounted) {
|
|
1665
|
+
if (!mounted) return when.audience === "signed-in" || when.cart === "has-items" ? "placeholder" : "show";
|
|
1666
|
+
const known = viewer === null ? { signedIn: null, cartItemCount: null } : viewer ?? { signedIn: false, cartItemCount: 0 };
|
|
1667
|
+
let pending = false;
|
|
1668
|
+
if (when.audience !== "all") {
|
|
1669
|
+
if (known.signedIn === null) pending = pending || when.audience === "signed-in";
|
|
1670
|
+
else if ((known.signedIn ? "signed-in" : "guest") !== when.audience) return "hide";
|
|
1671
|
+
}
|
|
1672
|
+
if (when.cart !== "any") {
|
|
1673
|
+
if (known.cartItemCount === null) pending = pending || when.cart === "has-items";
|
|
1674
|
+
else if ((known.cartItemCount > 0 ? "has-items" : "empty") !== when.cart) return "hide";
|
|
1675
|
+
}
|
|
1676
|
+
return pending ? "placeholder" : "show";
|
|
1677
|
+
}
|
|
1678
|
+
var DEVICES = ["desktop", "tablet", "phone"];
|
|
1679
|
+
var isRec = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1680
|
+
var list = (v) => Array.isArray(v) ? v.filter(isRec) : [];
|
|
1681
|
+
function lengthOf(value) {
|
|
1682
|
+
if (typeof value === "number") return Number.isFinite(value) && value > 0 ? `${String(Math.min(Math.round(value), 2e3))}px` : null;
|
|
1683
|
+
if (typeof value === "string" && value !== "none" && import_builder_schema12.SPACING_TOKENS.includes(value)) return `var(--tb-space-${value})`;
|
|
1684
|
+
return null;
|
|
1685
|
+
}
|
|
1686
|
+
function heightAt(node, device) {
|
|
1687
|
+
const resolved = (0, import_builder_schema12.resolveResponsive)(isRec(node.props) ? node.props : {}, node.responsive, device);
|
|
1688
|
+
if (resolved.hidden === true) return null;
|
|
1689
|
+
const own = lengthOf(resolved.minHeight) ?? lengthOf(resolved.height);
|
|
1690
|
+
if (own !== null) return own;
|
|
1691
|
+
const columns = list(node.columns).map((c) => heightAt(c, device)).filter((h) => h !== null);
|
|
1692
|
+
if (columns.length > 0) return columns.length === 1 ? columns[0] : `max(${columns.join(",")})`;
|
|
1693
|
+
const stacked = list(node.children).map((c) => heightAt(c, device)).filter((h) => h !== null);
|
|
1694
|
+
if (stacked.length > 0) return stacked.length === 1 ? stacked[0] : `calc(${stacked.join(" + ")})`;
|
|
1695
|
+
return null;
|
|
1696
|
+
}
|
|
1697
|
+
function reservedHeights(node) {
|
|
1698
|
+
const found = DEVICES.map((device) => [device, heightAt(node, device)]);
|
|
1699
|
+
if (found.every(([, h]) => h === null)) return {};
|
|
1700
|
+
return Object.fromEntries(found.map(([device, h]) => [device, h ?? "0px"]));
|
|
1701
|
+
}
|
|
1702
|
+
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)))}}}";
|
|
1703
|
+
function ShowWhen({ when, heights, children }) {
|
|
1704
|
+
const viewer = useViewer();
|
|
1705
|
+
const [mounted, setMounted] = (0, import_react11.useState)(false);
|
|
1706
|
+
(0, import_react11.useEffect)(() => setMounted(true), []);
|
|
1707
|
+
const state = showWhenState(when, viewer, mounted);
|
|
1708
|
+
if (state === "show") return children;
|
|
1709
|
+
if (state === "hide") return null;
|
|
1710
|
+
const style = {
|
|
1711
|
+
...heights.desktop === void 0 ? {} : { "--tb-sw-h": heights.desktop },
|
|
1712
|
+
...heights.tablet === void 0 ? {} : { "--tb-sw-ht": heights.tablet },
|
|
1713
|
+
...heights.phone === void 0 ? {} : { "--tb-sw-hp": heights.phone }
|
|
1714
|
+
};
|
|
1715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
1716
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("style", { href: "tb-showwhen", precedence: "throttle", children: SHOW_WHEN_CSS }),
|
|
1717
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1718
|
+
"div",
|
|
1719
|
+
{
|
|
1720
|
+
className: "tb-sw",
|
|
1721
|
+
"aria-hidden": "true",
|
|
1722
|
+
"data-b-showwhen": when.audience === "signed-in" ? "signed-in" : "has-items",
|
|
1723
|
+
...Object.keys(style).length === 0 ? {} : { style }
|
|
1724
|
+
}
|
|
1725
|
+
)
|
|
1479
1726
|
] });
|
|
1480
1727
|
}
|
|
1481
1728
|
|
|
@@ -1501,9 +1748,9 @@ var BASE_CSS = `@layer throttle{
|
|
|
1501
1748
|
}`;
|
|
1502
1749
|
|
|
1503
1750
|
// src/renderer.tsx
|
|
1504
|
-
var
|
|
1505
|
-
var
|
|
1506
|
-
var COMMON_BY_KEY2 = new Map(
|
|
1751
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1752
|
+
var DEVICES2 = ["desktop", "tablet", "phone"];
|
|
1753
|
+
var COMMON_BY_KEY2 = new Map(import_builder_schema13.COMMON_WIDGET_SETTINGS.map((f) => [f.key, f]));
|
|
1507
1754
|
var withCustomCache = /* @__PURE__ */ new WeakMap();
|
|
1508
1755
|
function registryFor(doc, base) {
|
|
1509
1756
|
const snapshots = doc.customWidgets;
|
|
@@ -1518,7 +1765,7 @@ function registryFor(doc, base) {
|
|
|
1518
1765
|
try {
|
|
1519
1766
|
registry = base.withCustom(
|
|
1520
1767
|
Object.values(snapshots).filter(
|
|
1521
|
-
(snapshot) => snapshot.kind !== "code" ||
|
|
1768
|
+
(snapshot) => snapshot.kind !== "code" || import_builder_schema13.codeWidgetSnapshotSchema.safeParse(snapshot).success
|
|
1522
1769
|
)
|
|
1523
1770
|
);
|
|
1524
1771
|
} catch (error) {
|
|
@@ -1529,7 +1776,7 @@ function registryFor(doc, base) {
|
|
|
1529
1776
|
}
|
|
1530
1777
|
return registry;
|
|
1531
1778
|
}
|
|
1532
|
-
var
|
|
1779
|
+
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1533
1780
|
function pickLocale(value, locale) {
|
|
1534
1781
|
const lang = locale.split("-")[0] ?? locale;
|
|
1535
1782
|
for (const key of [locale, lang, "en"]) {
|
|
@@ -1540,25 +1787,36 @@ function pickLocale(value, locale) {
|
|
|
1540
1787
|
return "";
|
|
1541
1788
|
}
|
|
1542
1789
|
function onOrigin(asset, mediaOrigin) {
|
|
1543
|
-
if ((0,
|
|
1544
|
-
return { ...asset, variants: asset.variants.filter((v) => (0,
|
|
1790
|
+
if ((0, import_builder_schema13.safeUrl)(asset.url, "src", { mediaOrigin }) === null) return null;
|
|
1791
|
+
return { ...asset, variants: asset.variants.filter((v) => (0, import_builder_schema13.safeUrl)(v.url, "src", { mediaOrigin }) !== null) };
|
|
1792
|
+
}
|
|
1793
|
+
function prepareItem(field, item, ctx) {
|
|
1794
|
+
if (!isRecord3(item)) return item;
|
|
1795
|
+
const out = { ...item };
|
|
1796
|
+
for (const itemField of field.itemFields ?? []) {
|
|
1797
|
+
if (!Object.hasOwn(out, itemField.key)) continue;
|
|
1798
|
+
const prepared = prepare(itemField, out[itemField.key], ctx);
|
|
1799
|
+
out[itemField.key] = prepared;
|
|
1800
|
+
}
|
|
1801
|
+
return out;
|
|
1545
1802
|
}
|
|
1546
1803
|
function prepare(field, value, ctx) {
|
|
1547
1804
|
if (field === void 0 || value === null) return value;
|
|
1548
|
-
if (field.
|
|
1805
|
+
if (field.control === "list" && Array.isArray(value)) return value.map((item) => prepareItem(field, item, ctx));
|
|
1806
|
+
if (field.translatable === true && isRecord3(value)) return pickLocale(value, ctx.locale);
|
|
1549
1807
|
if (field.control === "image" && typeof value === "string") {
|
|
1550
1808
|
const asset = Object.hasOwn(ctx.assets, value) ? ctx.assets[value] : void 0;
|
|
1551
1809
|
return asset === void 0 ? null : onOrigin(asset, ctx.mediaOrigin);
|
|
1552
1810
|
}
|
|
1553
|
-
if (field.control === "link" &&
|
|
1554
|
-
const
|
|
1555
|
-
const raw = ctx.resolveLink?.(
|
|
1556
|
-
return { ...value, href: (0,
|
|
1811
|
+
if (field.control === "link" && isRecord3(value) && typeof value.kind === "string") {
|
|
1812
|
+
const target2 = value;
|
|
1813
|
+
const raw = ctx.resolveLink?.(target2) ?? (target2.kind === "url" ? target2.href : null);
|
|
1814
|
+
return { ...value, href: (0, import_builder_schema13.safeUrl)(raw, "href", { mediaOrigin: ctx.mediaOrigin }) };
|
|
1557
1815
|
}
|
|
1558
1816
|
return value;
|
|
1559
1817
|
}
|
|
1560
1818
|
function storedLinkPart(value) {
|
|
1561
|
-
if (!
|
|
1819
|
+
if (!isRecord3(value) || value.kind !== "page") return value;
|
|
1562
1820
|
const { slug: _slug, href: _href, ...stored } = value;
|
|
1563
1821
|
void _slug;
|
|
1564
1822
|
void _href;
|
|
@@ -1567,13 +1825,13 @@ function storedLinkPart(value) {
|
|
|
1567
1825
|
function settingsAt(node, fields, device, ctx) {
|
|
1568
1826
|
const base = {};
|
|
1569
1827
|
for (const field of fields.values()) base[field.key] = field.default;
|
|
1570
|
-
const resolved = (0,
|
|
1828
|
+
const resolved = (0, import_builder_schema13.resolveResponsive)({ ...base, ...node.props }, node.responsive, device);
|
|
1571
1829
|
const out = {};
|
|
1572
1830
|
for (const [key, value] of Object.entries(resolved)) {
|
|
1573
1831
|
const field = fields.get(key);
|
|
1574
1832
|
const freeText = field?.control === "text" || field?.control === "richtext";
|
|
1575
1833
|
const checked2 = field?.control === "link" ? storedLinkPart(value) : value;
|
|
1576
|
-
const usable = field === void 0 || (freeText ? value !== null : (0,
|
|
1834
|
+
const usable = field === void 0 || (freeText ? value !== null : (0, import_builder_schema13.validateSettingValue)(field, checked2) === null) ? value : field.default;
|
|
1577
1835
|
out[key] = prepare(field, usable, ctx);
|
|
1578
1836
|
}
|
|
1579
1837
|
return out;
|
|
@@ -1581,7 +1839,7 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
1581
1839
|
function variantsOf(node, def, fields, ctx) {
|
|
1582
1840
|
const markup = [...fields.values()].filter((f) => f.output === "markup").map((f) => f.key);
|
|
1583
1841
|
const groups = /* @__PURE__ */ new Map();
|
|
1584
|
-
for (const device of
|
|
1842
|
+
for (const device of DEVICES2) {
|
|
1585
1843
|
const props = settingsAt(node, fields, device, ctx);
|
|
1586
1844
|
const signature = stable(markup.map((key) => props[key] ?? null));
|
|
1587
1845
|
const group = groups.get(signature);
|
|
@@ -1592,8 +1850,8 @@ function variantsOf(node, def, fields, ctx) {
|
|
|
1592
1850
|
return [...groups.values()];
|
|
1593
1851
|
}
|
|
1594
1852
|
function hiddenEverywhere(props, responsive) {
|
|
1595
|
-
return
|
|
1596
|
-
(device) => (0,
|
|
1853
|
+
return DEVICES2.every(
|
|
1854
|
+
(device) => (0, import_builder_schema13.resolveResponsive)({ hidden: props.hidden ?? false }, responsive, device).hidden === true
|
|
1597
1855
|
);
|
|
1598
1856
|
}
|
|
1599
1857
|
var variantClass = (variant) => `tb-v ${variant.devices.map((d) => `tb-only-${d}`).join(" ")}`;
|
|
@@ -1609,7 +1867,7 @@ function renderCodeWidget(node, snapshot, ctx, registry) {
|
|
|
1609
1867
|
}
|
|
1610
1868
|
const props = settingsAt(node, fields, "desktop", ctx);
|
|
1611
1869
|
const anchor = props.anchor;
|
|
1612
|
-
return /* @__PURE__ */ (0,
|
|
1870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1613
1871
|
CodeWidget,
|
|
1614
1872
|
{
|
|
1615
1873
|
node,
|
|
@@ -1638,7 +1896,7 @@ function renderWidget(node, ctx, registry) {
|
|
|
1638
1896
|
if (isDevelopment()) {
|
|
1639
1897
|
warnOnce(`missing:${node.type}@${String(node.v)}`, `Unknown widget ${node.type} v${String(node.v)}; rendering nothing for it`);
|
|
1640
1898
|
}
|
|
1641
|
-
return /* @__PURE__ */ (0,
|
|
1899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(NodeWrapper, { id: node.id, part: "widget", type: node.type, className: "tb-w", missing: true, children: ctx.edit !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "tb-missing", children: "Widget unavailable: update @usethrottle/storefront-react" }) });
|
|
1642
1900
|
}
|
|
1643
1901
|
if (ctx.edit === void 0 && hiddenEverywhere(node.props, node.responsive)) return null;
|
|
1644
1902
|
const fields = new Map([...COMMON_BY_KEY2, ...def.settings.map((f) => [f.key, f])]);
|
|
@@ -1651,21 +1909,22 @@ function renderWidget(node, ctx, registry) {
|
|
|
1651
1909
|
}
|
|
1652
1910
|
const custom = node.type.startsWith("custom.");
|
|
1653
1911
|
const edit = ctx.edit;
|
|
1654
|
-
|
|
1912
|
+
const copies = variants.map((variant, index) => {
|
|
1655
1913
|
const anchor = variant.props.anchor;
|
|
1656
|
-
return /* @__PURE__ */ (0,
|
|
1914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1657
1915
|
NodeWrapper,
|
|
1658
1916
|
{
|
|
1659
1917
|
id: node.id,
|
|
1660
1918
|
part: "widget",
|
|
1661
1919
|
type: node.type,
|
|
1662
1920
|
custom,
|
|
1921
|
+
cssClass: node.cssClass,
|
|
1663
1922
|
edit,
|
|
1664
1923
|
className: variants.length > 1 ? `tb-w ${variantClass(variant)}` : "tb-w",
|
|
1665
1924
|
anchor: index === 0 && !ctx.dupe && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
1666
1925
|
copyAnchor: ctx.vpath !== "" && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
1667
1926
|
entrance: entranceOf(variant.props.entrance, variant.props.entranceDelayMs, ctx.interactive),
|
|
1668
|
-
children: /* @__PURE__ */ (0,
|
|
1927
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1669
1928
|
Component2,
|
|
1670
1929
|
{
|
|
1671
1930
|
node,
|
|
@@ -1685,36 +1944,45 @@ function renderWidget(node, ctx, registry) {
|
|
|
1685
1944
|
variant.devices.join("-")
|
|
1686
1945
|
);
|
|
1687
1946
|
});
|
|
1947
|
+
return gated(node, ctx, copies);
|
|
1948
|
+
}
|
|
1949
|
+
function gated(node, ctx, content) {
|
|
1950
|
+
if (ctx.edit !== void 0) return content;
|
|
1951
|
+
const when = parseShowWhen(node.showWhen);
|
|
1952
|
+
if (when === null) return content;
|
|
1953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ShowWhen, { when, heights: reservedHeights(node), children: content });
|
|
1688
1954
|
}
|
|
1689
1955
|
function renderColumn(column, ctx, registry) {
|
|
1690
1956
|
if (ctx.edit === void 0 && hiddenEverywhere(column.props, column.responsive)) return null;
|
|
1691
|
-
|
|
1957
|
+
const drawn = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1692
1958
|
NodeWrapper,
|
|
1693
1959
|
{
|
|
1694
1960
|
id: column.id,
|
|
1695
1961
|
part: "column",
|
|
1696
1962
|
className: "tb-col",
|
|
1963
|
+
cssClass: column.cssClass,
|
|
1697
1964
|
anchor: ctx.dupe ? void 0 : column.props.anchor,
|
|
1698
1965
|
copyAnchor: ctx.vpath === "" ? void 0 : column.props.anchor,
|
|
1699
1966
|
edit: ctx.edit,
|
|
1700
1967
|
entrance: entranceOf(
|
|
1701
|
-
(0,
|
|
1702
|
-
(0,
|
|
1968
|
+
(0, import_builder_schema13.resolveEntrance)(column, "desktop").entrance,
|
|
1969
|
+
(0, import_builder_schema13.resolveEntrance)(column, "desktop").entranceDelayMs,
|
|
1703
1970
|
ctx.interactive
|
|
1704
1971
|
),
|
|
1705
1972
|
children: column.children.map(
|
|
1706
|
-
(child) => child.type === "inner-section" ? /* @__PURE__ */ (0,
|
|
1973
|
+
(child) => child.type === "inner-section" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react12.Fragment, { children: renderSection(child, ctx, registry, true) }, child.id) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react12.Fragment, { children: renderWidget(child, ctx, registry) }, child.id)
|
|
1707
1974
|
)
|
|
1708
1975
|
},
|
|
1709
1976
|
column.id
|
|
1710
1977
|
);
|
|
1978
|
+
return gated(column, ctx, drawn);
|
|
1711
1979
|
}
|
|
1712
|
-
var PLAIN = (0,
|
|
1980
|
+
var PLAIN = (0, import_builder_schema13.resolveInteraction)({ props: {}, responsive: void 0 }, "desktop");
|
|
1713
1981
|
function sectionVariants(section, ctx) {
|
|
1714
1982
|
const groups = /* @__PURE__ */ new Map();
|
|
1715
|
-
for (const device of
|
|
1716
|
-
const interaction = ctx.interactive ? (0,
|
|
1717
|
-
const entrance = ctx.interactive ? (0,
|
|
1983
|
+
for (const device of DEVICES2) {
|
|
1984
|
+
const interaction = ctx.interactive ? (0, import_builder_schema13.resolveInteraction)(section, device) : PLAIN;
|
|
1985
|
+
const entrance = ctx.interactive ? (0, import_builder_schema13.resolveEntrance)(section, device) : { entrance: "none", entranceDelayMs: 0 };
|
|
1718
1986
|
const signature = stable([interaction, entrance]);
|
|
1719
1987
|
const group = groups.get(signature);
|
|
1720
1988
|
if (group === void 0) groups.set(signature, { devices: [device], interaction, entrance });
|
|
@@ -1732,7 +2000,8 @@ function panelsOf(section, ctx, registry, fallback) {
|
|
|
1732
2000
|
function renderSection(section, ctx, registry, nested = false) {
|
|
1733
2001
|
if (ctx.edit === void 0 && hiddenEverywhere(section.props, section.responsive)) return null;
|
|
1734
2002
|
const variants = sectionVariants(section, ctx);
|
|
1735
|
-
const
|
|
2003
|
+
const frame = nested || !ctx.interactive || ctx.edit !== void 0 ? null : frameOf(section);
|
|
2004
|
+
const marker = variants.length > 1 && !ctx.dupe && section.props.anchor !== void 0 && import_builder_schema13.ANCHOR_RE.test(section.props.anchor) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id: section.props.anchor, className: "tb-anchor" }, "anchor") : null;
|
|
1736
2005
|
const copies = variants.map((variant, index) => {
|
|
1737
2006
|
const { interaction } = variant;
|
|
1738
2007
|
const id = `ix-${section.id}-${ctx.vpath}${String(index)}`;
|
|
@@ -1740,9 +2009,9 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
1740
2009
|
const columns = () => section.columns.map((column) => renderColumn(column, own, registry));
|
|
1741
2010
|
let body;
|
|
1742
2011
|
if (interaction.interaction === "tabs") {
|
|
1743
|
-
body = /* @__PURE__ */ (0,
|
|
2012
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Tabs, { id, panels: panelsOf(section, own, registry, (n) => `Tab ${String(n)}`) });
|
|
1744
2013
|
} else if (interaction.interaction === "accordion") {
|
|
1745
|
-
body = /* @__PURE__ */ (0,
|
|
2014
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1746
2015
|
Accordion,
|
|
1747
2016
|
{
|
|
1748
2017
|
id,
|
|
@@ -1752,7 +2021,7 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
1752
2021
|
}
|
|
1753
2022
|
);
|
|
1754
2023
|
} else if (interaction.interaction === "carousel") {
|
|
1755
|
-
body = /* @__PURE__ */ (0,
|
|
2024
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1756
2025
|
Carousel,
|
|
1757
2026
|
{
|
|
1758
2027
|
panels: panelsOf(section, own, registry, () => ""),
|
|
@@ -1761,7 +2030,7 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
1761
2030
|
}
|
|
1762
2031
|
);
|
|
1763
2032
|
} else if (interaction.interaction === "toggle") {
|
|
1764
|
-
body = /* @__PURE__ */ (0,
|
|
2033
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1765
2034
|
Toggle,
|
|
1766
2035
|
{
|
|
1767
2036
|
labelOpen: pickLocale(interaction.toggleLabelOpen, ctx.locale),
|
|
@@ -1771,39 +2040,55 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
1771
2040
|
}
|
|
1772
2041
|
);
|
|
1773
2042
|
} else {
|
|
1774
|
-
body = /* @__PURE__ */ (0,
|
|
2043
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "tb-row", children: columns() });
|
|
2044
|
+
}
|
|
2045
|
+
if (frame?.collapse != null) {
|
|
2046
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2047
|
+
Collapse,
|
|
2048
|
+
{
|
|
2049
|
+
sectionId: section.id,
|
|
2050
|
+
id: `fr-${section.id}-${ctx.vpath}${String(index)}`,
|
|
2051
|
+
px: frame.collapse.px,
|
|
2052
|
+
label: pickLocale(frame.collapse.label, ctx.locale) || import_builder_schema13.SITE_STRING_DEFAULTS["nav.menu"],
|
|
2053
|
+
children: body
|
|
2054
|
+
}
|
|
2055
|
+
);
|
|
1775
2056
|
}
|
|
1776
|
-
return /* @__PURE__ */ (0,
|
|
2057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1777
2058
|
NodeWrapper,
|
|
1778
2059
|
{
|
|
1779
2060
|
id: section.id,
|
|
1780
2061
|
part: "section",
|
|
2062
|
+
cssClass: section.cssClass,
|
|
1781
2063
|
as: nested ? "div" : "section",
|
|
1782
|
-
className: `${nested ? "tb-section tb-nested" : "tb-section"}${variants.length > 1 ? ` ${variantClass({ devices: variant.devices, props: {} })}` : ""}`,
|
|
2064
|
+
className: `${nested ? "tb-section tb-nested" : "tb-section"}${frame?.sticky === true ? " tb-sticky" : ""}${variants.length > 1 ? ` ${variantClass({ devices: variant.devices, props: {} })}` : ""}`,
|
|
1783
2065
|
anchor: variants.length === 1 && !ctx.dupe ? section.props.anchor : void 0,
|
|
1784
2066
|
copyAnchor: variants.length > 1 || ctx.vpath !== "" ? section.props.anchor : void 0,
|
|
1785
2067
|
edit: ctx.edit,
|
|
1786
2068
|
entrance: entranceOf(variant.entrance.entrance, variant.entrance.entranceDelayMs, ctx.interactive),
|
|
1787
|
-
children:
|
|
2069
|
+
children: [
|
|
2070
|
+
frame !== null ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("style", { href: "tb-frame", precedence: "throttle", children: FRAME_CSS }) : null,
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "tb-inner", children: body })
|
|
2072
|
+
]
|
|
1788
2073
|
},
|
|
1789
2074
|
variant.devices.join("-")
|
|
1790
2075
|
);
|
|
1791
2076
|
});
|
|
1792
|
-
return marker === null ? copies : [marker, ...copies];
|
|
2077
|
+
return gated(section, ctx, marker === null ? copies : [marker, ...copies]);
|
|
1793
2078
|
}
|
|
1794
2079
|
function needsRuntime(doc) {
|
|
1795
2080
|
let found = false;
|
|
1796
|
-
(0,
|
|
2081
|
+
(0, import_builder_schema13.walkNodes)(doc, (node) => {
|
|
1797
2082
|
if (found || node.type === "saved-section") return;
|
|
1798
2083
|
if (node.type === "section" || node.type === "inner-section") {
|
|
1799
|
-
found =
|
|
1800
|
-
(device) => (0,
|
|
2084
|
+
found = DEVICES2.some(
|
|
2085
|
+
(device) => (0, import_builder_schema13.resolveInteraction)(node, device).interaction !== "none" || (0, import_builder_schema13.resolveEntrance)(node, device).entrance !== "none"
|
|
1801
2086
|
);
|
|
1802
2087
|
} else if (node.type === "column") {
|
|
1803
|
-
found =
|
|
2088
|
+
found = DEVICES2.some((device) => (0, import_builder_schema13.resolveEntrance)(node, device).entrance !== "none");
|
|
1804
2089
|
} else {
|
|
1805
|
-
found =
|
|
1806
|
-
const entrance = (0,
|
|
2090
|
+
found = DEVICES2.some((device) => {
|
|
2091
|
+
const entrance = (0, import_builder_schema13.resolveResponsive)(node.props, node.responsive, device).entrance;
|
|
1807
2092
|
return entrance !== void 0 && entrance !== "none";
|
|
1808
2093
|
});
|
|
1809
2094
|
}
|
|
@@ -1815,40 +2100,40 @@ function BuilderRenderer(props) {
|
|
|
1815
2100
|
const expansion = expandSavedSections(raw, props.savedSections);
|
|
1816
2101
|
const source = expansion.doc;
|
|
1817
2102
|
const registry = registryFor(source, base);
|
|
1818
|
-
const { doc } = (0,
|
|
2103
|
+
const { doc } = (0, import_builder_schema13.upgradeNodes)(source, registry);
|
|
1819
2104
|
const mediaOrigin = props.mediaOrigin ?? "";
|
|
1820
2105
|
const interactive = props.interactive !== false;
|
|
1821
2106
|
const ctx = { registry, data, locale, assets, mediaOrigin, resolveLink, code, edit: editMode, interactive, vpath: props.idScope?.vpath ?? "", dupe: props.idScope?.dupe ?? false, snapshots: source.customWidgets };
|
|
1822
2107
|
const css = compileResponsiveCss(doc, registry, assets, mediaOrigin);
|
|
1823
2108
|
const upgraded = new Map(doc.sections.map((section) => [section.id, section]));
|
|
1824
|
-
return /* @__PURE__ */ (0,
|
|
1825
|
-
interactive && needsRuntime(doc) ? /* @__PURE__ */ (0,
|
|
1826
|
-
/* @__PURE__ */ (0,
|
|
1827
|
-
css === "" ? null : /* @__PURE__ */ (0,
|
|
2109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "tb-root", "data-throttle-part": "builder-root", ...props.scopeCustomCss === true ? { "data-b-root": "" } : {}, children: [
|
|
2110
|
+
interactive && needsRuntime(doc) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(InteractionRuntime, {}) : null,
|
|
2111
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("style", { href: "tb-base", precedence: "throttle", children: BASE_CSS }),
|
|
2112
|
+
css === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("style", { children: css }),
|
|
1828
2113
|
(expansion.roots ?? doc.sections.map((section) => ({ kind: "section", id: section.id }))).map((root) => {
|
|
1829
2114
|
if (root.kind === "section") {
|
|
1830
2115
|
const section2 = upgraded.get(root.id);
|
|
1831
|
-
return section2?.type === "section" ? /* @__PURE__ */ (0,
|
|
2116
|
+
return section2?.type === "section" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react12.Fragment, { children: renderSection(section2, ctx, registry) }, root.id) : null;
|
|
1832
2117
|
}
|
|
1833
2118
|
const section = root.sectionId === null ? void 0 : upgraded.get(root.sectionId);
|
|
1834
2119
|
if (section?.type === "section") {
|
|
1835
|
-
return root.ref.props.hidden === true && ctx.edit === void 0 ? null : /* @__PURE__ */ (0,
|
|
2120
|
+
return root.ref.props.hidden === true && ctx.edit === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react12.Fragment, { children: renderSection(section, ctx, registry) }, root.ref.id);
|
|
1836
2121
|
}
|
|
1837
|
-
return /* @__PURE__ */ (0,
|
|
2122
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MissingSavedSection, { node: root.ref }, root.ref.id);
|
|
1838
2123
|
})
|
|
1839
2124
|
] });
|
|
1840
2125
|
}
|
|
1841
2126
|
function validateRender(doc) {
|
|
1842
2127
|
const h1 = [];
|
|
1843
|
-
(0,
|
|
2128
|
+
(0, import_builder_schema13.walkNodes)(doc, (node) => {
|
|
1844
2129
|
if (node.type === "basic.heading" && node.props.level === "h1") h1.push(node.id);
|
|
1845
2130
|
});
|
|
1846
2131
|
return h1.length > 1 ? [{ code: "MULTIPLE_H1", message: `The page has ${String(h1.length)} level 1 headings; use one`, nodeIds: h1 }] : [];
|
|
1847
2132
|
}
|
|
1848
2133
|
|
|
1849
2134
|
// src/asset-image.tsx
|
|
1850
|
-
var
|
|
1851
|
-
var
|
|
2135
|
+
var import_builder_schema14 = require("@usethrottle/builder-schema");
|
|
2136
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1852
2137
|
function isFrozenAsset(value) {
|
|
1853
2138
|
if (typeof value !== "object" || value === null) return false;
|
|
1854
2139
|
const v = value;
|
|
@@ -1856,7 +2141,7 @@ function isFrozenAsset(value) {
|
|
|
1856
2141
|
}
|
|
1857
2142
|
function AssetImage(props) {
|
|
1858
2143
|
const { asset, alt, sizes, className, loading = "lazy", style, mediaOrigin } = props;
|
|
1859
|
-
const href = (url) => (0,
|
|
2144
|
+
const href = (url) => (0, import_builder_schema14.safeUrl)(url, "src", { mediaOrigin });
|
|
1860
2145
|
if (!isFrozenAsset(asset)) return null;
|
|
1861
2146
|
const src = href(asset.url);
|
|
1862
2147
|
if (src === null) return null;
|
|
@@ -1864,7 +2149,7 @@ function AssetImage(props) {
|
|
|
1864
2149
|
const url = href(variant.url);
|
|
1865
2150
|
return url === null || url.includes(",") ? [] : [`${url} ${String(variant.width)}w`];
|
|
1866
2151
|
}).join(", ");
|
|
1867
|
-
return /* @__PURE__ */ (0,
|
|
2152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1868
2153
|
"img",
|
|
1869
2154
|
{
|
|
1870
2155
|
src,
|
|
@@ -1881,20 +2166,20 @@ function AssetImage(props) {
|
|
|
1881
2166
|
}
|
|
1882
2167
|
|
|
1883
2168
|
// src/provider.tsx
|
|
1884
|
-
var
|
|
2169
|
+
var import_react25 = require("react");
|
|
1885
2170
|
var import_builder2 = require("@usethrottle/builder");
|
|
1886
|
-
var
|
|
2171
|
+
var import_ui10 = require("@usethrottle/ui");
|
|
1887
2172
|
|
|
1888
2173
|
// src/page.tsx
|
|
1889
|
-
var
|
|
2174
|
+
var import_react13 = require("react");
|
|
1890
2175
|
var import_builder = require("@usethrottle/builder");
|
|
1891
2176
|
|
|
1892
2177
|
// src/load.ts
|
|
1893
2178
|
function pageOf(raw, initialData) {
|
|
1894
|
-
const { document: document2, id: _id, slug, title, path, generation, pageType: _type, updatedAt: _updated, savedSections, code, ...meta } = raw;
|
|
2179
|
+
const { document: document2, id: _id, slug: slug2, title, path, generation, pageType: _type, updatedAt: _updated, savedSections, code, ...meta } = raw;
|
|
1895
2180
|
return {
|
|
1896
2181
|
kind: "page",
|
|
1897
|
-
slug,
|
|
2182
|
+
slug: slug2,
|
|
1898
2183
|
title,
|
|
1899
2184
|
path,
|
|
1900
2185
|
generation,
|
|
@@ -1909,7 +2194,7 @@ function pageOf(raw, initialData) {
|
|
|
1909
2194
|
var isRedirect = (raw) => typeof raw.redirectTo === "string";
|
|
1910
2195
|
|
|
1911
2196
|
// src/safe-path.ts
|
|
1912
|
-
var
|
|
2197
|
+
var import_builder_schema15 = require("@usethrottle/builder-schema");
|
|
1913
2198
|
var UNSAFE = /[\x00-\x20\x7f-\xa0\\\u1680\u2000-\u200f\u2028\u2029\u202f\u205f\u3000\ufeff]/;
|
|
1914
2199
|
var LEADING = /^\/(?![/\\])/;
|
|
1915
2200
|
function plainPath(path) {
|
|
@@ -1924,15 +2209,15 @@ function sitePath(to) {
|
|
|
1924
2209
|
return null;
|
|
1925
2210
|
}
|
|
1926
2211
|
if (!plainPath(decoded2)) return null;
|
|
1927
|
-
return (0,
|
|
2212
|
+
return (0, import_builder_schema15.safeUrl)(to, "href", { mediaOrigin: "" });
|
|
1928
2213
|
}
|
|
1929
2214
|
|
|
1930
2215
|
// src/page.tsx
|
|
1931
|
-
var
|
|
2216
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1932
2217
|
function BuilderPageView({ page, resolve = "shopper" }) {
|
|
1933
2218
|
const builder = useBuilder();
|
|
1934
2219
|
if (builder === null) throw new Error("A Builder page needs a BuilderProvider above it");
|
|
1935
|
-
return /* @__PURE__ */ (0,
|
|
2220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PageBody, { page, resolve, builder });
|
|
1936
2221
|
}
|
|
1937
2222
|
function PageBody({
|
|
1938
2223
|
page,
|
|
@@ -1941,7 +2226,7 @@ function PageBody({
|
|
|
1941
2226
|
}) {
|
|
1942
2227
|
const expanded = expandSavedSections(page.document, page.savedSections).doc;
|
|
1943
2228
|
const resolved = useResolvedData(expanded, builder.registry, builder.locale, resolve);
|
|
1944
|
-
return /* @__PURE__ */ (0,
|
|
2229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1945
2230
|
BuilderRenderer,
|
|
1946
2231
|
{
|
|
1947
2232
|
document: page.document,
|
|
@@ -1960,17 +2245,17 @@ function PageBody({
|
|
|
1960
2245
|
}
|
|
1961
2246
|
var entries = /* @__PURE__ */ new WeakMap();
|
|
1962
2247
|
var ENTRY_MS = 5e3;
|
|
1963
|
-
function read(client,
|
|
2248
|
+
function read(client, slug2, locale) {
|
|
1964
2249
|
let perClient = entries.get(client);
|
|
1965
2250
|
if (perClient === void 0) {
|
|
1966
2251
|
perClient = /* @__PURE__ */ new Map();
|
|
1967
2252
|
entries.set(client, perClient);
|
|
1968
2253
|
}
|
|
1969
|
-
const key = `${locale}|${
|
|
2254
|
+
const key = `${locale}|${slug2}`;
|
|
1970
2255
|
let entry = perClient.get(key);
|
|
1971
2256
|
if (entry === void 0) {
|
|
1972
2257
|
const made = { status: "pending", promise: Promise.resolve() };
|
|
1973
|
-
made.promise = client.pages.get(
|
|
2258
|
+
made.promise = client.pages.get(slug2, { locale }).then(
|
|
1974
2259
|
(raw) => {
|
|
1975
2260
|
made.status = "done";
|
|
1976
2261
|
made.value = isRedirect(raw) ? raw : pageOf(raw, {});
|
|
@@ -1990,22 +2275,22 @@ function read(client, slug, locale) {
|
|
|
1990
2275
|
if (entry.status === "failed") throw entry.error;
|
|
1991
2276
|
return entry.value;
|
|
1992
2277
|
}
|
|
1993
|
-
function BuilderPage({ slug, initial }) {
|
|
2278
|
+
function BuilderPage({ slug: slug2, initial }) {
|
|
1994
2279
|
const builder = useBuilder();
|
|
1995
2280
|
if (builder === null) throw new Error("BuilderPage needs a BuilderProvider above it");
|
|
1996
|
-
if (initial !== void 0) return /* @__PURE__ */ (0,
|
|
2281
|
+
if (initial !== void 0) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BuilderPageView, { page: initial });
|
|
1997
2282
|
if (builder.site.status === "unavailable") {
|
|
1998
2283
|
throw new import_builder.BuilderUnavailableError("network", "The Builder is unavailable and has no last good answer");
|
|
1999
2284
|
}
|
|
2000
2285
|
if (builder.client === null) {
|
|
2001
2286
|
throw new Error("BuilderPage reads the page itself: give BuilderProvider a builderKey or a client, or pass `initial`");
|
|
2002
2287
|
}
|
|
2003
|
-
const found = read(builder.client,
|
|
2004
|
-
if ("redirectTo" in found) return /* @__PURE__ */ (0,
|
|
2005
|
-
return /* @__PURE__ */ (0,
|
|
2288
|
+
const found = read(builder.client, slug2, builder.locale);
|
|
2289
|
+
if ("redirectTo" in found) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Redirect, { to: found.redirectTo });
|
|
2290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BuilderPageView, { page: found, resolve: "all" });
|
|
2006
2291
|
}
|
|
2007
2292
|
function Redirect({ to }) {
|
|
2008
|
-
(0,
|
|
2293
|
+
(0, import_react13.useEffect)(() => {
|
|
2009
2294
|
const path = sitePath(to);
|
|
2010
2295
|
if (path !== null) window.location.replace(path);
|
|
2011
2296
|
}, [to]);
|
|
@@ -2013,18 +2298,18 @@ function Redirect({ to }) {
|
|
|
2013
2298
|
}
|
|
2014
2299
|
|
|
2015
2300
|
// src/registry.ts
|
|
2016
|
-
var
|
|
2301
|
+
var import_builder_schema33 = require("@usethrottle/builder-schema");
|
|
2017
2302
|
|
|
2018
2303
|
// src/basics/index.ts
|
|
2019
|
-
var
|
|
2304
|
+
var import_builder_schema31 = require("@usethrottle/builder-schema");
|
|
2020
2305
|
|
|
2021
2306
|
// src/basics/announcement.tsx
|
|
2022
|
-
var
|
|
2307
|
+
var import_react14 = require("react");
|
|
2023
2308
|
var import_ui = require("@usethrottle/ui");
|
|
2024
|
-
var
|
|
2309
|
+
var import_builder_schema17 = require("@usethrottle/builder-schema");
|
|
2025
2310
|
|
|
2026
2311
|
// src/basics/util.tsx
|
|
2027
|
-
var
|
|
2312
|
+
var import_builder_schema16 = require("@usethrottle/builder-schema");
|
|
2028
2313
|
|
|
2029
2314
|
// src/basics/styles.ts
|
|
2030
2315
|
var BASICS_CSS = `@layer throttle{
|
|
@@ -2089,34 +2374,34 @@ var BASICS_CSS = `@layer throttle{
|
|
|
2089
2374
|
}`;
|
|
2090
2375
|
|
|
2091
2376
|
// src/basics/util.tsx
|
|
2092
|
-
var
|
|
2377
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2093
2378
|
function BasicStyles() {
|
|
2094
|
-
return /* @__PURE__ */ (0,
|
|
2379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("style", { href: "tb-basics", precedence: "throttle", children: BASICS_CSS });
|
|
2095
2380
|
}
|
|
2096
|
-
var
|
|
2381
|
+
var isRecord4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2097
2382
|
var str = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
2098
2383
|
function oneOf(value, allowed, fallback) {
|
|
2099
2384
|
return allowed.find((candidate) => candidate === value) ?? fallback;
|
|
2100
2385
|
}
|
|
2101
2386
|
function hrefOf(link, mediaOrigin) {
|
|
2102
|
-
if (!
|
|
2103
|
-
return (0,
|
|
2387
|
+
if (!isRecord4(link)) return null;
|
|
2388
|
+
return (0, import_builder_schema16.safeUrl)(link.href, "href", { mediaOrigin });
|
|
2104
2389
|
}
|
|
2105
2390
|
function Placeholder({ editMode, children }) {
|
|
2106
|
-
return editMode ? /* @__PURE__ */ (0,
|
|
2391
|
+
return editMode ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "tb-b-empty", children }) : null;
|
|
2107
2392
|
}
|
|
2108
2393
|
var ID_RE2 = /^[a-z0-9]{8,24}(-[a-z0-9]{8,24})?$/;
|
|
2109
|
-
var
|
|
2394
|
+
var DEVICES3 = ["desktop", "tablet", "phone"];
|
|
2110
2395
|
function defaultOf(type, key) {
|
|
2111
|
-
const def =
|
|
2396
|
+
const def = import_builder_schema16.BASIC_WIDGET_DEFINITIONS.filter((d) => d.type === type).sort((a, b) => b.v - a.v)[0];
|
|
2112
2397
|
return def?.settings.find((f) => f.key === key)?.default ?? null;
|
|
2113
2398
|
}
|
|
2114
2399
|
function enumCss(node, rules) {
|
|
2115
2400
|
if (!ID_RE2.test(node.id)) return "";
|
|
2116
2401
|
const per = { desktop: /* @__PURE__ */ new Map(), tablet: /* @__PURE__ */ new Map(), phone: /* @__PURE__ */ new Map() };
|
|
2117
|
-
for (const device of
|
|
2402
|
+
for (const device of DEVICES3) {
|
|
2118
2403
|
const settings = { ...Object.fromEntries(rules.map((r) => [r.key, defaultOf(node.type, r.key)])), ...node.props };
|
|
2119
|
-
const resolved = (0,
|
|
2404
|
+
const resolved = (0, import_builder_schema16.resolveResponsive)(settings, node.responsive, device);
|
|
2120
2405
|
for (const rule of rules) {
|
|
2121
2406
|
const value = resolved[rule.key];
|
|
2122
2407
|
const fallback = defaultOf(node.type, rule.key);
|
|
@@ -2133,7 +2418,7 @@ function enumCss(node, rules) {
|
|
|
2133
2418
|
}
|
|
2134
2419
|
|
|
2135
2420
|
// src/basics/announcement.tsx
|
|
2136
|
-
var
|
|
2421
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2137
2422
|
var KEY = "tb-announcement-dismissed";
|
|
2138
2423
|
function read2(message) {
|
|
2139
2424
|
try {
|
|
@@ -2151,25 +2436,25 @@ function write(message) {
|
|
|
2151
2436
|
function Announcement({ props, mediaOrigin, editMode }) {
|
|
2152
2437
|
const design = (0, import_ui.useSiteDesign)();
|
|
2153
2438
|
const message = design?.announcement?.message;
|
|
2154
|
-
const [dismissed, setDismissed] = (0,
|
|
2155
|
-
(0,
|
|
2439
|
+
const [dismissed, setDismissed] = (0, import_react14.useState)(false);
|
|
2440
|
+
(0, import_react14.useEffect)(() => {
|
|
2156
2441
|
if (message !== void 0 && read2(message)) setDismissed(true);
|
|
2157
2442
|
}, [message]);
|
|
2158
2443
|
if (message === void 0) {
|
|
2159
|
-
return /* @__PURE__ */ (0,
|
|
2160
|
-
/* @__PURE__ */ (0,
|
|
2161
|
-
/* @__PURE__ */ (0,
|
|
2444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2445
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(BasicStyles, {}),
|
|
2446
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Placeholder, { editMode, children: "No announcement: turn one on in Site settings" })
|
|
2162
2447
|
] });
|
|
2163
2448
|
}
|
|
2164
2449
|
if (dismissed && !editMode) return null;
|
|
2165
|
-
const href = (0,
|
|
2450
|
+
const href = (0, import_builder_schema17.safeUrl)(design?.announcement?.href, "href", { mediaOrigin });
|
|
2166
2451
|
const strings = design?.strings;
|
|
2167
|
-
const dismissLabel = (strings !== void 0 && Object.hasOwn(strings, "announcement.dismiss") ? str(strings["announcement.dismiss"]) : void 0) ??
|
|
2168
|
-
return /* @__PURE__ */ (0,
|
|
2169
|
-
/* @__PURE__ */ (0,
|
|
2170
|
-
/* @__PURE__ */ (0,
|
|
2171
|
-
/* @__PURE__ */ (0,
|
|
2172
|
-
props.dismissible === true && /* @__PURE__ */ (0,
|
|
2452
|
+
const dismissLabel = (strings !== void 0 && Object.hasOwn(strings, "announcement.dismiss") ? str(strings["announcement.dismiss"]) : void 0) ?? import_builder_schema17.SITE_STRING_DEFAULTS["announcement.dismiss"];
|
|
2453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2454
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(BasicStyles, {}),
|
|
2455
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "tb-b-announcement", role: "region", "aria-label": message, children: [
|
|
2456
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "tb-b-announcement-text", children: href === null ? message : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("a", { href, children: message }) }),
|
|
2457
|
+
props.dismissible === true && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2173
2458
|
"button",
|
|
2174
2459
|
{
|
|
2175
2460
|
type: "button",
|
|
@@ -2178,7 +2463,7 @@ function Announcement({ props, mediaOrigin, editMode }) {
|
|
|
2178
2463
|
write(message);
|
|
2179
2464
|
setDismissed(true);
|
|
2180
2465
|
},
|
|
2181
|
-
children: /* @__PURE__ */ (0,
|
|
2466
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_ui.Icon, { name: "close", size: 16, label: dismissLabel })
|
|
2182
2467
|
}
|
|
2183
2468
|
)
|
|
2184
2469
|
] })
|
|
@@ -2186,36 +2471,36 @@ function Announcement({ props, mediaOrigin, editMode }) {
|
|
|
2186
2471
|
}
|
|
2187
2472
|
|
|
2188
2473
|
// src/basics/button.tsx
|
|
2189
|
-
var
|
|
2474
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2190
2475
|
var STYLES = ["primary", "secondary", "outline", "link"];
|
|
2191
2476
|
var SIZES = ["s", "m", "l"];
|
|
2192
2477
|
function Button({ props, mediaOrigin, inlineEdit }) {
|
|
2193
2478
|
const href = hrefOf(props.link, mediaOrigin);
|
|
2194
2479
|
const className = `tb-b-button tb-b-button--${oneOf(props.style, STYLES, "primary")} tb-b-button--${oneOf(props.size, SIZES, "m")}`;
|
|
2195
2480
|
const label = inlineEdit?.("label") ?? str(props.label) ?? "";
|
|
2196
|
-
return /* @__PURE__ */ (0,
|
|
2197
|
-
/* @__PURE__ */ (0,
|
|
2198
|
-
/* @__PURE__ */ (0,
|
|
2481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
2482
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(BasicStyles, {}),
|
|
2483
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "tb-b-button-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("a", { className, ...href === null ? {} : { href }, children: label }) })
|
|
2199
2484
|
] });
|
|
2200
2485
|
}
|
|
2201
2486
|
|
|
2202
2487
|
// src/basics/copyright.tsx
|
|
2203
2488
|
var import_ui2 = require("@usethrottle/ui");
|
|
2204
|
-
var
|
|
2205
|
-
var
|
|
2489
|
+
var import_builder_schema18 = require("@usethrottle/builder-schema");
|
|
2490
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2206
2491
|
function Copyright(_) {
|
|
2207
2492
|
const design = (0, import_ui2.useSiteDesign)();
|
|
2208
2493
|
const strings = design?.strings;
|
|
2209
2494
|
const template = strings !== void 0 && Object.hasOwn(strings, "footer.copyright") ? str(strings["footer.copyright"]) : void 0;
|
|
2210
|
-
const line = (template ??
|
|
2211
|
-
return /* @__PURE__ */ (0,
|
|
2212
|
-
/* @__PURE__ */ (0,
|
|
2213
|
-
/* @__PURE__ */ (0,
|
|
2495
|
+
const line = (template ?? import_builder_schema18.SITE_STRING_DEFAULTS["footer.copyright"]).replace("{year}", () => String((/* @__PURE__ */ new Date()).getFullYear())).replace("{store}", () => str(design?.brand?.storeName) ?? "").replace(/\s{2,}/g, " ").replace(/\s+([.,])/g, "$1");
|
|
2496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
2497
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BasicStyles, {}),
|
|
2498
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "tb-b-copyright", children: line })
|
|
2214
2499
|
] });
|
|
2215
2500
|
}
|
|
2216
2501
|
|
|
2217
2502
|
// src/basics/countdown.tsx
|
|
2218
|
-
var
|
|
2503
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2219
2504
|
var UNITS2 = [
|
|
2220
2505
|
{ key: "d", show: "showDays", label: "labelDays", seconds: 86400 },
|
|
2221
2506
|
{ key: "h", show: "showHours", label: "labelHours", seconds: 3600 },
|
|
@@ -2241,10 +2526,10 @@ function targetText(date) {
|
|
|
2241
2526
|
}
|
|
2242
2527
|
function Countdown({ props, editMode, interactive, locale }) {
|
|
2243
2528
|
void locale;
|
|
2244
|
-
const
|
|
2245
|
-
const when =
|
|
2529
|
+
const target2 = str(props.target);
|
|
2530
|
+
const when = target2 === void 0 ? null : new Date(target2);
|
|
2246
2531
|
if (when === null || Number.isNaN(when.getTime())) {
|
|
2247
|
-
return /* @__PURE__ */ (0,
|
|
2532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Placeholder, { editMode, children: "Set the date and time the countdown ends" });
|
|
2248
2533
|
}
|
|
2249
2534
|
const live = interactive !== false;
|
|
2250
2535
|
const behavior = oneOf(props.expiredBehavior, ["text", "hide"], "text");
|
|
@@ -2255,11 +2540,11 @@ function Countdown({ props, editMode, interactive, locale }) {
|
|
|
2255
2540
|
if (value !== null) left -= value * unit.seconds;
|
|
2256
2541
|
return { ...unit, text: value === null ? "--" : two(value), name: str(props[unit.label]) ?? "" };
|
|
2257
2542
|
});
|
|
2258
|
-
return /* @__PURE__ */ (0,
|
|
2259
|
-
/* @__PURE__ */ (0,
|
|
2260
|
-
/* @__PURE__ */ (0,
|
|
2261
|
-
live ? /* @__PURE__ */ (0,
|
|
2262
|
-
/* @__PURE__ */ (0,
|
|
2543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
2544
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(BasicStyles, {}),
|
|
2545
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("style", { href: "tb-countdown", precedence: "throttle", children: COUNTDOWN_CSS }),
|
|
2546
|
+
live ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(InteractionRuntime, {}) : null,
|
|
2547
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2263
2548
|
"div",
|
|
2264
2549
|
{
|
|
2265
2550
|
className: "tb-b-cd",
|
|
@@ -2267,13 +2552,13 @@ function Countdown({ props, editMode, interactive, locale }) {
|
|
|
2267
2552
|
"aria-live": "off",
|
|
2268
2553
|
...live ? { "data-b-cd": String(when.getTime()), "data-b-expired": behavior } : {},
|
|
2269
2554
|
children: [
|
|
2270
|
-
/* @__PURE__ */ (0,
|
|
2271
|
-
units.length === 0 ? null : /* @__PURE__ */ (0,
|
|
2272
|
-
/* @__PURE__ */ (0,
|
|
2273
|
-
/* @__PURE__ */ (0,
|
|
2555
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "tb-b-cd-date", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("time", { dateTime: when.toISOString(), children: targetText(when) }) }),
|
|
2556
|
+
units.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "tb-b-cd-units", children: units.map((unit) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "tb-b-cd-unit", children: [
|
|
2557
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "tb-b-cd-num", "data-u": unit.key, "aria-hidden": "true", children: unit.text }),
|
|
2558
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "tb-b-cd-label", children: unit.name })
|
|
2274
2559
|
] }, unit.key)) }),
|
|
2275
|
-
/* @__PURE__ */ (0,
|
|
2276
|
-
/* @__PURE__ */ (0,
|
|
2560
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "tb-b-cd-ended", hidden: live || when.getTime() > Date.now(), children: str(props.expiredText) ?? "" }),
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "tb-b-sr", "data-b-live": "", "aria-live": "polite" })
|
|
2277
2562
|
]
|
|
2278
2563
|
}
|
|
2279
2564
|
)
|
|
@@ -2281,30 +2566,103 @@ function Countdown({ props, editMode, interactive, locale }) {
|
|
|
2281
2566
|
}
|
|
2282
2567
|
|
|
2283
2568
|
// src/basics/divider.tsx
|
|
2284
|
-
var
|
|
2569
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2285
2570
|
var RULES = [{ key: "style", property: "--bx-style", values: { solid: "solid", dashed: "dashed", dotted: "dotted" } }];
|
|
2286
2571
|
function Divider({ node }) {
|
|
2287
|
-
return /* @__PURE__ */ (0,
|
|
2288
|
-
/* @__PURE__ */ (0,
|
|
2289
|
-
/* @__PURE__ */ (0,
|
|
2290
|
-
/* @__PURE__ */ (0,
|
|
2572
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2573
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(BasicStyles, {}),
|
|
2574
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(WidgetStyle, { css: enumCss(node, RULES) }),
|
|
2575
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("hr", { className: "tb-b-divider" })
|
|
2576
|
+
] });
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
// src/basics/v2/styles.tsx
|
|
2580
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2581
|
+
var BASICS_V2_CSS = `@layer throttle{
|
|
2582
|
+
.tb-b-faq{color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.6}
|
|
2583
|
+
.tb-b-faq-item{border-block-end:1px solid var(--tb-color-border,currentColor)}
|
|
2584
|
+
.tb-b-faq-q{margin:0;padding:var(--tb-space-s) 0;font-weight:600;cursor:pointer}
|
|
2585
|
+
h3.tb-b-faq-q{cursor:auto;font-size:inherit}
|
|
2586
|
+
.tb-b-faq-a{padding-block-end:var(--tb-space-s)}
|
|
2587
|
+
.tb-b-faq-a>:first-child{margin-block-start:0}
|
|
2588
|
+
.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}
|
|
2589
|
+
.tb-b-faq summary:focus-visible,.tb-b-faq-all:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
2590
|
+
.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}
|
|
2591
|
+
.tb-b-rich>:first-child{margin-block-start:0}
|
|
2592
|
+
.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)}
|
|
2593
|
+
.tb-b-rich table{border-collapse:collapse;max-inline-size:100%;display:block;overflow-x:auto}
|
|
2594
|
+
.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}
|
|
2595
|
+
.tb-b-rich figure{margin-inline:0}
|
|
2596
|
+
.tb-b-rich img{max-inline-size:100%;block-size:auto}
|
|
2597
|
+
.tb-b-rich pre{overflow-x:auto;padding:var(--tb-space-s);background:var(--tb-color-muted,#eee)}
|
|
2598
|
+
.tb-b-rich code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}
|
|
2599
|
+
.tb-b-rich blockquote{margin-inline:0;padding-inline-start:var(--tb-space-m);border-inline-start:3px solid var(--tb-color-border,currentColor)}
|
|
2600
|
+
.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)}
|
|
2601
|
+
.tb-b-toc-title{margin:0 0 var(--tb-space-xs);font-weight:600}
|
|
2602
|
+
.tb-b-toc ol{margin:0;padding:0;list-style:none}
|
|
2603
|
+
.tb-b-toc-l3{padding-inline-start:var(--tb-space-m)}
|
|
2604
|
+
.tb-b-toc a{color:inherit}
|
|
2605
|
+
.tb-b-svg{display:block;text-align:var(--b-align,left);color:var(--b-color,inherit);line-height:0}
|
|
2606
|
+
.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)}
|
|
2607
|
+
.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}
|
|
2608
|
+
.tb-b-icons li{display:flex;gap:var(--tb-space-s);align-items:flex-start;padding-block:var(--tb-space-xs)}
|
|
2609
|
+
.tb-b-icons-icon{flex:0 0 auto;display:inline-flex;color:var(--b-iconColor,var(--tb-color-primary,currentColor))}
|
|
2610
|
+
.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)}
|
|
2611
|
+
.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))}
|
|
2612
|
+
.tb-b-quote blockquote{margin:0;font-family:var(--throttle-font-family-heading,inherit);line-height:1.4}
|
|
2613
|
+
.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)}
|
|
2614
|
+
.tb-b-quote-photo{inline-size:48px;block-size:48px;border-radius:50%;object-fit:cover}
|
|
2615
|
+
.tb-b-quote-by{display:flex;flex-direction:column}
|
|
2616
|
+
.tb-b-quote-name{font-weight:600}
|
|
2617
|
+
.tb-b-quote-role{color:var(--tb-color-muted-foreground,inherit)}
|
|
2618
|
+
.tb-b-heading-wrap{text-align:var(--b-align,left)}
|
|
2619
|
+
.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))}
|
|
2620
|
+
.tb-b-kicker-rule{flex:0 0 auto;inline-size:2rem;block-size:1px;background:currentColor}
|
|
2621
|
+
.tb-b-crumbs{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-s))}
|
|
2622
|
+
.tb-b-crumbs ol{display:flex;flex-wrap:wrap;gap:var(--tb-space-xs);margin:0;padding:0;list-style:none}
|
|
2623
|
+
.tb-b-crumbs li{display:inline-flex;align-items:center;gap:var(--tb-space-xs)}
|
|
2624
|
+
.tb-b-crumbs a{color:inherit;text-decoration:none}
|
|
2625
|
+
.tb-b-crumbs a:hover{text-decoration:underline}
|
|
2626
|
+
.tb-b-crumbs a:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
2627
|
+
.tb-b-crumbs [aria-current]{font-weight:600}
|
|
2628
|
+
}`;
|
|
2629
|
+
function BasicV2Styles() {
|
|
2630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
2631
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BasicStyles, {}),
|
|
2632
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("style", { href: "tb-basics-v2", precedence: "throttle", children: BASICS_V2_CSS })
|
|
2291
2633
|
] });
|
|
2292
2634
|
}
|
|
2293
2635
|
|
|
2294
2636
|
// src/basics/heading.tsx
|
|
2295
|
-
var
|
|
2637
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2296
2638
|
var LEVELS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
2297
2639
|
function Heading({ props, inlineEdit }) {
|
|
2298
2640
|
const Tag = oneOf(props.level, LEVELS, "h2");
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2641
|
+
const heading = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Tag, { className: "tb-b-heading", children: inlineEdit?.("text") ?? str(props.text) ?? "" });
|
|
2642
|
+
const kicker = inlineEdit?.("kicker") ?? str(props.kicker);
|
|
2643
|
+
const rule = props.rule === true;
|
|
2644
|
+
if (kicker === void 0 && !rule) {
|
|
2645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
2646
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BasicStyles, {}),
|
|
2647
|
+
heading
|
|
2648
|
+
] });
|
|
2649
|
+
}
|
|
2650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
2651
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BasicStyles, {}),
|
|
2652
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BasicV2Styles, {}),
|
|
2653
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "tb-b-heading-wrap", children: [
|
|
2654
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("p", { className: "tb-b-kicker", children: [
|
|
2655
|
+
rule && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "tb-b-kicker-rule", "aria-hidden": "true" }),
|
|
2656
|
+
kicker
|
|
2657
|
+
] }),
|
|
2658
|
+
heading
|
|
2659
|
+
] })
|
|
2302
2660
|
] });
|
|
2303
2661
|
}
|
|
2304
2662
|
|
|
2305
2663
|
// src/basics/image.tsx
|
|
2306
|
-
var
|
|
2307
|
-
var
|
|
2664
|
+
var import_builder_schema19 = require("@usethrottle/builder-schema");
|
|
2665
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2308
2666
|
var RULES2 = [
|
|
2309
2667
|
{ key: "radius", property: "--bx-radius", values: { none: "0", s: "4px", m: "8px", l: "16px", full: "9999px" } },
|
|
2310
2668
|
{ key: "fit", property: "--bx-fit", values: { cover: "cover", contain: "contain" } }
|
|
@@ -2314,23 +2672,23 @@ function Image({ node, props, mediaOrigin, editMode }) {
|
|
|
2314
2672
|
const decorative = props.decorative === true;
|
|
2315
2673
|
const alt = decorative ? "" : typeof props.alt === "string" ? props.alt : "";
|
|
2316
2674
|
const asset = isFrozenAsset(props.image) ? props.image : void 0;
|
|
2317
|
-
const image = /* @__PURE__ */ (0,
|
|
2318
|
-
const shown2 = asset !== void 0 && (0,
|
|
2319
|
-
return /* @__PURE__ */ (0,
|
|
2320
|
-
/* @__PURE__ */ (0,
|
|
2321
|
-
/* @__PURE__ */ (0,
|
|
2322
|
-
shown2 ? /* @__PURE__ */ (0,
|
|
2675
|
+
const image = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(AssetImage, { asset, mediaOrigin, alt, className: "tb-b-img", sizes: "(max-width: 767px) 100vw, 50vw" });
|
|
2676
|
+
const shown2 = asset !== void 0 && (0, import_builder_schema19.safeUrl)(asset.url, "src", { mediaOrigin }) !== null;
|
|
2677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
2678
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(BasicStyles, {}),
|
|
2679
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(WidgetStyle, { css: enumCss(node, RULES2) }),
|
|
2680
|
+
shown2 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "tb-b-image", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "tb-b-image-box", children: href === null ? image : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("a", { href, children: image }) }) }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Placeholder, { editMode, children: asset === void 0 ? "Choose an image" : "Image unavailable" })
|
|
2323
2681
|
] });
|
|
2324
2682
|
}
|
|
2325
2683
|
|
|
2326
2684
|
// src/basics/logo.tsx
|
|
2327
2685
|
var import_ui3 = require("@usethrottle/ui");
|
|
2328
|
-
var
|
|
2329
|
-
var
|
|
2686
|
+
var import_builder_schema20 = require("@usethrottle/builder-schema");
|
|
2687
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2330
2688
|
function Logo({ props, mediaOrigin, editMode }) {
|
|
2331
2689
|
const design = (0, import_ui3.useSiteDesign)();
|
|
2332
2690
|
const scheme = design?.theme?.colorScheme ?? "auto";
|
|
2333
|
-
const src = (url) => url === void 0 ? void 0 : (0,
|
|
2691
|
+
const src = (url) => url === void 0 ? void 0 : (0, import_builder_schema20.safeUrl)(url, "src", { mediaOrigin }) ?? void 0;
|
|
2334
2692
|
const light = src(design?.brand?.logo?.light);
|
|
2335
2693
|
const dark = src(design?.brand?.logo?.dark);
|
|
2336
2694
|
const main = scheme === "dark" ? dark ?? light : light ?? dark;
|
|
@@ -2339,65 +2697,65 @@ function Logo({ props, mediaOrigin, editMode }) {
|
|
|
2339
2697
|
const alt = name ?? "";
|
|
2340
2698
|
let content = null;
|
|
2341
2699
|
if (main !== void 0) {
|
|
2342
|
-
const img = /* @__PURE__ */ (0,
|
|
2343
|
-
content = scheme === "auto" && light !== void 0 && dark !== void 0 ? /* @__PURE__ */ (0,
|
|
2344
|
-
/* @__PURE__ */ (0,
|
|
2700
|
+
const img = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("img", { src: main, alt, decoding: "async" });
|
|
2701
|
+
content = scheme === "auto" && light !== void 0 && dark !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("picture", { children: [
|
|
2702
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("source", { media: "(prefers-color-scheme: dark)", srcSet: dark }),
|
|
2345
2703
|
img
|
|
2346
2704
|
] }) : img;
|
|
2347
2705
|
} else if (name !== void 0) {
|
|
2348
|
-
content = /* @__PURE__ */ (0,
|
|
2706
|
+
content = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "tb-b-logo-name", children: name });
|
|
2349
2707
|
}
|
|
2350
|
-
return /* @__PURE__ */ (0,
|
|
2351
|
-
/* @__PURE__ */ (0,
|
|
2352
|
-
content === null ? /* @__PURE__ */ (0,
|
|
2708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
2709
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(BasicStyles, {}),
|
|
2710
|
+
content === null ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Placeholder, { editMode, children: "Logo: add one in Site settings" }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "tb-b-logo", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { href, children: content }) })
|
|
2353
2711
|
] });
|
|
2354
2712
|
}
|
|
2355
2713
|
|
|
2356
2714
|
// src/basics/menu.tsx
|
|
2357
|
-
var
|
|
2715
|
+
var import_react15 = require("react");
|
|
2358
2716
|
var import_ui4 = require("@usethrottle/ui");
|
|
2359
|
-
var
|
|
2360
|
-
var
|
|
2717
|
+
var import_builder_schema21 = require("@usethrottle/builder-schema");
|
|
2718
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2361
2719
|
var LAYOUTS = ["horizontal", "vertical", "drawer-on-phone"];
|
|
2362
2720
|
var MAX_DEPTH2 = 3;
|
|
2363
2721
|
function List({ items, mediaOrigin, depth = 0, id, onNavigate }) {
|
|
2364
2722
|
const shown2 = items.flatMap((item) => {
|
|
2365
|
-
const href = (0,
|
|
2723
|
+
const href = (0, import_builder_schema21.safeUrl)(item.href, "href", { mediaOrigin });
|
|
2366
2724
|
return href === null ? [] : [{ item, href }];
|
|
2367
2725
|
});
|
|
2368
2726
|
if (shown2.length === 0) return null;
|
|
2369
|
-
return /* @__PURE__ */ (0,
|
|
2370
|
-
/* @__PURE__ */ (0,
|
|
2371
|
-
depth + 1 < MAX_DEPTH2 && item.children !== void 0 && /* @__PURE__ */ (0,
|
|
2727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("ul", { ...id === void 0 ? {} : { id }, ...onNavigate === void 0 ? {} : { onClick: onNavigate }, children: shown2.map(({ item, href }, index) => /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("li", { children: [
|
|
2728
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("a", { href, children: item.label }),
|
|
2729
|
+
depth + 1 < MAX_DEPTH2 && item.children !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(List, { items: item.children, mediaOrigin, depth: depth + 1 })
|
|
2372
2730
|
] }, `${String(index)}:${href}`)) });
|
|
2373
2731
|
}
|
|
2374
2732
|
function Menu({ props, mediaOrigin, editMode }) {
|
|
2375
2733
|
const design = (0, import_ui4.useSiteDesign)();
|
|
2376
|
-
const listId = (0,
|
|
2377
|
-
const toggle = (0,
|
|
2378
|
-
const [open,
|
|
2734
|
+
const listId = (0, import_react15.useId)();
|
|
2735
|
+
const toggle = (0, import_react15.useRef)(null);
|
|
2736
|
+
const [open, setOpen2] = (0, import_react15.useState)(false);
|
|
2379
2737
|
const name = str(props.menu) ?? "header";
|
|
2380
2738
|
const layout = oneOf(props.layout, LAYOUTS, "horizontal");
|
|
2381
2739
|
const menus = design?.menus;
|
|
2382
2740
|
const items = menus !== void 0 && Object.hasOwn(menus, name) ? menus[name] : void 0;
|
|
2383
2741
|
const strings = design?.strings;
|
|
2384
|
-
const label = (strings !== void 0 && Object.hasOwn(strings, "nav.menu") ? str(strings["nav.menu"]) : void 0) ??
|
|
2742
|
+
const label = (strings !== void 0 && Object.hasOwn(strings, "nav.menu") ? str(strings["nav.menu"]) : void 0) ?? import_builder_schema21.SITE_STRING_DEFAULTS["nav.menu"];
|
|
2385
2743
|
if (items === void 0 || items.length === 0) {
|
|
2386
|
-
return /* @__PURE__ */ (0,
|
|
2387
|
-
/* @__PURE__ */ (0,
|
|
2388
|
-
/* @__PURE__ */ (0,
|
|
2744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
2745
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(BasicStyles, {}),
|
|
2746
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Placeholder, { editMode, children: `Menu "${name}" is empty: add links in Site settings` })
|
|
2389
2747
|
] });
|
|
2390
2748
|
}
|
|
2391
2749
|
const drawer = layout === "drawer-on-phone";
|
|
2392
2750
|
const onKeyDown = (event) => {
|
|
2393
2751
|
if (event.key === "Escape" && open) {
|
|
2394
|
-
|
|
2752
|
+
setOpen2(false);
|
|
2395
2753
|
toggle.current?.focus();
|
|
2396
2754
|
}
|
|
2397
2755
|
};
|
|
2398
|
-
return /* @__PURE__ */ (0,
|
|
2399
|
-
/* @__PURE__ */ (0,
|
|
2400
|
-
/* @__PURE__ */ (0,
|
|
2756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
2757
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(BasicStyles, {}),
|
|
2758
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
2401
2759
|
"nav",
|
|
2402
2760
|
{
|
|
2403
2761
|
className: `tb-b-menu tb-b-menu--${layout}${layout === "vertical" ? "" : " tb-b-menu--h"}`,
|
|
@@ -2405,7 +2763,7 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
2405
2763
|
"data-open": drawer ? String(open) : void 0,
|
|
2406
2764
|
onKeyDown: drawer ? onKeyDown : void 0,
|
|
2407
2765
|
children: [
|
|
2408
|
-
drawer && /* @__PURE__ */ (0,
|
|
2766
|
+
drawer && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2409
2767
|
"button",
|
|
2410
2768
|
{
|
|
2411
2769
|
ref: toggle,
|
|
@@ -2413,11 +2771,11 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
2413
2771
|
className: "tb-b-menu-toggle",
|
|
2414
2772
|
"aria-expanded": open,
|
|
2415
2773
|
"aria-controls": listId,
|
|
2416
|
-
onClick: () =>
|
|
2417
|
-
children: /* @__PURE__ */ (0,
|
|
2774
|
+
onClick: () => setOpen2((value) => !value),
|
|
2775
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_ui4.Icon, { name: open ? "close" : "menu", size: 24, label })
|
|
2418
2776
|
}
|
|
2419
2777
|
),
|
|
2420
|
-
/* @__PURE__ */ (0,
|
|
2778
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(List, { items, mediaOrigin, id: listId, ...drawer ? { onNavigate: () => setOpen2(false) } : {} })
|
|
2421
2779
|
]
|
|
2422
2780
|
}
|
|
2423
2781
|
)
|
|
@@ -2425,18 +2783,18 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
2425
2783
|
}
|
|
2426
2784
|
|
|
2427
2785
|
// src/basics/spacer.tsx
|
|
2428
|
-
var
|
|
2786
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2429
2787
|
function Spacer() {
|
|
2430
|
-
return /* @__PURE__ */ (0,
|
|
2431
|
-
/* @__PURE__ */ (0,
|
|
2432
|
-
/* @__PURE__ */ (0,
|
|
2788
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
|
|
2789
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(BasicStyles, {}),
|
|
2790
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "tb-b-spacer", "aria-hidden": "true" })
|
|
2433
2791
|
] });
|
|
2434
2792
|
}
|
|
2435
2793
|
|
|
2436
2794
|
// src/basics/rich-text.tsx
|
|
2437
|
-
var
|
|
2438
|
-
var
|
|
2439
|
-
var
|
|
2795
|
+
var import_react16 = require("react");
|
|
2796
|
+
var import_builder_schema22 = require("@usethrottle/builder-schema");
|
|
2797
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
2440
2798
|
var ALLOWED = /* @__PURE__ */ new Set(["p", "br", "strong", "em", "u", "s", "a", "ul", "ol", "li", "h2", "h3", "h4", "blockquote", "code"]);
|
|
2441
2799
|
var ALIAS = { b: "strong", i: "em", strike: "s", del: "s" };
|
|
2442
2800
|
var DROP_WITH_CONTENT = /* @__PURE__ */ new Set([
|
|
@@ -2595,17 +2953,17 @@ function parseRichText(source, mediaOrigin) {
|
|
|
2595
2953
|
}
|
|
2596
2954
|
}
|
|
2597
2955
|
if (name === "li") {
|
|
2598
|
-
let
|
|
2599
|
-
while (
|
|
2600
|
-
if (
|
|
2601
|
-
if (
|
|
2602
|
-
stack.length =
|
|
2956
|
+
let list2 = stack.length - 1;
|
|
2957
|
+
while (list2 > 0 && stack[list2].tag !== "ul" && stack[list2].tag !== "ol") list2 -= 1;
|
|
2958
|
+
if (list2 === 0) list2 = -1;
|
|
2959
|
+
if (list2 === -1) continue;
|
|
2960
|
+
stack.length = list2 + 1;
|
|
2603
2961
|
}
|
|
2604
2962
|
if (name === "a") closeTo("a");
|
|
2605
2963
|
const el = { tag: name, children: [] };
|
|
2606
2964
|
if (name === "a") {
|
|
2607
2965
|
const href = tag.attrs.get("href");
|
|
2608
|
-
el.href = href === void 0 ? null : (0,
|
|
2966
|
+
el.href = href === void 0 ? null : (0, import_builder_schema22.safeUrl)(decode(href).trim(), "href", { mediaOrigin });
|
|
2609
2967
|
}
|
|
2610
2968
|
nodes += 1;
|
|
2611
2969
|
top().children.push(el);
|
|
@@ -2616,12 +2974,12 @@ function parseRichText(source, mediaOrigin) {
|
|
|
2616
2974
|
}
|
|
2617
2975
|
function toReact(el, key) {
|
|
2618
2976
|
const children = el.children.map((child, index) => typeof child === "string" ? child : toReact(child, index));
|
|
2619
|
-
if (el.tag === "br") return /* @__PURE__ */ (0,
|
|
2977
|
+
if (el.tag === "br") return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("br", {}, key);
|
|
2620
2978
|
if (el.tag === "a") {
|
|
2621
|
-
if (el.href === null || el.href === void 0) return /* @__PURE__ */ (0,
|
|
2622
|
-
return /* @__PURE__ */ (0,
|
|
2979
|
+
if (el.href === null || el.href === void 0) return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react16.Fragment, { children }, key);
|
|
2980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("a", { href: el.href, rel: "noopener noreferrer", className: "tb-b-link", children }, key);
|
|
2623
2981
|
}
|
|
2624
|
-
return (0,
|
|
2982
|
+
return (0, import_react16.createElement)(el.tag, { key }, ...children);
|
|
2625
2983
|
}
|
|
2626
2984
|
function RichText({
|
|
2627
2985
|
html,
|
|
@@ -2630,26 +2988,26 @@ function RichText({
|
|
|
2630
2988
|
editMode = false
|
|
2631
2989
|
}) {
|
|
2632
2990
|
const tree = parseRichText(html, mediaOrigin);
|
|
2633
|
-
return /* @__PURE__ */ (0,
|
|
2991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className, children: [
|
|
2634
2992
|
tree.children.map((child, index) => typeof child === "string" ? child : toReact(child, index)),
|
|
2635
|
-
editMode && tree.truncated === true && /* @__PURE__ */ (0,
|
|
2993
|
+
editMode && tree.truncated === true && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("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." })
|
|
2636
2994
|
] });
|
|
2637
2995
|
}
|
|
2638
2996
|
|
|
2639
2997
|
// src/basics/text.tsx
|
|
2640
|
-
var
|
|
2998
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
2641
2999
|
function Text({ props, mediaOrigin, editMode, inlineEdit }) {
|
|
2642
3000
|
const editor = inlineEdit?.("html") ?? null;
|
|
2643
|
-
return /* @__PURE__ */ (0,
|
|
2644
|
-
/* @__PURE__ */ (0,
|
|
2645
|
-
editor === null ? /* @__PURE__ */ (0,
|
|
3001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
|
|
3002
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(BasicStyles, {}),
|
|
3003
|
+
editor === null ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(RichText, { html: str(props.html) ?? "", mediaOrigin, className: "tb-b-text", editMode }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "tb-b-text", children: editor })
|
|
2646
3004
|
] });
|
|
2647
3005
|
}
|
|
2648
3006
|
|
|
2649
3007
|
// src/basics/video.tsx
|
|
2650
|
-
var
|
|
3008
|
+
var import_react17 = require("react");
|
|
2651
3009
|
var import_ui5 = require("@usethrottle/ui");
|
|
2652
|
-
var
|
|
3010
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2653
3011
|
var RULES3 = [
|
|
2654
3012
|
{ key: "ratio", property: "--bx-ratio", values: { "16:9": "16 / 9", "4:3": "4 / 3", "1:1": "1 / 1", "9:16": "9 / 16" } }
|
|
2655
3013
|
];
|
|
@@ -2666,7 +3024,7 @@ function parseVideoUrl(input) {
|
|
|
2666
3024
|
}
|
|
2667
3025
|
if (url.protocol !== "https:" || url.username !== "" || url.password !== "" || url.port !== "" && url.port !== "443") return null;
|
|
2668
3026
|
const host = url.hostname.toLowerCase();
|
|
2669
|
-
const parts = url.pathname.split("/").filter((
|
|
3027
|
+
const parts = url.pathname.split("/").filter((part2) => part2 !== "");
|
|
2670
3028
|
if (host === "youtu.be") {
|
|
2671
3029
|
const id = parts[0];
|
|
2672
3030
|
return parts.length === 1 && id !== void 0 && YOUTUBE_ID.test(id) ? { provider: "youtube", id } : null;
|
|
@@ -2689,12 +3047,12 @@ function embedSrc(video, muted) {
|
|
|
2689
3047
|
return video.provider === "youtube" ? `https://www.youtube-nocookie.com/embed/${video.id}?autoplay=1&rel=0&playsinline=1${muted ? "&mute=1" : ""}` : `https://player.vimeo.com/video/${video.id}?autoplay=1&dnt=1${muted ? "&muted=1" : ""}`;
|
|
2690
3048
|
}
|
|
2691
3049
|
function Video({ node, props, editMode }) {
|
|
2692
|
-
const [loaded, setLoaded] = (0,
|
|
3050
|
+
const [loaded, setLoaded] = (0, import_react17.useState)(false);
|
|
2693
3051
|
const video = parseVideoUrl(str(props.url) ?? "");
|
|
2694
|
-
return /* @__PURE__ */ (0,
|
|
2695
|
-
/* @__PURE__ */ (0,
|
|
2696
|
-
/* @__PURE__ */ (0,
|
|
2697
|
-
video === null ? /* @__PURE__ */ (0,
|
|
3052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
3053
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(BasicStyles, {}),
|
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(WidgetStyle, { css: enumCss(node, RULES3) }),
|
|
3055
|
+
video === null ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Placeholder, { editMode, children: "Paste a YouTube or Vimeo link" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "tb-b-video", "data-provider": video.provider, children: loaded && !editMode ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
2698
3056
|
"iframe",
|
|
2699
3057
|
{
|
|
2700
3058
|
src: embedSrc(video, props.autoplayMuted === true),
|
|
@@ -2703,47 +3061,1474 @@ function Video({ node, props, editMode }) {
|
|
|
2703
3061
|
referrerPolicy: "strict-origin-when-cross-origin",
|
|
2704
3062
|
sandbox: "allow-scripts allow-same-origin allow-presentation allow-popups"
|
|
2705
3063
|
}
|
|
2706
|
-
) : /* @__PURE__ */ (0,
|
|
3064
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("button", { type: "button", className: "tb-b-play", "aria-label": "Play video", onClick: () => setLoaded(true), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_ui5.Icon, { name: "play", size: 28 }) }) }) })
|
|
2707
3065
|
] });
|
|
2708
3066
|
}
|
|
2709
3067
|
|
|
2710
3068
|
// src/basics/v2/announcement-v2.tsx
|
|
2711
|
-
var
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
var breadcrumbsWidgets = [];
|
|
2715
|
-
|
|
2716
|
-
// src/basics/v2/faq.tsx
|
|
2717
|
-
var faqWidgets = [];
|
|
2718
|
-
|
|
2719
|
-
// src/basics/v2/icon-list.tsx
|
|
2720
|
-
var iconListWidgets = [];
|
|
3069
|
+
var import_react19 = require("react");
|
|
3070
|
+
var import_ui7 = require("@usethrottle/ui");
|
|
3071
|
+
var import_builder_schema25 = require("@usethrottle/builder-schema");
|
|
2721
3072
|
|
|
2722
|
-
// src/
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
3073
|
+
// src/theme.ts
|
|
3074
|
+
var import_builder_schema23 = require("@usethrottle/builder-schema");
|
|
3075
|
+
var import_presets = require("@usethrottle/ui/presets");
|
|
3076
|
+
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3077
|
+
var str2 = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
3078
|
+
var HEX = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
3079
|
+
var SCALE = { compact: 0.85, comfortable: 1, roomy: 1.25 };
|
|
3080
|
+
var PALETTE_KEYS = Object.keys(import_presets.PRESET_TOKENS.clean.light);
|
|
3081
|
+
function palette(base, over) {
|
|
3082
|
+
if (!isRecord5(over)) return base;
|
|
3083
|
+
const out = { ...base };
|
|
3084
|
+
for (const key of PALETTE_KEYS) {
|
|
3085
|
+
const value = over[key];
|
|
3086
|
+
if (typeof value === "string" && HEX.test(value)) out[key] = value;
|
|
2728
3087
|
}
|
|
2729
|
-
|
|
2730
|
-
return [
|
|
2731
|
-
...v1.map((widget) => replacement.get(widget.type) ?? widget),
|
|
2732
|
-
...[...replacement.values()].filter((widget) => !v1Types.has(widget.type))
|
|
2733
|
-
];
|
|
3088
|
+
return out;
|
|
2734
3089
|
}
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
3090
|
+
function themeTokens(settings) {
|
|
3091
|
+
const theme = isRecord5(settings.theme) ? settings.theme : {};
|
|
3092
|
+
const preset = import_presets.PRESET_NAMES.includes(theme.preset) ? theme.preset : "clean";
|
|
3093
|
+
const customized = theme.customized === true;
|
|
3094
|
+
const base = import_presets.PRESET_TOKENS[preset];
|
|
3095
|
+
const colorScheme = theme.colorScheme === "light" || theme.colorScheme === "dark" ? theme.colorScheme : "auto";
|
|
3096
|
+
if (!customized) return { preset, customized, tokens: base, colorScheme };
|
|
3097
|
+
const fonts = isRecord5(theme.fonts) ? theme.fonts : {};
|
|
3098
|
+
return {
|
|
3099
|
+
preset,
|
|
3100
|
+
customized,
|
|
3101
|
+
colorScheme,
|
|
3102
|
+
tokens: {
|
|
3103
|
+
light: palette(base.light, theme.light),
|
|
3104
|
+
dark: palette(base.dark, theme.dark),
|
|
3105
|
+
fonts: {
|
|
3106
|
+
heading: str2(fonts.heading) ?? base.fonts.heading,
|
|
3107
|
+
body: str2(fonts.body) ?? base.fonts.body,
|
|
3108
|
+
mono: str2(fonts.mono) ?? base.fonts.mono
|
|
3109
|
+
},
|
|
3110
|
+
radius: typeof theme.radius === "number" && theme.radius >= 0 && theme.radius <= 32 ? theme.radius : base.radius,
|
|
3111
|
+
spacingScale: theme.spacingScale === "compact" || theme.spacingScale === "roomy" ? theme.spacingScale : base.spacingScale
|
|
3112
|
+
}
|
|
3113
|
+
};
|
|
3114
|
+
}
|
|
3115
|
+
var GENERIC = { serif: "serif", sans: "sans-serif", mono: "monospace", display: "sans-serif" };
|
|
3116
|
+
var SYSTEM_STACK = {
|
|
3117
|
+
"system-sans": 'system-ui, -apple-system, "Segoe UI", sans-serif',
|
|
3118
|
+
"system-serif": 'Georgia, "Times New Roman", serif',
|
|
3119
|
+
"system-mono": "ui-monospace, SFMono-Regular, Menlo, monospace"
|
|
3120
|
+
};
|
|
3121
|
+
function fontStack(family) {
|
|
3122
|
+
if (Object.hasOwn(SYSTEM_STACK, family)) return SYSTEM_STACK[family];
|
|
3123
|
+
const known = import_builder_schema23.SITE_FONTS.find((f) => f.family === family);
|
|
3124
|
+
if (known === void 0 || !/^[A-Za-z0-9 ]{1,60}$/.test(family)) return SYSTEM_STACK["system-sans"];
|
|
3125
|
+
return `"${family}", ${Object.hasOwn(GENERIC, known.category) ? GENERIC[known.category] : "sans-serif"}`;
|
|
3126
|
+
}
|
|
3127
|
+
function variables(p) {
|
|
3128
|
+
return {
|
|
3129
|
+
colorPrimary: p.colorPrimary,
|
|
3130
|
+
colorPrimaryForeground: p.colorPrimaryForeground,
|
|
3131
|
+
colorBackground: p.colorBackground,
|
|
3132
|
+
colorSurface: p.colorSurface,
|
|
3133
|
+
colorForeground: p.colorForeground,
|
|
3134
|
+
colorMuted: p.colorMuted,
|
|
3135
|
+
colorMutedForeground: p.colorMutedForeground,
|
|
3136
|
+
colorBorder: p.colorBorder,
|
|
3137
|
+
colorBorderControl: p.colorBorderControl,
|
|
3138
|
+
colorSuccess: p.colorSuccess,
|
|
3139
|
+
colorWarning: p.colorWarning,
|
|
3140
|
+
colorDanger: p.colorDanger
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
function appearanceOf(settings) {
|
|
3144
|
+
const { tokens, colorScheme } = themeTokens(settings);
|
|
3145
|
+
return {
|
|
3146
|
+
theme: colorScheme,
|
|
3147
|
+
variables: {
|
|
3148
|
+
...variables(tokens.light),
|
|
3149
|
+
fontFamily: fontStack(tokens.fonts.body),
|
|
3150
|
+
borderRadius: `${String(tokens.radius)}px`
|
|
3151
|
+
},
|
|
3152
|
+
darkVariables: variables(tokens.dark)
|
|
3153
|
+
};
|
|
3154
|
+
}
|
|
3155
|
+
var kebab = (key) => key.replace(/^color/, "").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/^([A-Z])/, (c) => c.toLowerCase()).toLowerCase();
|
|
3156
|
+
function colourDecls(p) {
|
|
3157
|
+
return PALETTE_KEYS.map((key) => `--tb-color-${kebab(key)}:${p[key]}`).join(";");
|
|
3158
|
+
}
|
|
3159
|
+
function themeCss(settings, options = {}) {
|
|
3160
|
+
const { tokens, colorScheme } = themeTokens(settings);
|
|
3161
|
+
const heading = options.hostFont === true ? "" : `--throttle-font-family-heading:${fontStack(tokens.fonts.heading)};`;
|
|
3162
|
+
const light = `:root{--tb-scale:${String(SCALE[tokens.spacingScale])};${heading}${colourDecls(tokens.light)}}`;
|
|
3163
|
+
const dark = colourDecls(tokens.dark);
|
|
3164
|
+
if (colorScheme === "light") return light;
|
|
3165
|
+
if (colorScheme === "dark") return `${light}:root{${dark}}`;
|
|
3166
|
+
return `${light}@media (prefers-color-scheme:dark){:root{${dark}}}`;
|
|
3167
|
+
}
|
|
3168
|
+
function customCssOf(settings, mediaOrigin = "") {
|
|
3169
|
+
const theme = isRecord5(settings.theme) ? settings.theme : {};
|
|
3170
|
+
const css = theme.customCss;
|
|
3171
|
+
if (typeof css !== "string" || css.trim() === "") return "";
|
|
3172
|
+
return (0, import_builder_schema23.sanitizeSiteCss)(css, { mediaOrigin }).css;
|
|
3173
|
+
}
|
|
3174
|
+
var CUSTOM_CSS_INLINE_MAX_BYTES = 4096;
|
|
3175
|
+
function customCssDeliveryOf(settings, answerTheme, mediaOrigin = "") {
|
|
3176
|
+
const theme = isRecord5(settings.theme) ? settings.theme : {};
|
|
3177
|
+
const raw = typeof theme.customCss === "string" ? theme.customCss : "";
|
|
3178
|
+
const candidate = isRecord5(answerTheme) ? answerTheme.customCssHref : void 0;
|
|
3179
|
+
const href = typeof candidate === "string" && /^https:\/\/[^\s/\\]+\/[^\s\\]*$/iu.test(candidate) && (0, import_builder_schema23.safeUrl)(candidate, "href", { mediaOrigin: "" }) !== null && new URL(candidate).pathname.includes("/v1/css/") ? candidate : void 0;
|
|
3180
|
+
const inline2 = customCssOf(settings, mediaOrigin);
|
|
3181
|
+
const small = new TextEncoder().encode(inline2).length <= CUSTOM_CSS_INLINE_MAX_BYTES;
|
|
3182
|
+
if (href !== void 0 && raw.trim() === "") return { inline: "", href };
|
|
3183
|
+
if (href !== void 0 && inline2 !== "" && !small) return { inline: "", href };
|
|
3184
|
+
return { inline: inline2 };
|
|
3185
|
+
}
|
|
3186
|
+
function customCssSheet(css) {
|
|
3187
|
+
return css === "" ? "" : `@layer throttle,throttle-custom;@layer throttle-custom{${css}}`;
|
|
3188
|
+
}
|
|
3189
|
+
function makeResolveLink(settings, packs) {
|
|
3190
|
+
const routes = isRecord5(settings.routes) ? settings.routes : {};
|
|
3191
|
+
const pageRoute = str2(routes.page) ?? "/pages/{handle}";
|
|
3192
|
+
return (target2) => {
|
|
3193
|
+
for (const pack of packs) {
|
|
3194
|
+
const href = pack.linkTargets?.resolve(target2) ?? null;
|
|
3195
|
+
if (href !== null) return (0, import_builder_schema23.safeUrl)(href, "href", { mediaOrigin: "" });
|
|
3196
|
+
}
|
|
3197
|
+
if (target2.kind === "url") return (0, import_builder_schema23.safeUrl)(target2.href, "href", { mediaOrigin: "" });
|
|
3198
|
+
if (typeof target2.href === "string") return (0, import_builder_schema23.safeUrl)(target2.href, "href", { mediaOrigin: "" });
|
|
3199
|
+
if (target2.kind === "page") {
|
|
3200
|
+
const slug2 = str2(target2.slug) ?? str2(target2.handle);
|
|
3201
|
+
if (slug2 !== void 0 && /^[A-Za-z0-9._~-]{1,200}$/.test(slug2)) {
|
|
3202
|
+
return (0, import_builder_schema23.safeUrl)(pageRoute.replace("{handle}", slug2), "href", { mediaOrigin: "" });
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
return null;
|
|
3206
|
+
};
|
|
3207
|
+
}
|
|
3208
|
+
var MENU_KINDS = /* @__PURE__ */ new Set(["category", "collection", "product", "page", "search", "url"]);
|
|
3209
|
+
function menuItems(items, resolve, depth = 0) {
|
|
3210
|
+
if (!Array.isArray(items) || depth > 3) return [];
|
|
3211
|
+
const out = [];
|
|
3212
|
+
for (const item of items) {
|
|
3213
|
+
if (!isRecord5(item) || !isRecord5(item.target) || typeof item.target.kind !== "string") continue;
|
|
3214
|
+
const label = str2(item.label);
|
|
3215
|
+
const href = resolve(item.target);
|
|
3216
|
+
if (label === void 0 || href === null) continue;
|
|
3217
|
+
const kind = MENU_KINDS.has(item.target.kind) ? item.target.kind : void 0;
|
|
3218
|
+
const children = menuItems(item.children, resolve, depth + 1);
|
|
3219
|
+
out.push({
|
|
3220
|
+
label,
|
|
3221
|
+
href,
|
|
3222
|
+
...kind === void 0 ? {} : { kind },
|
|
3223
|
+
...children.length === 0 ? {} : { children }
|
|
3224
|
+
});
|
|
3225
|
+
}
|
|
3226
|
+
return out;
|
|
3227
|
+
}
|
|
3228
|
+
function localizedText(v, locale) {
|
|
3229
|
+
if (!isRecord5(v)) return str2(v);
|
|
3230
|
+
if (locale !== void 0 && Object.prototype.hasOwnProperty.call(v, locale)) {
|
|
3231
|
+
const own = str2(v[locale]);
|
|
3232
|
+
if (own !== void 0) return own;
|
|
3233
|
+
}
|
|
3234
|
+
return Object.values(v).map(str2).find((s) => s !== void 0);
|
|
3235
|
+
}
|
|
3236
|
+
var DEVICES4 = ["desktop", "tablet", "phone"];
|
|
3237
|
+
function normalizeMessages(messages) {
|
|
3238
|
+
const out = [];
|
|
3239
|
+
messages.forEach((m, index) => {
|
|
3240
|
+
if (!isRecord5(m)) return;
|
|
3241
|
+
const pages = isRecord5(m.pages) ? m.pages : {};
|
|
3242
|
+
out.push({
|
|
3243
|
+
...m,
|
|
3244
|
+
id: str2(m.id) ?? `m${String(index)}`,
|
|
3245
|
+
target: isRecord5(m.target) ? m.target : null,
|
|
3246
|
+
startsAt: str2(m.startsAt) ?? null,
|
|
3247
|
+
endsAt: str2(m.endsAt) ?? null,
|
|
3248
|
+
audience: m.audience === "guest" || m.audience === "signed-in" ? m.audience : "all",
|
|
3249
|
+
devices: Array.isArray(m.devices) ? m.devices.filter((d) => DEVICES4.some((x) => x === d)) : [...DEVICES4],
|
|
3250
|
+
pages: {
|
|
3251
|
+
mode: pages.mode === "include" || pages.mode === "exclude" ? pages.mode : "all",
|
|
3252
|
+
list: Array.isArray(pages.list) ? pages.list.filter((p) => typeof p === "string") : []
|
|
3253
|
+
}
|
|
3254
|
+
});
|
|
3255
|
+
});
|
|
3256
|
+
return out;
|
|
3257
|
+
}
|
|
3258
|
+
function eligibleOnAnyDevice(messages, now, audience, page) {
|
|
3259
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3260
|
+
for (const device of DEVICES4) for (const m of (0, import_builder_schema23.eligibleMessages)(messages, { now, device, audience, page })) ids.add(m.id);
|
|
3261
|
+
return messages.filter((m) => ids.has(m.id));
|
|
3262
|
+
}
|
|
3263
|
+
function serverMessages(messages, now, page) {
|
|
3264
|
+
return eligibleOnAnyDevice(messages, now, "all", page);
|
|
3265
|
+
}
|
|
3266
|
+
var assetUrl = (v, mediaOrigin) => {
|
|
3267
|
+
const raw = typeof v === "string" ? v : isRecord5(v) ? v.url : void 0;
|
|
3268
|
+
return typeof raw === "string" ? (0, import_builder_schema23.safeUrl)(raw, "src", { mediaOrigin }) ?? void 0 : void 0;
|
|
3269
|
+
};
|
|
3270
|
+
function partClassesOf(settings) {
|
|
3271
|
+
const theme = isRecord5(settings.theme) ? settings.theme : {};
|
|
3272
|
+
const advanced = isRecord5(theme.advanced) ? theme.advanced : {};
|
|
3273
|
+
if (!isRecord5(advanced.partClasses)) return {};
|
|
3274
|
+
const entries2 = Object.entries(advanced.partClasses).filter((e) => typeof e[1] === "string" && e[1] !== "");
|
|
3275
|
+
return entries2.length === 0 ? {} : { partClasses: Object.fromEntries(entries2) };
|
|
3276
|
+
}
|
|
3277
|
+
function siteDesignOf(settings, resolve, pageOutlet, mediaOrigin, locale, now = Date.now()) {
|
|
3278
|
+
const { preset, customized, tokens, colorScheme } = themeTokens(settings);
|
|
3279
|
+
const brand = isRecord5(settings.brand) ? settings.brand : {};
|
|
3280
|
+
const logo = isRecord5(brand.logo) ? brand.logo : {};
|
|
3281
|
+
const light = assetUrl(logo.light, mediaOrigin);
|
|
3282
|
+
const dark = assetUrl(logo.dark, mediaOrigin);
|
|
3283
|
+
const favicon = assetUrl(brand.favicon, mediaOrigin);
|
|
3284
|
+
const menus = isRecord5(settings.menus) ? Object.fromEntries(Object.entries(settings.menus).map(([name, items]) => [name, menuItems(items, resolve)])) : {};
|
|
3285
|
+
const rawAnnouncement = isRecord5(settings.announcement) ? settings.announcement : null;
|
|
3286
|
+
const messages = rawAnnouncement !== null && Array.isArray(rawAnnouncement.messages) ? rawAnnouncement.messages : null;
|
|
3287
|
+
const currentMessage = messages === null ? null : serverMessages(normalizeMessages(messages), now, {})[0] ?? null;
|
|
3288
|
+
const announcement = rawAnnouncement === null || messages === null ? rawAnnouncement : { ...rawAnnouncement, message: currentMessage?.text, target: currentMessage?.target };
|
|
3289
|
+
const message = announcement === null ? void 0 : localizedText(announcement.message, locale);
|
|
3290
|
+
const announcementHref = announcement !== null && isRecord5(announcement.target) && typeof announcement.target.kind === "string" ? resolve(announcement.target) : null;
|
|
3291
|
+
const strings = isRecord5(settings.strings) ? Object.fromEntries(Object.entries(settings.strings).filter((entry) => typeof entry[1] === "string")) : {};
|
|
3292
|
+
const seo = isRecord5(settings.seo) ? settings.seo : {};
|
|
3293
|
+
const routes = isRecord5(settings.routes) ? settings.routes : {};
|
|
3294
|
+
const connections = isRecord5(settings.connections) ? settings.connections : {};
|
|
3295
|
+
const shareImage = assetUrl(seo.shareImage, mediaOrigin);
|
|
3296
|
+
const titleTemplate = str2(seo.titleTemplate);
|
|
3297
|
+
const defaultDescription = str2(seo.defaultDescription);
|
|
3298
|
+
const pageRoute = str2(routes.page);
|
|
3299
|
+
return {
|
|
3300
|
+
source: "builder",
|
|
3301
|
+
theme: { preset, customized, colorScheme, ...customized ? { values: tokens } : {}, ...partClassesOf(settings) },
|
|
3302
|
+
brand: {
|
|
3303
|
+
...str2(brand.storeName) === void 0 ? {} : { storeName: str2(brand.storeName) },
|
|
3304
|
+
logo: light === void 0 && dark === void 0 ? null : { ...light === void 0 ? {} : { light }, ...dark === void 0 ? {} : { dark } },
|
|
3305
|
+
favicon: favicon ?? null
|
|
3306
|
+
},
|
|
3307
|
+
menus,
|
|
3308
|
+
announcement: announcement !== null && announcement.enabled === true && message !== void 0 ? { message, ...announcementHref === null ? {} : { href: announcementHref } } : null,
|
|
3309
|
+
strings,
|
|
3310
|
+
seo: {
|
|
3311
|
+
...titleTemplate === void 0 ? {} : { titleTemplate },
|
|
3312
|
+
...defaultDescription === void 0 ? {} : { defaultDescription },
|
|
3313
|
+
...shareImage === void 0 ? {} : { shareImage }
|
|
3314
|
+
},
|
|
3315
|
+
...pageRoute === void 0 ? {} : { routes: { page: pageRoute } },
|
|
3316
|
+
connections: {
|
|
3317
|
+
throttlePublishableKey: typeof connections.throttlePublishableKey === "string" ? connections.throttlePublishableKey : null
|
|
3318
|
+
},
|
|
3319
|
+
...pageOutlet === void 0 ? {} : { pageOutlet }
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
// src/basics/v2/menu-v2.tsx
|
|
3324
|
+
var import_react18 = require("react");
|
|
3325
|
+
var import_ui6 = require("@usethrottle/ui");
|
|
3326
|
+
var import_builder_schema24 = require("@usethrottle/builder-schema");
|
|
3327
|
+
|
|
3328
|
+
// src/interactions/menu-runtime.ts
|
|
3329
|
+
var holds3 = 0;
|
|
3330
|
+
var release2;
|
|
3331
|
+
var ITEM = "[data-tb-i]";
|
|
3332
|
+
var hovers = () => window.matchMedia?.("(hover:none)").matches !== true;
|
|
3333
|
+
function toggleOf(item) {
|
|
3334
|
+
return item.querySelector(":scope > [data-tb-t]");
|
|
3335
|
+
}
|
|
3336
|
+
function setItem(item, open) {
|
|
3337
|
+
if (open) item.setAttribute("data-open", "true");
|
|
3338
|
+
else item.removeAttribute("data-open");
|
|
3339
|
+
toggleOf(item)?.setAttribute("aria-expanded", String(open));
|
|
3340
|
+
item.querySelector(":scope > [data-nav-panel]")?.toggleAttribute("hidden", !open);
|
|
3341
|
+
}
|
|
3342
|
+
function closeOthers(keep) {
|
|
3343
|
+
for (const item of document.querySelectorAll(`${ITEM}[data-open]`)) {
|
|
3344
|
+
if (keep === null || !item.contains(keep)) setItem(item, false);
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
var NAV_TOP = "[data-nav-top]";
|
|
3348
|
+
var PANEL = "[data-nav-panel]";
|
|
3349
|
+
function navKey(event, el) {
|
|
3350
|
+
const entry = el.closest(NAV_TOP);
|
|
3351
|
+
if (entry === null) return false;
|
|
3352
|
+
const focus = (links, at2) => links[(at2 + links.length) % links.length]?.focus();
|
|
3353
|
+
const top = entry.querySelector(":scope > a");
|
|
3354
|
+
if (event.key === "Escape" && entry.hasAttribute("data-open")) {
|
|
3355
|
+
event.preventDefault();
|
|
3356
|
+
setItem(entry, false);
|
|
3357
|
+
top?.focus();
|
|
3358
|
+
return true;
|
|
3359
|
+
}
|
|
3360
|
+
const panel = el.closest(PANEL);
|
|
3361
|
+
if (panel !== null) {
|
|
3362
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return false;
|
|
3363
|
+
event.preventDefault();
|
|
3364
|
+
const links = [...panel.querySelectorAll("a")];
|
|
3365
|
+
focus(links, links.indexOf(el) + (event.key === "ArrowDown" ? 1 : -1));
|
|
3366
|
+
return true;
|
|
3367
|
+
}
|
|
3368
|
+
if (el !== top) return false;
|
|
3369
|
+
const list2 = entry.parentElement;
|
|
3370
|
+
const tops = [...list2?.querySelectorAll(":scope > li > a") ?? []];
|
|
3371
|
+
const at = tops.indexOf(el);
|
|
3372
|
+
const rtl = list2 !== null && getComputedStyle(list2).direction === "rtl";
|
|
3373
|
+
const forward = rtl ? "ArrowLeft" : "ArrowRight";
|
|
3374
|
+
const back = rtl ? "ArrowRight" : "ArrowLeft";
|
|
3375
|
+
if (event.key === forward || event.key === back) focus(tops, at + (event.key === forward ? 1 : -1));
|
|
3376
|
+
else if (event.key === "Home") focus(tops, 0);
|
|
3377
|
+
else if (event.key === "End") focus(tops, -1);
|
|
3378
|
+
else if (event.key === "ArrowDown" && entry.querySelector(":scope > " + PANEL) !== null) {
|
|
3379
|
+
if (!entry.hasAttribute("data-open")) setItem(entry, true);
|
|
3380
|
+
entry.querySelector(":scope > " + PANEL + " a")?.focus();
|
|
3381
|
+
} else return false;
|
|
3382
|
+
event.preventDefault();
|
|
3383
|
+
return true;
|
|
3384
|
+
}
|
|
3385
|
+
var drawerToggle = (nav) => nav.querySelector(":scope > [data-tb-drawer]");
|
|
3386
|
+
function setDrawer(nav, open) {
|
|
3387
|
+
nav.setAttribute("data-open", String(open));
|
|
3388
|
+
drawerToggle(nav)?.setAttribute("aria-expanded", String(open));
|
|
3389
|
+
const list2 = nav.querySelector(":scope > ul");
|
|
3390
|
+
if (list2 === null) return;
|
|
3391
|
+
if (open) {
|
|
3392
|
+
list2.setAttribute("role", "dialog");
|
|
3393
|
+
list2.setAttribute("aria-modal", "true");
|
|
3394
|
+
const label = nav.getAttribute("aria-label");
|
|
3395
|
+
if (label !== null) list2.setAttribute("aria-label", label);
|
|
3396
|
+
focusablesOf(list2)[0]?.focus();
|
|
3397
|
+
} else {
|
|
3398
|
+
list2.removeAttribute("role");
|
|
3399
|
+
list2.removeAttribute("aria-modal");
|
|
3400
|
+
list2.removeAttribute("aria-label");
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
var target = (event) => event.target instanceof Element ? event.target : null;
|
|
3404
|
+
function install2() {
|
|
3405
|
+
const over = (event) => {
|
|
3406
|
+
const el = target(event);
|
|
3407
|
+
if (el === null || !hovers()) return;
|
|
3408
|
+
closeOthers(el);
|
|
3409
|
+
for (let item = el.closest(ITEM); item !== null; item = item.parentElement?.closest(ITEM) ?? null) setItem(item, true);
|
|
3410
|
+
};
|
|
3411
|
+
const out = (event) => {
|
|
3412
|
+
if (!hovers()) return;
|
|
3413
|
+
const to = event.relatedTarget instanceof Node ? event.relatedTarget : null;
|
|
3414
|
+
closeOthers(to);
|
|
3415
|
+
};
|
|
3416
|
+
const focusin = (event) => {
|
|
3417
|
+
const el = target(event);
|
|
3418
|
+
if (el === null) return;
|
|
3419
|
+
closeOthers(el);
|
|
3420
|
+
if (el.closest("[data-tb-t]") !== null || el.closest(NAV_TOP) !== null) return;
|
|
3421
|
+
for (let item = el.closest(ITEM); item !== null; item = item.parentElement?.closest(ITEM) ?? null) setItem(item, true);
|
|
3422
|
+
};
|
|
3423
|
+
const click = (event) => {
|
|
3424
|
+
const el = target(event);
|
|
3425
|
+
if (el === null) return;
|
|
3426
|
+
const opener = el.closest("[data-tb-drawer]");
|
|
3427
|
+
if (opener !== null) {
|
|
3428
|
+
const nav2 = opener.closest("nav");
|
|
3429
|
+
if (nav2 !== null) setDrawer(nav2, nav2.getAttribute("data-open") !== "true");
|
|
3430
|
+
return;
|
|
3431
|
+
}
|
|
3432
|
+
const toggle = el.closest("[data-tb-t]");
|
|
3433
|
+
const item = toggle?.closest(ITEM) ?? null;
|
|
3434
|
+
if (item !== null) {
|
|
3435
|
+
closeOthers(item);
|
|
3436
|
+
setItem(item, item.getAttribute("data-open") !== "true");
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
closeOthers(el);
|
|
3440
|
+
const nav = el.closest("nav[data-open=true]");
|
|
3441
|
+
if (nav !== null && el.closest("a") !== null) setDrawer(nav, false);
|
|
3442
|
+
};
|
|
3443
|
+
const keydown = (event) => {
|
|
3444
|
+
const el = target(event);
|
|
3445
|
+
const drawer = document.querySelector("nav[data-open=true]");
|
|
3446
|
+
if (event.key === "Tab" && drawer !== null) {
|
|
3447
|
+
const toggle = drawerToggle(drawer);
|
|
3448
|
+
const list2 = drawer.querySelector(":scope > ul");
|
|
3449
|
+
if (list2 !== null) trapTab(event, [...toggle === null ? [] : [toggle], ...focusablesOf(list2)]);
|
|
3450
|
+
return;
|
|
3451
|
+
}
|
|
3452
|
+
if (drawer === null && el !== null && navKey(event, el)) return;
|
|
3453
|
+
if (event.key !== "Escape") return;
|
|
3454
|
+
if (drawer !== null) {
|
|
3455
|
+
closeOthers(null);
|
|
3456
|
+
setDrawer(drawer, false);
|
|
3457
|
+
drawerToggle(drawer)?.focus();
|
|
3458
|
+
return;
|
|
3459
|
+
}
|
|
3460
|
+
const open = document.querySelector(`${ITEM}[data-open]`);
|
|
3461
|
+
if (open !== null) {
|
|
3462
|
+
const focusInside = el !== null && open.contains(el);
|
|
3463
|
+
const back = toggleOf(open);
|
|
3464
|
+
closeOthers(null);
|
|
3465
|
+
if (focusInside) back?.focus();
|
|
3466
|
+
}
|
|
3467
|
+
};
|
|
3468
|
+
document.addEventListener("mouseover", over);
|
|
3469
|
+
document.addEventListener("mouseout", out);
|
|
3470
|
+
document.addEventListener("focusin", focusin);
|
|
3471
|
+
document.addEventListener("click", click);
|
|
3472
|
+
document.addEventListener("keydown", keydown);
|
|
3473
|
+
return () => {
|
|
3474
|
+
document.removeEventListener("mouseover", over);
|
|
3475
|
+
document.removeEventListener("mouseout", out);
|
|
3476
|
+
document.removeEventListener("focusin", focusin);
|
|
3477
|
+
document.removeEventListener("click", click);
|
|
3478
|
+
document.removeEventListener("keydown", keydown);
|
|
3479
|
+
};
|
|
3480
|
+
}
|
|
3481
|
+
function startMenuRuntime() {
|
|
3482
|
+
if (holds3++ === 0) release2 = install2();
|
|
3483
|
+
let done = false;
|
|
3484
|
+
return () => {
|
|
3485
|
+
if (done) return;
|
|
3486
|
+
done = true;
|
|
3487
|
+
if (--holds3 === 0) {
|
|
3488
|
+
release2?.();
|
|
3489
|
+
release2 = void 0;
|
|
3490
|
+
}
|
|
3491
|
+
};
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3494
|
+
// src/basics/v2/menu-v2.tsx
|
|
3495
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3496
|
+
var MODES = ["horizontal", "vertical", "drawer", "mega"];
|
|
3497
|
+
var MAX_LEVEL = 3;
|
|
3498
|
+
var CLASS_RE = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;
|
|
3499
|
+
var SUBMENU_DEFAULT = "Show submenu for {label}";
|
|
3500
|
+
function localized(value, locale) {
|
|
3501
|
+
if (!isRecord4(value)) return str(value);
|
|
3502
|
+
for (const key of [locale, "en"]) {
|
|
3503
|
+
if (Object.hasOwn(value, key)) {
|
|
3504
|
+
const own = str(value[key]);
|
|
3505
|
+
if (own !== void 0) return own;
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
return Object.values(value).map(str).find((s) => s !== void 0);
|
|
3509
|
+
}
|
|
3510
|
+
function makeLink(builder, own, mediaOrigin) {
|
|
3511
|
+
const targets = builder?.linkTargets;
|
|
3512
|
+
const fallback = own ?? builder?.resolveLink;
|
|
3513
|
+
return (target2) => {
|
|
3514
|
+
if (target2.kind === "url") return (0, import_builder_schema24.safeUrl)(target2.href, "href", { mediaOrigin });
|
|
3515
|
+
if (targets !== void 0 && typeof target2.id === "string") {
|
|
3516
|
+
const key = `${String(target2.kind)}:${target2.id}`;
|
|
3517
|
+
if (Object.hasOwn(targets, key)) {
|
|
3518
|
+
const known = targets[key];
|
|
3519
|
+
return typeof known === "string" ? (0, import_builder_schema24.safeUrl)(known, "href", { mediaOrigin }) : null;
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
const raw = fallback?.(target2) ?? null;
|
|
3523
|
+
return raw === null ? null : (0, import_builder_schema24.safeUrl)(raw, "href", { mediaOrigin });
|
|
3524
|
+
};
|
|
3525
|
+
}
|
|
3526
|
+
function megaOf(value, locale) {
|
|
3527
|
+
if (!isRecord4(value) || value.enabled !== true) return void 0;
|
|
3528
|
+
const columns = typeof value.columns === "number" ? Math.min(6, Math.max(2, Math.round(value.columns))) : 3;
|
|
3529
|
+
const f = value.featured;
|
|
3530
|
+
let featured = null;
|
|
3531
|
+
if (isRecord4(f) && f.kind === "section" && typeof f.id === "string") featured = { kind: "section", id: f.id };
|
|
3532
|
+
else if (isRecord4(f) && f.kind === "image" && typeof f.asset === "string") {
|
|
3533
|
+
featured = { kind: "image", asset: f.asset, link: isRecord4(f.link) ? f.link : null, caption: localized(f.caption, locale) ?? "" };
|
|
3534
|
+
}
|
|
3535
|
+
return { columns, featured };
|
|
3536
|
+
}
|
|
3537
|
+
function build(raw, level, b) {
|
|
3538
|
+
if (!Array.isArray(raw)) return [];
|
|
3539
|
+
const out = [];
|
|
3540
|
+
raw.forEach((entry, index) => {
|
|
3541
|
+
if (!isRecord4(entry) || !isRecord4(entry.target)) return;
|
|
3542
|
+
const target2 = entry.target;
|
|
3543
|
+
const label = localized(entry.label, b.r.locale);
|
|
3544
|
+
if (label === void 0) return;
|
|
3545
|
+
out.push({
|
|
3546
|
+
key: typeof entry.id === "string" ? entry.id : String(index),
|
|
3547
|
+
label,
|
|
3548
|
+
href: target2.kind === "category" && typeof entry.url === "string" ? (0, import_builder_schema24.safeUrl)(entry.url, "href", { mediaOrigin: b.r.mediaOrigin }) : b.r.link(target2),
|
|
3549
|
+
newTab: entry.newTab === true,
|
|
3550
|
+
classes: Array.isArray(entry.cssClass) ? entry.cssClass.filter((c) => typeof c === "string" && CLASS_RE.test(c)) : [],
|
|
3551
|
+
description: localized(entry.description, b.r.locale),
|
|
3552
|
+
badge: localized(entry.badge, b.r.locale),
|
|
3553
|
+
// Mega is only for a top-level item of the header menu, in mega mode.
|
|
3554
|
+
mega: b.mega && level === 1 && b.menu === "header" ? megaOf(entry.mega, b.r.locale) : void 0,
|
|
3555
|
+
children: level < MAX_LEVEL ? build(entry.children, level + 1, b) : [],
|
|
3556
|
+
...target2.kind === "category" && typeof entry.handle === "string" ? { handle: entry.handle } : {}
|
|
3557
|
+
});
|
|
3558
|
+
});
|
|
3559
|
+
return out;
|
|
3560
|
+
}
|
|
3561
|
+
function fromDesign(items, level, r) {
|
|
3562
|
+
return items.map((item, index) => ({
|
|
3563
|
+
key: String(index),
|
|
3564
|
+
label: item.label,
|
|
3565
|
+
href: (0, import_builder_schema24.safeUrl)(item.href, "href", { mediaOrigin: r.mediaOrigin }),
|
|
3566
|
+
newTab: false,
|
|
3567
|
+
classes: [],
|
|
3568
|
+
description: void 0,
|
|
3569
|
+
badge: void 0,
|
|
3570
|
+
mega: void 0,
|
|
3571
|
+
children: level < MAX_LEVEL && item.children !== void 0 ? fromDesign(item.children, level + 1, r) : []
|
|
3572
|
+
}));
|
|
3573
|
+
}
|
|
3574
|
+
function Anchor({ item }) {
|
|
3575
|
+
return item.href === null ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "tb-mm-text", children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("a", { href: item.href, ...item.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}, children: item.label });
|
|
3576
|
+
}
|
|
3577
|
+
var Extras = ({ item, describe }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
3578
|
+
item.badge === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "tb-mm-badge", children: item.badge }),
|
|
3579
|
+
describe && item.description !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "tb-mm-desc", children: item.description }) : null
|
|
3580
|
+
] });
|
|
3581
|
+
function FeaturedPanel({ featured, label, ctx }) {
|
|
3582
|
+
const { builder, props } = ctx;
|
|
3583
|
+
const site = builder?.site;
|
|
3584
|
+
if (builder === null || site === void 0 || site.status !== "ok") return null;
|
|
3585
|
+
const parts = [site.header, site.footer];
|
|
3586
|
+
if (featured.kind === "section") {
|
|
3587
|
+
let answer;
|
|
3588
|
+
for (const part2 of parts) {
|
|
3589
|
+
const all2 = part2.savedSections;
|
|
3590
|
+
if (answer === void 0 && all2 !== void 0 && Object.hasOwn(all2, featured.id)) answer = all2[featured.id];
|
|
3591
|
+
}
|
|
3592
|
+
const parsed2 = answer === void 0 ? null : import_builder_schema24.sectionNodeSchema.safeParse(answer.section);
|
|
3593
|
+
if (answer === void 0 || parsed2 === null || !parsed2.success) return null;
|
|
3594
|
+
const assets = { ...site.footer.assets, ...site.header.assets };
|
|
3595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "tb-mm-feat", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3596
|
+
BuilderRenderer,
|
|
3597
|
+
{
|
|
3598
|
+
document: { schemaVersion: 1, sections: [parsed2.data] },
|
|
3599
|
+
registry: builder.registry,
|
|
3600
|
+
data: {},
|
|
3601
|
+
locale: props.locale,
|
|
3602
|
+
assets,
|
|
3603
|
+
mediaOrigin: props.mediaOrigin,
|
|
3604
|
+
interactive: props.interactive,
|
|
3605
|
+
resolveLink: props.resolveLink ?? builder.resolveLink
|
|
3606
|
+
}
|
|
3607
|
+
) });
|
|
3608
|
+
}
|
|
3609
|
+
let asset;
|
|
3610
|
+
for (const part2 of parts) {
|
|
3611
|
+
if (asset === void 0 && Object.hasOwn(part2.assets, featured.asset)) asset = part2.assets[featured.asset];
|
|
3612
|
+
}
|
|
3613
|
+
if (!isFrozenAsset(asset)) return null;
|
|
3614
|
+
const href = featured.link === null ? null : makeLink(builder, props.resolveLink, props.mediaOrigin)(featured.link);
|
|
3615
|
+
const image = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(AssetImage, { asset, mediaOrigin: props.mediaOrigin, alt: href === null ? featured.caption : featured.caption || label });
|
|
3616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("figure", { className: "tb-mm-feat", children: [
|
|
3617
|
+
href === null ? image : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("a", { href, children: image }),
|
|
3618
|
+
featured.caption === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("figcaption", { children: featured.caption })
|
|
3619
|
+
] });
|
|
3620
|
+
}
|
|
3621
|
+
function List2({ items, top, ctx }) {
|
|
3622
|
+
if (items.length === 0) return null;
|
|
3623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("ul", { ...top === void 0 ? { className: "tb-mm-sub" } : { id: top.id, className: "tb-mm-list" }, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Entry, { item, level: top === void 0 ? 2 : 1, ctx }, item.key)) });
|
|
3624
|
+
}
|
|
3625
|
+
function Entry({ item, level, ctx }) {
|
|
3626
|
+
const hasPanel = item.mega !== void 0 && (item.children.length > 0 || item.mega.featured !== null);
|
|
3627
|
+
const sub = item.children.length > 0 || hasPanel;
|
|
3628
|
+
const toggle = sub && level === 1 && ctx.mode !== "vertical";
|
|
3629
|
+
const cls = ["tb-mm-i", ...item.classes].join(" ");
|
|
3630
|
+
const subId = `${ctx.listId}-${item.key.replace(/[^A-Za-z0-9_-]/g, "_")}`;
|
|
3631
|
+
let below = null;
|
|
3632
|
+
if (hasPanel && item.mega !== void 0) {
|
|
3633
|
+
below = /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { id: subId, className: "tb-mm-panel", style: { "--tb-mm-cols": item.mega.columns }, children: [
|
|
3634
|
+
item.children.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("ul", { className: "tb-mm-cols", children: item.children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("li", { className: "tb-mm-col", children: [
|
|
3635
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Anchor, { item: child }),
|
|
3636
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Extras, { item: child, describe: true }),
|
|
3637
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(List2, { items: child.children, ctx })
|
|
3638
|
+
] }, child.key)) }),
|
|
3639
|
+
item.mega.featured === null ? null : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(FeaturedPanel, { featured: item.mega.featured, label: item.label, ctx })
|
|
3640
|
+
] });
|
|
3641
|
+
} else if (sub) {
|
|
3642
|
+
below = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("ul", { id: subId, className: "tb-mm-sub", children: item.children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Entry, { item: child, level: 2, ctx }, child.key)) });
|
|
3643
|
+
}
|
|
3644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("li", { className: cls, ...sub && level === 1 ? { "data-tb-i": "" } : {}, children: [
|
|
3645
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Anchor, { item }),
|
|
3646
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Extras, { item, describe: false }),
|
|
3647
|
+
toggle ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3648
|
+
"button",
|
|
3649
|
+
{
|
|
3650
|
+
type: "button",
|
|
3651
|
+
className: "tb-mm-t",
|
|
3652
|
+
"data-tb-t": "",
|
|
3653
|
+
"aria-expanded": "false",
|
|
3654
|
+
"aria-controls": subId,
|
|
3655
|
+
"aria-label": ctx.submenu.replace("{label}", () => item.label),
|
|
3656
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("svg", { viewBox: "0 0 24 24", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "M6 9l6 6 6-6", fill: "none", stroke: "currentColor", strokeWidth: "2" }) })
|
|
3657
|
+
}
|
|
3658
|
+
) : null,
|
|
3659
|
+
below
|
|
3660
|
+
] });
|
|
3661
|
+
}
|
|
3662
|
+
function MenuRuntime() {
|
|
3663
|
+
(0, import_react18.useEffect)(() => startMenuRuntime(), []);
|
|
3664
|
+
return null;
|
|
3665
|
+
}
|
|
3666
|
+
var part = (key, extra) => ({
|
|
3667
|
+
className: [`tsf-${key}`, extra].filter(Boolean).join(" "),
|
|
3668
|
+
"data-throttle-part": key
|
|
3669
|
+
});
|
|
3670
|
+
function StorefrontNav({ items, label, listId, ctx, className, menu }) {
|
|
3671
|
+
const categories = items.some((item) => item.handle !== void 0);
|
|
3672
|
+
const handle = (item, parent) => item.handle === void 0 ? {} : { "data-category-handle": item.handle, ...categories ? { "data-category-parent": parent } : {} };
|
|
3673
|
+
const link = (item) => item.href === null ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { ...part("category-nav-link", "tb-mm-text"), children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("a", { ...part("category-nav-link"), href: item.href, ...item.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}, children: item.label });
|
|
3674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("nav", { ...part("category-nav", className), "aria-label": label, ...categories ? {} : { "data-menu": menu }, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("ul", { ...part("category-nav-list"), children: items.map((item) => {
|
|
3675
|
+
const sub = item.children.length > 0;
|
|
3676
|
+
const panelId = `${listId}-${item.key.replace(/[^A-Za-z0-9_-]/g, "_")}`;
|
|
3677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("li", { ...part("category-nav-item", item.classes.join(" ")), "data-nav-top": "", ...sub ? { "data-tb-i": "" } : {}, ...handle(item, ""), children: [
|
|
3678
|
+
link(item),
|
|
3679
|
+
sub ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3680
|
+
"button",
|
|
3681
|
+
{
|
|
3682
|
+
type: "button",
|
|
3683
|
+
...part("category-nav-toggle"),
|
|
3684
|
+
"data-tb-t": "",
|
|
3685
|
+
"aria-expanded": "false",
|
|
3686
|
+
"aria-controls": panelId,
|
|
3687
|
+
"aria-label": ctx.submenu.replace("{label}", () => item.label),
|
|
3688
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_ui6.Icon, { name: "chevron-down", size: 14 })
|
|
3689
|
+
}
|
|
3690
|
+
) : null,
|
|
3691
|
+
sub ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("ul", { ...part("category-nav-panel"), id: panelId, "data-nav-panel": "", hidden: true, children: item.children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("li", { ...part("category-nav-child", child.classes.join(" ")), ...handle(child, item.handle ?? ""), children: link(child) }, child.key)) }) : null
|
|
3692
|
+
] }, item.key);
|
|
3693
|
+
}) }) });
|
|
3694
|
+
}
|
|
3695
|
+
function Nav({ items, label, listId, ctx, className, menu }) {
|
|
3696
|
+
if (ctx.variant === "storefront") return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(StorefrontNav, { items, label, listId, ctx, menu, ...className === void 0 ? {} : { className } });
|
|
3697
|
+
const full = { ...ctx, listId };
|
|
3698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("nav", { className: `tb-mm tb-mm--${ctx.mode}${className === void 0 ? "" : ` ${className}`}`, "aria-label": label, children: [
|
|
3699
|
+
ctx.mode === "drawer" && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("button", { type: "button", className: "tb-mm-drawer", "data-tb-drawer": "", "aria-expanded": "false", "aria-controls": listId, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_ui6.Icon, { name: "menu", size: 24, label }) }),
|
|
3700
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(List2, { items, top: { id: listId }, ctx: full })
|
|
3701
|
+
] });
|
|
3702
|
+
}
|
|
3703
|
+
function MenuV2(props) {
|
|
3704
|
+
const { props: settings, data, mediaOrigin, editMode, locale } = props;
|
|
3705
|
+
const builder = useBuilder();
|
|
3706
|
+
const design = (0, import_ui6.useSiteDesign)();
|
|
3707
|
+
const listId = (0, import_react18.useId)();
|
|
3708
|
+
const mobileId = (0, import_react18.useId)();
|
|
3709
|
+
const name = str(settings.menu) ?? "header";
|
|
3710
|
+
const mode = oneOf(settings.mode, MODES, "horizontal");
|
|
3711
|
+
const r = { mediaOrigin, locale, link: makeLink(builder, props.resolveLink, mediaOrigin) };
|
|
3712
|
+
const categories = Array.isArray(data.categories) ? data.categories : [];
|
|
3713
|
+
const forMenu = (menu, raw) => build((0, import_builder_schema24.expandMenu)(Array.isArray(raw) ? raw : [], categories).menu, 1, { r, menu, mega: mode === "mega" });
|
|
3714
|
+
let items = [];
|
|
3715
|
+
let mobile = [];
|
|
3716
|
+
const site = builder?.site;
|
|
3717
|
+
const menus = site?.status === "ok" && isRecord4(site.settings.menus) ? site.settings.menus : void 0;
|
|
3718
|
+
if (menus !== void 0) {
|
|
3719
|
+
items = Object.hasOwn(menus, name) ? forMenu(name, menus[name]) : [];
|
|
3720
|
+
if (name === "header" && Object.hasOwn(menus, "mobile")) mobile = forMenu("mobile", menus.mobile);
|
|
3721
|
+
} else if (design?.menus !== void 0 && Object.hasOwn(design.menus, name)) {
|
|
3722
|
+
items = fromDesign(design.menus[name] ?? [], 1, r);
|
|
3723
|
+
}
|
|
3724
|
+
const word = (key, fallback) => {
|
|
3725
|
+
for (const strings of [site?.status === "ok" ? site.settings.strings : void 0, design?.strings]) {
|
|
3726
|
+
if (isRecord4(strings) && Object.hasOwn(strings, key) && str(strings[key]) !== void 0) return strings[key];
|
|
3727
|
+
}
|
|
3728
|
+
return fallback;
|
|
3729
|
+
};
|
|
3730
|
+
const label = word("nav.menu", import_builder_schema24.SITE_STRING_DEFAULTS["nav.menu"]);
|
|
3731
|
+
if (items.length === 0 && mobile.length === 0) {
|
|
3732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
3733
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(BasicStyles, {}),
|
|
3734
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Placeholder, { editMode, children: `Menu "${name}" is empty: add links in Site settings` })
|
|
3735
|
+
] });
|
|
3736
|
+
}
|
|
3737
|
+
const ctx = { builder, props, mode, variant: oneOf(settings.variant, ["default", "storefront"], "default"), submenu: word("nav.submenu", SUBMENU_DEFAULT) };
|
|
3738
|
+
const nameOf = (menu) => menu === "header" ? label : `${label} (${menu})`;
|
|
3739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
3740
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(BasicStyles, {}),
|
|
3741
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("style", { href: "tb-menu-v2", precedence: "throttle", children: MENU_V2_CSS }),
|
|
3742
|
+
items.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Nav, { items, menu: name, label: nameOf(name), listId, ctx, ...mobile.length > 0 ? { className: "tb-mm-hide-phone" } : {} }),
|
|
3743
|
+
mobile.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Nav, { items: mobile, menu: "mobile", label: nameOf("mobile"), listId: mobileId, ctx, className: "tb-mm-only-phone" }),
|
|
3744
|
+
props.interactive === false ? null : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(MenuRuntime, {})
|
|
3745
|
+
] });
|
|
3746
|
+
}
|
|
3747
|
+
var MENU_V2_CSS = `@layer throttle{
|
|
3748
|
+
.tb-mm{position:relative;color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));text-align:var(--b-align,start)}
|
|
3749
|
+
.tb-mm ul{margin:0;padding:0;list-style:none}
|
|
3750
|
+
.tb-mm li{position:relative;min-inline-size:0}
|
|
3751
|
+
.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}
|
|
3752
|
+
.tb-mm a:hover{text-decoration:underline}
|
|
3753
|
+
.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}
|
|
3754
|
+
.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)}
|
|
3755
|
+
.tb-mm-desc{display:block;padding-inline:var(--tb-space-s);font-size:.85em;opacity:.75;overflow-wrap:anywhere}
|
|
3756
|
+
.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}
|
|
3757
|
+
.tb-mm-t svg{transition:transform .15s}
|
|
3758
|
+
.tb-mm-i[data-open]>.tb-mm-t svg{transform:rotate(180deg)}
|
|
3759
|
+
.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}
|
|
3760
|
+
.tb-mm-only-phone{display:none}
|
|
3761
|
+
.tb-mm--horizontal>ul,.tb-mm--drawer>ul,.tb-mm--mega>ul{display:flex;flex-wrap:wrap;align-items:center}
|
|
3762
|
+
.tb-mm--horizontal>ul>li,.tb-mm--drawer>ul>li,.tb-mm--mega>ul>li{display:inline-flex;align-items:center}
|
|
3763
|
+
.tb-mm-sub,.tb-mm-panel{display:none}
|
|
3764
|
+
.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)}
|
|
3765
|
+
.tb-mm-sub .tb-mm-sub{position:static;min-inline-size:0;padding:0;padding-inline-start:var(--tb-space-m);border:0}
|
|
3766
|
+
.tb-mm-sub>li{display:block}
|
|
3767
|
+
.tb-mm-i[data-open]>.tb-mm-sub{display:block}
|
|
3768
|
+
.tb-mm-sub .tb-mm-sub{display:block}
|
|
3769
|
+
.tb-mm--vertical .tb-mm-t{display:none}
|
|
3770
|
+
.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}
|
|
3771
|
+
.tb-mm--mega>ul>li{position:static}
|
|
3772
|
+
.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)}
|
|
3773
|
+
.tb-mm-i[data-open]>.tb-mm-panel{display:flex;gap:var(--tb-space-m)}
|
|
3774
|
+
.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}
|
|
3775
|
+
.tb-mm-col>.tb-mm-sub{display:block;position:static;min-inline-size:0;padding:0;border:0}
|
|
3776
|
+
.tb-mm-feat{flex:0 1 16rem;min-inline-size:0;margin:0}
|
|
3777
|
+
.tb-mm-feat img{display:block;max-inline-size:100%;block-size:auto}
|
|
3778
|
+
@media (max-width:767.98px){
|
|
3779
|
+
.tb-mm-hide-phone{display:none}
|
|
3780
|
+
.tb-mm-only-phone{display:block}
|
|
3781
|
+
.tb-mm--mega>ul{display:block}
|
|
3782
|
+
.tb-mm--mega>ul>li{display:flex;flex-wrap:wrap;align-items:center}
|
|
3783
|
+
.tb-mm--mega>ul>li>a,.tb-mm--mega>ul>li>.tb-mm-text{flex:1 1 0}
|
|
3784
|
+
.tb-mm--mega>ul>li>.tb-mm-sub,.tb-mm--mega>ul>li>.tb-mm-panel{flex:1 0 100%}
|
|
3785
|
+
.tb-mm-panel{position:static;inset:auto;border:0;padding:0;background:transparent}
|
|
3786
|
+
.tb-mm-cols{display:block}
|
|
3787
|
+
.tb-mm-feat{display:none}
|
|
3788
|
+
.tb-mm--mega>ul>li>.tb-mm-panel{position:static;border:0;padding:0}
|
|
3789
|
+
.tb-mm-i>.tb-mm-sub{position:static;min-inline-size:0;border:0;padding:0;padding-inline-start:var(--tb-space-m)}
|
|
3790
|
+
.tb-mm--drawer>.tb-mm-drawer{display:inline-flex;position:relative;z-index:61}
|
|
3791
|
+
.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)}
|
|
3792
|
+
.tb-mm--drawer>ul{display:none}
|
|
3793
|
+
.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)}
|
|
3794
|
+
.tb-mm--drawer[data-open=true]>ul>li{display:flex;flex-wrap:wrap}
|
|
3795
|
+
.tb-mm--drawer[data-open=true] .tb-mm-sub{display:block;position:static;border:0}
|
|
3796
|
+
}
|
|
3797
|
+
@media (scripting: none){
|
|
3798
|
+
.tb-mm-t{display:none}
|
|
3799
|
+
.tb-mm-i:hover>.tb-mm-sub,.tb-mm-i:focus-within>.tb-mm-sub{display:block}
|
|
3800
|
+
.tb-mm-i:hover>.tb-mm-panel,.tb-mm-i:focus-within>.tb-mm-panel{display:flex;gap:var(--tb-space-m)}
|
|
3801
|
+
@media (max-width:767.98px){
|
|
3802
|
+
.tb-mm-sub,.tb-mm-panel{display:block}
|
|
3803
|
+
.tb-mm--drawer>.tb-mm-drawer{display:none}
|
|
3804
|
+
.tb-mm--drawer>ul{display:block}
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3807
|
+
}`;
|
|
3808
|
+
var definition = import_builder_schema24.MB_BASIC_WIDGET_DEFINITIONS.find((d) => d.type === "basic.menu" && d.v === 2);
|
|
3809
|
+
if (definition === void 0) throw new Error("builder-schema has no basic.menu v2 definition");
|
|
3810
|
+
var menuV2Widgets = [{ ...definition, Component: MenuV2 }];
|
|
3811
|
+
|
|
3812
|
+
// src/basics/v2/announcement-v2.tsx
|
|
3813
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3814
|
+
var DEVICES5 = ["desktop", "tablet", "phone"];
|
|
3815
|
+
var DISMISS_PREFIX = "tb-an-dismissed:";
|
|
3816
|
+
var COLOR_HEX = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
3817
|
+
var COLOR_TOKEN2 = /^token:([a-z][a-z-]{0,30})$/;
|
|
3818
|
+
var REDUCED = "(prefers-reduced-motion: reduce)";
|
|
3819
|
+
function readDismissed(ids) {
|
|
3820
|
+
const out = [];
|
|
3821
|
+
for (const id of ids) {
|
|
3822
|
+
try {
|
|
3823
|
+
if (window.localStorage.getItem(`${DISMISS_PREFIX}${id}`) === "1") out.push(id);
|
|
3824
|
+
} catch {
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
return out;
|
|
3828
|
+
}
|
|
3829
|
+
function writeDismissed(id) {
|
|
3830
|
+
try {
|
|
3831
|
+
window.localStorage.setItem(`${DISMISS_PREFIX}${id}`, "1");
|
|
3832
|
+
} catch {
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
var matches = (query) => window.matchMedia?.(query).matches === true;
|
|
3836
|
+
function deviceNow() {
|
|
3837
|
+
return matches("(max-width:767.98px)") ? "phone" : matches("(max-width:1024.98px)") ? "tablet" : "desktop";
|
|
3838
|
+
}
|
|
3839
|
+
function colorOf(value) {
|
|
3840
|
+
if (typeof value !== "string") return void 0;
|
|
3841
|
+
if (COLOR_HEX.test(value)) return value;
|
|
3842
|
+
const token = COLOR_TOKEN2.exec(value);
|
|
3843
|
+
return token === null ? void 0 : `var(--tb-color-${token[1]})`;
|
|
3844
|
+
}
|
|
3845
|
+
var textOf = (tree) => tree.children.map((child) => typeof child === "string" ? child : textOf(child)).join("");
|
|
3846
|
+
function inline(children) {
|
|
3847
|
+
return children.map((child, index) => {
|
|
3848
|
+
if (typeof child === "string") return child;
|
|
3849
|
+
const inner = inline(child.children);
|
|
3850
|
+
if (child.tag === "strong" || child.tag === "em") return (0, import_react19.createElement)(child.tag, { key: index }, ...inner);
|
|
3851
|
+
if (child.tag === "a" && typeof child.href === "string") {
|
|
3852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("a", { href: child.href, rel: "noopener noreferrer", children: inner }, index);
|
|
3853
|
+
}
|
|
3854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react19.Fragment, { children: inner }, index);
|
|
3855
|
+
});
|
|
3856
|
+
}
|
|
3857
|
+
function MessageText({ message, locale, mediaOrigin, href }) {
|
|
3858
|
+
const tree = parseRichText(localized(message.text, locale) ?? "", mediaOrigin);
|
|
3859
|
+
if (href !== null) return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("a", { href, children: textOf(tree) });
|
|
3860
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "tb-an-text", children: inline(tree.children) });
|
|
3861
|
+
}
|
|
3862
|
+
function pageOf2(builder) {
|
|
3863
|
+
const given = builder?.page;
|
|
3864
|
+
if (given !== void 0) return given;
|
|
3865
|
+
return { home: builder?.pathname === "/" };
|
|
3866
|
+
}
|
|
3867
|
+
function audienceOf(ready, viewer) {
|
|
3868
|
+
if (!ready || viewer === null || viewer?.signedIn === null) return "all";
|
|
3869
|
+
return viewer?.signedIn === true ? "signed-in" : "guest";
|
|
3870
|
+
}
|
|
3871
|
+
function Bar({ raw, props, builder }) {
|
|
3872
|
+
const { props: settings, mediaOrigin, locale, editMode } = props;
|
|
3873
|
+
const design = (0, import_ui7.useSiteDesign)();
|
|
3874
|
+
const viewer = useViewer();
|
|
3875
|
+
const all2 = (0, import_react19.useMemo)(() => normalizeMessages(Array.isArray(raw.messages) ? raw.messages : []), [raw]);
|
|
3876
|
+
const style = isRecord4(raw.style) ? raw.style : {};
|
|
3877
|
+
const rotate = isRecord4(raw.rotate) ? raw.rotate : {};
|
|
3878
|
+
const [ready, setReady] = (0, import_react19.useState)(false);
|
|
3879
|
+
const [dismissed, setDismissed] = (0, import_react19.useState)(() => /* @__PURE__ */ new Set());
|
|
3880
|
+
const [at, setAt] = (0, import_react19.useState)(0);
|
|
3881
|
+
const [hover, setHover] = (0, import_react19.useState)(false);
|
|
3882
|
+
const [focus, setFocus] = (0, import_react19.useState)(false);
|
|
3883
|
+
const [reduced2, setReduced] = (0, import_react19.useState)(false);
|
|
3884
|
+
const site = builder?.site;
|
|
3885
|
+
const loadedAt = site?.status === "ok" && site.loadedAt !== void 0 ? Date.parse(site.loadedAt) : Number.NaN;
|
|
3886
|
+
const now = ready || Number.isNaN(loadedAt) ? Date.now() : loadedAt;
|
|
3887
|
+
const page = pageOf2(builder);
|
|
3888
|
+
const eligible = eligibleOnAnyDevice(all2, now, audienceOf(ready, viewer), page);
|
|
3889
|
+
const shown2 = eligible.filter((m) => editMode || !dismissed.has(m.id));
|
|
3890
|
+
const forEveryone = new Set(eligibleOnAnyDevice(all2, now, "all", page).map((m) => m.id));
|
|
3891
|
+
const waiting = [...eligibleOnAnyDevice(all2, now, "guest", page), ...eligibleOnAnyDevice(all2, now, "signed-in", page)].some(
|
|
3892
|
+
(m) => !forEveryone.has(m.id)
|
|
3893
|
+
);
|
|
3894
|
+
const interactive = props.interactive !== false && !editMode;
|
|
3895
|
+
const rotating = interactive && rotate.enabled === true && shown2.length > 1;
|
|
3896
|
+
const current = Math.min(at, Math.max(0, shown2.length - 1));
|
|
3897
|
+
const intervalS = typeof rotate.intervalS === "number" ? Math.min(15, Math.max(3, rotate.intervalS)) : 6;
|
|
3898
|
+
const shownRef = (0, import_react19.useRef)(shown2);
|
|
3899
|
+
shownRef.current = shown2;
|
|
3900
|
+
(0, import_react19.useEffect)(() => {
|
|
3901
|
+
setReady(true);
|
|
3902
|
+
setDismissed(new Set(readDismissed(all2.map((m) => m.id))));
|
|
3903
|
+
}, [all2]);
|
|
3904
|
+
(0, import_react19.useEffect)(() => {
|
|
3905
|
+
const query = window.matchMedia?.(REDUCED);
|
|
3906
|
+
if (query === void 0) return void 0;
|
|
3907
|
+
const sync = () => setReduced(query.matches);
|
|
3908
|
+
sync();
|
|
3909
|
+
query.addEventListener?.("change", sync);
|
|
3910
|
+
return () => query.removeEventListener?.("change", sync);
|
|
3911
|
+
}, []);
|
|
3912
|
+
const step2 = (direction) => setAt((from) => {
|
|
3913
|
+
const list2 = shownRef.current;
|
|
3914
|
+
const device = deviceNow();
|
|
3915
|
+
let i = Math.min(from, list2.length - 1);
|
|
3916
|
+
for (let tries = 0; tries < list2.length; tries += 1) {
|
|
3917
|
+
i = (i + direction + list2.length) % list2.length;
|
|
3918
|
+
if (list2[i].devices.includes(device)) return i;
|
|
3919
|
+
}
|
|
3920
|
+
return from;
|
|
3921
|
+
});
|
|
3922
|
+
(0, import_react19.useEffect)(() => {
|
|
3923
|
+
const list2 = shownRef.current;
|
|
3924
|
+
if (list2.length > 1 && list2[0] !== void 0 && !list2[0].devices.includes(deviceNow())) step2(1);
|
|
3925
|
+
}, [ready]);
|
|
3926
|
+
(0, import_react19.useEffect)(() => {
|
|
3927
|
+
if (!rotating || hover || focus || reduced2) return void 0;
|
|
3928
|
+
const timer = setInterval(() => step2(1), intervalS * 1e3);
|
|
3929
|
+
return () => clearInterval(timer);
|
|
3930
|
+
}, [rotating, hover, focus, reduced2, intervalS]);
|
|
3931
|
+
if (raw.enabled !== true) return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Placeholder, { editMode, children: "No announcement: turn one on in Site settings" });
|
|
3932
|
+
const reserve = eligible.length === 0 && waiting;
|
|
3933
|
+
if (shown2.length === 0 && !reserve) return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Placeholder, { editMode, children: "No announcement is showing now" });
|
|
3934
|
+
const link = makeLink(builder, props.resolveLink, mediaOrigin);
|
|
3935
|
+
const word = (key, fallback) => {
|
|
3936
|
+
for (const strings of [site?.status === "ok" ? site.settings.strings : void 0, design?.strings]) {
|
|
3937
|
+
if (isRecord4(strings) && Object.hasOwn(strings, key) && str(strings[key]) !== void 0) return strings[key];
|
|
3938
|
+
}
|
|
3939
|
+
return fallback;
|
|
3940
|
+
};
|
|
3941
|
+
const dismissLabel = word("announcement.dismiss", import_builder_schema25.SITE_STRING_DEFAULTS["announcement.dismiss"]);
|
|
3942
|
+
const dismissible = interactive && style.dismissible === true && settings.dismissible !== false;
|
|
3943
|
+
const dismiss = (id) => {
|
|
3944
|
+
writeDismissed(id);
|
|
3945
|
+
setDismissed((previous) => new Set(previous).add(id));
|
|
3946
|
+
};
|
|
3947
|
+
const height = isRecord4(style.height) ? style.height : {};
|
|
3948
|
+
const vars = {};
|
|
3949
|
+
for (const [device, key] of [["desktop", "--tb-an-hd"], ["tablet", "--tb-an-ht"], ["phone", "--tb-an-hp"]]) {
|
|
3950
|
+
const value = Object.hasOwn(height, device) ? height[device] : null;
|
|
3951
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 200) vars[key] = `${String(value)}px`;
|
|
3952
|
+
}
|
|
3953
|
+
const background = colorOf(style.background);
|
|
3954
|
+
const foreground = colorOf(style.text);
|
|
3955
|
+
if (background !== void 0) vars["--tb-an-bg"] = background;
|
|
3956
|
+
if (foreground !== void 0) vars["--tb-an-fg"] = foreground;
|
|
3957
|
+
const align = style.align === "left" || style.align === "right" ? style.align : "center";
|
|
3958
|
+
const size = style.size === "m" ? "m" : "s";
|
|
3959
|
+
const transition = rotate.transition === "slide" ? "slide" : "fade";
|
|
3960
|
+
const activeMessage = shown2[current];
|
|
3961
|
+
const live = rotating && !hover && !focus && !reduced2 ? "off" : "polite";
|
|
3962
|
+
const dismissButton = (id) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("button", { type: "button", className: "tb-b-dismiss", onClick: () => dismiss(id), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_ui7.Icon, { name: "close", size: 16, label: dismissLabel }) });
|
|
3963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
3964
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(BasicStyles, {}),
|
|
3965
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("style", { href: "tb-an", precedence: "throttle", children: ANNOUNCEMENT_V2_CSS }),
|
|
3966
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
3967
|
+
"div",
|
|
3968
|
+
{
|
|
3969
|
+
className: `tb-an tb-an--${size} tb-an--${transition}${rotating ? " tb-an--rot" : ""}${reserve ? " tb-an--reserve" : ""}`,
|
|
3970
|
+
role: "region",
|
|
3971
|
+
"aria-label": word("announcement.label", "Announcement"),
|
|
3972
|
+
"data-align": align,
|
|
3973
|
+
style: vars,
|
|
3974
|
+
onMouseEnter: () => setHover(true),
|
|
3975
|
+
onMouseLeave: () => setHover(false),
|
|
3976
|
+
onFocus: () => setFocus(true),
|
|
3977
|
+
onBlur: () => setFocus(false),
|
|
3978
|
+
children: [
|
|
3979
|
+
rotating && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("button", { type: "button", className: "tb-an-step", "data-tb-an-prev": "", "aria-label": word("announcement.previous", "Previous announcement"), onClick: () => step2(-1), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { "aria-hidden": "true", children: "\u2039" }) }),
|
|
3980
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "tb-an-track", ...rotating ? { "aria-live": live } : {}, children: shown2.map((m, index) => {
|
|
3981
|
+
const target2 = isRecord4(m.target) ? m.target : null;
|
|
3982
|
+
const hidden = DEVICES5.filter((d) => !m.devices.includes(d)).map((d) => ` tb-an-hide-${d}`).join("");
|
|
3983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
3984
|
+
"div",
|
|
3985
|
+
{
|
|
3986
|
+
className: `tb-b-announcement tb-an-msg${hidden}`,
|
|
3987
|
+
...rotating && index === current ? { "data-active": "" } : {},
|
|
3988
|
+
children: [
|
|
3989
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "tb-b-announcement-text", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(MessageText, { message: m, locale, mediaOrigin, href: target2 === null ? null : link(target2) }) }),
|
|
3990
|
+
!rotating && dismissible && dismissButton(m.id)
|
|
3991
|
+
]
|
|
3992
|
+
},
|
|
3993
|
+
m.id
|
|
3994
|
+
);
|
|
3995
|
+
}) }),
|
|
3996
|
+
rotating && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("button", { type: "button", className: "tb-an-step", "data-tb-an-next": "", "aria-label": word("announcement.next", "Next announcement"), onClick: () => step2(1), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { "aria-hidden": "true", children: "\u203A" }) }),
|
|
3997
|
+
rotating && dismissible && activeMessage !== void 0 && dismissButton(activeMessage.id)
|
|
3998
|
+
]
|
|
3999
|
+
}
|
|
4000
|
+
)
|
|
4001
|
+
] });
|
|
4002
|
+
}
|
|
4003
|
+
function AnnouncementV2(props) {
|
|
4004
|
+
const builder = useBuilder();
|
|
4005
|
+
const site = builder?.site;
|
|
4006
|
+
const raw = site?.status === "ok" && isRecord4(site.settings.announcement) ? site.settings.announcement : null;
|
|
4007
|
+
if (raw === null || !Array.isArray(raw.messages)) return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Announcement, { ...props });
|
|
4008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Bar, { raw, props, builder });
|
|
4009
|
+
}
|
|
4010
|
+
var ANNOUNCEMENT_V2_CSS = `@layer throttle{
|
|
4011
|
+
.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)))}
|
|
4012
|
+
.tb-an--reserve,.tb-an--rot{--tb-an-rf:2.5rem}
|
|
4013
|
+
.tb-an-track{flex:1 1 auto;min-inline-size:0}
|
|
4014
|
+
.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}
|
|
4015
|
+
.tb-an[data-align=left] .tb-b-announcement{text-align:var(--b-align,start);justify-content:flex-start}
|
|
4016
|
+
.tb-an[data-align=right] .tb-b-announcement{text-align:var(--b-align,end);justify-content:flex-end}
|
|
4017
|
+
.tb-an--m .tb-b-announcement{font-size:var(--tb-text-m)}
|
|
4018
|
+
.tb-an-text{display:inline}
|
|
4019
|
+
.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}
|
|
4020
|
+
.tb-an-step:focus-visible{outline:2px solid currentColor;outline-offset:-2px}
|
|
4021
|
+
[dir=rtl] .tb-an-step span{display:inline-block;transform:scaleX(-1)}
|
|
4022
|
+
.tb-an--rot .tb-an-track{display:grid}
|
|
4023
|
+
.tb-an--rot .tb-an-msg{grid-area:1/1}
|
|
4024
|
+
.tb-an--rot .tb-an-msg:not([data-active]){visibility:hidden}
|
|
4025
|
+
@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}}
|
|
4026
|
+
@keyframes tb-an-fade{from{opacity:0}to{opacity:1}}
|
|
4027
|
+
@keyframes tb-an-slide{from{opacity:0;transform:translateY(-.75rem)}to{opacity:1;transform:none}}
|
|
4028
|
+
@media (max-width:1024.98px){.tb-an{min-block-size:var(--tb-an-ht,var(--tb-an-hd,var(--tb-an-rf)))}}
|
|
4029
|
+
@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))))}}
|
|
4030
|
+
@media (min-width:1024.99px){.tb-an-hide-desktop{display:none}}
|
|
4031
|
+
@media (min-width:767.99px) and (max-width:1024.98px){.tb-an-hide-tablet{display:none}}
|
|
4032
|
+
@media (max-width:767.98px){.tb-an-hide-phone{display:none}}
|
|
4033
|
+
}`;
|
|
4034
|
+
var definition2 = import_builder_schema25.BASIC_WIDGET_DEFINITIONS.find((d) => d.type === "basic.announcement");
|
|
4035
|
+
if (definition2 === void 0) throw new Error("builder-schema has no basic.announcement definition");
|
|
4036
|
+
var announcementV2Widgets = [{ ...definition2, Component: AnnouncementV2 }];
|
|
4037
|
+
|
|
4038
|
+
// src/basics/v2/breadcrumbs.tsx
|
|
4039
|
+
var import_ui8 = require("@usethrottle/ui");
|
|
4040
|
+
var import_builder_schema27 = require("@usethrottle/builder-schema");
|
|
4041
|
+
|
|
4042
|
+
// src/server/jsonld.ts
|
|
4043
|
+
var CONTEXT = "https://schema.org";
|
|
4044
|
+
function breadcrumbJsonLd(items) {
|
|
4045
|
+
return {
|
|
4046
|
+
"@context": CONTEXT,
|
|
4047
|
+
"@type": "BreadcrumbList",
|
|
4048
|
+
itemListElement: items.map((item, index) => ({
|
|
4049
|
+
"@type": "ListItem",
|
|
4050
|
+
position: index + 1,
|
|
4051
|
+
name: item.name,
|
|
4052
|
+
item: item.url
|
|
4053
|
+
}))
|
|
4054
|
+
};
|
|
4055
|
+
}
|
|
4056
|
+
function faqJsonLd(items) {
|
|
4057
|
+
return {
|
|
4058
|
+
"@context": CONTEXT,
|
|
4059
|
+
"@type": "FAQPage",
|
|
4060
|
+
mainEntity: items.map((item) => ({
|
|
4061
|
+
"@type": "Question",
|
|
4062
|
+
name: item.question,
|
|
4063
|
+
acceptedAnswer: { "@type": "Answer", text: item.answer }
|
|
4064
|
+
}))
|
|
4065
|
+
};
|
|
4066
|
+
}
|
|
4067
|
+
function jsonLdString(value) {
|
|
4068
|
+
return JSON.stringify(value).replaceAll("<", "\\u003c");
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
// src/basics/v2/definitions.ts
|
|
4072
|
+
var import_builder_schema26 = require("@usethrottle/builder-schema");
|
|
4073
|
+
function mbDefinition(type) {
|
|
4074
|
+
const found = import_builder_schema26.MB_BASIC_WIDGET_DEFINITIONS.filter((d) => d.type === type).sort((a, b) => b.v - a.v)[0];
|
|
4075
|
+
if (found === void 0) throw new Error(`No MB definition of ${type}`);
|
|
4076
|
+
return found;
|
|
4077
|
+
}
|
|
4078
|
+
|
|
4079
|
+
// src/basics/v2/breadcrumbs.tsx
|
|
4080
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
4081
|
+
var SEPARATORS = { slash: "/", chevron: "\u203A", dot: "\xB7", arrow: "\u2192" };
|
|
4082
|
+
function jsonLdOn(settings) {
|
|
4083
|
+
if (!isRecord4(settings) || !isRecord4(settings.seo) || !isRecord4(settings.seo.structuredData)) return false;
|
|
4084
|
+
return settings.seo.structuredData.breadcrumbs === true;
|
|
4085
|
+
}
|
|
4086
|
+
function Breadcrumbs({ props, data, mediaOrigin, resolveLink, editMode }) {
|
|
4087
|
+
const design = (0, import_ui8.useSiteDesign)();
|
|
4088
|
+
const builder = useBuilder();
|
|
4089
|
+
const product = isRecord4(data.product) ? data.product : null;
|
|
4090
|
+
const title = product === null ? void 0 : str(product.title) ?? str(product.handle);
|
|
4091
|
+
if (product === null || title === void 0) {
|
|
4092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
4093
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(BasicV2Styles, {}),
|
|
4094
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Placeholder, { editMode, children: "The trail appears on a product page" })
|
|
4095
|
+
] });
|
|
4096
|
+
}
|
|
4097
|
+
const href = (target2) => (0, import_builder_schema27.safeUrl)(resolveLink?.(target2), "href", { mediaOrigin });
|
|
4098
|
+
const trail = [{ name: str(design?.brand?.storeName?.trim()) ?? "Home", href: "/" }];
|
|
4099
|
+
for (const step2 of Array.isArray(product.breadcrumbs) ? product.breadcrumbs : []) {
|
|
4100
|
+
if (!isRecord4(step2) || str(step2.name) === void 0) continue;
|
|
4101
|
+
const handle2 = str(step2.handle);
|
|
4102
|
+
trail.push({ name: step2.name, href: handle2 === void 0 ? null : href({ kind: "category", handle: handle2 }) });
|
|
4103
|
+
}
|
|
4104
|
+
const handle = str(product.handle);
|
|
4105
|
+
const current = { name: title, href: handle === void 0 ? null : href({ kind: "product", handle }) };
|
|
4106
|
+
const shown2 = props.showCurrent === false ? trail : [...trail, current];
|
|
4107
|
+
const separator = SEPARATORS[oneOf(props.separator, ["slash", "chevron", "dot", "arrow"], "slash")];
|
|
4108
|
+
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;
|
|
4109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
4110
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(BasicV2Styles, {}),
|
|
4111
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("nav", { className: "tb-b-crumbs", "aria-label": "Breadcrumb", children: [
|
|
4112
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("ol", { children: shown2.map((crumb, index) => {
|
|
4113
|
+
const last = index === shown2.length - 1 && props.showCurrent !== false;
|
|
4114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("li", { children: [
|
|
4115
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "tb-b-crumbs-sep", "aria-hidden": "true", children: separator }),
|
|
4116
|
+
last ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { "aria-current": "page", children: crumb.name }) : crumb.href === null ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: crumb.name }) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("a", { href: crumb.href, children: crumb.name })
|
|
4117
|
+
] }, `${String(index)}:${crumb.name}`);
|
|
4118
|
+
}) }),
|
|
4119
|
+
jsonLd !== null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("script", { type: "application/ld+json", children: jsonLd })
|
|
4120
|
+
] })
|
|
4121
|
+
] });
|
|
4122
|
+
}
|
|
4123
|
+
var breadcrumbsWidgets = [{ ...mbDefinition("basic.breadcrumbs"), Component: Breadcrumbs }];
|
|
4124
|
+
|
|
4125
|
+
// src/basics/v2/faq.tsx
|
|
4126
|
+
var import_react21 = require("react");
|
|
4127
|
+
var import_builder_schema29 = require("@usethrottle/builder-schema");
|
|
4128
|
+
|
|
4129
|
+
// src/basics/v2/markup.tsx
|
|
4130
|
+
var import_react20 = require("react");
|
|
4131
|
+
var import_builder_schema28 = require("@usethrottle/builder-schema");
|
|
4132
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
4133
|
+
var RICH = new Set(import_builder_schema28.RICH_CONTENT_ALLOWED_TAGS);
|
|
4134
|
+
var SVG = new Set(import_builder_schema28.SVG_ALLOWED_TAGS);
|
|
4135
|
+
var VOID2 = /* @__PURE__ */ new Set(["br", "hr", "img"]);
|
|
4136
|
+
var MAX_DEPTH4 = 24;
|
|
4137
|
+
var TOKEN = /<(\/?)([A-Za-z][A-Za-z0-9]*)((?:\s+[^\s="'<>/]+(?:="[^"]*")?)*)\s*(\/?)>|([^<]+)|</gu;
|
|
4138
|
+
var ATTR = /\s+([^\s="'<>/]+)(?:="([^"]*)")?/gu;
|
|
4139
|
+
var ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\xA0" };
|
|
4140
|
+
function decode2(value) {
|
|
4141
|
+
return value.replace(/&(?:#x([0-9a-f]{1,6})|#(\d{1,7})|([a-z]{2,6}));/giu, (whole, hex, dec, name) => {
|
|
4142
|
+
if (name !== void 0) return Object.hasOwn(ENTITIES, name.toLowerCase()) ? ENTITIES[name.toLowerCase()] : whole;
|
|
4143
|
+
const code = hex !== void 0 ? Number.parseInt(hex, 16) : Number.parseInt(dec ?? "", 10);
|
|
4144
|
+
return code > 0 && code <= 1114111 && !(code >= 55296 && code <= 57343) ? String.fromCodePoint(code) : "";
|
|
4145
|
+
});
|
|
4146
|
+
}
|
|
4147
|
+
function parseMarkup(markup, kind) {
|
|
4148
|
+
const allowed = kind === "rich" ? RICH : SVG;
|
|
4149
|
+
const root = { tag: "#root", attrs: [], children: [] };
|
|
4150
|
+
const stack = [root];
|
|
4151
|
+
let skipping = 0;
|
|
4152
|
+
for (const match of markup.matchAll(TOKEN)) {
|
|
4153
|
+
const [, closing, name, attrText2, selfClose, text] = match;
|
|
4154
|
+
const top = stack[stack.length - 1];
|
|
4155
|
+
if (name === void 0) {
|
|
4156
|
+
if (skipping === 0 && text !== void 0) top.children.push(decode2(text));
|
|
4157
|
+
continue;
|
|
4158
|
+
}
|
|
4159
|
+
const tag = [...allowed].find((candidate) => candidate.toLowerCase() === name.toLowerCase());
|
|
4160
|
+
if (closing === "/") {
|
|
4161
|
+
if (skipping > 0) skipping -= 1;
|
|
4162
|
+
else if (tag !== void 0 && stack.length > 1 && top.tag === tag) stack.pop();
|
|
4163
|
+
continue;
|
|
4164
|
+
}
|
|
4165
|
+
const isVoid = VOID2.has(name.toLowerCase());
|
|
4166
|
+
if (tag === void 0 || stack.length > MAX_DEPTH4) {
|
|
4167
|
+
if (selfClose !== "/" && !isVoid) skipping += 1;
|
|
4168
|
+
continue;
|
|
4169
|
+
}
|
|
4170
|
+
if (skipping > 0) {
|
|
4171
|
+
if (selfClose !== "/" && !isVoid) skipping += 1;
|
|
4172
|
+
continue;
|
|
4173
|
+
}
|
|
4174
|
+
const attrs = [];
|
|
4175
|
+
for (const a of (attrText2 ?? "").matchAll(ATTR)) attrs.push([a[1], decode2(a[2] ?? "")]);
|
|
4176
|
+
const element = { tag, attrs, children: [] };
|
|
4177
|
+
top.children.push(element);
|
|
4178
|
+
if (selfClose !== "/" && !isVoid) stack.push(element);
|
|
4179
|
+
}
|
|
4180
|
+
return root.children;
|
|
4181
|
+
}
|
|
4182
|
+
function textOf2(nodes) {
|
|
4183
|
+
return nodes.map((n) => typeof n === "string" ? n : n.tag === "br" ? " " : textOf2(n.children)).join("");
|
|
4184
|
+
}
|
|
4185
|
+
var SPECIAL = {
|
|
4186
|
+
class: "className",
|
|
4187
|
+
colspan: "colSpan",
|
|
4188
|
+
rowspan: "rowSpan",
|
|
4189
|
+
"xlink:href": "xlinkHref",
|
|
4190
|
+
"xml:space": "xmlSpace",
|
|
4191
|
+
"xmlns:xlink": "xmlnsXlink"
|
|
4192
|
+
};
|
|
4193
|
+
var camel = (name) => name.replace(/-([a-z])/gu, (_m, c) => c.toUpperCase());
|
|
4194
|
+
function styleOf(value) {
|
|
4195
|
+
const out = {};
|
|
4196
|
+
for (const declaration of value.split(";")) {
|
|
4197
|
+
const colon = declaration.indexOf(":");
|
|
4198
|
+
if (colon === -1) continue;
|
|
4199
|
+
const property = declaration.slice(0, colon).trim();
|
|
4200
|
+
const v = declaration.slice(colon + 1).trim();
|
|
4201
|
+
if (/^[a-z][a-z-]*$/u.test(property) && v !== "") out[camel(property)] = v;
|
|
4202
|
+
}
|
|
4203
|
+
return out;
|
|
4204
|
+
}
|
|
4205
|
+
var HYPHENATED = /* @__PURE__ */ new Set([
|
|
4206
|
+
"alignment-baseline",
|
|
4207
|
+
"baseline-shift",
|
|
4208
|
+
"clip-path",
|
|
4209
|
+
"clip-rule",
|
|
4210
|
+
"color-interpolation",
|
|
4211
|
+
"color-interpolation-filters",
|
|
4212
|
+
"dominant-baseline",
|
|
4213
|
+
"fill-opacity",
|
|
4214
|
+
"fill-rule",
|
|
4215
|
+
"flood-color",
|
|
4216
|
+
"flood-opacity",
|
|
4217
|
+
"font-family",
|
|
4218
|
+
"font-size",
|
|
4219
|
+
"font-size-adjust",
|
|
4220
|
+
"font-stretch",
|
|
4221
|
+
"font-style",
|
|
4222
|
+
"font-variant",
|
|
4223
|
+
"font-weight",
|
|
4224
|
+
"letter-spacing",
|
|
4225
|
+
"lighting-color",
|
|
4226
|
+
"marker-end",
|
|
4227
|
+
"marker-mid",
|
|
4228
|
+
"marker-start",
|
|
4229
|
+
"paint-order",
|
|
4230
|
+
"shape-rendering",
|
|
4231
|
+
"stop-color",
|
|
4232
|
+
"stop-opacity",
|
|
4233
|
+
"stroke-dasharray",
|
|
4234
|
+
"stroke-dashoffset",
|
|
4235
|
+
"stroke-linecap",
|
|
4236
|
+
"stroke-linejoin",
|
|
4237
|
+
"stroke-miterlimit",
|
|
4238
|
+
"stroke-opacity",
|
|
4239
|
+
"stroke-width",
|
|
4240
|
+
"text-anchor",
|
|
4241
|
+
"text-decoration",
|
|
4242
|
+
"text-rendering",
|
|
4243
|
+
"vector-effect",
|
|
4244
|
+
"word-spacing",
|
|
4245
|
+
"writing-mode"
|
|
4246
|
+
]);
|
|
4247
|
+
var DENIED_PROP = /^(?:children|key|ref|dangerously|innerhtml|outerhtml|suppress|on)/iu;
|
|
4248
|
+
function propName(name) {
|
|
4249
|
+
if (Object.hasOwn(SPECIAL, name)) return SPECIAL[name];
|
|
4250
|
+
if (/^(?:aria|data)-[a-z0-9-]{1,60}$/u.test(name)) return name;
|
|
4251
|
+
const prop = HYPHENATED.has(name) ? camel(name) : name;
|
|
4252
|
+
if (!/^[a-z][a-zA-Z0-9]*$/u.test(prop) || DENIED_PROP.test(prop)) return null;
|
|
4253
|
+
return prop;
|
|
4254
|
+
}
|
|
4255
|
+
function propsOf(element, key) {
|
|
4256
|
+
const props = { key };
|
|
4257
|
+
for (const [name, value] of element.attrs) {
|
|
4258
|
+
if (name === "style") {
|
|
4259
|
+
props.style = styleOf(value);
|
|
4260
|
+
continue;
|
|
4261
|
+
}
|
|
4262
|
+
const prop = propName(name);
|
|
4263
|
+
if (prop !== null) props[prop] = value;
|
|
4264
|
+
}
|
|
4265
|
+
return props;
|
|
4266
|
+
}
|
|
4267
|
+
var FRAGMENT = /^#[A-Za-z_][\w:.-]{0,99}$/u;
|
|
4268
|
+
function checkUrls(tag, props, mediaOrigin) {
|
|
4269
|
+
for (const key of ["href", "xlinkHref", "src"]) {
|
|
4270
|
+
if (!Object.hasOwn(props, key)) continue;
|
|
4271
|
+
const value = props[key];
|
|
4272
|
+
const safe = SVG.has(tag) ? typeof value === "string" && FRAGMENT.test(value) ? value : null : (0, import_builder_schema28.safeUrl)(value, key === "src" ? "src" : "href", { mediaOrigin });
|
|
4273
|
+
if (safe !== null) {
|
|
4274
|
+
props[key] = safe;
|
|
4275
|
+
continue;
|
|
4276
|
+
}
|
|
4277
|
+
if (tag === "a" || tag === "img") return false;
|
|
4278
|
+
delete props[key];
|
|
4279
|
+
}
|
|
4280
|
+
return true;
|
|
4281
|
+
}
|
|
4282
|
+
function renderMarkup(nodes, options = {}) {
|
|
4283
|
+
return nodes.map((node, index) => {
|
|
4284
|
+
if (typeof node === "string") return node;
|
|
4285
|
+
const props = { ...propsOf(node, index), ...options.extra?.(node) ?? {} };
|
|
4286
|
+
if (!checkUrls(node.tag, props, options.mediaOrigin ?? "")) return null;
|
|
4287
|
+
if (VOID2.has(node.tag)) return (0, import_react20.createElement)(node.tag, props);
|
|
4288
|
+
return (0, import_react20.createElement)(node.tag, props, ...renderMarkup(node.children, options));
|
|
4289
|
+
});
|
|
4290
|
+
}
|
|
4291
|
+
function svgElement(svg) {
|
|
4292
|
+
const clean = (0, import_builder_schema28.sanitizeSvg)(svg).svg;
|
|
4293
|
+
if (clean === "") return null;
|
|
4294
|
+
const root = parseMarkup(clean, "svg")[0];
|
|
4295
|
+
if (root === void 0 || typeof root === "string" || root.tag !== "svg") return null;
|
|
4296
|
+
const withFill = root.attrs.some(([name]) => name === "fill") ? root : { ...root, attrs: [...root.attrs, ["fill", "currentColor"]] };
|
|
4297
|
+
return renderMarkup([withFill])[0] ?? null;
|
|
4298
|
+
}
|
|
4299
|
+
async function readSvg(response, mediaOrigin) {
|
|
4300
|
+
if (!response.ok || (0, import_builder_schema28.safeUrl)(response.url, "src", { mediaOrigin }) === null) return null;
|
|
4301
|
+
if (!/^image\/svg\+xml(?:\s*;|$)/iu.test(response.headers.get("content-type") ?? "")) return null;
|
|
4302
|
+
const reader = response.body?.getReader();
|
|
4303
|
+
if (reader === void 0) {
|
|
4304
|
+
const text2 = await response.text();
|
|
4305
|
+
return new TextEncoder().encode(text2).length > import_builder_schema28.SVG_MAX_BYTES ? null : text2;
|
|
4306
|
+
}
|
|
4307
|
+
const decoder = new TextDecoder();
|
|
4308
|
+
let total = 0;
|
|
4309
|
+
let text = "";
|
|
4310
|
+
for (; ; ) {
|
|
4311
|
+
const { done, value } = await reader.read();
|
|
4312
|
+
if (done) return text + decoder.decode();
|
|
4313
|
+
total += value.length;
|
|
4314
|
+
if (total > import_builder_schema28.SVG_MAX_BYTES) {
|
|
4315
|
+
await reader.cancel();
|
|
4316
|
+
return null;
|
|
4317
|
+
}
|
|
4318
|
+
text += decoder.decode(value, { stream: true });
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
function SvgFromAsset({ asset, mediaOrigin, label }) {
|
|
4322
|
+
const src = isFrozenAsset(asset) ? (0, import_builder_schema28.safeUrl)(asset.url, "src", { mediaOrigin }) : null;
|
|
4323
|
+
const [source, setSource] = (0, import_react20.useState)(null);
|
|
4324
|
+
(0, import_react20.useEffect)(() => {
|
|
4325
|
+
if (src === null) return;
|
|
4326
|
+
const controller = new AbortController();
|
|
4327
|
+
fetch(src, { credentials: "omit", redirect: "error", signal: controller.signal }).then((response) => readSvg(response, mediaOrigin)).then((text) => {
|
|
4328
|
+
if (text !== null && !controller.signal.aborted) setSource(text);
|
|
4329
|
+
}).catch(() => void 0);
|
|
4330
|
+
return () => controller.abort();
|
|
4331
|
+
}, [src]);
|
|
4332
|
+
if (src === null) return null;
|
|
4333
|
+
const inline2 = source === null ? null : svgElement(source);
|
|
4334
|
+
if (inline2 !== null) return inline2;
|
|
4335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(AssetImage, { asset, mediaOrigin, alt: label ?? "", loading: "eager" });
|
|
4336
|
+
}
|
|
4337
|
+
|
|
4338
|
+
// src/basics/v2/faq.tsx
|
|
4339
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
4340
|
+
function itemsOf(value) {
|
|
4341
|
+
if (!Array.isArray(value)) return [];
|
|
4342
|
+
return value.flatMap((row) => {
|
|
4343
|
+
if (!isRecord4(row)) return [];
|
|
4344
|
+
const question = str(row.question);
|
|
4345
|
+
return question === void 0 ? [] : [{ question, answer: typeof row.answer === "string" ? row.answer : "" }];
|
|
4346
|
+
});
|
|
4347
|
+
}
|
|
4348
|
+
function faqJsonLdOn(settings) {
|
|
4349
|
+
if (!isRecord4(settings) || !isRecord4(settings.seo) || !isRecord4(settings.seo.structuredData)) return false;
|
|
4350
|
+
return settings.seo.structuredData.faq === true;
|
|
4351
|
+
}
|
|
4352
|
+
function Faq({ props, mediaOrigin, editMode }) {
|
|
4353
|
+
const builder = useBuilder();
|
|
4354
|
+
const group = (0, import_react21.useId)();
|
|
4355
|
+
const root = (0, import_react21.useRef)(null);
|
|
4356
|
+
const [all2, setAll] = (0, import_react21.useState)(false);
|
|
4357
|
+
const items = itemsOf(props.items);
|
|
4358
|
+
if (items.length === 0) {
|
|
4359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
|
4360
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BasicV2Styles, {}),
|
|
4361
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Placeholder, { editMode, children: "Add questions in the settings" })
|
|
4362
|
+
] });
|
|
4363
|
+
}
|
|
4364
|
+
const answers = items.map((item) => parseMarkup((0, import_builder_schema29.sanitizeRichContent)(item.answer, mediaOrigin).html, "rich"));
|
|
4365
|
+
const open = props.mode === "open";
|
|
4366
|
+
const oneOpen = props.oneOpen === true;
|
|
4367
|
+
const showAll = !open && props.expandAll === true && !oneOpen;
|
|
4368
|
+
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;
|
|
4369
|
+
const toggleAll = () => {
|
|
4370
|
+
const next = !all2;
|
|
4371
|
+
for (const details of root.current?.querySelectorAll("details") ?? []) details.open = next;
|
|
4372
|
+
setAll(next);
|
|
4373
|
+
};
|
|
4374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
|
4375
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BasicV2Styles, {}),
|
|
4376
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "tb-b-faq", ref: root, children: [
|
|
4377
|
+
showAll && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { type: "button", className: "tb-b-faq-all", "aria-expanded": all2, onClick: toggleAll, children: all2 ? "Collapse all" : "Expand all" }),
|
|
4378
|
+
items.map(
|
|
4379
|
+
(item, index) => open ? /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "tb-b-faq-item", children: [
|
|
4380
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "tb-b-faq-q", children: item.question }),
|
|
4381
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "tb-b-faq-a", children: renderMarkup(answers[index] ?? [], { mediaOrigin }) })
|
|
4382
|
+
] }, `${String(index)}:${item.question}`) : /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("details", { className: "tb-b-faq-item", ...oneOpen ? { name: `faq-${group}` } : {}, children: [
|
|
4383
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("summary", { className: "tb-b-faq-q", children: item.question }),
|
|
4384
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "tb-b-faq-a", children: renderMarkup(answers[index] ?? [], { mediaOrigin }) })
|
|
4385
|
+
] }, `${String(index)}:${item.question}`)
|
|
4386
|
+
),
|
|
4387
|
+
jsonLd !== null && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("script", { type: "application/ld+json", children: jsonLd })
|
|
4388
|
+
] })
|
|
4389
|
+
] });
|
|
4390
|
+
}
|
|
4391
|
+
var faqWidgets = [{ ...mbDefinition("basic.faq"), Component: Faq }];
|
|
4392
|
+
|
|
4393
|
+
// src/basics/v2/heading-v2.tsx
|
|
4394
|
+
var headingV2Widgets = [{ ...mbDefinition("basic.heading"), Component: Heading }];
|
|
4395
|
+
|
|
4396
|
+
// src/basics/v2/icon-list.tsx
|
|
4397
|
+
var import_ui9 = require("@usethrottle/ui");
|
|
4398
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
4399
|
+
var isIconName = (name) => typeof name === "string" && import_ui9.ICON_NAMES.includes(name);
|
|
4400
|
+
function IconList({ props, mediaOrigin, editMode }) {
|
|
4401
|
+
const rows = Array.isArray(props.items) ? props.items.flatMap((row) => isRecord4(row) ? [row] : []) : [];
|
|
4402
|
+
if (rows.length === 0) {
|
|
4403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
|
4404
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BasicV2Styles, {}),
|
|
4405
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Placeholder, { editMode, children: "Add rows in the settings" })
|
|
4406
|
+
] });
|
|
4407
|
+
}
|
|
4408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
|
|
4409
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BasicV2Styles, {}),
|
|
4410
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("ul", { className: "tb-b-icons", children: rows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("li", { children: [
|
|
4411
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "tb-b-icons-icon", "aria-hidden": "true", children: isFrozenAsset(row.svgAsset) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(SvgFromAsset, { asset: row.svgAsset, mediaOrigin }) : isIconName(row.icon) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_ui9.Icon, { name: row.icon }) : null }),
|
|
4412
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "tb-b-icons-text", children: str(row.text) ?? "" })
|
|
4413
|
+
] }, `${String(index)}:${str(row.text) ?? ""}`)) })
|
|
4414
|
+
] });
|
|
4415
|
+
}
|
|
4416
|
+
var iconListWidgets = [{ ...mbDefinition("basic.icon-list"), Component: IconList }];
|
|
4417
|
+
|
|
4418
|
+
// src/basics/v2/merge.ts
|
|
4419
|
+
function mergeV2Widgets(v1, v2) {
|
|
4420
|
+
const replacement = /* @__PURE__ */ new Map();
|
|
4421
|
+
for (const widget of v2) {
|
|
4422
|
+
if (replacement.has(widget.type)) throw new Error(`Two v2 widgets of type ${widget.type}`);
|
|
4423
|
+
replacement.set(widget.type, widget);
|
|
4424
|
+
}
|
|
4425
|
+
const v1Types = new Set(v1.map((widget) => widget.type));
|
|
4426
|
+
return [
|
|
4427
|
+
...v1.map((widget) => replacement.get(widget.type) ?? widget),
|
|
4428
|
+
...[...replacement.values()].filter((widget) => !v1Types.has(widget.type))
|
|
4429
|
+
];
|
|
4430
|
+
}
|
|
4431
|
+
|
|
4432
|
+
// src/basics/v2/quote.tsx
|
|
4433
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4434
|
+
function Quote({ props, mediaOrigin, editMode, inlineEdit }) {
|
|
4435
|
+
const quote = inlineEdit?.("quote") ?? str(props.quote);
|
|
4436
|
+
if (quote === void 0) {
|
|
4437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
4438
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(BasicV2Styles, {}),
|
|
4439
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Placeholder, { editMode, children: "Write the quote in the settings" })
|
|
4440
|
+
] });
|
|
4441
|
+
}
|
|
4442
|
+
const name = str(props.name);
|
|
4443
|
+
const role = str(props.role);
|
|
4444
|
+
const image = isFrozenAsset(props.image) ? props.image : null;
|
|
4445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
4446
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(BasicV2Styles, {}),
|
|
4447
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("figure", { className: "tb-b-quote", children: [
|
|
4448
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("blockquote", { children: quote }),
|
|
4449
|
+
(name !== void 0 || role !== void 0 || image !== null) && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("figcaption", { children: [
|
|
4450
|
+
image !== null && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AssetImage, { asset: image, mediaOrigin, alt: "", className: "tb-b-quote-photo" }),
|
|
4451
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("span", { className: "tb-b-quote-by", children: [
|
|
4452
|
+
name !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "tb-b-quote-name", children: name }),
|
|
4453
|
+
role !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "tb-b-quote-role", children: role })
|
|
4454
|
+
] })
|
|
4455
|
+
] })
|
|
4456
|
+
] })
|
|
4457
|
+
] });
|
|
4458
|
+
}
|
|
4459
|
+
var quoteWidgets = [{ ...mbDefinition("basic.quote"), Component: Quote }];
|
|
4460
|
+
|
|
4461
|
+
// src/basics/v2/rich-content.tsx
|
|
4462
|
+
var import_builder_schema30 = require("@usethrottle/builder-schema");
|
|
4463
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
4464
|
+
var slug = (text) => text.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/gu, "-").replace(/^-+|-+$/gu, "").slice(0, 40);
|
|
4465
|
+
function headings(nodes, nodeId) {
|
|
4466
|
+
const found = /* @__PURE__ */ new Map();
|
|
4467
|
+
const visit = (list2) => {
|
|
4468
|
+
for (const node of list2) {
|
|
4469
|
+
if (typeof node === "string") continue;
|
|
4470
|
+
if (node.tag === "h2" || node.tag === "h3") {
|
|
4471
|
+
const label = textOf2(node.children).replace(/\s+/gu, " ").trim();
|
|
4472
|
+
const n = found.size + 1;
|
|
4473
|
+
found.set(node, { id: `${nodeId}-${String(n)}${slug(label) === "" ? "" : `-${slug(label)}`}`, level: node.tag === "h2" ? 2 : 3, label });
|
|
4474
|
+
}
|
|
4475
|
+
visit(node.children);
|
|
4476
|
+
}
|
|
4477
|
+
};
|
|
4478
|
+
visit(nodes);
|
|
4479
|
+
return found;
|
|
4480
|
+
}
|
|
4481
|
+
function RichContent({ node, props, mediaOrigin, editMode }) {
|
|
4482
|
+
const html = str(props.html);
|
|
4483
|
+
if (html === void 0) {
|
|
4484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
4485
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(BasicV2Styles, {}),
|
|
4486
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Placeholder, { editMode, children: "Add content in the settings" })
|
|
4487
|
+
] });
|
|
4488
|
+
}
|
|
4489
|
+
const tree = parseMarkup((0, import_builder_schema30.sanitizeRichContent)(html, mediaOrigin).html, "rich");
|
|
4490
|
+
const entries2 = headings(tree, node.id);
|
|
4491
|
+
const toc = props.toc === true ? [...entries2.values()].filter((e) => e.label !== "") : [];
|
|
4492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
4493
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(BasicV2Styles, {}),
|
|
4494
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "tb-b-rich", children: [
|
|
4495
|
+
toc.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("nav", { className: "tb-b-toc", "aria-label": str(props.tocTitle) ?? "Contents", children: [
|
|
4496
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "tb-b-toc-title", children: str(props.tocTitle) ?? "Contents" }),
|
|
4497
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("ol", { children: toc.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("li", { className: `tb-b-toc-l${String(entry.level)}`, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("a", { href: `#${entry.id}`, children: entry.label }) }, entry.id)) })
|
|
4498
|
+
] }),
|
|
4499
|
+
renderMarkup(tree, {
|
|
4500
|
+
mediaOrigin,
|
|
4501
|
+
extra: (element) => {
|
|
4502
|
+
const entry = entries2.get(element);
|
|
4503
|
+
return entry === void 0 ? void 0 : { id: entry.id };
|
|
4504
|
+
}
|
|
4505
|
+
})
|
|
4506
|
+
] })
|
|
4507
|
+
] });
|
|
4508
|
+
}
|
|
4509
|
+
var richContentWidgets = [{ ...mbDefinition("basic.rich-content"), Component: RichContent }];
|
|
2744
4510
|
|
|
2745
4511
|
// src/basics/v2/svg.tsx
|
|
2746
|
-
var
|
|
4512
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
4513
|
+
function Svg({ props, mediaOrigin, editMode }) {
|
|
4514
|
+
const pasted = str(props.svg);
|
|
4515
|
+
const label = str(props.label);
|
|
4516
|
+
const inline2 = pasted === void 0 ? null : svgElement(pasted);
|
|
4517
|
+
const asset = pasted === void 0 && props.asset !== null && props.asset !== void 0 ? props.asset : null;
|
|
4518
|
+
if (inline2 === null && asset === null) {
|
|
4519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
|
|
4520
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(BasicV2Styles, {}),
|
|
4521
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Placeholder, { editMode, children: "Paste an SVG or pick one from the media library" })
|
|
4522
|
+
] });
|
|
4523
|
+
}
|
|
4524
|
+
const decorative = props.decorative !== false;
|
|
4525
|
+
const access = decorative ? { "aria-hidden": true } : label === void 0 ? {} : { role: "img", "aria-label": label };
|
|
4526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
|
|
4527
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(BasicV2Styles, {}),
|
|
4528
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "tb-b-svg", ...access, children: inline2 ?? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SvgFromAsset, { asset, mediaOrigin, ...label === void 0 || decorative ? {} : { label } }) })
|
|
4529
|
+
] });
|
|
4530
|
+
}
|
|
4531
|
+
var svgWidgets = [{ ...mbDefinition("basic.svg"), Component: Svg }];
|
|
2747
4532
|
|
|
2748
4533
|
// src/basics/index.ts
|
|
2749
4534
|
var BASIC_COMPONENTS = {
|
|
@@ -2760,8 +4545,8 @@ var BASIC_COMPONENTS = {
|
|
|
2760
4545
|
"basic.copyright": Copyright,
|
|
2761
4546
|
"basic.countdown": Countdown
|
|
2762
4547
|
};
|
|
2763
|
-
var v1Widgets =
|
|
2764
|
-
(
|
|
4548
|
+
var v1Widgets = import_builder_schema31.BASIC_WIDGET_DEFINITIONS.flatMap(
|
|
4549
|
+
(definition3) => definition3.v === 1 && Object.hasOwn(BASIC_COMPONENTS, definition3.type) ? [{ ...definition3, Component: BASIC_COMPONENTS[definition3.type] }] : []
|
|
2765
4550
|
);
|
|
2766
4551
|
var widgets = mergeV2Widgets(v1Widgets, [
|
|
2767
4552
|
...faqWidgets,
|
|
@@ -2771,30 +4556,31 @@ var widgets = mergeV2Widgets(v1Widgets, [
|
|
|
2771
4556
|
...iconListWidgets,
|
|
2772
4557
|
...quoteWidgets,
|
|
2773
4558
|
...menuV2Widgets,
|
|
2774
|
-
...announcementV2Widgets
|
|
4559
|
+
...announcementV2Widgets,
|
|
4560
|
+
...headingV2Widgets
|
|
2775
4561
|
]);
|
|
2776
4562
|
var basicPack = { id: "basic", version: "0.0.0", widgets, dataSources: [] };
|
|
2777
4563
|
|
|
2778
4564
|
// src/custom/factory.ts
|
|
2779
|
-
var
|
|
4565
|
+
var import_react23 = require("react");
|
|
2780
4566
|
|
|
2781
4567
|
// src/custom/composite-widget.tsx
|
|
2782
|
-
var
|
|
2783
|
-
var
|
|
2784
|
-
var
|
|
4568
|
+
var import_react22 = require("react");
|
|
4569
|
+
var import_builder_schema32 = require("@usethrottle/builder-schema");
|
|
4570
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
2785
4571
|
var SETTING_KEY_RE = /^[a-z][A-Za-z0-9]{0,39}$/;
|
|
2786
4572
|
var NODE_ID_RE = /^[a-z0-9]{8,24}$/;
|
|
2787
4573
|
var WRAP = { section: "zzcompsec001", column: "zzcompcol001", inner: "zzcompinr001" };
|
|
2788
|
-
var
|
|
4574
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2789
4575
|
var compiled3 = /* @__PURE__ */ new WeakMap();
|
|
2790
4576
|
function parseBody(raw) {
|
|
2791
|
-
if (!
|
|
4577
|
+
if (!isRecord6(raw)) return null;
|
|
2792
4578
|
const columns = Array.isArray(raw.columns) ? raw.columns : void 0;
|
|
2793
4579
|
const stack = Array.isArray(raw.stack) ? raw.stack : void 0;
|
|
2794
4580
|
if (columns === void 0 === (stack === void 0)) return null;
|
|
2795
4581
|
const children = columns !== void 0 ? [{ id: WRAP.inner, type: "inner-section", props: {}, columns }] : stack ?? [];
|
|
2796
|
-
if (stack?.some((node) =>
|
|
2797
|
-
const parsed2 =
|
|
4582
|
+
if (stack?.some((node) => isRecord6(node) && node.type === "inner-section")) return null;
|
|
4583
|
+
const parsed2 = import_builder_schema32.pageDocumentSchema.safeParse({
|
|
2798
4584
|
schemaVersion: 1,
|
|
2799
4585
|
sections: [{ id: WRAP.section, type: "section", props: {}, columns: [{ id: WRAP.column, type: "column", props: { width: 100 }, children }] }]
|
|
2800
4586
|
});
|
|
@@ -2826,38 +4612,38 @@ function compile2(snapshot) {
|
|
|
2826
4612
|
const bindings = [];
|
|
2827
4613
|
if (extra.bindings !== void 0 && !Array.isArray(extra.bindings)) return refuse("bindings is not a list");
|
|
2828
4614
|
for (const raw of extra.bindings ?? []) {
|
|
2829
|
-
if (!
|
|
4615
|
+
if (!isRecord6(raw) || typeof raw.setting !== "string" || !SETTING_KEY_RE.test(raw.setting) || !Array.isArray(raw.targets)) {
|
|
2830
4616
|
return refuse("a binding is malformed");
|
|
2831
4617
|
}
|
|
2832
4618
|
const targets = [];
|
|
2833
|
-
for (const
|
|
2834
|
-
if (!
|
|
4619
|
+
for (const target2 of raw.targets) {
|
|
4620
|
+
if (!isRecord6(target2) || typeof target2.node !== "string" || !NODE_ID_RE.test(target2.node) || typeof target2.prop !== "string" || !SETTING_KEY_RE.test(target2.prop)) {
|
|
2835
4621
|
return refuse("a binding target is malformed");
|
|
2836
4622
|
}
|
|
2837
|
-
targets.push({ node:
|
|
4623
|
+
targets.push({ node: target2.node, prop: target2.prop });
|
|
2838
4624
|
}
|
|
2839
4625
|
bindings.push({ setting: raw.setting, targets });
|
|
2840
4626
|
}
|
|
2841
4627
|
const data = [];
|
|
2842
|
-
if (extra.data !== void 0 && !
|
|
4628
|
+
if (extra.data !== void 0 && !isRecord6(extra.data)) return refuse("data is not a record");
|
|
2843
4629
|
for (const [name, raw] of Object.entries(extra.data ?? {})) {
|
|
2844
|
-
if (!SETTING_KEY_RE.test(name) || !
|
|
4630
|
+
if (!SETTING_KEY_RE.test(name) || !isRecord6(raw) || !Array.isArray(raw.targets)) return refuse("a data input is malformed");
|
|
2845
4631
|
const targets = [];
|
|
2846
|
-
for (const
|
|
2847
|
-
if (!
|
|
4632
|
+
for (const target2 of raw.targets) {
|
|
4633
|
+
if (!isRecord6(target2) || typeof target2.node !== "string" || !NODE_ID_RE.test(target2.node) || typeof target2.input !== "string" || !SETTING_KEY_RE.test(target2.input)) {
|
|
2848
4634
|
return refuse("a data target is malformed");
|
|
2849
4635
|
}
|
|
2850
|
-
targets.push({ node:
|
|
4636
|
+
targets.push({ node: target2.node, input: target2.input });
|
|
2851
4637
|
}
|
|
2852
4638
|
data.push([name, { targets }]);
|
|
2853
4639
|
}
|
|
2854
4640
|
return { body, bindings, data };
|
|
2855
4641
|
}
|
|
2856
|
-
var
|
|
4642
|
+
var DEVICES6 = ["tablet", "phone"];
|
|
2857
4643
|
function withoutAnchor(node) {
|
|
2858
4644
|
delete node.props.anchor;
|
|
2859
4645
|
const responsive = node.responsive;
|
|
2860
|
-
for (const device of
|
|
4646
|
+
for (const device of DEVICES6) if (responsive?.[device] !== void 0) delete responsive[device].anchor;
|
|
2861
4647
|
}
|
|
2862
4648
|
function instanceId(outer, inner) {
|
|
2863
4649
|
let a = 3735928559;
|
|
@@ -2871,7 +4657,7 @@ function instanceId(outer, inner) {
|
|
|
2871
4657
|
b = Math.imul(b ^ b >>> 16, 2246822507) ^ Math.imul(a ^ a >>> 13, 3266489909);
|
|
2872
4658
|
return `i${(a >>> 0).toString(36).padStart(7, "0")}${(b >>> 0).toString(36).padStart(7, "0")}${(outer.length + inner.length).toString(36)}`;
|
|
2873
4659
|
}
|
|
2874
|
-
function
|
|
4660
|
+
function build2(input) {
|
|
2875
4661
|
const { snapshot, registry, node: outer, props, data } = input;
|
|
2876
4662
|
const body = structuredClone(input.compiled.body);
|
|
2877
4663
|
const assets = {};
|
|
@@ -2900,11 +4686,11 @@ function build(input) {
|
|
|
2900
4686
|
return id;
|
|
2901
4687
|
}
|
|
2902
4688
|
if (field.control === "link") {
|
|
2903
|
-
if (!
|
|
2904
|
-
const { href, ...
|
|
2905
|
-
if (
|
|
2906
|
-
hrefs.set(JSON.stringify(
|
|
2907
|
-
return
|
|
4689
|
+
if (!isRecord6(value) || typeof value.kind !== "string") return null;
|
|
4690
|
+
const { href, ...target2 } = value;
|
|
4691
|
+
if (target2.kind === "url") return typeof href === "string" ? { kind: "url", href } : null;
|
|
4692
|
+
hrefs.set(JSON.stringify(target2), typeof href === "string" ? href : null);
|
|
4693
|
+
return target2;
|
|
2908
4694
|
}
|
|
2909
4695
|
return value;
|
|
2910
4696
|
};
|
|
@@ -2912,21 +4698,21 @@ function build(input) {
|
|
|
2912
4698
|
const field = fields.get(binding.setting);
|
|
2913
4699
|
if (field === void 0 || !Object.hasOwn(props, binding.setting)) continue;
|
|
2914
4700
|
const value = props[binding.setting];
|
|
2915
|
-
for (const
|
|
2916
|
-
const inner = byId.get(
|
|
2917
|
-
const innerField = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v)?.settings.find((f) => f.key ===
|
|
4701
|
+
for (const target2 of binding.targets) {
|
|
4702
|
+
const inner = byId.get(target2.node);
|
|
4703
|
+
const innerField = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v)?.settings.find((f) => f.key === target2.prop);
|
|
2918
4704
|
if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
|
|
2919
4705
|
const converted = convert(field, value);
|
|
2920
|
-
if ((0,
|
|
2921
|
-
inner.props[
|
|
4706
|
+
if ((0, import_builder_schema32.validateSettingValue)(innerField, converted) !== null) continue;
|
|
4707
|
+
inner.props[target2.prop] = converted;
|
|
2922
4708
|
const responsive = inner.responsive;
|
|
2923
|
-
for (const device of
|
|
2924
|
-
if (responsive?.[device] !== void 0) delete responsive[device][
|
|
4709
|
+
for (const device of DEVICES6) {
|
|
4710
|
+
if (responsive?.[device] !== void 0) delete responsive[device][target2.prop];
|
|
2925
4711
|
const raw = outer.responsive?.[device];
|
|
2926
4712
|
const plain = field.output === "css" && field.translatable !== true && field.control !== "image" && field.control !== "link";
|
|
2927
|
-
if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && (0,
|
|
4713
|
+
if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && (0, import_builder_schema32.validateSettingValue)(innerField, raw[binding.setting]) === null) {
|
|
2928
4714
|
const target$ = inner.responsive ?? (inner.responsive = {});
|
|
2929
|
-
(target$[device] ?? (target$[device] = {}))[
|
|
4715
|
+
(target$[device] ?? (target$[device] = {}))[target2.prop] = raw[binding.setting];
|
|
2930
4716
|
}
|
|
2931
4717
|
}
|
|
2932
4718
|
}
|
|
@@ -2934,11 +4720,11 @@ function build(input) {
|
|
|
2934
4720
|
for (const [name, input$] of input.compiled.data) {
|
|
2935
4721
|
if (!Object.hasOwn(data, name) || data[name] === void 0) continue;
|
|
2936
4722
|
const key = `composite.${name}`;
|
|
2937
|
-
for (const
|
|
2938
|
-
const inner = byId.get(
|
|
4723
|
+
for (const target2 of input$.targets) {
|
|
4724
|
+
const inner = byId.get(target2.node);
|
|
2939
4725
|
const def = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v);
|
|
2940
|
-
if (inner === void 0 || def?.data === void 0 || !Object.hasOwn(def.data,
|
|
2941
|
-
inner.data = { ...inner.data ?? {}, [
|
|
4726
|
+
if (inner === void 0 || def?.data === void 0 || !Object.hasOwn(def.data, target2.input)) continue;
|
|
4727
|
+
inner.data = { ...inner.data ?? {}, [target2.input]: { source: key } };
|
|
2942
4728
|
innerData[key] = data[name];
|
|
2943
4729
|
}
|
|
2944
4730
|
}
|
|
@@ -2966,12 +4752,12 @@ function CompositeBody(props) {
|
|
|
2966
4752
|
const { snapshot, registry, node, data, locale, mediaOrigin, budget, resolveLink, interactive, idScope } = props;
|
|
2967
4753
|
const composite = compileComposite(snapshot);
|
|
2968
4754
|
if (composite === null) return null;
|
|
2969
|
-
const built =
|
|
4755
|
+
const built = build2({ snapshot, compiled: composite, registry, node, props: props.props, data });
|
|
2970
4756
|
if (!(budget ?? new RenderBudget()).take(built.weight)) {
|
|
2971
4757
|
warnOnce(`composite-weight:${snapshot.type}@${String(snapshot.v)}`, `${snapshot.type} would render too many nodes; rendering nothing for it`);
|
|
2972
4758
|
return null;
|
|
2973
4759
|
}
|
|
2974
|
-
return /* @__PURE__ */ (0,
|
|
4760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2975
4761
|
BuilderRenderer,
|
|
2976
4762
|
{
|
|
2977
4763
|
document: built.document,
|
|
@@ -2982,28 +4768,28 @@ function CompositeBody(props) {
|
|
|
2982
4768
|
mediaOrigin,
|
|
2983
4769
|
interactive,
|
|
2984
4770
|
idScope,
|
|
2985
|
-
resolveLink: (
|
|
4771
|
+
resolveLink: (target2) => built.hrefs.get(JSON.stringify(target2)) ?? resolveLink?.(target2) ?? null
|
|
2986
4772
|
}
|
|
2987
4773
|
);
|
|
2988
4774
|
}
|
|
2989
4775
|
function CompositeWidget(props) {
|
|
2990
|
-
return /* @__PURE__ */ (0,
|
|
4776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PartBoundary, { label: `${props.snapshot.type}@${String(props.snapshot.v)}`, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_react22.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CompositeBody, { ...props }) }) });
|
|
2991
4777
|
}
|
|
2992
4778
|
|
|
2993
4779
|
// src/custom/factory.ts
|
|
2994
4780
|
var isDisabled = (snapshot) => snapshot.status === "disabled";
|
|
2995
|
-
var Disabled = ({ editMode }) => editMode ? (0,
|
|
4781
|
+
var Disabled = ({ editMode }) => editMode ? (0, import_react23.createElement)("div", { className: "tb-missing" }, "This custom widget is disabled") : null;
|
|
2996
4782
|
var customWidgetFactory = (snapshot, registry) => {
|
|
2997
4783
|
if (isDisabled(snapshot)) return Disabled;
|
|
2998
4784
|
if (snapshot.kind === "template") {
|
|
2999
4785
|
const template = compileTemplate(snapshot, registry);
|
|
3000
4786
|
if (template === null) return null;
|
|
3001
|
-
const Component2 = (props) => (0,
|
|
4787
|
+
const Component2 = (props) => (0, import_react23.createElement)(TemplateWidget, { ...props, snapshot, registry });
|
|
3002
4788
|
componentWeights.set(Component2, template.weight);
|
|
3003
4789
|
return Component2;
|
|
3004
4790
|
}
|
|
3005
4791
|
if (compileComposite(snapshot) === null) return null;
|
|
3006
|
-
return (props) => (0,
|
|
4792
|
+
return (props) => (0, import_react23.createElement)(CompositeWidget, { ...props, snapshot, registry });
|
|
3007
4793
|
};
|
|
3008
4794
|
|
|
3009
4795
|
// src/registry.ts
|
|
@@ -3017,11 +4803,11 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
3017
4803
|
const sources = [];
|
|
3018
4804
|
const resolvers = /* @__PURE__ */ new Map();
|
|
3019
4805
|
for (const pack of all2) {
|
|
3020
|
-
for (const { Component: Component2, ...
|
|
3021
|
-
const key = customKey(
|
|
4806
|
+
for (const { Component: Component2, ...definition3 } of pack.widgets) {
|
|
4807
|
+
const key = customKey(definition3.type, definition3.v);
|
|
3022
4808
|
if (components.has(key)) continue;
|
|
3023
4809
|
components.set(key, Component2);
|
|
3024
|
-
definitions.push(
|
|
4810
|
+
definitions.push(definition3);
|
|
3025
4811
|
}
|
|
3026
4812
|
for (const { resolve, ...descriptor } of pack.dataSources) {
|
|
3027
4813
|
if (resolvers.has(descriptor.id)) continue;
|
|
@@ -3030,8 +4816,8 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
3030
4816
|
}
|
|
3031
4817
|
}
|
|
3032
4818
|
const factory = options.customWidget ?? DEFAULT_CUSTOM_WIDGET;
|
|
3033
|
-
const
|
|
3034
|
-
const schema = (0,
|
|
4819
|
+
const build3 = (custom) => {
|
|
4820
|
+
const schema = (0, import_builder_schema33.createRegistry)(definitions, sources, custom);
|
|
3035
4821
|
const snapshots = new Map(custom.map((snapshot) => [customKey(snapshot.type, snapshot.v), snapshot]));
|
|
3036
4822
|
const built = /* @__PURE__ */ new Map();
|
|
3037
4823
|
const registry = {
|
|
@@ -3051,16 +4837,16 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
3051
4837
|
if (!built.has(key)) built.set(key, factory(snapshot, registry));
|
|
3052
4838
|
return built.get(key) ?? void 0;
|
|
3053
4839
|
},
|
|
3054
|
-
withCustom: (more) =>
|
|
4840
|
+
withCustom: (more) => build3([...custom, ...more])
|
|
3055
4841
|
};
|
|
3056
4842
|
return registry;
|
|
3057
4843
|
};
|
|
3058
|
-
return
|
|
4844
|
+
return build3([]);
|
|
3059
4845
|
}
|
|
3060
4846
|
|
|
3061
4847
|
// src/slot.tsx
|
|
3062
|
-
var
|
|
3063
|
-
var
|
|
4848
|
+
var import_react24 = require("react");
|
|
4849
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
3064
4850
|
function contextKey(context) {
|
|
3065
4851
|
if (typeof context !== "object" || context === null) return "";
|
|
3066
4852
|
return Object.values(context).map((value) => {
|
|
@@ -3072,245 +4858,59 @@ function contextKey(context) {
|
|
|
3072
4858
|
function BuilderSlot({ name, context }) {
|
|
3073
4859
|
const builder = useBuilder();
|
|
3074
4860
|
if (builder === null || builder.site.status !== "ok") return null;
|
|
3075
|
-
const
|
|
3076
|
-
if (
|
|
4861
|
+
const part2 = Object.hasOwn(builder.site.slots, name) ? builder.site.slots[name] : void 0;
|
|
4862
|
+
if (part2 === void 0 || part2.document.sections.length === 0) return null;
|
|
3077
4863
|
return (
|
|
3078
4864
|
// Suspense inside the boundary: see parts.tsx.
|
|
3079
|
-
/* @__PURE__ */ (0,
|
|
4865
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PartBoundary, { label: `Builder slot ${name}`, resetKey: contextKey(context), children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { "data-throttle-part": "builder-slot", "data-b-slot": name, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react24.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PartView, { part: part2, context }) }) }) })
|
|
3080
4866
|
);
|
|
3081
4867
|
}
|
|
3082
4868
|
|
|
3083
|
-
// src/theme.ts
|
|
3084
|
-
var import_builder_schema24 = require("@usethrottle/builder-schema");
|
|
3085
|
-
var import_presets = require("@usethrottle/ui/presets");
|
|
3086
|
-
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
3087
|
-
var str2 = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
3088
|
-
var HEX = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
3089
|
-
var SCALE = { compact: 0.85, comfortable: 1, roomy: 1.25 };
|
|
3090
|
-
var PALETTE_KEYS = Object.keys(import_presets.PRESET_TOKENS.clean.light);
|
|
3091
|
-
function palette(base, over) {
|
|
3092
|
-
if (!isRecord5(over)) return base;
|
|
3093
|
-
const out = { ...base };
|
|
3094
|
-
for (const key of PALETTE_KEYS) {
|
|
3095
|
-
const value = over[key];
|
|
3096
|
-
if (typeof value === "string" && HEX.test(value)) out[key] = value;
|
|
3097
|
-
}
|
|
3098
|
-
return out;
|
|
3099
|
-
}
|
|
3100
|
-
function themeTokens(settings) {
|
|
3101
|
-
const theme = isRecord5(settings.theme) ? settings.theme : {};
|
|
3102
|
-
const preset = import_presets.PRESET_NAMES.includes(theme.preset) ? theme.preset : "clean";
|
|
3103
|
-
const customized = theme.customized === true;
|
|
3104
|
-
const base = import_presets.PRESET_TOKENS[preset];
|
|
3105
|
-
const colorScheme = theme.colorScheme === "light" || theme.colorScheme === "dark" ? theme.colorScheme : "auto";
|
|
3106
|
-
if (!customized) return { preset, customized, tokens: base, colorScheme };
|
|
3107
|
-
const fonts = isRecord5(theme.fonts) ? theme.fonts : {};
|
|
3108
|
-
return {
|
|
3109
|
-
preset,
|
|
3110
|
-
customized,
|
|
3111
|
-
colorScheme,
|
|
3112
|
-
tokens: {
|
|
3113
|
-
light: palette(base.light, theme.light),
|
|
3114
|
-
dark: palette(base.dark, theme.dark),
|
|
3115
|
-
fonts: {
|
|
3116
|
-
heading: str2(fonts.heading) ?? base.fonts.heading,
|
|
3117
|
-
body: str2(fonts.body) ?? base.fonts.body,
|
|
3118
|
-
mono: str2(fonts.mono) ?? base.fonts.mono
|
|
3119
|
-
},
|
|
3120
|
-
radius: typeof theme.radius === "number" && theme.radius >= 0 && theme.radius <= 32 ? theme.radius : base.radius,
|
|
3121
|
-
spacingScale: theme.spacingScale === "compact" || theme.spacingScale === "roomy" ? theme.spacingScale : base.spacingScale
|
|
3122
|
-
}
|
|
3123
|
-
};
|
|
3124
|
-
}
|
|
3125
|
-
var GENERIC = { serif: "serif", sans: "sans-serif", mono: "monospace", display: "sans-serif" };
|
|
3126
|
-
var SYSTEM_STACK = {
|
|
3127
|
-
"system-sans": 'system-ui, -apple-system, "Segoe UI", sans-serif',
|
|
3128
|
-
"system-serif": 'Georgia, "Times New Roman", serif',
|
|
3129
|
-
"system-mono": "ui-monospace, SFMono-Regular, Menlo, monospace"
|
|
3130
|
-
};
|
|
3131
|
-
function fontStack(family) {
|
|
3132
|
-
if (Object.hasOwn(SYSTEM_STACK, family)) return SYSTEM_STACK[family];
|
|
3133
|
-
const known = import_builder_schema24.SITE_FONTS.find((f) => f.family === family);
|
|
3134
|
-
if (known === void 0 || !/^[A-Za-z0-9 ]{1,60}$/.test(family)) return SYSTEM_STACK["system-sans"];
|
|
3135
|
-
return `"${family}", ${Object.hasOwn(GENERIC, known.category) ? GENERIC[known.category] : "sans-serif"}`;
|
|
3136
|
-
}
|
|
3137
|
-
function variables(p) {
|
|
3138
|
-
return {
|
|
3139
|
-
colorPrimary: p.colorPrimary,
|
|
3140
|
-
colorPrimaryForeground: p.colorPrimaryForeground,
|
|
3141
|
-
colorBackground: p.colorBackground,
|
|
3142
|
-
colorSurface: p.colorSurface,
|
|
3143
|
-
colorForeground: p.colorForeground,
|
|
3144
|
-
colorMuted: p.colorMuted,
|
|
3145
|
-
colorMutedForeground: p.colorMutedForeground,
|
|
3146
|
-
colorBorder: p.colorBorder,
|
|
3147
|
-
colorBorderControl: p.colorBorderControl,
|
|
3148
|
-
colorSuccess: p.colorSuccess,
|
|
3149
|
-
colorWarning: p.colorWarning,
|
|
3150
|
-
colorDanger: p.colorDanger
|
|
3151
|
-
};
|
|
3152
|
-
}
|
|
3153
|
-
function appearanceOf(settings) {
|
|
3154
|
-
const { tokens, colorScheme } = themeTokens(settings);
|
|
3155
|
-
return {
|
|
3156
|
-
theme: colorScheme,
|
|
3157
|
-
variables: {
|
|
3158
|
-
...variables(tokens.light),
|
|
3159
|
-
fontFamily: fontStack(tokens.fonts.body),
|
|
3160
|
-
borderRadius: `${String(tokens.radius)}px`
|
|
3161
|
-
},
|
|
3162
|
-
darkVariables: variables(tokens.dark)
|
|
3163
|
-
};
|
|
3164
|
-
}
|
|
3165
|
-
var kebab = (key) => key.replace(/^color/, "").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/^([A-Z])/, (c) => c.toLowerCase()).toLowerCase();
|
|
3166
|
-
function colourDecls(p) {
|
|
3167
|
-
return PALETTE_KEYS.map((key) => `--tb-color-${kebab(key)}:${p[key]}`).join(";");
|
|
3168
|
-
}
|
|
3169
|
-
function themeCss(settings, options = {}) {
|
|
3170
|
-
const { tokens, colorScheme } = themeTokens(settings);
|
|
3171
|
-
const heading = options.hostFont === true ? "" : `--throttle-font-family-heading:${fontStack(tokens.fonts.heading)};`;
|
|
3172
|
-
const light = `:root{--tb-scale:${String(SCALE[tokens.spacingScale])};${heading}${colourDecls(tokens.light)}}`;
|
|
3173
|
-
const dark = colourDecls(tokens.dark);
|
|
3174
|
-
if (colorScheme === "light") return light;
|
|
3175
|
-
if (colorScheme === "dark") return `${light}:root{${dark}}`;
|
|
3176
|
-
return `${light}@media (prefers-color-scheme:dark){:root{${dark}}}`;
|
|
3177
|
-
}
|
|
3178
|
-
function customCssOf(settings) {
|
|
3179
|
-
const theme = isRecord5(settings.theme) ? settings.theme : {};
|
|
3180
|
-
const css = theme.customCss;
|
|
3181
|
-
if (typeof css !== "string" || css.trim() === "" || css.length > import_builder_schema24.THEME_CSS_MAX_CHARS) return "";
|
|
3182
|
-
const result = (0, import_builder_schema24.sanitizeThemeCss)(css);
|
|
3183
|
-
return result.ok ? result.css : "";
|
|
3184
|
-
}
|
|
3185
|
-
function customCssSheet(css) {
|
|
3186
|
-
return css === "" ? "" : `@layer throttle,throttle-custom;@layer throttle-custom{${css}}`;
|
|
3187
|
-
}
|
|
3188
|
-
function makeResolveLink(settings, packs) {
|
|
3189
|
-
const routes = isRecord5(settings.routes) ? settings.routes : {};
|
|
3190
|
-
const pageRoute = str2(routes.page) ?? "/pages/{handle}";
|
|
3191
|
-
return (target) => {
|
|
3192
|
-
for (const pack of packs) {
|
|
3193
|
-
const href = pack.linkTargets?.resolve(target) ?? null;
|
|
3194
|
-
if (href !== null) return (0, import_builder_schema24.safeUrl)(href, "href", { mediaOrigin: "" });
|
|
3195
|
-
}
|
|
3196
|
-
if (target.kind === "url") return (0, import_builder_schema24.safeUrl)(target.href, "href", { mediaOrigin: "" });
|
|
3197
|
-
if (typeof target.href === "string") return (0, import_builder_schema24.safeUrl)(target.href, "href", { mediaOrigin: "" });
|
|
3198
|
-
if (target.kind === "page") {
|
|
3199
|
-
const slug = str2(target.slug) ?? str2(target.handle);
|
|
3200
|
-
if (slug !== void 0 && /^[A-Za-z0-9._~-]{1,200}$/.test(slug)) {
|
|
3201
|
-
return (0, import_builder_schema24.safeUrl)(pageRoute.replace("{handle}", slug), "href", { mediaOrigin: "" });
|
|
3202
|
-
}
|
|
3203
|
-
}
|
|
3204
|
-
return null;
|
|
3205
|
-
};
|
|
3206
|
-
}
|
|
3207
|
-
var MENU_KINDS = /* @__PURE__ */ new Set(["category", "collection", "product", "page", "search", "url"]);
|
|
3208
|
-
function menuItems(items, resolve, depth = 0) {
|
|
3209
|
-
if (!Array.isArray(items) || depth > 3) return [];
|
|
3210
|
-
const out = [];
|
|
3211
|
-
for (const item of items) {
|
|
3212
|
-
if (!isRecord5(item) || !isRecord5(item.target) || typeof item.target.kind !== "string") continue;
|
|
3213
|
-
const label = str2(item.label);
|
|
3214
|
-
const href = resolve(item.target);
|
|
3215
|
-
if (label === void 0 || href === null) continue;
|
|
3216
|
-
const kind = MENU_KINDS.has(item.target.kind) ? item.target.kind : void 0;
|
|
3217
|
-
const children = menuItems(item.children, resolve, depth + 1);
|
|
3218
|
-
out.push({
|
|
3219
|
-
label,
|
|
3220
|
-
href,
|
|
3221
|
-
...kind === void 0 ? {} : { kind },
|
|
3222
|
-
...children.length === 0 ? {} : { children }
|
|
3223
|
-
});
|
|
3224
|
-
}
|
|
3225
|
-
return out;
|
|
3226
|
-
}
|
|
3227
|
-
var assetUrl = (v, mediaOrigin) => {
|
|
3228
|
-
const raw = typeof v === "string" ? v : isRecord5(v) ? v.url : void 0;
|
|
3229
|
-
return typeof raw === "string" ? (0, import_builder_schema24.safeUrl)(raw, "src", { mediaOrigin }) ?? void 0 : void 0;
|
|
3230
|
-
};
|
|
3231
|
-
function siteDesignOf(settings, resolve, pageOutlet, mediaOrigin) {
|
|
3232
|
-
const { preset, customized, tokens, colorScheme } = themeTokens(settings);
|
|
3233
|
-
const brand = isRecord5(settings.brand) ? settings.brand : {};
|
|
3234
|
-
const logo = isRecord5(brand.logo) ? brand.logo : {};
|
|
3235
|
-
const light = assetUrl(logo.light, mediaOrigin);
|
|
3236
|
-
const dark = assetUrl(logo.dark, mediaOrigin);
|
|
3237
|
-
const favicon = assetUrl(brand.favicon, mediaOrigin);
|
|
3238
|
-
const menus = isRecord5(settings.menus) ? Object.fromEntries(Object.entries(settings.menus).map(([name, items]) => [name, menuItems(items, resolve)])) : {};
|
|
3239
|
-
const announcement = isRecord5(settings.announcement) ? settings.announcement : null;
|
|
3240
|
-
const message = announcement === null ? void 0 : str2(announcement.message);
|
|
3241
|
-
const announcementHref = announcement !== null && isRecord5(announcement.target) && typeof announcement.target.kind === "string" ? resolve(announcement.target) : null;
|
|
3242
|
-
const strings = isRecord5(settings.strings) ? Object.fromEntries(Object.entries(settings.strings).filter((entry) => typeof entry[1] === "string")) : {};
|
|
3243
|
-
const seo = isRecord5(settings.seo) ? settings.seo : {};
|
|
3244
|
-
const routes = isRecord5(settings.routes) ? settings.routes : {};
|
|
3245
|
-
const connections = isRecord5(settings.connections) ? settings.connections : {};
|
|
3246
|
-
const shareImage = assetUrl(seo.shareImage, mediaOrigin);
|
|
3247
|
-
const titleTemplate = str2(seo.titleTemplate);
|
|
3248
|
-
const defaultDescription = str2(seo.defaultDescription);
|
|
3249
|
-
const pageRoute = str2(routes.page);
|
|
3250
|
-
return {
|
|
3251
|
-
source: "builder",
|
|
3252
|
-
theme: { preset, customized, colorScheme, ...customized ? { values: tokens } : {} },
|
|
3253
|
-
brand: {
|
|
3254
|
-
...str2(brand.storeName) === void 0 ? {} : { storeName: str2(brand.storeName) },
|
|
3255
|
-
logo: light === void 0 && dark === void 0 ? null : { ...light === void 0 ? {} : { light }, ...dark === void 0 ? {} : { dark } },
|
|
3256
|
-
favicon: favicon ?? null
|
|
3257
|
-
},
|
|
3258
|
-
menus,
|
|
3259
|
-
announcement: announcement !== null && announcement.enabled === true && message !== void 0 ? { message, ...announcementHref === null ? {} : { href: announcementHref } } : null,
|
|
3260
|
-
strings,
|
|
3261
|
-
seo: {
|
|
3262
|
-
...titleTemplate === void 0 ? {} : { titleTemplate },
|
|
3263
|
-
...defaultDescription === void 0 ? {} : { defaultDescription },
|
|
3264
|
-
...shareImage === void 0 ? {} : { shareImage }
|
|
3265
|
-
},
|
|
3266
|
-
...pageRoute === void 0 ? {} : { routes: { page: pageRoute } },
|
|
3267
|
-
connections: {
|
|
3268
|
-
throttlePublishableKey: typeof connections.throttlePublishableKey === "string" ? connections.throttlePublishableKey : null
|
|
3269
|
-
},
|
|
3270
|
-
...pageOutlet === void 0 ? {} : { pageOutlet }
|
|
3271
|
-
};
|
|
3272
|
-
}
|
|
3273
|
-
|
|
3274
4869
|
// src/provider.tsx
|
|
3275
|
-
var
|
|
4870
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
3276
4871
|
var EMPTY = {};
|
|
4872
|
+
function loadedAtOf(site) {
|
|
4873
|
+
if (site.status !== "ok" || site.loadedAt === void 0) return void 0;
|
|
4874
|
+
const at = Date.parse(site.loadedAt);
|
|
4875
|
+
return Number.isNaN(at) ? void 0 : at;
|
|
4876
|
+
}
|
|
3277
4877
|
function useParentFont() {
|
|
3278
|
-
return (0,
|
|
4878
|
+
return (0, import_react25.useContext)(import_ui10.AppearanceContext)?.variables?.fontFamily;
|
|
3279
4879
|
}
|
|
3280
|
-
function BuilderProvider({ builderKey, client, packs, site, onError, interactive = true, pathname, catalogRoutes, mode = "live", children }) {
|
|
4880
|
+
function BuilderProvider({ builderKey, client, packs, site, onError, interactive = true, pathname, catalogRoutes, routeTable, templateName, ownPagePaths, mode = "live", viewer, page, linkTargets, children }) {
|
|
3281
4881
|
const packsKey = packs.map((pack) => `${pack.id}@${pack.version}`).join("|");
|
|
3282
|
-
const registryRef = (0,
|
|
4882
|
+
const registryRef = (0, import_react25.useRef)(null);
|
|
3283
4883
|
if (registryRef.current?.key !== packsKey) {
|
|
3284
4884
|
registryRef.current = { key: packsKey, registry: createRendererRegistry(packs) };
|
|
3285
4885
|
}
|
|
3286
4886
|
const registry = registryRef.current.registry;
|
|
3287
|
-
const builder = (0,
|
|
4887
|
+
const builder = (0, import_react25.useMemo)(
|
|
3288
4888
|
() => client ?? (builderKey === void 0 ? null : (0, import_builder2.createBuilderClient)({ builderKey })),
|
|
3289
4889
|
[client, builderKey]
|
|
3290
4890
|
);
|
|
3291
4891
|
const mediaOrigin = site.status === "ok" ? site.mediaOrigin : "";
|
|
3292
4892
|
const settings = site.status === "ok" ? site.settings : EMPTY;
|
|
3293
|
-
const resolveLink = (0,
|
|
3294
|
-
const outlets = (0,
|
|
3295
|
-
const renderers = (0,
|
|
3296
|
-
const pageOutlet = (0,
|
|
4893
|
+
const resolveLink = (0, import_react25.useMemo)(() => makeResolveLink(settings, packs), [settings, packs]);
|
|
4894
|
+
const outlets = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
|
|
4895
|
+
const renderers = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
|
|
4896
|
+
const pageOutlet = (0, import_react25.useCallback)((handle) => {
|
|
3297
4897
|
let outlet = outlets.current.get(handle);
|
|
3298
4898
|
if (outlet === void 0) {
|
|
3299
4899
|
outlet = function PageOutlet() {
|
|
3300
|
-
return /* @__PURE__ */ (0,
|
|
4900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PartBoundary, { label: `Builder page ${handle}`, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react25.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(BuilderPage, { slug: handle }) }) });
|
|
3301
4901
|
};
|
|
3302
4902
|
outlets.current.set(handle, outlet);
|
|
3303
4903
|
}
|
|
3304
4904
|
return outlet;
|
|
3305
4905
|
}, []);
|
|
3306
|
-
const resolveSlot = (0,
|
|
4906
|
+
const resolveSlot = (0, import_react25.useCallback)(
|
|
3307
4907
|
(name) => {
|
|
3308
|
-
const
|
|
3309
|
-
if (
|
|
4908
|
+
const part2 = site.status === "ok" && Object.hasOwn(site.slots, name) ? site.slots[name] : void 0;
|
|
4909
|
+
if (part2 === void 0 || part2.document.sections.length === 0) return null;
|
|
3310
4910
|
let renderer = renderers.current.get(name);
|
|
3311
4911
|
if (renderer === void 0) {
|
|
3312
4912
|
renderer = function SlotRenderer({ context }) {
|
|
3313
|
-
return /* @__PURE__ */ (0,
|
|
4913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(BuilderSlot, { name, context });
|
|
3314
4914
|
};
|
|
3315
4915
|
renderers.current.set(name, renderer);
|
|
3316
4916
|
}
|
|
@@ -3318,56 +4918,104 @@ function BuilderProvider({ builderKey, client, packs, site, onError, interactive
|
|
|
3318
4918
|
},
|
|
3319
4919
|
[site]
|
|
3320
4920
|
);
|
|
3321
|
-
const
|
|
4921
|
+
const delivery = (0, import_react25.useMemo)(() => site.status === "ok" ? customCssDeliveryOf(site.settings, site.theme, mediaOrigin) : { inline: "" }, [site, mediaOrigin]);
|
|
4922
|
+
const customCss = delivery.inline;
|
|
4923
|
+
const customCssHref = delivery.href;
|
|
3322
4924
|
const configured = settings.routes?.page;
|
|
3323
4925
|
const pageRoute = typeof configured === "string" ? configured : "/pages/{handle}";
|
|
3324
4926
|
const catalogKey = catalogRoutes?.join("\n");
|
|
3325
|
-
const
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
4927
|
+
const storeRoutes = settings.routes?.store;
|
|
4928
|
+
const tableKey = JSON.stringify(routeTable ?? storeRoutes ?? null);
|
|
4929
|
+
const codeRoutes = (0, import_react25.useMemo)(() => {
|
|
4930
|
+
const table = routeTable ?? (storeRoutes === void 0 ? void 0 : buildRouteTable(storeRoutes));
|
|
4931
|
+
return {
|
|
4932
|
+
page: pageRoute,
|
|
4933
|
+
...catalogRoutes === void 0 ? {} : { catalog: catalogRoutes },
|
|
4934
|
+
...table === void 0 ? {} : { routeTable: table },
|
|
4935
|
+
...ownPagePaths === void 0 ? {} : { allow: ownPagePaths }
|
|
4936
|
+
};
|
|
4937
|
+
}, [pageRoute, catalogKey, tableKey, ownPagePaths?.join("\n")]);
|
|
3330
4938
|
useLeaveCodeRoutes(pathname, codeRoutes);
|
|
3331
4939
|
const leaving = mustLeave(pathname, codeRoutes);
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3334
|
-
|
|
4940
|
+
const pageId = page?.id;
|
|
4941
|
+
const pageTemplate = page?.template;
|
|
4942
|
+
const pageHome = page?.home;
|
|
4943
|
+
const stablePage = (0, import_react25.useMemo)(
|
|
4944
|
+
() => page === void 0 ? void 0 : { id: pageId, template: pageTemplate, home: pageHome },
|
|
4945
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4946
|
+
[page === void 0, pageId, pageTemplate, pageHome]
|
|
4947
|
+
);
|
|
4948
|
+
const value = (0, import_react25.useMemo)(
|
|
4949
|
+
() => ({ client: builder, packs, registry, site, locale: site.locale, mediaOrigin, onError, resolveLink, interactive, customCss, mode, pathname, codeRoutes, templateName, page: stablePage, linkTargets }),
|
|
4950
|
+
[builder, packs, registry, site, mediaOrigin, onError, resolveLink, interactive, customCss, mode, pathname, codeRoutes, templateName, stablePage, linkTargets]
|
|
3335
4951
|
);
|
|
3336
|
-
const design = (0,
|
|
3337
|
-
() => site.status === "ok" ? siteDesignOf(site.settings, resolveLink, pageOutlet, mediaOrigin) : null,
|
|
4952
|
+
const design = (0, import_react25.useMemo)(
|
|
4953
|
+
() => site.status === "ok" ? siteDesignOf(site.settings, resolveLink, pageOutlet, mediaOrigin, site.locale, loadedAtOf(site)) : null,
|
|
3338
4954
|
[site, resolveLink, pageOutlet, mediaOrigin]
|
|
3339
4955
|
);
|
|
3340
|
-
const own = (0,
|
|
3341
|
-
const merged = (0,
|
|
4956
|
+
const own = (0, import_react25.useMemo)(() => site.status === "ok" ? appearanceOf(site.settings) : void 0, [site]);
|
|
4957
|
+
const merged = (0, import_ui10.useAppearanceProviderValue)(own);
|
|
3342
4958
|
const parentFont = useParentFont();
|
|
3343
|
-
const appearance = (0,
|
|
4959
|
+
const appearance = (0, import_react25.useMemo)(() => {
|
|
3344
4960
|
if (own === void 0) return void 0;
|
|
3345
4961
|
return parentFont === void 0 ? merged : { ...merged, variables: { ...merged.variables, fontFamily: parentFont } };
|
|
3346
4962
|
}, [own, merged, parentFont]);
|
|
3347
|
-
return /* @__PURE__ */ (0,
|
|
3348
|
-
site.status === "ok" ? /* @__PURE__ */ (0,
|
|
3349
|
-
customCss === "" ? null : /* @__PURE__ */ (0,
|
|
3350
|
-
|
|
4963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(BuilderContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_ui10.ThrottleUIProvider, { ...appearance === void 0 ? {} : { appearance }, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_ui10.SiteDesignProvider, { value: design, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_ui10.SlotOutletProvider, { resolve: resolveSlot, children: [
|
|
4964
|
+
site.status === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("style", { children: themeCss(site.settings, { hostFont: parentFont !== void 0 }) }) : null,
|
|
4965
|
+
customCss === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("style", { children: customCssSheet(customCss) }),
|
|
4966
|
+
customCssHref === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("link", { rel: "stylesheet", href: customCssHref }),
|
|
4967
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ViewerContext.Provider, { value: viewer, children: leaving ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { "data-b-leaving": "", hidden: true }) : children })
|
|
3351
4968
|
] }) }) }) });
|
|
3352
4969
|
}
|
|
3353
4970
|
|
|
3354
4971
|
// src/parts.tsx
|
|
3355
|
-
var
|
|
3356
|
-
var
|
|
4972
|
+
var import_react26 = require("react");
|
|
4973
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
3357
4974
|
function Part({ name, tag }) {
|
|
3358
4975
|
const builder = useBuilder();
|
|
3359
4976
|
if (builder === null || builder.site.status !== "ok") return null;
|
|
3360
|
-
const
|
|
3361
|
-
if (
|
|
4977
|
+
const part2 = builder.site[name];
|
|
4978
|
+
if (part2.document.sections.length === 0) return null;
|
|
3362
4979
|
const Tag = tag;
|
|
3363
4980
|
return (
|
|
3364
4981
|
// Error boundaries do not catch on the server: the Suspense inside turns a throw
|
|
3365
4982
|
// during SSR into "render nothing here" and the client retries under the boundary.
|
|
3366
|
-
/* @__PURE__ */ (0,
|
|
4983
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PartBoundary, { label: `Builder ${name}`, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Tag, { "data-throttle-part": `builder-${name}`, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_react26.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PartView, { part: part2 }) }) }) })
|
|
3367
4984
|
);
|
|
3368
4985
|
}
|
|
3369
|
-
var BuilderHeader = () => /* @__PURE__ */ (0,
|
|
3370
|
-
var BuilderFooter = () => /* @__PURE__ */ (0,
|
|
4986
|
+
var BuilderHeader = () => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Part, { name: "header", tag: "header" });
|
|
4987
|
+
var BuilderFooter = () => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Part, { name: "footer", tag: "footer" });
|
|
4988
|
+
|
|
4989
|
+
// src/template-view.tsx
|
|
4990
|
+
var import_react27 = require("react");
|
|
4991
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
4992
|
+
function BuilderTemplateView({
|
|
4993
|
+
name,
|
|
4994
|
+
part: part2,
|
|
4995
|
+
context
|
|
4996
|
+
}) {
|
|
4997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PartBoundary, { label: `Builder template ${name}`, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { "data-throttle-part": "builder-template", "data-b-template": name, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react27.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PartView, { part: part2, context }) }) }) });
|
|
4998
|
+
}
|
|
4999
|
+
function BuilderRouteScope({
|
|
5000
|
+
templateName,
|
|
5001
|
+
routeTable,
|
|
5002
|
+
allowPath,
|
|
5003
|
+
children
|
|
5004
|
+
}) {
|
|
5005
|
+
const builder = useBuilder();
|
|
5006
|
+
const tableKey = JSON.stringify(routeTable ?? null);
|
|
5007
|
+
const value = (0, import_react27.useMemo)(() => {
|
|
5008
|
+
if (builder === null) return null;
|
|
5009
|
+
const codeRoutes = {
|
|
5010
|
+
...builder.codeRoutes,
|
|
5011
|
+
...routeTable === void 0 ? {} : { routeTable: { ...builder.codeRoutes.routeTable, ...routeTable } },
|
|
5012
|
+
...allowPath === void 0 ? {} : { allow: [...builder.codeRoutes.allow ?? [], allowPath] }
|
|
5013
|
+
};
|
|
5014
|
+
return { ...builder, codeRoutes, templateName };
|
|
5015
|
+
}, [builder, templateName, tableKey, allowPath]);
|
|
5016
|
+
if (allowPath !== void 0) allowCodePath(allowPath);
|
|
5017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BuilderContext.Provider, { value, children });
|
|
5018
|
+
}
|
|
3371
5019
|
|
|
3372
5020
|
// src/index.ts
|
|
3373
5021
|
var import_builder3 = require("@usethrottle/builder");
|