@fragmentsx/render-react 1.2.6 → 1.4.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/useFragment.d.ts.map +1 -1
- package/dist/hooks/fragment/useFragmentManager.d.ts +1 -1
- package/dist/hooks/fragment/useFragmentManager.d.ts.map +1 -1
- package/dist/hooks/layer/index.d.ts +2 -1
- package/dist/hooks/layer/index.d.ts.map +1 -1
- package/dist/hooks/layer/useLayerValue.d.ts.map +1 -1
- package/dist/hooks/layer/useLayersValue.d.ts.map +1 -1
- package/dist/hooks/layer/useReadVariable.d.ts +1 -0
- package/dist/hooks/layer/useReadVariable.d.ts.map +1 -1
- package/dist/hooks/layer/useResolvedLayer.d.ts +14 -0
- package/dist/hooks/layer/useResolvedLayer.d.ts.map +1 -0
- package/dist/hooks/layer/useResolvedLayerVariables.d.ts +7 -0
- package/dist/hooks/layer/useResolvedLayerVariables.d.ts.map +1 -0
- package/dist/hooks/layer-styles/useLayerPaint.d.ts +8 -0
- package/dist/hooks/layer-styles/useLayerPaint.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/index.d.ts +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/index.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useImagePaint.d.ts +6 -0
- package/dist/hooks/layer-styles/useLayerStyles/useImagePaint.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerBackground.d.ts +4 -2
- package/dist/hooks/layer-styles/useLayerStyles/useLayerBackground.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerBorder.d.ts +16 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerBorder.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerDisplay.d.ts +2 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerDisplay.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerFlex.d.ts +4 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerFlex.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerLayout.d.ts +10 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerLayout.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerPosition.d.ts +36 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerPosition.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerSize.d.ts +7 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerSize.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerSizeValue.d.ts +9 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerSizeValue.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useLayerTextStyles.d.ts +4 -0
- package/dist/hooks/layer-styles/useLayerStyles/useLayerTextStyles.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useLayerStyles/useOptionalSize.d.ts +2 -0
- package/dist/hooks/layer-styles/useLayerStyles/useOptionalSize.d.ts.map +1 -1
- package/dist/hooks/suspense/index.d.ts +3 -0
- package/dist/hooks/suspense/index.d.ts.map +1 -0
- package/dist/hooks/suspense/useSuspenseLoadArea.d.ts +6 -0
- package/dist/hooks/suspense/useSuspenseLoadArea.d.ts.map +1 -0
- package/dist/hooks/suspense/useSuspenseLoadFragment.d.ts +3 -0
- package/dist/hooks/suspense/useSuspenseLoadFragment.d.ts.map +1 -0
- package/dist/hooks/utils/useExtractProps.d.ts +16 -0
- package/dist/hooks/utils/useExtractProps.d.ts.map +1 -0
- package/dist/hooks/utils/useLayerInteractions.d.ts.map +1 -1
- package/dist/index.cjs.js +1471 -668
- package/dist/index.es.js +1474 -671
- package/dist/nodes/Area/Area.d.ts +8 -0
- package/dist/nodes/Area/Area.d.ts.map +1 -1
- package/dist/nodes/Area/hooks/useArea.d.ts +7 -2
- package/dist/nodes/Area/hooks/useArea.d.ts.map +1 -1
- package/dist/nodes/Area/index.d.ts +1 -0
- package/dist/nodes/Area/index.d.ts.map +1 -1
- package/dist/nodes/Collection/Collection.d.ts.map +1 -1
- package/dist/nodes/Collection/hooks/useCollection.d.ts +1 -1
- 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 -1
- package/dist/nodes/CollectionItem/hooks/useCollection.d.ts.map +1 -1
- package/dist/nodes/CssChunk/hooks/useCssChunk.d.ts.map +1 -1
- package/dist/nodes/Fragment/Fragment.d.ts.map +1 -1
- package/dist/nodes/Frame/hooks/useFrame.d.ts +1 -1
- package/dist/nodes/Instance/Instance.d.ts.map +1 -1
- package/dist/nodes/Instance/hooks/useInstance.d.ts +1 -2
- package/dist/nodes/Instance/hooks/useInstance.d.ts.map +1 -1
- package/dist/nodes/Instance/hooks/useInstanceProps.d.ts +0 -1
- package/dist/nodes/Instance/hooks/useInstanceProps.d.ts.map +1 -1
- package/dist/nodes/Instance/test/array-linking.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/array-linking.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/cardDocuments.d.ts +39 -0
- package/dist/nodes/Instance/test/cardDocuments.d.ts.map +1 -0
- package/dist/nodes/Instance/test/collection-props.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/collection-props.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/collection-schema.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/collection-schema.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/dual-instance.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/dual-instance.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/props-basic.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/props-basic.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/props-drilling.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/props-drilling.browser.test.d.ts.map +1 -0
- package/dist/nodes/Instance/test/props-dynamic.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/props-dynamic.browser.test.d.ts.map +1 -0
- package/dist/nodes/Text/hooks/useTextAttributes.d.ts +1 -1
- package/dist/providers/AreaManager.d.ts +3 -0
- package/dist/providers/AreaManager.d.ts.map +1 -0
- package/dist/providers/Scope/index.d.ts.map +1 -1
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/utils/common/index.d.ts +0 -1
- package/dist/utils/common/index.d.ts.map +1 -1
- package/dist/utils/css/buildCssBlock.d.ts +6 -0
- package/dist/utils/css/buildCssBlock.d.ts.map +1 -0
- package/dist/utils/css/buildCssBlock.test.d.ts +2 -0
- package/dist/utils/css/buildCssBlock.test.d.ts.map +1 -0
- package/dist/utils/css/compareRules.d.ts +3 -0
- package/dist/utils/css/compareRules.d.ts.map +1 -0
- package/dist/utils/css/compareRules.test.d.ts +2 -0
- package/dist/utils/css/compareRules.test.d.ts.map +1 -0
- package/dist/utils/css/extractStyleSheet.d.ts +6 -0
- package/dist/utils/css/extractStyleSheet.d.ts.map +1 -0
- package/dist/utils/css/findGroups.d.ts +11 -0
- package/dist/utils/css/findGroups.d.ts.map +1 -0
- package/dist/utils/css/getAllChildren.d.ts +4 -0
- package/dist/utils/css/getAllChildren.d.ts.map +1 -0
- package/dist/utils/css/getAllChildren.test.d.ts +2 -0
- package/dist/utils/css/getAllChildren.test.d.ts.map +1 -0
- package/dist/utils/css/index.d.ts +12 -0
- package/dist/utils/css/index.d.ts.map +1 -0
- package/dist/utils/css/makeCss.d.ts +5 -0
- package/dist/utils/css/makeCss.d.ts.map +1 -0
- package/dist/utils/css/toCSS.d.ts +3 -0
- package/dist/utils/css/toCSS.d.ts.map +1 -0
- package/dist/utils/css/toCSS.test.d.ts +2 -0
- package/dist/utils/css/toCSS.test.d.ts.map +1 -0
- package/dist/utils/css/types.d.ts +5 -0
- package/dist/utils/css/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/layer/cloneLayer.d.ts.map +1 -1
- package/dist/utils/layer/duplicateLayer.d.ts.map +1 -1
- package/dist/utils/suspense/createSuspenseResource.d.ts +5 -0
- package/dist/utils/suspense/createSuspenseResource.d.ts.map +1 -0
- package/dist/utils/suspense/createSuspenseResource.test.d.ts +2 -0
- package/dist/utils/suspense/createSuspenseResource.test.d.ts.map +1 -0
- package/dist/utils/suspense/index.d.ts +4 -0
- package/dist/utils/suspense/index.d.ts.map +1 -0
- package/dist/utils/suspense/suspenseCache.d.ts +4 -0
- package/dist/utils/suspense/suspenseCache.d.ts.map +1 -0
- package/dist/utils/suspense/suspenseCache.test.d.ts +2 -0
- package/dist/utils/suspense/suspenseCache.test.d.ts.map +1 -0
- package/dist/utils/variables/index.d.ts +1 -1
- package/dist/utils/variables/index.d.ts.map +1 -1
- package/dist/utils/variables/toCssCustomProperties.d.ts +7 -0
- package/dist/utils/variables/toCssCustomProperties.d.ts.map +1 -0
- package/package.json +6 -5
- package/dist/hooks/layer/useExtractProps.d.ts +0 -9
- package/dist/hooks/layer/useExtractProps.d.ts.map +0 -1
- package/dist/hooks/layer/useLayerCssVariable.d.ts +0 -8
- package/dist/hooks/layer/useLayerCssVariable.d.ts.map +0 -1
- package/dist/utils/common/loadFragmentManager.d.ts +0 -3
- package/dist/utils/common/loadFragmentManager.d.ts.map +0 -1
- package/dist/utils/variables/getCssVariables.d.ts +0 -3
- package/dist/utils/variables/getCssVariables.d.ts.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -3,9 +3,10 @@ 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");
|
|
7
6
|
const utils = require("@fragmentsx/utils");
|
|
8
7
|
const core = require("@graph-state/core");
|
|
8
|
+
const react$1 = require("@graph-state/react");
|
|
9
|
+
const clientCore = require("@fragmentsx/client-core");
|
|
9
10
|
const GlobalManagerContext = react.createContext(null);
|
|
10
11
|
const GlobalManagerProvider = GlobalManagerContext.Provider;
|
|
11
12
|
const FragmentContext = react.createContext({
|
|
@@ -24,35 +25,9 @@ const RenderTargetContext = react.createContext(
|
|
|
24
25
|
definition.definition.renderTarget.document
|
|
25
26
|
);
|
|
26
27
|
const RenderTargetProvider = RenderTargetContext.Provider;
|
|
28
|
+
const AreaManagerContext = react.createContext(null);
|
|
29
|
+
const AreaManagerProvider = AreaManagerContext.Provider;
|
|
27
30
|
const ScopeContext = react.createContext([]);
|
|
28
|
-
const useGlobalManager = (globalManager) => {
|
|
29
|
-
var _a, _b;
|
|
30
|
-
const currentGlobalManager = react.useContext(GlobalManagerContext);
|
|
31
|
-
const resultManager = globalManager ?? currentGlobalManager;
|
|
32
|
-
const [fragmentsGraph] = react$1.useGraph(
|
|
33
|
-
resultManager,
|
|
34
|
-
(_a = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _a.key
|
|
35
|
-
);
|
|
36
|
-
const queryFragmentManager = (id) => {
|
|
37
|
-
var _a2, _b2;
|
|
38
|
-
return (_b2 = (_a2 = resultManager == null ? void 0 : resultManager.$load) == null ? void 0 : _a2.loadFragment) == null ? void 0 : _b2.call(_a2, id);
|
|
39
|
-
};
|
|
40
|
-
const queryArea = (id) => {
|
|
41
|
-
var _a2, _b2;
|
|
42
|
-
return (_b2 = (_a2 = resultManager == null ? void 0 : resultManager.$load) == null ? void 0 : _a2.loadArea) == null ? void 0 : _b2.call(_a2, id);
|
|
43
|
-
};
|
|
44
|
-
const setRenderTarget = (value) => {
|
|
45
|
-
resultManager == null ? void 0 : resultManager.setRenderTarget(value);
|
|
46
|
-
};
|
|
47
|
-
return {
|
|
48
|
-
fragmentsGraph,
|
|
49
|
-
manager: resultManager,
|
|
50
|
-
queryFragmentManager,
|
|
51
|
-
queryArea,
|
|
52
|
-
getFragmentManager: ((_b = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _b.getManager) ?? utils.noop,
|
|
53
|
-
setRenderTarget
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
31
|
const Scope = ({
|
|
57
32
|
value,
|
|
58
33
|
children,
|
|
@@ -60,9 +35,11 @@ const Scope = ({
|
|
|
60
35
|
layerKey
|
|
61
36
|
}) => {
|
|
62
37
|
var _a, _b;
|
|
63
|
-
const { manager: globalManager } = useGlobalManager();
|
|
64
38
|
const currentScope = react.useContext(ScopeContext) ?? [];
|
|
65
|
-
const nextScope =
|
|
39
|
+
const nextScope = react.useMemo(
|
|
40
|
+
() => [...currentScope, value],
|
|
41
|
+
[currentScope, value]
|
|
42
|
+
);
|
|
66
43
|
(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.registerScope) == null ? void 0 : _b.call(_a, layerKey, value);
|
|
67
44
|
return /* @__PURE__ */ jsxRuntime.jsx(ScopeContext.Provider, { value: nextScope, children });
|
|
68
45
|
};
|
|
@@ -73,191 +50,6 @@ const getOverrider = (manager, layerEntity) => {
|
|
|
73
50
|
const layer = manager.resolve(layerEntity);
|
|
74
51
|
return manager.resolve(getKey(layer == null ? void 0 : layer.overrideFrom) ?? layerEntity);
|
|
75
52
|
};
|
|
76
|
-
const getLayer = (manager, layer, options) => {
|
|
77
|
-
if (!manager || !layer) return null;
|
|
78
|
-
const layerKey = manager.keyOfEntity(layer);
|
|
79
|
-
const layerData = manager.resolve(layerKey);
|
|
80
|
-
const overrider = getOverrider(manager, layerKey);
|
|
81
|
-
return definition.getNormalizeLayer(layerData, overrider, options == null ? void 0 : options.withFallback);
|
|
82
|
-
};
|
|
83
|
-
const getNormalizeLayer = (layerKey, manager, options) => {
|
|
84
|
-
const layer = manager == null ? void 0 : manager.resolve(layerKey);
|
|
85
|
-
const parsedLayer = getLayer(manager, layerKey, options);
|
|
86
|
-
return {
|
|
87
|
-
layerKey,
|
|
88
|
-
rawLayer: layer,
|
|
89
|
-
layer: parsedLayer
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
const useNormalizeLayer = (layerKey, manager, options) => {
|
|
93
|
-
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
94
|
-
const resultManager = manager ?? fragmentManager;
|
|
95
|
-
if (!resultManager) {
|
|
96
|
-
return {
|
|
97
|
-
layerKey,
|
|
98
|
-
rawLayer: null,
|
|
99
|
-
layer: null
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return getNormalizeLayer(layerKey, resultManager, options);
|
|
103
|
-
};
|
|
104
|
-
const useNormalizeLayers = (layerKeys, manager, options) => {
|
|
105
|
-
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
106
|
-
const resultManager = manager ?? fragmentManager;
|
|
107
|
-
return layerKeys.map(
|
|
108
|
-
(layerKey) => getNormalizeLayer(layerKey, resultManager, options)
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
function useForceUpdate() {
|
|
112
|
-
return react.useReducer(() => ({}), {});
|
|
113
|
-
}
|
|
114
|
-
const extractVariableValue = (input, variableId) => {
|
|
115
|
-
if (utils.isObject(input)) {
|
|
116
|
-
if (variableId in input) {
|
|
117
|
-
return input[variableId];
|
|
118
|
-
}
|
|
119
|
-
for (let key in input) {
|
|
120
|
-
if (input.hasOwnProperty(key)) {
|
|
121
|
-
const result = extractVariableValue(input[key], variableId);
|
|
122
|
-
if (result !== void 0) {
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return void 0;
|
|
129
|
-
};
|
|
130
|
-
function deepMerge(a, b) {
|
|
131
|
-
if (!utils.isObject(a) || !utils.isObject(b)) return a;
|
|
132
|
-
const result = { ...b };
|
|
133
|
-
for (const [key, value] of Object.entries(a)) {
|
|
134
|
-
if (key in result && typeof result[key] === "object" && typeof value === "object") {
|
|
135
|
-
result[key] = deepMerge(value, result[key]);
|
|
136
|
-
} else {
|
|
137
|
-
result[key] = value;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return result;
|
|
141
|
-
}
|
|
142
|
-
const useReadVariable = (variableKey, customScopes) => {
|
|
143
|
-
const contextScopes = react.useContext(ScopeContext);
|
|
144
|
-
const scopes = customScopes ?? contextScopes;
|
|
145
|
-
const unmountAbortController = react.useRef(new AbortController());
|
|
146
|
-
const [dep, forceUpdate] = useForceUpdate();
|
|
147
|
-
react.useEffect(
|
|
148
|
-
() => () => {
|
|
149
|
-
var _a;
|
|
150
|
-
(_a = unmountAbortController.current) == null ? void 0 : _a.abort("unmount");
|
|
151
|
-
},
|
|
152
|
-
[]
|
|
153
|
-
);
|
|
154
|
-
const extractVariableDefaultValue = (manager, variableEntity) => {
|
|
155
|
-
const variableLayer = manager.resolve(variableEntity);
|
|
156
|
-
if ((variableLayer == null ? void 0 : variableLayer.type) !== definition.definition.variableType.Object)
|
|
157
|
-
return variableLayer == null ? void 0 : variableLayer.defaultValue;
|
|
158
|
-
return Object.values((variableLayer == null ? void 0 : variableLayer.fields) ?? {}).reduce(
|
|
159
|
-
(acc, fieldLink) => {
|
|
160
|
-
var _a;
|
|
161
|
-
if (!!fieldLink && definition.isVariableLink(fieldLink)) {
|
|
162
|
-
const _id = (_a = core.entityOfKey(fieldLink)) == null ? void 0 : _a._id;
|
|
163
|
-
if (_id) {
|
|
164
|
-
acc[_id] = extractVariableDefaultValue(manager, fieldLink);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return acc;
|
|
168
|
-
},
|
|
169
|
-
{}
|
|
170
|
-
);
|
|
171
|
-
};
|
|
172
|
-
const resolveVariableLayer = (manager, variableLink, customProps) => {
|
|
173
|
-
var _a, _b;
|
|
174
|
-
const variableLayer = (_a = getNormalizeLayer(variableLink, manager)) == null ? void 0 : _a.layer;
|
|
175
|
-
if (!variableLayer) return null;
|
|
176
|
-
if ((variableLayer == null ? void 0 : variableLayer.type) === definition.definition.variableType.Array) {
|
|
177
|
-
const definitionLayer = manager.resolve(variableLayer == null ? void 0 : variableLayer.definition);
|
|
178
|
-
if (!((_b = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _b.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== definition.definition.variableType.Object)
|
|
179
|
-
return variableLayer;
|
|
180
|
-
const definitionDefaultValue = extractVariableDefaultValue(
|
|
181
|
-
manager,
|
|
182
|
-
definitionLayer
|
|
183
|
-
);
|
|
184
|
-
const customValue = customProps == null ? void 0 : customProps[variableLayer == null ? void 0 : variableLayer._id];
|
|
185
|
-
return {
|
|
186
|
-
...variableLayer,
|
|
187
|
-
defaultValue: (variableLayer == null ? void 0 : variableLayer.defaultValue).map((item, index) => {
|
|
188
|
-
const customItemValue = Array.isArray(customValue) ? customValue.at(index) : null;
|
|
189
|
-
return deepMerge(
|
|
190
|
-
customItemValue ? { ...item, ...customItemValue } : item,
|
|
191
|
-
definitionDefaultValue
|
|
192
|
-
);
|
|
193
|
-
})
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
return variableLayer;
|
|
197
|
-
};
|
|
198
|
-
const readVariable = (variableKey2) => {
|
|
199
|
-
var _a, _b, _c, _d, _e;
|
|
200
|
-
const variableId = (_a = core.entityOfKey(variableKey2)) == null ? void 0 : _a._id;
|
|
201
|
-
if (!definition.isVariableLink(variableKey2)) {
|
|
202
|
-
return {
|
|
203
|
-
value: null,
|
|
204
|
-
layer: null
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
let instanceScope = scopes.findLast(
|
|
208
|
-
(scope) => {
|
|
209
|
-
var _a2;
|
|
210
|
-
return (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.InstanceScope && !!((_a2 = scope.documentManager) == null ? void 0 : _a2.resolve(variableKey2));
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
if (!instanceScope) {
|
|
214
|
-
instanceScope = scopes.find(
|
|
215
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.InstanceScope
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
const variableLayer = resolveVariableLayer(
|
|
219
|
-
instanceScope == null ? void 0 : instanceScope.documentManager,
|
|
220
|
-
variableKey2
|
|
221
|
-
);
|
|
222
|
-
(_c = instanceScope == null ? void 0 : instanceScope.documentManager) == null ? void 0 : _c.subscribe(variableKey2, forceUpdate, {
|
|
223
|
-
signal: (_b = unmountAbortController.current) == null ? void 0 : _b.signal
|
|
224
|
-
});
|
|
225
|
-
let instanceProp = (_d = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _d[variableId];
|
|
226
|
-
if (Array.isArray(instanceProp)) {
|
|
227
|
-
instanceProp = instanceProp.map(
|
|
228
|
-
(rawProp, index) => {
|
|
229
|
-
var _a2;
|
|
230
|
-
return deepMerge(rawProp, (_a2 = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a2.at(index));
|
|
231
|
-
}
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
const lastCollectionItem = scopes.findLast(
|
|
235
|
-
(scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.CollectionItemScope
|
|
236
|
-
);
|
|
237
|
-
resolveVariableLayer(
|
|
238
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.manager,
|
|
239
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
|
|
240
|
-
lastCollectionItem == null ? void 0 : lastCollectionItem.value
|
|
241
|
-
);
|
|
242
|
-
const collectionItemProp = utils.isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_e = core.entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _e._id) === variableId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, variableId);
|
|
243
|
-
const currentValue = variableKey2 === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
|
|
244
|
-
const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
|
|
245
|
-
const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
|
|
246
|
-
const resultValue = required ? currentValue : currentValue ?? collectionItemProp ?? defaultValue;
|
|
247
|
-
if (definition.isVariableLink(resultValue)) {
|
|
248
|
-
return readVariable(resultValue);
|
|
249
|
-
}
|
|
250
|
-
return {
|
|
251
|
-
value: resultValue,
|
|
252
|
-
layer: variableLayer
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
const result = readVariable(variableKey);
|
|
256
|
-
return {
|
|
257
|
-
...result,
|
|
258
|
-
readVariable
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
53
|
const getParent = (manager, layerKey) => {
|
|
262
54
|
const layer = manager.resolve(layerKey);
|
|
263
55
|
return manager.resolve(getKey(layer == null ? void 0 : layer.parent) ?? null);
|
|
@@ -433,6 +225,9 @@ const cloneLayer = (manager, layer, externalProps = {}) => {
|
|
|
433
225
|
layerGraph,
|
|
434
226
|
(key, value, history) => {
|
|
435
227
|
const isRoot = history.length <= 2;
|
|
228
|
+
if ((value == null ? void 0 : value._type) === definition.definition.nodes.Instance && key === "props") {
|
|
229
|
+
return utils.cleanGraph(value);
|
|
230
|
+
}
|
|
436
231
|
if (!!value && n(value) && !IGNORE_TYPES.includes(value._type)) {
|
|
437
232
|
const nextId = utils.generateId();
|
|
438
233
|
const parentFromValue = utils.getKey(value.parent);
|
|
@@ -669,6 +464,41 @@ const moveChildren = (manager, targetKey, to, index) => {
|
|
|
669
464
|
spliceChildren(manager, targetParent, targetKey);
|
|
670
465
|
}
|
|
671
466
|
};
|
|
467
|
+
const getLayer = (manager, layer, options) => {
|
|
468
|
+
if (!manager || !layer) return null;
|
|
469
|
+
const layerKey = manager.keyOfEntity(layer);
|
|
470
|
+
const layerData = manager.resolve(layerKey);
|
|
471
|
+
const overrider = getOverrider(manager, layerKey);
|
|
472
|
+
return definition.getNormalizeLayer(layerData, overrider, options == null ? void 0 : options.withFallback);
|
|
473
|
+
};
|
|
474
|
+
const getNormalizeLayer = (layerKey, manager, options) => {
|
|
475
|
+
const layer = manager == null ? void 0 : manager.resolve(layerKey);
|
|
476
|
+
const parsedLayer = getLayer(manager, layerKey, options);
|
|
477
|
+
return {
|
|
478
|
+
layerKey,
|
|
479
|
+
rawLayer: layer,
|
|
480
|
+
layer: parsedLayer
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
const useNormalizeLayer = (layerKey, manager, options) => {
|
|
484
|
+
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
485
|
+
const resultManager = manager ?? fragmentManager;
|
|
486
|
+
if (!resultManager) {
|
|
487
|
+
return {
|
|
488
|
+
layerKey,
|
|
489
|
+
rawLayer: null,
|
|
490
|
+
layer: null
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
return getNormalizeLayer(layerKey, resultManager, options);
|
|
494
|
+
};
|
|
495
|
+
const useNormalizeLayers = (layerKeys, manager, options) => {
|
|
496
|
+
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
497
|
+
const resultManager = manager ?? fragmentManager;
|
|
498
|
+
return layerKeys.map(
|
|
499
|
+
(layerKey) => getNormalizeLayer(layerKey, resultManager, options)
|
|
500
|
+
);
|
|
501
|
+
};
|
|
672
502
|
const calcBackground = (manager, layerKey) => {
|
|
673
503
|
manager.resolve(layerKey);
|
|
674
504
|
const { layer } = getNormalizeLayer(layerKey, manager);
|
|
@@ -781,23 +611,21 @@ const calcLinearGradient = (angle, values) => {
|
|
|
781
611
|
}
|
|
782
612
|
return `linear-gradient(${angle}deg, ${parts.join(", ")})`;
|
|
783
613
|
};
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
var _a, _b;
|
|
790
|
-
return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
|
|
614
|
+
const getOverriderByLayers = (layerKey, layers) => {
|
|
615
|
+
return layers.find((l) => {
|
|
616
|
+
var _a;
|
|
617
|
+
return (_a = l == null ? void 0 : l.overrides) == null ? void 0 : _a.includes(layerKey);
|
|
618
|
+
});
|
|
791
619
|
};
|
|
792
|
-
const
|
|
793
|
-
return Object.entries(
|
|
620
|
+
const toCssCustomProperties = (props) => {
|
|
621
|
+
return Object.entries(props).reduce(
|
|
794
622
|
(acc, [key, value]) => {
|
|
795
623
|
var _a, _b;
|
|
796
|
-
if (isVariableLink(value)) {
|
|
624
|
+
if (definition.isVariableLink(value)) {
|
|
797
625
|
const nestedVariableId = (_a = core.entityOfKey(value)) == null ? void 0 : _a._id;
|
|
798
626
|
value = `var(--${nestedVariableId})`;
|
|
799
627
|
}
|
|
800
|
-
if (
|
|
628
|
+
if (typeof value === "string" && ((_b = value.startsWith) == null ? void 0 : _b.call(value, "http"))) {
|
|
801
629
|
value = `url("${value}")`;
|
|
802
630
|
}
|
|
803
631
|
acc[`--${key}`] = value;
|
|
@@ -806,12 +634,6 @@ const getCssVariables = (props) => {
|
|
|
806
634
|
{}
|
|
807
635
|
);
|
|
808
636
|
};
|
|
809
|
-
const getOverriderByLayers = (layerKey, layers) => {
|
|
810
|
-
return layers.find((l) => {
|
|
811
|
-
var _a;
|
|
812
|
-
return (_a = l == null ? void 0 : l.overrides) == null ? void 0 : _a.includes(layerKey);
|
|
813
|
-
});
|
|
814
|
-
};
|
|
815
637
|
const declareFragmentProperty = (manager, property, fragmentLink = manager.$fragment.root) => {
|
|
816
638
|
const propertyLayer = createLayer(property);
|
|
817
639
|
if (propertyLayer && "type" in propertyLayer) {
|
|
@@ -863,21 +685,48 @@ function getHydratedData(id) {
|
|
|
863
685
|
return null;
|
|
864
686
|
}
|
|
865
687
|
}
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
688
|
+
const createSuspenseResource = (key, valueOrPromise, cache) => {
|
|
689
|
+
if (cache.has(key)) return cache.get(key);
|
|
690
|
+
if (!(valueOrPromise instanceof Promise)) {
|
|
691
|
+
const resource2 = {
|
|
692
|
+
read() {
|
|
693
|
+
return valueOrPromise;
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
cache.set(key, resource2);
|
|
697
|
+
return resource2;
|
|
698
|
+
}
|
|
699
|
+
let status = "pending";
|
|
700
|
+
let result;
|
|
701
|
+
let error;
|
|
702
|
+
const suspender = valueOrPromise.then(
|
|
703
|
+
(r) => {
|
|
704
|
+
status = "success";
|
|
705
|
+
result = r;
|
|
706
|
+
},
|
|
707
|
+
(e) => {
|
|
708
|
+
status = "error";
|
|
709
|
+
error = e;
|
|
874
710
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
711
|
+
);
|
|
712
|
+
const resource = {
|
|
713
|
+
read() {
|
|
714
|
+
if (status === "pending") throw suspender;
|
|
715
|
+
if (status === "error") throw error;
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
cache.set(key, resource);
|
|
720
|
+
return resource;
|
|
721
|
+
};
|
|
722
|
+
const globalCache = /* @__PURE__ */ new WeakMap();
|
|
723
|
+
const getSuspenseCache = (manager) => {
|
|
724
|
+
let cache = globalCache.get(manager);
|
|
725
|
+
if (!cache) {
|
|
726
|
+
cache = /* @__PURE__ */ new Map();
|
|
727
|
+
globalCache.set(manager, cache);
|
|
879
728
|
}
|
|
880
|
-
return
|
|
729
|
+
return cache;
|
|
881
730
|
};
|
|
882
731
|
const duplicateLayer = (manager, layer) => {
|
|
883
732
|
var _a;
|
|
@@ -886,6 +735,9 @@ const duplicateLayer = (manager, layer) => {
|
|
|
886
735
|
const linkedMap = {};
|
|
887
736
|
const nextLayer = nodeWalker(layerGraph, (key, value, history) => {
|
|
888
737
|
const nextId = utils.generateId();
|
|
738
|
+
if ((value == null ? void 0 : value._type) === definition.definition.nodes.Instance && key === "props") {
|
|
739
|
+
return utils.cleanGraph(value);
|
|
740
|
+
}
|
|
889
741
|
if (!!value && n(value)) {
|
|
890
742
|
linkedMap[core.keyOfEntity(value)] = core.keyOfEntity({ ...value, _id: nextId });
|
|
891
743
|
const linkedParent = linkedMap == null ? void 0 : linkedMap[utils.getKey(value.parent)];
|
|
@@ -952,6 +804,14 @@ const wrapTextInParagraphWithAttributes = (text, attributes) => {
|
|
|
952
804
|
).map(([key, value]) => `${utils.toKebabCase(key)}: ${value}`).join("; ");
|
|
953
805
|
return `<p style="${style}">${text}</p>`;
|
|
954
806
|
};
|
|
807
|
+
const isVariableLink = (value) => {
|
|
808
|
+
var _a;
|
|
809
|
+
return isLink(value) && ((_a = value == null ? void 0 : value.split(":")) == null ? void 0 : _a.at(0)) === definition.definition.nodes.Variable;
|
|
810
|
+
};
|
|
811
|
+
const isLink = (value) => {
|
|
812
|
+
var _a, _b;
|
|
813
|
+
return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
|
|
814
|
+
};
|
|
955
815
|
const layerFieldSetter = (manager, layerKey, fieldKey, currentValue) => (value, options) => {
|
|
956
816
|
var _a;
|
|
957
817
|
const { success, output } = definition.parseLayerField(
|
|
@@ -980,26 +840,474 @@ const layerFieldSetter = (manager, layerKey, fieldKey, currentValue) => (value,
|
|
|
980
840
|
);
|
|
981
841
|
}
|
|
982
842
|
};
|
|
983
|
-
const
|
|
843
|
+
const EMPTY_RESOLVED$1 = {
|
|
844
|
+
layerKey: null,
|
|
845
|
+
rawLayer: null,
|
|
846
|
+
layer: null,
|
|
847
|
+
isOverride: false
|
|
848
|
+
};
|
|
849
|
+
const useResolvedLayer = (layerKey, options) => {
|
|
850
|
+
const { manager } = react.useContext(FragmentContext);
|
|
851
|
+
const resultManager = (options == null ? void 0 : options.manager) ?? manager;
|
|
852
|
+
const key = core.keyOfEntity(layerKey);
|
|
853
|
+
react$1.useGraph(resultManager, key);
|
|
854
|
+
if (!resultManager || !key) {
|
|
855
|
+
return EMPTY_RESOLVED$1;
|
|
856
|
+
}
|
|
857
|
+
const rawLayer = resultManager.resolve(key);
|
|
858
|
+
const overrider = getOverrider(resultManager, key);
|
|
859
|
+
const layer = definition.getNormalizeLayer(rawLayer, overrider, options == null ? void 0 : options.withFallback);
|
|
860
|
+
let isOverride = false;
|
|
861
|
+
if (!(options == null ? void 0 : options.skipOverrideCheck)) {
|
|
862
|
+
isOverride = !isPartOfPrimary(resultManager, key);
|
|
863
|
+
}
|
|
864
|
+
return { layerKey: key, rawLayer, layer, isOverride };
|
|
865
|
+
};
|
|
866
|
+
function useForceUpdate() {
|
|
867
|
+
return react.useReducer(() => ({}), {});
|
|
868
|
+
}
|
|
869
|
+
const EMPTY_RESOLVED = {
|
|
870
|
+
values: {},
|
|
871
|
+
cssVariableValues: {},
|
|
872
|
+
rawValues: {}
|
|
873
|
+
};
|
|
874
|
+
const extractVariableValue$1 = (input, variableId) => {
|
|
875
|
+
if (utils.isObject(input)) {
|
|
876
|
+
if (variableId in input) return input[variableId];
|
|
877
|
+
for (const key in input) {
|
|
878
|
+
if (input.hasOwnProperty(key)) {
|
|
879
|
+
const result = extractVariableValue$1(input[key], variableId);
|
|
880
|
+
if (result !== void 0) return result;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return void 0;
|
|
885
|
+
};
|
|
886
|
+
function deepMerge$1(a, b) {
|
|
887
|
+
if (!utils.isObject(a) || !utils.isObject(b)) return a;
|
|
888
|
+
const result = { ...b };
|
|
889
|
+
for (const [key, value] of Object.entries(a)) {
|
|
890
|
+
if (key in result && typeof result[key] === "object" && typeof value === "object") {
|
|
891
|
+
result[key] = deepMerge$1(value, result[key]);
|
|
892
|
+
} else {
|
|
893
|
+
result[key] = value;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
return result;
|
|
897
|
+
}
|
|
898
|
+
const useResolvedLayerVariables = (layer, rawLayer, customScopes) => {
|
|
984
899
|
var _a;
|
|
985
|
-
const
|
|
986
|
-
const
|
|
987
|
-
const
|
|
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();
|
|
910
|
+
};
|
|
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
|
+
});
|
|
917
|
+
if (!layer) {
|
|
918
|
+
subscriptions.current = [];
|
|
919
|
+
return EMPTY_RESOLVED;
|
|
920
|
+
}
|
|
921
|
+
const values = {};
|
|
922
|
+
const cssVariableValues = {};
|
|
923
|
+
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
|
+
const resolveField = (fieldPath, value, raw) => {
|
|
1023
|
+
var _a2;
|
|
1024
|
+
rawValues[fieldPath] = raw;
|
|
1025
|
+
if (definition.isVariableLink(value)) {
|
|
1026
|
+
const resolved = readVariable(value);
|
|
1027
|
+
values[fieldPath] = resolved.value ?? value;
|
|
1028
|
+
const variableId = (_a2 = core.entityOfKey(value)) == null ? void 0 : _a2._id;
|
|
1029
|
+
cssVariableValues[fieldPath] = `var(--${variableId}, ${transformCssValue(
|
|
1030
|
+
resolved.value ?? value
|
|
1031
|
+
)})`;
|
|
1032
|
+
} else {
|
|
1033
|
+
values[fieldPath] = value;
|
|
1034
|
+
cssVariableValues[fieldPath] = transformCssValue(value);
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
subscriptions.current = [];
|
|
1038
|
+
for (const [field, value] of Object.entries(layer)) {
|
|
1039
|
+
resolveField(field, value, rawLayer == null ? void 0 : rawLayer[field]);
|
|
1040
|
+
if (utils.isObject(value) && !definition.isVariableLink(value)) {
|
|
1041
|
+
for (const [nestedField, nestedValue] of Object.entries(
|
|
1042
|
+
value
|
|
1043
|
+
)) {
|
|
1044
|
+
resolveField(
|
|
1045
|
+
`${field}.${nestedField}`,
|
|
1046
|
+
nestedValue,
|
|
1047
|
+
(_a = rawLayer == null ? void 0 : rawLayer[field]) == null ? void 0 : _a[nestedField]
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return { values, cssVariableValues, rawValues };
|
|
1053
|
+
};
|
|
1054
|
+
const useRenderTarget = () => {
|
|
1055
|
+
const renderTarget = react.useContext(RenderTargetContext);
|
|
988
1056
|
return {
|
|
989
|
-
|
|
1057
|
+
renderTarget,
|
|
1058
|
+
isCanvas: renderTarget === definition.definition.renderTarget.canvas,
|
|
1059
|
+
isDocument: renderTarget === definition.definition.renderTarget.document
|
|
990
1060
|
};
|
|
991
1061
|
};
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
const { manager } = react.useContext(FragmentContext);
|
|
995
|
-
const
|
|
996
|
-
const
|
|
997
|
-
const
|
|
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);
|
|
998
1238
|
return {
|
|
999
|
-
|
|
1239
|
+
...result,
|
|
1240
|
+
readVariable,
|
|
1241
|
+
_dep: dep
|
|
1000
1242
|
};
|
|
1001
1243
|
};
|
|
1244
|
+
const useLayersValue = (layerKeys, fieldKey, options) => {
|
|
1245
|
+
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1246
|
+
const resultManager = (options == null ? void 0 : options.manager) ?? fragmentManager;
|
|
1247
|
+
if (!resultManager) {
|
|
1248
|
+
return [];
|
|
1249
|
+
}
|
|
1250
|
+
const keys = (layerKeys == null ? void 0 : layerKeys.map(core.keyOfEntity)) ?? [];
|
|
1251
|
+
react$1.useGraphStack(resultManager, keys, {
|
|
1252
|
+
// selector: (data) => (data ? pick(data, fieldKey) : data),
|
|
1253
|
+
});
|
|
1254
|
+
const normalizeLayers = useNormalizeLayers(keys, resultManager, options);
|
|
1255
|
+
const { readVariable } = useReadVariable(null, options == null ? void 0 : options.scopes);
|
|
1256
|
+
return normalizeLayers.map((normalizedLayer) => {
|
|
1257
|
+
var _a, _b;
|
|
1258
|
+
const rawValue = utils.get(normalizedLayer.rawLayer, fieldKey);
|
|
1259
|
+
const layerValue = utils.get(normalizedLayer.layer, fieldKey);
|
|
1260
|
+
const variableValue = (_a = readVariable(layerValue)) == null ? void 0 : _a.value;
|
|
1261
|
+
const currentValue = variableValue ?? layerValue;
|
|
1262
|
+
const isInherit = isInheritField(
|
|
1263
|
+
resultManager,
|
|
1264
|
+
normalizedLayer.layerKey,
|
|
1265
|
+
fieldKey
|
|
1266
|
+
);
|
|
1267
|
+
const isOverride = !isInherit && !isPartOfPrimary(resultManager, normalizedLayer.layerKey);
|
|
1268
|
+
const setter = layerFieldSetter(
|
|
1269
|
+
resultManager,
|
|
1270
|
+
normalizedLayer.layerKey,
|
|
1271
|
+
fieldKey,
|
|
1272
|
+
currentValue
|
|
1273
|
+
);
|
|
1274
|
+
const resetOverride = () => {
|
|
1275
|
+
resultManager.mutate(
|
|
1276
|
+
normalizedLayer.layerKey,
|
|
1277
|
+
(prev) => {
|
|
1278
|
+
const r = utils.omit(prev, fieldKey);
|
|
1279
|
+
return r;
|
|
1280
|
+
},
|
|
1281
|
+
{ replace: true }
|
|
1282
|
+
);
|
|
1283
|
+
};
|
|
1284
|
+
const restore = (fallbackValue) => {
|
|
1285
|
+
var _a2, _b2, _c;
|
|
1286
|
+
const tempValue = ((_c = (_b2 = resultManager.resolve((_a2 = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a2.temp)) == null ? void 0 : _b2[normalizedLayer.layerKey]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
|
|
1287
|
+
return tempValue;
|
|
1288
|
+
};
|
|
1289
|
+
const updateValue = (value, options2) => {
|
|
1290
|
+
setter(value, options2);
|
|
1291
|
+
};
|
|
1292
|
+
const isVariable = definition.isVariableLink(rawValue ?? layerValue);
|
|
1293
|
+
const variableId = isVariable ? (_b = core.entityOfKey(layerValue)) == null ? void 0 : _b._id : null;
|
|
1294
|
+
return [
|
|
1295
|
+
currentValue,
|
|
1296
|
+
updateValue,
|
|
1297
|
+
{
|
|
1298
|
+
isOverride,
|
|
1299
|
+
resetOverride,
|
|
1300
|
+
isVariable,
|
|
1301
|
+
cssVariableValue: isVariable ? `var(--${variableId}, ${transformCssValue(currentValue)})` : transformCssValue(currentValue),
|
|
1302
|
+
rawValue,
|
|
1303
|
+
restore,
|
|
1304
|
+
...resultManager.entityOfKey(normalizedLayer.layerKey)
|
|
1305
|
+
}
|
|
1306
|
+
];
|
|
1307
|
+
});
|
|
1308
|
+
};
|
|
1002
1309
|
const useLayerValue = (layerKey, fieldKey, options) => {
|
|
1310
|
+
var _a;
|
|
1003
1311
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1004
1312
|
const resultManager = (options == null ? void 0 : options.manager) ?? fragmentManager;
|
|
1005
1313
|
if (!resultManager) {
|
|
@@ -1029,8 +1337,8 @@ const useLayerValue = (layerKey, fieldKey, options) => {
|
|
|
1029
1337
|
}, [updateLayerData]);
|
|
1030
1338
|
const restore = react.useCallback(
|
|
1031
1339
|
(fallbackValue) => {
|
|
1032
|
-
var
|
|
1033
|
-
const tempValue = ((_c = (_b = resultManager.resolve((
|
|
1340
|
+
var _a2, _b, _c;
|
|
1341
|
+
const tempValue = ((_c = (_b = resultManager.resolve((_a2 = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a2.temp)) == null ? void 0 : _b[key]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
|
|
1034
1342
|
updateLayerData({ [fieldKey]: tempValue });
|
|
1035
1343
|
return tempValue;
|
|
1036
1344
|
},
|
|
@@ -1042,27 +1350,123 @@ const useLayerValue = (layerKey, fieldKey, options) => {
|
|
|
1042
1350
|
},
|
|
1043
1351
|
[setter]
|
|
1044
1352
|
);
|
|
1045
|
-
const
|
|
1353
|
+
const isVariable = definition.isVariableLink(rawValue ?? layerValue);
|
|
1354
|
+
const variableId = isVariable ? (_a = core.entityOfKey(layerValue)) == null ? void 0 : _a._id : null;
|
|
1046
1355
|
return [
|
|
1047
1356
|
currentValue,
|
|
1048
1357
|
updateValue,
|
|
1049
1358
|
{
|
|
1050
1359
|
isOverride,
|
|
1051
1360
|
resetOverride,
|
|
1052
|
-
isVariable
|
|
1053
|
-
cssVariableValue:
|
|
1361
|
+
isVariable,
|
|
1362
|
+
cssVariableValue: isVariable ? `var(--${variableId}, ${transformCssValue(currentValue)})` : transformCssValue(currentValue),
|
|
1054
1363
|
rawValue,
|
|
1055
1364
|
restore,
|
|
1056
1365
|
...resultManager.entityOfKey(key)
|
|
1057
1366
|
}
|
|
1058
1367
|
];
|
|
1059
1368
|
};
|
|
1369
|
+
const useLayerChildren = (layerKey, customManager) => {
|
|
1370
|
+
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1371
|
+
const [layerData] = react$1.useGraph(customManager ?? fragmentManager, layerKey, {
|
|
1372
|
+
selector: (data) => utils.pick(data, "children")
|
|
1373
|
+
});
|
|
1374
|
+
return (layerData == null ? void 0 : layerData.children) ?? [];
|
|
1375
|
+
};
|
|
1376
|
+
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
1377
|
+
var _a, _b, _c, _d;
|
|
1378
|
+
if (!fragmentManager || !layerKey) return [];
|
|
1379
|
+
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
1380
|
+
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
1381
|
+
layerParents.forEach((parent) => {
|
|
1382
|
+
var _a2, _b2, _c2, _d2;
|
|
1383
|
+
const parentLink = core.keyOfEntity(parent);
|
|
1384
|
+
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
1385
|
+
resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
|
|
1389
|
+
if (areaScope) {
|
|
1390
|
+
resultScopes.push(areaScope);
|
|
1391
|
+
}
|
|
1392
|
+
return resultScopes;
|
|
1393
|
+
};
|
|
1394
|
+
const useLayerLink = (layerKey) => {
|
|
1395
|
+
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1396
|
+
const [link] = useLayerValue(layerKey, "link", fragmentManager);
|
|
1397
|
+
const [href] = useLayerValue(link, "href", fragmentManager);
|
|
1398
|
+
const [isNewTab] = useLayerValue(link, "isNewTab", fragmentManager);
|
|
1399
|
+
const isLink2 = utils.isValue(href) && typeof href === "string" && !!(href == null ? void 0 : href.length);
|
|
1400
|
+
const linkTarget = isNewTab ? "_blank" : "";
|
|
1401
|
+
const linkProps = react.useMemo(() => {
|
|
1402
|
+
if (isLink2) {
|
|
1403
|
+
return {
|
|
1404
|
+
target: linkTarget,
|
|
1405
|
+
href
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
return {};
|
|
1409
|
+
}, [linkTarget, href, isLink2]);
|
|
1410
|
+
return {
|
|
1411
|
+
isLink: isLink2,
|
|
1412
|
+
linkHref: href,
|
|
1413
|
+
linkTarget,
|
|
1414
|
+
linkProps
|
|
1415
|
+
};
|
|
1416
|
+
};
|
|
1417
|
+
const useLayerVariableValue = (layerKey, fieldKey, manager) => {
|
|
1418
|
+
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1419
|
+
const resultManager = manager ?? fragmentManager;
|
|
1420
|
+
const [layerValue, updateValue, layerInfo] = useLayerValue(
|
|
1421
|
+
layerKey,
|
|
1422
|
+
fieldKey,
|
|
1423
|
+
resultManager
|
|
1424
|
+
);
|
|
1425
|
+
const { value: instanceValue } = useReadVariable(
|
|
1426
|
+
(layerInfo == null ? void 0 : layerInfo.isVariable) ? layerValue : null
|
|
1427
|
+
);
|
|
1428
|
+
return [
|
|
1429
|
+
(layerInfo == null ? void 0 : layerInfo.isVariable) ? instanceValue : layerValue,
|
|
1430
|
+
updateValue,
|
|
1431
|
+
{
|
|
1432
|
+
...layerInfo,
|
|
1433
|
+
rawValue: layerValue
|
|
1434
|
+
}
|
|
1435
|
+
];
|
|
1436
|
+
};
|
|
1437
|
+
const useLayerLinearGradient = (linearGradientLink) => {
|
|
1438
|
+
const [stops] = useLayerValue(linearGradientLink, "stops");
|
|
1439
|
+
const [angle] = useLayerValue(linearGradientLink, "angle");
|
|
1440
|
+
const stopsValue = useLayersValue(stops, "value");
|
|
1441
|
+
const stopsPosition = useLayersValue(stops, "position");
|
|
1442
|
+
const stopValues = react.useMemo(
|
|
1443
|
+
() => (stops == null ? void 0 : stops.flatMap((stop, index) => {
|
|
1444
|
+
var _a, _b, _c;
|
|
1445
|
+
return [
|
|
1446
|
+
(_b = (_a = stopsValue == null ? void 0 : stopsValue.at(index)) == null ? void 0 : _a.at(2)) == null ? void 0 : _b.cssVariableValue,
|
|
1447
|
+
(_c = stopsPosition == null ? void 0 : stopsPosition.at(index)) == null ? void 0 : _c.at(0)
|
|
1448
|
+
];
|
|
1449
|
+
})) ?? [],
|
|
1450
|
+
[stops, stopsValue, stopsPosition]
|
|
1451
|
+
);
|
|
1452
|
+
return react.useMemo(
|
|
1453
|
+
() => ({
|
|
1454
|
+
"background-image": calcLinearGradient(angle, stopValues)
|
|
1455
|
+
}),
|
|
1456
|
+
[angle, stopValues]
|
|
1457
|
+
);
|
|
1458
|
+
};
|
|
1060
1459
|
const processOptionalSize = (value, type) => {
|
|
1061
1460
|
if (value === -1) return "";
|
|
1062
1461
|
if (type === definition.definition.sizing.Fixed) return utils.toPx(value);
|
|
1063
1462
|
if (type === definition.definition.sizing.Relative) return `${value}%`;
|
|
1064
1463
|
return "";
|
|
1065
1464
|
};
|
|
1465
|
+
const calcOptionalSize = (type, vars) => {
|
|
1466
|
+
const value = vars.values[type];
|
|
1467
|
+
const valueType = vars.values[`${type}Type`];
|
|
1468
|
+
return processOptionalSize(value, valueType);
|
|
1469
|
+
};
|
|
1066
1470
|
const useOptionalSize = (type, layerKey) => {
|
|
1067
1471
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1068
1472
|
const [value] = useLayerValue(layerKey, type, fragmentManager);
|
|
@@ -1072,6 +1476,14 @@ const useOptionalSize = (type, layerKey) => {
|
|
|
1072
1476
|
[valueType, value]
|
|
1073
1477
|
);
|
|
1074
1478
|
};
|
|
1479
|
+
const calcLayerSize = (vars) => {
|
|
1480
|
+
return {
|
|
1481
|
+
minWidth: calcOptionalSize("minWidth", vars),
|
|
1482
|
+
minHeight: calcOptionalSize("minHeight", vars),
|
|
1483
|
+
maxWidth: calcOptionalSize("maxWidth", vars),
|
|
1484
|
+
maxHeight: calcOptionalSize("maxHeight", vars)
|
|
1485
|
+
};
|
|
1486
|
+
};
|
|
1075
1487
|
const useLayerSize = (layerKey) => {
|
|
1076
1488
|
const { manager } = react.useContext(FragmentContext);
|
|
1077
1489
|
const minWidth = useOptionalSize("minWidth", layerKey);
|
|
@@ -1087,15 +1499,30 @@ const useLayerSize = (layerKey) => {
|
|
|
1087
1499
|
maxHeight
|
|
1088
1500
|
};
|
|
1089
1501
|
};
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1502
|
+
const autoSizes = [definition.definition.sizing.Hug];
|
|
1503
|
+
const calcLayerSizeValue = (resolved, vars, sizeType, parentResolved, instanceVars, context) => {
|
|
1504
|
+
const { isDocument, isTopLevel: isTop, instanceLayerKey } = context;
|
|
1505
|
+
const isPartOfInstance = !!instanceLayerKey;
|
|
1506
|
+
const layerNode = resolved.rawLayer;
|
|
1507
|
+
const instanceType = instanceVars.values[`${sizeType}Type`];
|
|
1508
|
+
const valueType = vars.values[`${sizeType}Type`];
|
|
1509
|
+
const growType = sizeType === "width" ? "horizontalGrow" : "verticalGrow";
|
|
1510
|
+
return (value) => {
|
|
1511
|
+
var _a;
|
|
1512
|
+
if (isTop && isDocument && ((_a = parentResolved.layer) == null ? void 0 : _a[growType]) === definition.definition.fragmentGrowingMode.fill) {
|
|
1513
|
+
return "100%";
|
|
1514
|
+
}
|
|
1515
|
+
if (isTop && isPartOfInstance && !autoSizes.includes(instanceType)) {
|
|
1516
|
+
return "100%";
|
|
1517
|
+
}
|
|
1518
|
+
if (autoSizes.includes(valueType)) {
|
|
1519
|
+
return (layerNode == null ? void 0 : layerNode._type) === definition.definition.nodes.Instance ? "auto" : "fit-content";
|
|
1520
|
+
}
|
|
1521
|
+
if (valueType === definition.definition.sizing.Relative) return `${value}%`;
|
|
1522
|
+
if (valueType === definition.definition.sizing.Fill) return `100%`;
|
|
1523
|
+
return utils.toPx(value);
|
|
1096
1524
|
};
|
|
1097
1525
|
};
|
|
1098
|
-
const autoSizes = [definition.definition.sizing.Hug];
|
|
1099
1526
|
const useLayerSizeValue = (layerKey, sizeType) => {
|
|
1100
1527
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1101
1528
|
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext$1);
|
|
@@ -1150,6 +1577,65 @@ const useLayerSizeValue = (layerKey, sizeType) => {
|
|
|
1150
1577
|
]
|
|
1151
1578
|
);
|
|
1152
1579
|
};
|
|
1580
|
+
const calcLayerPosition = (resolved, vars, parentResolved, instanceResolved, instanceVars, context) => {
|
|
1581
|
+
const { isDocument, isTopLevel: isTop, instanceLayerKey } = context;
|
|
1582
|
+
const width = vars.values.width;
|
|
1583
|
+
const height = vars.values.height;
|
|
1584
|
+
const widthCalc = calcLayerSizeValue(
|
|
1585
|
+
resolved,
|
|
1586
|
+
vars,
|
|
1587
|
+
"width",
|
|
1588
|
+
parentResolved,
|
|
1589
|
+
instanceVars,
|
|
1590
|
+
context
|
|
1591
|
+
);
|
|
1592
|
+
const heightCalc = calcLayerSizeValue(
|
|
1593
|
+
resolved,
|
|
1594
|
+
vars,
|
|
1595
|
+
"height",
|
|
1596
|
+
parentResolved,
|
|
1597
|
+
instanceVars,
|
|
1598
|
+
context
|
|
1599
|
+
);
|
|
1600
|
+
const position = vars.values.position;
|
|
1601
|
+
const centerAnchorX = vars.values.centerAnchorX;
|
|
1602
|
+
const centerAnchorY = vars.values.centerAnchorY;
|
|
1603
|
+
const top = vars.values.top;
|
|
1604
|
+
const left = vars.values.left;
|
|
1605
|
+
const right = vars.values.right;
|
|
1606
|
+
const bottom = vars.values.bottom;
|
|
1607
|
+
const skipPosition = isTop && isDocument || !!instanceLayerKey && isTop;
|
|
1608
|
+
if (isTop && !skipPosition) {
|
|
1609
|
+
return {
|
|
1610
|
+
position: definition.definition.positionType.absolute,
|
|
1611
|
+
top: utils.toPx(top),
|
|
1612
|
+
left: utils.toPx(left),
|
|
1613
|
+
width,
|
|
1614
|
+
height
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
if (position === definition.definition.positionType.relative || skipPosition) {
|
|
1618
|
+
return {
|
|
1619
|
+
position: definition.definition.positionType.relative,
|
|
1620
|
+
width: widthCalc(width),
|
|
1621
|
+
height: heightCalc(height)
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
const hasConstrainX = utils.isFiniteNumber(left) && utils.isFiniteNumber(right);
|
|
1625
|
+
const hasConstrainY = utils.isFiniteNumber(top) && utils.isFiniteNumber(bottom);
|
|
1626
|
+
const hasAnyConstrainX = utils.isFiniteNumber(left) || utils.isFiniteNumber(right);
|
|
1627
|
+
const hasAnyConstrainY = utils.isFiniteNumber(top) || utils.isFiniteNumber(bottom);
|
|
1628
|
+
return {
|
|
1629
|
+
position,
|
|
1630
|
+
left: utils.isFiniteNumber(left) ? utils.toPx(left) : !utils.isFiniteNumber(right) ? `${centerAnchorX * 100}%` : null,
|
|
1631
|
+
top: utils.isFiniteNumber(top) ? utils.toPx(top) : !utils.isFiniteNumber(bottom) ? `${centerAnchorY * 100}%` : null,
|
|
1632
|
+
right: utils.isFiniteNumber(right) ? utils.toPx(right) : null,
|
|
1633
|
+
bottom: utils.isFiniteNumber(bottom) ? utils.toPx(bottom) : null,
|
|
1634
|
+
width: hasConstrainX ? null : widthCalc(width),
|
|
1635
|
+
height: hasConstrainY ? null : heightCalc(height),
|
|
1636
|
+
transform: !hasAnyConstrainX || !hasAnyConstrainY ? `translate3d(${!hasAnyConstrainX ? "-50%" : 0}, ${!hasAnyConstrainY ? "-50%" : 0}, 0px)` : null
|
|
1637
|
+
};
|
|
1638
|
+
};
|
|
1153
1639
|
const useLayerPosition = (layerKey) => {
|
|
1154
1640
|
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext$1);
|
|
1155
1641
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
@@ -1198,6 +1684,14 @@ const useLayerPosition = (layerKey) => {
|
|
|
1198
1684
|
transform: !hasAnyConstrainX || !hasAnyConstrainY ? `translate3d(${!hasAnyConstrainX ? "-50%" : 0}, ${!hasAnyConstrainY ? "-50%" : 0}, 0px)` : null
|
|
1199
1685
|
};
|
|
1200
1686
|
};
|
|
1687
|
+
const calcImagePaint = (imageVars) => {
|
|
1688
|
+
var _a, _b;
|
|
1689
|
+
return {
|
|
1690
|
+
background: imageVars.cssVariableValues.src,
|
|
1691
|
+
backgroundRepeat: "no-repeat",
|
|
1692
|
+
backgroundSize: (_b = (_a = imageVars.values.scale) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a)
|
|
1693
|
+
};
|
|
1694
|
+
};
|
|
1201
1695
|
const useImagePaint = (imageLinkKey) => {
|
|
1202
1696
|
var _a;
|
|
1203
1697
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
@@ -1209,186 +1703,24 @@ const useImagePaint = (imageLinkKey) => {
|
|
|
1209
1703
|
backgroundSize: (_a = scale == null ? void 0 : scale.toLowerCase) == null ? void 0 : _a.call(scale)
|
|
1210
1704
|
};
|
|
1211
1705
|
};
|
|
1212
|
-
const
|
|
1213
|
-
const
|
|
1214
|
-
const
|
|
1215
|
-
const
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
selector: (graph) => graph ? utils.pick(graph, "defaultValue", "required") : graph
|
|
1222
|
-
}
|
|
1223
|
-
);
|
|
1224
|
-
return variableLayers.map((layer) => {
|
|
1225
|
-
const { _id: propertyId } = layer ?? {};
|
|
1226
|
-
const currentValue = (props == null ? void 0 : props[propertyId]) ?? null;
|
|
1227
|
-
const required = (layer == null ? void 0 : layer.required) ?? false;
|
|
1228
|
-
const defaultValue = (layer == null ? void 0 : layer.defaultValue) ?? null;
|
|
1229
|
-
const resultValue = required ? currentValue : currentValue ?? defaultValue;
|
|
1706
|
+
const calcLayerBackground = (paintVars, imageVars, imageSizeVars, linearGradient) => {
|
|
1707
|
+
const fillType = paintVars.values.type;
|
|
1708
|
+
const cssSolidFill = paintVars.cssVariableValues.solid;
|
|
1709
|
+
const cssImageSize = imageSizeVars.cssVariableValues.imageSize;
|
|
1710
|
+
if (fillType === definition.definition.paintMode.Solid) {
|
|
1711
|
+
return { background: cssSolidFill };
|
|
1712
|
+
}
|
|
1713
|
+
if (fillType === definition.definition.paintMode.Image) {
|
|
1714
|
+
const image = calcImagePaint(imageVars);
|
|
1230
1715
|
return {
|
|
1231
|
-
|
|
1232
|
-
|
|
1716
|
+
...image,
|
|
1717
|
+
backgroundSize: cssImageSize ?? image.backgroundSize
|
|
1233
1718
|
};
|
|
1234
|
-
});
|
|
1235
|
-
};
|
|
1236
|
-
const useLayersValue = (layerKeys, fieldKey, options) => {
|
|
1237
|
-
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1238
|
-
const resultManager = (options == null ? void 0 : options.manager) ?? fragmentManager;
|
|
1239
|
-
if (!resultManager) {
|
|
1240
|
-
return [];
|
|
1241
1719
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
// selector: (data) => (data ? pick(data, fieldKey) : data),
|
|
1245
|
-
});
|
|
1246
|
-
const normalizeLayers = useNormalizeLayers(keys, resultManager, options);
|
|
1247
|
-
const { readVariable } = useReadVariable(null, options == null ? void 0 : options.scopes);
|
|
1248
|
-
return normalizeLayers.map((normalizedLayer) => {
|
|
1249
|
-
var _a, _b;
|
|
1250
|
-
const rawValue = utils.get(normalizedLayer.rawLayer, fieldKey);
|
|
1251
|
-
const layerValue = utils.get(normalizedLayer.layer, fieldKey);
|
|
1252
|
-
const variableValue = (_a = readVariable(layerValue)) == null ? void 0 : _a.value;
|
|
1253
|
-
const currentValue = variableValue ?? layerValue;
|
|
1254
|
-
const isInherit = isInheritField(
|
|
1255
|
-
resultManager,
|
|
1256
|
-
normalizedLayer.layerKey,
|
|
1257
|
-
fieldKey
|
|
1258
|
-
);
|
|
1259
|
-
const isOverride = !isInherit && !isPartOfPrimary(resultManager, normalizedLayer.layerKey);
|
|
1260
|
-
const setter = layerFieldSetter(
|
|
1261
|
-
resultManager,
|
|
1262
|
-
normalizedLayer.layerKey,
|
|
1263
|
-
fieldKey,
|
|
1264
|
-
currentValue
|
|
1265
|
-
);
|
|
1266
|
-
const resetOverride = () => {
|
|
1267
|
-
resultManager.mutate(
|
|
1268
|
-
normalizedLayer.layerKey,
|
|
1269
|
-
(prev) => {
|
|
1270
|
-
const r = utils.omit(prev, fieldKey);
|
|
1271
|
-
return r;
|
|
1272
|
-
},
|
|
1273
|
-
{ replace: true }
|
|
1274
|
-
);
|
|
1275
|
-
};
|
|
1276
|
-
const restore = (fallbackValue) => {
|
|
1277
|
-
var _a2, _b2, _c;
|
|
1278
|
-
const tempValue = ((_c = (_b2 = resultManager.resolve((_a2 = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a2.temp)) == null ? void 0 : _b2[normalizedLayer.layerKey]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
|
|
1279
|
-
return tempValue;
|
|
1280
|
-
};
|
|
1281
|
-
const updateValue = (value, options2) => {
|
|
1282
|
-
setter(value, options2);
|
|
1283
|
-
};
|
|
1284
|
-
const cssValue = (_b = getLayerCssVariable(
|
|
1285
|
-
resultManager,
|
|
1286
|
-
rawValue ?? layerValue
|
|
1287
|
-
)) == null ? void 0 : _b.value;
|
|
1288
|
-
return [
|
|
1289
|
-
currentValue,
|
|
1290
|
-
updateValue,
|
|
1291
|
-
{
|
|
1292
|
-
isOverride,
|
|
1293
|
-
resetOverride,
|
|
1294
|
-
isVariable: definition.isVariableLink(rawValue ?? layerValue),
|
|
1295
|
-
cssVariableValue: cssValue ?? currentValue,
|
|
1296
|
-
rawValue,
|
|
1297
|
-
restore,
|
|
1298
|
-
...resultManager.entityOfKey(normalizedLayer.layerKey)
|
|
1299
|
-
}
|
|
1300
|
-
];
|
|
1301
|
-
});
|
|
1302
|
-
};
|
|
1303
|
-
const useLayerChildren = (layerKey, customManager) => {
|
|
1304
|
-
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1305
|
-
const [layerData] = react$1.useGraph(customManager ?? fragmentManager, layerKey, {
|
|
1306
|
-
selector: (data) => utils.pick(data, "children")
|
|
1307
|
-
});
|
|
1308
|
-
return (layerData == null ? void 0 : layerData.children) ?? [];
|
|
1309
|
-
};
|
|
1310
|
-
const useLayerScopes = (fragmentManager, layerKey) => {
|
|
1311
|
-
var _a, _b, _c, _d;
|
|
1312
|
-
if (!fragmentManager || !layerKey) return [];
|
|
1313
|
-
const layerParents = getAllParents(fragmentManager, layerKey);
|
|
1314
|
-
const resultScopes = [(_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.scopes) == null ? void 0 : _b.get(void 0)];
|
|
1315
|
-
layerParents.forEach((parent) => {
|
|
1316
|
-
var _a2, _b2, _c2, _d2;
|
|
1317
|
-
const parentLink = core.keyOfEntity(parent);
|
|
1318
|
-
if ((_b2 = (_a2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a2.scopes) == null ? void 0 : _b2.has(parentLink)) {
|
|
1319
|
-
resultScopes.push((_d2 = (_c2 = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c2.scopes) == null ? void 0 : _d2.get(parentLink));
|
|
1320
|
-
}
|
|
1321
|
-
});
|
|
1322
|
-
const areaScope = (_d = (_c = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _c.scopes) == null ? void 0 : _d.get("Area");
|
|
1323
|
-
if (areaScope) {
|
|
1324
|
-
resultScopes.push(areaScope);
|
|
1720
|
+
if (fillType === definition.definition.paintMode.LinearGradient) {
|
|
1721
|
+
return linearGradient;
|
|
1325
1722
|
}
|
|
1326
|
-
return
|
|
1327
|
-
};
|
|
1328
|
-
const useLayerLink = (layerKey) => {
|
|
1329
|
-
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1330
|
-
const [link] = useLayerValue(layerKey, "link", fragmentManager);
|
|
1331
|
-
const [href] = useLayerValue(link, "href", fragmentManager);
|
|
1332
|
-
const [isNewTab] = useLayerValue(link, "isNewTab", fragmentManager);
|
|
1333
|
-
const isLink2 = utils.isValue(href) && typeof href === "string" && !!(href == null ? void 0 : href.length);
|
|
1334
|
-
const linkTarget = isNewTab ? "_blank" : "";
|
|
1335
|
-
const linkProps = react.useMemo(() => {
|
|
1336
|
-
if (isLink2) {
|
|
1337
|
-
return {
|
|
1338
|
-
target: linkTarget,
|
|
1339
|
-
href
|
|
1340
|
-
};
|
|
1341
|
-
}
|
|
1342
|
-
return {};
|
|
1343
|
-
}, [linkTarget, href, isLink2]);
|
|
1344
|
-
return {
|
|
1345
|
-
isLink: isLink2,
|
|
1346
|
-
linkHref: href,
|
|
1347
|
-
linkTarget,
|
|
1348
|
-
linkProps
|
|
1349
|
-
};
|
|
1350
|
-
};
|
|
1351
|
-
const useLayerVariableValue = (layerKey, fieldKey, manager) => {
|
|
1352
|
-
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1353
|
-
const resultManager = manager ?? fragmentManager;
|
|
1354
|
-
const [layerValue, updateValue, layerInfo] = useLayerValue(
|
|
1355
|
-
layerKey,
|
|
1356
|
-
fieldKey,
|
|
1357
|
-
resultManager
|
|
1358
|
-
);
|
|
1359
|
-
const { value: instanceValue } = useReadVariable(
|
|
1360
|
-
(layerInfo == null ? void 0 : layerInfo.isVariable) ? layerValue : null
|
|
1361
|
-
);
|
|
1362
|
-
return [
|
|
1363
|
-
(layerInfo == null ? void 0 : layerInfo.isVariable) ? instanceValue : layerValue,
|
|
1364
|
-
updateValue,
|
|
1365
|
-
{
|
|
1366
|
-
...layerInfo,
|
|
1367
|
-
rawValue: layerValue
|
|
1368
|
-
}
|
|
1369
|
-
];
|
|
1370
|
-
};
|
|
1371
|
-
const useLayerLinearGradient = (linearGradientLink) => {
|
|
1372
|
-
const [stops] = useLayerValue(linearGradientLink, "stops");
|
|
1373
|
-
const [angle] = useLayerValue(linearGradientLink, "angle");
|
|
1374
|
-
const stopsValue = useLayersValue(stops, "value");
|
|
1375
|
-
const stopsPosition = useLayersValue(stops, "position");
|
|
1376
|
-
const stopValues = react.useMemo(
|
|
1377
|
-
() => (stops == null ? void 0 : stops.flatMap((stop, index) => {
|
|
1378
|
-
var _a, _b, _c;
|
|
1379
|
-
return [
|
|
1380
|
-
(_b = (_a = stopsValue == null ? void 0 : stopsValue.at(index)) == null ? void 0 : _a.at(2)) == null ? void 0 : _b.cssVariableValue,
|
|
1381
|
-
(_c = stopsPosition == null ? void 0 : stopsPosition.at(index)) == null ? void 0 : _c.at(0)
|
|
1382
|
-
];
|
|
1383
|
-
})) ?? [],
|
|
1384
|
-
[stops, stopsValue, stopsPosition]
|
|
1385
|
-
);
|
|
1386
|
-
return react.useMemo(
|
|
1387
|
-
() => ({
|
|
1388
|
-
"background-image": calcLinearGradient(angle, stopValues)
|
|
1389
|
-
}),
|
|
1390
|
-
[angle, stopValues]
|
|
1391
|
-
);
|
|
1723
|
+
return { background: null };
|
|
1392
1724
|
};
|
|
1393
1725
|
const useLayerBackground = (layerKey) => {
|
|
1394
1726
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
@@ -1431,9 +1763,16 @@ const useLayerBackground = (layerKey) => {
|
|
|
1431
1763
|
cssImageFillOptions.cssVariableValue,
|
|
1432
1764
|
cssSolidFill,
|
|
1433
1765
|
cssImageSize,
|
|
1434
|
-
image
|
|
1766
|
+
image,
|
|
1767
|
+
linearGradient
|
|
1435
1768
|
]);
|
|
1436
1769
|
};
|
|
1770
|
+
const calcLayerDisplay = (vars) => {
|
|
1771
|
+
const layerModeValue = vars.values.layerMode;
|
|
1772
|
+
const visible = vars.values.visible;
|
|
1773
|
+
if (!visible) return "none";
|
|
1774
|
+
return layerModeValue === definition.definition.layerMode.flex ? "flex" : null;
|
|
1775
|
+
};
|
|
1437
1776
|
const useLayerDisplay = (layerKey) => {
|
|
1438
1777
|
const { manager } = react.useContext(FragmentContext);
|
|
1439
1778
|
const [layerModeValue] = useLayerValue(layerKey, "layerMode", manager);
|
|
@@ -1445,6 +1784,15 @@ const useLayerDisplay = (layerKey) => {
|
|
|
1445
1784
|
return layerModeValue === definition.definition.layerMode.flex ? "flex" : null;
|
|
1446
1785
|
}, [layerModeValue, visible]);
|
|
1447
1786
|
};
|
|
1787
|
+
const calcLayerPaint = (paintVars) => {
|
|
1788
|
+
return {
|
|
1789
|
+
type: paintVars.values.type,
|
|
1790
|
+
solid: paintVars.values.solid,
|
|
1791
|
+
solidCssValue: paintVars.cssVariableValues.solid,
|
|
1792
|
+
image: paintVars.values.image,
|
|
1793
|
+
linearGradientLink: paintVars.values.linearGradient
|
|
1794
|
+
};
|
|
1795
|
+
};
|
|
1448
1796
|
const useLayerPaint = (paintLinkKey) => {
|
|
1449
1797
|
const [type] = useLayerValue(paintLinkKey, "type");
|
|
1450
1798
|
const [solid, , solidInfo] = useLayerValue(paintLinkKey, "solid");
|
|
@@ -1458,18 +1806,49 @@ const useLayerPaint = (paintLinkKey) => {
|
|
|
1458
1806
|
linearGradientLink
|
|
1459
1807
|
};
|
|
1460
1808
|
};
|
|
1809
|
+
const calcLayerBorder = (borderVars, borderPaintVars, borderLinearGradient, paintVars, linearGradient) => {
|
|
1810
|
+
const type = borderVars.values.type;
|
|
1811
|
+
const width = borderVars.values.width;
|
|
1812
|
+
const borderPaint = calcLayerPaint(borderPaintVars);
|
|
1813
|
+
const paint = calcLayerPaint(paintVars);
|
|
1814
|
+
if (type === definition.definition.borderType.None) {
|
|
1815
|
+
return { border: null };
|
|
1816
|
+
}
|
|
1817
|
+
if (borderPaint.type === definition.definition.paintMode.LinearGradient) {
|
|
1818
|
+
let background = `linear-gradient(${paint.solid}, ${paint.solid}) padding-box, ${borderLinearGradient == null ? void 0 : borderLinearGradient["background-image"]} border-box`;
|
|
1819
|
+
if (paint.type === definition.definition.paintMode.LinearGradient) {
|
|
1820
|
+
background = `${linearGradient == null ? void 0 : linearGradient["background-image"]} padding-box, ${borderLinearGradient == null ? void 0 : borderLinearGradient["background-image"]} border-box`;
|
|
1821
|
+
}
|
|
1822
|
+
if (paint.type === definition.definition.paintMode.None) {
|
|
1823
|
+
background = `linear-gradient(transparent, transparent) padding-box, ${borderLinearGradient == null ? void 0 : borderLinearGradient["background-image"]} border-box`;
|
|
1824
|
+
}
|
|
1825
|
+
return {
|
|
1826
|
+
...calcBorderSides(
|
|
1827
|
+
type,
|
|
1828
|
+
width,
|
|
1829
|
+
borderPaint.type === definition.definition.paintMode.Solid ? borderPaint.solid : "transparent"
|
|
1830
|
+
),
|
|
1831
|
+
background
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
if (borderPaint.type === definition.definition.paintMode.Solid) {
|
|
1835
|
+
return calcBorderSides(type, width, borderPaint.solidCssValue);
|
|
1836
|
+
}
|
|
1837
|
+
return { border: null };
|
|
1838
|
+
};
|
|
1461
1839
|
const useLayerBorder = (layerKey) => {
|
|
1840
|
+
var _a, _b;
|
|
1462
1841
|
const [borderLinkKey] = useLayerValue(layerKey, "border");
|
|
1463
1842
|
const [type] = useLayerValue(borderLinkKey, "type");
|
|
1464
1843
|
const [width] = useLayerValue(borderLinkKey, "width");
|
|
1465
1844
|
const [borderPaintLink] = useLayerValue(borderLinkKey, "paint");
|
|
1466
1845
|
const borderPaint = useLayerPaint(borderPaintLink);
|
|
1467
|
-
const borderLinearGradient = useLayerLinearGradient(
|
|
1846
|
+
const borderLinearGradient = (_a = useLayerLinearGradient(
|
|
1468
1847
|
borderPaint.linearGradientLink
|
|
1469
|
-
);
|
|
1848
|
+
)) == null ? void 0 : _a["background-image"];
|
|
1470
1849
|
const [paintLinkKey] = useLayerValue(layerKey, "paint");
|
|
1471
1850
|
const paint = useLayerPaint(paintLinkKey);
|
|
1472
|
-
const linearGradient = useLayerLinearGradient(paint.linearGradientLink);
|
|
1851
|
+
const linearGradient = (_b = useLayerLinearGradient(paint.linearGradientLink)) == null ? void 0 : _b["background-image"];
|
|
1473
1852
|
if (type === definition.definition.borderType.None) {
|
|
1474
1853
|
return {
|
|
1475
1854
|
border: null
|
|
@@ -1478,7 +1857,7 @@ const useLayerBorder = (layerKey) => {
|
|
|
1478
1857
|
if (borderPaint.type === definition.definition.paintMode.LinearGradient) {
|
|
1479
1858
|
let background = `linear-gradient(${paint.solid}, ${paint.solid}) padding-box, ${borderLinearGradient} border-box`;
|
|
1480
1859
|
if (paint.type === definition.definition.paintMode.LinearGradient) {
|
|
1481
|
-
background = `${linearGradient
|
|
1860
|
+
background = `${linearGradient} padding-box, ${borderLinearGradient} border-box`;
|
|
1482
1861
|
}
|
|
1483
1862
|
if (paint.type === definition.definition.paintMode.None) {
|
|
1484
1863
|
background = `linear-gradient(transparent, transparent) padding-box, ${borderLinearGradient} border-box`;
|
|
@@ -1497,6 +1876,28 @@ const useLayerBorder = (layerKey) => {
|
|
|
1497
1876
|
}
|
|
1498
1877
|
return { border: null };
|
|
1499
1878
|
};
|
|
1879
|
+
const calcLayerLayout = (vars) => {
|
|
1880
|
+
const layerModeValue = vars.values.layerMode;
|
|
1881
|
+
const layerWrap = vars.values.layerWrap;
|
|
1882
|
+
const layerDistribute = vars.values.layerDistribute;
|
|
1883
|
+
const layerDirectionValue = vars.values.layerDirection;
|
|
1884
|
+
const layerAlign = vars.values.layerAlign;
|
|
1885
|
+
const padding = vars.values.padding;
|
|
1886
|
+
const gap = vars.values.layerGap;
|
|
1887
|
+
const isFlex = layerModeValue === definition.definition.layerMode.flex;
|
|
1888
|
+
const baseFlow = layerDirectionValue === definition.definition.layerDirection.vertical ? "column" : "row";
|
|
1889
|
+
const wrap = isFlex ? layerWrap ? "wrap" : null : null;
|
|
1890
|
+
const flexFlow = [baseFlow, wrap].filter(Boolean).join(" ");
|
|
1891
|
+
return {
|
|
1892
|
+
display: isFlex ? "flex" : null,
|
|
1893
|
+
gap: utils.toPx(gap),
|
|
1894
|
+
flexWrap: isFlex ? layerWrap ? "wrap" : null : null,
|
|
1895
|
+
justifyContent: isFlex ? layerDistribute : null,
|
|
1896
|
+
flexFlow,
|
|
1897
|
+
alignItems: isFlex ? layerAlign : null,
|
|
1898
|
+
padding: isFlex ? padding : null
|
|
1899
|
+
};
|
|
1900
|
+
};
|
|
1500
1901
|
const useLayerLayout = (layerKey) => {
|
|
1501
1902
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1502
1903
|
const [layerModeValue] = useLayerValue(
|
|
@@ -1532,6 +1933,15 @@ const useLayerLayout = (layerKey) => {
|
|
|
1532
1933
|
padding: isFlex ? padding : null
|
|
1533
1934
|
};
|
|
1534
1935
|
};
|
|
1936
|
+
const calcLayerTextStyles = (vars) => {
|
|
1937
|
+
const attributes = vars.values.attributes;
|
|
1938
|
+
const color = vars.values["attributes.color"];
|
|
1939
|
+
const cleanAttributes = utils.omit(attributes, "_id", "_type");
|
|
1940
|
+
return {
|
|
1941
|
+
...cleanAttributes,
|
|
1942
|
+
color
|
|
1943
|
+
};
|
|
1944
|
+
};
|
|
1535
1945
|
const useLayerTextStyles = (layerKey) => {
|
|
1536
1946
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1537
1947
|
const [attributes] = useLayerValue(layerKey, "attributes", fragmentManager);
|
|
@@ -1542,6 +1952,15 @@ const useLayerTextStyles = (layerKey) => {
|
|
|
1542
1952
|
color
|
|
1543
1953
|
};
|
|
1544
1954
|
};
|
|
1955
|
+
const calcLayerFlex = (vars, parentVars) => {
|
|
1956
|
+
const widthType = vars.values.widthType;
|
|
1957
|
+
const heightType = vars.values.heightType;
|
|
1958
|
+
const layerDirectionValue = parentVars.values.layerDirection;
|
|
1959
|
+
const type = layerDirectionValue === definition.definition.layerDirection.horizontal ? widthType : heightType;
|
|
1960
|
+
return {
|
|
1961
|
+
flex: type === definition.definition.sizing.Fill ? "1 0 0" : "0 0 auto"
|
|
1962
|
+
};
|
|
1963
|
+
};
|
|
1545
1964
|
const useLayerFlex = (layerKey) => {
|
|
1546
1965
|
const { manager } = react.useContext(FragmentContext);
|
|
1547
1966
|
const [widthType] = useLayerValue(layerKey, "widthType", manager);
|
|
@@ -1557,48 +1976,121 @@ const useLayerFlex = (layerKey) => {
|
|
|
1557
1976
|
flex: type === definition.definition.sizing.Fill ? "1 0 0" : "0 0 auto"
|
|
1558
1977
|
};
|
|
1559
1978
|
};
|
|
1979
|
+
const SKIP_OVERRIDE = { skipOverrideCheck: true };
|
|
1560
1980
|
const useLayerStyles = (layerKey) => {
|
|
1561
1981
|
try {
|
|
1562
|
-
if (!layerKey)
|
|
1563
|
-
throw new Error("Empty layer key");
|
|
1564
|
-
}
|
|
1982
|
+
if (!layerKey) throw new Error("Empty layer key");
|
|
1565
1983
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
1566
|
-
const
|
|
1567
|
-
const
|
|
1568
|
-
const
|
|
1569
|
-
const
|
|
1570
|
-
const
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
const
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1984
|
+
const { layerKey: instanceLayerKey } = react.useContext(InstanceContext$1);
|
|
1985
|
+
const { isDocument } = useRenderTarget();
|
|
1986
|
+
const resolved = useResolvedLayer(layerKey);
|
|
1987
|
+
const vars = useResolvedLayerVariables(resolved.layer, resolved.rawLayer);
|
|
1988
|
+
const paintResolved = useResolvedLayer(vars.values.paint, SKIP_OVERRIDE);
|
|
1989
|
+
const paintVars = useResolvedLayerVariables(
|
|
1990
|
+
paintResolved.layer,
|
|
1991
|
+
paintResolved.rawLayer
|
|
1992
|
+
);
|
|
1993
|
+
const borderResolved = useResolvedLayer(vars.values.border, SKIP_OVERRIDE);
|
|
1994
|
+
const borderVars = useResolvedLayerVariables(
|
|
1995
|
+
borderResolved.layer,
|
|
1996
|
+
borderResolved.rawLayer
|
|
1997
|
+
);
|
|
1998
|
+
const borderPaintResolved = useResolvedLayer(
|
|
1999
|
+
borderVars.values.paint,
|
|
2000
|
+
SKIP_OVERRIDE
|
|
2001
|
+
);
|
|
2002
|
+
const borderPaintVars = useResolvedLayerVariables(
|
|
2003
|
+
borderPaintResolved.layer,
|
|
2004
|
+
borderPaintResolved.rawLayer
|
|
2005
|
+
);
|
|
2006
|
+
const imageResolved = useResolvedLayer(
|
|
2007
|
+
paintVars.values.image,
|
|
2008
|
+
SKIP_OVERRIDE
|
|
2009
|
+
);
|
|
2010
|
+
const imageVars = useResolvedLayerVariables(
|
|
2011
|
+
imageResolved.layer,
|
|
2012
|
+
imageResolved.rawLayer
|
|
2013
|
+
);
|
|
2014
|
+
const imageSizeLayerKey = definition.isVariableLink(paintVars.rawValues.image) ? paintVars.rawValues.image : layerKey;
|
|
2015
|
+
const imageSizeResolved = useResolvedLayer(
|
|
2016
|
+
imageSizeLayerKey,
|
|
2017
|
+
SKIP_OVERRIDE
|
|
2018
|
+
);
|
|
2019
|
+
const imageSizeVars = useResolvedLayerVariables(
|
|
2020
|
+
imageSizeResolved.layer,
|
|
2021
|
+
imageSizeResolved.rawLayer
|
|
2022
|
+
);
|
|
2023
|
+
const parentLayerKey = core.keyOfEntity(
|
|
2024
|
+
getParent(fragmentManager, layerKey)
|
|
2025
|
+
);
|
|
2026
|
+
const parentResolved = useResolvedLayer(
|
|
2027
|
+
parentLayerKey,
|
|
2028
|
+
SKIP_OVERRIDE
|
|
2029
|
+
);
|
|
2030
|
+
const parentVars = useResolvedLayerVariables(
|
|
2031
|
+
parentResolved.layer,
|
|
2032
|
+
parentResolved.rawLayer
|
|
2033
|
+
);
|
|
2034
|
+
const instanceResolved = useResolvedLayer(
|
|
2035
|
+
instanceLayerKey,
|
|
2036
|
+
SKIP_OVERRIDE
|
|
2037
|
+
);
|
|
2038
|
+
const instanceVars = useResolvedLayerVariables(
|
|
2039
|
+
instanceResolved.layer,
|
|
2040
|
+
instanceResolved.rawLayer
|
|
2041
|
+
);
|
|
2042
|
+
const paint = calcLayerPaint(paintVars);
|
|
2043
|
+
const borderPaint = calcLayerPaint(borderPaintVars);
|
|
2044
|
+
const linearGradient = useLayerLinearGradient(paint.linearGradientLink);
|
|
2045
|
+
const borderLinearGradient = useLayerLinearGradient(
|
|
2046
|
+
borderPaint.linearGradientLink
|
|
2047
|
+
);
|
|
2048
|
+
const context = {
|
|
2049
|
+
isDocument,
|
|
2050
|
+
isTopLevel: isTopLevel(fragmentManager, layerKey),
|
|
2051
|
+
instanceLayerKey
|
|
2052
|
+
};
|
|
2053
|
+
const layerSize = calcLayerSize(vars);
|
|
2054
|
+
const position = calcLayerPosition(
|
|
2055
|
+
resolved,
|
|
2056
|
+
vars,
|
|
2057
|
+
parentResolved,
|
|
2058
|
+
instanceResolved,
|
|
2059
|
+
instanceVars,
|
|
2060
|
+
context
|
|
2061
|
+
);
|
|
2062
|
+
const background = calcLayerBackground(
|
|
2063
|
+
paintVars,
|
|
2064
|
+
imageVars,
|
|
2065
|
+
imageSizeVars,
|
|
2066
|
+
linearGradient
|
|
1580
2067
|
);
|
|
1581
|
-
const
|
|
1582
|
-
const
|
|
1583
|
-
|
|
2068
|
+
const display = calcLayerDisplay(vars);
|
|
2069
|
+
const border = calcLayerBorder(
|
|
2070
|
+
borderVars,
|
|
2071
|
+
borderPaintVars,
|
|
2072
|
+
borderLinearGradient,
|
|
2073
|
+
paintVars,
|
|
2074
|
+
linearGradient
|
|
2075
|
+
);
|
|
2076
|
+
const layout = calcLayerLayout(vars);
|
|
2077
|
+
const textStyles = calcLayerTextStyles(vars);
|
|
2078
|
+
const layerFlex = calcLayerFlex(vars, parentVars);
|
|
1584
2079
|
return {
|
|
1585
|
-
// ...(props ?? {}),
|
|
1586
2080
|
...background,
|
|
1587
2081
|
...border,
|
|
1588
2082
|
...position,
|
|
1589
|
-
opacity,
|
|
1590
|
-
overflow,
|
|
1591
|
-
rotate: utils.isValue(rotate) ? `${rotate}deg` : null,
|
|
1592
|
-
"border-radius": utils.isValue(
|
|
1593
|
-
"white-space": whiteSpace,
|
|
1594
|
-
"z-index": zIndex !== -1 ? zIndex : null,
|
|
2083
|
+
opacity: vars.values.opacity,
|
|
2084
|
+
overflow: vars.values.overflow,
|
|
2085
|
+
rotate: utils.isValue(vars.values.rotate) ? `${vars.values.rotate}deg` : null,
|
|
2086
|
+
"border-radius": utils.isValue(vars.rawValues.borderRadius) ? vars.values.borderRadius : null,
|
|
2087
|
+
"white-space": vars.values.whiteSpace,
|
|
2088
|
+
"z-index": vars.values.zIndex !== -1 ? vars.values.zIndex : null,
|
|
1595
2089
|
...layout,
|
|
1596
2090
|
...layerSize,
|
|
1597
2091
|
...textStyles,
|
|
1598
2092
|
...layerFlex,
|
|
1599
2093
|
display
|
|
1600
|
-
// "user-select": "none",
|
|
1601
|
-
// ...cssOverride,
|
|
1602
2094
|
};
|
|
1603
2095
|
} catch (e) {
|
|
1604
2096
|
return {};
|
|
@@ -1703,6 +2195,34 @@ const useStyleSheet = (manager) => {
|
|
|
1703
2195
|
unmount: ((_b = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _b.unmount) ?? utils.noop
|
|
1704
2196
|
};
|
|
1705
2197
|
};
|
|
2198
|
+
const useGlobalManager = (globalManager) => {
|
|
2199
|
+
var _a, _b;
|
|
2200
|
+
const currentGlobalManager = react.useContext(GlobalManagerContext);
|
|
2201
|
+
const resultManager = globalManager ?? currentGlobalManager;
|
|
2202
|
+
const [fragmentsGraph] = react$1.useGraph(
|
|
2203
|
+
resultManager,
|
|
2204
|
+
(_a = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _a.key
|
|
2205
|
+
);
|
|
2206
|
+
const queryFragmentManager = (id) => {
|
|
2207
|
+
var _a2, _b2;
|
|
2208
|
+
return (_b2 = (_a2 = resultManager == null ? void 0 : resultManager.$load) == null ? void 0 : _a2.loadFragment) == null ? void 0 : _b2.call(_a2, id);
|
|
2209
|
+
};
|
|
2210
|
+
const queryArea = (id) => {
|
|
2211
|
+
var _a2, _b2;
|
|
2212
|
+
return (_b2 = (_a2 = resultManager == null ? void 0 : resultManager.$load) == null ? void 0 : _a2.loadArea) == null ? void 0 : _b2.call(_a2, id);
|
|
2213
|
+
};
|
|
2214
|
+
const setRenderTarget = (value) => {
|
|
2215
|
+
resultManager == null ? void 0 : resultManager.setRenderTarget(value);
|
|
2216
|
+
};
|
|
2217
|
+
return {
|
|
2218
|
+
fragmentsGraph,
|
|
2219
|
+
manager: resultManager,
|
|
2220
|
+
queryFragmentManager,
|
|
2221
|
+
queryArea,
|
|
2222
|
+
getFragmentManager: ((_b = resultManager == null ? void 0 : resultManager.$fragments) == null ? void 0 : _b.getManager) ?? utils.noop,
|
|
2223
|
+
setRenderTarget
|
|
2224
|
+
};
|
|
2225
|
+
};
|
|
1706
2226
|
const useLayerInteractions = (layerKey, options) => {
|
|
1707
2227
|
const pause = (options == null ? void 0 : options.pauseInteractions) ?? false;
|
|
1708
2228
|
const { manager: globalManager } = useGlobalManager();
|
|
@@ -1727,12 +2247,14 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
1727
2247
|
});
|
|
1728
2248
|
const fireEvent = react.useCallback(
|
|
1729
2249
|
(eventLink) => {
|
|
1730
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2250
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1731
2251
|
const eventType = (_a = core.entityOfKey(eventLink)) == null ? void 0 : _a._type;
|
|
1732
2252
|
const eventValue = (_b = getNormalizeLayer(eventLink, fragmentManager)) == null ? void 0 : _b.layer;
|
|
2253
|
+
console.log(scopes, eventLink, eventType, eventValue);
|
|
1733
2254
|
if (eventType === definition.definition.nodes.GoalEvent && (eventValue == null ? void 0 : eventValue.goalId)) {
|
|
1734
2255
|
if (!areaScope) return null;
|
|
1735
|
-
(
|
|
2256
|
+
console.log((_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.reachGoal);
|
|
2257
|
+
(_e = (_d = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _d.reachGoal) == null ? void 0 : _e.call(_d, {
|
|
1736
2258
|
goalId: eventValue == null ? void 0 : eventValue.goalId,
|
|
1737
2259
|
...utils.pick(areaScope, "variantId", "campaignId", "areaId")
|
|
1738
2260
|
});
|
|
@@ -1740,10 +2262,10 @@ const useLayerInteractions = (layerKey, options) => {
|
|
|
1740
2262
|
if (eventType === definition.definition.nodes.MutateEvent) {
|
|
1741
2263
|
const target = eventValue == null ? void 0 : eventValue.target;
|
|
1742
2264
|
const targetLayer = getNormalizeLayer(target, fragmentManager);
|
|
1743
|
-
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((
|
|
2265
|
+
const value = (eventValue == null ? void 0 : eventValue.value) ?? ((_f = targetLayer == null ? void 0 : targetLayer.layer) == null ? void 0 : _f.defaultValue);
|
|
1744
2266
|
if (definition.isVariableLink(target) && utils.isValue(value)) {
|
|
1745
|
-
const targetId = (
|
|
1746
|
-
(
|
|
2267
|
+
const targetId = (_g = core.entityOfKey(target)) == null ? void 0 : _g._id;
|
|
2268
|
+
(_h = instanceScope == null ? void 0 : instanceScope.onChangeProps) == null ? void 0 : _h.call(instanceScope, targetId, value);
|
|
1747
2269
|
}
|
|
1748
2270
|
}
|
|
1749
2271
|
},
|
|
@@ -1950,41 +2472,250 @@ const useCollection = (layerKey, options) => {
|
|
|
1950
2472
|
...frame
|
|
1951
2473
|
};
|
|
1952
2474
|
};
|
|
1953
|
-
const
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2475
|
+
const resolveFieldRef = (field, manager) => {
|
|
2476
|
+
if (definition.isVariableLink(field)) {
|
|
2477
|
+
return manager.resolve(field);
|
|
2478
|
+
}
|
|
2479
|
+
if (utils.isObject(field) && (field == null ? void 0 : field._id)) {
|
|
2480
|
+
return field;
|
|
2481
|
+
}
|
|
2482
|
+
return void 0;
|
|
2483
|
+
};
|
|
2484
|
+
const fieldRefToKey = (field) => {
|
|
2485
|
+
if (definition.isVariableLink(field)) {
|
|
2486
|
+
return field;
|
|
2487
|
+
}
|
|
2488
|
+
if (utils.isObject(field) && (field == null ? void 0 : field._type) && (field == null ? void 0 : field._id)) {
|
|
2489
|
+
return core.keyOfEntity(field);
|
|
2490
|
+
}
|
|
2491
|
+
return void 0;
|
|
2492
|
+
};
|
|
2493
|
+
const collectLeafKeys = (defVar, manager, keys) => {
|
|
2494
|
+
if (!(defVar == null ? void 0 : defVar.fields)) return;
|
|
2495
|
+
const fields = utils.cleanGraph(defVar.fields);
|
|
2496
|
+
for (const fieldRef of Object.values(fields)) {
|
|
2497
|
+
const fieldVar = resolveFieldRef(fieldRef, manager);
|
|
2498
|
+
const fieldKey = fieldRefToKey(fieldRef);
|
|
2499
|
+
if (!fieldVar || !fieldKey) continue;
|
|
2500
|
+
if (fieldVar.type === definition.definition.variableType.Object && fieldVar.fields) {
|
|
2501
|
+
collectLeafKeys(fieldVar, manager, keys);
|
|
2502
|
+
} else {
|
|
2503
|
+
keys.push(fieldKey);
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
};
|
|
2507
|
+
const flattenObjectFields = (defVar, valueObj, manager, result) => {
|
|
2508
|
+
if (!(defVar == null ? void 0 : defVar.fields)) return;
|
|
2509
|
+
const fields = utils.cleanGraph(defVar.fields);
|
|
2510
|
+
for (const [fieldName, fieldRef] of Object.entries(fields)) {
|
|
2511
|
+
const fieldVar = resolveFieldRef(fieldRef, manager);
|
|
2512
|
+
if (!(fieldVar == null ? void 0 : fieldVar._id)) continue;
|
|
2513
|
+
const fieldValue = valueObj[fieldName] ?? valueObj[fieldVar._id];
|
|
2514
|
+
if (fieldValue === void 0) continue;
|
|
2515
|
+
if (fieldVar.type === definition.definition.variableType.Object && fieldVar.fields && utils.isObject(fieldValue)) {
|
|
2516
|
+
flattenObjectFields(
|
|
2517
|
+
fieldVar,
|
|
2518
|
+
fieldValue,
|
|
2519
|
+
manager,
|
|
2520
|
+
result
|
|
2521
|
+
);
|
|
2522
|
+
} else {
|
|
2523
|
+
result[fieldVar._id] = fieldValue;
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
};
|
|
2527
|
+
const buildFieldIdMapping = (childDef, parentDef, childManager, parentManager) => {
|
|
2528
|
+
const mapping = {};
|
|
2529
|
+
if (!(childDef == null ? void 0 : childDef.fields) || !(parentDef == null ? void 0 : parentDef.fields)) return mapping;
|
|
2530
|
+
const childFields = utils.cleanGraph(childDef.fields);
|
|
2531
|
+
const parentFields = utils.cleanGraph(parentDef.fields);
|
|
2532
|
+
for (const [fieldName, childFieldRef] of Object.entries(childFields)) {
|
|
2533
|
+
const parentFieldRef = parentFields[fieldName];
|
|
2534
|
+
if (!parentFieldRef) continue;
|
|
2535
|
+
const childFieldVar = resolveFieldRef(childFieldRef, childManager);
|
|
2536
|
+
if (!(childFieldVar == null ? void 0 : childFieldVar._id)) continue;
|
|
2537
|
+
const parentFieldVar = resolveFieldRef(parentFieldRef, parentManager);
|
|
2538
|
+
if (!(parentFieldVar == null ? void 0 : parentFieldVar._id)) continue;
|
|
2539
|
+
if (childFieldVar.type === definition.definition.variableType.Object && childFieldVar.fields && (parentFieldVar == null ? void 0 : parentFieldVar.type) === definition.definition.variableType.Object && (parentFieldVar == null ? void 0 : parentFieldVar.fields)) {
|
|
2540
|
+
Object.assign(
|
|
2541
|
+
mapping,
|
|
2542
|
+
buildFieldIdMapping(
|
|
2543
|
+
childFieldVar,
|
|
2544
|
+
parentFieldVar,
|
|
2545
|
+
childManager,
|
|
2546
|
+
parentManager
|
|
2547
|
+
)
|
|
2548
|
+
);
|
|
2549
|
+
continue;
|
|
2550
|
+
}
|
|
2551
|
+
mapping[parentFieldVar._id] = childFieldVar._id;
|
|
2552
|
+
}
|
|
2553
|
+
return mapping;
|
|
2554
|
+
};
|
|
2555
|
+
const resolveArrayItems = (items, manager) => {
|
|
2556
|
+
const result = [];
|
|
2557
|
+
for (const item of items) {
|
|
2558
|
+
if (definition.isLink(item)) {
|
|
2559
|
+
const resolved = manager.resolve(item);
|
|
2560
|
+
if (!resolved) continue;
|
|
2561
|
+
const payload = utils.isObject(resolved.value) ? resolved.value : resolved;
|
|
2562
|
+
if (utils.isObject(payload)) {
|
|
2563
|
+
result.push(utils.cleanGraph(payload));
|
|
1969
2564
|
}
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
...definitionProps
|
|
2565
|
+
} else if (utils.isObject(item)) {
|
|
2566
|
+
const payload = utils.isObject(item.value) ? item.value : item;
|
|
2567
|
+
result.push(utils.cleanGraph(payload));
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
return result;
|
|
2571
|
+
};
|
|
2572
|
+
const remapArrayItems = (items, mapping) => {
|
|
2573
|
+
return items.map((item) => {
|
|
2574
|
+
const remapped = {};
|
|
2575
|
+
for (const [key, value] of Object.entries(item)) {
|
|
2576
|
+
const newKey = mapping[key] ?? key;
|
|
2577
|
+
remapped[newKey] = value;
|
|
2578
|
+
}
|
|
2579
|
+
return remapped;
|
|
1986
2580
|
});
|
|
1987
2581
|
};
|
|
2582
|
+
const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
2583
|
+
const { readVariable, _dep } = useReadVariable();
|
|
2584
|
+
const leafKeys = react.useMemo(() => {
|
|
2585
|
+
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
2586
|
+
const keys = [];
|
|
2587
|
+
for (const defKey of definitions) {
|
|
2588
|
+
const defVar = manager.resolve(defKey);
|
|
2589
|
+
if (!defVar) continue;
|
|
2590
|
+
if (defVar.type === definition.definition.variableType.Object && defVar.fields) {
|
|
2591
|
+
collectLeafKeys(defVar, manager, keys);
|
|
2592
|
+
} else if (defVar.type === definition.definition.variableType.Array && defVar.definition) {
|
|
2593
|
+
const arrDef = resolveFieldRef(defVar.definition, manager);
|
|
2594
|
+
if ((arrDef == null ? void 0 : arrDef.type) === definition.definition.variableType.Object && (arrDef == null ? void 0 : arrDef.fields)) {
|
|
2595
|
+
collectLeafKeys(arrDef, manager, keys);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
return keys;
|
|
2600
|
+
}, [definitions, manager]);
|
|
2601
|
+
const leafLayers = react$1.useGraphStack(leafKeys.length ? manager : null, leafKeys);
|
|
2602
|
+
const arrayItemKeys = react.useMemo(() => {
|
|
2603
|
+
var _a;
|
|
2604
|
+
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
2605
|
+
const resolveManager = parentManager ?? manager;
|
|
2606
|
+
if (!resolveManager) return [];
|
|
2607
|
+
const keys = [];
|
|
2608
|
+
for (const defKey of definitions) {
|
|
2609
|
+
const defVar = manager.resolve(defKey);
|
|
2610
|
+
if (!(defVar == null ? void 0 : defVar._id)) continue;
|
|
2611
|
+
if (defVar.type !== definition.definition.variableType.Array || !defVar.definition)
|
|
2612
|
+
continue;
|
|
2613
|
+
const propValue = props[defVar._id];
|
|
2614
|
+
if (!definition.isVariableLink(propValue)) continue;
|
|
2615
|
+
const parentVar = resolveManager.resolve(propValue);
|
|
2616
|
+
if ((parentVar == null ? void 0 : parentVar.type) !== definition.definition.variableType.Array) continue;
|
|
2617
|
+
const items = parentVar.defaultValue;
|
|
2618
|
+
if (!Array.isArray(items)) continue;
|
|
2619
|
+
for (const item of items) {
|
|
2620
|
+
if (definition.isLink(item)) {
|
|
2621
|
+
keys.push(item);
|
|
2622
|
+
const resolved = resolveManager.resolve(item);
|
|
2623
|
+
if ((resolved == null ? void 0 : resolved.value) && utils.isObject(resolved.value) && ((_a = resolved.value) == null ? void 0 : _a._type)) {
|
|
2624
|
+
const valueKey = core.keyOfEntity(resolved.value);
|
|
2625
|
+
if (valueKey) keys.push(valueKey);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
return keys;
|
|
2631
|
+
}, [definitions, manager, parentManager, props, _dep]);
|
|
2632
|
+
const arrayItemLayers = react$1.useGraphStack(
|
|
2633
|
+
arrayItemKeys.length ? parentManager ?? manager : null,
|
|
2634
|
+
arrayItemKeys
|
|
2635
|
+
);
|
|
2636
|
+
return react.useMemo(() => {
|
|
2637
|
+
if (!manager || !(definitions == null ? void 0 : definitions.length)) return props;
|
|
2638
|
+
const resolveManager = parentManager ?? manager;
|
|
2639
|
+
const base = {};
|
|
2640
|
+
for (const layer of leafLayers) {
|
|
2641
|
+
if ((layer == null ? void 0 : layer._id) && (layer == null ? void 0 : layer.defaultValue) != null) {
|
|
2642
|
+
base[layer._id] = layer.defaultValue;
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
const expanded = {};
|
|
2646
|
+
const handledPropKeys = /* @__PURE__ */ new Set();
|
|
2647
|
+
for (const defKey of definitions) {
|
|
2648
|
+
const defVar = manager.resolve(defKey);
|
|
2649
|
+
if (!(defVar == null ? void 0 : defVar._id)) continue;
|
|
2650
|
+
const propValue = props[defVar._id];
|
|
2651
|
+
handledPropKeys.add(defVar._id);
|
|
2652
|
+
if (propValue === void 0) continue;
|
|
2653
|
+
if (defVar.type === definition.definition.variableType.Object && defVar.fields) {
|
|
2654
|
+
if (utils.isObject(propValue)) {
|
|
2655
|
+
flattenObjectFields(
|
|
2656
|
+
defVar,
|
|
2657
|
+
propValue,
|
|
2658
|
+
manager,
|
|
2659
|
+
expanded
|
|
2660
|
+
);
|
|
2661
|
+
continue;
|
|
2662
|
+
}
|
|
2663
|
+
expanded[defVar._id] = propValue;
|
|
2664
|
+
continue;
|
|
2665
|
+
}
|
|
2666
|
+
if (defVar.type === definition.definition.variableType.Array && defVar.definition) {
|
|
2667
|
+
if (definition.isVariableLink(propValue) && resolveManager) {
|
|
2668
|
+
const parentVar = resolveManager.resolve(propValue);
|
|
2669
|
+
if ((parentVar == null ? void 0 : parentVar.type) === definition.definition.variableType.Array && (parentVar == null ? void 0 : parentVar.definition)) {
|
|
2670
|
+
const { value: resolvedArray } = readVariable(propValue);
|
|
2671
|
+
if (Array.isArray(resolvedArray)) {
|
|
2672
|
+
const concreteItems = resolveArrayItems(
|
|
2673
|
+
resolvedArray,
|
|
2674
|
+
resolveManager
|
|
2675
|
+
);
|
|
2676
|
+
const childDef = resolveFieldRef(defVar.definition, manager);
|
|
2677
|
+
const parentDef = resolveFieldRef(
|
|
2678
|
+
parentVar.definition,
|
|
2679
|
+
resolveManager
|
|
2680
|
+
);
|
|
2681
|
+
if ((childDef == null ? void 0 : childDef.type) === definition.definition.variableType.Object && (childDef == null ? void 0 : childDef.fields) && (parentDef == null ? void 0 : parentDef.type) === definition.definition.variableType.Object && (parentDef == null ? void 0 : parentDef.fields)) {
|
|
2682
|
+
const mapping = buildFieldIdMapping(
|
|
2683
|
+
childDef,
|
|
2684
|
+
parentDef,
|
|
2685
|
+
manager,
|
|
2686
|
+
resolveManager
|
|
2687
|
+
);
|
|
2688
|
+
expanded[defVar._id] = remapArrayItems(concreteItems, mapping);
|
|
2689
|
+
} else {
|
|
2690
|
+
expanded[defVar._id] = concreteItems;
|
|
2691
|
+
}
|
|
2692
|
+
continue;
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
expanded[defVar._id] = propValue;
|
|
2696
|
+
continue;
|
|
2697
|
+
}
|
|
2698
|
+
expanded[defVar._id] = propValue;
|
|
2699
|
+
continue;
|
|
2700
|
+
}
|
|
2701
|
+
expanded[defVar._id] = propValue;
|
|
2702
|
+
}
|
|
2703
|
+
for (const [key, value] of Object.entries(props)) {
|
|
2704
|
+
if (!handledPropKeys.has(key) && !(key in expanded)) {
|
|
2705
|
+
expanded[key] = value;
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
return { ...base, ...expanded };
|
|
2709
|
+
}, [
|
|
2710
|
+
leafLayers,
|
|
2711
|
+
arrayItemLayers,
|
|
2712
|
+
props,
|
|
2713
|
+
manager,
|
|
2714
|
+
parentManager,
|
|
2715
|
+
definitions,
|
|
2716
|
+
_dep
|
|
2717
|
+
]);
|
|
2718
|
+
};
|
|
1988
2719
|
const CollectionItem = ({
|
|
1989
2720
|
layer,
|
|
1990
2721
|
manager,
|
|
@@ -1994,20 +2725,22 @@ const CollectionItem = ({
|
|
|
1994
2725
|
...restProps
|
|
1995
2726
|
}) => {
|
|
1996
2727
|
var _a;
|
|
1997
|
-
|
|
2728
|
+
core.keyOfEntity(layer);
|
|
1998
2729
|
const definitionId = ((_a = core.entityOfKey(sourceDefinition)) == null ? void 0 : _a._id) ?? "";
|
|
1999
2730
|
const value = layer.value ?? layer;
|
|
2000
|
-
const
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2731
|
+
const inputProps = {
|
|
2732
|
+
[definitionId]: value
|
|
2733
|
+
};
|
|
2734
|
+
const props = utils.cleanGraph(inputProps);
|
|
2735
|
+
const definitions = react.useMemo(
|
|
2736
|
+
() => sourceDefinition ? [sourceDefinition] : [],
|
|
2737
|
+
[sourceDefinition]
|
|
2738
|
+
);
|
|
2739
|
+
const expandedProps = useExtractProps(props, manager, void 0, definitions);
|
|
2740
|
+
const cssVars = react.useMemo(
|
|
2741
|
+
() => toCssCustomProperties(expandedProps),
|
|
2742
|
+
[expandedProps]
|
|
2743
|
+
);
|
|
2011
2744
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2012
2745
|
Scope,
|
|
2013
2746
|
{
|
|
@@ -2017,7 +2750,7 @@ const CollectionItem = ({
|
|
|
2017
2750
|
type: definition.definition.scopeTypes.CollectionItemScope,
|
|
2018
2751
|
...restProps,
|
|
2019
2752
|
sourceDefinition,
|
|
2020
|
-
value:
|
|
2753
|
+
value: expandedProps,
|
|
2021
2754
|
manager
|
|
2022
2755
|
},
|
|
2023
2756
|
children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2025,7 +2758,7 @@ const CollectionItem = ({
|
|
|
2025
2758
|
{
|
|
2026
2759
|
style: {
|
|
2027
2760
|
display: "contents",
|
|
2028
|
-
...
|
|
2761
|
+
...cssVars
|
|
2029
2762
|
},
|
|
2030
2763
|
children: /* @__PURE__ */ jsxRuntime.jsx(FrameElement, { ...restProps, layerKey: child })
|
|
2031
2764
|
},
|
|
@@ -2141,24 +2874,18 @@ const Frame = ({
|
|
|
2141
2874
|
}
|
|
2142
2875
|
);
|
|
2143
2876
|
};
|
|
2144
|
-
const useIsomorphicEffect = (callback, deps) => {
|
|
2145
|
-
react.useEffect(callback, deps);
|
|
2146
|
-
if (!utils.isBrowser) {
|
|
2147
|
-
callback();
|
|
2148
|
-
}
|
|
2149
|
-
};
|
|
2150
2877
|
const useCssChunk = (linkKey) => {
|
|
2151
2878
|
const { manager } = react.useContext(FragmentContext);
|
|
2152
2879
|
const [chunkId] = useLayerValue(linkKey, "chunkId", { manager });
|
|
2153
2880
|
const [enabled] = useLayerValue(linkKey, "enabled", { manager });
|
|
2154
|
-
const
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
}, [enabled]);
|
|
2881
|
+
const { addCssChunk } = useStyleSheet(manager);
|
|
2882
|
+
react.useEffect(() => {
|
|
2883
|
+
if (!enabled || !chunkId) return;
|
|
2884
|
+
const cleanup = addCssChunk(chunkId);
|
|
2885
|
+
return () => {
|
|
2886
|
+
cleanup();
|
|
2887
|
+
};
|
|
2888
|
+
}, [enabled, chunkId, addCssChunk]);
|
|
2162
2889
|
};
|
|
2163
2890
|
const CssChunk = ({ linkKey }) => {
|
|
2164
2891
|
useCssChunk(linkKey);
|
|
@@ -2172,23 +2899,18 @@ const useFragmentManager = (fragmentId, inputGlobalManager) => {
|
|
|
2172
2899
|
getFragmentManager,
|
|
2173
2900
|
queryFragmentManager
|
|
2174
2901
|
} = useGlobalManager(inputGlobalManager);
|
|
2175
|
-
const [loading, setLoading] = react.useState(false);
|
|
2176
2902
|
const manager = getFragmentManager(fragmentId);
|
|
2903
|
+
const loading = !!fragmentId && !manager;
|
|
2177
2904
|
react.useEffect(() => {
|
|
2178
|
-
(
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
await queryFragmentManager(fragmentId);
|
|
2182
|
-
setLoading(false);
|
|
2183
|
-
}
|
|
2184
|
-
})();
|
|
2905
|
+
if (fragmentsGraph && !getFragmentManager(fragmentId) && !!fragmentId) {
|
|
2906
|
+
queryFragmentManager(fragmentId);
|
|
2907
|
+
}
|
|
2185
2908
|
}, [fragmentId, fragmentsGraph]);
|
|
2186
2909
|
return {
|
|
2187
2910
|
loading,
|
|
2188
2911
|
manager,
|
|
2189
2912
|
fragmentLayerKey: (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root,
|
|
2190
2913
|
queryFragmentManager
|
|
2191
|
-
// loadFragmentManager,
|
|
2192
2914
|
};
|
|
2193
2915
|
};
|
|
2194
2916
|
const useFragmentChildren = (fragmentId) => {
|
|
@@ -2246,7 +2968,7 @@ const useFragment = (fragmentId, globalManager) => {
|
|
|
2246
2968
|
const { properties: definitions } = useFragmentProperties(fragmentId);
|
|
2247
2969
|
const scopes = react.useContext(ScopeContext);
|
|
2248
2970
|
!(scopes == null ? void 0 : scopes.length);
|
|
2249
|
-
const { addLayerStyle,
|
|
2971
|
+
const { addLayerStyle, mount, unmount } = useStyleSheet(
|
|
2250
2972
|
fragmentContext.manager
|
|
2251
2973
|
);
|
|
2252
2974
|
if (fragmentContext.manager) {
|
|
@@ -2281,35 +3003,26 @@ const useFragment = (fragmentId, globalManager) => {
|
|
|
2281
3003
|
definitions
|
|
2282
3004
|
};
|
|
2283
3005
|
};
|
|
2284
|
-
const FragmentInternal = (
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
// fragmentManager={fragmentContext.manager}
|
|
2305
|
-
// layerKey={layerKey}
|
|
2306
|
-
// value={{
|
|
2307
|
-
// type: definition.scopeTypes.FragmentScope,
|
|
2308
|
-
// manager: fragmentContext.manager,
|
|
2309
|
-
// definitions,
|
|
2310
|
-
// }}
|
|
2311
|
-
// >
|
|
2312
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { "data-key": layerKey, className: hash, children: [
|
|
3006
|
+
const FragmentInternal = react.memo(
|
|
3007
|
+
({
|
|
3008
|
+
fragmentId,
|
|
3009
|
+
globalManager,
|
|
3010
|
+
pauseInteractions,
|
|
3011
|
+
collectStyle,
|
|
3012
|
+
FrameElement = Frame
|
|
3013
|
+
}) => {
|
|
3014
|
+
const {
|
|
3015
|
+
children,
|
|
3016
|
+
fragmentContext,
|
|
3017
|
+
hash,
|
|
3018
|
+
chunkLinks,
|
|
3019
|
+
isResize,
|
|
3020
|
+
isTopFragment,
|
|
3021
|
+
definitions,
|
|
3022
|
+
layerKey
|
|
3023
|
+
} = useFragment(fragmentId);
|
|
3024
|
+
if (!fragmentContext.manager) return null;
|
|
3025
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-key": layerKey, className: hash, children: [
|
|
2313
3026
|
chunkLinks.map((linkKey) => /* @__PURE__ */ jsxRuntime.jsx(CssChunk, { linkKey })),
|
|
2314
3027
|
children.map((childLink) => {
|
|
2315
3028
|
var _a;
|
|
@@ -2327,29 +3040,57 @@ const FragmentInternal = ({
|
|
|
2327
3040
|
childLink
|
|
2328
3041
|
);
|
|
2329
3042
|
})
|
|
2330
|
-
] })
|
|
2331
|
-
|
|
2332
|
-
|
|
3043
|
+
] });
|
|
3044
|
+
}
|
|
3045
|
+
);
|
|
2333
3046
|
const Fragment = (props) => {
|
|
2334
3047
|
const currentGlobalManager = react.useContext(GlobalManagerContext);
|
|
2335
3048
|
const { manager: resultGlobalManager } = useGlobalManager(
|
|
2336
3049
|
props.globalManager
|
|
2337
3050
|
);
|
|
2338
3051
|
const { manager } = useFragmentManager(props.fragmentId, resultGlobalManager);
|
|
2339
|
-
const
|
|
3052
|
+
const fragmentContextValue = react.useMemo(() => ({ manager }), [manager]);
|
|
3053
|
+
const Base = /* @__PURE__ */ jsxRuntime.jsx(FragmentContext.Provider, { value: fragmentContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(FragmentInternal, { ...props }) });
|
|
2340
3054
|
if (!currentGlobalManager) {
|
|
2341
3055
|
return /* @__PURE__ */ jsxRuntime.jsx(GlobalManagerProvider, { value: resultGlobalManager, children: Base });
|
|
2342
3056
|
}
|
|
2343
3057
|
return Base;
|
|
2344
3058
|
};
|
|
3059
|
+
const resolveObjectToConcreteValue = (objectVar, manager, readVariable) => {
|
|
3060
|
+
const fields = utils.cleanGraph(objectVar.fields);
|
|
3061
|
+
const result = {};
|
|
3062
|
+
for (const [fieldName, fieldRef] of Object.entries(fields)) {
|
|
3063
|
+
let fieldVar;
|
|
3064
|
+
let fieldKey;
|
|
3065
|
+
if (definition.isVariableLink(fieldRef)) {
|
|
3066
|
+
fieldKey = fieldRef;
|
|
3067
|
+
fieldVar = manager == null ? void 0 : manager.resolve(fieldKey);
|
|
3068
|
+
} else if (utils.isObject(fieldRef) && (fieldRef == null ? void 0 : fieldRef._id)) {
|
|
3069
|
+
fieldKey = core.keyOfEntity(fieldRef);
|
|
3070
|
+
fieldVar = fieldRef;
|
|
3071
|
+
}
|
|
3072
|
+
if (!fieldVar || !fieldKey) continue;
|
|
3073
|
+
if (fieldVar.type === definition.definition.variableType.Object && fieldVar.fields) {
|
|
3074
|
+
result[fieldName] = resolveObjectToConcreteValue(
|
|
3075
|
+
fieldVar,
|
|
3076
|
+
manager,
|
|
3077
|
+
readVariable
|
|
3078
|
+
);
|
|
3079
|
+
} else {
|
|
3080
|
+
const { value } = readVariable(fieldKey);
|
|
3081
|
+
if (value != null) {
|
|
3082
|
+
result[fieldName] = value;
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
return result;
|
|
3087
|
+
};
|
|
2345
3088
|
const useInstanceProps = (instanceProps) => {
|
|
2346
3089
|
const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
|
|
2347
3090
|
const { manager: loadedManager } = useFragmentManager(
|
|
2348
3091
|
isTopInstance ? instanceProps == null ? void 0 : instanceProps.fragmentId : null
|
|
2349
3092
|
);
|
|
2350
3093
|
const { manager: fragmentContextManager } = react.useContext(FragmentContext);
|
|
2351
|
-
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(instanceProps == null ? void 0 : instanceProps.fragmentId);
|
|
2352
|
-
const { readVariable } = useReadVariable();
|
|
2353
3094
|
const fragmentManager = isTopInstance ? loadedManager : fragmentContextManager;
|
|
2354
3095
|
const [instanceLayer] = react$1.useGraph(fragmentManager, instanceProps.layerKey);
|
|
2355
3096
|
const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
|
|
@@ -2361,19 +3102,40 @@ const useInstanceProps = (instanceProps) => {
|
|
|
2361
3102
|
...localProps
|
|
2362
3103
|
};
|
|
2363
3104
|
}
|
|
2364
|
-
const extractProps =
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
3105
|
+
const extractProps = utils.cleanGraph(inputProps);
|
|
3106
|
+
const { readVariable } = useReadVariable();
|
|
3107
|
+
let resolvedProps = extractProps;
|
|
3108
|
+
if (!isTopInstance) {
|
|
3109
|
+
resolvedProps = {};
|
|
3110
|
+
for (const [key, value] of Object.entries(extractProps)) {
|
|
3111
|
+
if (!definition.isVariableLink(value)) {
|
|
3112
|
+
resolvedProps[key] = value;
|
|
3113
|
+
continue;
|
|
3114
|
+
}
|
|
3115
|
+
const varLayer = fragmentManager == null ? void 0 : fragmentManager.resolve(value);
|
|
3116
|
+
if ((varLayer == null ? void 0 : varLayer.type) === definition.definition.variableType.Array) {
|
|
3117
|
+
resolvedProps[key] = value;
|
|
3118
|
+
continue;
|
|
3119
|
+
}
|
|
3120
|
+
if ((varLayer == null ? void 0 : varLayer.type) === definition.definition.variableType.Object && (varLayer == null ? void 0 : varLayer.fields)) {
|
|
3121
|
+
resolvedProps[key] = resolveObjectToConcreteValue(
|
|
3122
|
+
varLayer,
|
|
3123
|
+
fragmentManager,
|
|
3124
|
+
readVariable
|
|
3125
|
+
);
|
|
3126
|
+
continue;
|
|
3127
|
+
}
|
|
3128
|
+
const { value: resolved } = readVariable(value);
|
|
3129
|
+
resolvedProps[key] = resolved;
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
2369
3132
|
react.useEffect(() => {
|
|
2370
3133
|
if (utils.isValue(instanceProps == null ? void 0 : instanceProps.props)) {
|
|
2371
3134
|
setLocalProps(instanceProps.props);
|
|
2372
3135
|
}
|
|
2373
3136
|
}, [instanceProps == null ? void 0 : instanceProps.props]);
|
|
2374
3137
|
return {
|
|
2375
|
-
props:
|
|
2376
|
-
cssProps: getCssVariables(extractProps),
|
|
3138
|
+
props: resolvedProps,
|
|
2377
3139
|
onChangeProps: (variableId, value) => {
|
|
2378
3140
|
var _a;
|
|
2379
3141
|
setLocalProps((prev) => ({ ...prev, [variableId]: value }));
|
|
@@ -2391,7 +3153,7 @@ const useInstance = (instanceProps) => {
|
|
|
2391
3153
|
);
|
|
2392
3154
|
const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
|
|
2393
3155
|
const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(resultFragmentId);
|
|
2394
|
-
const { props,
|
|
3156
|
+
const { props, onChangeProps } = useInstanceProps(instanceProps);
|
|
2395
3157
|
const classnames = useClassnames(
|
|
2396
3158
|
instanceProps.layerKey,
|
|
2397
3159
|
innerFragmentManager
|
|
@@ -2402,7 +3164,6 @@ const useInstance = (instanceProps) => {
|
|
|
2402
3164
|
events,
|
|
2403
3165
|
definitions,
|
|
2404
3166
|
props,
|
|
2405
|
-
cssProps,
|
|
2406
3167
|
parentManager,
|
|
2407
3168
|
innerManager: innerFragmentManager,
|
|
2408
3169
|
fragmentId: resultFragmentId,
|
|
@@ -2410,6 +3171,22 @@ const useInstance = (instanceProps) => {
|
|
|
2410
3171
|
onChangeProps
|
|
2411
3172
|
};
|
|
2412
3173
|
};
|
|
3174
|
+
const useSuspenseLoadFragment = (globalManager, fragmentId, skip) => {
|
|
3175
|
+
var _a, _b;
|
|
3176
|
+
if (skip || !globalManager || !fragmentId) return;
|
|
3177
|
+
const cache = getSuspenseCache(globalManager);
|
|
3178
|
+
const valueOrPromise = (_b = (_a = globalManager.$load) == null ? void 0 : _a.loadFragment) == null ? void 0 : _b.call(_a, fragmentId);
|
|
3179
|
+
if (valueOrPromise == null) return;
|
|
3180
|
+
createSuspenseResource(`fragment:${fragmentId}`, valueOrPromise, cache).read();
|
|
3181
|
+
};
|
|
3182
|
+
const useSuspenseLoadArea = (globalManager, areaCode, skip) => {
|
|
3183
|
+
var _a, _b;
|
|
3184
|
+
if (skip || !globalManager || !areaCode) return null;
|
|
3185
|
+
const cache = getSuspenseCache(globalManager);
|
|
3186
|
+
const valueOrPromise = (_b = (_a = globalManager.$load) == null ? void 0 : _a.loadArea) == null ? void 0 : _b.call(_a, areaCode);
|
|
3187
|
+
if (valueOrPromise == null) return null;
|
|
3188
|
+
return createSuspenseResource(`area:${areaCode}`, valueOrPromise, cache).read();
|
|
3189
|
+
};
|
|
2413
3190
|
const InstanceInitial = ({
|
|
2414
3191
|
Tag: inputTag,
|
|
2415
3192
|
style = {},
|
|
@@ -2417,13 +3194,12 @@ const InstanceInitial = ({
|
|
|
2417
3194
|
FrameElement,
|
|
2418
3195
|
...instanceProps
|
|
2419
3196
|
}) => {
|
|
2420
|
-
var _a
|
|
3197
|
+
var _a;
|
|
2421
3198
|
const ssr = ((_a = instanceProps == null ? void 0 : instanceProps.options) == null ? void 0 : _a.ssr) ?? true;
|
|
2422
3199
|
const link = useLayerLink(instanceProps.layerKey);
|
|
2423
3200
|
const Tag = (link == null ? void 0 : link.isLink) ? inputTag ?? "a" : inputTag ?? "div";
|
|
2424
3201
|
const {
|
|
2425
3202
|
fragmentId,
|
|
2426
|
-
cssProps,
|
|
2427
3203
|
parentManager,
|
|
2428
3204
|
events,
|
|
2429
3205
|
props,
|
|
@@ -2436,52 +3212,67 @@ const InstanceInitial = ({
|
|
|
2436
3212
|
...instanceProps,
|
|
2437
3213
|
pauseInteractions
|
|
2438
3214
|
});
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
3215
|
+
const expandedProps = useExtractProps(
|
|
3216
|
+
props,
|
|
3217
|
+
innerManager,
|
|
3218
|
+
parentManager,
|
|
3219
|
+
definitions
|
|
3220
|
+
);
|
|
3221
|
+
const cssVars = react.useMemo(
|
|
3222
|
+
() => toCssCustomProperties(expandedProps),
|
|
3223
|
+
[expandedProps]
|
|
3224
|
+
);
|
|
3225
|
+
useSuspenseLoadFragment(globalManager, fragmentId, !ssr);
|
|
3226
|
+
const scopeValue = react.useMemo(
|
|
3227
|
+
() => ({
|
|
3228
|
+
type: definition.definition.scopeTypes.InstanceScope,
|
|
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
|
+
]
|
|
3244
|
+
);
|
|
3245
|
+
const instanceContextValue = react.useMemo(
|
|
3246
|
+
() => ({
|
|
3247
|
+
layerKey: instanceProps.layerKey,
|
|
3248
|
+
definitions,
|
|
3249
|
+
innerManager,
|
|
3250
|
+
parentManager,
|
|
3251
|
+
props: expandedProps
|
|
3252
|
+
}),
|
|
3253
|
+
[
|
|
3254
|
+
instanceProps.layerKey,
|
|
3255
|
+
definitions,
|
|
3256
|
+
innerManager,
|
|
3257
|
+
parentManager,
|
|
3258
|
+
expandedProps
|
|
3259
|
+
]
|
|
3260
|
+
);
|
|
2442
3261
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2443
3262
|
Scope,
|
|
2444
3263
|
{
|
|
2445
3264
|
fragmentManager: innerManager,
|
|
2446
3265
|
layerKey: instanceProps.layerKey,
|
|
2447
|
-
value:
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
definitions,
|
|
2451
|
-
fragmentId,
|
|
2452
|
-
documentManager: innerManager,
|
|
2453
|
-
layerKey: instanceProps.layerKey,
|
|
2454
|
-
onChangeProps
|
|
2455
|
-
},
|
|
2456
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2457
|
-
InstanceContext$1.Provider,
|
|
3266
|
+
value: scopeValue,
|
|
3267
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(InstanceContext$1.Provider, { value: instanceContextValue, children: parentManager ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3268
|
+
Tag,
|
|
2458
3269
|
{
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
},
|
|
2466
|
-
children: parentManager ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2467
|
-
Tag,
|
|
2468
|
-
{
|
|
2469
|
-
className: classnames,
|
|
2470
|
-
"data-key": instanceProps.layerKey,
|
|
2471
|
-
style: { ...style, ...cssProps },
|
|
2472
|
-
...link.linkProps,
|
|
2473
|
-
...events,
|
|
2474
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2475
|
-
Fragment,
|
|
2476
|
-
{
|
|
2477
|
-
fragmentId,
|
|
2478
|
-
globalManager,
|
|
2479
|
-
FrameElement,
|
|
2480
|
-
pauseInteractions
|
|
2481
|
-
}
|
|
2482
|
-
)
|
|
2483
|
-
}
|
|
2484
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(Tag, { style: { ...style, ...cssProps }, ...link.linkProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3270
|
+
className: classnames,
|
|
3271
|
+
"data-key": instanceProps.layerKey,
|
|
3272
|
+
style: { ...style, ...cssVars },
|
|
3273
|
+
...link.linkProps,
|
|
3274
|
+
...events,
|
|
3275
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2485
3276
|
Fragment,
|
|
2486
3277
|
{
|
|
2487
3278
|
fragmentId,
|
|
@@ -2489,9 +3280,17 @@ const InstanceInitial = ({
|
|
|
2489
3280
|
FrameElement,
|
|
2490
3281
|
pauseInteractions
|
|
2491
3282
|
}
|
|
2492
|
-
)
|
|
3283
|
+
)
|
|
2493
3284
|
}
|
|
2494
|
-
)
|
|
3285
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Tag, { style: { ...style, ...cssVars }, ...link.linkProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3286
|
+
Fragment,
|
|
3287
|
+
{
|
|
3288
|
+
fragmentId,
|
|
3289
|
+
globalManager,
|
|
3290
|
+
FrameElement,
|
|
3291
|
+
pauseInteractions
|
|
3292
|
+
}
|
|
3293
|
+
) }) })
|
|
2495
3294
|
}
|
|
2496
3295
|
);
|
|
2497
3296
|
};
|
|
@@ -2511,26 +3310,24 @@ const Instance = (props) => {
|
|
|
2511
3310
|
) });
|
|
2512
3311
|
};
|
|
2513
3312
|
const useArea = (options) => {
|
|
2514
|
-
|
|
3313
|
+
var _a;
|
|
3314
|
+
const { manager: resultGlobalManager } = useGlobalManager(
|
|
2515
3315
|
options == null ? void 0 : options.globalManager
|
|
2516
3316
|
);
|
|
2517
|
-
const
|
|
3317
|
+
const ssr = ((_a = options == null ? void 0 : options.options) == null ? void 0 : _a.ssr) ?? true;
|
|
3318
|
+
const areaData = useSuspenseLoadArea(
|
|
3319
|
+
resultGlobalManager,
|
|
3320
|
+
options.areaCode,
|
|
3321
|
+
!(isBrowser || ssr)
|
|
3322
|
+
);
|
|
2518
3323
|
const { manager: fragmentManager } = useFragmentManager(
|
|
2519
|
-
areaData.fragmentId,
|
|
3324
|
+
areaData == null ? void 0 : areaData.fragmentId,
|
|
2520
3325
|
resultGlobalManager
|
|
2521
3326
|
);
|
|
2522
3327
|
const resultProps = react.useMemo(
|
|
2523
|
-
() => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options == null ? void 0 : options.props) ??
|
|
3328
|
+
() => ({ ...(areaData == null ? void 0 : areaData.props) ?? {}, ...(options == null ? void 0 : options.props) ?? {} }),
|
|
2524
3329
|
[areaData, options]
|
|
2525
3330
|
);
|
|
2526
|
-
react.useEffect(() => {
|
|
2527
|
-
(async () => {
|
|
2528
|
-
const response = await queryArea(options.areaCode);
|
|
2529
|
-
if (response) {
|
|
2530
|
-
setAreaData(response);
|
|
2531
|
-
}
|
|
2532
|
-
})();
|
|
2533
|
-
}, []);
|
|
2534
3331
|
return {
|
|
2535
3332
|
...areaData,
|
|
2536
3333
|
fragmentManager,
|
|
@@ -2539,28 +3336,30 @@ const useArea = (options) => {
|
|
|
2539
3336
|
};
|
|
2540
3337
|
};
|
|
2541
3338
|
const AreaInitial = (areaProps) => {
|
|
2542
|
-
var _a, _b, _c;
|
|
2543
|
-
const { manager: globalManager } = useGlobalManager(areaProps == null ? void 0 : areaProps.globalManager);
|
|
2544
|
-
const ssr = ((_a = areaProps == null ? void 0 : areaProps.options) == null ? void 0 : _a.ssr) ?? true;
|
|
2545
|
-
if (isBrowser || ssr) {
|
|
2546
|
-
(_c = (_b = globalManager == null ? void 0 : globalManager.$load) == null ? void 0 : _b.loadArea) == null ? void 0 : _c.call(_b, areaProps.areaCode, {
|
|
2547
|
-
suspense: true
|
|
2548
|
-
});
|
|
2549
|
-
}
|
|
2550
3339
|
const areaData = useArea(areaProps);
|
|
2551
3340
|
if (!areaData) return null;
|
|
2552
|
-
|
|
3341
|
+
const areaManager = react.useMemo(
|
|
3342
|
+
() => clientCore.createAreaManager({
|
|
3343
|
+
areaId: areaData.areaId,
|
|
3344
|
+
campaignId: areaData.campaignId,
|
|
3345
|
+
variantId: areaData.variantId,
|
|
3346
|
+
areaProperties: areaData.areaProperties
|
|
3347
|
+
}),
|
|
3348
|
+
[areaData.areaId]
|
|
3349
|
+
);
|
|
3350
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AreaManagerProvider, { value: areaManager, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2553
3351
|
Scope,
|
|
2554
3352
|
{
|
|
2555
3353
|
fragmentManager: areaData.fragmentManager,
|
|
2556
3354
|
layerKey: "Area",
|
|
2557
3355
|
value: {
|
|
2558
3356
|
type: definition.definition.scopeTypes.AreaScope,
|
|
3357
|
+
areaManager,
|
|
2559
3358
|
...areaData ?? {}
|
|
2560
3359
|
},
|
|
2561
3360
|
children: /* @__PURE__ */ jsxRuntime.jsx(Instance, { fragmentId: areaData.fragmentId, props: areaData == null ? void 0 : areaData.props })
|
|
2562
3361
|
}
|
|
2563
|
-
);
|
|
3362
|
+
) });
|
|
2564
3363
|
};
|
|
2565
3364
|
const Area = (props) => {
|
|
2566
3365
|
return "globalManager" in props ? /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(GlobalManagerProvider, { value: props.globalManager, children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: null, children: /* @__PURE__ */ jsxRuntime.jsx(AreaInitial, { ...props }) });
|
|
@@ -2586,6 +3385,8 @@ const useLayerCssOverride = (layerKey) => {
|
|
|
2586
3385
|
return utils.isValue(cssOverride) ? cssStringToJsObject(cssOverride) : {};
|
|
2587
3386
|
};
|
|
2588
3387
|
exports.Area = Area;
|
|
3388
|
+
exports.AreaManagerContext = AreaManagerContext;
|
|
3389
|
+
exports.AreaManagerProvider = AreaManagerProvider;
|
|
2589
3390
|
exports.Collection = Collection;
|
|
2590
3391
|
exports.CssChunk = CssChunk;
|
|
2591
3392
|
exports.CustomRender = CustomRender;
|
|
@@ -2612,12 +3413,12 @@ exports.calcSize = calcSize;
|
|
|
2612
3413
|
exports.cloneLayer = cloneLayer;
|
|
2613
3414
|
exports.copyLayer = copyLayer;
|
|
2614
3415
|
exports.createLayer = createLayer;
|
|
3416
|
+
exports.createSuspenseResource = createSuspenseResource;
|
|
2615
3417
|
exports.declareFragmentProperty = declareFragmentProperty;
|
|
2616
3418
|
exports.defaultCustomRender = defaultCustomRender;
|
|
2617
3419
|
exports.duplicateLayer = duplicateLayer;
|
|
2618
3420
|
exports.findBreakpoint = findBreakpoint;
|
|
2619
3421
|
exports.getAllParents = getAllParents;
|
|
2620
|
-
exports.getCssVariables = getCssVariables;
|
|
2621
3422
|
exports.getHydratedData = getHydratedData;
|
|
2622
3423
|
exports.getKey = getKey;
|
|
2623
3424
|
exports.getNormalizeLayer = getNormalizeLayer;
|
|
@@ -2625,6 +3426,7 @@ exports.getOverrider = getOverrider;
|
|
|
2625
3426
|
exports.getOverriderByLayers = getOverriderByLayers;
|
|
2626
3427
|
exports.getParent = getParent;
|
|
2627
3428
|
exports.getStylesheetKey = getStylesheetKey;
|
|
3429
|
+
exports.getSuspenseCache = getSuspenseCache;
|
|
2628
3430
|
exports.hashGenerator = hashGenerator;
|
|
2629
3431
|
exports.insertChildren = insertChildren;
|
|
2630
3432
|
exports.isBrowser = isBrowser;
|
|
@@ -2636,7 +3438,6 @@ exports.isRootLayer = isRootLayer;
|
|
|
2636
3438
|
exports.isTopLevel = isTopLevel;
|
|
2637
3439
|
exports.isVariableLink = isVariableLink;
|
|
2638
3440
|
exports.layerFieldSetter = layerFieldSetter;
|
|
2639
|
-
exports.loadFragmentManager = loadFragmentManager;
|
|
2640
3441
|
exports.makeSnapshot = makeSnapshot;
|
|
2641
3442
|
exports.moveChildren = moveChildren;
|
|
2642
3443
|
exports.nodeWalker = nodeWalker;
|
|
@@ -2645,6 +3446,7 @@ exports.removeChildren = removeChildren;
|
|
|
2645
3446
|
exports.serializeData = serializeData;
|
|
2646
3447
|
exports.setKey = setKey;
|
|
2647
3448
|
exports.spliceChildren = spliceChildren;
|
|
3449
|
+
exports.toCssCustomProperties = toCssCustomProperties;
|
|
2648
3450
|
exports.transformCssValue = transformCssValue;
|
|
2649
3451
|
exports.useArea = useArea;
|
|
2650
3452
|
exports.useCollection = useCollection;
|
|
@@ -2662,7 +3464,6 @@ exports.useLayerBackground = useLayerBackground;
|
|
|
2662
3464
|
exports.useLayerBorder = useLayerBorder;
|
|
2663
3465
|
exports.useLayerChildren = useLayerChildren;
|
|
2664
3466
|
exports.useLayerCssOverride = useLayerCssOverride;
|
|
2665
|
-
exports.useLayerCssVariable = useLayerCssVariable;
|
|
2666
3467
|
exports.useLayerDisplay = useLayerDisplay;
|
|
2667
3468
|
exports.useLayerFlex = useLayerFlex;
|
|
2668
3469
|
exports.useLayerLayout = useLayerLayout;
|
|
@@ -2680,6 +3481,8 @@ exports.useOptionalSize = useOptionalSize;
|
|
|
2680
3481
|
exports.useReadVariable = useReadVariable;
|
|
2681
3482
|
exports.useReadVariables = useReadVariables;
|
|
2682
3483
|
exports.useRenderTarget = useRenderTarget;
|
|
3484
|
+
exports.useResolvedLayer = useResolvedLayer;
|
|
3485
|
+
exports.useResolvedLayerVariables = useResolvedLayerVariables;
|
|
2683
3486
|
exports.useTextAttributes = useTextAttributes;
|
|
2684
3487
|
exports.useTextContent = useTextContent;
|
|
2685
3488
|
exports.useTextHighlight = useTextHighlight;
|