@fragmentsx/render-react 1.2.4 → 1.2.6

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.
Files changed (75) hide show
  1. package/dist/hooks/layer/useExtractProps.d.ts +9 -0
  2. package/dist/hooks/layer/useExtractProps.d.ts.map +1 -0
  3. package/dist/hooks/layer/useLayerCssVariable.d.ts.map +1 -1
  4. package/dist/hooks/layer/useReadVariable.d.ts.map +1 -1
  5. package/dist/hooks/layer-styles/useLayerStyles/index.d.ts.map +1 -1
  6. package/dist/hooks/layer-styles/useLayerStyles/useLayerLayout.d.ts +1 -1
  7. package/dist/hooks/layer-styles/useLayerStyles/useLayerLayout.d.ts.map +1 -1
  8. package/dist/hooks/utils/useForceUpdate.d.ts +2 -0
  9. package/dist/hooks/utils/useForceUpdate.d.ts.map +1 -0
  10. package/dist/hooks/utils/useLayerInteractions.d.ts.map +1 -1
  11. package/dist/index.cjs.js +165 -109
  12. package/dist/index.es.js +167 -111
  13. package/dist/nodes/Area/test/area-project-props.browser.test.d.ts +2 -0
  14. package/dist/nodes/Area/test/area-project-props.browser.test.d.ts.map +1 -0
  15. package/dist/nodes/Collection/Collection.d.ts.map +1 -1
  16. package/dist/nodes/Collection/hooks/useCollection.d.ts.map +1 -1
  17. package/dist/nodes/CollectionItem/CollectionItem.d.ts +7 -0
  18. package/dist/nodes/CollectionItem/CollectionItem.d.ts.map +1 -0
  19. package/dist/nodes/CollectionItem/hooks/useCollection.d.ts +26 -0
  20. package/dist/nodes/CollectionItem/hooks/useCollection.d.ts.map +1 -0
  21. package/dist/nodes/CollectionItem/index.d.ts +3 -0
  22. package/dist/nodes/CollectionItem/index.d.ts.map +1 -0
  23. package/dist/nodes/Frame/Frame.d.ts +1 -0
  24. package/dist/nodes/Frame/Frame.d.ts.map +1 -1
  25. package/dist/nodes/Frame/hooks/useFrame.d.ts +1 -0
  26. package/dist/nodes/Frame/hooks/useFrame.d.ts.map +1 -1
  27. package/dist/nodes/Instance/hooks/useInstance.d.ts +1 -1
  28. package/dist/nodes/Instance/hooks/useInstanceProps.d.ts +1 -1
  29. package/dist/nodes/Instance/hooks/useInstanceProps.d.ts.map +1 -1
  30. package/dist/nodes/Instance/test/basic.test.d.ts +2 -0
  31. package/dist/nodes/Instance/test/basic.test.d.ts.map +1 -0
  32. package/dist/nodes/Instance/test/collection.browser.test.d.ts +2 -0
  33. package/dist/nodes/Instance/test/collection.browser.test.d.ts.map +1 -0
  34. package/dist/nodes/Instance/test/constraints.browser.test.d.ts +2 -0
  35. package/dist/nodes/Instance/test/constraints.browser.test.d.ts.map +1 -0
  36. package/dist/nodes/Instance/test/css-chunks.browser.test.d.ts +2 -0
  37. package/dist/nodes/Instance/test/css-chunks.browser.test.d.ts.map +1 -0
  38. package/dist/nodes/Instance/test/fragmentDocuments.d.ts +19 -0
  39. package/dist/nodes/Instance/test/fragmentDocuments.d.ts.map +1 -0
  40. package/dist/nodes/Instance/test/layout.browser.test.d.ts +2 -0
  41. package/dist/nodes/Instance/test/layout.browser.test.d.ts.map +1 -0
  42. package/dist/nodes/Instance/test/modified.browser.test.d.ts +2 -0
  43. package/dist/nodes/Instance/test/modified.browser.test.d.ts.map +1 -0
  44. package/dist/nodes/Instance/test/modified.test.d.ts +2 -0
  45. package/dist/nodes/Instance/test/modified.test.d.ts.map +1 -0
  46. package/dist/nodes/Instance/test/nested-instance.browser.test.d.ts +2 -0
  47. package/dist/nodes/Instance/test/nested-instance.browser.test.d.ts.map +1 -0
  48. package/dist/nodes/Instance/test/nested-instance.test.d.ts +2 -0
  49. package/dist/nodes/Instance/test/nested-instance.test.d.ts.map +1 -0
  50. package/dist/nodes/Instance/test/paint.browser.test.d.ts +2 -0
  51. package/dist/nodes/Instance/test/paint.browser.test.d.ts.map +1 -0
  52. package/dist/nodes/Instance/test/resize.browser.test.d.ts +2 -0
  53. package/dist/nodes/Instance/test/resize.browser.test.d.ts.map +1 -0
  54. package/dist/nodes/Instance/test/sizing.browser.test.d.ts +2 -0
  55. package/dist/nodes/Instance/test/sizing.browser.test.d.ts.map +1 -0
  56. package/dist/nodes/Instance/test/standalone-props.browser.test.d.ts +2 -0
  57. package/dist/nodes/Instance/test/standalone-props.browser.test.d.ts.map +1 -0
  58. package/dist/nodes/Instance/test/structure.test.d.ts +2 -0
  59. package/dist/nodes/Instance/test/structure.test.d.ts.map +1 -0
  60. package/dist/nodes/Instance/test/styles.browser.test.d.ts +2 -0
  61. package/dist/nodes/Instance/test/styles.browser.test.d.ts.map +1 -0
  62. package/dist/nodes/Instance/test/text.browser.test.d.ts +2 -0
  63. package/dist/nodes/Instance/test/text.browser.test.d.ts.map +1 -0
  64. package/dist/nodes/Instance/test/text.test.d.ts +2 -0
  65. package/dist/nodes/Instance/test/text.test.d.ts.map +1 -0
  66. package/dist/nodes/Text/hooks/useTextContent.d.ts.map +1 -1
  67. package/dist/test/setupTests.d.ts +0 -1
  68. package/dist/test/setupTests.d.ts.map +1 -1
  69. package/package.json +20 -8
  70. package/dist/test/__examples__/Fragment.test.d.ts +0 -6
  71. package/dist/test/__examples__/Fragment.test.d.ts.map +0 -1
  72. package/dist/test/__examples__/useReadVariable.test.d.ts +0 -6
  73. package/dist/test/__examples__/useReadVariable.test.d.ts.map +0 -1
  74. package/dist/test/testUtils.d.ts +0 -17
  75. package/dist/test/testUtils.d.ts.map +0 -1
@@ -0,0 +1,9 @@
1
+ import { GraphState, LinkKey } from '@graph-state/core';
2
+ interface Options {
3
+ inputProps: Record<string, unknown>;
4
+ definitions: LinkKey[];
5
+ manager?: GraphState;
6
+ }
7
+ export declare const useExtractProps: ({ layerKey, definitions, manager, inputProps, }: Options) => unknown;
8
+ export {};
9
+ //# sourceMappingURL=useExtractProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExtractProps.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useExtractProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAaxD,UAAU,OAAO;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,WAAW,EAAE,OAAO,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,eAAO,MAAM,eAAe,oDAKzB,OAAO,YAsCT,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLayerCssVariable.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useLayerCssVariable.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,eAAO,MAAM,mBAAmB,YAAa,UAAU;;CAQtD,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAU/B,CAAC"}
1
+ {"version":3,"file":"useLayerCssVariable.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useLayerCssVariable.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,eAAO,MAAM,mBAAmB,YAAa,UAAU;;CAQtD,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAiB/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useReadVariable.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useReadVariable.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAiDrE,eAAO,MAAM,eAAe,iBACZ,OAAO,GAAG,IAAI,iBACb,OAAO,EAAE;iCAgFY,OAAO;;;;;;;;;;CAgI5C,CAAC"}
1
+ {"version":3,"file":"useReadVariable.d.ts","sourceRoot":"","sources":["../../../src/hooks/layer/useReadVariable.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAkDrE,eAAO,MAAM,eAAe,iBACZ,OAAO,GAAG,IAAI,iBACb,OAAO,EAAE;iCAyFY,OAAO;;;;;;;;;;CAkJ5C,CAAC"}
@@ -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;AAa5C,eAAO,MAAM,cAAc,aAAc,OAAO,OAsF/C,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;AAa5C,eAAO,MAAM,cAAc,aAAc,OAAO,OAoF/C,CAAC"}
@@ -4,7 +4,7 @@ export declare const useLayerLayout: (layerKey: LinkKey) => {
4
4
  gap: string;
5
5
  flexWrap: string | null;
6
6
  justifyContent: any;
7
- flexFlow: string | null;
7
+ flexFlow: string;
8
8
  alignItems: any;
9
9
  padding: any;
10
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useLayerLayout.d.ts","sourceRoot":"","sources":["../../../../src/hooks/layer-styles/useLayerStyles/useLayerLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAO5C,eAAO,MAAM,cAAc,aAAc,OAAO;;;;;;;;CA+C/C,CAAC"}
1
+ {"version":3,"file":"useLayerLayout.d.ts","sourceRoot":"","sources":["../../../../src/hooks/layer-styles/useLayerStyles/useLayerLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAO5C,eAAO,MAAM,cAAc,aAAc,OAAO;;;;;;;;CAwC/C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function useForceUpdate(): [unknown, () => void];
2
+ //# sourceMappingURL=useForceUpdate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForceUpdate.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useForceUpdate.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,IAEgC,CAC1D,OAAO,EACP,MAAM,IAAI,CACX,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLayerInteractions.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useLayerInteractions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAQzD,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,oBAAoB,aACrB,OAAO,YACP,2BAA2B;;;;CAuFtC,CAAC"}
1
+ {"version":3,"file":"useLayerInteractions.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/useLayerInteractions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;AASzD,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,oBAAoB,aACrB,OAAO,YACP,2BAA2B;;;;CAuFtC,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -108,6 +108,9 @@ const useNormalizeLayers = (layerKeys, manager, options) => {
108
108
  (layerKey) => getNormalizeLayer(layerKey, resultManager, options)
109
109
  );
110
110
  };
111
+ function useForceUpdate() {
112
+ return react.useReducer(() => ({}), {});
113
+ }
111
114
  const extractVariableValue = (input, variableId) => {
112
115
  if (utils.isObject(input)) {
113
116
  if (variableId in input) {
@@ -139,6 +142,15 @@ function deepMerge(a, b) {
139
142
  const useReadVariable = (variableKey, customScopes) => {
140
143
  const contextScopes = react.useContext(ScopeContext);
141
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
+ );
142
154
  const extractVariableDefaultValue = (manager, variableEntity) => {
143
155
  const variableLayer = manager.resolve(variableEntity);
144
156
  if ((variableLayer == null ? void 0 : variableLayer.type) !== definition.definition.variableType.Object)
@@ -184,7 +196,7 @@ const useReadVariable = (variableKey, customScopes) => {
184
196
  return variableLayer;
185
197
  };
186
198
  const readVariable = (variableKey2) => {
187
- var _a, _b, _c;
199
+ var _a, _b, _c, _d, _e;
188
200
  const variableId = (_a = core.entityOfKey(variableKey2)) == null ? void 0 : _a._id;
189
201
  if (!definition.isVariableLink(variableKey2)) {
190
202
  return {
@@ -207,7 +219,10 @@ const useReadVariable = (variableKey, customScopes) => {
207
219
  instanceScope == null ? void 0 : instanceScope.documentManager,
208
220
  variableKey2
209
221
  );
210
- let instanceProp = (_b = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _b[variableId];
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];
211
226
  if (Array.isArray(instanceProp)) {
212
227
  instanceProp = instanceProp.map(
213
228
  (rawProp, index) => {
@@ -224,7 +239,7 @@ const useReadVariable = (variableKey, customScopes) => {
224
239
  lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
225
240
  lastCollectionItem == null ? void 0 : lastCollectionItem.value
226
241
  );
227
- 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);
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);
228
243
  const currentValue = variableKey2 === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
229
244
  const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
230
245
  const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
@@ -975,11 +990,13 @@ const getLayerCssVariable = (manager, inputValue) => {
975
990
  };
976
991
  };
977
992
  const useLayerCssVariable = (inputValue) => {
993
+ var _a;
978
994
  const { manager } = react.useContext(FragmentContext);
979
995
  const isVariable = definition.isVariableLink(inputValue);
980
996
  const { layer } = useNormalizeLayer(inputValue, isVariable ? manager : null);
997
+ const variableId = (layer == null ? void 0 : layer._id) ?? ((_a = core.entityOfKey(inputValue)) == null ? void 0 : _a._id);
981
998
  return {
982
- value: isVariable ? `var(--${layer == null ? void 0 : layer._id}, ${transformCssValue(layer == null ? void 0 : layer.defaultValue)})` : null
999
+ value: isVariable ? `var(--${variableId}, ${transformCssValue(layer == null ? void 0 : layer.defaultValue)})` : null
983
1000
  };
984
1001
  };
985
1002
  const useLayerValue = (layerKey, fieldKey, options) => {
@@ -1358,10 +1375,10 @@ const useLayerLinearGradient = (linearGradientLink) => {
1358
1375
  const stopsPosition = useLayersValue(stops, "position");
1359
1376
  const stopValues = react.useMemo(
1360
1377
  () => (stops == null ? void 0 : stops.flatMap((stop, index) => {
1361
- var _a, _b;
1378
+ var _a, _b, _c;
1362
1379
  return [
1363
- (_a = stopsValue == null ? void 0 : stopsValue.at(index)) == null ? void 0 : _a.at(0),
1364
- (_b = stopsPosition == null ? void 0 : stopsPosition.at(index)) == null ? void 0 : _b.at(0)
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)
1365
1382
  ];
1366
1383
  })) ?? [],
1367
1384
  [stops, stopsValue, stopsPosition]
@@ -1461,7 +1478,7 @@ const useLayerBorder = (layerKey) => {
1461
1478
  if (borderPaint.type === definition.definition.paintMode.LinearGradient) {
1462
1479
  let background = `linear-gradient(${paint.solid}, ${paint.solid}) padding-box, ${borderLinearGradient} border-box`;
1463
1480
  if (paint.type === definition.definition.paintMode.LinearGradient) {
1464
- background = `${linearGradient} padding-box, ${borderLinearGradient} border-box`;
1481
+ background = `${linearGradient["background-image"]} padding-box, ${borderLinearGradient["background-image"]} border-box`;
1465
1482
  }
1466
1483
  if (paint.type === definition.definition.paintMode.None) {
1467
1484
  background = `linear-gradient(transparent, transparent) padding-box, ${borderLinearGradient} border-box`;
@@ -1502,25 +1519,18 @@ const useLayerLayout = (layerKey) => {
1502
1519
  const [padding] = useLayerValue(layerKey, "padding", fragmentManager);
1503
1520
  const [gap] = useLayerValue(layerKey, "layerGap", fragmentManager);
1504
1521
  const isFlex = layerModeValue === definition.definition.layerMode.flex;
1505
- return react.useMemo(
1506
- () => ({
1507
- display: isFlex ? "flex" : null,
1508
- gap: utils.toPx(gap),
1509
- flexWrap: isFlex ? layerWrap ? "wrap" : null : null,
1510
- justifyContent: isFlex ? layerDistribute : null,
1511
- flexFlow: isFlex ? layerDirectionValue === definition.definition.layerDirection.vertical ? "column" : "row" : null,
1512
- alignItems: isFlex ? layerAlign : null,
1513
- padding: isFlex ? padding : null
1514
- }),
1515
- [
1516
- isFlex,
1517
- layerWrap,
1518
- layerDistribute,
1519
- layerDirectionValue,
1520
- layerAlign,
1521
- padding
1522
- ]
1523
- );
1522
+ const baseFlow = layerDirectionValue === definition.definition.layerDirection.vertical ? "column" : "row";
1523
+ const wrap = isFlex ? layerWrap ? "wrap" : null : null;
1524
+ const flexFlow = [baseFlow, wrap].filter(Boolean).join(" ");
1525
+ return {
1526
+ display: isFlex ? "flex" : null,
1527
+ gap: utils.toPx(gap),
1528
+ flexWrap: isFlex ? layerWrap ? "wrap" : null : null,
1529
+ justifyContent: isFlex ? layerDistribute : null,
1530
+ flexFlow,
1531
+ alignItems: isFlex ? layerAlign : null,
1532
+ padding: isFlex ? padding : null
1533
+ };
1524
1534
  };
1525
1535
  const useLayerTextStyles = (layerKey) => {
1526
1536
  const { manager: fragmentManager } = react.useContext(FragmentContext);
@@ -1563,7 +1573,7 @@ const useLayerStyles = (layerKey) => {
1563
1573
  const layout = useLayerLayout(layerKey);
1564
1574
  const [zIndex] = useLayerValue(layerKey, "zIndex", fragmentManager);
1565
1575
  const [rotate] = useLayerValue(layerKey, "rotate", fragmentManager);
1566
- const [borderRadius] = useLayerValue(
1576
+ const [borderRadius, , { rawValue: rawBorderRadius }] = useLayerValue(
1567
1577
  layerKey,
1568
1578
  "borderRadius",
1569
1579
  fragmentManager
@@ -1573,13 +1583,13 @@ const useLayerStyles = (layerKey) => {
1573
1583
  const [overflow] = useLayerValue(layerKey, "overflow", fragmentManager);
1574
1584
  return {
1575
1585
  // ...(props ?? {}),
1576
- ...border,
1577
1586
  ...background,
1587
+ ...border,
1578
1588
  ...position,
1579
1589
  opacity,
1580
1590
  overflow,
1581
1591
  rotate: utils.isValue(rotate) ? `${rotate}deg` : null,
1582
- "border-radius": borderRadius,
1592
+ "border-radius": utils.isValue(rawBorderRadius) ? borderRadius : null,
1583
1593
  "white-space": whiteSpace,
1584
1594
  "z-index": zIndex !== -1 ? zIndex : null,
1585
1595
  ...layout,
@@ -1632,10 +1642,12 @@ const useTextContent = (layerKey, manager) => {
1632
1642
  readVariable(variable.variableKey).value ?? ""
1633
1643
  );
1634
1644
  });
1635
- nextContent = nextContent.replace(
1636
- /\{\{(.*?)}}/,
1637
- `<mark class="highlight">$1</mark>`
1638
- );
1645
+ if (typeof nextContent === "string") {
1646
+ nextContent = nextContent.replace(
1647
+ /\{\{(.*?)}}/,
1648
+ `<mark class="highlight">$1</mark>`
1649
+ );
1650
+ }
1639
1651
  return nextContent;
1640
1652
  };
1641
1653
  const useHash = (layerKey, manager) => {
@@ -1695,7 +1707,7 @@ const useLayerInteractions = (layerKey, options) => {
1695
1707
  const pause = (options == null ? void 0 : options.pauseInteractions) ?? false;
1696
1708
  const { manager: globalManager } = useGlobalManager();
1697
1709
  const { manager: fragmentManager } = react.useContext(FragmentContext);
1698
- const scopes = useLayerScopes(fragmentManager, layerKey);
1710
+ const scopes = react.useContext(ScopeContext);
1699
1711
  const areaScope = scopes.find(
1700
1712
  (scope) => (scope == null ? void 0 : scope.type) === definition.definition.scopeTypes.AreaScope
1701
1713
  );
@@ -1829,7 +1841,7 @@ const useTextHighlight = (layerKey, options) => {
1829
1841
  styles["letter-spacing"] = utils.toPx(letterSpacing);
1830
1842
  }
1831
1843
  if (!!fontFamily) {
1832
- styles["font-family"] = fontFamily;
1844
+ styles["font-family"] = `${fontFamily} !important`;
1833
1845
  }
1834
1846
  return {
1835
1847
  stylesString: Object.entries(styles).reduce(
@@ -1906,8 +1918,7 @@ const useFrame = (layerKey, options) => {
1906
1918
  Tag: (link == null ? void 0 : link.isLink) ? (options == null ? void 0 : options.FrameTag) ?? "a" : (options == null ? void 0 : options.FrameTag) ?? "div",
1907
1919
  type: layer == null ? void 0 : layer._type,
1908
1920
  classnames,
1909
- styles: {},
1910
- //isBrowser ? pick(styles, "background") : {},
1921
+ styles,
1911
1922
  children,
1912
1923
  events,
1913
1924
  linkProps: link.linkProps
@@ -1923,16 +1934,106 @@ const useCollection = (layerKey, options) => {
1923
1934
  });
1924
1935
  const source = collectionLayer == null ? void 0 : collectionLayer.source;
1925
1936
  const sourceDefinition = (_a = fragmentManager == null ? void 0 : fragmentManager.resolve(source)) == null ? void 0 : _a.definition;
1926
- const [sourceValue] = useLayerValue(layerKey, "source", fragmentManager);
1937
+ const [sourceValue] = useLayerValue(layerKey, "source", {
1938
+ manager: fragmentManager
1939
+ });
1940
+ const sourceValues = react$1.useGraphStack(fragmentManager, sourceValue ?? []);
1941
+ const resultValues = (sourceValue ?? []).map(
1942
+ (initValue, index) => (sourceValues == null ? void 0 : sourceValues[index]) ?? initValue
1943
+ );
1927
1944
  return {
1928
1945
  source,
1929
1946
  sourceDefinition,
1930
- sourceValue: sourceValue ?? [],
1947
+ sourceValue: resultValues ?? [],
1931
1948
  fragmentManager,
1932
1949
  children,
1933
1950
  ...frame
1934
1951
  };
1935
1952
  };
1953
+ const useExtractProps = ({
1954
+ layerKey,
1955
+ definitions,
1956
+ manager,
1957
+ inputProps
1958
+ }) => {
1959
+ const flatDefinition = react.useMemo(() => {
1960
+ const acc = [];
1961
+ const run = (defLink) => {
1962
+ var _a;
1963
+ const resolvedDefinition = (_a = getNormalizeLayer(defLink, manager)) == null ? void 0 : _a.layer;
1964
+ if ((resolvedDefinition == null ? void 0 : resolvedDefinition.type) === definition.definition.variableType.Array) return;
1965
+ if ((resolvedDefinition == null ? void 0 : resolvedDefinition.type) === definition.definition.variableType.Object) {
1966
+ Object.values(utils.cleanGraph(resolvedDefinition == null ? void 0 : resolvedDefinition.fields)).forEach(run);
1967
+ } else if (definition.isVariableLink(defLink)) {
1968
+ acc.push(defLink);
1969
+ }
1970
+ };
1971
+ definitions.forEach(run);
1972
+ return acc;
1973
+ }, [definitions]);
1974
+ const definitionsData = react$1.useGraphStack(manager, flatDefinition);
1975
+ const definitionProps = react.useMemo(
1976
+ () => definitionsData.reduce((acc, definition2) => {
1977
+ const defId = definition2._id;
1978
+ acc[defId] = (inputProps == null ? void 0 : inputProps[defId]) ?? (definition2 == null ? void 0 : definition2.defaultValue);
1979
+ return acc;
1980
+ }, {}),
1981
+ [inputProps]
1982
+ );
1983
+ return utils.cleanGraph({
1984
+ ...inputProps,
1985
+ ...definitionProps
1986
+ });
1987
+ };
1988
+ const CollectionItem = ({
1989
+ layer,
1990
+ manager,
1991
+ FrameElement,
1992
+ children,
1993
+ sourceDefinition,
1994
+ ...restProps
1995
+ }) => {
1996
+ var _a;
1997
+ const layerKey = core.keyOfEntity(layer);
1998
+ const definitionId = ((_a = core.entityOfKey(sourceDefinition)) == null ? void 0 : _a._id) ?? "";
1999
+ const value = layer.value ?? layer;
2000
+ const props = useExtractProps({
2001
+ layerKey,
2002
+ definitions: [sourceDefinition],
2003
+ inputProps: utils.isObject(value) ? {
2004
+ // [definitionId]: layer.value,
2005
+ ...value
2006
+ } : {
2007
+ [definitionId]: value
2008
+ },
2009
+ manager
2010
+ });
2011
+ return /* @__PURE__ */ jsxRuntime.jsx(
2012
+ Scope,
2013
+ {
2014
+ fragmentManager: manager,
2015
+ layerKey: core.keyOfEntity(layer),
2016
+ value: {
2017
+ type: definition.definition.scopeTypes.CollectionItemScope,
2018
+ ...restProps,
2019
+ sourceDefinition,
2020
+ value: props,
2021
+ manager
2022
+ },
2023
+ children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
2024
+ "div",
2025
+ {
2026
+ style: {
2027
+ display: "contents",
2028
+ ...getCssVariables(props ?? {})
2029
+ },
2030
+ children: /* @__PURE__ */ jsxRuntime.jsx(FrameElement, { ...restProps, layerKey: child })
2031
+ },
2032
+ child
2033
+ ))
2034
+ }
2035
+ );
2036
+ };
1936
2037
  const Collection = ({
1937
2038
  layerKey,
1938
2039
  styles: inputStyles,
@@ -1968,37 +2069,17 @@ const Collection = ({
1968
2069
  "data-key": layerKey,
1969
2070
  style: resultStyles,
1970
2071
  ...restProps,
1971
- children: (_a = sourceValue == null ? void 0 : sourceValue.map) == null ? void 0 : _a.call(sourceValue, (collectionItemLinkKey) => /* @__PURE__ */ jsxRuntime.jsx(
1972
- react$1.GraphValue,
2072
+ children: (_a = sourceValue == null ? void 0 : sourceValue.map) == null ? void 0 : _a.call(sourceValue, (itemValue, index) => /* @__PURE__ */ jsxRuntime.jsx(
2073
+ CollectionItem,
1973
2074
  {
1974
- graphState: fragmentManager,
1975
- field: collectionItemLinkKey,
1976
- children: (value) => /* @__PURE__ */ jsxRuntime.jsx(
1977
- Scope,
1978
- {
1979
- fragmentManager,
1980
- layerKey: collectionItemLinkKey,
1981
- value: {
1982
- type: definition.definition.scopeTypes.CollectionItemScope,
1983
- source,
1984
- sourceDefinition,
1985
- value,
1986
- manager: fragmentManager
1987
- },
1988
- children: children == null ? void 0 : children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
1989
- "div",
1990
- {
1991
- style: {
1992
- display: "contents",
1993
- ...getCssVariables(value ?? {})
1994
- },
1995
- children: /* @__PURE__ */ jsxRuntime.jsx(FrameElement, { ...restProps, layerKey: child })
1996
- },
1997
- child
1998
- ))
1999
- }
2000
- )
2001
- }
2075
+ layer: itemValue,
2076
+ manager: fragmentManager,
2077
+ source,
2078
+ children,
2079
+ sourceDefinition,
2080
+ FrameElement
2081
+ },
2082
+ index
2002
2083
  ))
2003
2084
  }
2004
2085
  )
@@ -2270,54 +2351,29 @@ const useInstanceProps = (instanceProps) => {
2270
2351
  const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(instanceProps == null ? void 0 : instanceProps.fragmentId);
2271
2352
  const { readVariable } = useReadVariable();
2272
2353
  const fragmentManager = isTopInstance ? loadedManager : fragmentContextManager;
2273
- const flatDefinition = react.useMemo(() => {
2274
- const acc = [];
2275
- const run = (defLink) => {
2276
- const resolvedDefinition = fragmentManager.resolve(defLink);
2277
- if ((resolvedDefinition == null ? void 0 : resolvedDefinition.type) === definition.definition.variableType.Object) {
2278
- Object.values(resolvedDefinition.fields).forEach(run);
2279
- } else if (definition.isVariableLink(defLink)) {
2280
- acc.push(defLink);
2281
- }
2282
- };
2283
- definitions.forEach(run);
2284
- return acc;
2285
- }, [definitions]);
2286
- const definitionsData = react$1.useGraphStack(innerFragmentManager, flatDefinition);
2287
2354
  const [instanceLayer] = react$1.useGraph(fragmentManager, instanceProps.layerKey);
2288
2355
  const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
2289
2356
  const [localProps, setLocalProps] = react.useState(instanceProps.props ?? {});
2290
- const mergedProps = react.useMemo(() => {
2291
- let base = instanceLayerProps;
2292
- if (isTopInstance && utils.isObject(base) && utils.isObject(localProps)) {
2293
- base = {
2294
- ...base,
2295
- ...localProps
2296
- };
2297
- }
2298
- if (isTopInstance && fragmentManager) {
2299
- definitionsData.forEach((definition2) => {
2300
- const defId = definition2._id;
2301
- base[defId] = (localProps == null ? void 0 : localProps[defId]) ?? (definition2 == null ? void 0 : definition2.defaultValue);
2302
- });
2303
- }
2304
- return utils.omit(base, "_type", "_id");
2305
- }, [
2306
- isTopInstance,
2307
- fragmentManager,
2308
- instanceLayerProps,
2309
- definitionsData,
2310
- localProps,
2311
- readVariable
2312
- ]);
2357
+ let inputProps = instanceLayerProps;
2358
+ if (isTopInstance && utils.isObject(inputProps) && utils.isObject(localProps)) {
2359
+ inputProps = {
2360
+ ...inputProps,
2361
+ ...localProps
2362
+ };
2363
+ }
2364
+ const extractProps = useExtractProps({
2365
+ definitions,
2366
+ manager: fragmentManager,
2367
+ inputProps
2368
+ });
2313
2369
  react.useEffect(() => {
2314
2370
  if (utils.isValue(instanceProps == null ? void 0 : instanceProps.props)) {
2315
2371
  setLocalProps(instanceProps.props);
2316
2372
  }
2317
2373
  }, [instanceProps == null ? void 0 : instanceProps.props]);
2318
2374
  return {
2319
- props: mergedProps,
2320
- cssProps: getCssVariables(mergedProps),
2375
+ props: extractProps,
2376
+ cssProps: getCssVariables(extractProps),
2321
2377
  onChangeProps: (variableId, value) => {
2322
2378
  var _a;
2323
2379
  setLocalProps((prev) => ({ ...prev, [variableId]: value }));