@fragmentsx/render-react 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/layer-styles/useLayerStyles/index.d.ts +2 -0
- package/dist/hooks/layer-styles/useLayerStyles/index.d.ts.map +1 -1
- package/dist/hooks/layer-styles/useStyleRegistrar.d.ts +3 -0
- package/dist/hooks/layer-styles/useStyleRegistrar.d.ts.map +1 -1
- package/dist/hooks/utils/useExtractProps.d.ts.map +1 -1
- package/dist/index.cjs.js +70 -84
- package/dist/index.es.js +70 -84
- 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/Instance/Instance.d.ts.map +1 -1
- package/dist/nodes/Instance/test/text-css-vars.browser.test.d.ts +2 -0
- package/dist/nodes/Instance/test/text-css-vars.browser.test.d.ts.map +1 -0
- package/dist/nodes/Text/hooks/useTextAttributes.d.ts.map +1 -1
- package/dist/nodes/Text/hooks/useTextCssVars.d.ts +14 -0
- package/dist/nodes/Text/hooks/useTextCssVars.d.ts.map +1 -0
- package/dist/utils/variables/extractStyleVarIds.d.ts +6 -0
- package/dist/utils/variables/extractStyleVarIds.d.ts.map +1 -0
- package/dist/utils/variables/extractStyleVarIds.test.d.ts +2 -0
- package/dist/utils/variables/extractStyleVarIds.test.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { LinkKey } from '@graph-state/core';
|
|
2
|
+
import { StyleRegistrar } from '../useStyleRegistrar';
|
|
2
3
|
interface UseLayerStylesOptions {
|
|
3
4
|
collectStyle?: boolean;
|
|
5
|
+
registrar?: StyleRegistrar;
|
|
4
6
|
}
|
|
5
7
|
export declare const useLayerStyles: (layerKey: LinkKey, options?: UseLayerStylesOptions) => void;
|
|
6
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/layer-styles/useLayerStyles/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/layer-styles/useLayerStyles/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAW5C,OAAO,EAEL,cAAc,EACf,MAAM,wCAAwC,CAAC;AAchD,UAAU,qBAAqB;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,eAAO,MAAM,cAAc,aACf,OAAO,YACP,qBAAqB,SAuMhC,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LinkKey } from '@graph-state/core';
|
|
2
|
+
export type StyleRegistrar = ReturnType<typeof useStyleRegistrar>;
|
|
2
3
|
export declare const useStyleRegistrar: (layerKey: LinkKey) => {
|
|
4
|
+
baseline: Record<string, any>;
|
|
5
|
+
instance: Record<string, any>;
|
|
3
6
|
add(prop: string, value: any, isDynamic: boolean): void;
|
|
4
7
|
addAll(styles: Record<string, any>, isDynamic: boolean): void;
|
|
5
8
|
flush(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStyleRegistrar.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer-styles/useStyleRegistrar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI5C,eAAO,MAAM,iBAAiB,aAAc,OAAO
|
|
1
|
+
{"version":3,"file":"useStyleRegistrar.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer-styles/useStyleRegistrar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI5C,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,eAAO,MAAM,iBAAiB,aAAc,OAAO;;;cAarC,MAAM,SAAS,GAAG,aAAa,OAAO;mBAIjC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,aAAa,OAAO;;iBAiBzC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAInC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExtractProps.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useExtractProps.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"useExtractProps.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useExtractProps.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;AA2OrE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,UACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACpB,UAAU,kBACJ,UAAU,gBACZ,OAAO,EAAE,KACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAwRxB,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
6
6
|
const react = require("react");
|
|
7
7
|
const definition = require("@fragmentsx/definition");
|
|
8
8
|
const jsxRuntime = require("react/jsx-runtime");
|
|
9
|
-
const react$1 = require("@graph-state/react");
|
|
10
9
|
const utils = require("@fragmentsx/utils");
|
|
11
10
|
const core = require("@graph-state/core");
|
|
11
|
+
const react$1 = require("@graph-state/react");
|
|
12
12
|
const clientCore = require("@fragmentsx/client-core");
|
|
13
13
|
const GlobalManagerContext = react.createContext(null);
|
|
14
14
|
const GlobalManagerProvider = GlobalManagerContext.Provider;
|
|
@@ -955,7 +955,7 @@ const useReadVariables = (variableKeys, customManager) => {
|
|
|
955
955
|
const refAreaLayer = areaManager == null ? void 0 : areaManager.resolve(refKey);
|
|
956
956
|
const refGlobalLayer = globalManager == null ? void 0 : globalManager.resolve(refKey);
|
|
957
957
|
const refFragmentLayer = resultManager == null ? void 0 : resultManager.resolve(refKey);
|
|
958
|
-
const refValue = (refCampaignLayer == null ? void 0 : refCampaignLayer.defaultValue) ?? (refAreaLayer == null ? void 0 : refAreaLayer.defaultValue) ?? (refGlobalLayer == null ? void 0 : refGlobalLayer.defaultValue) ?? (refFragmentLayer == null ? void 0 : refFragmentLayer.defaultValue) ??
|
|
958
|
+
const refValue = (refCampaignLayer == null ? void 0 : refCampaignLayer.defaultValue) ?? (refAreaLayer == null ? void 0 : refAreaLayer.defaultValue) ?? (refGlobalLayer == null ? void 0 : refGlobalLayer.defaultValue) ?? (refFragmentLayer == null ? void 0 : refFragmentLayer.defaultValue) ?? null;
|
|
959
959
|
return {
|
|
960
960
|
value: refValue,
|
|
961
961
|
layer: refCampaignLayer ?? refAreaLayer ?? refGlobalLayer ?? refFragmentLayer ?? null
|
|
@@ -1298,6 +1298,8 @@ const useStyleRegistrar = (layerKey) => {
|
|
|
1298
1298
|
const instance = {};
|
|
1299
1299
|
const hasInstance = !!instanceId;
|
|
1300
1300
|
return {
|
|
1301
|
+
baseline,
|
|
1302
|
+
instance,
|
|
1301
1303
|
add(prop, value, isDynamic) {
|
|
1302
1304
|
(isDynamic && hasInstance ? instance : baseline)[prop] = value;
|
|
1303
1305
|
},
|
|
@@ -1846,7 +1848,7 @@ const useLayerFlex = (layerKey) => {
|
|
|
1846
1848
|
const SKIP_OVERRIDE = { skipOverrideCheck: true };
|
|
1847
1849
|
const useLayerStyles = (layerKey, options) => {
|
|
1848
1850
|
const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
|
|
1849
|
-
const reg = useStyleRegistrar(layerKey);
|
|
1851
|
+
const reg = (options == null ? void 0 : options.registrar) ?? useStyleRegistrar(layerKey);
|
|
1850
1852
|
try {
|
|
1851
1853
|
if (!layerKey) throw new Error("Empty layer key");
|
|
1852
1854
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
@@ -1982,7 +1984,7 @@ const useLayerStyles = (layerKey, options) => {
|
|
|
1982
1984
|
display,
|
|
1983
1985
|
vars.isVariable.visible || vars.isVariable.layerMode
|
|
1984
1986
|
);
|
|
1985
|
-
if (collectStyle) {
|
|
1987
|
+
if (collectStyle && !(options == null ? void 0 : options.registrar)) {
|
|
1986
1988
|
reg.flush();
|
|
1987
1989
|
}
|
|
1988
1990
|
} catch (e) {
|
|
@@ -2084,6 +2086,39 @@ const useTextContent = (layerKey, manager) => {
|
|
|
2084
2086
|
}
|
|
2085
2087
|
return nextContent;
|
|
2086
2088
|
};
|
|
2089
|
+
function extractStyleVarIds(html) {
|
|
2090
|
+
if (!html) return [];
|
|
2091
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2092
|
+
const varRegex = /var\(--([a-zA-Z0-9_-]+)/g;
|
|
2093
|
+
let match;
|
|
2094
|
+
while ((match = varRegex.exec(html)) !== null) {
|
|
2095
|
+
ids.add(match[1]);
|
|
2096
|
+
}
|
|
2097
|
+
return Array.from(ids);
|
|
2098
|
+
}
|
|
2099
|
+
const useTextCssVars = (layerKey, reg, input) => {
|
|
2100
|
+
const varIds = react.useMemo(() => {
|
|
2101
|
+
const fromContent = extractStyleVarIds(input.content);
|
|
2102
|
+
const fromHighlight = extractStyleVarIds(input.highlightStylesString);
|
|
2103
|
+
return [.../* @__PURE__ */ new Set([...fromContent, ...fromHighlight])];
|
|
2104
|
+
}, [input.content, input.highlightStylesString]);
|
|
2105
|
+
const variableKeys = react.useMemo(
|
|
2106
|
+
() => varIds.map(
|
|
2107
|
+
(id) => core.keyOfEntity({
|
|
2108
|
+
_type: definition.definition.nodes.Variable,
|
|
2109
|
+
_id: id
|
|
2110
|
+
})
|
|
2111
|
+
),
|
|
2112
|
+
[varIds]
|
|
2113
|
+
);
|
|
2114
|
+
const resolved = useReadVariables(variableKeys);
|
|
2115
|
+
varIds.forEach((id, index) => {
|
|
2116
|
+
var _a;
|
|
2117
|
+
const value = (_a = resolved[index]) == null ? void 0 : _a.value;
|
|
2118
|
+
if (value == null) return;
|
|
2119
|
+
reg.add(`--${id}`, String(value), true);
|
|
2120
|
+
});
|
|
2121
|
+
};
|
|
2087
2122
|
const useHash = (layerKey, manager) => {
|
|
2088
2123
|
if (!layerKey || !manager) return null;
|
|
2089
2124
|
const layer = manager.resolve(layerKey);
|
|
@@ -2293,19 +2328,21 @@ const useTextHighlight = (layerKey, options) => {
|
|
|
2293
2328
|
const useTextAttributes = (layerKey, options) => {
|
|
2294
2329
|
const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
|
|
2295
2330
|
const { manager: fragmentManager } = react.useContext(FragmentContext);
|
|
2296
|
-
useLayerStyles(layerKey, { collectStyle });
|
|
2297
2331
|
const highlight = useTextHighlight(layerKey);
|
|
2298
2332
|
const content = useTextContent(layerKey);
|
|
2333
|
+
const reg = useStyleRegistrar(layerKey);
|
|
2334
|
+
useLayerStyles(layerKey, { collectStyle, registrar: reg });
|
|
2335
|
+
useTextCssVars(layerKey, reg, {
|
|
2336
|
+
content,
|
|
2337
|
+
highlightStylesString: highlight.stylesString
|
|
2338
|
+
});
|
|
2339
|
+
if (collectStyle) {
|
|
2340
|
+
reg.flush();
|
|
2341
|
+
}
|
|
2299
2342
|
const classnames = useClassnames(layerKey, fragmentManager);
|
|
2300
2343
|
const hash = useHash(layerKey, fragmentManager);
|
|
2301
2344
|
const events = useLayerInteractions(layerKey, options);
|
|
2302
|
-
return {
|
|
2303
|
-
hash,
|
|
2304
|
-
events,
|
|
2305
|
-
classnames,
|
|
2306
|
-
content,
|
|
2307
|
-
highlight
|
|
2308
|
-
};
|
|
2345
|
+
return { hash, events, classnames, content, highlight };
|
|
2309
2346
|
};
|
|
2310
2347
|
const Text = ({
|
|
2311
2348
|
layerKey,
|
|
@@ -2362,8 +2399,9 @@ const useCollection = (layerKey, options) => {
|
|
|
2362
2399
|
const [sourceValue] = useLayerValue(layerKey, "source", {
|
|
2363
2400
|
manager: fragmentManager
|
|
2364
2401
|
});
|
|
2365
|
-
const
|
|
2366
|
-
const
|
|
2402
|
+
const safeSourceValue = Array.isArray(sourceValue) ? sourceValue : [];
|
|
2403
|
+
const sourceValues = react$1.useGraphStack(fragmentManager, safeSourceValue);
|
|
2404
|
+
const resultValues = safeSourceValue.map(
|
|
2367
2405
|
(initValue, index) => (
|
|
2368
2406
|
// Если initValue — объект (пришёл из пропсов через useReadVariables),
|
|
2369
2407
|
// он уже содержит актуальные значения и имеет приоритет.
|
|
@@ -2509,6 +2547,7 @@ const fillArrayItemDefaults = (items, parentDef, manager) => {
|
|
|
2509
2547
|
};
|
|
2510
2548
|
const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
2511
2549
|
const areaManager = react.useContext(AreaManagerContext);
|
|
2550
|
+
const campaignManager = react.useContext(CampaignManagerContext);
|
|
2512
2551
|
const globalManager = react.useContext(GlobalManagerContext);
|
|
2513
2552
|
const arrayVariableKeys = react.useMemo(() => {
|
|
2514
2553
|
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
@@ -2564,8 +2603,8 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2564
2603
|
const propValue = props[defVar._id];
|
|
2565
2604
|
if (!definition.isVariableLink(propValue)) continue;
|
|
2566
2605
|
const resolveManager = parentManager ?? manager;
|
|
2567
|
-
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2568
|
-
const ownerManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : null;
|
|
2606
|
+
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2607
|
+
const ownerManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ? campaignManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : null;
|
|
2569
2608
|
if ((parentVar == null ? void 0 : parentVar.type) !== definition.definition.variableType.Array) continue;
|
|
2570
2609
|
const items = parentVar.defaultValue;
|
|
2571
2610
|
if (!Array.isArray(items)) continue;
|
|
@@ -2582,7 +2621,15 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2582
2621
|
}
|
|
2583
2622
|
}
|
|
2584
2623
|
return { arrayItemKeys: keys, arrayItemManager: itemManager };
|
|
2585
|
-
}, [
|
|
2624
|
+
}, [
|
|
2625
|
+
definitions,
|
|
2626
|
+
manager,
|
|
2627
|
+
parentManager,
|
|
2628
|
+
campaignManager,
|
|
2629
|
+
areaManager,
|
|
2630
|
+
globalManager,
|
|
2631
|
+
props
|
|
2632
|
+
]);
|
|
2586
2633
|
const arrayItemLayers = react$1.useGraphStack(
|
|
2587
2634
|
arrayItemKeys.length ? arrayItemManager ?? parentManager ?? manager : null,
|
|
2588
2635
|
arrayItemKeys
|
|
@@ -2620,8 +2667,8 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2620
2667
|
}
|
|
2621
2668
|
if (defVar.type === definition.definition.variableType.Array && defVar.definition) {
|
|
2622
2669
|
if (definition.isVariableLink(propValue)) {
|
|
2623
|
-
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2624
|
-
const parentVarManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : resolveManager;
|
|
2670
|
+
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2671
|
+
const parentVarManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ? campaignManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : resolveManager;
|
|
2625
2672
|
if ((parentVar == null ? void 0 : parentVar.type) === definition.definition.variableType.Array && (parentVar == null ? void 0 : parentVar.definition)) {
|
|
2626
2673
|
const resolvedArray = arrayResolvedByKey[propValue];
|
|
2627
2674
|
if (Array.isArray(resolvedArray)) {
|
|
@@ -2669,6 +2716,7 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2669
2716
|
props,
|
|
2670
2717
|
manager,
|
|
2671
2718
|
parentManager,
|
|
2719
|
+
campaignManager,
|
|
2672
2720
|
areaManager,
|
|
2673
2721
|
globalManager,
|
|
2674
2722
|
definitions
|
|
@@ -2698,10 +2746,6 @@ const CollectionItem = ({
|
|
|
2698
2746
|
[sourceDefinition]
|
|
2699
2747
|
);
|
|
2700
2748
|
const expandedProps = useExtractProps(props, manager, void 0, definitions);
|
|
2701
|
-
const cssVars = react.useMemo(
|
|
2702
|
-
() => toCssCustomProperties(expandedProps),
|
|
2703
|
-
[expandedProps]
|
|
2704
|
-
);
|
|
2705
2749
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2706
2750
|
Scope,
|
|
2707
2751
|
{
|
|
@@ -2726,17 +2770,7 @@ const CollectionItem = ({
|
|
|
2726
2770
|
onChangeProps: null,
|
|
2727
2771
|
instanceId: collectionInstanceId
|
|
2728
2772
|
},
|
|
2729
|
-
children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2730
|
-
"div",
|
|
2731
|
-
{
|
|
2732
|
-
style: {
|
|
2733
|
-
display: "contents",
|
|
2734
|
-
...cssVars
|
|
2735
|
-
},
|
|
2736
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(FrameElement, { ...restProps, layerKey: child })
|
|
2737
|
-
},
|
|
2738
|
-
child
|
|
2739
|
-
))
|
|
2773
|
+
children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "contents" }, children: /* @__PURE__ */ jsxRuntime.jsx(FrameElement, { ...restProps, layerKey: child }) }, child))
|
|
2740
2774
|
}
|
|
2741
2775
|
)
|
|
2742
2776
|
}
|
|
@@ -3294,45 +3328,6 @@ const useSuspenseLoadArea = (globalManager, areaCode, skip) => {
|
|
|
3294
3328
|
if (valueOrPromise == null) return null;
|
|
3295
3329
|
return createSuspenseResource(`area:${areaCode}`, valueOrPromise, cache).read();
|
|
3296
3330
|
};
|
|
3297
|
-
const collectPropertyCssVars = (manager, result) => {
|
|
3298
|
-
if (!(manager == null ? void 0 : manager.$properties)) return;
|
|
3299
|
-
const keys = manager.$properties.getPropertyKeys() ?? [];
|
|
3300
|
-
const processField = (fieldLayer) => {
|
|
3301
|
-
if (!(fieldLayer == null ? void 0 : fieldLayer._id)) return;
|
|
3302
|
-
if (fieldLayer.type === definition.definition.variableType.Object && fieldLayer.fields) {
|
|
3303
|
-
for (const [key, ref] of Object.entries(fieldLayer.fields)) {
|
|
3304
|
-
if (key === "_type" || key === "_id") continue;
|
|
3305
|
-
const child = utils.isObject(ref) ? ref : manager.resolve(ref);
|
|
3306
|
-
if (child) processField(child);
|
|
3307
|
-
}
|
|
3308
|
-
return;
|
|
3309
|
-
}
|
|
3310
|
-
if (fieldLayer.defaultValue != null) {
|
|
3311
|
-
result[`--${fieldLayer._id}`] = String(fieldLayer.defaultValue);
|
|
3312
|
-
}
|
|
3313
|
-
};
|
|
3314
|
-
for (const key of keys) {
|
|
3315
|
-
const layer = manager.resolve(key, { deep: true });
|
|
3316
|
-
if (layer) processField(layer);
|
|
3317
|
-
}
|
|
3318
|
-
};
|
|
3319
|
-
const useManagerCssProperties = () => {
|
|
3320
|
-
var _a, _b, _c, _d;
|
|
3321
|
-
const globalManager = react.useContext(GlobalManagerContext);
|
|
3322
|
-
const areaManager = react.useContext(AreaManagerContext);
|
|
3323
|
-
react$1.useGraph(globalManager, (_a = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _a.key);
|
|
3324
|
-
react$1.useGraph(areaManager, (_b = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _b.key);
|
|
3325
|
-
const globalKeys = ((_c = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _c.getPropertyKeys()) ?? [];
|
|
3326
|
-
const areaKeys = ((_d = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _d.getPropertyKeys()) ?? [];
|
|
3327
|
-
react$1.useGraphStack(globalKeys.length ? globalManager : null, globalKeys);
|
|
3328
|
-
react$1.useGraphStack(areaKeys.length ? areaManager : null, areaKeys);
|
|
3329
|
-
return react.useMemo(() => {
|
|
3330
|
-
const vars = {};
|
|
3331
|
-
collectPropertyCssVars(globalManager, vars);
|
|
3332
|
-
collectPropertyCssVars(areaManager, vars);
|
|
3333
|
-
return vars;
|
|
3334
|
-
}, [globalManager, areaManager, globalKeys.length, areaKeys.length]);
|
|
3335
|
-
};
|
|
3336
3331
|
const InstanceInitial = ({
|
|
3337
3332
|
Tag: inputTag,
|
|
3338
3333
|
style = {},
|
|
@@ -3368,15 +3363,6 @@ const InstanceInitial = ({
|
|
|
3368
3363
|
parentManager,
|
|
3369
3364
|
definitions
|
|
3370
3365
|
);
|
|
3371
|
-
const propsCssVars = react.useMemo(
|
|
3372
|
-
() => toCssCustomProperties(expandedProps),
|
|
3373
|
-
[expandedProps]
|
|
3374
|
-
);
|
|
3375
|
-
const managerCssVars = useManagerCssProperties();
|
|
3376
|
-
const cssVars = react.useMemo(
|
|
3377
|
-
() => ({ ...managerCssVars, ...propsCssVars }),
|
|
3378
|
-
[managerCssVars, propsCssVars]
|
|
3379
|
-
);
|
|
3380
3366
|
useSuspenseLoadFragment(globalManager, fragmentId, !ssr);
|
|
3381
3367
|
const instanceContextValue = react.useMemo(
|
|
3382
3368
|
() => ({
|
|
@@ -3403,7 +3389,7 @@ const InstanceInitial = ({
|
|
|
3403
3389
|
{
|
|
3404
3390
|
className: classnames,
|
|
3405
3391
|
"data-key": instanceProps.layerKey,
|
|
3406
|
-
style
|
|
3392
|
+
style,
|
|
3407
3393
|
...link.linkProps,
|
|
3408
3394
|
...events,
|
|
3409
3395
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3416,7 +3402,7 @@ const InstanceInitial = ({
|
|
|
3416
3402
|
}
|
|
3417
3403
|
)
|
|
3418
3404
|
}
|
|
3419
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(Tag, { style
|
|
3405
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Tag, { style, ...link.linkProps, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3420
3406
|
Fragment,
|
|
3421
3407
|
{
|
|
3422
3408
|
fragmentId,
|
package/dist/index.es.js
CHANGED
|
@@ -4,9 +4,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
import { createContext, useContext, useMemo, useCallback, useEffect, useState, useRef, memo, Suspense, Component } from "react";
|
|
5
5
|
import { definition, getNormalizeLayer as getNormalizeLayer$1, isVariableLink as isVariableLink$1, parseLayerField, isLink as isLink$1 } from "@fragmentsx/definition";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { useGraph, useGraphStack } from "@graph-state/react";
|
|
8
7
|
import { cleanGraph, generateId, getKey as getKey$1, isValue, isObject, pick, toPx, setKey as setKey$1, toKebabCase, set, isPrimitive, get, omit, noop, isFiniteNumber, hashGenerator as hashGenerator$1, isBrowser as isBrowser$1 } from "@fragmentsx/utils";
|
|
9
8
|
import { keyOfEntity, isPartialKey, entityOfKey, isLinkKey } from "@graph-state/core";
|
|
9
|
+
import { useGraph, useGraphStack } from "@graph-state/react";
|
|
10
10
|
import { createAreaManager, createCampaignManager } from "@fragmentsx/client-core";
|
|
11
11
|
const GlobalManagerContext = createContext(null);
|
|
12
12
|
const GlobalManagerProvider = GlobalManagerContext.Provider;
|
|
@@ -953,7 +953,7 @@ const useReadVariables = (variableKeys, customManager) => {
|
|
|
953
953
|
const refAreaLayer = areaManager == null ? void 0 : areaManager.resolve(refKey);
|
|
954
954
|
const refGlobalLayer = globalManager == null ? void 0 : globalManager.resolve(refKey);
|
|
955
955
|
const refFragmentLayer = resultManager == null ? void 0 : resultManager.resolve(refKey);
|
|
956
|
-
const refValue = (refCampaignLayer == null ? void 0 : refCampaignLayer.defaultValue) ?? (refAreaLayer == null ? void 0 : refAreaLayer.defaultValue) ?? (refGlobalLayer == null ? void 0 : refGlobalLayer.defaultValue) ?? (refFragmentLayer == null ? void 0 : refFragmentLayer.defaultValue) ??
|
|
956
|
+
const refValue = (refCampaignLayer == null ? void 0 : refCampaignLayer.defaultValue) ?? (refAreaLayer == null ? void 0 : refAreaLayer.defaultValue) ?? (refGlobalLayer == null ? void 0 : refGlobalLayer.defaultValue) ?? (refFragmentLayer == null ? void 0 : refFragmentLayer.defaultValue) ?? null;
|
|
957
957
|
return {
|
|
958
958
|
value: refValue,
|
|
959
959
|
layer: refCampaignLayer ?? refAreaLayer ?? refGlobalLayer ?? refFragmentLayer ?? null
|
|
@@ -1296,6 +1296,8 @@ const useStyleRegistrar = (layerKey) => {
|
|
|
1296
1296
|
const instance = {};
|
|
1297
1297
|
const hasInstance = !!instanceId;
|
|
1298
1298
|
return {
|
|
1299
|
+
baseline,
|
|
1300
|
+
instance,
|
|
1299
1301
|
add(prop, value, isDynamic) {
|
|
1300
1302
|
(isDynamic && hasInstance ? instance : baseline)[prop] = value;
|
|
1301
1303
|
},
|
|
@@ -1844,7 +1846,7 @@ const useLayerFlex = (layerKey) => {
|
|
|
1844
1846
|
const SKIP_OVERRIDE = { skipOverrideCheck: true };
|
|
1845
1847
|
const useLayerStyles = (layerKey, options) => {
|
|
1846
1848
|
const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
|
|
1847
|
-
const reg = useStyleRegistrar(layerKey);
|
|
1849
|
+
const reg = (options == null ? void 0 : options.registrar) ?? useStyleRegistrar(layerKey);
|
|
1848
1850
|
try {
|
|
1849
1851
|
if (!layerKey) throw new Error("Empty layer key");
|
|
1850
1852
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
@@ -1980,7 +1982,7 @@ const useLayerStyles = (layerKey, options) => {
|
|
|
1980
1982
|
display,
|
|
1981
1983
|
vars.isVariable.visible || vars.isVariable.layerMode
|
|
1982
1984
|
);
|
|
1983
|
-
if (collectStyle) {
|
|
1985
|
+
if (collectStyle && !(options == null ? void 0 : options.registrar)) {
|
|
1984
1986
|
reg.flush();
|
|
1985
1987
|
}
|
|
1986
1988
|
} catch (e) {
|
|
@@ -2082,6 +2084,39 @@ const useTextContent = (layerKey, manager) => {
|
|
|
2082
2084
|
}
|
|
2083
2085
|
return nextContent;
|
|
2084
2086
|
};
|
|
2087
|
+
function extractStyleVarIds(html) {
|
|
2088
|
+
if (!html) return [];
|
|
2089
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2090
|
+
const varRegex = /var\(--([a-zA-Z0-9_-]+)/g;
|
|
2091
|
+
let match;
|
|
2092
|
+
while ((match = varRegex.exec(html)) !== null) {
|
|
2093
|
+
ids.add(match[1]);
|
|
2094
|
+
}
|
|
2095
|
+
return Array.from(ids);
|
|
2096
|
+
}
|
|
2097
|
+
const useTextCssVars = (layerKey, reg, input) => {
|
|
2098
|
+
const varIds = useMemo(() => {
|
|
2099
|
+
const fromContent = extractStyleVarIds(input.content);
|
|
2100
|
+
const fromHighlight = extractStyleVarIds(input.highlightStylesString);
|
|
2101
|
+
return [.../* @__PURE__ */ new Set([...fromContent, ...fromHighlight])];
|
|
2102
|
+
}, [input.content, input.highlightStylesString]);
|
|
2103
|
+
const variableKeys = useMemo(
|
|
2104
|
+
() => varIds.map(
|
|
2105
|
+
(id) => keyOfEntity({
|
|
2106
|
+
_type: definition.nodes.Variable,
|
|
2107
|
+
_id: id
|
|
2108
|
+
})
|
|
2109
|
+
),
|
|
2110
|
+
[varIds]
|
|
2111
|
+
);
|
|
2112
|
+
const resolved = useReadVariables(variableKeys);
|
|
2113
|
+
varIds.forEach((id, index) => {
|
|
2114
|
+
var _a;
|
|
2115
|
+
const value = (_a = resolved[index]) == null ? void 0 : _a.value;
|
|
2116
|
+
if (value == null) return;
|
|
2117
|
+
reg.add(`--${id}`, String(value), true);
|
|
2118
|
+
});
|
|
2119
|
+
};
|
|
2085
2120
|
const useHash = (layerKey, manager) => {
|
|
2086
2121
|
if (!layerKey || !manager) return null;
|
|
2087
2122
|
const layer = manager.resolve(layerKey);
|
|
@@ -2291,19 +2326,21 @@ const useTextHighlight = (layerKey, options) => {
|
|
|
2291
2326
|
const useTextAttributes = (layerKey, options) => {
|
|
2292
2327
|
const collectStyle = (options == null ? void 0 : options.collectStyle) ?? true;
|
|
2293
2328
|
const { manager: fragmentManager } = useContext(FragmentContext);
|
|
2294
|
-
useLayerStyles(layerKey, { collectStyle });
|
|
2295
2329
|
const highlight = useTextHighlight(layerKey);
|
|
2296
2330
|
const content = useTextContent(layerKey);
|
|
2331
|
+
const reg = useStyleRegistrar(layerKey);
|
|
2332
|
+
useLayerStyles(layerKey, { collectStyle, registrar: reg });
|
|
2333
|
+
useTextCssVars(layerKey, reg, {
|
|
2334
|
+
content,
|
|
2335
|
+
highlightStylesString: highlight.stylesString
|
|
2336
|
+
});
|
|
2337
|
+
if (collectStyle) {
|
|
2338
|
+
reg.flush();
|
|
2339
|
+
}
|
|
2297
2340
|
const classnames = useClassnames(layerKey, fragmentManager);
|
|
2298
2341
|
const hash = useHash(layerKey, fragmentManager);
|
|
2299
2342
|
const events = useLayerInteractions(layerKey, options);
|
|
2300
|
-
return {
|
|
2301
|
-
hash,
|
|
2302
|
-
events,
|
|
2303
|
-
classnames,
|
|
2304
|
-
content,
|
|
2305
|
-
highlight
|
|
2306
|
-
};
|
|
2343
|
+
return { hash, events, classnames, content, highlight };
|
|
2307
2344
|
};
|
|
2308
2345
|
const Text = ({
|
|
2309
2346
|
layerKey,
|
|
@@ -2360,8 +2397,9 @@ const useCollection = (layerKey, options) => {
|
|
|
2360
2397
|
const [sourceValue] = useLayerValue(layerKey, "source", {
|
|
2361
2398
|
manager: fragmentManager
|
|
2362
2399
|
});
|
|
2363
|
-
const
|
|
2364
|
-
const
|
|
2400
|
+
const safeSourceValue = Array.isArray(sourceValue) ? sourceValue : [];
|
|
2401
|
+
const sourceValues = useGraphStack(fragmentManager, safeSourceValue);
|
|
2402
|
+
const resultValues = safeSourceValue.map(
|
|
2365
2403
|
(initValue, index) => (
|
|
2366
2404
|
// Если initValue — объект (пришёл из пропсов через useReadVariables),
|
|
2367
2405
|
// он уже содержит актуальные значения и имеет приоритет.
|
|
@@ -2507,6 +2545,7 @@ const fillArrayItemDefaults = (items, parentDef, manager) => {
|
|
|
2507
2545
|
};
|
|
2508
2546
|
const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
2509
2547
|
const areaManager = useContext(AreaManagerContext);
|
|
2548
|
+
const campaignManager = useContext(CampaignManagerContext);
|
|
2510
2549
|
const globalManager = useContext(GlobalManagerContext);
|
|
2511
2550
|
const arrayVariableKeys = useMemo(() => {
|
|
2512
2551
|
if (!manager || !(definitions == null ? void 0 : definitions.length)) return [];
|
|
@@ -2562,8 +2601,8 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2562
2601
|
const propValue = props[defVar._id];
|
|
2563
2602
|
if (!isVariableLink$1(propValue)) continue;
|
|
2564
2603
|
const resolveManager = parentManager ?? manager;
|
|
2565
|
-
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2566
|
-
const ownerManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : null;
|
|
2604
|
+
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2605
|
+
const ownerManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ? campaignManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : null;
|
|
2567
2606
|
if ((parentVar == null ? void 0 : parentVar.type) !== definition.variableType.Array) continue;
|
|
2568
2607
|
const items = parentVar.defaultValue;
|
|
2569
2608
|
if (!Array.isArray(items)) continue;
|
|
@@ -2580,7 +2619,15 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2580
2619
|
}
|
|
2581
2620
|
}
|
|
2582
2621
|
return { arrayItemKeys: keys, arrayItemManager: itemManager };
|
|
2583
|
-
}, [
|
|
2622
|
+
}, [
|
|
2623
|
+
definitions,
|
|
2624
|
+
manager,
|
|
2625
|
+
parentManager,
|
|
2626
|
+
campaignManager,
|
|
2627
|
+
areaManager,
|
|
2628
|
+
globalManager,
|
|
2629
|
+
props
|
|
2630
|
+
]);
|
|
2584
2631
|
const arrayItemLayers = useGraphStack(
|
|
2585
2632
|
arrayItemKeys.length ? arrayItemManager ?? parentManager ?? manager : null,
|
|
2586
2633
|
arrayItemKeys
|
|
@@ -2618,8 +2665,8 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2618
2665
|
}
|
|
2619
2666
|
if (defVar.type === definition.variableType.Array && defVar.definition) {
|
|
2620
2667
|
if (isVariableLink$1(propValue)) {
|
|
2621
|
-
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2622
|
-
const parentVarManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : resolveManager;
|
|
2668
|
+
const parentVar = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ?? (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ?? (areaManager == null ? void 0 : areaManager.resolve(propValue)) ?? (globalManager == null ? void 0 : globalManager.resolve(propValue));
|
|
2669
|
+
const parentVarManager = (resolveManager == null ? void 0 : resolveManager.resolve(propValue)) ? resolveManager : (campaignManager == null ? void 0 : campaignManager.resolve(propValue)) ? campaignManager : (areaManager == null ? void 0 : areaManager.resolve(propValue)) ? areaManager : (globalManager == null ? void 0 : globalManager.resolve(propValue)) ? globalManager : resolveManager;
|
|
2623
2670
|
if ((parentVar == null ? void 0 : parentVar.type) === definition.variableType.Array && (parentVar == null ? void 0 : parentVar.definition)) {
|
|
2624
2671
|
const resolvedArray = arrayResolvedByKey[propValue];
|
|
2625
2672
|
if (Array.isArray(resolvedArray)) {
|
|
@@ -2667,6 +2714,7 @@ const useExtractProps = (props, manager, parentManager, definitions) => {
|
|
|
2667
2714
|
props,
|
|
2668
2715
|
manager,
|
|
2669
2716
|
parentManager,
|
|
2717
|
+
campaignManager,
|
|
2670
2718
|
areaManager,
|
|
2671
2719
|
globalManager,
|
|
2672
2720
|
definitions
|
|
@@ -2696,10 +2744,6 @@ const CollectionItem = ({
|
|
|
2696
2744
|
[sourceDefinition]
|
|
2697
2745
|
);
|
|
2698
2746
|
const expandedProps = useExtractProps(props, manager, void 0, definitions);
|
|
2699
|
-
const cssVars = useMemo(
|
|
2700
|
-
() => toCssCustomProperties(expandedProps),
|
|
2701
|
-
[expandedProps]
|
|
2702
|
-
);
|
|
2703
2747
|
return /* @__PURE__ */ jsx(
|
|
2704
2748
|
Scope,
|
|
2705
2749
|
{
|
|
@@ -2724,17 +2768,7 @@ const CollectionItem = ({
|
|
|
2724
2768
|
onChangeProps: null,
|
|
2725
2769
|
instanceId: collectionInstanceId
|
|
2726
2770
|
},
|
|
2727
|
-
children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsx(
|
|
2728
|
-
"div",
|
|
2729
|
-
{
|
|
2730
|
-
style: {
|
|
2731
|
-
display: "contents",
|
|
2732
|
-
...cssVars
|
|
2733
|
-
},
|
|
2734
|
-
children: /* @__PURE__ */ jsx(FrameElement, { ...restProps, layerKey: child })
|
|
2735
|
-
},
|
|
2736
|
-
child
|
|
2737
|
-
))
|
|
2771
|
+
children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsx("div", { style: { display: "contents" }, children: /* @__PURE__ */ jsx(FrameElement, { ...restProps, layerKey: child }) }, child))
|
|
2738
2772
|
}
|
|
2739
2773
|
)
|
|
2740
2774
|
}
|
|
@@ -3292,45 +3326,6 @@ const useSuspenseLoadArea = (globalManager, areaCode, skip) => {
|
|
|
3292
3326
|
if (valueOrPromise == null) return null;
|
|
3293
3327
|
return createSuspenseResource(`area:${areaCode}`, valueOrPromise, cache).read();
|
|
3294
3328
|
};
|
|
3295
|
-
const collectPropertyCssVars = (manager, result) => {
|
|
3296
|
-
if (!(manager == null ? void 0 : manager.$properties)) return;
|
|
3297
|
-
const keys = manager.$properties.getPropertyKeys() ?? [];
|
|
3298
|
-
const processField = (fieldLayer) => {
|
|
3299
|
-
if (!(fieldLayer == null ? void 0 : fieldLayer._id)) return;
|
|
3300
|
-
if (fieldLayer.type === definition.variableType.Object && fieldLayer.fields) {
|
|
3301
|
-
for (const [key, ref] of Object.entries(fieldLayer.fields)) {
|
|
3302
|
-
if (key === "_type" || key === "_id") continue;
|
|
3303
|
-
const child = isObject(ref) ? ref : manager.resolve(ref);
|
|
3304
|
-
if (child) processField(child);
|
|
3305
|
-
}
|
|
3306
|
-
return;
|
|
3307
|
-
}
|
|
3308
|
-
if (fieldLayer.defaultValue != null) {
|
|
3309
|
-
result[`--${fieldLayer._id}`] = String(fieldLayer.defaultValue);
|
|
3310
|
-
}
|
|
3311
|
-
};
|
|
3312
|
-
for (const key of keys) {
|
|
3313
|
-
const layer = manager.resolve(key, { deep: true });
|
|
3314
|
-
if (layer) processField(layer);
|
|
3315
|
-
}
|
|
3316
|
-
};
|
|
3317
|
-
const useManagerCssProperties = () => {
|
|
3318
|
-
var _a, _b, _c, _d;
|
|
3319
|
-
const globalManager = useContext(GlobalManagerContext);
|
|
3320
|
-
const areaManager = useContext(AreaManagerContext);
|
|
3321
|
-
useGraph(globalManager, (_a = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _a.key);
|
|
3322
|
-
useGraph(areaManager, (_b = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _b.key);
|
|
3323
|
-
const globalKeys = ((_c = globalManager == null ? void 0 : globalManager.$properties) == null ? void 0 : _c.getPropertyKeys()) ?? [];
|
|
3324
|
-
const areaKeys = ((_d = areaManager == null ? void 0 : areaManager.$properties) == null ? void 0 : _d.getPropertyKeys()) ?? [];
|
|
3325
|
-
useGraphStack(globalKeys.length ? globalManager : null, globalKeys);
|
|
3326
|
-
useGraphStack(areaKeys.length ? areaManager : null, areaKeys);
|
|
3327
|
-
return useMemo(() => {
|
|
3328
|
-
const vars = {};
|
|
3329
|
-
collectPropertyCssVars(globalManager, vars);
|
|
3330
|
-
collectPropertyCssVars(areaManager, vars);
|
|
3331
|
-
return vars;
|
|
3332
|
-
}, [globalManager, areaManager, globalKeys.length, areaKeys.length]);
|
|
3333
|
-
};
|
|
3334
3329
|
const InstanceInitial = ({
|
|
3335
3330
|
Tag: inputTag,
|
|
3336
3331
|
style = {},
|
|
@@ -3366,15 +3361,6 @@ const InstanceInitial = ({
|
|
|
3366
3361
|
parentManager,
|
|
3367
3362
|
definitions
|
|
3368
3363
|
);
|
|
3369
|
-
const propsCssVars = useMemo(
|
|
3370
|
-
() => toCssCustomProperties(expandedProps),
|
|
3371
|
-
[expandedProps]
|
|
3372
|
-
);
|
|
3373
|
-
const managerCssVars = useManagerCssProperties();
|
|
3374
|
-
const cssVars = useMemo(
|
|
3375
|
-
() => ({ ...managerCssVars, ...propsCssVars }),
|
|
3376
|
-
[managerCssVars, propsCssVars]
|
|
3377
|
-
);
|
|
3378
3364
|
useSuspenseLoadFragment(globalManager, fragmentId, !ssr);
|
|
3379
3365
|
const instanceContextValue = useMemo(
|
|
3380
3366
|
() => ({
|
|
@@ -3401,7 +3387,7 @@ const InstanceInitial = ({
|
|
|
3401
3387
|
{
|
|
3402
3388
|
className: classnames,
|
|
3403
3389
|
"data-key": instanceProps.layerKey,
|
|
3404
|
-
style
|
|
3390
|
+
style,
|
|
3405
3391
|
...link.linkProps,
|
|
3406
3392
|
...events,
|
|
3407
3393
|
children: /* @__PURE__ */ jsx(
|
|
@@ -3414,7 +3400,7 @@ const InstanceInitial = ({
|
|
|
3414
3400
|
}
|
|
3415
3401
|
)
|
|
3416
3402
|
}
|
|
3417
|
-
) : /* @__PURE__ */ jsx(Tag, { style
|
|
3403
|
+
) : /* @__PURE__ */ jsx(Tag, { style, ...link.linkProps, children: /* @__PURE__ */ jsx(
|
|
3418
3404
|
Fragment,
|
|
3419
3405
|
{
|
|
3420
3406
|
fragmentId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCollection.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Collection/hooks/useCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAY,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKzE,eAAO,MAAM,aAAa,aAAc,OAAO,YAAY,eAAe;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useCollection.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Collection/hooks/useCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAY,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKzE,eAAO,MAAM,aAAa,aAAc,OAAO,YAAY,eAAe;;;;;;;;;;;;;;;;;;;;;CA+BzE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionItem.d.ts","sourceRoot":"","sources":["../../../src/nodes/CollectionItem/CollectionItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAW,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAS,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"CollectionItem.d.ts","sourceRoot":"","sources":["../../../src/nodes/CollectionItem/CollectionItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAW,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAS,UAAU,EAAE,MAAM,eAAe,CAAC;AAMlD,UAAU,eAAgB,SAAQ,UAAU;CAAG;AAE/C,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,eAAe,CA0D9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCollection.d.ts","sourceRoot":"","sources":["../../../../src/nodes/CollectionItem/hooks/useCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAY,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKzE,eAAO,MAAM,aAAa,aAAc,OAAO,YAAY,eAAe;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useCollection.d.ts","sourceRoot":"","sources":["../../../../src/nodes/CollectionItem/hooks/useCollection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAY,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKzE,eAAO,MAAM,aAAa,aAAc,OAAO,YAAY,eAAe;;;;;;;;;;;;;;;;;;;;;CA0BzE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../../src/nodes/Instance/Instance.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,WAAW,EAMZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../../src/nodes/Instance/Instance.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,WAAW,EAMZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAU5C,UAAU,eAAe;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAc,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACpE,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,OAAO,UAAU,CAAC,YAAY,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9D;AA+FD,eAAO,MAAM,QAAQ,yDAoBpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-css-vars.browser.test.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Instance/test/text-css-vars.browser.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextAttributes.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Text/hooks/useTextAttributes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTextAttributes.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Text/hooks/useTextAttributes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAW5C,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,iBAAiB,aAClB,OAAO,YACP,iBAAiB;;;;;;;;;;;;CA+B5B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LinkKey } from '@graph-state/core';
|
|
2
|
+
import { StyleRegistrar } from '../../../hooks/layer-styles/useStyleRegistrar';
|
|
3
|
+
interface UseTextCssVarsInput {
|
|
4
|
+
content: string;
|
|
5
|
+
highlightStylesString: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Извлекает var(--id) из контента и highlight, резолвит значения
|
|
9
|
+
* и регистрирует --id: value через registrar.
|
|
10
|
+
* Не вызывает flush — это ответственность вызывающего (useTextAttributes).
|
|
11
|
+
*/
|
|
12
|
+
export declare const useTextCssVars: (layerKey: LinkKey, reg: StyleRegistrar, input: UseTextCssVarsInput) => void;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=useTextCssVars.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTextCssVars.d.ts","sourceRoot":"","sources":["../../../../src/nodes/Text/hooks/useTextCssVars.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAe,MAAM,mBAAmB,CAAC;AAKzD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE7E,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,aACf,OAAO,OACZ,cAAc,SACZ,mBAAmB,SA0B3B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Извлекает ID переменных из var(--id) паттернов в HTML/CSS строке.
|
|
3
|
+
* Возвращает уникальный список ID (hex для fragment variables, alphanumeric+dash для project/area/campaign properties).
|
|
4
|
+
*/
|
|
5
|
+
export declare function extractStyleVarIds(html: string): string[];
|
|
6
|
+
//# sourceMappingURL=extractStyleVarIds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractStyleVarIds.d.ts","sourceRoot":"","sources":["../../../src/utils/variables/extractStyleVarIds.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CASzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractStyleVarIds.test.d.ts","sourceRoot":"","sources":["../../../src/utils/variables/extractStyleVarIds.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fragmentsx/render-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@graph-state/core": "^0.13.2",
|
|
28
28
|
"@graph-state/react": "^0.8.3",
|
|
29
29
|
"react-use-measure": "^2.1.7",
|
|
30
|
-
"@fragmentsx/client-core": "0.
|
|
30
|
+
"@fragmentsx/client-core": "0.6.0",
|
|
31
31
|
"@fragmentsx/definition": "0.2.2",
|
|
32
32
|
"@fragmentsx/utils": "0.2.0"
|
|
33
33
|
},
|