@fragmentsx/render-react 1.5.3 → 1.6.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/fragment/useFragmentManager.d.ts.map +1 -1
- package/dist/hooks/layer/useLayerValue.d.ts.map +1 -1
- package/dist/hooks/layer/useLayerVariableValue.d.ts.map +1 -1
- package/dist/hooks/layer/useLayersValue.d.ts.map +1 -1
- package/dist/hooks/layer/useReadVariable.d.ts +8 -11
- package/dist/hooks/layer/useReadVariable.d.ts.map +1 -1
- package/dist/hooks/layer/useReadVariables.d.ts +3 -3
- package/dist/hooks/layer/useReadVariables.d.ts.map +1 -1
- package/dist/hooks/layer/useResolvedLayerVariables.d.ts +1 -1
- package/dist/hooks/layer/useResolvedLayerVariables.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/calcImagePaint.test.d.ts +2 -0
- package/dist/hooks/layer-styles/useLayerStyles/calcImagePaint.test.d.ts.map +1 -0
- package/dist/hooks/utils/useExtractProps.d.ts.map +1 -1
- package/dist/hooks/utils/useLayerInteractions.d.ts.map +1 -1
- package/dist/index.cjs.js +377 -435
- package/dist/index.es.js +378 -436
- package/dist/nodes/Instance/Instance.d.ts.map +1 -1
- package/dist/nodes/Instance/hooks/useInstanceProps.d.ts.map +1 -1
- package/dist/nodes/Instance/test/project-props.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/project-props.browser.test.d.ts.map +1 -0
- package/dist/nodes/Text/hooks/useTextContent.d.ts.map +1 -1
- package/dist/providers/InstanceContext.d.ts +1 -0
- package/dist/providers/InstanceContext.d.ts.map +1 -1
- package/dist/utils/common/transformCssValue.test.d.ts +2 -0
- package/dist/utils/common/transformCssValue.test.d.ts.map +1 -0
- package/package.json +4 -2
package/dist/index.cjs.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const react = require("react");
|
|
4
4
|
const definition = require("@fragmentsx/definition");
|
|
5
5
|
const jsxRuntime = require("react/jsx-runtime");
|
|
6
|
+
const react$1 = require("@graph-state/react");
|
|
6
7
|
const utils = require("@fragmentsx/utils");
|
|
7
8
|
const core = require("@graph-state/core");
|
|
8
|
-
const react$1 = require("@graph-state/react");
|
|
9
9
|
const clientCore = require("@fragmentsx/client-core");
|
|
10
10
|
const GlobalManagerContext = react.createContext(null);
|
|
11
11
|
const GlobalManagerProvider = GlobalManagerContext.Provider;
|
|
@@ -14,12 +14,13 @@ const FragmentContext = react.createContext({
|
|
|
14
14
|
});
|
|
15
15
|
const defaultCustomRender = (layerKey, node) => node;
|
|
16
16
|
const CustomRender = react.createContext(defaultCustomRender);
|
|
17
|
-
const InstanceContext
|
|
17
|
+
const InstanceContext = react.createContext({
|
|
18
18
|
layerKey: null,
|
|
19
19
|
parentManager: null,
|
|
20
20
|
innerManager: null,
|
|
21
21
|
props: {},
|
|
22
|
-
definitions: []
|
|
22
|
+
definitions: [],
|
|
23
|
+
onChangeProps: null
|
|
23
24
|
});
|
|
24
25
|
const RenderTargetContext = react.createContext(
|
|
25
26
|
definition.definition.renderTarget.document
|
|
@@ -662,8 +663,8 @@ function hashGenerator(layerKey) {
|
|
|
662
663
|
return /^[0-9]/.test(raw) ? `h${raw}` : raw;
|
|
663
664
|
}
|
|
664
665
|
const transformCssValue = (value) => {
|
|
665
|
-
var _a;
|
|
666
|
-
if ((_a = value == null ? void 0 : value.startsWith) == null ? void 0 : _a.call(value, "http")) {
|
|
666
|
+
var _a, _b;
|
|
667
|
+
if (((_a = value == null ? void 0 : value.startsWith) == null ? void 0 : _a.call(value, "http")) || ((_b = value == null ? void 0 : value.startsWith) == null ? void 0 : _b.call(value, "data:"))) {
|
|
667
668
|
value = `url("${value}")`;
|
|
668
669
|
}
|
|
669
670
|
return value;
|
|
@@ -863,178 +864,135 @@ const useResolvedLayer = (layerKey, options) => {
|
|
|
863
864
|
}
|
|
864
865
|
return { layerKey: key, rawLayer, layer, isOverride };
|
|
865
866
|
};
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
const EMPTY_RESOLVED = {
|
|
870
|
-
values: {},
|
|
871
|
-
cssVariableValues: {},
|
|
872
|
-
rawValues: {}
|
|
873
|
-
};
|
|
874
|
-
const extractVariableValue$1 = (input, variableId) => {
|
|
875
|
-
if (utils.isObject(input)) {
|
|
867
|
+
const extractVariableValue = (input, variableId) => {
|
|
868
|
+
if (input && typeof input === "object") {
|
|
876
869
|
if (variableId in input) return input[variableId];
|
|
877
870
|
for (const key in input) {
|
|
878
871
|
if (input.hasOwnProperty(key)) {
|
|
879
|
-
const result = extractVariableValue
|
|
872
|
+
const result = extractVariableValue(input[key], variableId);
|
|
880
873
|
if (result !== void 0) return result;
|
|
881
874
|
}
|
|
882
875
|
}
|
|
883
876
|
}
|
|
884
877
|
return void 0;
|
|
885
878
|
};
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
879
|
+
const useReadVariables = (variableKeys, customManager) => {
|
|
880
|
+
var _a, _b, _c, _d;
|
|
881
|
+
const filterKeys = variableKeys.filter(definition.isVariableLink);
|
|
882
|
+
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
883
|
+
const { props: instanceProps } = react.useContext(InstanceContext);
|
|
884
|
+
const globalManager = react.useContext(GlobalManagerContext);
|
|
885
|
+
const areaManager = react.useContext(AreaManagerContext);
|
|
886
|
+
const scopes = react.useContext(ScopeContext);
|
|
887
|
+
const resultManager = customManager ?? ((_a = react.useContext(InstanceContext)) == null ? void 0 : _a.innerManager) ?? fragmentManager;
|
|
888
|
+
const variableLayers = react$1.useGraphStack(resultManager, filterKeys, {
|
|
889
|
+
pause: !filterKeys.length || !resultManager,
|
|
890
|
+
selector: (graph) => graph ? utils.pick(graph, "_id", "defaultValue", "required") : graph
|
|
891
|
+
});
|
|
892
|
+
react$1.useGraph(globalManager, (_b = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _b.key);
|
|
893
|
+
react$1.useGraph(areaManager, (_c = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _c.key);
|
|
894
|
+
const globalPropertyKeys = react.useMemo(() => {
|
|
895
|
+
if (!(globalManager == null ? void 0 : globalManager.$properties)) return [];
|
|
896
|
+
return filterKeys.filter((key) => globalManager.resolve(key));
|
|
897
|
+
}, [filterKeys, globalManager]);
|
|
898
|
+
const areaPropertyKeys = react.useMemo(() => {
|
|
899
|
+
if (!(areaManager == null ? void 0 : areaManager.$properties)) return [];
|
|
900
|
+
return filterKeys.filter((key) => areaManager.resolve(key));
|
|
901
|
+
}, [filterKeys, areaManager]);
|
|
902
|
+
react$1.useGraphStack(
|
|
903
|
+
globalPropertyKeys.length ? globalManager : null,
|
|
904
|
+
globalPropertyKeys
|
|
905
|
+
);
|
|
906
|
+
react$1.useGraphStack(areaPropertyKeys.length ? areaManager : null, areaPropertyKeys);
|
|
907
|
+
const lastCollectionItem = (_d = scopes == null ? void 0 : scopes.findLast) == null ? void 0 : _d.call(
|
|
908
|
+
scopes,
|
|
909
|
+
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.CollectionItemScope
|
|
910
|
+
);
|
|
911
|
+
return filterKeys.map((variableKey, index) => {
|
|
912
|
+
var _a2;
|
|
913
|
+
const layer = variableLayers[index] ?? null;
|
|
914
|
+
const { _id: propertyId } = layer ?? {};
|
|
915
|
+
let collectionItemProp = void 0;
|
|
916
|
+
if (lastCollectionItem && propertyId) {
|
|
917
|
+
collectionItemProp = utils.isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_a2 = core.entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _a2._id) === propertyId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, propertyId);
|
|
918
|
+
}
|
|
919
|
+
const instanceProp = (instanceProps == null ? void 0 : instanceProps[propertyId]) ?? null;
|
|
920
|
+
const areaLayer = areaManager == null ? void 0 : areaManager.resolve(variableKey);
|
|
921
|
+
const areaProp = (areaLayer == null ? void 0 : areaLayer.defaultValue) ?? null;
|
|
922
|
+
const globalLayer = globalManager == null ? void 0 : globalManager.resolve(variableKey);
|
|
923
|
+
const globalProp = (globalLayer == null ? void 0 : globalLayer.defaultValue) ?? null;
|
|
924
|
+
const required = (layer == null ? void 0 : layer.required) ?? false;
|
|
925
|
+
const defaultValue = (layer == null ? void 0 : layer.defaultValue) ?? null;
|
|
926
|
+
const currentValue = collectionItemProp ?? (variableKey === instanceProp ? null : instanceProp) ?? areaProp ?? globalProp ?? null;
|
|
927
|
+
const resultValue = required ? currentValue : currentValue ?? defaultValue;
|
|
928
|
+
if (definition.isVariableLink(resultValue)) {
|
|
929
|
+
const refKey = resultValue;
|
|
930
|
+
const refAreaLayer = areaManager == null ? void 0 : areaManager.resolve(refKey);
|
|
931
|
+
const refGlobalLayer = globalManager == null ? void 0 : globalManager.resolve(refKey);
|
|
932
|
+
const refFragmentLayer = resultManager == null ? void 0 : resultManager.resolve(refKey);
|
|
933
|
+
const refValue = (refAreaLayer == null ? void 0 : refAreaLayer.defaultValue) ?? (refGlobalLayer == null ? void 0 : refGlobalLayer.defaultValue) ?? (refFragmentLayer == null ? void 0 : refFragmentLayer.defaultValue) ?? resultValue;
|
|
934
|
+
return {
|
|
935
|
+
value: refValue,
|
|
936
|
+
layer: refAreaLayer ?? refGlobalLayer ?? refFragmentLayer ?? null
|
|
937
|
+
};
|
|
894
938
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
const useResolvedLayerVariables = (layer, rawLayer, customScopes) => {
|
|
899
|
-
var _a;
|
|
900
|
-
const contextScopes = react.useContext(ScopeContext);
|
|
901
|
-
const scopes = customScopes ?? contextScopes;
|
|
902
|
-
const subscriptions = react.useRef([]);
|
|
903
|
-
const [dep, forceUpdate] = useForceUpdate();
|
|
904
|
-
react.useEffect(() => {
|
|
905
|
-
const controller = new AbortController();
|
|
906
|
-
let ready = false;
|
|
907
|
-
const update = () => {
|
|
908
|
-
if (!ready) return;
|
|
909
|
-
forceUpdate();
|
|
939
|
+
return {
|
|
940
|
+
value: resultValue,
|
|
941
|
+
layer: layer ?? areaLayer ?? globalLayer ?? null
|
|
910
942
|
};
|
|
911
|
-
for (const { manager, key } of subscriptions.current) {
|
|
912
|
-
manager.subscribe(key, update, { signal: controller.signal });
|
|
913
|
-
}
|
|
914
|
-
ready = true;
|
|
915
|
-
return () => controller.abort();
|
|
916
943
|
});
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
944
|
+
};
|
|
945
|
+
const EMPTY_RESOLVED = {
|
|
946
|
+
values: {},
|
|
947
|
+
cssVariableValues: {},
|
|
948
|
+
rawValues: {}
|
|
949
|
+
};
|
|
950
|
+
const collectVariableKeys = (layer) => {
|
|
951
|
+
const keys = [];
|
|
952
|
+
if (!layer) return keys;
|
|
953
|
+
for (const [, value] of Object.entries(layer)) {
|
|
954
|
+
if (definition.isVariableLink(value)) {
|
|
955
|
+
keys.push(value);
|
|
956
|
+
} else if (utils.isObject(value) && !definition.isVariableLink(value)) {
|
|
957
|
+
for (const [, nestedValue] of Object.entries(
|
|
958
|
+
value
|
|
959
|
+
)) {
|
|
960
|
+
if (definition.isVariableLink(nestedValue)) {
|
|
961
|
+
keys.push(nestedValue);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
920
965
|
}
|
|
966
|
+
return keys;
|
|
967
|
+
};
|
|
968
|
+
const useResolvedLayerVariables = (layer, rawLayer, _customScopes) => {
|
|
969
|
+
var _a;
|
|
970
|
+
const variableKeys = collectVariableKeys(layer);
|
|
971
|
+
const resolved = useReadVariables(variableKeys);
|
|
972
|
+
if (!layer) return EMPTY_RESOLVED;
|
|
973
|
+
const resolvedByKey = {};
|
|
974
|
+
variableKeys.forEach((key, i) => {
|
|
975
|
+
var _a2;
|
|
976
|
+
resolvedByKey[key] = ((_a2 = resolved[i]) == null ? void 0 : _a2.value) ?? null;
|
|
977
|
+
});
|
|
921
978
|
const values = {};
|
|
922
979
|
const cssVariableValues = {};
|
|
923
980
|
const rawValues = {};
|
|
924
|
-
const readVariable = (variableKey) => {
|
|
925
|
-
var _a2, _b, _c;
|
|
926
|
-
const variableId = (_a2 = core.entityOfKey(variableKey)) == null ? void 0 : _a2._id;
|
|
927
|
-
if (!definition.isVariableLink(variableKey)) {
|
|
928
|
-
return { value: null, layer: null };
|
|
929
|
-
}
|
|
930
|
-
let instanceScope = scopes.findLast(
|
|
931
|
-
(scope) => {
|
|
932
|
-
var _a3;
|
|
933
|
-
return (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.InstanceScope && !!((_a3 = scope.documentManager) == null ? void 0 : _a3.resolve(variableKey));
|
|
934
|
-
}
|
|
935
|
-
);
|
|
936
|
-
if (!instanceScope) {
|
|
937
|
-
instanceScope = scopes.find(
|
|
938
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.InstanceScope
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
const resolveVariableLayer = (manager, variableLink, customProps) => {
|
|
942
|
-
var _a3, _b2;
|
|
943
|
-
const variableLayer2 = (_a3 = getNormalizeLayer(variableLink, manager)) == null ? void 0 : _a3.layer;
|
|
944
|
-
if (!variableLayer2) return null;
|
|
945
|
-
if ((variableLayer2 == null ? void 0 : variableLayer2.type) === definition.definition.variableType.Array) {
|
|
946
|
-
const definitionLayer = manager.resolve(variableLayer2 == null ? void 0 : variableLayer2.definition);
|
|
947
|
-
if (!((_b2 = variableLayer2 == null ? void 0 : variableLayer2.defaultValue) == null ? void 0 : _b2.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.definition.variableType.Object)
|
|
948
|
-
return variableLayer2;
|
|
949
|
-
const extractVariableDefaultValue = (mgr, varEntity) => {
|
|
950
|
-
const varLayer = mgr.resolve(varEntity);
|
|
951
|
-
if ((varLayer == null ? void 0 : varLayer.type) !== definition.definition.variableType.Object)
|
|
952
|
-
return varLayer == null ? void 0 : varLayer.defaultValue;
|
|
953
|
-
return Object.values((varLayer == null ? void 0 : varLayer.fields) ?? {}).reduce(
|
|
954
|
-
(acc, fieldLink) => {
|
|
955
|
-
var _a4;
|
|
956
|
-
if (!!fieldLink && definition.isVariableLink(fieldLink)) {
|
|
957
|
-
const _id = (_a4 = core.entityOfKey(fieldLink)) == null ? void 0 : _a4._id;
|
|
958
|
-
if (_id) acc[_id] = extractVariableDefaultValue(mgr, fieldLink);
|
|
959
|
-
}
|
|
960
|
-
return acc;
|
|
961
|
-
},
|
|
962
|
-
{}
|
|
963
|
-
);
|
|
964
|
-
};
|
|
965
|
-
const definitionDefaultValue = extractVariableDefaultValue(
|
|
966
|
-
manager,
|
|
967
|
-
definitionLayer
|
|
968
|
-
);
|
|
969
|
-
const customValue = customProps == null ? void 0 : customProps[variableLayer2 == null ? void 0 : variableLayer2._id];
|
|
970
|
-
return {
|
|
971
|
-
...variableLayer2,
|
|
972
|
-
defaultValue: variableLayer2.defaultValue.map(
|
|
973
|
-
(item, index) => {
|
|
974
|
-
const customItemValue = Array.isArray(customValue) ? customValue.at(index) : null;
|
|
975
|
-
return deepMerge$1(
|
|
976
|
-
customItemValue ? { ...item, ...customItemValue } : item,
|
|
977
|
-
definitionDefaultValue
|
|
978
|
-
);
|
|
979
|
-
}
|
|
980
|
-
)
|
|
981
|
-
};
|
|
982
|
-
}
|
|
983
|
-
return variableLayer2;
|
|
984
|
-
};
|
|
985
|
-
const variableLayer = resolveVariableLayer(
|
|
986
|
-
instanceScope == null ? void 0 : instanceScope.documentManager,
|
|
987
|
-
variableKey
|
|
988
|
-
);
|
|
989
|
-
if ((instanceScope == null ? void 0 : instanceScope.documentManager) && variableKey) {
|
|
990
|
-
subscriptions.current.push({
|
|
991
|
-
manager: instanceScope.documentManager,
|
|
992
|
-
key: variableKey
|
|
993
|
-
});
|
|
994
|
-
}
|
|
995
|
-
let instanceProp = variableId ? (_b = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _b[variableId] : void 0;
|
|
996
|
-
if (Array.isArray(instanceProp)) {
|
|
997
|
-
instanceProp = instanceProp.map(
|
|
998
|
-
(rawProp, index) => {
|
|
999
|
-
var _a3;
|
|
1000
|
-
return deepMerge$1(rawProp, (_a3 = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a3.at(index));
|
|
1001
|
-
}
|
|
1002
|
-
);
|
|
1003
|
-
}
|
|
1004
|
-
const lastCollectionItem = scopes.findLast(
|
|
1005
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.CollectionItemScope
|
|
1006
|
-
);
|
|
1007
|
-
resolveVariableLayer(
|
|
1008
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.manager,
|
|
1009
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
|
|
1010
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.value
|
|
1011
|
-
);
|
|
1012
|
-
const collectionItemProp = utils.isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_c = core.entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _c._id) === variableId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue$1(lastCollectionItem == null ? void 0 : lastCollectionItem.value, variableId);
|
|
1013
|
-
const currentValue = variableKey === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
|
|
1014
|
-
const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
|
|
1015
|
-
const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
|
|
1016
|
-
const resultValue = required ? currentValue : currentValue ?? collectionItemProp ?? defaultValue;
|
|
1017
|
-
if (definition.isVariableLink(resultValue)) {
|
|
1018
|
-
return readVariable(resultValue);
|
|
1019
|
-
}
|
|
1020
|
-
return { value: resultValue, layer: variableLayer };
|
|
1021
|
-
};
|
|
1022
981
|
const resolveField = (fieldPath, value, raw) => {
|
|
1023
982
|
var _a2;
|
|
1024
983
|
rawValues[fieldPath] = raw;
|
|
1025
984
|
if (definition.isVariableLink(value)) {
|
|
1026
|
-
const
|
|
1027
|
-
values[fieldPath] =
|
|
985
|
+
const resolvedValue = resolvedByKey[value] ?? value;
|
|
986
|
+
values[fieldPath] = resolvedValue;
|
|
1028
987
|
const variableId = (_a2 = core.entityOfKey(value)) == null ? void 0 : _a2._id;
|
|
1029
988
|
cssVariableValues[fieldPath] = `var(--${variableId}, ${transformCssValue(
|
|
1030
|
-
|
|
989
|
+
resolvedValue
|
|
1031
990
|
)})`;
|
|
1032
991
|
} else {
|
|
1033
992
|
values[fieldPath] = value;
|
|
1034
993
|
cssVariableValues[fieldPath] = transformCssValue(value);
|
|
1035
994
|
}
|
|
1036
995
|
};
|
|
1037
|
-
subscriptions.current = [];
|
|
1038
996
|
for (const [field, value] of Object.entries(layer)) {
|
|
1039
997
|
resolveField(field, value, rawLayer == null ? void 0 : rawLayer[field]);
|
|
1040
998
|
if (utils.isObject(value) && !definition.isVariableLink(value)) {
|
|
@@ -1059,188 +1017,6 @@ const useRenderTarget = () => {
|
|
|
1059
1017
|
isDocument: renderTarget === definition.definition.renderTarget.document
|
|
1060
1018
|
};
|
|
1061
1019
|
};
|
|
1062
|
-
const useReadVariables = (variableKeys) => {
|
|
1063
|
-
const filterKeys = variableKeys.filter(definition.isVariableLink);
|
|
1064
|
-
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1065
|
-
const { props, innerManager, layerKey } = react.useContext(InstanceContext);
|
|
1066
|
-
const resultManager = innerManager ?? fragmentManager;
|
|
1067
|
-
const variableLayers = react$1.useGraphStack(
|
|
1068
|
-
!!filterKeys.length ? resultManager : null,
|
|
1069
|
-
filterKeys,
|
|
1070
|
-
{
|
|
1071
|
-
selector: (graph) => graph ? utils.pick(graph, "defaultValue", "required") : graph
|
|
1072
|
-
}
|
|
1073
|
-
);
|
|
1074
|
-
return variableLayers.map((layer) => {
|
|
1075
|
-
const { _id: propertyId } = layer ?? {};
|
|
1076
|
-
const currentValue = (props == null ? void 0 : props[propertyId]) ?? null;
|
|
1077
|
-
const required = (layer == null ? void 0 : layer.required) ?? false;
|
|
1078
|
-
const defaultValue = (layer == null ? void 0 : layer.defaultValue) ?? null;
|
|
1079
|
-
const resultValue = required ? currentValue : currentValue ?? defaultValue;
|
|
1080
|
-
return {
|
|
1081
|
-
value: resultValue,
|
|
1082
|
-
layer
|
|
1083
|
-
};
|
|
1084
|
-
});
|
|
1085
|
-
};
|
|
1086
|
-
const extractVariableValue = (input, variableId) => {
|
|
1087
|
-
if (utils.isObject(input)) {
|
|
1088
|
-
if (variableId in input) {
|
|
1089
|
-
return input[variableId];
|
|
1090
|
-
}
|
|
1091
|
-
for (let key in input) {
|
|
1092
|
-
if (input.hasOwnProperty(key)) {
|
|
1093
|
-
const result = extractVariableValue(input[key], variableId);
|
|
1094
|
-
if (result !== void 0) {
|
|
1095
|
-
return result;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
return void 0;
|
|
1101
|
-
};
|
|
1102
|
-
function deepMerge(a, b) {
|
|
1103
|
-
if (!utils.isObject(a) || !utils.isObject(b)) return a;
|
|
1104
|
-
const result = { ...b };
|
|
1105
|
-
for (const [key, value] of Object.entries(a)) {
|
|
1106
|
-
if (key in result && typeof result[key] === "object" && typeof value === "object") {
|
|
1107
|
-
result[key] = deepMerge(value, result[key]);
|
|
1108
|
-
} else {
|
|
1109
|
-
result[key] = value;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
return result;
|
|
1113
|
-
}
|
|
1114
|
-
const useReadVariable = (variableKey, customScopes) => {
|
|
1115
|
-
const contextScopes = react.useContext(ScopeContext);
|
|
1116
|
-
const scopes = customScopes ?? contextScopes;
|
|
1117
|
-
const subscriptions = react.useRef([]);
|
|
1118
|
-
const [dep, forceUpdate] = useForceUpdate();
|
|
1119
|
-
react.useEffect(() => {
|
|
1120
|
-
const controller = new AbortController();
|
|
1121
|
-
let ready = false;
|
|
1122
|
-
const update = () => {
|
|
1123
|
-
if (!ready) return;
|
|
1124
|
-
forceUpdate();
|
|
1125
|
-
};
|
|
1126
|
-
for (const { manager, key } of subscriptions.current) {
|
|
1127
|
-
manager.subscribe(key, update, { signal: controller.signal });
|
|
1128
|
-
}
|
|
1129
|
-
ready = true;
|
|
1130
|
-
return () => controller.abort();
|
|
1131
|
-
});
|
|
1132
|
-
const extractVariableDefaultValue = (manager, variableEntity) => {
|
|
1133
|
-
const variableLayer = manager.resolve(variableEntity);
|
|
1134
|
-
if ((variableLayer == null ? void 0 : variableLayer.type) !== definition.definition.variableType.Object)
|
|
1135
|
-
return variableLayer == null ? void 0 : variableLayer.defaultValue;
|
|
1136
|
-
return Object.values((variableLayer == null ? void 0 : variableLayer.fields) ?? {}).reduce(
|
|
1137
|
-
(acc, fieldLink) => {
|
|
1138
|
-
var _a;
|
|
1139
|
-
if (!!fieldLink && definition.isVariableLink(fieldLink)) {
|
|
1140
|
-
const _id = (_a = core.entityOfKey(fieldLink)) == null ? void 0 : _a._id;
|
|
1141
|
-
if (_id) {
|
|
1142
|
-
acc[_id] = extractVariableDefaultValue(manager, fieldLink);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
return acc;
|
|
1146
|
-
},
|
|
1147
|
-
{}
|
|
1148
|
-
);
|
|
1149
|
-
};
|
|
1150
|
-
const resolveVariableLayer = (manager, variableLink, customProps) => {
|
|
1151
|
-
var _a, _b;
|
|
1152
|
-
const variableLayer = (_a = getNormalizeLayer(variableLink, manager)) == null ? void 0 : _a.layer;
|
|
1153
|
-
if (!variableLayer) return null;
|
|
1154
|
-
if ((variableLayer == null ? void 0 : variableLayer.type) === definition.definition.variableType.Array) {
|
|
1155
|
-
const definitionLayer = manager.resolve(variableLayer == null ? void 0 : variableLayer.definition);
|
|
1156
|
-
if (!((_b = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _b.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.definition.variableType.Object)
|
|
1157
|
-
return variableLayer;
|
|
1158
|
-
const definitionDefaultValue = extractVariableDefaultValue(
|
|
1159
|
-
manager,
|
|
1160
|
-
definitionLayer
|
|
1161
|
-
);
|
|
1162
|
-
const customValue = customProps == null ? void 0 : customProps[variableLayer == null ? void 0 : variableLayer._id];
|
|
1163
|
-
return {
|
|
1164
|
-
...variableLayer,
|
|
1165
|
-
defaultValue: (variableLayer == null ? void 0 : variableLayer.defaultValue).map((item, index) => {
|
|
1166
|
-
const customItemValue = Array.isArray(customValue) ? customValue.at(index) : null;
|
|
1167
|
-
return deepMerge(
|
|
1168
|
-
customItemValue ? { ...item, ...customItemValue } : item,
|
|
1169
|
-
definitionDefaultValue
|
|
1170
|
-
);
|
|
1171
|
-
})
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
|
-
return variableLayer;
|
|
1175
|
-
};
|
|
1176
|
-
const readVariable = (variableKey2) => {
|
|
1177
|
-
var _a, _b, _c;
|
|
1178
|
-
const variableId = (_a = core.entityOfKey(variableKey2)) == null ? void 0 : _a._id;
|
|
1179
|
-
if (!definition.isVariableLink(variableKey2)) {
|
|
1180
|
-
return {
|
|
1181
|
-
value: null,
|
|
1182
|
-
layer: null
|
|
1183
|
-
};
|
|
1184
|
-
}
|
|
1185
|
-
let instanceScope = scopes.findLast(
|
|
1186
|
-
(scope) => {
|
|
1187
|
-
var _a2;
|
|
1188
|
-
return (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.InstanceScope && !!((_a2 = scope.documentManager) == null ? void 0 : _a2.resolve(variableKey2));
|
|
1189
|
-
}
|
|
1190
|
-
);
|
|
1191
|
-
if (!instanceScope) {
|
|
1192
|
-
instanceScope = scopes.find(
|
|
1193
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.InstanceScope
|
|
1194
|
-
);
|
|
1195
|
-
}
|
|
1196
|
-
const variableLayer = resolveVariableLayer(
|
|
1197
|
-
instanceScope == null ? void 0 : instanceScope.documentManager,
|
|
1198
|
-
variableKey2
|
|
1199
|
-
);
|
|
1200
|
-
if ((instanceScope == null ? void 0 : instanceScope.documentManager) && variableKey2) {
|
|
1201
|
-
subscriptions.current.push({
|
|
1202
|
-
manager: instanceScope.documentManager,
|
|
1203
|
-
key: variableKey2
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
let instanceProp = (_b = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _b[variableId];
|
|
1207
|
-
if (Array.isArray(instanceProp)) {
|
|
1208
|
-
instanceProp = instanceProp.map(
|
|
1209
|
-
(rawProp, index) => {
|
|
1210
|
-
var _a2;
|
|
1211
|
-
return deepMerge(rawProp, (_a2 = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a2.at(index));
|
|
1212
|
-
}
|
|
1213
|
-
);
|
|
1214
|
-
}
|
|
1215
|
-
const lastCollectionItem = scopes.findLast(
|
|
1216
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.CollectionItemScope
|
|
1217
|
-
);
|
|
1218
|
-
resolveVariableLayer(
|
|
1219
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.manager,
|
|
1220
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
|
|
1221
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.value
|
|
1222
|
-
);
|
|
1223
|
-
const collectionItemProp = utils.isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_c = core.entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _c._id) === variableId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, variableId);
|
|
1224
|
-
const currentValue = variableKey2 === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
|
|
1225
|
-
const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
|
|
1226
|
-
const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
|
|
1227
|
-
const resultValue = required ? currentValue : currentValue ?? collectionItemProp ?? defaultValue;
|
|
1228
|
-
if (definition.isVariableLink(resultValue)) {
|
|
1229
|
-
return readVariable(resultValue);
|
|
1230
|
-
}
|
|
1231
|
-
return {
|
|
1232
|
-
value: resultValue,
|
|
1233
|
-
layer: variableLayer
|
|
1234
|
-
};
|
|
1235
|
-
};
|
|
1236
|
-
subscriptions.current = [];
|
|
1237
|
-
const result = readVariable(variableKey);
|
|
1238
|
-
return {
|
|
1239
|
-
...result,
|
|
1240
|
-
readVariable,
|
|
1241
|
-
_dep: dep
|
|
1242
|
-
};
|
|
1243
|
-
};
|
|
1244
1020
|
const useLayersValue = (layerKeys, fieldKey, options) => {
|
|
1245
1021
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1246
1022
|
const resultManager = (options == null ? void 0 : options.manager) ?? fragmentManager;
|
|
@@ -1252,12 +1028,21 @@ const useLayersValue = (layerKeys, fieldKey, options) => {
|
|
|
1252
1028
|
// selector: (data) => (data ? pick(data, fieldKey) : data),
|
|
1253
1029
|
});
|
|
1254
1030
|
const normalizeLayers = useNormalizeLayers(keys, resultManager, options);
|
|
1255
|
-
const
|
|
1031
|
+
const variableKeysFromLayers = normalizeLayers.map((nl) => utils.get(nl.layer, fieldKey)).filter(definition.isVariableLink);
|
|
1032
|
+
const resolvedVariables = useReadVariables(
|
|
1033
|
+
variableKeysFromLayers,
|
|
1034
|
+
resultManager
|
|
1035
|
+
);
|
|
1036
|
+
const resolvedByKey = {};
|
|
1037
|
+
variableKeysFromLayers.forEach((key, i) => {
|
|
1038
|
+
var _a;
|
|
1039
|
+
resolvedByKey[key] = ((_a = resolvedVariables[i]) == null ? void 0 : _a.value) ?? null;
|
|
1040
|
+
});
|
|
1256
1041
|
return normalizeLayers.map((normalizedLayer) => {
|
|
1257
|
-
var _a
|
|
1042
|
+
var _a;
|
|
1258
1043
|
const rawValue = utils.get(normalizedLayer.rawLayer, fieldKey);
|
|
1259
1044
|
const layerValue = utils.get(normalizedLayer.layer, fieldKey);
|
|
1260
|
-
const variableValue = (
|
|
1045
|
+
const variableValue = definition.isVariableLink(layerValue) ? resolvedByKey[layerValue] ?? null : null;
|
|
1261
1046
|
const currentValue = variableValue ?? layerValue;
|
|
1262
1047
|
const isInherit = isInheritField(
|
|
1263
1048
|
resultManager,
|
|
@@ -1282,15 +1067,15 @@ const useLayersValue = (layerKeys, fieldKey, options) => {
|
|
|
1282
1067
|
);
|
|
1283
1068
|
};
|
|
1284
1069
|
const restore = (fallbackValue) => {
|
|
1285
|
-
var _a2,
|
|
1286
|
-
const tempValue = ((_c = (
|
|
1070
|
+
var _a2, _b, _c;
|
|
1071
|
+
const tempValue = ((_c = (_b = resultManager.resolve((_a2 = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a2.temp)) == null ? void 0 : _b[normalizedLayer.layerKey]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
|
|
1287
1072
|
return tempValue;
|
|
1288
1073
|
};
|
|
1289
1074
|
const updateValue = (value, options2) => {
|
|
1290
1075
|
setter(value, options2);
|
|
1291
1076
|
};
|
|
1292
1077
|
const isVariable = definition.isVariableLink(rawValue ?? layerValue);
|
|
1293
|
-
const variableId = isVariable ? (
|
|
1078
|
+
const variableId = isVariable ? (_a = core.entityOfKey(layerValue)) == null ? void 0 : _a._id : null;
|
|
1294
1079
|
return [
|
|
1295
1080
|
currentValue,
|
|
1296
1081
|
updateValue,
|
|
@@ -1307,7 +1092,7 @@ const useLayersValue = (layerKeys, fieldKey, options) => {
|
|
|
1307
1092
|
});
|
|
1308
1093
|
};
|
|
1309
1094
|
const useLayerValue = (layerKey, fieldKey, options) => {
|
|
1310
|
-
var _a;
|
|
1095
|
+
var _a, _b;
|
|
1311
1096
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1312
1097
|
const resultManager = (options == null ? void 0 : options.manager) ?? fragmentManager;
|
|
1313
1098
|
if (!resultManager) {
|
|
@@ -1320,7 +1105,11 @@ const useLayerValue = (layerKey, fieldKey, options) => {
|
|
|
1320
1105
|
const { layer, rawLayer } = useNormalizeLayer(key, resultManager, options);
|
|
1321
1106
|
const rawValue = utils.get(rawLayer, fieldKey);
|
|
1322
1107
|
const layerValue = utils.get(layer, fieldKey);
|
|
1323
|
-
const
|
|
1108
|
+
const variableResults = useReadVariables(
|
|
1109
|
+
definition.isVariableLink(layerValue) ? [layerValue] : [],
|
|
1110
|
+
resultManager
|
|
1111
|
+
);
|
|
1112
|
+
const variableValue = ((_a = variableResults[0]) == null ? void 0 : _a.value) ?? null;
|
|
1324
1113
|
const currentValue = variableValue ?? layerValue;
|
|
1325
1114
|
const isInherit = isInheritField(resultManager, key, fieldKey);
|
|
1326
1115
|
const isOverride = !isInherit && !isPartOfPrimary(resultManager, key);
|
|
@@ -1337,8 +1126,8 @@ const useLayerValue = (layerKey, fieldKey, options) => {
|
|
|
1337
1126
|
}, [updateLayerData]);
|
|
1338
1127
|
const restore = react.useCallback(
|
|
1339
1128
|
(fallbackValue) => {
|
|
1340
|
-
var _a2,
|
|
1341
|
-
const tempValue = ((_c = (
|
|
1129
|
+
var _a2, _b2, _c;
|
|
1130
|
+
const tempValue = ((_c = (_b2 = resultManager.resolve((_a2 = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a2.temp)) == null ? void 0 : _b2[key]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
|
|
1342
1131
|
updateLayerData({ [fieldKey]: tempValue });
|
|
1343
1132
|
return tempValue;
|
|
1344
1133
|
},
|
|
@@ -1351,7 +1140,7 @@ const useLayerValue = (layerKey, fieldKey, options) => {
|
|
|
1351
1140
|
[setter]
|
|
1352
1141
|
);
|
|
1353
1142
|
const isVariable = definition.isVariableLink(rawValue ?? layerValue);
|
|
1354
|
-
const variableId = isVariable ? (
|
|
1143
|
+
const variableId = isVariable ? (_b = core.entityOfKey(layerValue)) == null ? void 0 : _b._id : null;
|
|
1355
1144
|
return [
|
|
1356
1145
|
currentValue,
|
|
1357
1146
|
updateValue,
|
|
@@ -1366,6 +1155,20 @@ const useLayerValue = (layerKey, fieldKey, options) => {
|
|
|
1366
1155
|
}
|
|
1367
1156
|
];
|
|
1368
1157
|
};
|
|
1158
|
+
const useReadVariable = (variableKey, _customScopes) => {
|
|
1159
|
+
const keys = variableKey && definition.isVariableLink(variableKey) ? [variableKey] : [];
|
|
1160
|
+
const results = useReadVariables(keys);
|
|
1161
|
+
const result = results[0] ?? { value: null, layer: null };
|
|
1162
|
+
return {
|
|
1163
|
+
...result,
|
|
1164
|
+
readVariable: () => {
|
|
1165
|
+
throw new Error(
|
|
1166
|
+
"readVariable() removed — используй useReadVariables"
|
|
1167
|
+
);
|
|
1168
|
+
},
|
|
1169
|
+
_dep: 0
|
|
1170
|
+
};
|
|
1171
|
+
};
|
|
1369
1172
|
const useLayerChildren = (layerKey, customManager) => {
|
|
1370
1173
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1371
1174
|
const [layerData] = react$1.useGraph(customManager ?? fragmentManager, layerKey, {
|
|
@@ -1415,6 +1218,7 @@ const useLayerLink = (layerKey) => {
|
|
|
1415
1218
|
};
|
|
1416
1219
|
};
|
|
1417
1220
|
const useLayerVariableValue = (layerKey, fieldKey, manager) => {
|
|
1221
|
+
var _a;
|
|
1418
1222
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1419
1223
|
const resultManager = manager ?? fragmentManager;
|
|
1420
1224
|
const [layerValue, updateValue, layerInfo] = useLayerValue(
|
|
@@ -1422,9 +1226,11 @@ const useLayerVariableValue = (layerKey, fieldKey, manager) => {
|
|
|
1422
1226
|
fieldKey,
|
|
1423
1227
|
resultManager
|
|
1424
1228
|
);
|
|
1425
|
-
const
|
|
1426
|
-
(layerInfo == null ? void 0 : layerInfo.isVariable) ? layerValue :
|
|
1229
|
+
const variableResults = useReadVariables(
|
|
1230
|
+
(layerInfo == null ? void 0 : layerInfo.isVariable) && definition.isVariableLink(layerValue) ? [layerValue] : [],
|
|
1231
|
+
resultManager
|
|
1427
1232
|
);
|
|
1233
|
+
const instanceValue = ((_a = variableResults[0]) == null ? void 0 : _a.value) ?? null;
|
|
1428
1234
|
return [
|
|
1429
1235
|
(layerInfo == null ? void 0 : layerInfo.isVariable) ? instanceValue : layerValue,
|
|
1430
1236
|
updateValue,
|
|
@@ -1525,7 +1331,7 @@ const calcLayerSizeValue = (resolved, vars, sizeType, parentResolved, instanceVa
|
|
|
1525
1331
|
};
|
|
1526
1332
|
const useLayerSizeValue = (layerKey, sizeType) => {
|
|
1527
1333
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1528
|
-
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext
|
|
1334
|
+
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext);
|
|
1529
1335
|
const { isDocument } = useRenderTarget();
|
|
1530
1336
|
const isTop = isTopLevel(fragmentManager, layerKey);
|
|
1531
1337
|
const isPartOfInstance = !!instanceLayerKey;
|
|
@@ -1637,7 +1443,7 @@ const calcLayerPosition = (resolved, vars, parentResolved, instanceResolved, ins
|
|
|
1637
1443
|
};
|
|
1638
1444
|
};
|
|
1639
1445
|
const useLayerPosition = (layerKey) => {
|
|
1640
|
-
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext
|
|
1446
|
+
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext);
|
|
1641
1447
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1642
1448
|
const isTop = isTopLevel(fragmentManager, layerKey);
|
|
1643
1449
|
const { isDocument } = useRenderTarget();
|
|
@@ -1981,7 +1787,7 @@ const useLayerStyles = (layerKey) => {
|
|
|
1981
1787
|
try {
|
|
1982
1788
|
if (!layerKey) throw new Error("Empty layer key");
|
|
1983
1789
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1984
|
-
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext
|
|
1790
|
+
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext);
|
|
1985
1791
|
const { isDocument } = useRenderTarget();
|
|
1986
1792
|
const resolved = useResolvedLayer(layerKey);
|
|
1987
1793
|
const vars = useResolvedLayerVariables(resolved.layer, resolved.rawLayer);
|
|
@@ -2122,16 +1928,14 @@ const useTextContent = (layerKey, manager) => {
|
|
|
2122
1928
|
fragmentManager
|
|
2123
1929
|
);
|
|
2124
1930
|
const variables = extractVariablesFromHtml(content);
|
|
2125
|
-
const
|
|
2126
|
-
|
|
2127
|
-
fragmentManager,
|
|
2128
|
-
variables.map((variable) => variable.variableKey)
|
|
2129
|
-
);
|
|
1931
|
+
const variableKeys = variables.map((variable) => variable.variableKey);
|
|
1932
|
+
const resolvedVariables = useReadVariables(variableKeys);
|
|
2130
1933
|
let nextContent = content;
|
|
2131
|
-
variables.forEach((variable) => {
|
|
1934
|
+
variables.forEach((variable, index) => {
|
|
1935
|
+
var _a;
|
|
2132
1936
|
nextContent = nextContent.replace(
|
|
2133
1937
|
variable.fullMatch,
|
|
2134
|
-
|
|
1938
|
+
((_a = resolvedVariables[index]) == null ? void 0 : _a.value) ?? ""
|
|
2135
1939
|
);
|
|
2136
1940
|
});
|
|
2137
1941
|
if (typeof nextContent === "string") {
|
|
@@ -2219,31 +2023,31 @@ const useGlobalManager = (globalManager) => {
|
|
|
2219
2023
|
};
|
|
2220
2024
|
};
|
|
2221
2025
|
const useLayerInteractions = (layerKey, options) => {
|
|
2026
|
+
var _a;
|
|
2222
2027
|
const pause = (options == null ? void 0 : options.pauseInteractions) ?? false;
|
|
2223
2028
|
const { manager: globalManager } = useGlobalManager();
|
|
2224
2029
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
2225
2030
|
const scopes = react.useContext(ScopeContext);
|
|
2226
|
-
const areaScope = scopes.find(
|
|
2031
|
+
const areaScope = (_a = scopes == null ? void 0 : scopes.find) == null ? void 0 : _a.call(
|
|
2032
|
+
scopes,
|
|
2227
2033
|
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.AreaScope
|
|
2228
2034
|
);
|
|
2229
|
-
const
|
|
2230
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.InstanceScope
|
|
2231
|
-
);
|
|
2035
|
+
const { onChangeProps } = react.useContext(InstanceContext);
|
|
2232
2036
|
const [interactionLinks] = useLayerValue(layerKey, "interactions");
|
|
2233
2037
|
const interactionOns = useLayersValue(interactionLinks, "on");
|
|
2234
2038
|
const interactionEvents = useLayersValue(interactionLinks, "event");
|
|
2235
2039
|
const interactions = (interactionLinks ?? []).map((linkKey, index) => {
|
|
2236
|
-
var
|
|
2040
|
+
var _a2, _b;
|
|
2237
2041
|
return {
|
|
2238
2042
|
linkKey,
|
|
2239
|
-
on: (
|
|
2043
|
+
on: (_a2 = interactionOns == null ? void 0 : interactionOns.at(index)) == null ? void 0 : _a2.at(0),
|
|
2240
2044
|
event: (_b = interactionEvents == null ? void 0 : interactionEvents.at(index)) == null ? void 0 : _b.at(0)
|
|
2241
2045
|
};
|
|
2242
2046
|
});
|
|
2243
2047
|
const fireEvent = react.useCallback(
|
|
2244
2048
|
(eventLink) => {
|
|
2245
|
-
var
|
|
2246
|
-
const eventType = (
|
|
2049
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
2050
|
+
const eventType = (_a2 = core.entityOfKey(eventLink)) == null ? void 0 : _a2._type;
|
|
2247
2051
|
const eventValue = (_b = getNormalizeLayer(eventLink, fragmentManager)) == null ? void 0 : _b.layer;
|
|
2248
2052
|
console.log(scopes, eventLink, eventType, eventValue);
|
|
2249
2053
|
if (eventType === definition.definition.nodes.GoalEvent && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
@@ -2260,7 +2064,7 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
2260
2064
|
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((_f = targetLayer == null ? void 0 : targetLayer.layer) == null ? void 0 : _f.defaultValue);
|
|
2261
2065
|
if (definition.isVariableLink(target) && utils.isValue(value)) {
|
|
2262
2066
|
const targetId = (_g = core.entityOfKey(target)) == null ? void 0 : _g._id;
|
|
2263
|
-
|
|
2067
|
+
onChangeProps == null ? void 0 : onChangeProps(targetId, value);
|
|
2264
2068
|
}
|
|
2265
2069
|
}
|
|
2266
2070
|
},
|
|
@@ -2575,7 +2379,27 @@ const remapArrayItems = (items, mapping) => {
|
|
|
2575
2379
|
});
|
|
2576
2380
|
};
|
|
2577
2381
|
const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
2578
|
-
const
|
|
2382
|
+
const arrayVariableKeys = react.useMemo(() => {
|
|
2383
|
+
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
2384
|
+
const keys = [];
|
|
2385
|
+
for (const defKey of definitions) {
|
|
2386
|
+
const defVar = manager.resolve(defKey);
|
|
2387
|
+
if (!(defVar == null ? void 0 : defVar._id)) continue;
|
|
2388
|
+
if (defVar.type !== definition.definition.variableType.Array || !defVar.definition)
|
|
2389
|
+
continue;
|
|
2390
|
+
const propValue = props[defVar._id];
|
|
2391
|
+
if (definition.isVariableLink(propValue)) {
|
|
2392
|
+
keys.push(propValue);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
return keys;
|
|
2396
|
+
}, [definitions, manager, props]);
|
|
2397
|
+
const arrayResolvedResults = useReadVariables(arrayVariableKeys);
|
|
2398
|
+
const arrayResolvedByKey = {};
|
|
2399
|
+
arrayVariableKeys.forEach((key, i) => {
|
|
2400
|
+
var _a;
|
|
2401
|
+
arrayResolvedByKey[key] = ((_a = arrayResolvedResults[i]) == null ? void 0 : _a.value) ?? null;
|
|
2402
|
+
});
|
|
2579
2403
|
const leafKeys = react.useMemo(() => {
|
|
2580
2404
|
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
2581
2405
|
const keys = [];
|
|
@@ -2623,7 +2447,7 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2623
2447
|
}
|
|
2624
2448
|
}
|
|
2625
2449
|
return keys;
|
|
2626
|
-
}, [definitions, manager, parentManager, props
|
|
2450
|
+
}, [definitions, manager, parentManager, props]);
|
|
2627
2451
|
const arrayItemLayers = react$1.useGraphStack(
|
|
2628
2452
|
arrayItemKeys.length ? parentManager ?? manager : null,
|
|
2629
2453
|
arrayItemKeys
|
|
@@ -2662,7 +2486,7 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2662
2486
|
if (definition.isVariableLink(propValue) && resolveManager) {
|
|
2663
2487
|
const parentVar = resolveManager.resolve(propValue);
|
|
2664
2488
|
if ((parentVar == null ? void 0 : parentVar.type) === definition.definition.variableType.Array && (parentVar == null ? void 0 : parentVar.definition)) {
|
|
2665
|
-
const
|
|
2489
|
+
const resolvedArray = arrayResolvedByKey[propValue];
|
|
2666
2490
|
if (Array.isArray(resolvedArray)) {
|
|
2667
2491
|
const concreteItems = resolveArrayItems(
|
|
2668
2492
|
resolvedArray,
|
|
@@ -2704,11 +2528,11 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2704
2528
|
}, [
|
|
2705
2529
|
leafLayers,
|
|
2706
2530
|
arrayItemLayers,
|
|
2531
|
+
arrayResolvedResults,
|
|
2707
2532
|
props,
|
|
2708
2533
|
manager,
|
|
2709
2534
|
parentManager,
|
|
2710
|
-
definitions
|
|
2711
|
-
_dep
|
|
2535
|
+
definitions
|
|
2712
2536
|
]);
|
|
2713
2537
|
};
|
|
2714
2538
|
const CollectionItem = ({
|
|
@@ -2895,8 +2719,10 @@ const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
|
2895
2719
|
} = useGlobalManager(inputGlobalManager);
|
|
2896
2720
|
react$1.useGraph(globalManager, (_a = globalManager == null ? void 0 : globalManager.$fragments) == null ? void 0 : _a.key, {
|
|
2897
2721
|
selector: (state) => {
|
|
2898
|
-
|
|
2899
|
-
|
|
2722
|
+
return {
|
|
2723
|
+
...state,
|
|
2724
|
+
managers: fragmentId ? utils.pick(state.managers, fragmentId) : state.managers
|
|
2725
|
+
};
|
|
2900
2726
|
}
|
|
2901
2727
|
});
|
|
2902
2728
|
const manager = getFragmentManager(fragmentId);
|
|
@@ -2914,7 +2740,7 @@ const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
|
2914
2740
|
};
|
|
2915
2741
|
};
|
|
2916
2742
|
const useFragmentChildren = (fragmentId) => {
|
|
2917
|
-
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext
|
|
2743
|
+
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext);
|
|
2918
2744
|
const { manager, fragmentLayerKey } = useFragmentManager(fragmentId);
|
|
2919
2745
|
const children = useLayerChildren(fragmentLayerKey, manager);
|
|
2920
2746
|
const [resizeChildren, setResizeChildren] = react.useState(null);
|
|
@@ -2957,7 +2783,7 @@ const useFragmentCssChunks = (fragmentId) => {
|
|
|
2957
2783
|
};
|
|
2958
2784
|
const useFragment = (fragmentId, globalManager) => {
|
|
2959
2785
|
var _a, _b;
|
|
2960
|
-
const instanceContext = react.useContext(InstanceContext
|
|
2786
|
+
const instanceContext = react.useContext(InstanceContext);
|
|
2961
2787
|
const fragmentContext = useFragmentManager(fragmentId);
|
|
2962
2788
|
const { setRef, children, isResize, primary } = useFragmentChildren(fragmentId);
|
|
2963
2789
|
const chunkLinks = useFragmentCssChunks(fragmentId);
|
|
@@ -3056,7 +2882,64 @@ const Fragment = (props) => {
|
|
|
3056
2882
|
}
|
|
3057
2883
|
return Base;
|
|
3058
2884
|
};
|
|
3059
|
-
const
|
|
2885
|
+
const resolveFromManagers = (key, ...managers) => {
|
|
2886
|
+
for (const mgr of managers) {
|
|
2887
|
+
if (!mgr) continue;
|
|
2888
|
+
const layer = mgr.resolve(key, { deep: true });
|
|
2889
|
+
if (layer == null ? void 0 : layer.type) return { layer, manager: mgr };
|
|
2890
|
+
}
|
|
2891
|
+
return { layer: null, manager: null };
|
|
2892
|
+
};
|
|
2893
|
+
const collectAllVariableKeys = (extractProps, fragmentManager, globalManager, areaManager) => {
|
|
2894
|
+
const keys = [];
|
|
2895
|
+
const collectFromObject = (obj) => {
|
|
2896
|
+
for (const value of Object.values(obj)) {
|
|
2897
|
+
if (definition.isVariableLink(value)) {
|
|
2898
|
+
keys.push(value);
|
|
2899
|
+
} else if (utils.isObject(value)) {
|
|
2900
|
+
collectFromObject(value);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
};
|
|
2904
|
+
const collectObjectFields = (objectVar, manager) => {
|
|
2905
|
+
const fields = utils.cleanGraph(objectVar.fields);
|
|
2906
|
+
for (const fieldRef of Object.values(fields)) {
|
|
2907
|
+
let fieldKey;
|
|
2908
|
+
let fieldVar;
|
|
2909
|
+
if (definition.isVariableLink(fieldRef)) {
|
|
2910
|
+
fieldKey = fieldRef;
|
|
2911
|
+
fieldVar = manager == null ? void 0 : manager.resolve(fieldKey);
|
|
2912
|
+
} else if (utils.isObject(fieldRef) && (fieldRef == null ? void 0 : fieldRef._id)) {
|
|
2913
|
+
fieldKey = core.keyOfEntity(fieldRef);
|
|
2914
|
+
fieldVar = fieldRef;
|
|
2915
|
+
}
|
|
2916
|
+
if (!fieldVar || !fieldKey) continue;
|
|
2917
|
+
if (fieldVar.type === definition.definition.variableType.Object && fieldVar.fields) {
|
|
2918
|
+
collectObjectFields(fieldVar, manager);
|
|
2919
|
+
} else {
|
|
2920
|
+
keys.push(fieldKey);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
for (const value of Object.values(extractProps)) {
|
|
2925
|
+
if (definition.isVariableLink(value)) {
|
|
2926
|
+
keys.push(value);
|
|
2927
|
+
const { layer: varLayer, manager: varManager } = resolveFromManagers(
|
|
2928
|
+
value,
|
|
2929
|
+
fragmentManager,
|
|
2930
|
+
globalManager,
|
|
2931
|
+
areaManager
|
|
2932
|
+
);
|
|
2933
|
+
if ((varLayer == null ? void 0 : varLayer.type) === definition.definition.variableType.Object && (varLayer == null ? void 0 : varLayer.fields)) {
|
|
2934
|
+
collectObjectFields(varLayer, varManager);
|
|
2935
|
+
}
|
|
2936
|
+
} else if (utils.isObject(value)) {
|
|
2937
|
+
collectFromObject(value);
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
return keys;
|
|
2941
|
+
};
|
|
2942
|
+
const resolveObjectToConcreteValueFromMap = (objectVar, manager, resolvedByKey) => {
|
|
3060
2943
|
const fields = utils.cleanGraph(objectVar.fields);
|
|
3061
2944
|
const result = {};
|
|
3062
2945
|
for (const [fieldName, fieldRef] of Object.entries(fields)) {
|
|
@@ -3071,13 +2954,13 @@ const resolveObjectToConcreteValue = (objectVar, manager, readVariable) => {
|
|
|
3071
2954
|
}
|
|
3072
2955
|
if (!fieldVar || !fieldKey) continue;
|
|
3073
2956
|
if (fieldVar.type === definition.definition.variableType.Object && fieldVar.fields) {
|
|
3074
|
-
result[fieldName] =
|
|
2957
|
+
result[fieldName] = resolveObjectToConcreteValueFromMap(
|
|
3075
2958
|
fieldVar,
|
|
3076
2959
|
manager,
|
|
3077
|
-
|
|
2960
|
+
resolvedByKey
|
|
3078
2961
|
);
|
|
3079
2962
|
} else {
|
|
3080
|
-
const
|
|
2963
|
+
const value = resolvedByKey[fieldKey];
|
|
3081
2964
|
if (value != null) {
|
|
3082
2965
|
result[fieldName] = value;
|
|
3083
2966
|
}
|
|
@@ -3085,12 +2968,30 @@ const resolveObjectToConcreteValue = (objectVar, manager, readVariable) => {
|
|
|
3085
2968
|
}
|
|
3086
2969
|
return result;
|
|
3087
2970
|
};
|
|
2971
|
+
const deepResolveObjectValuesFromMap = (obj, resolvedByKey) => {
|
|
2972
|
+
const result = {};
|
|
2973
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2974
|
+
if (definition.isVariableLink(value)) {
|
|
2975
|
+
result[key] = resolvedByKey[value];
|
|
2976
|
+
} else if (utils.isObject(value)) {
|
|
2977
|
+
result[key] = deepResolveObjectValuesFromMap(
|
|
2978
|
+
value,
|
|
2979
|
+
resolvedByKey
|
|
2980
|
+
);
|
|
2981
|
+
} else {
|
|
2982
|
+
result[key] = value;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
return result;
|
|
2986
|
+
};
|
|
3088
2987
|
const useInstanceProps = (instanceProps) => {
|
|
3089
2988
|
const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
|
|
3090
2989
|
const { manager: loadedManager } = useFragmentManager(
|
|
3091
2990
|
isTopInstance ? instanceProps == null ? void 0 : instanceProps.fragmentId : null
|
|
3092
2991
|
);
|
|
3093
2992
|
const { manager: fragmentContextManager } = react.useContext(FragmentContext);
|
|
2993
|
+
const globalManager = react.useContext(GlobalManagerContext);
|
|
2994
|
+
const areaManager = react.useContext(AreaManagerContext);
|
|
3094
2995
|
const fragmentManager = isTopInstance ? loadedManager : fragmentContextManager;
|
|
3095
2996
|
const [instanceLayer] = react$1.useGraph(fragmentManager, instanceProps.layerKey);
|
|
3096
2997
|
const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
|
|
@@ -3103,30 +3004,52 @@ const useInstanceProps = (instanceProps) => {
|
|
|
3103
3004
|
};
|
|
3104
3005
|
}
|
|
3105
3006
|
const extractProps = utils.cleanGraph(inputProps);
|
|
3106
|
-
const
|
|
3007
|
+
const variableKeys = !isTopInstance ? collectAllVariableKeys(
|
|
3008
|
+
extractProps,
|
|
3009
|
+
fragmentManager,
|
|
3010
|
+
globalManager,
|
|
3011
|
+
areaManager
|
|
3012
|
+
) : [];
|
|
3013
|
+
const resolvedVariableResults = useReadVariables(variableKeys);
|
|
3014
|
+
const resolvedByKey = {};
|
|
3015
|
+
variableKeys.forEach((key, i) => {
|
|
3016
|
+
var _a;
|
|
3017
|
+
resolvedByKey[key] = ((_a = resolvedVariableResults[i]) == null ? void 0 : _a.value) ?? null;
|
|
3018
|
+
});
|
|
3107
3019
|
let resolvedProps = extractProps;
|
|
3108
3020
|
if (!isTopInstance) {
|
|
3109
3021
|
resolvedProps = {};
|
|
3110
3022
|
for (const [key, value] of Object.entries(extractProps)) {
|
|
3111
3023
|
if (!definition.isVariableLink(value)) {
|
|
3112
|
-
|
|
3024
|
+
if (utils.isObject(value)) {
|
|
3025
|
+
resolvedProps[key] = deepResolveObjectValuesFromMap(
|
|
3026
|
+
value,
|
|
3027
|
+
resolvedByKey
|
|
3028
|
+
);
|
|
3029
|
+
} else {
|
|
3030
|
+
resolvedProps[key] = value;
|
|
3031
|
+
}
|
|
3113
3032
|
continue;
|
|
3114
3033
|
}
|
|
3115
|
-
const
|
|
3034
|
+
const { layer: varLayer, manager: varManager } = resolveFromManagers(
|
|
3035
|
+
value,
|
|
3036
|
+
fragmentManager,
|
|
3037
|
+
globalManager,
|
|
3038
|
+
areaManager
|
|
3039
|
+
);
|
|
3116
3040
|
if ((varLayer == null ? void 0 : varLayer.type) === definition.definition.variableType.Array) {
|
|
3117
3041
|
resolvedProps[key] = value;
|
|
3118
3042
|
continue;
|
|
3119
3043
|
}
|
|
3120
3044
|
if ((varLayer == null ? void 0 : varLayer.type) === definition.definition.variableType.Object && (varLayer == null ? void 0 : varLayer.fields)) {
|
|
3121
|
-
resolvedProps[key] =
|
|
3045
|
+
resolvedProps[key] = resolveObjectToConcreteValueFromMap(
|
|
3122
3046
|
varLayer,
|
|
3123
|
-
|
|
3124
|
-
|
|
3047
|
+
varManager,
|
|
3048
|
+
resolvedByKey
|
|
3125
3049
|
);
|
|
3126
3050
|
continue;
|
|
3127
3051
|
}
|
|
3128
|
-
|
|
3129
|
-
resolvedProps[key] = resolved;
|
|
3052
|
+
resolvedProps[key] = resolvedByKey[value] ?? value;
|
|
3130
3053
|
}
|
|
3131
3054
|
}
|
|
3132
3055
|
react.useEffect(() => {
|
|
@@ -3187,6 +3110,45 @@ const useSuspenseLoadArea = (globalManager, areaCode, skip) => {
|
|
|
3187
3110
|
if (valueOrPromise == null) return null;
|
|
3188
3111
|
return createSuspenseResource(`area:${areaCode}`, valueOrPromise, cache).read();
|
|
3189
3112
|
};
|
|
3113
|
+
const collectPropertyCssVars = (manager, result) => {
|
|
3114
|
+
if (!(manager == null ? void 0 : manager.$properties)) return;
|
|
3115
|
+
const keys = manager.$properties.getPropertyKeys() ?? [];
|
|
3116
|
+
const processField = (fieldLayer) => {
|
|
3117
|
+
if (!(fieldLayer == null ? void 0 : fieldLayer._id)) return;
|
|
3118
|
+
if (fieldLayer.type === definition.definition.variableType.Object && fieldLayer.fields) {
|
|
3119
|
+
for (const [key, ref] of Object.entries(fieldLayer.fields)) {
|
|
3120
|
+
if (key === "_type" || key === "_id") continue;
|
|
3121
|
+
const child = utils.isObject(ref) ? ref : manager.resolve(ref);
|
|
3122
|
+
if (child) processField(child);
|
|
3123
|
+
}
|
|
3124
|
+
return;
|
|
3125
|
+
}
|
|
3126
|
+
if (fieldLayer.defaultValue != null) {
|
|
3127
|
+
result[`--${fieldLayer._id}`] = String(fieldLayer.defaultValue);
|
|
3128
|
+
}
|
|
3129
|
+
};
|
|
3130
|
+
for (const key of keys) {
|
|
3131
|
+
const layer = manager.resolve(key, { deep: true });
|
|
3132
|
+
if (layer) processField(layer);
|
|
3133
|
+
}
|
|
3134
|
+
};
|
|
3135
|
+
const useManagerCssProperties = () => {
|
|
3136
|
+
var _a, _b, _c, _d;
|
|
3137
|
+
const globalManager = react.useContext(GlobalManagerContext);
|
|
3138
|
+
const areaManager = react.useContext(AreaManagerContext);
|
|
3139
|
+
react$1.useGraph(globalManager, (_a = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _a.key);
|
|
3140
|
+
react$1.useGraph(areaManager, (_b = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _b.key);
|
|
3141
|
+
const globalKeys = ((_c = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _c.getPropertyKeys()) ?? [];
|
|
3142
|
+
const areaKeys = ((_d = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _d.getPropertyKeys()) ?? [];
|
|
3143
|
+
react$1.useGraphStack(globalKeys.length ? globalManager : null, globalKeys);
|
|
3144
|
+
react$1.useGraphStack(areaKeys.length ? areaManager : null, areaKeys);
|
|
3145
|
+
return react.useMemo(() => {
|
|
3146
|
+
const vars = {};
|
|
3147
|
+
collectPropertyCssVars(globalManager, vars);
|
|
3148
|
+
collectPropertyCssVars(areaManager, vars);
|
|
3149
|
+
return vars;
|
|
3150
|
+
}, [globalManager, areaManager, globalKeys.length, areaKeys.length]);
|
|
3151
|
+
};
|
|
3190
3152
|
const InstanceInitial = ({
|
|
3191
3153
|
Tag: inputTag,
|
|
3192
3154
|
style = {},
|
|
@@ -3218,71 +3180,43 @@ const InstanceInitial = ({
|
|
|
3218
3180
|
parentManager,
|
|
3219
3181
|
definitions
|
|
3220
3182
|
);
|
|
3221
|
-
const
|
|
3183
|
+
const propsCssVars = react.useMemo(
|
|
3222
3184
|
() => toCssCustomProperties(expandedProps),
|
|
3223
3185
|
[expandedProps]
|
|
3224
3186
|
);
|
|
3225
|
-
|
|
3226
|
-
const
|
|
3227
|
-
() => ({
|
|
3228
|
-
|
|
3229
|
-
props: expandedProps,
|
|
3230
|
-
definitions,
|
|
3231
|
-
fragmentId,
|
|
3232
|
-
documentManager: innerManager,
|
|
3233
|
-
layerKey: instanceProps.layerKey,
|
|
3234
|
-
onChangeProps
|
|
3235
|
-
}),
|
|
3236
|
-
[
|
|
3237
|
-
expandedProps,
|
|
3238
|
-
definitions,
|
|
3239
|
-
fragmentId,
|
|
3240
|
-
innerManager,
|
|
3241
|
-
instanceProps.layerKey,
|
|
3242
|
-
onChangeProps
|
|
3243
|
-
]
|
|
3187
|
+
const managerCssVars = useManagerCssProperties();
|
|
3188
|
+
const cssVars = react.useMemo(
|
|
3189
|
+
() => ({ ...managerCssVars, ...propsCssVars }),
|
|
3190
|
+
[managerCssVars, propsCssVars]
|
|
3244
3191
|
);
|
|
3192
|
+
useSuspenseLoadFragment(globalManager, fragmentId, !ssr);
|
|
3245
3193
|
const instanceContextValue = react.useMemo(
|
|
3246
3194
|
() => ({
|
|
3247
3195
|
layerKey: instanceProps.layerKey,
|
|
3248
3196
|
definitions,
|
|
3249
3197
|
innerManager,
|
|
3250
3198
|
parentManager,
|
|
3251
|
-
props: expandedProps
|
|
3199
|
+
props: expandedProps,
|
|
3200
|
+
onChangeProps
|
|
3252
3201
|
}),
|
|
3253
3202
|
[
|
|
3254
3203
|
instanceProps.layerKey,
|
|
3255
3204
|
definitions,
|
|
3256
3205
|
innerManager,
|
|
3257
3206
|
parentManager,
|
|
3258
|
-
expandedProps
|
|
3207
|
+
expandedProps,
|
|
3208
|
+
onChangeProps
|
|
3259
3209
|
]
|
|
3260
3210
|
);
|
|
3261
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3262
|
-
|
|
3211
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InstanceContext.Provider, { value: instanceContextValue, children: parentManager ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3212
|
+
Tag,
|
|
3263
3213
|
{
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
className: classnames,
|
|
3271
|
-
"data-key": instanceProps.layerKey,
|
|
3272
|
-
style: { ...style, ...cssVars },
|
|
3273
|
-
...link.linkProps,
|
|
3274
|
-
...events,
|
|
3275
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3276
|
-
Fragment,
|
|
3277
|
-
{
|
|
3278
|
-
fragmentId,
|
|
3279
|
-
globalManager,
|
|
3280
|
-
FrameElement,
|
|
3281
|
-
pauseInteractions
|
|
3282
|
-
}
|
|
3283
|
-
)
|
|
3284
|
-
}
|
|
3285
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(Tag, { style: { ...style, ...cssVars }, ...link.linkProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3214
|
+
className: classnames,
|
|
3215
|
+
"data-key": instanceProps.layerKey,
|
|
3216
|
+
style: { ...style, ...cssVars },
|
|
3217
|
+
...link.linkProps,
|
|
3218
|
+
...events,
|
|
3219
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3286
3220
|
Fragment,
|
|
3287
3221
|
{
|
|
3288
3222
|
fragmentId,
|
|
@@ -3290,18 +3224,26 @@ const InstanceInitial = ({
|
|
|
3290
3224
|
FrameElement,
|
|
3291
3225
|
pauseInteractions
|
|
3292
3226
|
}
|
|
3293
|
-
)
|
|
3227
|
+
)
|
|
3294
3228
|
}
|
|
3295
|
-
)
|
|
3229
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Tag, { style: { ...style, ...cssVars }, ...link.linkProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3230
|
+
Fragment,
|
|
3231
|
+
{
|
|
3232
|
+
fragmentId,
|
|
3233
|
+
globalManager,
|
|
3234
|
+
FrameElement,
|
|
3235
|
+
pauseInteractions
|
|
3236
|
+
}
|
|
3237
|
+
) }) });
|
|
3296
3238
|
};
|
|
3297
3239
|
const Instance = (props) => {
|
|
3298
|
-
return "globalManager" in props ? /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, {
|
|
3240
|
+
return "globalManager" in props ? /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(GlobalManagerProvider, { value: props.globalManager, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3299
3241
|
RenderTargetProvider,
|
|
3300
3242
|
{
|
|
3301
3243
|
value: props.renderTarget ?? definition.definition.renderTarget.document,
|
|
3302
3244
|
children: /* @__PURE__ */ jsxRuntime.jsx(InstanceInitial, { ...props })
|
|
3303
3245
|
}
|
|
3304
|
-
) }) }) : /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, {
|
|
3246
|
+
) }) }) : /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3305
3247
|
RenderTargetProvider,
|
|
3306
3248
|
{
|
|
3307
3249
|
value: props.renderTarget ?? definition.definition.renderTarget.document,
|
|
@@ -3512,7 +3454,7 @@ exports.Frame = Frame;
|
|
|
3512
3454
|
exports.GlobalManagerContext = GlobalManagerContext;
|
|
3513
3455
|
exports.GlobalManagerProvider = GlobalManagerProvider;
|
|
3514
3456
|
exports.Instance = Instance;
|
|
3515
|
-
exports.InstanceContext = InstanceContext
|
|
3457
|
+
exports.InstanceContext = InstanceContext;
|
|
3516
3458
|
exports.RenderTargetContext = RenderTargetContext;
|
|
3517
3459
|
exports.RenderTargetProvider = RenderTargetProvider;
|
|
3518
3460
|
exports.Scope = Scope;
|