@fragmentsx/render-react 1.1.2 → 1.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 +120 -62
- package/dist/index.es.js +120 -62
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -392,6 +392,7 @@ const renderMode = createConstants("viewport", "parent", "fixed");
|
|
|
392
392
|
const interactions = createConstants("click", "mouseover", "appear");
|
|
393
393
|
const eventMode = createConstants("goal", "callback", "tracker");
|
|
394
394
|
const scopeTypes = createConstants(
|
|
395
|
+
"AreaScope",
|
|
395
396
|
"InstanceScope",
|
|
396
397
|
"FragmentScope",
|
|
397
398
|
"CollectionScope",
|
|
@@ -1282,7 +1283,8 @@ const SceneSchema = /* @__PURE__ */ object({
|
|
|
1282
1283
|
}),
|
|
1283
1284
|
visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
|
|
1284
1285
|
rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
1285
|
-
zIndex: layerField(/* @__PURE__ */ number(), { fallback:
|
|
1286
|
+
zIndex: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
1287
|
+
classnames: layerField(/* @__PURE__ */ array(/* @__PURE__ */ number()), { fallback: [] })
|
|
1286
1288
|
});
|
|
1287
1289
|
const FillSchema = /* @__PURE__ */ object({
|
|
1288
1290
|
fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
|
|
@@ -1429,7 +1431,7 @@ const TextSchema = /* @__PURE__ */ object({
|
|
|
1429
1431
|
fallback: ""
|
|
1430
1432
|
}),
|
|
1431
1433
|
whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
|
|
1432
|
-
fallback: whiteSpace.
|
|
1434
|
+
fallback: whiteSpace.normal
|
|
1433
1435
|
}),
|
|
1434
1436
|
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
|
|
1435
1437
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
@@ -1551,6 +1553,7 @@ const StringVariableSchema = /* @__PURE__ */ object({
|
|
|
1551
1553
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1552
1554
|
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1553
1555
|
isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1556
|
+
isRich: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1554
1557
|
...GraphFieldSchema.entries
|
|
1555
1558
|
});
|
|
1556
1559
|
const EventVariableSchema = /* @__PURE__ */ object({
|
|
@@ -2194,6 +2197,8 @@ function isFiniteNumber(value) {
|
|
|
2194
2197
|
}
|
|
2195
2198
|
var setKey$1 = (v2) => `$${v2}`;
|
|
2196
2199
|
function hashGenerator(layerKey) {
|
|
2200
|
+
if (!(layerKey == null ? void 0 : layerKey.length))
|
|
2201
|
+
return layerKey;
|
|
2197
2202
|
let hash = 0;
|
|
2198
2203
|
for (let i2 = 0; i2 < layerKey.length; i2++) {
|
|
2199
2204
|
hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
|
|
@@ -2230,7 +2235,7 @@ const useGlobalManager = (globalManager) => {
|
|
|
2230
2235
|
setRenderTarget
|
|
2231
2236
|
};
|
|
2232
2237
|
};
|
|
2233
|
-
const useFragmentManager = (fragmentId, inputGlobalManager
|
|
2238
|
+
const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
2234
2239
|
var _a;
|
|
2235
2240
|
const {
|
|
2236
2241
|
fragmentsGraph,
|
|
@@ -2321,7 +2326,7 @@ const cloneLayer = (manager, layer, externalProps = {}, _parent) => {
|
|
|
2321
2326
|
_type: layerGraph._type,
|
|
2322
2327
|
overrideFrom: setKey(layerKey),
|
|
2323
2328
|
parent: setKey(layerParent),
|
|
2324
|
-
...(layerGraph == null ? void 0 : layerGraph._type) === index.nodes.Instance ? pick(layerGraph, "fragment") : {},
|
|
2329
|
+
...(layerGraph == null ? void 0 : layerGraph._type) === index.nodes.Instance ? pick(layerGraph, "fragment", "props") : {},
|
|
2325
2330
|
...externalProps
|
|
2326
2331
|
},
|
|
2327
2332
|
true
|
|
@@ -2853,7 +2858,7 @@ const useLayerSizeValue = (layerKey, sizeType) => {
|
|
|
2853
2858
|
return "100%";
|
|
2854
2859
|
}
|
|
2855
2860
|
if (autoSizes.includes(valueType)) {
|
|
2856
|
-
return layerNode._type === index.nodes.Instance ? "auto" : "
|
|
2861
|
+
return layerNode._type === index.nodes.Instance ? "auto" : "fit-content";
|
|
2857
2862
|
}
|
|
2858
2863
|
if (valueType === index.sizing.Relative) {
|
|
2859
2864
|
return `${value}%`;
|
|
@@ -2931,13 +2936,14 @@ const useLayerBackground = (layerKey) => {
|
|
|
2931
2936
|
"solidFill",
|
|
2932
2937
|
fragmentManager
|
|
2933
2938
|
);
|
|
2934
|
-
const [imageFill, ,
|
|
2939
|
+
const [imageFill, , cssImageFillOptions] = useLayerValue(
|
|
2935
2940
|
layerKey,
|
|
2936
2941
|
"imageFill",
|
|
2937
2942
|
fragmentManager
|
|
2938
2943
|
);
|
|
2944
|
+
const imageSizeLayerKey = (cssImageFillOptions == null ? void 0 : cssImageFillOptions.isVariable) ? cssImageFillOptions == null ? void 0 : cssImageFillOptions.rawValue : layerKey;
|
|
2939
2945
|
const [, , { cssVariableValue: cssImageSize }] = useLayerValue(
|
|
2940
|
-
|
|
2946
|
+
imageSizeLayerKey,
|
|
2941
2947
|
"imageSize",
|
|
2942
2948
|
fragmentManager
|
|
2943
2949
|
);
|
|
@@ -2947,7 +2953,7 @@ const useLayerBackground = (layerKey) => {
|
|
|
2947
2953
|
background: cssSolidFill
|
|
2948
2954
|
};
|
|
2949
2955
|
}
|
|
2950
|
-
if (fillType === index.paintMode.Image &&
|
|
2956
|
+
if (fillType === index.paintMode.Image && cssImageFillOptions.cssVariableValue) {
|
|
2951
2957
|
return {
|
|
2952
2958
|
background: `url(${imageFill})`,
|
|
2953
2959
|
backgroundSize: cssImageSize == null ? void 0 : cssImageSize.toLowerCase(),
|
|
@@ -2957,7 +2963,12 @@ const useLayerBackground = (layerKey) => {
|
|
|
2957
2963
|
return {
|
|
2958
2964
|
background: "transparent"
|
|
2959
2965
|
};
|
|
2960
|
-
}, [
|
|
2966
|
+
}, [
|
|
2967
|
+
fillType,
|
|
2968
|
+
cssImageFillOptions.cssVariableValue,
|
|
2969
|
+
cssSolidFill,
|
|
2970
|
+
cssImageSize
|
|
2971
|
+
]);
|
|
2961
2972
|
};
|
|
2962
2973
|
const useLayerDisplay = (layerKey) => {
|
|
2963
2974
|
const { manager } = require$$0.useContext(FragmentContext);
|
|
@@ -3010,7 +3021,11 @@ const useCalcLayerBorder = (layerKey) => {
|
|
|
3010
3021
|
const useLayerBorder = (layerKey) => {
|
|
3011
3022
|
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
3012
3023
|
const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
|
|
3013
|
-
const [borderColor] = useLayerValue(
|
|
3024
|
+
const [, , { cssVariableValue: borderColor }] = useLayerValue(
|
|
3025
|
+
layerKey,
|
|
3026
|
+
"borderColor",
|
|
3027
|
+
fragmentManager
|
|
3028
|
+
);
|
|
3014
3029
|
const calcBorder = useCalcLayerBorder(layerKey);
|
|
3015
3030
|
return require$$0.useMemo(
|
|
3016
3031
|
() => calcBorder(borderWidth, borderColor),
|
|
@@ -3091,12 +3106,14 @@ const useLayerStyles = (layerKey) => {
|
|
|
3091
3106
|
);
|
|
3092
3107
|
const [whiteSpace2] = useLayerValue(layerKey, "whiteSpace", fragmentManager);
|
|
3093
3108
|
const textStyles = useLayerTextStyles(layerKey);
|
|
3109
|
+
const [overflow2] = useLayerValue(layerKey, "overflow", fragmentManager);
|
|
3094
3110
|
return {
|
|
3095
3111
|
// ...(props ?? {}),
|
|
3096
3112
|
...border,
|
|
3097
3113
|
...background,
|
|
3098
3114
|
...position,
|
|
3099
3115
|
opacity,
|
|
3116
|
+
overflow: overflow2,
|
|
3100
3117
|
rotate: isValue(rotate) ? `${rotate}deg` : null,
|
|
3101
3118
|
"border-radius": borderRadius,
|
|
3102
3119
|
"white-space": whiteSpace2,
|
|
@@ -3121,12 +3138,6 @@ const useFragmentProperties = (fragmentId) => {
|
|
|
3121
3138
|
manager
|
|
3122
3139
|
};
|
|
3123
3140
|
};
|
|
3124
|
-
const useHash = (layerKey, manager) => {
|
|
3125
|
-
if (!layerKey || !manager) return null;
|
|
3126
|
-
const layer = manager.resolve(layerKey);
|
|
3127
|
-
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
3128
|
-
return hashGenerator(overrideFrom ?? layerKey);
|
|
3129
|
-
};
|
|
3130
3141
|
const useInstanceProps = (instanceProps) => {
|
|
3131
3142
|
const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
|
|
3132
3143
|
const { manager: loadedManager } = useFragmentManager(
|
|
@@ -3160,10 +3171,32 @@ const useInstanceProps = (instanceProps) => {
|
|
|
3160
3171
|
cssProps: getCssVariables(mergedProps)
|
|
3161
3172
|
};
|
|
3162
3173
|
};
|
|
3174
|
+
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
3175
|
+
var _a, _b, _c, _d;
|
|
3176
|
+
if (!fragmentManager || !layerKey) return [];
|
|
3177
|
+
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
3178
|
+
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
3179
|
+
layerParents.forEach((parent) => {
|
|
3180
|
+
var _a2, _b2, _c2, _d2;
|
|
3181
|
+
const parentLink = core.keyOfEntity(parent);
|
|
3182
|
+
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
3183
|
+
resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
|
|
3184
|
+
}
|
|
3185
|
+
});
|
|
3186
|
+
const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
|
|
3187
|
+
if (areaScope) {
|
|
3188
|
+
resultScopes.push(areaScope);
|
|
3189
|
+
}
|
|
3190
|
+
return resultScopes;
|
|
3191
|
+
};
|
|
3163
3192
|
const useLayerInteractions = (layerKey, options2) => {
|
|
3164
3193
|
const pause = (options2 == null ? void 0 : options2.pauseInteractions) ?? false;
|
|
3165
3194
|
const { manager: globalManager } = useGlobalManager();
|
|
3166
3195
|
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
3196
|
+
const scopes = useLayerScopes(fragmentManager, layerKey);
|
|
3197
|
+
const areaScope = scopes.find(
|
|
3198
|
+
(scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.AreaScope
|
|
3199
|
+
);
|
|
3167
3200
|
const [interactions2] = useLayerValue(
|
|
3168
3201
|
layerKey,
|
|
3169
3202
|
"interactions",
|
|
@@ -3173,10 +3206,14 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
3173
3206
|
const fireEvent = require$$0.useCallback(
|
|
3174
3207
|
(eventLink) => {
|
|
3175
3208
|
var _a, _b, _c, _d;
|
|
3209
|
+
if (!areaScope) return null;
|
|
3176
3210
|
const event = fragmentManager.resolve(eventLink);
|
|
3177
3211
|
const { value: eventValue } = readVariable(eventLink);
|
|
3178
|
-
if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.
|
|
3179
|
-
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a,
|
|
3212
|
+
if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
3213
|
+
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, {
|
|
3214
|
+
goalId: eventValue == null ? void 0 : eventValue.goalId,
|
|
3215
|
+
...pick(areaScope, "variantId", "campaignId", "areaId")
|
|
3216
|
+
});
|
|
3180
3217
|
}
|
|
3181
3218
|
if ((event == null ? void 0 : event.mode) === index.eventMode.tracker && eventValue) {
|
|
3182
3219
|
(_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
|
|
@@ -3185,13 +3222,13 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
3185
3222
|
eventValue();
|
|
3186
3223
|
}
|
|
3187
3224
|
},
|
|
3188
|
-
[globalManager, fragmentManager]
|
|
3225
|
+
[globalManager, fragmentManager, areaScope]
|
|
3189
3226
|
);
|
|
3190
3227
|
require$$0.useEffect(() => {
|
|
3191
3228
|
if (!pause && Array.isArray(interactions2)) {
|
|
3192
3229
|
interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.appear).map((el) => el.event).forEach(fireEvent);
|
|
3193
3230
|
}
|
|
3194
|
-
}, [pause]);
|
|
3231
|
+
}, [pause, areaScope]);
|
|
3195
3232
|
return require$$0.useMemo(() => {
|
|
3196
3233
|
if (!pause && !interactions2 || !Array.isArray(interactions2)) return {};
|
|
3197
3234
|
if (pause) return {};
|
|
@@ -3203,6 +3240,22 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
3203
3240
|
};
|
|
3204
3241
|
}, [interactions2, fireEvent, pause]);
|
|
3205
3242
|
};
|
|
3243
|
+
const useHash = (layerKey, manager) => {
|
|
3244
|
+
if (!layerKey || !manager) return null;
|
|
3245
|
+
const layer = manager.resolve(layerKey);
|
|
3246
|
+
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
3247
|
+
return hashGenerator(overrideFrom ?? layerKey);
|
|
3248
|
+
};
|
|
3249
|
+
const useClassnames = (layerKey, manager) => {
|
|
3250
|
+
const hash = useHash(layerKey, manager);
|
|
3251
|
+
const [classnames] = useLayerValue(layerKey, "classnames", { manager });
|
|
3252
|
+
if (!layerKey || !manager) return null;
|
|
3253
|
+
let base = [hash];
|
|
3254
|
+
if (classnames == null ? void 0 : classnames.length) {
|
|
3255
|
+
base = [...base, ...classnames];
|
|
3256
|
+
}
|
|
3257
|
+
return base.join(" ");
|
|
3258
|
+
};
|
|
3206
3259
|
const useInstance = (instanceProps) => {
|
|
3207
3260
|
const { manager: parentManager } = require$$0.useContext(FragmentContext);
|
|
3208
3261
|
const [instanceLayer] = y(parentManager, instanceProps.layerKey);
|
|
@@ -3214,9 +3267,12 @@ const useInstance = (instanceProps) => {
|
|
|
3214
3267
|
const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
|
|
3215
3268
|
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
|
|
3216
3269
|
const { props, cssProps } = useInstanceProps(instanceProps);
|
|
3217
|
-
const
|
|
3270
|
+
const classnames = useClassnames(
|
|
3271
|
+
instanceProps.layerKey,
|
|
3272
|
+
innerFragmentManager
|
|
3273
|
+
);
|
|
3218
3274
|
return {
|
|
3219
|
-
|
|
3275
|
+
classnames,
|
|
3220
3276
|
styles: styles2,
|
|
3221
3277
|
events,
|
|
3222
3278
|
definitions,
|
|
@@ -3312,9 +3368,11 @@ const useFragment = (fragmentId, globalManager) => {
|
|
|
3312
3368
|
(_a = fragmentContext.manager) == null ? void 0 : _a.resolve(fragmentContext.fragmentLayerKey),
|
|
3313
3369
|
(_b = fragmentContext.manager) == null ? void 0 : _b.key
|
|
3314
3370
|
);
|
|
3315
|
-
mount();
|
|
3316
3371
|
}
|
|
3317
3372
|
require$$0.useEffect(() => {
|
|
3373
|
+
if (fragmentContext.manager) {
|
|
3374
|
+
mount();
|
|
3375
|
+
}
|
|
3318
3376
|
return () => {
|
|
3319
3377
|
unmount();
|
|
3320
3378
|
};
|
|
@@ -3359,7 +3417,7 @@ const useFrame = (layerKey, options2) => {
|
|
|
3359
3417
|
const layer = fragmentManager.entityOfKey(layerKey);
|
|
3360
3418
|
const styles2 = useLayerStyles(layerKey);
|
|
3361
3419
|
const children = useLayerChildren(layerKey);
|
|
3362
|
-
const
|
|
3420
|
+
const classnames = useClassnames(layerKey, fragmentManager);
|
|
3363
3421
|
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
3364
3422
|
const events = useLayerInteractions(layerKey, options2);
|
|
3365
3423
|
const link = useLayerLink(layerKey);
|
|
@@ -3369,7 +3427,7 @@ const useFrame = (layerKey, options2) => {
|
|
|
3369
3427
|
return {
|
|
3370
3428
|
Tag: (link == null ? void 0 : link.isLink) ? (options2 == null ? void 0 : options2.FrameTag) ?? "a" : (options2 == null ? void 0 : options2.FrameTag) ?? "div",
|
|
3371
3429
|
type: layer == null ? void 0 : layer._type,
|
|
3372
|
-
|
|
3430
|
+
classnames,
|
|
3373
3431
|
styles: {},
|
|
3374
3432
|
//isBrowser ? pick(styles, "background") : {},
|
|
3375
3433
|
children,
|
|
@@ -3422,14 +3480,14 @@ const useTextAttributes = (layerKey, options2) => {
|
|
|
3422
3480
|
const { manager: fragmentManager } = require$$0.useContext(FragmentContext);
|
|
3423
3481
|
const styles2 = useLayerStyles(layerKey);
|
|
3424
3482
|
const content = useTextContent(layerKey);
|
|
3425
|
-
const
|
|
3483
|
+
const classnames = useClassnames(layerKey, fragmentManager);
|
|
3426
3484
|
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
3427
3485
|
if (collectStyle) {
|
|
3428
3486
|
addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
|
|
3429
3487
|
}
|
|
3430
3488
|
return {
|
|
3431
3489
|
styles: styles2,
|
|
3432
|
-
|
|
3490
|
+
classnames,
|
|
3433
3491
|
content
|
|
3434
3492
|
};
|
|
3435
3493
|
};
|
|
@@ -3515,19 +3573,6 @@ function useInjectedStyle() {
|
|
|
3515
3573
|
injectStyle
|
|
3516
3574
|
};
|
|
3517
3575
|
}
|
|
3518
|
-
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
3519
|
-
var _a, _b;
|
|
3520
|
-
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
3521
|
-
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
3522
|
-
layerParents.forEach((parent) => {
|
|
3523
|
-
var _a2, _b2, _c, _d;
|
|
3524
|
-
const parentLink = core.keyOfEntity(parent);
|
|
3525
|
-
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
3526
|
-
resultScopes.push((_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get(parentLink));
|
|
3527
|
-
}
|
|
3528
|
-
});
|
|
3529
|
-
return resultScopes;
|
|
3530
|
-
};
|
|
3531
3576
|
function cssToJsStyle(cssKey) {
|
|
3532
3577
|
return cssKey.replace(/-([a-z])/g, (_2, letter) => letter.toUpperCase());
|
|
3533
3578
|
}
|
|
@@ -3555,6 +3600,10 @@ const useArea = (options2) => {
|
|
|
3555
3600
|
options2 == null ? void 0 : options2.globalManager
|
|
3556
3601
|
);
|
|
3557
3602
|
const [areaData, setAreaData] = require$$0.useState(queryArea(options2.areaCode));
|
|
3603
|
+
const { manager: fragmentManager } = useFragmentManager(
|
|
3604
|
+
areaData.fragmentId,
|
|
3605
|
+
resultGlobalManager
|
|
3606
|
+
);
|
|
3558
3607
|
const resultProps = require$$0.useMemo(
|
|
3559
3608
|
() => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options2 == null ? void 0 : options2.props) ?? [] }),
|
|
3560
3609
|
[areaData, options2]
|
|
@@ -3569,6 +3618,7 @@ const useArea = (options2) => {
|
|
|
3569
3618
|
}, []);
|
|
3570
3619
|
return {
|
|
3571
3620
|
...areaData,
|
|
3621
|
+
fragmentManager,
|
|
3572
3622
|
props: resultProps,
|
|
3573
3623
|
globalManager: resultGlobalManager
|
|
3574
3624
|
};
|
|
@@ -3603,8 +3653,8 @@ const Text = ({
|
|
|
3603
3653
|
collectStyle,
|
|
3604
3654
|
...restProps
|
|
3605
3655
|
}) => {
|
|
3606
|
-
const {
|
|
3607
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className:
|
|
3656
|
+
const { classnames, content } = useTextAttributes(layerKey, { collectStyle });
|
|
3657
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tag, { className: classnames, "data-key": layerKey, ...restProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3608
3658
|
"div",
|
|
3609
3659
|
{
|
|
3610
3660
|
className: styles.text,
|
|
@@ -3634,7 +3684,7 @@ const Collection = ({
|
|
|
3634
3684
|
fragmentManager,
|
|
3635
3685
|
styles: styles2,
|
|
3636
3686
|
sourceDefinition,
|
|
3637
|
-
|
|
3687
|
+
classnames,
|
|
3638
3688
|
source,
|
|
3639
3689
|
children,
|
|
3640
3690
|
sourceValue
|
|
@@ -3655,7 +3705,7 @@ const Collection = ({
|
|
|
3655
3705
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3656
3706
|
FrameTag,
|
|
3657
3707
|
{
|
|
3658
|
-
className:
|
|
3708
|
+
className: classnames,
|
|
3659
3709
|
"data-key": layerKey,
|
|
3660
3710
|
style: resultStyles,
|
|
3661
3711
|
...restProps,
|
|
@@ -3693,16 +3743,13 @@ const Frame = ({
|
|
|
3693
3743
|
layerKey,
|
|
3694
3744
|
styles: inputStyles,
|
|
3695
3745
|
hidden,
|
|
3696
|
-
|
|
3746
|
+
pauseInteractions,
|
|
3697
3747
|
...restProps
|
|
3698
3748
|
}) => {
|
|
3699
|
-
const { styles: styles2,
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
pauseInteractions: !interactive
|
|
3704
|
-
}
|
|
3705
|
-
);
|
|
3749
|
+
const { styles: styles2, classnames, children, type, events, linkProps, Tag } = useFrame(layerKey, {
|
|
3750
|
+
...restProps,
|
|
3751
|
+
pauseInteractions
|
|
3752
|
+
});
|
|
3706
3753
|
const resultStyles = inputStyles ?? styles2;
|
|
3707
3754
|
const isMounted = useMounted();
|
|
3708
3755
|
if (isMounted && hidden) {
|
|
@@ -3724,7 +3771,7 @@ const Frame = ({
|
|
|
3724
3771
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3725
3772
|
Tag,
|
|
3726
3773
|
{
|
|
3727
|
-
className:
|
|
3774
|
+
className: classnames,
|
|
3728
3775
|
"data-key": layerKey,
|
|
3729
3776
|
style: {
|
|
3730
3777
|
...resultStyles,
|
|
@@ -3740,7 +3787,7 @@ const Frame = ({
|
|
|
3740
3787
|
const FragmentInternal = ({
|
|
3741
3788
|
fragmentId,
|
|
3742
3789
|
globalManager,
|
|
3743
|
-
|
|
3790
|
+
pauseInteractions,
|
|
3744
3791
|
collectStyle,
|
|
3745
3792
|
FrameElement = Frame
|
|
3746
3793
|
}) => {
|
|
@@ -3772,7 +3819,7 @@ const FragmentInternal = ({
|
|
|
3772
3819
|
FrameElement,
|
|
3773
3820
|
{
|
|
3774
3821
|
layerKey: childLink,
|
|
3775
|
-
|
|
3822
|
+
pauseInteractions,
|
|
3776
3823
|
collectStyle,
|
|
3777
3824
|
hidden: !isResize && !isPrimary && !isTopFragment,
|
|
3778
3825
|
style: { display: isPrimary ? null : "none" }
|
|
@@ -3797,7 +3844,7 @@ const Fragment = (props) => {
|
|
|
3797
3844
|
const InstanceInitial = ({
|
|
3798
3845
|
Tag: inputTag,
|
|
3799
3846
|
style = {},
|
|
3800
|
-
|
|
3847
|
+
pauseInteractions,
|
|
3801
3848
|
FrameElement,
|
|
3802
3849
|
...instanceProps
|
|
3803
3850
|
}) => {
|
|
@@ -3811,13 +3858,13 @@ const InstanceInitial = ({
|
|
|
3811
3858
|
parentManager,
|
|
3812
3859
|
events,
|
|
3813
3860
|
props,
|
|
3814
|
-
|
|
3861
|
+
classnames,
|
|
3815
3862
|
innerManager,
|
|
3816
3863
|
definitions,
|
|
3817
3864
|
globalManager
|
|
3818
3865
|
} = useInstance({
|
|
3819
3866
|
...instanceProps,
|
|
3820
|
-
pauseInteractions
|
|
3867
|
+
pauseInteractions
|
|
3821
3868
|
});
|
|
3822
3869
|
if (ssr) {
|
|
3823
3870
|
(_c = (_b = globalManager == null ? void 0 : globalManager.$load) == null ? void 0 : _b.loadFragment) == null ? void 0 : _c.call(_b, fragmentId, { suspense: true });
|
|
@@ -3848,7 +3895,7 @@ const InstanceInitial = ({
|
|
|
3848
3895
|
children: parentManager ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3849
3896
|
Tag,
|
|
3850
3897
|
{
|
|
3851
|
-
className:
|
|
3898
|
+
className: classnames,
|
|
3852
3899
|
"data-key": instanceProps.layerKey,
|
|
3853
3900
|
style: { ...style, ...cssProps },
|
|
3854
3901
|
...link.linkProps,
|
|
@@ -3859,7 +3906,7 @@ const InstanceInitial = ({
|
|
|
3859
3906
|
fragmentId,
|
|
3860
3907
|
globalManager,
|
|
3861
3908
|
FrameElement,
|
|
3862
|
-
|
|
3909
|
+
pauseInteractions
|
|
3863
3910
|
}
|
|
3864
3911
|
)
|
|
3865
3912
|
}
|
|
@@ -3869,7 +3916,7 @@ const InstanceInitial = ({
|
|
|
3869
3916
|
fragmentId,
|
|
3870
3917
|
globalManager,
|
|
3871
3918
|
FrameElement,
|
|
3872
|
-
|
|
3919
|
+
pauseInteractions
|
|
3873
3920
|
}
|
|
3874
3921
|
) })
|
|
3875
3922
|
}
|
|
@@ -3892,7 +3939,18 @@ const AreaInitial = (areaProps) => {
|
|
|
3892
3939
|
}
|
|
3893
3940
|
const areaData = useArea(areaProps);
|
|
3894
3941
|
if (!areaData) return null;
|
|
3895
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3942
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3943
|
+
Scope,
|
|
3944
|
+
{
|
|
3945
|
+
fragmentManager: areaData.fragmentManager,
|
|
3946
|
+
layerKey: "Area",
|
|
3947
|
+
value: {
|
|
3948
|
+
type: definition.definition.scopeTypes.AreaScope,
|
|
3949
|
+
...areaData ?? {}
|
|
3950
|
+
},
|
|
3951
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Instance, { fragmentId: areaData.fragmentId, props: areaData == null ? void 0 : areaData.props })
|
|
3952
|
+
}
|
|
3953
|
+
);
|
|
3896
3954
|
};
|
|
3897
3955
|
const Area = (props) => {
|
|
3898
3956
|
return "globalManager" in props ? /* @__PURE__ */ jsxRuntime.jsx(require$$0.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(GlobalManager, { value: props.globalManager, children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(require$$0.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) });
|
package/dist/index.es.js
CHANGED
|
@@ -390,6 +390,7 @@ const renderMode = createConstants("viewport", "parent", "fixed");
|
|
|
390
390
|
const interactions = createConstants("click", "mouseover", "appear");
|
|
391
391
|
const eventMode = createConstants("goal", "callback", "tracker");
|
|
392
392
|
const scopeTypes = createConstants(
|
|
393
|
+
"AreaScope",
|
|
393
394
|
"InstanceScope",
|
|
394
395
|
"FragmentScope",
|
|
395
396
|
"CollectionScope",
|
|
@@ -1280,7 +1281,8 @@ const SceneSchema = /* @__PURE__ */ object({
|
|
|
1280
1281
|
}),
|
|
1281
1282
|
visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
|
|
1282
1283
|
rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
1283
|
-
zIndex: layerField(/* @__PURE__ */ number(), { fallback:
|
|
1284
|
+
zIndex: layerField(/* @__PURE__ */ number(), { fallback: null }),
|
|
1285
|
+
classnames: layerField(/* @__PURE__ */ array(/* @__PURE__ */ number()), { fallback: [] })
|
|
1284
1286
|
});
|
|
1285
1287
|
const FillSchema = /* @__PURE__ */ object({
|
|
1286
1288
|
fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
|
|
@@ -1427,7 +1429,7 @@ const TextSchema = /* @__PURE__ */ object({
|
|
|
1427
1429
|
fallback: ""
|
|
1428
1430
|
}),
|
|
1429
1431
|
whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
|
|
1430
|
-
fallback: whiteSpace.
|
|
1432
|
+
fallback: whiteSpace.normal
|
|
1431
1433
|
}),
|
|
1432
1434
|
textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
|
|
1433
1435
|
parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
|
|
@@ -1549,6 +1551,7 @@ const StringVariableSchema = /* @__PURE__ */ object({
|
|
|
1549
1551
|
required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1550
1552
|
placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
|
|
1551
1553
|
isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1554
|
+
isRich: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
|
|
1552
1555
|
...GraphFieldSchema.entries
|
|
1553
1556
|
});
|
|
1554
1557
|
const EventVariableSchema = /* @__PURE__ */ object({
|
|
@@ -2192,6 +2195,8 @@ function isFiniteNumber(value) {
|
|
|
2192
2195
|
}
|
|
2193
2196
|
var setKey$1 = (v2) => `$${v2}`;
|
|
2194
2197
|
function hashGenerator(layerKey) {
|
|
2198
|
+
if (!(layerKey == null ? void 0 : layerKey.length))
|
|
2199
|
+
return layerKey;
|
|
2195
2200
|
let hash = 0;
|
|
2196
2201
|
for (let i2 = 0; i2 < layerKey.length; i2++) {
|
|
2197
2202
|
hash = (hash << 5) - hash + layerKey.charCodeAt(i2);
|
|
@@ -2228,7 +2233,7 @@ const useGlobalManager = (globalManager) => {
|
|
|
2228
2233
|
setRenderTarget
|
|
2229
2234
|
};
|
|
2230
2235
|
};
|
|
2231
|
-
const useFragmentManager = (fragmentId, inputGlobalManager
|
|
2236
|
+
const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
2232
2237
|
var _a;
|
|
2233
2238
|
const {
|
|
2234
2239
|
fragmentsGraph,
|
|
@@ -2319,7 +2324,7 @@ const cloneLayer = (manager, layer, externalProps = {}, _parent) => {
|
|
|
2319
2324
|
_type: layerGraph._type,
|
|
2320
2325
|
overrideFrom: setKey(layerKey),
|
|
2321
2326
|
parent: setKey(layerParent),
|
|
2322
|
-
...(layerGraph == null ? void 0 : layerGraph._type) === index.nodes.Instance ? pick(layerGraph, "fragment") : {},
|
|
2327
|
+
...(layerGraph == null ? void 0 : layerGraph._type) === index.nodes.Instance ? pick(layerGraph, "fragment", "props") : {},
|
|
2323
2328
|
...externalProps
|
|
2324
2329
|
},
|
|
2325
2330
|
true
|
|
@@ -2851,7 +2856,7 @@ const useLayerSizeValue = (layerKey, sizeType) => {
|
|
|
2851
2856
|
return "100%";
|
|
2852
2857
|
}
|
|
2853
2858
|
if (autoSizes.includes(valueType)) {
|
|
2854
|
-
return layerNode._type === index.nodes.Instance ? "auto" : "
|
|
2859
|
+
return layerNode._type === index.nodes.Instance ? "auto" : "fit-content";
|
|
2855
2860
|
}
|
|
2856
2861
|
if (valueType === index.sizing.Relative) {
|
|
2857
2862
|
return `${value}%`;
|
|
@@ -2929,13 +2934,14 @@ const useLayerBackground = (layerKey) => {
|
|
|
2929
2934
|
"solidFill",
|
|
2930
2935
|
fragmentManager
|
|
2931
2936
|
);
|
|
2932
|
-
const [imageFill, ,
|
|
2937
|
+
const [imageFill, , cssImageFillOptions] = useLayerValue(
|
|
2933
2938
|
layerKey,
|
|
2934
2939
|
"imageFill",
|
|
2935
2940
|
fragmentManager
|
|
2936
2941
|
);
|
|
2942
|
+
const imageSizeLayerKey = (cssImageFillOptions == null ? void 0 : cssImageFillOptions.isVariable) ? cssImageFillOptions == null ? void 0 : cssImageFillOptions.rawValue : layerKey;
|
|
2937
2943
|
const [, , { cssVariableValue: cssImageSize }] = useLayerValue(
|
|
2938
|
-
|
|
2944
|
+
imageSizeLayerKey,
|
|
2939
2945
|
"imageSize",
|
|
2940
2946
|
fragmentManager
|
|
2941
2947
|
);
|
|
@@ -2945,7 +2951,7 @@ const useLayerBackground = (layerKey) => {
|
|
|
2945
2951
|
background: cssSolidFill
|
|
2946
2952
|
};
|
|
2947
2953
|
}
|
|
2948
|
-
if (fillType === index.paintMode.Image &&
|
|
2954
|
+
if (fillType === index.paintMode.Image && cssImageFillOptions.cssVariableValue) {
|
|
2949
2955
|
return {
|
|
2950
2956
|
background: `url(${imageFill})`,
|
|
2951
2957
|
backgroundSize: cssImageSize == null ? void 0 : cssImageSize.toLowerCase(),
|
|
@@ -2955,7 +2961,12 @@ const useLayerBackground = (layerKey) => {
|
|
|
2955
2961
|
return {
|
|
2956
2962
|
background: "transparent"
|
|
2957
2963
|
};
|
|
2958
|
-
}, [
|
|
2964
|
+
}, [
|
|
2965
|
+
fillType,
|
|
2966
|
+
cssImageFillOptions.cssVariableValue,
|
|
2967
|
+
cssSolidFill,
|
|
2968
|
+
cssImageSize
|
|
2969
|
+
]);
|
|
2959
2970
|
};
|
|
2960
2971
|
const useLayerDisplay = (layerKey) => {
|
|
2961
2972
|
const { manager } = useContext(FragmentContext);
|
|
@@ -3008,7 +3019,11 @@ const useCalcLayerBorder = (layerKey) => {
|
|
|
3008
3019
|
const useLayerBorder = (layerKey) => {
|
|
3009
3020
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
3010
3021
|
const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
|
|
3011
|
-
const [borderColor] = useLayerValue(
|
|
3022
|
+
const [, , { cssVariableValue: borderColor }] = useLayerValue(
|
|
3023
|
+
layerKey,
|
|
3024
|
+
"borderColor",
|
|
3025
|
+
fragmentManager
|
|
3026
|
+
);
|
|
3012
3027
|
const calcBorder = useCalcLayerBorder(layerKey);
|
|
3013
3028
|
return useMemo(
|
|
3014
3029
|
() => calcBorder(borderWidth, borderColor),
|
|
@@ -3089,12 +3104,14 @@ const useLayerStyles = (layerKey) => {
|
|
|
3089
3104
|
);
|
|
3090
3105
|
const [whiteSpace2] = useLayerValue(layerKey, "whiteSpace", fragmentManager);
|
|
3091
3106
|
const textStyles = useLayerTextStyles(layerKey);
|
|
3107
|
+
const [overflow2] = useLayerValue(layerKey, "overflow", fragmentManager);
|
|
3092
3108
|
return {
|
|
3093
3109
|
// ...(props ?? {}),
|
|
3094
3110
|
...border,
|
|
3095
3111
|
...background,
|
|
3096
3112
|
...position,
|
|
3097
3113
|
opacity,
|
|
3114
|
+
overflow: overflow2,
|
|
3098
3115
|
rotate: isValue(rotate) ? `${rotate}deg` : null,
|
|
3099
3116
|
"border-radius": borderRadius,
|
|
3100
3117
|
"white-space": whiteSpace2,
|
|
@@ -3119,12 +3136,6 @@ const useFragmentProperties = (fragmentId) => {
|
|
|
3119
3136
|
manager
|
|
3120
3137
|
};
|
|
3121
3138
|
};
|
|
3122
|
-
const useHash = (layerKey, manager) => {
|
|
3123
|
-
if (!layerKey || !manager) return null;
|
|
3124
|
-
const layer = manager.resolve(layerKey);
|
|
3125
|
-
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
3126
|
-
return hashGenerator(overrideFrom ?? layerKey);
|
|
3127
|
-
};
|
|
3128
3139
|
const useInstanceProps = (instanceProps) => {
|
|
3129
3140
|
const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
|
|
3130
3141
|
const { manager: loadedManager } = useFragmentManager(
|
|
@@ -3158,10 +3169,32 @@ const useInstanceProps = (instanceProps) => {
|
|
|
3158
3169
|
cssProps: getCssVariables(mergedProps)
|
|
3159
3170
|
};
|
|
3160
3171
|
};
|
|
3172
|
+
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
3173
|
+
var _a, _b, _c, _d;
|
|
3174
|
+
if (!fragmentManager || !layerKey) return [];
|
|
3175
|
+
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
3176
|
+
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
3177
|
+
layerParents.forEach((parent) => {
|
|
3178
|
+
var _a2, _b2, _c2, _d2;
|
|
3179
|
+
const parentLink = keyOfEntity(parent);
|
|
3180
|
+
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
3181
|
+
resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
|
|
3182
|
+
}
|
|
3183
|
+
});
|
|
3184
|
+
const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
|
|
3185
|
+
if (areaScope) {
|
|
3186
|
+
resultScopes.push(areaScope);
|
|
3187
|
+
}
|
|
3188
|
+
return resultScopes;
|
|
3189
|
+
};
|
|
3161
3190
|
const useLayerInteractions = (layerKey, options2) => {
|
|
3162
3191
|
const pause = (options2 == null ? void 0 : options2.pauseInteractions) ?? false;
|
|
3163
3192
|
const { manager: globalManager } = useGlobalManager();
|
|
3164
3193
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
3194
|
+
const scopes = useLayerScopes(fragmentManager, layerKey);
|
|
3195
|
+
const areaScope = scopes.find(
|
|
3196
|
+
(scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.AreaScope
|
|
3197
|
+
);
|
|
3165
3198
|
const [interactions2] = useLayerValue(
|
|
3166
3199
|
layerKey,
|
|
3167
3200
|
"interactions",
|
|
@@ -3171,10 +3204,14 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
3171
3204
|
const fireEvent = useCallback(
|
|
3172
3205
|
(eventLink) => {
|
|
3173
3206
|
var _a, _b, _c, _d;
|
|
3207
|
+
if (!areaScope) return null;
|
|
3174
3208
|
const event = fragmentManager.resolve(eventLink);
|
|
3175
3209
|
const { value: eventValue } = readVariable(eventLink);
|
|
3176
|
-
if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.
|
|
3177
|
-
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a,
|
|
3210
|
+
if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
3211
|
+
(_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, {
|
|
3212
|
+
goalId: eventValue == null ? void 0 : eventValue.goalId,
|
|
3213
|
+
...pick(areaScope, "variantId", "campaignId", "areaId")
|
|
3214
|
+
});
|
|
3178
3215
|
}
|
|
3179
3216
|
if ((event == null ? void 0 : event.mode) === index.eventMode.tracker && eventValue) {
|
|
3180
3217
|
(_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
|
|
@@ -3183,13 +3220,13 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
3183
3220
|
eventValue();
|
|
3184
3221
|
}
|
|
3185
3222
|
},
|
|
3186
|
-
[globalManager, fragmentManager]
|
|
3223
|
+
[globalManager, fragmentManager, areaScope]
|
|
3187
3224
|
);
|
|
3188
3225
|
useEffect(() => {
|
|
3189
3226
|
if (!pause && Array.isArray(interactions2)) {
|
|
3190
3227
|
interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.appear).map((el) => el.event).forEach(fireEvent);
|
|
3191
3228
|
}
|
|
3192
|
-
}, [pause]);
|
|
3229
|
+
}, [pause, areaScope]);
|
|
3193
3230
|
return useMemo(() => {
|
|
3194
3231
|
if (!pause && !interactions2 || !Array.isArray(interactions2)) return {};
|
|
3195
3232
|
if (pause) return {};
|
|
@@ -3201,6 +3238,22 @@ const useLayerInteractions = (layerKey, options2) => {
|
|
|
3201
3238
|
};
|
|
3202
3239
|
}, [interactions2, fireEvent, pause]);
|
|
3203
3240
|
};
|
|
3241
|
+
const useHash = (layerKey, manager) => {
|
|
3242
|
+
if (!layerKey || !manager) return null;
|
|
3243
|
+
const layer = manager.resolve(layerKey);
|
|
3244
|
+
const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
|
|
3245
|
+
return hashGenerator(overrideFrom ?? layerKey);
|
|
3246
|
+
};
|
|
3247
|
+
const useClassnames = (layerKey, manager) => {
|
|
3248
|
+
const hash = useHash(layerKey, manager);
|
|
3249
|
+
const [classnames] = useLayerValue(layerKey, "classnames", { manager });
|
|
3250
|
+
if (!layerKey || !manager) return null;
|
|
3251
|
+
let base = [hash];
|
|
3252
|
+
if (classnames == null ? void 0 : classnames.length) {
|
|
3253
|
+
base = [...base, ...classnames];
|
|
3254
|
+
}
|
|
3255
|
+
return base.join(" ");
|
|
3256
|
+
};
|
|
3204
3257
|
const useInstance = (instanceProps) => {
|
|
3205
3258
|
const { manager: parentManager } = useContext(FragmentContext);
|
|
3206
3259
|
const [instanceLayer] = y(parentManager, instanceProps.layerKey);
|
|
@@ -3212,9 +3265,12 @@ const useInstance = (instanceProps) => {
|
|
|
3212
3265
|
const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
|
|
3213
3266
|
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
|
|
3214
3267
|
const { props, cssProps } = useInstanceProps(instanceProps);
|
|
3215
|
-
const
|
|
3268
|
+
const classnames = useClassnames(
|
|
3269
|
+
instanceProps.layerKey,
|
|
3270
|
+
innerFragmentManager
|
|
3271
|
+
);
|
|
3216
3272
|
return {
|
|
3217
|
-
|
|
3273
|
+
classnames,
|
|
3218
3274
|
styles: styles2,
|
|
3219
3275
|
events,
|
|
3220
3276
|
definitions,
|
|
@@ -3310,9 +3366,11 @@ const useFragment = (fragmentId, globalManager) => {
|
|
|
3310
3366
|
(_a = fragmentContext.manager) == null ? void 0 : _a.resolve(fragmentContext.fragmentLayerKey),
|
|
3311
3367
|
(_b = fragmentContext.manager) == null ? void 0 : _b.key
|
|
3312
3368
|
);
|
|
3313
|
-
mount();
|
|
3314
3369
|
}
|
|
3315
3370
|
useEffect(() => {
|
|
3371
|
+
if (fragmentContext.manager) {
|
|
3372
|
+
mount();
|
|
3373
|
+
}
|
|
3316
3374
|
return () => {
|
|
3317
3375
|
unmount();
|
|
3318
3376
|
};
|
|
@@ -3357,7 +3415,7 @@ const useFrame = (layerKey, options2) => {
|
|
|
3357
3415
|
const layer = fragmentManager.entityOfKey(layerKey);
|
|
3358
3416
|
const styles2 = useLayerStyles(layerKey);
|
|
3359
3417
|
const children = useLayerChildren(layerKey);
|
|
3360
|
-
const
|
|
3418
|
+
const classnames = useClassnames(layerKey, fragmentManager);
|
|
3361
3419
|
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
3362
3420
|
const events = useLayerInteractions(layerKey, options2);
|
|
3363
3421
|
const link = useLayerLink(layerKey);
|
|
@@ -3367,7 +3425,7 @@ const useFrame = (layerKey, options2) => {
|
|
|
3367
3425
|
return {
|
|
3368
3426
|
Tag: (link == null ? void 0 : link.isLink) ? (options2 == null ? void 0 : options2.FrameTag) ?? "a" : (options2 == null ? void 0 : options2.FrameTag) ?? "div",
|
|
3369
3427
|
type: layer == null ? void 0 : layer._type,
|
|
3370
|
-
|
|
3428
|
+
classnames,
|
|
3371
3429
|
styles: {},
|
|
3372
3430
|
//isBrowser ? pick(styles, "background") : {},
|
|
3373
3431
|
children,
|
|
@@ -3420,14 +3478,14 @@ const useTextAttributes = (layerKey, options2) => {
|
|
|
3420
3478
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
3421
3479
|
const styles2 = useLayerStyles(layerKey);
|
|
3422
3480
|
const content = useTextContent(layerKey);
|
|
3423
|
-
const
|
|
3481
|
+
const classnames = useClassnames(layerKey, fragmentManager);
|
|
3424
3482
|
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
3425
3483
|
if (collectStyle) {
|
|
3426
3484
|
addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
|
|
3427
3485
|
}
|
|
3428
3486
|
return {
|
|
3429
3487
|
styles: styles2,
|
|
3430
|
-
|
|
3488
|
+
classnames,
|
|
3431
3489
|
content
|
|
3432
3490
|
};
|
|
3433
3491
|
};
|
|
@@ -3513,19 +3571,6 @@ function useInjectedStyle() {
|
|
|
3513
3571
|
injectStyle
|
|
3514
3572
|
};
|
|
3515
3573
|
}
|
|
3516
|
-
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
3517
|
-
var _a, _b;
|
|
3518
|
-
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
3519
|
-
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
3520
|
-
layerParents.forEach((parent) => {
|
|
3521
|
-
var _a2, _b2, _c, _d;
|
|
3522
|
-
const parentLink = keyOfEntity(parent);
|
|
3523
|
-
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
3524
|
-
resultScopes.push((_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get(parentLink));
|
|
3525
|
-
}
|
|
3526
|
-
});
|
|
3527
|
-
return resultScopes;
|
|
3528
|
-
};
|
|
3529
3574
|
function cssToJsStyle(cssKey) {
|
|
3530
3575
|
return cssKey.replace(/-([a-z])/g, (_2, letter) => letter.toUpperCase());
|
|
3531
3576
|
}
|
|
@@ -3553,6 +3598,10 @@ const useArea = (options2) => {
|
|
|
3553
3598
|
options2 == null ? void 0 : options2.globalManager
|
|
3554
3599
|
);
|
|
3555
3600
|
const [areaData, setAreaData] = useState(queryArea(options2.areaCode));
|
|
3601
|
+
const { manager: fragmentManager } = useFragmentManager(
|
|
3602
|
+
areaData.fragmentId,
|
|
3603
|
+
resultGlobalManager
|
|
3604
|
+
);
|
|
3556
3605
|
const resultProps = useMemo(
|
|
3557
3606
|
() => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options2 == null ? void 0 : options2.props) ?? [] }),
|
|
3558
3607
|
[areaData, options2]
|
|
@@ -3567,6 +3616,7 @@ const useArea = (options2) => {
|
|
|
3567
3616
|
}, []);
|
|
3568
3617
|
return {
|
|
3569
3618
|
...areaData,
|
|
3619
|
+
fragmentManager,
|
|
3570
3620
|
props: resultProps,
|
|
3571
3621
|
globalManager: resultGlobalManager
|
|
3572
3622
|
};
|
|
@@ -3601,8 +3651,8 @@ const Text = ({
|
|
|
3601
3651
|
collectStyle,
|
|
3602
3652
|
...restProps
|
|
3603
3653
|
}) => {
|
|
3604
|
-
const {
|
|
3605
|
-
return /* @__PURE__ */ jsx(Tag, { className:
|
|
3654
|
+
const { classnames, content } = useTextAttributes(layerKey, { collectStyle });
|
|
3655
|
+
return /* @__PURE__ */ jsx(Tag, { className: classnames, "data-key": layerKey, ...restProps, children: /* @__PURE__ */ jsx(
|
|
3606
3656
|
"div",
|
|
3607
3657
|
{
|
|
3608
3658
|
className: styles.text,
|
|
@@ -3632,7 +3682,7 @@ const Collection = ({
|
|
|
3632
3682
|
fragmentManager,
|
|
3633
3683
|
styles: styles2,
|
|
3634
3684
|
sourceDefinition,
|
|
3635
|
-
|
|
3685
|
+
classnames,
|
|
3636
3686
|
source,
|
|
3637
3687
|
children,
|
|
3638
3688
|
sourceValue
|
|
@@ -3653,7 +3703,7 @@ const Collection = ({
|
|
|
3653
3703
|
children: /* @__PURE__ */ jsx(
|
|
3654
3704
|
FrameTag,
|
|
3655
3705
|
{
|
|
3656
|
-
className:
|
|
3706
|
+
className: classnames,
|
|
3657
3707
|
"data-key": layerKey,
|
|
3658
3708
|
style: resultStyles,
|
|
3659
3709
|
...restProps,
|
|
@@ -3691,16 +3741,13 @@ const Frame = ({
|
|
|
3691
3741
|
layerKey,
|
|
3692
3742
|
styles: inputStyles,
|
|
3693
3743
|
hidden,
|
|
3694
|
-
|
|
3744
|
+
pauseInteractions,
|
|
3695
3745
|
...restProps
|
|
3696
3746
|
}) => {
|
|
3697
|
-
const { styles: styles2,
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
pauseInteractions: !interactive
|
|
3702
|
-
}
|
|
3703
|
-
);
|
|
3747
|
+
const { styles: styles2, classnames, children, type, events, linkProps, Tag } = useFrame(layerKey, {
|
|
3748
|
+
...restProps,
|
|
3749
|
+
pauseInteractions
|
|
3750
|
+
});
|
|
3704
3751
|
const resultStyles = inputStyles ?? styles2;
|
|
3705
3752
|
const isMounted = useMounted();
|
|
3706
3753
|
if (isMounted && hidden) {
|
|
@@ -3722,7 +3769,7 @@ const Frame = ({
|
|
|
3722
3769
|
return /* @__PURE__ */ jsx(
|
|
3723
3770
|
Tag,
|
|
3724
3771
|
{
|
|
3725
|
-
className:
|
|
3772
|
+
className: classnames,
|
|
3726
3773
|
"data-key": layerKey,
|
|
3727
3774
|
style: {
|
|
3728
3775
|
...resultStyles,
|
|
@@ -3738,7 +3785,7 @@ const Frame = ({
|
|
|
3738
3785
|
const FragmentInternal = ({
|
|
3739
3786
|
fragmentId,
|
|
3740
3787
|
globalManager,
|
|
3741
|
-
|
|
3788
|
+
pauseInteractions,
|
|
3742
3789
|
collectStyle,
|
|
3743
3790
|
FrameElement = Frame
|
|
3744
3791
|
}) => {
|
|
@@ -3770,7 +3817,7 @@ const FragmentInternal = ({
|
|
|
3770
3817
|
FrameElement,
|
|
3771
3818
|
{
|
|
3772
3819
|
layerKey: childLink,
|
|
3773
|
-
|
|
3820
|
+
pauseInteractions,
|
|
3774
3821
|
collectStyle,
|
|
3775
3822
|
hidden: !isResize && !isPrimary && !isTopFragment,
|
|
3776
3823
|
style: { display: isPrimary ? null : "none" }
|
|
@@ -3795,7 +3842,7 @@ const Fragment = (props) => {
|
|
|
3795
3842
|
const InstanceInitial = ({
|
|
3796
3843
|
Tag: inputTag,
|
|
3797
3844
|
style = {},
|
|
3798
|
-
|
|
3845
|
+
pauseInteractions,
|
|
3799
3846
|
FrameElement,
|
|
3800
3847
|
...instanceProps
|
|
3801
3848
|
}) => {
|
|
@@ -3809,13 +3856,13 @@ const InstanceInitial = ({
|
|
|
3809
3856
|
parentManager,
|
|
3810
3857
|
events,
|
|
3811
3858
|
props,
|
|
3812
|
-
|
|
3859
|
+
classnames,
|
|
3813
3860
|
innerManager,
|
|
3814
3861
|
definitions,
|
|
3815
3862
|
globalManager
|
|
3816
3863
|
} = useInstance({
|
|
3817
3864
|
...instanceProps,
|
|
3818
|
-
pauseInteractions
|
|
3865
|
+
pauseInteractions
|
|
3819
3866
|
});
|
|
3820
3867
|
if (ssr) {
|
|
3821
3868
|
(_c = (_b = globalManager == null ? void 0 : globalManager.$load) == null ? void 0 : _b.loadFragment) == null ? void 0 : _c.call(_b, fragmentId, { suspense: true });
|
|
@@ -3846,7 +3893,7 @@ const InstanceInitial = ({
|
|
|
3846
3893
|
children: parentManager ? /* @__PURE__ */ jsx(
|
|
3847
3894
|
Tag,
|
|
3848
3895
|
{
|
|
3849
|
-
className:
|
|
3896
|
+
className: classnames,
|
|
3850
3897
|
"data-key": instanceProps.layerKey,
|
|
3851
3898
|
style: { ...style, ...cssProps },
|
|
3852
3899
|
...link.linkProps,
|
|
@@ -3857,7 +3904,7 @@ const InstanceInitial = ({
|
|
|
3857
3904
|
fragmentId,
|
|
3858
3905
|
globalManager,
|
|
3859
3906
|
FrameElement,
|
|
3860
|
-
|
|
3907
|
+
pauseInteractions
|
|
3861
3908
|
}
|
|
3862
3909
|
)
|
|
3863
3910
|
}
|
|
@@ -3867,7 +3914,7 @@ const InstanceInitial = ({
|
|
|
3867
3914
|
fragmentId,
|
|
3868
3915
|
globalManager,
|
|
3869
3916
|
FrameElement,
|
|
3870
|
-
|
|
3917
|
+
pauseInteractions
|
|
3871
3918
|
}
|
|
3872
3919
|
) })
|
|
3873
3920
|
}
|
|
@@ -3890,7 +3937,18 @@ const AreaInitial = (areaProps) => {
|
|
|
3890
3937
|
}
|
|
3891
3938
|
const areaData = useArea(areaProps);
|
|
3892
3939
|
if (!areaData) return null;
|
|
3893
|
-
return /* @__PURE__ */ jsx(
|
|
3940
|
+
return /* @__PURE__ */ jsx(
|
|
3941
|
+
Scope,
|
|
3942
|
+
{
|
|
3943
|
+
fragmentManager: areaData.fragmentManager,
|
|
3944
|
+
layerKey: "Area",
|
|
3945
|
+
value: {
|
|
3946
|
+
type: definition.scopeTypes.AreaScope,
|
|
3947
|
+
...areaData ?? {}
|
|
3948
|
+
},
|
|
3949
|
+
children: /* @__PURE__ */ jsx(Instance, { fragmentId: areaData.fragmentId, props: areaData == null ? void 0 : areaData.props })
|
|
3950
|
+
}
|
|
3951
|
+
);
|
|
3894
3952
|
};
|
|
3895
3953
|
const Area = (props) => {
|
|
3896
3954
|
return "globalManager" in props ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(GlobalManager, { value: props.globalManager, children: /* @__PURE__ */ jsx(AreaInitial, { ...props }) }) }) : /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(AreaInitial, { ...props }) });
|