@fragmentsx/render-web 0.1.2 → 0.1.4
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/dist/index.cjs.js +118 -32
- package/dist/index.es.js +118 -32
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -734,6 +734,7 @@ const renderMode$1 = createConstants$1("viewport", "parent", "fixed");
|
|
|
734
734
|
const interactions$1 = createConstants$1("click", "mouseover", "appear");
|
|
735
735
|
const eventMode$1 = createConstants$1("goal", "callback", "tracker");
|
|
736
736
|
const scopeTypes$1 = createConstants$1(
|
|
737
|
+
"AreaScope",
|
|
737
738
|
"InstanceScope",
|
|
738
739
|
"FragmentScope",
|
|
739
740
|
"CollectionScope",
|
|
@@ -1578,7 +1579,8 @@ const SceneSchema$1 = /* @__PURE__ */ object$1({
|
|
|
1578
1579
|
}),
|
|
1579
1580
|
visible: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: true, variable: true }),
|
|
1580
1581
|
rotate: layerField$1(/* @__PURE__ */ number$1(), { fallback: null }),
|
|
1581
|
-
zIndex: layerField$1(/* @__PURE__ */ number$1(), { fallback:
|
|
1582
|
+
zIndex: layerField$1(/* @__PURE__ */ number$1(), { fallback: null }),
|
|
1583
|
+
classnames: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ number$1()), { fallback: [] })
|
|
1582
1584
|
});
|
|
1583
1585
|
const FillSchema$1 = /* @__PURE__ */ object$1({
|
|
1584
1586
|
fillType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(paintMode$1)), {
|
|
@@ -1725,7 +1727,7 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
|
|
|
1725
1727
|
fallback: ""
|
|
1726
1728
|
}),
|
|
1727
1729
|
whiteSpace: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(whiteSpace$1)), {
|
|
1728
|
-
fallback: whiteSpace$1.
|
|
1730
|
+
fallback: whiteSpace$1.normal
|
|
1729
1731
|
}),
|
|
1730
1732
|
textAlign: layerField$1(/* @__PURE__ */ string$1(), { fallback: "left" }),
|
|
1731
1733
|
parent: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ string$1()), { overridable: false }),
|
|
@@ -1847,6 +1849,7 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
|
|
|
1847
1849
|
required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
|
|
1848
1850
|
placeholder: layerField$1(/* @__PURE__ */ string$1(), { fallback: "" }),
|
|
1849
1851
|
isTextarea: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
|
|
1852
|
+
isRich: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
|
|
1850
1853
|
...GraphFieldSchema$1.entries
|
|
1851
1854
|
});
|
|
1852
1855
|
/* @__PURE__ */ object$1({
|
|
@@ -2058,6 +2061,8 @@ var isBrowser_default$1 = typeof window !== "undefined";
|
|
|
2058
2061
|
var getKey$1 = (v2) => isKey$1(v2) ? v2.slice(1) : null;
|
|
2059
2062
|
var isKey$1 = (v2) => typeof v2 === "string" && v2.startsWith("$");
|
|
2060
2063
|
function hashGenerator$1(layerKey) {
|
|
2064
|
+
if (!(layerKey == null ? void 0 : layerKey.length))
|
|
2065
|
+
return layerKey;
|
|
2061
2066
|
let hash = 0;
|
|
2062
2067
|
for (let i2 = 0; i2 < layerKey.length; i2++) {
|
|
2063
2068
|
hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
|
|
@@ -2083,9 +2088,12 @@ const getAreaListQuery = (areaCodes) => {
|
|
|
2083
2088
|
return {
|
|
2084
2089
|
query: `query($areaCodes: [String!]!) {
|
|
2085
2090
|
clientAreas(areaCodes: $areaCodes) {
|
|
2091
|
+
areaId
|
|
2092
|
+
campaignId
|
|
2086
2093
|
areaProperties
|
|
2087
2094
|
projectProperties
|
|
2088
2095
|
variant {
|
|
2096
|
+
id
|
|
2089
2097
|
fragment {
|
|
2090
2098
|
props
|
|
2091
2099
|
fragment {
|
|
@@ -2199,6 +2207,9 @@ const fetchPlugin = (state) => {
|
|
|
2199
2207
|
return acc;
|
|
2200
2208
|
}, area.variant.fragment.props);
|
|
2201
2209
|
const entity = {
|
|
2210
|
+
areaId: area.areaId,
|
|
2211
|
+
campaignId: area.campaignId,
|
|
2212
|
+
variantId: area.variant.id,
|
|
2202
2213
|
fragmentId: area.variant.fragment.fragment.id,
|
|
2203
2214
|
props: resultProps
|
|
2204
2215
|
};
|
|
@@ -2291,10 +2302,14 @@ const makeCss = (styles2, layerResolver) => (layerKey) => {
|
|
|
2291
2302
|
};
|
|
2292
2303
|
};
|
|
2293
2304
|
const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
2305
|
+
let countDepends = 0;
|
|
2294
2306
|
const removeStyle = () => {
|
|
2295
2307
|
if (!isBrowser_default$1) return;
|
|
2296
|
-
|
|
2297
|
-
if (
|
|
2308
|
+
countDepends--;
|
|
2309
|
+
if (countDepends <= 0) {
|
|
2310
|
+
const el = document.getElementById(key);
|
|
2311
|
+
if (el) el.remove();
|
|
2312
|
+
}
|
|
2298
2313
|
};
|
|
2299
2314
|
const injectStyle = (styles2) => {
|
|
2300
2315
|
if (!isBrowser_default$1) return;
|
|
@@ -2302,6 +2317,7 @@ const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
|
2302
2317
|
removeStyle();
|
|
2303
2318
|
return;
|
|
2304
2319
|
}
|
|
2320
|
+
countDepends++;
|
|
2305
2321
|
const existing = document.getElementById(key);
|
|
2306
2322
|
if (existing && existing.tagName === "STYLE") {
|
|
2307
2323
|
existing.textContent = styles2;
|
|
@@ -2330,6 +2346,7 @@ const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
|
2330
2346
|
const mount = () => {
|
|
2331
2347
|
isMounted = true;
|
|
2332
2348
|
if (pendingStyles) {
|
|
2349
|
+
countDepends++;
|
|
2333
2350
|
injectStyle(pendingStyles);
|
|
2334
2351
|
} else {
|
|
2335
2352
|
removeStyle();
|
|
@@ -2534,6 +2551,7 @@ const fragmentsPlugin = (options) => (state) => {
|
|
|
2534
2551
|
[fragmentId]: manager
|
|
2535
2552
|
}
|
|
2536
2553
|
});
|
|
2554
|
+
return manager;
|
|
2537
2555
|
};
|
|
2538
2556
|
const getManager = (fragmentId) => {
|
|
2539
2557
|
var _a, _b;
|
|
@@ -2556,8 +2574,8 @@ const fragmentsPlugin = (options) => (state) => {
|
|
|
2556
2574
|
});
|
|
2557
2575
|
return state;
|
|
2558
2576
|
};
|
|
2559
|
-
const addClientMetric = `mutation AddClientMetric($type: ClientMetricType!, $value:
|
|
2560
|
-
addClientMetric(metric: {metricType: $type,
|
|
2577
|
+
const addClientMetric = `mutation AddClientMetric($type: ClientMetricType!, $value: GoalAchievementPost!) {
|
|
2578
|
+
addClientMetric(metric: {metricType: $type, achievement: $value})
|
|
2561
2579
|
}`;
|
|
2562
2580
|
const pendingPixels = /* @__PURE__ */ new Set();
|
|
2563
2581
|
const sendWithImage = (url) => {
|
|
@@ -3519,6 +3537,7 @@ const renderMode = createConstants("viewport", "parent", "fixed");
|
|
|
3519
3537
|
const interactions = createConstants("click", "mouseover", "appear");
|
|
3520
3538
|
const eventMode = createConstants("goal", "callback", "tracker");
|
|
3521
3539
|
const scopeTypes = createConstants(
|
|
3540
|
+
"AreaScope",
|
|
3522
3541
|
"InstanceScope",
|
|
3523
3542
|
"FragmentScope",
|
|
3524
3543
|
"CollectionScope",
|
|
@@ -4409,7 +4428,8 @@ const SceneSchema = /* @__PURE__ */ object({
|
|
|
4409
4428
|
}),
|
|
4410
4429
|
visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
|
|
4411
4430
|
rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
4412
|
-
zIndex: layerField(/* @__PURE__ */ number(), { fallback:
|
|
4431
|
+
zIndex: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
4432
|
+
classnames: layerField(/* @__PURE__ */ array(/* @__PURE__ */ number()), { fallback: [] })
|
|
4413
4433
|
});
|
|
4414
4434
|
const FillSchema = /* @__PURE__ */ object({
|
|
4415
4435
|
fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
|
|
@@ -4556,7 +4576,7 @@ const TextSchema = /* @__PURE__ */ object({
|
|
|
4556
4576
|
fallback: ""
|
|
4557
4577
|
}),
|
|
4558
4578
|
whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
|
|
4559
|
-
fallback: whiteSpace.
|
|
4579
|
+
fallback: whiteSpace.normal
|
|
4560
4580
|
}),
|
|
4561
4581
|
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
|
|
4562
4582
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
@@ -4678,6 +4698,7 @@ const StringVariableSchema = /* @__PURE__ */ object({
|
|
|
4678
4698
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
4679
4699
|
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
4680
4700
|
isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
4701
|
+
isRich: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
4681
4702
|
...GraphFieldSchema.entries
|
|
4682
4703
|
});
|
|
4683
4704
|
const EventVariableSchema = /* @__PURE__ */ object({
|
|
@@ -5165,6 +5186,8 @@ function isFiniteNumber(value) {
|
|
|
5165
5186
|
return typeof value === "number" && isFinite(value);
|
|
5166
5187
|
}
|
|
5167
5188
|
function hashGenerator(layerKey) {
|
|
5189
|
+
if (!(layerKey == null ? void 0 : layerKey.length))
|
|
5190
|
+
return layerKey;
|
|
5168
5191
|
let hash = 0;
|
|
5169
5192
|
for (let i2 = 0; i2 < layerKey.length; i2++) {
|
|
5170
5193
|
hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
|
|
@@ -5201,7 +5224,7 @@ const useGlobalManager = (globalManager) => {
|
|
|
5201
5224
|
setRenderTarget
|
|
5202
5225
|
};
|
|
5203
5226
|
};
|
|
5204
|
-
const useFragmentManager = (fragmentId, inputGlobalManager
|
|
5227
|
+
const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
5205
5228
|
var _a;
|
|
5206
5229
|
const {
|
|
5207
5230
|
fragmentsGraph,
|
|
@@ -5601,7 +5624,7 @@ const useLayerSizeValue = (layerKey, sizeType) => {
|
|
|
5601
5624
|
return "100%";
|
|
5602
5625
|
}
|
|
5603
5626
|
if (autoSizes.includes(valueType)) {
|
|
5604
|
-
return layerNode._type === index.nodes.Instance ? "auto" : "
|
|
5627
|
+
return layerNode._type === index.nodes.Instance ? "auto" : "fit-content";
|
|
5605
5628
|
}
|
|
5606
5629
|
if (valueType === index.sizing.Relative) {
|
|
5607
5630
|
return `${value}%`;
|
|
@@ -5679,13 +5702,14 @@ const useLayerBackground = (layerKey) => {
|
|
|
5679
5702
|
"solidFill",
|
|
5680
5703
|
fragmentManager
|
|
5681
5704
|
);
|
|
5682
|
-
const [imageFill, ,
|
|
5705
|
+
const [imageFill, , cssImageFillOptions] = useLayerValue(
|
|
5683
5706
|
layerKey,
|
|
5684
5707
|
"imageFill",
|
|
5685
5708
|
fragmentManager
|
|
5686
5709
|
);
|
|
5710
|
+
const imageSizeLayerKey = (cssImageFillOptions == null ? void 0 : cssImageFillOptions.isVariable) ? cssImageFillOptions == null ? void 0 : cssImageFillOptions.rawValue : layerKey;
|
|
5687
5711
|
const [, , { cssVariableValue: cssImageSize }] = useLayerValue(
|
|
5688
|
-
|
|
5712
|
+
imageSizeLayerKey,
|
|
5689
5713
|
"imageSize",
|
|
5690
5714
|
fragmentManager
|
|
5691
5715
|
);
|
|
@@ -5695,7 +5719,7 @@ const useLayerBackground = (layerKey) => {
|
|
|
5695
5719
|
background: cssSolidFill
|
|
5696
5720
|
};
|
|
5697
5721
|
}
|
|
5698
|
-
if (fillType === index.paintMode.Image &&
|
|
5722
|
+
if (fillType === index.paintMode.Image && cssImageFillOptions.cssVariableValue) {
|
|
5699
5723
|
return {
|
|
5700
5724
|
background: `url(${imageFill})`,
|
|
5701
5725
|
backgroundSize: cssImageSize == null ? void 0 : cssImageSize.toLowerCase(),
|
|
@@ -5705,7 +5729,12 @@ const useLayerBackground = (layerKey) => {
|
|
|
5705
5729
|
return {
|
|
5706
5730
|
background: "transparent"
|
|
5707
5731
|
};
|
|
5708
|
-
}, [
|
|
5732
|
+
}, [
|
|
5733
|
+
fillType,
|
|
5734
|
+
cssImageFillOptions.cssVariableValue,
|
|
5735
|
+
cssSolidFill,
|
|
5736
|
+
cssImageSize
|
|
5737
|
+
]);
|
|
5709
5738
|
};
|
|
5710
5739
|
const useLayerDisplay = (layerKey) => {
|
|
5711
5740
|
const { manager } = x$2(FragmentContext);
|
|
@@ -5758,7 +5787,11 @@ const useCalcLayerBorder = (layerKey) => {
|
|
|
5758
5787
|
const useLayerBorder = (layerKey) => {
|
|
5759
5788
|
const { manager: fragmentManager } = x$2(FragmentContext);
|
|
5760
5789
|
const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
|
|
5761
|
-
const [borderColor] = useLayerValue(
|
|
5790
|
+
const [, , { cssVariableValue: borderColor }] = useLayerValue(
|
|
5791
|
+
layerKey,
|
|
5792
|
+
"borderColor",
|
|
5793
|
+
fragmentManager
|
|
5794
|
+
);
|
|
5762
5795
|
const calcBorder = useCalcLayerBorder(layerKey);
|
|
5763
5796
|
return T$1(
|
|
5764
5797
|
() => calcBorder(borderWidth, borderColor),
|
|
@@ -5839,12 +5872,14 @@ const useLayerStyles = (layerKey) => {
|
|
|
5839
5872
|
);
|
|
5840
5873
|
const [whiteSpace2] = useLayerValue(layerKey, "whiteSpace", fragmentManager);
|
|
5841
5874
|
const textStyles = useLayerTextStyles(layerKey);
|
|
5875
|
+
const [overflow2] = useLayerValue(layerKey, "overflow", fragmentManager);
|
|
5842
5876
|
return {
|
|
5843
5877
|
// ...(props ?? {}),
|
|
5844
5878
|
...border,
|
|
5845
5879
|
...background,
|
|
5846
5880
|
...position,
|
|
5847
5881
|
opacity,
|
|
5882
|
+
overflow: overflow2,
|
|
5848
5883
|
rotate: isValue(rotate) ? `${rotate}deg` : null,
|
|
5849
5884
|
"border-radius": borderRadius,
|
|
5850
5885
|
"white-space": whiteSpace2,
|
|
@@ -5869,12 +5904,6 @@ const useFragmentProperties = (fragmentId) => {
|
|
|
5869
5904
|
manager
|
|
5870
5905
|
};
|
|
5871
5906
|
};
|
|
5872
|
-
const useHash = (layerKey, manager) => {
|
|
5873
|
-
if (!layerKey || !manager) return null;
|
|
5874
|
-
const layer = manager.resolve(layerKey);
|
|
5875
|
-
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
5876
|
-
return hashGenerator(overrideFrom ?? layerKey);
|
|
5877
|
-
};
|
|
5878
5907
|
const useInstanceProps = (instanceProps) => {
|
|
5879
5908
|
const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
|
|
5880
5909
|
const { manager: loadedManager } = useFragmentManager(
|
|
@@ -5908,10 +5937,32 @@ const useInstanceProps = (instanceProps) => {
|
|
|
5908
5937
|
cssProps: getCssVariables(mergedProps)
|
|
5909
5938
|
};
|
|
5910
5939
|
};
|
|
5940
|
+
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
5941
|
+
var _a, _b, _c, _d;
|
|
5942
|
+
if (!fragmentManager || !layerKey) return [];
|
|
5943
|
+
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
5944
|
+
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
5945
|
+
layerParents.forEach((parent) => {
|
|
5946
|
+
var _a2, _b2, _c2, _d2;
|
|
5947
|
+
const parentLink = keyOfEntity(parent);
|
|
5948
|
+
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
5949
|
+
resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
|
|
5950
|
+
}
|
|
5951
|
+
});
|
|
5952
|
+
const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
|
|
5953
|
+
if (areaScope) {
|
|
5954
|
+
resultScopes.push(areaScope);
|
|
5955
|
+
}
|
|
5956
|
+
return resultScopes;
|
|
5957
|
+
};
|
|
5911
5958
|
const useLayerInteractions = (layerKey, options2) => {
|
|
5912
5959
|
const pause = (options2 == null ? void 0 : options2.pauseInteractions) ?? false;
|
|
5913
5960
|
const { manager: globalManager } = useGlobalManager();
|
|
5914
5961
|
const { manager: fragmentManager } = x$2(FragmentContext);
|
|
5962
|
+
const scopes = useLayerScopes(fragmentManager, layerKey);
|
|
5963
|
+
const areaScope = scopes.find(
|
|
5964
|
+
(scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.AreaScope
|
|
5965
|
+
);
|
|
5915
5966
|
const [interactions2] = useLayerValue(
|
|
5916
5967
|
layerKey,
|
|
5917
5968
|
"interactions",
|
|
@@ -5921,10 +5972,14 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
5921
5972
|
const fireEvent = q$1(
|
|
5922
5973
|
(eventLink) => {
|
|
5923
5974
|
var _a, _b, _c, _d;
|
|
5975
|
+
if (!areaScope) return null;
|
|
5924
5976
|
const event = fragmentManager.resolve(eventLink);
|
|
5925
5977
|
const { value: eventValue } = readVariable(eventLink);
|
|
5926
|
-
if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.
|
|
5927
|
-
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a,
|
|
5978
|
+
if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
5979
|
+
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, {
|
|
5980
|
+
goalId: eventValue == null ? void 0 : eventValue.goalId,
|
|
5981
|
+
...pick(areaScope, "variantId", "campaignId", "areaId")
|
|
5982
|
+
});
|
|
5928
5983
|
}
|
|
5929
5984
|
if ((event == null ? void 0 : event.mode) === index.eventMode.tracker && eventValue) {
|
|
5930
5985
|
(_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
|
|
@@ -5933,13 +5988,13 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
5933
5988
|
eventValue();
|
|
5934
5989
|
}
|
|
5935
5990
|
},
|
|
5936
|
-
[globalManager, fragmentManager]
|
|
5991
|
+
[globalManager, fragmentManager, areaScope]
|
|
5937
5992
|
);
|
|
5938
5993
|
y$2(() => {
|
|
5939
5994
|
if (!pause && Array.isArray(interactions2)) {
|
|
5940
5995
|
interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.appear).map((el) => el.event).forEach(fireEvent);
|
|
5941
5996
|
}
|
|
5942
|
-
}, [pause]);
|
|
5997
|
+
}, [pause, areaScope]);
|
|
5943
5998
|
return T$1(() => {
|
|
5944
5999
|
if (!pause && !interactions2 || !Array.isArray(interactions2)) return {};
|
|
5945
6000
|
if (pause) return {};
|
|
@@ -5951,6 +6006,22 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
5951
6006
|
};
|
|
5952
6007
|
}, [interactions2, fireEvent, pause]);
|
|
5953
6008
|
};
|
|
6009
|
+
const useHash = (layerKey, manager) => {
|
|
6010
|
+
if (!layerKey || !manager) return null;
|
|
6011
|
+
const layer = manager.resolve(layerKey);
|
|
6012
|
+
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
6013
|
+
return hashGenerator(overrideFrom ?? layerKey);
|
|
6014
|
+
};
|
|
6015
|
+
const useClassnames = (layerKey, manager) => {
|
|
6016
|
+
const hash = useHash(layerKey, manager);
|
|
6017
|
+
const [classnames] = useLayerValue(layerKey, "classnames", { manager });
|
|
6018
|
+
if (!layerKey || !manager) return null;
|
|
6019
|
+
let base = [hash];
|
|
6020
|
+
if (classnames == null ? void 0 : classnames.length) {
|
|
6021
|
+
base = [...base, ...classnames];
|
|
6022
|
+
}
|
|
6023
|
+
return base.join(" ");
|
|
6024
|
+
};
|
|
5954
6025
|
const useInstance = (instanceProps) => {
|
|
5955
6026
|
const { manager: parentManager } = x$2(FragmentContext);
|
|
5956
6027
|
const [instanceLayer] = y(parentManager, instanceProps.layerKey);
|
|
@@ -5962,9 +6033,12 @@ const useInstance = (instanceProps) => {
|
|
|
5962
6033
|
const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
|
|
5963
6034
|
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
|
|
5964
6035
|
const { props, cssProps } = useInstanceProps(instanceProps);
|
|
5965
|
-
const
|
|
6036
|
+
const classnames = useClassnames(
|
|
6037
|
+
instanceProps.layerKey,
|
|
6038
|
+
innerFragmentManager
|
|
6039
|
+
);
|
|
5966
6040
|
return {
|
|
5967
|
-
|
|
6041
|
+
classnames,
|
|
5968
6042
|
styles: styles2,
|
|
5969
6043
|
events,
|
|
5970
6044
|
definitions,
|
|
@@ -6133,9 +6207,11 @@ const useFragment = (fragmentId, globalManager) => {
|
|
|
6133
6207
|
(_a = fragmentContext.manager) == null ? void 0 : _a.resolve(fragmentContext.fragmentLayerKey),
|
|
6134
6208
|
(_b = fragmentContext.manager) == null ? void 0 : _b.key
|
|
6135
6209
|
);
|
|
6136
|
-
mount();
|
|
6137
6210
|
}
|
|
6138
6211
|
y$2(() => {
|
|
6212
|
+
if (fragmentContext.manager) {
|
|
6213
|
+
mount();
|
|
6214
|
+
}
|
|
6139
6215
|
return () => {
|
|
6140
6216
|
unmount();
|
|
6141
6217
|
};
|
|
@@ -6183,7 +6259,7 @@ const useFrame = (layerKey, options2) => {
|
|
|
6183
6259
|
const layer = fragmentManager.entityOfKey(layerKey);
|
|
6184
6260
|
const styles2 = useLayerStyles(layerKey);
|
|
6185
6261
|
const children = useLayerChildren(layerKey);
|
|
6186
|
-
const
|
|
6262
|
+
const classnames = useClassnames(layerKey, fragmentManager);
|
|
6187
6263
|
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
6188
6264
|
const events = useLayerInteractions(layerKey, options2);
|
|
6189
6265
|
const link = useLayerLink(layerKey);
|
|
@@ -6193,7 +6269,7 @@ const useFrame = (layerKey, options2) => {
|
|
|
6193
6269
|
return {
|
|
6194
6270
|
Tag: (link == null ? void 0 : link.isLink) ? "a" : "div",
|
|
6195
6271
|
type: layer == null ? void 0 : layer._type,
|
|
6196
|
-
|
|
6272
|
+
classnames,
|
|
6197
6273
|
styles: {},
|
|
6198
6274
|
//isBrowser ? pick(styles, "background") : {},
|
|
6199
6275
|
children,
|
|
@@ -6249,14 +6325,14 @@ const useTextAttributes = (layerKey, options2) => {
|
|
|
6249
6325
|
const { manager: fragmentManager } = x$2(FragmentContext);
|
|
6250
6326
|
const styles2 = useLayerStyles(layerKey);
|
|
6251
6327
|
const content = useTextContent(layerKey);
|
|
6252
|
-
const
|
|
6328
|
+
const classnames = useClassnames(layerKey, fragmentManager);
|
|
6253
6329
|
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
6254
6330
|
{
|
|
6255
6331
|
addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
|
|
6256
6332
|
}
|
|
6257
6333
|
return {
|
|
6258
6334
|
styles: styles2,
|
|
6259
|
-
|
|
6335
|
+
classnames,
|
|
6260
6336
|
content
|
|
6261
6337
|
};
|
|
6262
6338
|
};
|
|
@@ -6355,6 +6431,14 @@ const useArea = (options2) => {
|
|
|
6355
6431
|
options2 == null ? void 0 : options2.globalManager
|
|
6356
6432
|
);
|
|
6357
6433
|
const [areaData, setAreaData] = d(queryArea(options2.areaCode));
|
|
6434
|
+
const { manager: fragmentManager } = useFragmentManager(
|
|
6435
|
+
areaData.fragmentId,
|
|
6436
|
+
resultGlobalManager
|
|
6437
|
+
);
|
|
6438
|
+
const resultProps = T$1(
|
|
6439
|
+
() => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options2 == null ? void 0 : options2.props) ?? [] }),
|
|
6440
|
+
[areaData, options2]
|
|
6441
|
+
);
|
|
6358
6442
|
y$2(() => {
|
|
6359
6443
|
(async () => {
|
|
6360
6444
|
const response = await queryArea(options2.areaCode);
|
|
@@ -6365,6 +6449,8 @@ const useArea = (options2) => {
|
|
|
6365
6449
|
}, []);
|
|
6366
6450
|
return {
|
|
6367
6451
|
...areaData,
|
|
6452
|
+
fragmentManager,
|
|
6453
|
+
props: resultProps,
|
|
6368
6454
|
globalManager: resultGlobalManager
|
|
6369
6455
|
};
|
|
6370
6456
|
};
|
package/dist/index.es.js
CHANGED
|
@@ -733,6 +733,7 @@ const renderMode$1 = createConstants$1("viewport", "parent", "fixed");
|
|
|
733
733
|
const interactions$1 = createConstants$1("click", "mouseover", "appear");
|
|
734
734
|
const eventMode$1 = createConstants$1("goal", "callback", "tracker");
|
|
735
735
|
const scopeTypes$1 = createConstants$1(
|
|
736
|
+
"AreaScope",
|
|
736
737
|
"InstanceScope",
|
|
737
738
|
"FragmentScope",
|
|
738
739
|
"CollectionScope",
|
|
@@ -1577,7 +1578,8 @@ const SceneSchema$1 = /* @__PURE__ */ object$1({
|
|
|
1577
1578
|
}),
|
|
1578
1579
|
visible: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: true, variable: true }),
|
|
1579
1580
|
rotate: layerField$1(/* @__PURE__ */ number$1(), { fallback: null }),
|
|
1580
|
-
zIndex: layerField$1(/* @__PURE__ */ number$1(), { fallback:
|
|
1581
|
+
zIndex: layerField$1(/* @__PURE__ */ number$1(), { fallback: null }),
|
|
1582
|
+
classnames: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ number$1()), { fallback: [] })
|
|
1581
1583
|
});
|
|
1582
1584
|
const FillSchema$1 = /* @__PURE__ */ object$1({
|
|
1583
1585
|
fillType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(paintMode$1)), {
|
|
@@ -1724,7 +1726,7 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
|
|
|
1724
1726
|
fallback: ""
|
|
1725
1727
|
}),
|
|
1726
1728
|
whiteSpace: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(whiteSpace$1)), {
|
|
1727
|
-
fallback: whiteSpace$1.
|
|
1729
|
+
fallback: whiteSpace$1.normal
|
|
1728
1730
|
}),
|
|
1729
1731
|
textAlign: layerField$1(/* @__PURE__ */ string$1(), { fallback: "left" }),
|
|
1730
1732
|
parent: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ string$1()), { overridable: false }),
|
|
@@ -1846,6 +1848,7 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
|
|
|
1846
1848
|
required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
|
|
1847
1849
|
placeholder: layerField$1(/* @__PURE__ */ string$1(), { fallback: "" }),
|
|
1848
1850
|
isTextarea: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
|
|
1851
|
+
isRich: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
|
|
1849
1852
|
...GraphFieldSchema$1.entries
|
|
1850
1853
|
});
|
|
1851
1854
|
/* @__PURE__ */ object$1({
|
|
@@ -2057,6 +2060,8 @@ var isBrowser_default$1 = typeof window !== "undefined";
|
|
|
2057
2060
|
var getKey$1 = (v2) => isKey$1(v2) ? v2.slice(1) : null;
|
|
2058
2061
|
var isKey$1 = (v2) => typeof v2 === "string" && v2.startsWith("$");
|
|
2059
2062
|
function hashGenerator$1(layerKey) {
|
|
2063
|
+
if (!(layerKey == null ? void 0 : layerKey.length))
|
|
2064
|
+
return layerKey;
|
|
2060
2065
|
let hash = 0;
|
|
2061
2066
|
for (let i2 = 0; i2 < layerKey.length; i2++) {
|
|
2062
2067
|
hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
|
|
@@ -2082,9 +2087,12 @@ const getAreaListQuery = (areaCodes) => {
|
|
|
2082
2087
|
return {
|
|
2083
2088
|
query: `query($areaCodes: [String!]!) {
|
|
2084
2089
|
clientAreas(areaCodes: $areaCodes) {
|
|
2090
|
+
areaId
|
|
2091
|
+
campaignId
|
|
2085
2092
|
areaProperties
|
|
2086
2093
|
projectProperties
|
|
2087
2094
|
variant {
|
|
2095
|
+
id
|
|
2088
2096
|
fragment {
|
|
2089
2097
|
props
|
|
2090
2098
|
fragment {
|
|
@@ -2198,6 +2206,9 @@ const fetchPlugin = (state) => {
|
|
|
2198
2206
|
return acc;
|
|
2199
2207
|
}, area.variant.fragment.props);
|
|
2200
2208
|
const entity = {
|
|
2209
|
+
areaId: area.areaId,
|
|
2210
|
+
campaignId: area.campaignId,
|
|
2211
|
+
variantId: area.variant.id,
|
|
2201
2212
|
fragmentId: area.variant.fragment.fragment.id,
|
|
2202
2213
|
props: resultProps
|
|
2203
2214
|
};
|
|
@@ -2290,10 +2301,14 @@ const makeCss = (styles2, layerResolver) => (layerKey) => {
|
|
|
2290
2301
|
};
|
|
2291
2302
|
};
|
|
2292
2303
|
const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
2304
|
+
let countDepends = 0;
|
|
2293
2305
|
const removeStyle = () => {
|
|
2294
2306
|
if (!isBrowser_default$1) return;
|
|
2295
|
-
|
|
2296
|
-
if (
|
|
2307
|
+
countDepends--;
|
|
2308
|
+
if (countDepends <= 0) {
|
|
2309
|
+
const el = document.getElementById(key);
|
|
2310
|
+
if (el) el.remove();
|
|
2311
|
+
}
|
|
2297
2312
|
};
|
|
2298
2313
|
const injectStyle = (styles2) => {
|
|
2299
2314
|
if (!isBrowser_default$1) return;
|
|
@@ -2301,6 +2316,7 @@ const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
|
2301
2316
|
removeStyle();
|
|
2302
2317
|
return;
|
|
2303
2318
|
}
|
|
2319
|
+
countDepends++;
|
|
2304
2320
|
const existing = document.getElementById(key);
|
|
2305
2321
|
if (existing && existing.tagName === "STYLE") {
|
|
2306
2322
|
existing.textContent = styles2;
|
|
@@ -2329,6 +2345,7 @@ const autoInjector = (key, state, graphKey, transformStyles) => {
|
|
|
2329
2345
|
const mount = () => {
|
|
2330
2346
|
isMounted = true;
|
|
2331
2347
|
if (pendingStyles) {
|
|
2348
|
+
countDepends++;
|
|
2332
2349
|
injectStyle(pendingStyles);
|
|
2333
2350
|
} else {
|
|
2334
2351
|
removeStyle();
|
|
@@ -2533,6 +2550,7 @@ const fragmentsPlugin = (options) => (state) => {
|
|
|
2533
2550
|
[fragmentId]: manager
|
|
2534
2551
|
}
|
|
2535
2552
|
});
|
|
2553
|
+
return manager;
|
|
2536
2554
|
};
|
|
2537
2555
|
const getManager = (fragmentId) => {
|
|
2538
2556
|
var _a, _b;
|
|
@@ -2555,8 +2573,8 @@ const fragmentsPlugin = (options) => (state) => {
|
|
|
2555
2573
|
});
|
|
2556
2574
|
return state;
|
|
2557
2575
|
};
|
|
2558
|
-
const addClientMetric = `mutation AddClientMetric($type: ClientMetricType!, $value:
|
|
2559
|
-
addClientMetric(metric: {metricType: $type,
|
|
2576
|
+
const addClientMetric = `mutation AddClientMetric($type: ClientMetricType!, $value: GoalAchievementPost!) {
|
|
2577
|
+
addClientMetric(metric: {metricType: $type, achievement: $value})
|
|
2560
2578
|
}`;
|
|
2561
2579
|
const pendingPixels = /* @__PURE__ */ new Set();
|
|
2562
2580
|
const sendWithImage = (url) => {
|
|
@@ -3518,6 +3536,7 @@ const renderMode = createConstants("viewport", "parent", "fixed");
|
|
|
3518
3536
|
const interactions = createConstants("click", "mouseover", "appear");
|
|
3519
3537
|
const eventMode = createConstants("goal", "callback", "tracker");
|
|
3520
3538
|
const scopeTypes = createConstants(
|
|
3539
|
+
"AreaScope",
|
|
3521
3540
|
"InstanceScope",
|
|
3522
3541
|
"FragmentScope",
|
|
3523
3542
|
"CollectionScope",
|
|
@@ -4408,7 +4427,8 @@ const SceneSchema = /* @__PURE__ */ object({
|
|
|
4408
4427
|
}),
|
|
4409
4428
|
visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
|
|
4410
4429
|
rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
4411
|
-
zIndex: layerField(/* @__PURE__ */ number(), { fallback:
|
|
4430
|
+
zIndex: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
4431
|
+
classnames: layerField(/* @__PURE__ */ array(/* @__PURE__ */ number()), { fallback: [] })
|
|
4412
4432
|
});
|
|
4413
4433
|
const FillSchema = /* @__PURE__ */ object({
|
|
4414
4434
|
fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
|
|
@@ -4555,7 +4575,7 @@ const TextSchema = /* @__PURE__ */ object({
|
|
|
4555
4575
|
fallback: ""
|
|
4556
4576
|
}),
|
|
4557
4577
|
whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
|
|
4558
|
-
fallback: whiteSpace.
|
|
4578
|
+
fallback: whiteSpace.normal
|
|
4559
4579
|
}),
|
|
4560
4580
|
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
|
|
4561
4581
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
@@ -4677,6 +4697,7 @@ const StringVariableSchema = /* @__PURE__ */ object({
|
|
|
4677
4697
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
4678
4698
|
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
4679
4699
|
isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
4700
|
+
isRich: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
4680
4701
|
...GraphFieldSchema.entries
|
|
4681
4702
|
});
|
|
4682
4703
|
const EventVariableSchema = /* @__PURE__ */ object({
|
|
@@ -5164,6 +5185,8 @@ function isFiniteNumber(value) {
|
|
|
5164
5185
|
return typeof value === "number" && isFinite(value);
|
|
5165
5186
|
}
|
|
5166
5187
|
function hashGenerator(layerKey) {
|
|
5188
|
+
if (!(layerKey == null ? void 0 : layerKey.length))
|
|
5189
|
+
return layerKey;
|
|
5167
5190
|
let hash = 0;
|
|
5168
5191
|
for (let i2 = 0; i2 < layerKey.length; i2++) {
|
|
5169
5192
|
hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
|
|
@@ -5200,7 +5223,7 @@ const useGlobalManager = (globalManager) => {
|
|
|
5200
5223
|
setRenderTarget
|
|
5201
5224
|
};
|
|
5202
5225
|
};
|
|
5203
|
-
const useFragmentManager = (fragmentId, inputGlobalManager
|
|
5226
|
+
const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
5204
5227
|
var _a;
|
|
5205
5228
|
const {
|
|
5206
5229
|
fragmentsGraph,
|
|
@@ -5600,7 +5623,7 @@ const useLayerSizeValue = (layerKey, sizeType) => {
|
|
|
5600
5623
|
return "100%";
|
|
5601
5624
|
}
|
|
5602
5625
|
if (autoSizes.includes(valueType)) {
|
|
5603
|
-
return layerNode._type === index.nodes.Instance ? "auto" : "
|
|
5626
|
+
return layerNode._type === index.nodes.Instance ? "auto" : "fit-content";
|
|
5604
5627
|
}
|
|
5605
5628
|
if (valueType === index.sizing.Relative) {
|
|
5606
5629
|
return `${value}%`;
|
|
@@ -5678,13 +5701,14 @@ const useLayerBackground = (layerKey) => {
|
|
|
5678
5701
|
"solidFill",
|
|
5679
5702
|
fragmentManager
|
|
5680
5703
|
);
|
|
5681
|
-
const [imageFill, ,
|
|
5704
|
+
const [imageFill, , cssImageFillOptions] = useLayerValue(
|
|
5682
5705
|
layerKey,
|
|
5683
5706
|
"imageFill",
|
|
5684
5707
|
fragmentManager
|
|
5685
5708
|
);
|
|
5709
|
+
const imageSizeLayerKey = (cssImageFillOptions == null ? void 0 : cssImageFillOptions.isVariable) ? cssImageFillOptions == null ? void 0 : cssImageFillOptions.rawValue : layerKey;
|
|
5686
5710
|
const [, , { cssVariableValue: cssImageSize }] = useLayerValue(
|
|
5687
|
-
|
|
5711
|
+
imageSizeLayerKey,
|
|
5688
5712
|
"imageSize",
|
|
5689
5713
|
fragmentManager
|
|
5690
5714
|
);
|
|
@@ -5694,7 +5718,7 @@ const useLayerBackground = (layerKey) => {
|
|
|
5694
5718
|
background: cssSolidFill
|
|
5695
5719
|
};
|
|
5696
5720
|
}
|
|
5697
|
-
if (fillType === index.paintMode.Image &&
|
|
5721
|
+
if (fillType === index.paintMode.Image && cssImageFillOptions.cssVariableValue) {
|
|
5698
5722
|
return {
|
|
5699
5723
|
background: `url(${imageFill})`,
|
|
5700
5724
|
backgroundSize: cssImageSize == null ? void 0 : cssImageSize.toLowerCase(),
|
|
@@ -5704,7 +5728,12 @@ const useLayerBackground = (layerKey) => {
|
|
|
5704
5728
|
return {
|
|
5705
5729
|
background: "transparent"
|
|
5706
5730
|
};
|
|
5707
|
-
}, [
|
|
5731
|
+
}, [
|
|
5732
|
+
fillType,
|
|
5733
|
+
cssImageFillOptions.cssVariableValue,
|
|
5734
|
+
cssSolidFill,
|
|
5735
|
+
cssImageSize
|
|
5736
|
+
]);
|
|
5708
5737
|
};
|
|
5709
5738
|
const useLayerDisplay = (layerKey) => {
|
|
5710
5739
|
const { manager } = x$2(FragmentContext);
|
|
@@ -5757,7 +5786,11 @@ const useCalcLayerBorder = (layerKey) => {
|
|
|
5757
5786
|
const useLayerBorder = (layerKey) => {
|
|
5758
5787
|
const { manager: fragmentManager } = x$2(FragmentContext);
|
|
5759
5788
|
const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
|
|
5760
|
-
const [borderColor] = useLayerValue(
|
|
5789
|
+
const [, , { cssVariableValue: borderColor }] = useLayerValue(
|
|
5790
|
+
layerKey,
|
|
5791
|
+
"borderColor",
|
|
5792
|
+
fragmentManager
|
|
5793
|
+
);
|
|
5761
5794
|
const calcBorder = useCalcLayerBorder(layerKey);
|
|
5762
5795
|
return T$1(
|
|
5763
5796
|
() => calcBorder(borderWidth, borderColor),
|
|
@@ -5838,12 +5871,14 @@ const useLayerStyles = (layerKey) => {
|
|
|
5838
5871
|
);
|
|
5839
5872
|
const [whiteSpace2] = useLayerValue(layerKey, "whiteSpace", fragmentManager);
|
|
5840
5873
|
const textStyles = useLayerTextStyles(layerKey);
|
|
5874
|
+
const [overflow2] = useLayerValue(layerKey, "overflow", fragmentManager);
|
|
5841
5875
|
return {
|
|
5842
5876
|
// ...(props ?? {}),
|
|
5843
5877
|
...border,
|
|
5844
5878
|
...background,
|
|
5845
5879
|
...position,
|
|
5846
5880
|
opacity,
|
|
5881
|
+
overflow: overflow2,
|
|
5847
5882
|
rotate: isValue(rotate) ? `${rotate}deg` : null,
|
|
5848
5883
|
"border-radius": borderRadius,
|
|
5849
5884
|
"white-space": whiteSpace2,
|
|
@@ -5868,12 +5903,6 @@ const useFragmentProperties = (fragmentId) => {
|
|
|
5868
5903
|
manager
|
|
5869
5904
|
};
|
|
5870
5905
|
};
|
|
5871
|
-
const useHash = (layerKey, manager) => {
|
|
5872
|
-
if (!layerKey || !manager) return null;
|
|
5873
|
-
const layer = manager.resolve(layerKey);
|
|
5874
|
-
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
5875
|
-
return hashGenerator(overrideFrom ?? layerKey);
|
|
5876
|
-
};
|
|
5877
5906
|
const useInstanceProps = (instanceProps) => {
|
|
5878
5907
|
const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
|
|
5879
5908
|
const { manager: loadedManager } = useFragmentManager(
|
|
@@ -5907,10 +5936,32 @@ const useInstanceProps = (instanceProps) => {
|
|
|
5907
5936
|
cssProps: getCssVariables(mergedProps)
|
|
5908
5937
|
};
|
|
5909
5938
|
};
|
|
5939
|
+
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
5940
|
+
var _a, _b, _c, _d;
|
|
5941
|
+
if (!fragmentManager || !layerKey) return [];
|
|
5942
|
+
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
5943
|
+
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
5944
|
+
layerParents.forEach((parent) => {
|
|
5945
|
+
var _a2, _b2, _c2, _d2;
|
|
5946
|
+
const parentLink = keyOfEntity(parent);
|
|
5947
|
+
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
5948
|
+
resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
|
|
5949
|
+
}
|
|
5950
|
+
});
|
|
5951
|
+
const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
|
|
5952
|
+
if (areaScope) {
|
|
5953
|
+
resultScopes.push(areaScope);
|
|
5954
|
+
}
|
|
5955
|
+
return resultScopes;
|
|
5956
|
+
};
|
|
5910
5957
|
const useLayerInteractions = (layerKey, options2) => {
|
|
5911
5958
|
const pause = (options2 == null ? void 0 : options2.pauseInteractions) ?? false;
|
|
5912
5959
|
const { manager: globalManager } = useGlobalManager();
|
|
5913
5960
|
const { manager: fragmentManager } = x$2(FragmentContext);
|
|
5961
|
+
const scopes = useLayerScopes(fragmentManager, layerKey);
|
|
5962
|
+
const areaScope = scopes.find(
|
|
5963
|
+
(scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.AreaScope
|
|
5964
|
+
);
|
|
5914
5965
|
const [interactions2] = useLayerValue(
|
|
5915
5966
|
layerKey,
|
|
5916
5967
|
"interactions",
|
|
@@ -5920,10 +5971,14 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
5920
5971
|
const fireEvent = q$1(
|
|
5921
5972
|
(eventLink) => {
|
|
5922
5973
|
var _a, _b, _c, _d;
|
|
5974
|
+
if (!areaScope) return null;
|
|
5923
5975
|
const event = fragmentManager.resolve(eventLink);
|
|
5924
5976
|
const { value: eventValue } = readVariable(eventLink);
|
|
5925
|
-
if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.
|
|
5926
|
-
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a,
|
|
5977
|
+
if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
5978
|
+
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, {
|
|
5979
|
+
goalId: eventValue == null ? void 0 : eventValue.goalId,
|
|
5980
|
+
...pick(areaScope, "variantId", "campaignId", "areaId")
|
|
5981
|
+
});
|
|
5927
5982
|
}
|
|
5928
5983
|
if ((event == null ? void 0 : event.mode) === index.eventMode.tracker && eventValue) {
|
|
5929
5984
|
(_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
|
|
@@ -5932,13 +5987,13 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
5932
5987
|
eventValue();
|
|
5933
5988
|
}
|
|
5934
5989
|
},
|
|
5935
|
-
[globalManager, fragmentManager]
|
|
5990
|
+
[globalManager, fragmentManager, areaScope]
|
|
5936
5991
|
);
|
|
5937
5992
|
y$2(() => {
|
|
5938
5993
|
if (!pause && Array.isArray(interactions2)) {
|
|
5939
5994
|
interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.appear).map((el) => el.event).forEach(fireEvent);
|
|
5940
5995
|
}
|
|
5941
|
-
}, [pause]);
|
|
5996
|
+
}, [pause, areaScope]);
|
|
5942
5997
|
return T$1(() => {
|
|
5943
5998
|
if (!pause && !interactions2 || !Array.isArray(interactions2)) return {};
|
|
5944
5999
|
if (pause) return {};
|
|
@@ -5950,6 +6005,22 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
5950
6005
|
};
|
|
5951
6006
|
}, [interactions2, fireEvent, pause]);
|
|
5952
6007
|
};
|
|
6008
|
+
const useHash = (layerKey, manager) => {
|
|
6009
|
+
if (!layerKey || !manager) return null;
|
|
6010
|
+
const layer = manager.resolve(layerKey);
|
|
6011
|
+
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
6012
|
+
return hashGenerator(overrideFrom ?? layerKey);
|
|
6013
|
+
};
|
|
6014
|
+
const useClassnames = (layerKey, manager) => {
|
|
6015
|
+
const hash = useHash(layerKey, manager);
|
|
6016
|
+
const [classnames] = useLayerValue(layerKey, "classnames", { manager });
|
|
6017
|
+
if (!layerKey || !manager) return null;
|
|
6018
|
+
let base = [hash];
|
|
6019
|
+
if (classnames == null ? void 0 : classnames.length) {
|
|
6020
|
+
base = [...base, ...classnames];
|
|
6021
|
+
}
|
|
6022
|
+
return base.join(" ");
|
|
6023
|
+
};
|
|
5953
6024
|
const useInstance = (instanceProps) => {
|
|
5954
6025
|
const { manager: parentManager } = x$2(FragmentContext);
|
|
5955
6026
|
const [instanceLayer] = y(parentManager, instanceProps.layerKey);
|
|
@@ -5961,9 +6032,12 @@ const useInstance = (instanceProps) => {
|
|
|
5961
6032
|
const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
|
|
5962
6033
|
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
|
|
5963
6034
|
const { props, cssProps } = useInstanceProps(instanceProps);
|
|
5964
|
-
const
|
|
6035
|
+
const classnames = useClassnames(
|
|
6036
|
+
instanceProps.layerKey,
|
|
6037
|
+
innerFragmentManager
|
|
6038
|
+
);
|
|
5965
6039
|
return {
|
|
5966
|
-
|
|
6040
|
+
classnames,
|
|
5967
6041
|
styles: styles2,
|
|
5968
6042
|
events,
|
|
5969
6043
|
definitions,
|
|
@@ -6132,9 +6206,11 @@ const useFragment = (fragmentId, globalManager) => {
|
|
|
6132
6206
|
(_a = fragmentContext.manager) == null ? void 0 : _a.resolve(fragmentContext.fragmentLayerKey),
|
|
6133
6207
|
(_b = fragmentContext.manager) == null ? void 0 : _b.key
|
|
6134
6208
|
);
|
|
6135
|
-
mount();
|
|
6136
6209
|
}
|
|
6137
6210
|
y$2(() => {
|
|
6211
|
+
if (fragmentContext.manager) {
|
|
6212
|
+
mount();
|
|
6213
|
+
}
|
|
6138
6214
|
return () => {
|
|
6139
6215
|
unmount();
|
|
6140
6216
|
};
|
|
@@ -6182,7 +6258,7 @@ const useFrame = (layerKey, options2) => {
|
|
|
6182
6258
|
const layer = fragmentManager.entityOfKey(layerKey);
|
|
6183
6259
|
const styles2 = useLayerStyles(layerKey);
|
|
6184
6260
|
const children = useLayerChildren(layerKey);
|
|
6185
|
-
const
|
|
6261
|
+
const classnames = useClassnames(layerKey, fragmentManager);
|
|
6186
6262
|
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
6187
6263
|
const events = useLayerInteractions(layerKey, options2);
|
|
6188
6264
|
const link = useLayerLink(layerKey);
|
|
@@ -6192,7 +6268,7 @@ const useFrame = (layerKey, options2) => {
|
|
|
6192
6268
|
return {
|
|
6193
6269
|
Tag: (link == null ? void 0 : link.isLink) ? "a" : "div",
|
|
6194
6270
|
type: layer == null ? void 0 : layer._type,
|
|
6195
|
-
|
|
6271
|
+
classnames,
|
|
6196
6272
|
styles: {},
|
|
6197
6273
|
//isBrowser ? pick(styles, "background") : {},
|
|
6198
6274
|
children,
|
|
@@ -6248,14 +6324,14 @@ const useTextAttributes = (layerKey, options2) => {
|
|
|
6248
6324
|
const { manager: fragmentManager } = x$2(FragmentContext);
|
|
6249
6325
|
const styles2 = useLayerStyles(layerKey);
|
|
6250
6326
|
const content = useTextContent(layerKey);
|
|
6251
|
-
const
|
|
6327
|
+
const classnames = useClassnames(layerKey, fragmentManager);
|
|
6252
6328
|
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
6253
6329
|
{
|
|
6254
6330
|
addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
|
|
6255
6331
|
}
|
|
6256
6332
|
return {
|
|
6257
6333
|
styles: styles2,
|
|
6258
|
-
|
|
6334
|
+
classnames,
|
|
6259
6335
|
content
|
|
6260
6336
|
};
|
|
6261
6337
|
};
|
|
@@ -6354,6 +6430,14 @@ const useArea = (options2) => {
|
|
|
6354
6430
|
options2 == null ? void 0 : options2.globalManager
|
|
6355
6431
|
);
|
|
6356
6432
|
const [areaData, setAreaData] = d(queryArea(options2.areaCode));
|
|
6433
|
+
const { manager: fragmentManager } = useFragmentManager(
|
|
6434
|
+
areaData.fragmentId,
|
|
6435
|
+
resultGlobalManager
|
|
6436
|
+
);
|
|
6437
|
+
const resultProps = T$1(
|
|
6438
|
+
() => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options2 == null ? void 0 : options2.props) ?? [] }),
|
|
6439
|
+
[areaData, options2]
|
|
6440
|
+
);
|
|
6357
6441
|
y$2(() => {
|
|
6358
6442
|
(async () => {
|
|
6359
6443
|
const response = await queryArea(options2.areaCode);
|
|
@@ -6364,6 +6448,8 @@ const useArea = (options2) => {
|
|
|
6364
6448
|
}, []);
|
|
6365
6449
|
return {
|
|
6366
6450
|
...areaData,
|
|
6451
|
+
fragmentManager,
|
|
6452
|
+
props: resultProps,
|
|
6367
6453
|
globalManager: resultGlobalManager
|
|
6368
6454
|
};
|
|
6369
6455
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fragmentsx/render-web",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@graph-state/checkers": "^0.1.2",
|
|
26
26
|
"@graph-state/core": "^0.13.0",
|
|
27
|
-
"@fragmentsx/client-core": "0.1.
|
|
27
|
+
"@fragmentsx/client-core": "0.1.4",
|
|
28
28
|
"@fragmentsx/definition": "0.1.0",
|
|
29
|
-
"@fragmentsx/render-core": "0.1.
|
|
29
|
+
"@fragmentsx/render-core": "0.1.1",
|
|
30
30
|
"@fragmentsx/utils": "0.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|