@kotao/storefront 0.2.4 → 0.2.6
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/README.md +50 -2
- package/dist/bridge-ZKbKqgFd.d.ts +239 -0
- package/dist/cart-documents-BLavRDiu.d.ts +89 -0
- package/dist/cart-documents.d.ts +1 -2
- package/dist/cart-documents.js +1 -1
- package/dist/{chunk-M7BPQ54D.js → chunk-2MRB6SMP.js} +4 -3
- package/dist/chunk-2MRB6SMP.js.map +1 -0
- package/dist/chunk-CKGI3Y7L.js +19 -0
- package/dist/chunk-CKGI3Y7L.js.map +1 -0
- package/dist/{chunk-4TEFGD42.js → chunk-EG34HLSX.js} +209 -162
- package/dist/chunk-EG34HLSX.js.map +1 -0
- package/dist/chunk-O6YZEY7X.js +1382 -0
- package/dist/chunk-O6YZEY7X.js.map +1 -0
- package/dist/{chunk-7MTCGXIG.js → chunk-R4N565GX.js} +8 -4
- package/dist/chunk-R4N565GX.js.map +1 -0
- package/dist/{chunk-XMTWFJCZ.js → chunk-RFM27BKZ.js} +31 -7
- package/dist/chunk-RFM27BKZ.js.map +1 -0
- package/dist/{chunk-MYDKIJRH.js → chunk-SVMYFYIA.js} +2 -2
- package/dist/{chunk-MYDKIJRH.js.map → chunk-SVMYFYIA.js.map} +1 -1
- package/dist/{chunk-H3D7BAOL.js → chunk-VOTBNOWH.js} +21 -3
- package/dist/chunk-VOTBNOWH.js.map +1 -0
- package/dist/{chunk-PXVDVUFX.js → chunk-W74FGUZH.js} +10 -3
- package/dist/chunk-W74FGUZH.js.map +1 -0
- package/dist/{chunk-2IWNUDSZ.js → chunk-WNXI3MPM.js} +2 -2
- package/dist/chunk-WNXI3MPM.js.map +1 -0
- package/dist/chunk-XXNCFWXT.js +2118 -0
- package/dist/chunk-XXNCFWXT.js.map +1 -0
- package/dist/{client-bsiNPHBi.d.ts → client-CwOPPpFF.d.ts} +11 -1
- package/dist/{createCartHandler-C4RrPwSG.d.ts → createCartHandler-7DdKB-GF.d.ts} +1 -1
- package/dist/custom-css-Bl7Ur3-H.d.ts +6 -0
- package/dist/editor.d.ts +57 -104
- package/dist/editor.js +270 -1
- package/dist/editor.js.map +1 -1
- package/dist/events-react.d.ts +1 -1
- package/dist/events-react.js +1 -1
- package/dist/events.d.ts +3 -3
- package/dist/events.js +1 -1
- package/dist/{fetch-M3Y-fQrW.d.ts → fetch-Bq_cc8_G.d.ts} +5 -0
- package/dist/hydrogen-Bu7k0kE4.d.ts +259 -0
- package/dist/index.d.ts +74 -51
- package/dist/index.js +19 -15
- package/dist/index.js.map +1 -1
- package/dist/react-router.d.ts +30 -9
- package/dist/react-router.js +16 -7
- package/dist/react-router.js.map +1 -1
- package/dist/react.d.ts +79 -11
- package/dist/react.js +279 -10
- package/dist/react.js.map +1 -1
- package/dist/{routing-sEonP93J.d.ts → routing-Bz3Cg0BW.d.ts} +36 -6
- package/dist/seo.d.ts +7 -4
- package/dist/seo.js +2 -2
- package/dist/settings.d.ts +14 -4
- package/dist/settings.js +2 -2
- package/dist/{shop-BJSvtmnV.d.ts → shop-CnrnSAJw.d.ts} +33 -6
- package/dist/{store-CtCWHI8H.d.ts → store-DO08fzJi.d.ts} +1 -1
- package/dist/storefront-api-types.d.ts +12 -0
- package/dist/{types-BDhHWZsP.d.ts → types-BkY0yET-.d.ts} +3 -3
- package/dist/{types-bcbQzx87.d.ts → types-DZX8ScsJ.d.ts} +2 -0
- package/package.json +4 -4
- package/dist/cart-documents-CwwRTvm8.d.ts +0 -21
- package/dist/chunk-2IWNUDSZ.js.map +0 -1
- package/dist/chunk-4TEFGD42.js.map +0 -1
- package/dist/chunk-7MTCGXIG.js.map +0 -1
- package/dist/chunk-H3D7BAOL.js.map +0 -1
- package/dist/chunk-M7BPQ54D.js.map +0 -1
- package/dist/chunk-PXVDVUFX.js.map +0 -1
- package/dist/chunk-PXZ737N3.js +0 -439
- package/dist/chunk-PXZ737N3.js.map +0 -1
- package/dist/chunk-XMTWFJCZ.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { getCartFormInput, createAnalyticsBus, createPixelTransport } from './chunk-
|
|
2
|
-
export { useNonce } from './chunk-
|
|
1
|
+
import { getCartFormInput, createAnalyticsBus, collectAnalyticsAttribution, createPixelTransport } from './chunk-RFM27BKZ.js';
|
|
2
|
+
export { useNonce } from './chunk-RFM27BKZ.js';
|
|
3
3
|
import { getPaginationInfo } from './chunk-5QOFKGKD.js';
|
|
4
4
|
import { CART_FORM_ACTIONS, GRANTED_CONSENT, CONSENT_COOKIE, readConsentCookie, mergeConsent, buildConsentCookie } from './chunk-OGWYTYYS.js';
|
|
5
|
-
import { getSeoMeta, serializeJsonLd } from './chunk-
|
|
6
|
-
export { REACT_SEAM_CART_DOCUMENTS, createStorefrontApiCartAdapter } from './chunk-
|
|
5
|
+
import { getSeoMeta, serializeJsonLd } from './chunk-SVMYFYIA.js';
|
|
6
|
+
export { REACT_SEAM_CART_DOCUMENTS, createStorefrontApiCartAdapter } from './chunk-WNXI3MPM.js';
|
|
7
|
+
import { resolveHydrogenEditorStyles } from './chunk-XXNCFWXT.js';
|
|
7
8
|
export { StorefrontForm, StorefrontFormFields } from './chunk-VV653S52.js';
|
|
8
9
|
import './chunk-IIOHENCG.js';
|
|
9
10
|
import { buildImageAttrs } from './chunk-3YQXJNR7.js';
|
|
10
|
-
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useContext, useSyncExternalStore } from 'react';
|
|
11
|
+
import { createContext, useState, useRef, useMemo, useEffect, useCallback, useContext, useSyncExternalStore, Children, isValidElement, cloneElement, createElement } from 'react';
|
|
11
12
|
import { useFetcher } from 'react-router';
|
|
12
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
13
14
|
|
|
@@ -37,6 +38,22 @@ function OptimisticInput({ id, data }) {
|
|
|
37
38
|
function useOptimisticData(_id) {
|
|
38
39
|
return void 0;
|
|
39
40
|
}
|
|
41
|
+
|
|
42
|
+
// src/analytics/anonymous-context.ts
|
|
43
|
+
function anonymousPageContext(candidateUrl, currentUrl) {
|
|
44
|
+
if (!candidateUrl || !currentUrl) return {};
|
|
45
|
+
try {
|
|
46
|
+
const current = new URL(currentUrl);
|
|
47
|
+
const candidate = new URL(candidateUrl, current);
|
|
48
|
+
if (!["http:", "https:"].includes(current.protocol)) return {};
|
|
49
|
+
if (!["http:", "https:"].includes(candidate.protocol)) return {};
|
|
50
|
+
if (candidate.origin !== current.origin) return {};
|
|
51
|
+
const pathname = /^\/checkout(?:\/|$)/.test(candidate.pathname) ? "/checkout" : candidate.pathname || "/";
|
|
52
|
+
return { url: `${candidate.origin}${pathname}` };
|
|
53
|
+
} catch {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
40
57
|
var beaconSend = (endpoint, body) => {
|
|
41
58
|
if (typeof navigator !== "undefined" && typeof navigator.sendBeacon === "function") {
|
|
42
59
|
if (navigator.sendBeacon(endpoint, new Blob([body], { type: "application/json" }))) return;
|
|
@@ -57,12 +74,21 @@ function AnalyticsProvider(props) {
|
|
|
57
74
|
const [mounted, setMounted] = useState(false);
|
|
58
75
|
const consentRef = useRef(consent);
|
|
59
76
|
consentRef.current = consent;
|
|
77
|
+
const pageUrlRef = useRef(props.url);
|
|
78
|
+
pageUrlRef.current = props.url;
|
|
60
79
|
const contextRef = useRef({});
|
|
61
80
|
const shopId = props.shopId ?? props.shop?.shopId ?? props.shop?.storefrontId;
|
|
81
|
+
const browserUrl = typeof window === "undefined" ? void 0 : (() => {
|
|
82
|
+
try {
|
|
83
|
+
return new URL(props.url ?? window.location.href, window.location.href).href;
|
|
84
|
+
} catch {
|
|
85
|
+
return props.url;
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
62
88
|
contextRef.current = {
|
|
63
89
|
...shopId !== void 0 ? { shopId } : {},
|
|
64
90
|
...props.geo !== void 0 ? { geo: props.geo } : {},
|
|
65
|
-
...props.url !== void 0 ? { url: props.url } : {}
|
|
91
|
+
...browserUrl !== void 0 ? { url: browserUrl } : props.url !== void 0 ? { url: props.url } : {}
|
|
66
92
|
};
|
|
67
93
|
const endpointRef = useRef(props.pixelEndpoint);
|
|
68
94
|
const bus = useMemo(
|
|
@@ -72,7 +98,25 @@ function AnalyticsProvider(props) {
|
|
|
72
98
|
...endpointRef.current !== void 0 ? { endpoint: endpointRef.current } : {}
|
|
73
99
|
}),
|
|
74
100
|
getConsent: () => consentRef.current,
|
|
75
|
-
|
|
101
|
+
getAnonymousContext: () => {
|
|
102
|
+
if (typeof window === "undefined") return {};
|
|
103
|
+
return anonymousPageContext(
|
|
104
|
+
pageUrlRef.current ?? window.location.href,
|
|
105
|
+
window.location.href
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
// createAnalyticsBus calls this only after an explicit analytics grant. Keep every browser
|
|
109
|
+
// attribution/device read inside this lazy seam so denied visits never evaluate it.
|
|
110
|
+
getContext: () => ({
|
|
111
|
+
...collectAnalyticsAttribution(
|
|
112
|
+
typeof window === "undefined" || typeof document === "undefined" ? null : {
|
|
113
|
+
referrer: document.referrer,
|
|
114
|
+
search: window.location.search,
|
|
115
|
+
...typeof window.matchMedia === "function" ? { matchMedia: (query) => window.matchMedia(query) } : {}
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
...contextRef.current
|
|
119
|
+
})
|
|
76
120
|
}),
|
|
77
121
|
[]
|
|
78
122
|
);
|
|
@@ -144,13 +188,22 @@ function AnalyticsProductView({ data }) {
|
|
|
144
188
|
const product = data?.products?.[0];
|
|
145
189
|
const productId = product?.productId ?? product?.id ?? null;
|
|
146
190
|
const handle = product?.handle ?? void 0;
|
|
191
|
+
const price = product?.price == null ? void 0 : Number(product.price);
|
|
147
192
|
const payload = useMemo(() => {
|
|
148
193
|
if (productId == null) return null;
|
|
149
194
|
return {
|
|
150
195
|
productId,
|
|
151
|
-
...handle != null ? { handle } : {}
|
|
196
|
+
...handle != null ? { handle } : {},
|
|
197
|
+
...product?.variantId != null ? { variantId: product.variantId } : {},
|
|
198
|
+
...product?.title != null ? { title: product.title } : {},
|
|
199
|
+
...product?.variantTitle != null ? { variantTitle: product.variantTitle } : {},
|
|
200
|
+
...product?.vendor != null ? { vendor: product.vendor } : {},
|
|
201
|
+
...product?.sku != null ? { sku: product.sku } : {},
|
|
202
|
+
...price !== void 0 && Number.isFinite(price) ? { price } : {},
|
|
203
|
+
...product?.currency != null ? { currency: product.currency } : {},
|
|
204
|
+
...product?.quantity != null ? { quantity: product.quantity } : {}
|
|
152
205
|
};
|
|
153
|
-
}, [handle, productId]);
|
|
206
|
+
}, [handle, price, product, productId]);
|
|
154
207
|
usePublishAnalytics("product_viewed", payload);
|
|
155
208
|
return null;
|
|
156
209
|
}
|
|
@@ -1948,7 +2001,223 @@ function CartDrawerOverlay({ config, adapter }) {
|
|
|
1948
2001
|
}, [config, adapter]);
|
|
1949
2002
|
return null;
|
|
1950
2003
|
}
|
|
2004
|
+
var HydrogenEditorReactContext = createContext(null);
|
|
2005
|
+
var HYDROGEN_CANVAS_INTENT_EVENT = "kotao:hydrogen-canvas-intent";
|
|
2006
|
+
var HYDROGEN_CANVAS_RESULT_EVENT = "kotao:hydrogen-canvas-result";
|
|
2007
|
+
var HYDROGEN_CANVAS_STATE_EVENT = "kotao:hydrogen-canvas-state";
|
|
2008
|
+
var HYDROGEN_CANVAS_STATE_REQUEST_EVENT = "kotao:hydrogen-canvas-state-request";
|
|
2009
|
+
function useHydrogenEditorCanvasEvents(preview) {
|
|
2010
|
+
const snapshot = useSyncExternalStore(
|
|
2011
|
+
(listener) => preview.store.subscribe(listener),
|
|
2012
|
+
() => preview.store.getSnapshot(),
|
|
2013
|
+
() => preview.store.getSnapshot()
|
|
2014
|
+
);
|
|
2015
|
+
useEffect(() => {
|
|
2016
|
+
if (typeof document === "undefined" || typeof CustomEvent === "undefined") return;
|
|
2017
|
+
const dispatchState = () => {
|
|
2018
|
+
document.dispatchEvent(
|
|
2019
|
+
new CustomEvent(HYDROGEN_CANVAS_STATE_EVENT, {
|
|
2020
|
+
detail: {
|
|
2021
|
+
selectedInstanceId: snapshot.selectedInstanceId,
|
|
2022
|
+
hoveredInstanceId: snapshot.hoveredInstanceId,
|
|
2023
|
+
selectionStatus: snapshot.selectionStatus,
|
|
2024
|
+
revision: snapshot.revision
|
|
2025
|
+
}
|
|
2026
|
+
})
|
|
2027
|
+
);
|
|
2028
|
+
};
|
|
2029
|
+
dispatchState();
|
|
2030
|
+
document.addEventListener(HYDROGEN_CANVAS_STATE_REQUEST_EVENT, dispatchState);
|
|
2031
|
+
return () => document.removeEventListener(HYDROGEN_CANVAS_STATE_REQUEST_EVENT, dispatchState);
|
|
2032
|
+
}, [
|
|
2033
|
+
snapshot.hoveredInstanceId,
|
|
2034
|
+
snapshot.revision,
|
|
2035
|
+
snapshot.selectedInstanceId,
|
|
2036
|
+
snapshot.selectionStatus
|
|
2037
|
+
]);
|
|
2038
|
+
useEffect(() => {
|
|
2039
|
+
if (typeof document === "undefined" || typeof CustomEvent === "undefined") return;
|
|
2040
|
+
const onIntent = (event) => {
|
|
2041
|
+
if (!(event instanceof CustomEvent)) return;
|
|
2042
|
+
const result = preview.dispatchCanvasIntent(event.detail);
|
|
2043
|
+
document.dispatchEvent(new CustomEvent(HYDROGEN_CANVAS_RESULT_EVENT, { detail: result }));
|
|
2044
|
+
};
|
|
2045
|
+
document.addEventListener(HYDROGEN_CANVAS_INTENT_EVENT, onIntent);
|
|
2046
|
+
return () => document.removeEventListener(HYDROGEN_CANVAS_INTENT_EVENT, onIntent);
|
|
2047
|
+
}, [preview]);
|
|
2048
|
+
}
|
|
2049
|
+
function HydrogenEditorProvider({
|
|
2050
|
+
children,
|
|
2051
|
+
components = {},
|
|
2052
|
+
documentId,
|
|
2053
|
+
preview,
|
|
2054
|
+
reconciliationKey,
|
|
2055
|
+
reconciliationReason = "route",
|
|
2056
|
+
route,
|
|
2057
|
+
viewportWidth
|
|
2058
|
+
}) {
|
|
2059
|
+
useHydrogenEditorCanvasEvents(preview);
|
|
2060
|
+
const value = useMemo(
|
|
2061
|
+
() => ({
|
|
2062
|
+
preview,
|
|
2063
|
+
components,
|
|
2064
|
+
...viewportWidth !== void 0 ? { viewportWidth } : {}
|
|
2065
|
+
}),
|
|
2066
|
+
[components, preview, viewportWidth]
|
|
2067
|
+
);
|
|
2068
|
+
useEffect(() => {
|
|
2069
|
+
preview.reconcile(documentId, reconciliationReason, route);
|
|
2070
|
+
preview.ready();
|
|
2071
|
+
}, [documentId, preview, reconciliationKey, reconciliationReason, route]);
|
|
2072
|
+
return /* @__PURE__ */ jsx(HydrogenEditorReactContext.Provider, { value, children });
|
|
2073
|
+
}
|
|
2074
|
+
function useHydrogenEditorContext() {
|
|
2075
|
+
const context = useContext(HydrogenEditorReactContext);
|
|
2076
|
+
if (context === null) {
|
|
2077
|
+
throw new Error("Hydrogen editor hooks must be rendered inside HydrogenEditorProvider");
|
|
2078
|
+
}
|
|
2079
|
+
return context;
|
|
2080
|
+
}
|
|
2081
|
+
function useInstanceSnapshot(instanceId) {
|
|
2082
|
+
const { preview } = useHydrogenEditorContext();
|
|
2083
|
+
return useSyncExternalStore(
|
|
2084
|
+
(listener) => preview.store.subscribeInstance(instanceId, listener),
|
|
2085
|
+
() => preview.store.getInstanceSnapshot(instanceId),
|
|
2086
|
+
() => preview.store.getInstanceSnapshot(instanceId)
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
function useHydrogenEditorInstance(instanceId, sourceProps = {}) {
|
|
2090
|
+
const { preview, viewportWidth } = useHydrogenEditorContext();
|
|
2091
|
+
const snapshot = useInstanceSnapshot(instanceId);
|
|
2092
|
+
return useMemo(() => {
|
|
2093
|
+
if (snapshot === null) return null;
|
|
2094
|
+
return {
|
|
2095
|
+
snapshot,
|
|
2096
|
+
props: { ...sourceProps, ...snapshot.resolvedProps },
|
|
2097
|
+
styles: resolveHydrogenEditorStyles(preview.manifest, snapshot.instance, viewportWidth)
|
|
2098
|
+
};
|
|
2099
|
+
}, [preview.manifest, snapshot, sourceProps, viewportWidth]);
|
|
2100
|
+
}
|
|
2101
|
+
function useHydrogenEditorSlot(parentInstanceId, slotId) {
|
|
2102
|
+
const snapshot = useInstanceSnapshot(parentInstanceId);
|
|
2103
|
+
return snapshot?.childInstanceIds[slotId] ?? [];
|
|
2104
|
+
}
|
|
2105
|
+
function HydrogenEditorBoundary({
|
|
2106
|
+
applyPreviewProps = true,
|
|
2107
|
+
children,
|
|
2108
|
+
instanceId,
|
|
2109
|
+
viewportWidth
|
|
2110
|
+
}) {
|
|
2111
|
+
const { preview, viewportWidth: contextViewportWidth } = useHydrogenEditorContext();
|
|
2112
|
+
const snapshot = useInstanceSnapshot(instanceId);
|
|
2113
|
+
useEffect(() => preview.registerInstance(instanceId), [instanceId, preview]);
|
|
2114
|
+
if (snapshot === null) return null;
|
|
2115
|
+
const child = Children.only(children);
|
|
2116
|
+
if (!isValidElement(child)) return null;
|
|
2117
|
+
const effectiveViewportWidth = viewportWidth ?? contextViewportWidth;
|
|
2118
|
+
const previewProps = applyPreviewProps ? snapshot.resolvedProps : {};
|
|
2119
|
+
const childStyle = isRecordStyle(child.props.style) ? child.props.style : {};
|
|
2120
|
+
const previewStyle = applyPreviewProps ? resolveHydrogenEditorStyles(preview.manifest, snapshot.instance, effectiveViewportWidth) : {};
|
|
2121
|
+
const renderedChild = cloneElement(child, {
|
|
2122
|
+
...previewProps,
|
|
2123
|
+
...Object.keys(previewStyle).length > 0 ? { style: { ...childStyle, ...previewStyle } } : {}
|
|
2124
|
+
});
|
|
2125
|
+
const blockingReason = snapshot.capabilityReasons.find((reason) => reason.severity === "blocking");
|
|
2126
|
+
const inlineProps = snapshot.component.props.filter(
|
|
2127
|
+
(control) => control.allowedBindings.includes("inline") && (snapshot.instance.props[control.propName] ?? control.defaultBinding)?.kind !== "external" && (control.control === "text" || control.control === "textarea" || control.control === "richtext")
|
|
2128
|
+
).map((control) => ({ propName: control.propName, label: control.label }));
|
|
2129
|
+
const layoutControls = snapshot.component.styles.layout.filter((control) => ["gap", "height", "margin", "padding", "width"].includes(control.control)).map((control) => ({
|
|
2130
|
+
controlId: control.controlId,
|
|
2131
|
+
control: control.control,
|
|
2132
|
+
label: control.label,
|
|
2133
|
+
allowedValues: control.allowedValues
|
|
2134
|
+
}));
|
|
2135
|
+
const onPointerEnter = (_event) => {
|
|
2136
|
+
preview.hoverInstance(instanceId);
|
|
2137
|
+
};
|
|
2138
|
+
const onPointerLeave = (_event) => {
|
|
2139
|
+
preview.hoverInstance(null);
|
|
2140
|
+
};
|
|
2141
|
+
const onClick = (event) => {
|
|
2142
|
+
event.preventDefault();
|
|
2143
|
+
event.stopPropagation();
|
|
2144
|
+
preview.selectInstance(instanceId);
|
|
2145
|
+
};
|
|
2146
|
+
return /* @__PURE__ */ jsx(
|
|
2147
|
+
"span",
|
|
2148
|
+
{
|
|
2149
|
+
"data-kotao-hydrogen-capability": snapshot.editable ? "editable" : "read-only",
|
|
2150
|
+
"data-kotao-hydrogen-capabilities": snapshot.component.capabilities.join(" "),
|
|
2151
|
+
"data-kotao-hydrogen-component": snapshot.component.componentId,
|
|
2152
|
+
"data-kotao-hydrogen-instance": instanceId,
|
|
2153
|
+
"data-kotao-hydrogen-inline-props": JSON.stringify(inlineProps),
|
|
2154
|
+
"data-kotao-hydrogen-label": snapshot.component.name,
|
|
2155
|
+
"data-kotao-hydrogen-layout-controls": JSON.stringify(layoutControls),
|
|
2156
|
+
"data-kotao-hydrogen-reason": blockingReason?.code,
|
|
2157
|
+
onClick,
|
|
2158
|
+
onPointerEnter,
|
|
2159
|
+
onPointerLeave,
|
|
2160
|
+
style: { display: "contents" },
|
|
2161
|
+
children: renderedChild
|
|
2162
|
+
}
|
|
2163
|
+
);
|
|
2164
|
+
}
|
|
2165
|
+
function isRecordStyle(value) {
|
|
2166
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2167
|
+
}
|
|
2168
|
+
function HydrogenEditorRegisteredInstance({
|
|
2169
|
+
instanceId
|
|
2170
|
+
}) {
|
|
2171
|
+
const { components } = useHydrogenEditorContext();
|
|
2172
|
+
const instance = useHydrogenEditorInstance(instanceId);
|
|
2173
|
+
if (instance === null) return null;
|
|
2174
|
+
const Component = components[instance.snapshot.component.componentId];
|
|
2175
|
+
if (Component === void 0) {
|
|
2176
|
+
return /* @__PURE__ */ jsx(
|
|
2177
|
+
"span",
|
|
2178
|
+
{
|
|
2179
|
+
"data-kotao-hydrogen-instance": instanceId,
|
|
2180
|
+
"data-kotao-hydrogen-reason": "COMPONENT_RENDERER_UNAVAILABLE",
|
|
2181
|
+
style: { display: "contents" }
|
|
2182
|
+
}
|
|
2183
|
+
);
|
|
2184
|
+
}
|
|
2185
|
+
return /* @__PURE__ */ jsx(HydrogenEditorBoundary, { applyPreviewProps: false, instanceId, children: createElement(Component, {
|
|
2186
|
+
instanceId,
|
|
2187
|
+
props: instance.props,
|
|
2188
|
+
styles: instance.styles,
|
|
2189
|
+
slots: instance.snapshot.childInstanceIds,
|
|
2190
|
+
...instance.snapshot.instance.variantId !== void 0 ? { variantId: instance.snapshot.instance.variantId } : {}
|
|
2191
|
+
}) });
|
|
2192
|
+
}
|
|
2193
|
+
function HydrogenEditorSlot({
|
|
2194
|
+
empty = null,
|
|
2195
|
+
existingChildren = {},
|
|
2196
|
+
parentInstanceId,
|
|
2197
|
+
slotId
|
|
2198
|
+
}) {
|
|
2199
|
+
const parent = useInstanceSnapshot(parentInstanceId);
|
|
2200
|
+
const instanceIds = useHydrogenEditorSlot(parentInstanceId, slotId);
|
|
2201
|
+
const slot = parent?.component.slots.find((candidate) => candidate.slotId === slotId);
|
|
2202
|
+
return /* @__PURE__ */ jsx(
|
|
2203
|
+
"span",
|
|
2204
|
+
{
|
|
2205
|
+
"data-kotao-hydrogen-slot": slotId,
|
|
2206
|
+
"data-kotao-hydrogen-slot-accepts": slot?.accepts.mode === "any" ? "*" : slot?.accepts.componentIds.join(" ") ?? "",
|
|
2207
|
+
"data-kotao-hydrogen-slot-count": instanceIds.length,
|
|
2208
|
+
"data-kotao-hydrogen-slot-insertion": slot?.insertion ?? "fixed",
|
|
2209
|
+
"data-kotao-hydrogen-slot-label": slot?.label ?? slotId,
|
|
2210
|
+
"data-kotao-hydrogen-slot-max": slot?.maxInstances ?? 0,
|
|
2211
|
+
"data-kotao-hydrogen-slot-parent": parentInstanceId,
|
|
2212
|
+
style: { display: "contents" },
|
|
2213
|
+
children: instanceIds.length === 0 ? empty : instanceIds.map((instanceId) => {
|
|
2214
|
+
const existing = existingChildren[instanceId];
|
|
2215
|
+
return existing === void 0 ? /* @__PURE__ */ jsx(HydrogenEditorRegisteredInstance, { instanceId }, instanceId) : /* @__PURE__ */ jsx(HydrogenEditorBoundary, { instanceId, children: existing }, instanceId);
|
|
2216
|
+
})
|
|
2217
|
+
}
|
|
2218
|
+
);
|
|
2219
|
+
}
|
|
1951
2220
|
|
|
1952
|
-
export { Analytics, AnalyticsCartView, AnalyticsCollectionView, AnalyticsProductView, AnalyticsProvider, AnalyticsSearchView, CartDrawerOverlay, CartForm, ConsentBanner, Image, MediaFile, Money, OptimisticInput, Pagination, Seo, ShopPayButton, ThemeSettingsProvider, openSmartCart, useAnalytics, useGlobalThemeTokens, useMoney, useOptimisticData, useSectionSettings, useThemeSettings };
|
|
2221
|
+
export { Analytics, AnalyticsCartView, AnalyticsCollectionView, AnalyticsProductView, AnalyticsProvider, AnalyticsSearchView, CartDrawerOverlay, CartForm, ConsentBanner, HydrogenEditorBoundary, HydrogenEditorProvider, HydrogenEditorSlot, Image, MediaFile, Money, OptimisticInput, Pagination, Seo, ShopPayButton, ThemeSettingsProvider, openSmartCart, useAnalytics, useGlobalThemeTokens, useHydrogenEditorInstance, useHydrogenEditorSlot, useMoney, useOptimisticData, useSectionSettings, useThemeSettings };
|
|
1953
2222
|
//# sourceMappingURL=react.js.map
|
|
1954
2223
|
//# sourceMappingURL=react.js.map
|