@fragmentsx/render-react 1.6.3 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/layer/useReadVariables.d.ts.map +1 -1
- package/dist/hooks/layer/useResolvedLayerVariables.d.ts +1 -0
- package/dist/hooks/layer/useResolvedLayerVariables.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/index.d.ts +7 -1
- package/dist/hooks/layer-styles/useLayerStyles/index.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useImagePaint.d.ts +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useImagePaint.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useStyleRegistrar.d.ts +11 -0
- package/dist/hooks/layer-styles/useStyleRegistrar.d.ts.map +1 -0
- package/dist/hooks/utils/useClassnames.d.ts.map +1 -1
- package/dist/hooks/utils/useExtractProps.d.ts.map +1 -1
- package/dist/index.cjs.js +235 -177
- package/dist/index.es.js +235 -177
- package/dist/nodes/Collection/Collection.d.ts.map +1 -1
- package/dist/nodes/Collection/hooks/useCollection.d.ts +1 -2
- package/dist/nodes/Collection/hooks/useCollection.d.ts.map +1 -1
- package/dist/nodes/CollectionItem/CollectionItem.d.ts.map +1 -1
- package/dist/nodes/CollectionItem/hooks/useCollection.d.ts +1 -2
- package/dist/nodes/CollectionItem/hooks/useCollection.d.ts.map +1 -1
- package/dist/nodes/Frame/Frame.d.ts.map +1 -1
- package/dist/nodes/Frame/hooks/useFrame.d.ts +0 -1
- package/dist/nodes/Frame/hooks/useFrame.d.ts.map +1 -1
- package/dist/nodes/Instance/Instance.d.ts.map +1 -1
- package/dist/nodes/Instance/hooks/useInstance.d.ts +1 -1
- package/dist/nodes/Instance/test/text-css-vars.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/text-css-vars.browser.test.d.ts.map +1 -0
- package/dist/nodes/Text/Text.d.ts +1 -0
- package/dist/nodes/Text/Text.d.ts.map +1 -1
- package/dist/nodes/Text/hooks/useTextAttributes.d.ts +0 -1
- package/dist/nodes/Text/hooks/useTextAttributes.d.ts.map +1 -1
- package/dist/nodes/Text/hooks/useTextCssVars.d.ts +14 -0
- package/dist/nodes/Text/hooks/useTextCssVars.d.ts.map +1 -0
- package/dist/providers/InstanceContext.d.ts +1 -0
- package/dist/providers/InstanceContext.d.ts.map +1 -1
- package/dist/utils/variables/extractStyleVarIds.d.ts +6 -0
- package/dist/utils/variables/extractStyleVarIds.d.ts.map +1 -0
- package/dist/utils/variables/extractStyleVarIds.test.d.ts +2 -0
- package/dist/utils/variables/extractStyleVarIds.test.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -4,9 +4,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
import { createContext, useContext, useMemo, useCallback, useEffect, useState, useRef, memo, Suspense, Component } from "react";
|
|
5
5
|
import { definition, getNormalizeLayer as getNormalizeLayer$1, isVariableLink as isVariableLink$1, parseLayerField, isLink as isLink$1 } from "@fragmentsx/definition";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { useGraph, useGraphStack } from "@graph-state/react";
|
|
8
7
|
import { cleanGraph, generateId, getKey as getKey$1, isValue, isObject, pick, toPx, setKey as setKey$1, toKebabCase, set, isPrimitive, get, omit, noop, isFiniteNumber, hashGenerator as hashGenerator$1, isBrowser as isBrowser$1 } from "@fragmentsx/utils";
|
|
9
8
|
import { keyOfEntity, isPartialKey, entityOfKey, isLinkKey } from "@graph-state/core";
|
|
9
|
+
import { useGraph, useGraphStack } from "@graph-state/react";
|
|
10
10
|
import { createAreaManager, createCampaignManager } from "@fragmentsx/client-core";
|
|
11
11
|
const GlobalManagerContext = createContext(null);
|
|
12
12
|
const GlobalManagerProvider = GlobalManagerContext.Provider;
|
|
@@ -21,7 +21,8 @@ const InstanceContext = createContext({
|
|
|
21
21
|
innerManager: null,
|
|
22
22
|
props: {},
|
|
23
23
|
definitions: [],
|
|
24
|
-
onChangeProps: null
|
|
24
|
+
onChangeProps: null,
|
|
25
|
+
instanceId: null
|
|
25
26
|
});
|
|
26
27
|
const RenderTargetContext = createContext(
|
|
27
28
|
definition.renderTarget.document
|
|
@@ -928,21 +929,22 @@ const useReadVariables = (variableKeys, customManager) => {
|
|
|
928
929
|
return filterKeys.map((variableKey, index) => {
|
|
929
930
|
var _a2, _b2;
|
|
930
931
|
variableLayers[index];
|
|
931
|
-
const layer = ((_a2 = getNormalizeLayer(variableKey, resultManager)) == null ? void 0 : _a2.layer) ?? null;
|
|
932
|
-
const { _id: propertyId } = layer ?? {};
|
|
933
|
-
let collectionItemProp = void 0;
|
|
934
|
-
if (lastCollectionItem && propertyId) {
|
|
935
|
-
collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_b2 = entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _b2._id) === propertyId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, propertyId);
|
|
936
|
-
}
|
|
937
|
-
const instanceProp = (instanceProps == null ? void 0 : instanceProps[propertyId]) ?? null;
|
|
938
932
|
const campaignLayer = campaignManager == null ? void 0 : campaignManager.resolve(variableKey);
|
|
939
933
|
const campaignProp = (campaignLayer == null ? void 0 : campaignLayer.defaultValue) ?? null;
|
|
940
934
|
const areaLayer = areaManager == null ? void 0 : areaManager.resolve(variableKey);
|
|
941
935
|
const areaProp = (areaLayer == null ? void 0 : areaLayer.defaultValue) ?? null;
|
|
942
936
|
const globalLayer = globalManager == null ? void 0 : globalManager.resolve(variableKey);
|
|
943
937
|
const globalProp = (globalLayer == null ? void 0 : globalLayer.defaultValue) ?? null;
|
|
944
|
-
const
|
|
945
|
-
const
|
|
938
|
+
const fragmentLayer = ((_a2 = getNormalizeLayer(variableKey, resultManager)) == null ? void 0 : _a2.layer) ?? null;
|
|
939
|
+
const layer = fragmentLayer ?? campaignLayer ?? areaLayer ?? globalLayer ?? null;
|
|
940
|
+
const { _id: propertyId } = layer ?? {};
|
|
941
|
+
let collectionItemProp = void 0;
|
|
942
|
+
if (lastCollectionItem && propertyId) {
|
|
943
|
+
collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_b2 = entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _b2._id) === propertyId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, propertyId);
|
|
944
|
+
}
|
|
945
|
+
const instanceProp = (instanceProps == null ? void 0 : instanceProps[propertyId]) ?? null;
|
|
946
|
+
const required = (fragmentLayer == null ? void 0 : fragmentLayer.required) ?? (layer == null ? void 0 : layer.required) ?? false;
|
|
947
|
+
const defaultValue = (fragmentLayer == null ? void 0 : fragmentLayer.defaultValue) ?? (layer == null ? void 0 : layer.defaultValue) ?? null;
|
|
946
948
|
const currentValue = collectionItemProp ?? (variableKey === instanceProp ? null : instanceProp) ?? campaignProp ?? areaProp ?? globalProp ?? null;
|
|
947
949
|
const resultValue = required ? currentValue : currentValue ?? defaultValue;
|
|
948
950
|
if (isVariableLink$1(resultValue)) {
|
|
@@ -951,7 +953,7 @@ const useReadVariables = (variableKeys, customManager) => {
|
|
|
951
953
|
const refAreaLayer = areaManager == null ? void 0 : areaManager.resolve(refKey);
|
|
952
954
|
const refGlobalLayer = globalManager == null ? void 0 : globalManager.resolve(refKey);
|
|
953
955
|
const refFragmentLayer = resultManager == null ? void 0 : resultManager.resolve(refKey);
|
|
954
|
-
const refValue = (refCampaignLayer == null ? void 0 : refCampaignLayer.defaultValue) ?? (refAreaLayer == null ? void 0 : refAreaLayer.defaultValue) ?? (refGlobalLayer == null ? void 0 : refGlobalLayer.defaultValue) ?? (refFragmentLayer == null ? void 0 : refFragmentLayer.defaultValue) ??
|
|
956
|
+
const refValue = (refCampaignLayer == null ? void 0 : refCampaignLayer.defaultValue) ?? (refAreaLayer == null ? void 0 : refAreaLayer.defaultValue) ?? (refGlobalLayer == null ? void 0 : refGlobalLayer.defaultValue) ?? (refFragmentLayer == null ? void 0 : refFragmentLayer.defaultValue) ?? null;
|
|
955
957
|
return {
|
|
956
958
|
value: refValue,
|
|
957
959
|
layer: refCampaignLayer ?? refAreaLayer ?? refGlobalLayer ?? refFragmentLayer ?? null
|
|
@@ -966,7 +968,8 @@ const useReadVariables = (variableKeys, customManager) => {
|
|
|
966
968
|
const EMPTY_RESOLVED = {
|
|
967
969
|
values: {},
|
|
968
970
|
cssVariableValues: {},
|
|
969
|
-
rawValues: {}
|
|
971
|
+
rawValues: {},
|
|
972
|
+
isVariable: {}
|
|
970
973
|
};
|
|
971
974
|
const collectVariableKeys = (layer) => {
|
|
972
975
|
const keys = [];
|
|
@@ -1001,9 +1004,11 @@ const useResolvedLayerVariables = (layer, rawLayer, _customScopes) => {
|
|
|
1001
1004
|
const values = {};
|
|
1002
1005
|
const cssVariableValues = {};
|
|
1003
1006
|
const rawValues = {};
|
|
1007
|
+
const isVariable = {};
|
|
1004
1008
|
const resolveField = (fieldPath, value, raw) => {
|
|
1005
1009
|
var _a2;
|
|
1006
1010
|
rawValues[fieldPath] = raw;
|
|
1011
|
+
isVariable[fieldPath] = isVariableLink$1(value);
|
|
1007
1012
|
if (isVariableLink$1(value)) {
|
|
1008
1013
|
const resolvedValue = value in resolvedByKey ? resolvedByKey[value] : value;
|
|
1009
1014
|
values[fieldPath] = resolvedValue;
|
|
@@ -1029,7 +1034,7 @@ const useResolvedLayerVariables = (layer, rawLayer, _customScopes) => {
|
|
|
1029
1034
|
}
|
|
1030
1035
|
}
|
|
1031
1036
|
}
|
|
1032
|
-
return { values, cssVariableValues, rawValues };
|
|
1037
|
+
return { values, cssVariableValues, rawValues, isVariable };
|
|
1033
1038
|
};
|
|
1034
1039
|
const useRenderTarget = () => {
|
|
1035
1040
|
const renderTarget = useContext(RenderTargetContext);
|
|
@@ -1269,10 +1274,10 @@ const useLayerLinearGradient = (linearGradientLink) => {
|
|
|
1269
1274
|
const stopsPosition = useLayersValue(stops, "position");
|
|
1270
1275
|
const stopValues = useMemo(
|
|
1271
1276
|
() => (stops == null ? void 0 : stops.flatMap((stop, index) => {
|
|
1272
|
-
var _a, _b
|
|
1277
|
+
var _a, _b;
|
|
1273
1278
|
return [
|
|
1274
|
-
(
|
|
1275
|
-
(
|
|
1279
|
+
(_a = stopsValue == null ? void 0 : stopsValue.at(index)) == null ? void 0 : _a.at(0),
|
|
1280
|
+
(_b = stopsPosition == null ? void 0 : stopsPosition.at(index)) == null ? void 0 : _b.at(0)
|
|
1276
1281
|
];
|
|
1277
1282
|
})) ?? [],
|
|
1278
1283
|
[stops, stopsValue, stopsPosition]
|
|
@@ -1284,6 +1289,40 @@ const useLayerLinearGradient = (linearGradientLink) => {
|
|
|
1284
1289
|
[angle, stopValues]
|
|
1285
1290
|
);
|
|
1286
1291
|
};
|
|
1292
|
+
const useStyleRegistrar = (layerKey) => {
|
|
1293
|
+
const { manager } = useContext(FragmentContext);
|
|
1294
|
+
const { instanceId } = useContext(InstanceContext);
|
|
1295
|
+
const baseline = {};
|
|
1296
|
+
const instance = {};
|
|
1297
|
+
const hasInstance = !!instanceId;
|
|
1298
|
+
return {
|
|
1299
|
+
baseline,
|
|
1300
|
+
instance,
|
|
1301
|
+
add(prop, value, isDynamic) {
|
|
1302
|
+
(isDynamic && hasInstance ? instance : baseline)[prop] = value;
|
|
1303
|
+
},
|
|
1304
|
+
addAll(styles, isDynamic) {
|
|
1305
|
+
if (styles) {
|
|
1306
|
+
Object.assign(isDynamic && hasInstance ? instance : baseline, styles);
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
flush() {
|
|
1310
|
+
var _a, _b, _c, _d;
|
|
1311
|
+
(_b = (_a = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a.addBaselineStyle) == null ? void 0 : _b.call(_a, layerKey, baseline);
|
|
1312
|
+
if (instanceId && Object.keys(instance).length > 0) {
|
|
1313
|
+
(_d = (_c = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _c.addInstanceStyle) == null ? void 0 : _d.call(
|
|
1314
|
+
_c,
|
|
1315
|
+
layerKey,
|
|
1316
|
+
instanceId,
|
|
1317
|
+
instance
|
|
1318
|
+
);
|
|
1319
|
+
}
|
|
1320
|
+
},
|
|
1321
|
+
getStyles() {
|
|
1322
|
+
return { ...baseline, ...instance };
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
};
|
|
1287
1326
|
const processOptionalSize = (value, type) => {
|
|
1288
1327
|
if (value === -1) return "";
|
|
1289
1328
|
if (type === definition.sizing.Fixed) return toPx(value);
|
|
@@ -1515,7 +1554,7 @@ const useLayerPosition = (layerKey) => {
|
|
|
1515
1554
|
const calcImagePaint = (imageVars) => {
|
|
1516
1555
|
var _a, _b;
|
|
1517
1556
|
return {
|
|
1518
|
-
background: imageVars.
|
|
1557
|
+
background: transformCssValue(imageVars.values.src),
|
|
1519
1558
|
backgroundRepeat: "no-repeat",
|
|
1520
1559
|
backgroundSize: (_b = (_a = imageVars.values.scale) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a)
|
|
1521
1560
|
};
|
|
@@ -1533,16 +1572,16 @@ const useImagePaint = (imageLinkKey) => {
|
|
|
1533
1572
|
};
|
|
1534
1573
|
const calcLayerBackground = (paintVars, imageVars, imageSizeVars, linearGradient) => {
|
|
1535
1574
|
const fillType = paintVars.values.type;
|
|
1536
|
-
const
|
|
1537
|
-
const
|
|
1575
|
+
const solidFill = paintVars.values.solid;
|
|
1576
|
+
const imageSize = imageSizeVars.values.imageSize;
|
|
1538
1577
|
if (fillType === definition.paintMode.Solid) {
|
|
1539
|
-
return { background:
|
|
1578
|
+
return { background: solidFill };
|
|
1540
1579
|
}
|
|
1541
1580
|
if (fillType === definition.paintMode.Image) {
|
|
1542
1581
|
const image = calcImagePaint(imageVars);
|
|
1543
1582
|
return {
|
|
1544
1583
|
...image,
|
|
1545
|
-
backgroundSize:
|
|
1584
|
+
backgroundSize: imageSize ?? image.backgroundSize
|
|
1546
1585
|
};
|
|
1547
1586
|
}
|
|
1548
1587
|
if (fillType === definition.paintMode.LinearGradient) {
|
|
@@ -1660,7 +1699,7 @@ const calcLayerBorder = (borderVars, borderPaintVars, borderLinearGradient, pain
|
|
|
1660
1699
|
};
|
|
1661
1700
|
}
|
|
1662
1701
|
if (borderPaint.type === definition.paintMode.Solid) {
|
|
1663
|
-
return calcBorderSides(type, width, borderPaint.
|
|
1702
|
+
return calcBorderSides(type, width, borderPaint.solid);
|
|
1664
1703
|
}
|
|
1665
1704
|
return { border: null };
|
|
1666
1705
|
};
|
|
@@ -1805,7 +1844,9 @@ const useLayerFlex = (layerKey) => {
|
|
|
1805
1844
|
};
|
|
1806
1845
|
};
|
|
1807
1846
|
const SKIP_OVERRIDE = { skipOverrideCheck: true };
|
|
1808
|
-
const useLayerStyles = (layerKey) => {
|
|
1847
|
+
const useLayerStyles = (layerKey, options) => {
|
|
1848
|
+
const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
|
|
1849
|
+
const reg = (options == null ? void 0 : options.registrar) ?? useStyleRegistrar(layerKey);
|
|
1809
1850
|
try {
|
|
1810
1851
|
if (!layerKey) throw new Error("Empty layer key");
|
|
1811
1852
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
@@ -1904,24 +1945,47 @@ const useLayerStyles = (layerKey) => {
|
|
|
1904
1945
|
const layout = calcLayerLayout(vars);
|
|
1905
1946
|
const textStyles = calcLayerTextStyles(vars);
|
|
1906
1947
|
const layerFlex = calcLayerFlex(vars, parentVars);
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
"
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1948
|
+
reg.add("opacity", vars.values.opacity, vars.isVariable.opacity);
|
|
1949
|
+
reg.add("overflow", vars.values.overflow, vars.isVariable.overflow);
|
|
1950
|
+
reg.add(
|
|
1951
|
+
"border-radius",
|
|
1952
|
+
isValue(vars.rawValues.borderRadius) ? vars.values.borderRadius : null,
|
|
1953
|
+
vars.isVariable.borderRadius
|
|
1954
|
+
);
|
|
1955
|
+
reg.add("white-space", vars.values.whiteSpace, vars.isVariable.whiteSpace);
|
|
1956
|
+
reg.add(
|
|
1957
|
+
"rotate",
|
|
1958
|
+
isValue(vars.values.rotate) ? `${vars.values.rotate}deg` : null,
|
|
1959
|
+
vars.isVariable.rotate
|
|
1960
|
+
);
|
|
1961
|
+
reg.add(
|
|
1962
|
+
"z-index",
|
|
1963
|
+
vars.values.zIndex !== -1 ? vars.values.zIndex : null,
|
|
1964
|
+
vars.isVariable.zIndex
|
|
1965
|
+
);
|
|
1966
|
+
const bgDynamic = paintVars.isVariable.solid || paintVars.isVariable.type || imageVars.isVariable.src;
|
|
1967
|
+
reg.addAll(background, bgDynamic);
|
|
1968
|
+
const borderDynamic = borderPaintVars.isVariable.solid || borderVars.isVariable.type;
|
|
1969
|
+
reg.addAll(border, borderDynamic);
|
|
1970
|
+
const posDynamic = vars.isVariable.width || vars.isVariable.height || vars.isVariable.position || vars.isVariable.widthType || vars.isVariable.heightType;
|
|
1971
|
+
reg.addAll(position, posDynamic);
|
|
1972
|
+
const layoutDynamic = vars.isVariable.layerMode || vars.isVariable.layerDirection || vars.isVariable.layerDistribute || vars.isVariable.layerAlign || vars.isVariable.padding || vars.isVariable.layerGap;
|
|
1973
|
+
reg.addAll(layout, layoutDynamic);
|
|
1974
|
+
const flexDynamic = vars.isVariable.widthType || vars.isVariable.heightType || parentVars.isVariable.layerDirection;
|
|
1975
|
+
reg.addAll(layerFlex, flexDynamic);
|
|
1976
|
+
const sizeDynamic = vars.isVariable.minWidth || vars.isVariable.maxWidth || vars.isVariable.minHeight || vars.isVariable.maxHeight;
|
|
1977
|
+
reg.addAll(layerSize, sizeDynamic);
|
|
1978
|
+
const textDynamic = vars.isVariable["attributes.color"];
|
|
1979
|
+
reg.addAll(textStyles, textDynamic);
|
|
1980
|
+
reg.add(
|
|
1981
|
+
"display",
|
|
1982
|
+
display,
|
|
1983
|
+
vars.isVariable.visible || vars.isVariable.layerMode
|
|
1984
|
+
);
|
|
1985
|
+
if (collectStyle && !(options == null ? void 0 : options.registrar)) {
|
|
1986
|
+
reg.flush();
|
|
1987
|
+
}
|
|
1923
1988
|
} catch (e) {
|
|
1924
|
-
return {};
|
|
1925
1989
|
}
|
|
1926
1990
|
};
|
|
1927
1991
|
const MAX_NESTING_DEPTH = 5;
|
|
@@ -2020,6 +2084,39 @@ const useTextContent = (layerKey, manager) => {
|
|
|
2020
2084
|
}
|
|
2021
2085
|
return nextContent;
|
|
2022
2086
|
};
|
|
2087
|
+
function extractStyleVarIds(html) {
|
|
2088
|
+
if (!html) return [];
|
|
2089
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2090
|
+
const varRegex = /var\(--([a-zA-Z0-9_-]+)/g;
|
|
2091
|
+
let match;
|
|
2092
|
+
while ((match = varRegex.exec(html)) !== null) {
|
|
2093
|
+
ids.add(match[1]);
|
|
2094
|
+
}
|
|
2095
|
+
return Array.from(ids);
|
|
2096
|
+
}
|
|
2097
|
+
const useTextCssVars = (layerKey, reg, input) => {
|
|
2098
|
+
const varIds = useMemo(() => {
|
|
2099
|
+
const fromContent = extractStyleVarIds(input.content);
|
|
2100
|
+
const fromHighlight = extractStyleVarIds(input.highlightStylesString);
|
|
2101
|
+
return [.../* @__PURE__ */ new Set([...fromContent, ...fromHighlight])];
|
|
2102
|
+
}, [input.content, input.highlightStylesString]);
|
|
2103
|
+
const variableKeys = useMemo(
|
|
2104
|
+
() => varIds.map(
|
|
2105
|
+
(id) => keyOfEntity({
|
|
2106
|
+
_type: definition.nodes.Variable,
|
|
2107
|
+
_id: id
|
|
2108
|
+
})
|
|
2109
|
+
),
|
|
2110
|
+
[varIds]
|
|
2111
|
+
);
|
|
2112
|
+
const resolved = useReadVariables(variableKeys);
|
|
2113
|
+
varIds.forEach((id, index) => {
|
|
2114
|
+
var _a;
|
|
2115
|
+
const value = (_a = resolved[index]) == null ? void 0 : _a.value;
|
|
2116
|
+
if (value == null) return;
|
|
2117
|
+
reg.add(`--${id}`, String(value), true);
|
|
2118
|
+
});
|
|
2119
|
+
};
|
|
2023
2120
|
const useHash = (layerKey, manager) => {
|
|
2024
2121
|
if (!layerKey || !manager) return null;
|
|
2025
2122
|
const layer = manager.resolve(layerKey);
|
|
@@ -2028,6 +2125,7 @@ const useHash = (layerKey, manager) => {
|
|
|
2028
2125
|
};
|
|
2029
2126
|
const useClassnames = (layerKey, manager) => {
|
|
2030
2127
|
const hash = useHash(layerKey, manager);
|
|
2128
|
+
const { instanceId } = useContext(InstanceContext);
|
|
2031
2129
|
const [classnames] = useLayerValue(layerKey, "classnames", { manager });
|
|
2032
2130
|
const values = useLayersValue(classnames, "value");
|
|
2033
2131
|
const enables = useLayersValue(classnames, "enabled");
|
|
@@ -2039,40 +2137,13 @@ const useClassnames = (layerKey, manager) => {
|
|
|
2039
2137
|
[values, enables]
|
|
2040
2138
|
);
|
|
2041
2139
|
if (!layerKey || !manager) return null;
|
|
2042
|
-
|
|
2140
|
+
const instanceHash = instanceId ? hashGenerator$1(instanceId) : null;
|
|
2141
|
+
let base = [hash, instanceHash].filter(Boolean);
|
|
2043
2142
|
if (classnames == null ? void 0 : classnames.length) {
|
|
2044
2143
|
base = [...base, ...list];
|
|
2045
2144
|
}
|
|
2046
2145
|
return base.join(" ");
|
|
2047
2146
|
};
|
|
2048
|
-
const useStyleSheet = (manager) => {
|
|
2049
|
-
var _a, _b;
|
|
2050
|
-
const addLayerStyle = useCallback(
|
|
2051
|
-
(layerKey, styles, layer) => {
|
|
2052
|
-
var _a2, _b2;
|
|
2053
|
-
if (!!(manager == null ? void 0 : manager.$styleSheet) && manager && "addStyle" in (manager == null ? void 0 : manager.$styleSheet)) {
|
|
2054
|
-
(_b2 = (_a2 = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a2.addStyle) == null ? void 0 : _b2.call(_a2, layerKey, styles, layer);
|
|
2055
|
-
}
|
|
2056
|
-
},
|
|
2057
|
-
[manager]
|
|
2058
|
-
);
|
|
2059
|
-
const addCssChunk = useCallback(
|
|
2060
|
-
(id) => {
|
|
2061
|
-
var _a2, _b2;
|
|
2062
|
-
if (!!(manager == null ? void 0 : manager.$styleSheet) && manager && "addCssChunk" in (manager == null ? void 0 : manager.$styleSheet)) {
|
|
2063
|
-
return (_b2 = (_a2 = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a2.addCssChunk) == null ? void 0 : _b2.call(_a2, id);
|
|
2064
|
-
}
|
|
2065
|
-
return noop;
|
|
2066
|
-
},
|
|
2067
|
-
[manager]
|
|
2068
|
-
);
|
|
2069
|
-
return {
|
|
2070
|
-
addLayerStyle,
|
|
2071
|
-
addCssChunk,
|
|
2072
|
-
mount: ((_a = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a.mount) ?? noop,
|
|
2073
|
-
unmount: ((_b = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _b.unmount) ?? noop
|
|
2074
|
-
};
|
|
2075
|
-
};
|
|
2076
2147
|
const useGlobalManager = (globalManager) => {
|
|
2077
2148
|
var _a;
|
|
2078
2149
|
const currentGlobalManager = useContext(GlobalManagerContext);
|
|
@@ -2255,24 +2326,21 @@ const useTextHighlight = (layerKey, options) => {
|
|
|
2255
2326
|
const useTextAttributes = (layerKey, options) => {
|
|
2256
2327
|
const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
|
|
2257
2328
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
2258
|
-
const styles = useLayerStyles(layerKey);
|
|
2259
2329
|
const highlight = useTextHighlight(layerKey);
|
|
2260
2330
|
const content = useTextContent(layerKey);
|
|
2331
|
+
const reg = useStyleRegistrar(layerKey);
|
|
2332
|
+
useLayerStyles(layerKey, { collectStyle, registrar: reg });
|
|
2333
|
+
useTextCssVars(layerKey, reg, {
|
|
2334
|
+
content,
|
|
2335
|
+
highlightStylesString: highlight.stylesString
|
|
2336
|
+
});
|
|
2337
|
+
if (collectStyle) {
|
|
2338
|
+
reg.flush();
|
|
2339
|
+
}
|
|
2261
2340
|
const classnames = useClassnames(layerKey, fragmentManager);
|
|
2262
2341
|
const hash = useHash(layerKey, fragmentManager);
|
|
2263
|
-
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
2264
2342
|
const events = useLayerInteractions(layerKey, options);
|
|
2265
|
-
|
|
2266
|
-
addLayerStyle(layerKey, styles, fragmentManager.resolve(layerKey));
|
|
2267
|
-
}
|
|
2268
|
-
return {
|
|
2269
|
-
hash,
|
|
2270
|
-
events,
|
|
2271
|
-
styles,
|
|
2272
|
-
classnames,
|
|
2273
|
-
content,
|
|
2274
|
-
highlight
|
|
2275
|
-
};
|
|
2343
|
+
return { hash, events, classnames, content, highlight };
|
|
2276
2344
|
};
|
|
2277
2345
|
const Text = ({
|
|
2278
2346
|
layerKey,
|
|
@@ -2295,32 +2363,22 @@ const Text = ({
|
|
|
2295
2363
|
}
|
|
2296
2364
|
}
|
|
2297
2365
|
),
|
|
2298
|
-
/* @__PURE__ */ jsx(
|
|
2299
|
-
"div",
|
|
2300
|
-
{
|
|
2301
|
-
dangerouslySetInnerHTML: { __html: content }
|
|
2302
|
-
}
|
|
2303
|
-
)
|
|
2366
|
+
/* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: content } })
|
|
2304
2367
|
] });
|
|
2305
2368
|
};
|
|
2306
2369
|
const useFrame = (layerKey, options) => {
|
|
2307
2370
|
const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
|
|
2308
2371
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
2309
2372
|
const layer = fragmentManager.entityOfKey(layerKey);
|
|
2310
|
-
|
|
2373
|
+
useLayerStyles(layerKey, { collectStyle });
|
|
2311
2374
|
const children = useLayerChildren(layerKey);
|
|
2312
2375
|
const classnames = useClassnames(layerKey, fragmentManager);
|
|
2313
|
-
const { addLayerStyle } = useStyleSheet(fragmentManager);
|
|
2314
2376
|
const events = useLayerInteractions(layerKey, options);
|
|
2315
2377
|
const link = useLayerLink(layerKey);
|
|
2316
|
-
if (collectStyle) {
|
|
2317
|
-
addLayerStyle(layerKey, styles, fragmentManager.resolve(layerKey));
|
|
2318
|
-
}
|
|
2319
2378
|
return {
|
|
2320
2379
|
Tag: (link == null ? void 0 : link.isLink) ? (options == null ? void 0 : options.FrameTag) ?? "a" : (options == null ? void 0 : options.FrameTag) ?? "div",
|
|
2321
2380
|
type: layer == null ? void 0 : layer._type,
|
|
2322
2381
|
classnames,
|
|
2323
|
-
styles,
|
|
2324
2382
|
children,
|
|
2325
2383
|
events,
|
|
2326
2384
|
linkProps: link.linkProps
|
|
@@ -2339,8 +2397,9 @@ const useCollection = (layerKey, options) => {
|
|
|
2339
2397
|
const [sourceValue] = useLayerValue(layerKey, "source", {
|
|
2340
2398
|
manager: fragmentManager
|
|
2341
2399
|
});
|
|
2342
|
-
const
|
|
2343
|
-
const
|
|
2400
|
+
const safeSourceValue = Array.isArray(sourceValue) ? sourceValue : [];
|
|
2401
|
+
const sourceValues = useGraphStack(fragmentManager, safeSourceValue);
|
|
2402
|
+
const resultValues = safeSourceValue.map(
|
|
2344
2403
|
(initValue, index) => (
|
|
2345
2404
|
// Если initValue — объект (пришёл из пропсов через useReadVariables),
|
|
2346
2405
|
// он уже содержит актуальные значения и имеет приоритет.
|
|
@@ -2486,6 +2545,7 @@ const fillArrayItemDefaults = (items, parentDef, manager) => {
|
|
|
2486
2545
|
};
|
|
2487
2546
|
const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
2488
2547
|
const areaManager = useContext(AreaManagerContext);
|
|
2548
|
+
const campaignManager = useContext(CampaignManagerContext);
|
|
2489
2549
|
const globalManager = useContext(GlobalManagerContext);
|
|
2490
2550
|
const arrayVariableKeys = useMemo(() => {
|
|
2491
2551
|
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
@@ -2541,8 +2601,8 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2541
2601
|
const propValue = props[defVar._id];
|
|
2542
2602
|
if (!isVariableLink$1(propValue)) continue;
|
|
2543
2603
|
const resolveManager = parentManager ?? manager;
|
|
2544
|
-
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2545
|
-
const ownerManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : null;
|
|
2604
|
+
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2605
|
+
const ownerManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ? campaignManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : null;
|
|
2546
2606
|
if ((parentVar == null ? void 0 : parentVar.type) !== definition.variableType.Array) continue;
|
|
2547
2607
|
const items = parentVar.defaultValue;
|
|
2548
2608
|
if (!Array.isArray(items)) continue;
|
|
@@ -2559,7 +2619,15 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2559
2619
|
}
|
|
2560
2620
|
}
|
|
2561
2621
|
return { arrayItemKeys: keys, arrayItemManager: itemManager };
|
|
2562
|
-
}, [
|
|
2622
|
+
}, [
|
|
2623
|
+
definitions,
|
|
2624
|
+
manager,
|
|
2625
|
+
parentManager,
|
|
2626
|
+
campaignManager,
|
|
2627
|
+
areaManager,
|
|
2628
|
+
globalManager,
|
|
2629
|
+
props
|
|
2630
|
+
]);
|
|
2563
2631
|
const arrayItemLayers = useGraphStack(
|
|
2564
2632
|
arrayItemKeys.length ? arrayItemManager ?? parentManager ?? manager : null,
|
|
2565
2633
|
arrayItemKeys
|
|
@@ -2597,8 +2665,8 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2597
2665
|
}
|
|
2598
2666
|
if (defVar.type === definition.variableType.Array && defVar.definition) {
|
|
2599
2667
|
if (isVariableLink$1(propValue)) {
|
|
2600
|
-
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2601
|
-
const parentVarManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : resolveManager;
|
|
2668
|
+
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2669
|
+
const parentVarManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ? campaignManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : resolveManager;
|
|
2602
2670
|
if ((parentVar == null ? void 0 : parentVar.type) === definition.variableType.Array && (parentVar == null ? void 0 : parentVar.definition)) {
|
|
2603
2671
|
const resolvedArray = arrayResolvedByKey[propValue];
|
|
2604
2672
|
if (Array.isArray(resolvedArray)) {
|
|
@@ -2646,6 +2714,7 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2646
2714
|
props,
|
|
2647
2715
|
manager,
|
|
2648
2716
|
parentManager,
|
|
2717
|
+
campaignManager,
|
|
2649
2718
|
areaManager,
|
|
2650
2719
|
globalManager,
|
|
2651
2720
|
definitions
|
|
@@ -2657,12 +2726,15 @@ const CollectionItem = ({
|
|
|
2657
2726
|
FrameElement,
|
|
2658
2727
|
children,
|
|
2659
2728
|
sourceDefinition,
|
|
2729
|
+
index,
|
|
2660
2730
|
...restProps
|
|
2661
2731
|
}) => {
|
|
2662
|
-
var _a;
|
|
2732
|
+
var _a, _b;
|
|
2663
2733
|
keyOfEntity(layer);
|
|
2664
2734
|
const definitionId = ((_a = entityOfKey(sourceDefinition)) == null ? void 0 : _a._id) ?? "";
|
|
2665
2735
|
const value = layer.value ?? layer;
|
|
2736
|
+
const itemId = ((_b = entityOfKey(layer)) == null ? void 0 : _b._id) ?? index;
|
|
2737
|
+
const collectionInstanceId = `ci:${itemId}`;
|
|
2666
2738
|
const inputProps = {
|
|
2667
2739
|
[definitionId]: value
|
|
2668
2740
|
};
|
|
@@ -2672,10 +2744,6 @@ const CollectionItem = ({
|
|
|
2672
2744
|
[sourceDefinition]
|
|
2673
2745
|
);
|
|
2674
2746
|
const expandedProps = useExtractProps(props, manager, void 0, definitions);
|
|
2675
|
-
const cssVars = useMemo(
|
|
2676
|
-
() => toCssCustomProperties(expandedProps),
|
|
2677
|
-
[expandedProps]
|
|
2678
|
-
);
|
|
2679
2747
|
return /* @__PURE__ */ jsx(
|
|
2680
2748
|
Scope,
|
|
2681
2749
|
{
|
|
@@ -2688,17 +2756,21 @@ const CollectionItem = ({
|
|
|
2688
2756
|
value: expandedProps,
|
|
2689
2757
|
manager
|
|
2690
2758
|
},
|
|
2691
|
-
children:
|
|
2692
|
-
|
|
2759
|
+
children: /* @__PURE__ */ jsx(
|
|
2760
|
+
InstanceContext.Provider,
|
|
2693
2761
|
{
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2762
|
+
value: {
|
|
2763
|
+
layerKey: null,
|
|
2764
|
+
parentManager: null,
|
|
2765
|
+
innerManager: null,
|
|
2766
|
+
props: {},
|
|
2767
|
+
definitions: [],
|
|
2768
|
+
onChangeProps: null,
|
|
2769
|
+
instanceId: collectionInstanceId
|
|
2697
2770
|
},
|
|
2698
|
-
children: /* @__PURE__ */ jsx(FrameElement, { ...restProps, layerKey: child })
|
|
2699
|
-
}
|
|
2700
|
-
|
|
2701
|
-
))
|
|
2771
|
+
children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsx("div", { style: { display: "contents" }, children: /* @__PURE__ */ jsx(FrameElement, { ...restProps, layerKey: child }) }, child))
|
|
2772
|
+
}
|
|
2773
|
+
)
|
|
2702
2774
|
}
|
|
2703
2775
|
);
|
|
2704
2776
|
};
|
|
@@ -2740,6 +2812,7 @@ const Collection = ({
|
|
|
2740
2812
|
children: (_a = sourceValue == null ? void 0 : sourceValue.map) == null ? void 0 : _a.call(sourceValue, (itemValue, index) => /* @__PURE__ */ jsx(
|
|
2741
2813
|
CollectionItem,
|
|
2742
2814
|
{
|
|
2815
|
+
index,
|
|
2743
2816
|
layer: itemValue,
|
|
2744
2817
|
manager: fragmentManager,
|
|
2745
2818
|
source,
|
|
@@ -2771,11 +2844,13 @@ const Frame = ({
|
|
|
2771
2844
|
pauseInteractions,
|
|
2772
2845
|
...restProps
|
|
2773
2846
|
}) => {
|
|
2774
|
-
const {
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2847
|
+
const { classnames, children, type, events, linkProps, Tag } = useFrame(
|
|
2848
|
+
layerKey,
|
|
2849
|
+
{
|
|
2850
|
+
...restProps,
|
|
2851
|
+
pauseInteractions
|
|
2852
|
+
}
|
|
2853
|
+
);
|
|
2779
2854
|
const isMounted = useMounted();
|
|
2780
2855
|
if (isMounted && hidden) {
|
|
2781
2856
|
return /* @__PURE__ */ jsx("div", {});
|
|
@@ -2798,10 +2873,7 @@ const Frame = ({
|
|
|
2798
2873
|
{
|
|
2799
2874
|
className: classnames,
|
|
2800
2875
|
"data-key": layerKey,
|
|
2801
|
-
style: {
|
|
2802
|
-
...resultStyles,
|
|
2803
|
-
display: hidden ? "none" : resultStyles.display
|
|
2804
|
-
},
|
|
2876
|
+
style: inputStyles ? { ...inputStyles, display: hidden ? "none" : inputStyles.display } : hidden ? { display: "none" } : restProps == null ? void 0 : restProps.style,
|
|
2805
2877
|
...events,
|
|
2806
2878
|
...linkProps,
|
|
2807
2879
|
...restProps,
|
|
@@ -2809,6 +2881,34 @@ const Frame = ({
|
|
|
2809
2881
|
}
|
|
2810
2882
|
);
|
|
2811
2883
|
};
|
|
2884
|
+
const useStyleSheet = (manager) => {
|
|
2885
|
+
var _a, _b;
|
|
2886
|
+
const addLayerStyle = useCallback(
|
|
2887
|
+
(layerKey, styles, layer) => {
|
|
2888
|
+
var _a2, _b2;
|
|
2889
|
+
if (!!(manager == null ? void 0 : manager.$styleSheet) && manager && "addStyle" in (manager == null ? void 0 : manager.$styleSheet)) {
|
|
2890
|
+
(_b2 = (_a2 = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a2.addStyle) == null ? void 0 : _b2.call(_a2, layerKey, styles, layer);
|
|
2891
|
+
}
|
|
2892
|
+
},
|
|
2893
|
+
[manager]
|
|
2894
|
+
);
|
|
2895
|
+
const addCssChunk = useCallback(
|
|
2896
|
+
(id) => {
|
|
2897
|
+
var _a2, _b2;
|
|
2898
|
+
if (!!(manager == null ? void 0 : manager.$styleSheet) && manager && "addCssChunk" in (manager == null ? void 0 : manager.$styleSheet)) {
|
|
2899
|
+
return (_b2 = (_a2 = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a2.addCssChunk) == null ? void 0 : _b2.call(_a2, id);
|
|
2900
|
+
}
|
|
2901
|
+
return noop;
|
|
2902
|
+
},
|
|
2903
|
+
[manager]
|
|
2904
|
+
);
|
|
2905
|
+
return {
|
|
2906
|
+
addLayerStyle,
|
|
2907
|
+
addCssChunk,
|
|
2908
|
+
mount: ((_a = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a.mount) ?? noop,
|
|
2909
|
+
unmount: ((_b = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _b.unmount) ?? noop
|
|
2910
|
+
};
|
|
2911
|
+
};
|
|
2812
2912
|
const useCssChunk = (linkKey) => {
|
|
2813
2913
|
const { manager } = useContext(FragmentContext);
|
|
2814
2914
|
const [chunkId] = useLayerValue(linkKey, "chunkId", { manager });
|
|
@@ -3226,45 +3326,6 @@ const useSuspenseLoadArea = (globalManager, areaCode, skip) => {
|
|
|
3226
3326
|
if (valueOrPromise == null) return null;
|
|
3227
3327
|
return createSuspenseResource(`area:${areaCode}`, valueOrPromise, cache).read();
|
|
3228
3328
|
};
|
|
3229
|
-
const collectPropertyCssVars = (manager, result) => {
|
|
3230
|
-
if (!(manager == null ? void 0 : manager.$properties)) return;
|
|
3231
|
-
const keys = manager.$properties.getPropertyKeys() ?? [];
|
|
3232
|
-
const processField = (fieldLayer) => {
|
|
3233
|
-
if (!(fieldLayer == null ? void 0 : fieldLayer._id)) return;
|
|
3234
|
-
if (fieldLayer.type === definition.variableType.Object && fieldLayer.fields) {
|
|
3235
|
-
for (const [key, ref] of Object.entries(fieldLayer.fields)) {
|
|
3236
|
-
if (key === "_type" || key === "_id") continue;
|
|
3237
|
-
const child = isObject(ref) ? ref : manager.resolve(ref);
|
|
3238
|
-
if (child) processField(child);
|
|
3239
|
-
}
|
|
3240
|
-
return;
|
|
3241
|
-
}
|
|
3242
|
-
if (fieldLayer.defaultValue != null) {
|
|
3243
|
-
result[`--${fieldLayer._id}`] = String(fieldLayer.defaultValue);
|
|
3244
|
-
}
|
|
3245
|
-
};
|
|
3246
|
-
for (const key of keys) {
|
|
3247
|
-
const layer = manager.resolve(key, { deep: true });
|
|
3248
|
-
if (layer) processField(layer);
|
|
3249
|
-
}
|
|
3250
|
-
};
|
|
3251
|
-
const useManagerCssProperties = () => {
|
|
3252
|
-
var _a, _b, _c, _d;
|
|
3253
|
-
const globalManager = useContext(GlobalManagerContext);
|
|
3254
|
-
const areaManager = useContext(AreaManagerContext);
|
|
3255
|
-
useGraph(globalManager, (_a = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _a.key);
|
|
3256
|
-
useGraph(areaManager, (_b = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _b.key);
|
|
3257
|
-
const globalKeys = ((_c = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _c.getPropertyKeys()) ?? [];
|
|
3258
|
-
const areaKeys = ((_d = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _d.getPropertyKeys()) ?? [];
|
|
3259
|
-
useGraphStack(globalKeys.length ? globalManager : null, globalKeys);
|
|
3260
|
-
useGraphStack(areaKeys.length ? areaManager : null, areaKeys);
|
|
3261
|
-
return useMemo(() => {
|
|
3262
|
-
const vars = {};
|
|
3263
|
-
collectPropertyCssVars(globalManager, vars);
|
|
3264
|
-
collectPropertyCssVars(areaManager, vars);
|
|
3265
|
-
return vars;
|
|
3266
|
-
}, [globalManager, areaManager, globalKeys.length, areaKeys.length]);
|
|
3267
|
-
};
|
|
3268
3329
|
const InstanceInitial = ({
|
|
3269
3330
|
Tag: inputTag,
|
|
3270
3331
|
style = {},
|
|
@@ -3275,6 +3336,10 @@ const InstanceInitial = ({
|
|
|
3275
3336
|
var _a;
|
|
3276
3337
|
const ssr = ((_a = instanceProps == null ? void 0 : instanceProps.options) == null ? void 0 : _a.ssr) ?? true;
|
|
3277
3338
|
const link = useLayerLink(instanceProps.layerKey);
|
|
3339
|
+
const parentInstanceId = useContext(InstanceContext).instanceId;
|
|
3340
|
+
const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
|
|
3341
|
+
const instanceIdRef = useRef(isTopInstance ? crypto.randomUUID() : null);
|
|
3342
|
+
const instanceId = parentInstanceId ? `${parentInstanceId}:${instanceProps.layerKey}` : instanceIdRef.current ?? instanceProps.layerKey;
|
|
3278
3343
|
const Tag = (link == null ? void 0 : link.isLink) ? inputTag ?? "a" : inputTag ?? "div";
|
|
3279
3344
|
const {
|
|
3280
3345
|
fragmentId,
|
|
@@ -3296,15 +3361,6 @@ const InstanceInitial = ({
|
|
|
3296
3361
|
parentManager,
|
|
3297
3362
|
definitions
|
|
3298
3363
|
);
|
|
3299
|
-
const propsCssVars = useMemo(
|
|
3300
|
-
() => toCssCustomProperties(expandedProps),
|
|
3301
|
-
[expandedProps]
|
|
3302
|
-
);
|
|
3303
|
-
const managerCssVars = useManagerCssProperties();
|
|
3304
|
-
const cssVars = useMemo(
|
|
3305
|
-
() => ({ ...managerCssVars, ...propsCssVars }),
|
|
3306
|
-
[managerCssVars, propsCssVars]
|
|
3307
|
-
);
|
|
3308
3364
|
useSuspenseLoadFragment(globalManager, fragmentId, !ssr);
|
|
3309
3365
|
const instanceContextValue = useMemo(
|
|
3310
3366
|
() => ({
|
|
@@ -3313,7 +3369,8 @@ const InstanceInitial = ({
|
|
|
3313
3369
|
innerManager,
|
|
3314
3370
|
parentManager,
|
|
3315
3371
|
props: expandedProps,
|
|
3316
|
-
onChangeProps
|
|
3372
|
+
onChangeProps,
|
|
3373
|
+
instanceId
|
|
3317
3374
|
}),
|
|
3318
3375
|
[
|
|
3319
3376
|
instanceProps.layerKey,
|
|
@@ -3321,7 +3378,8 @@ const InstanceInitial = ({
|
|
|
3321
3378
|
innerManager,
|
|
3322
3379
|
parentManager,
|
|
3323
3380
|
expandedProps,
|
|
3324
|
-
onChangeProps
|
|
3381
|
+
onChangeProps,
|
|
3382
|
+
instanceId
|
|
3325
3383
|
]
|
|
3326
3384
|
);
|
|
3327
3385
|
return /* @__PURE__ */ jsx(InstanceContext.Provider, { value: instanceContextValue, children: parentManager ? /* @__PURE__ */ jsx(
|
|
@@ -3329,7 +3387,7 @@ const InstanceInitial = ({
|
|
|
3329
3387
|
{
|
|
3330
3388
|
className: classnames,
|
|
3331
3389
|
"data-key": instanceProps.layerKey,
|
|
3332
|
-
style
|
|
3390
|
+
style,
|
|
3333
3391
|
...link.linkProps,
|
|
3334
3392
|
...events,
|
|
3335
3393
|
children: /* @__PURE__ */ jsx(
|
|
@@ -3342,7 +3400,7 @@ const InstanceInitial = ({
|
|
|
3342
3400
|
}
|
|
3343
3401
|
)
|
|
3344
3402
|
}
|
|
3345
|
-
) : /* @__PURE__ */ jsx(Tag, { style
|
|
3403
|
+
) : /* @__PURE__ */ jsx(Tag, { style, ...link.linkProps, children: /* @__PURE__ */ jsx(
|
|
3346
3404
|
Fragment,
|
|
3347
3405
|
{
|
|
3348
3406
|
fragmentId,
|