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