@seed-design/figma 1.1.13 → 1.1.14

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 (43) hide show
  1. package/lib/codegen/index.cjs +636 -114
  2. package/lib/codegen/index.d.ts +136 -96
  3. package/lib/codegen/index.d.ts.map +1 -1
  4. package/lib/codegen/index.js +636 -114
  5. package/lib/codegen/targets/react/index.cjs +682 -134
  6. package/lib/codegen/targets/react/index.d.ts +31 -11
  7. package/lib/codegen/targets/react/index.d.ts.map +1 -1
  8. package/lib/codegen/targets/react/index.js +682 -135
  9. package/lib/index.cjs +1254 -433
  10. package/lib/index.d.ts +46 -10
  11. package/lib/index.d.ts.map +1 -1
  12. package/lib/index.js +1254 -433
  13. package/package.json +1 -1
  14. package/src/codegen/component-properties.ts +5 -5
  15. package/src/codegen/core/value-resolver.ts +49 -12
  16. package/src/codegen/targets/figma/frame.ts +1 -0
  17. package/src/codegen/targets/figma/pipeline.ts +5 -0
  18. package/src/codegen/targets/figma/props.ts +30 -1
  19. package/src/codegen/targets/figma/shape.ts +1 -0
  20. package/src/codegen/targets/figma/value-resolver.ts +20 -0
  21. package/src/codegen/targets/react/component/handlers/menu-sheet.ts +1 -1
  22. package/src/codegen/targets/react/component/handlers/page-banner.ts +2 -2
  23. package/src/codegen/targets/react/component/handlers/{radio-mark.ts → radiomark.ts} +4 -4
  24. package/src/codegen/targets/react/component/handlers/result-section.ts +1 -1
  25. package/src/codegen/targets/react/component/handlers/{switch-mark.ts → switchmark.ts} +4 -4
  26. package/src/codegen/targets/react/component/index.ts +4 -4
  27. package/src/codegen/targets/react/frame.ts +16 -2
  28. package/src/codegen/targets/react/pipeline.ts +6 -1
  29. package/src/codegen/targets/react/props.ts +26 -0
  30. package/src/codegen/targets/react/shape.ts +5 -1
  31. package/src/codegen/targets/react/value-resolver.ts +26 -0
  32. package/src/entities/data/__generated__/component-sets/index.d.ts +84 -89
  33. package/src/entities/data/__generated__/component-sets/index.mjs +84 -89
  34. package/src/entities/data/__generated__/components/index.d.ts +2 -2
  35. package/src/entities/data/__generated__/components/index.mjs +2 -2
  36. package/src/entities/data/__generated__/icons/index.mjs +14 -0
  37. package/src/entities/data/__generated__/styles/index.mjs +190 -1
  38. package/src/entities/data/__generated__/variable-collections/index.mjs +11 -1
  39. package/src/entities/data/__generated__/variables/index.mjs +280 -0
  40. package/src/normalizer/from-plugin.ts +427 -258
  41. package/src/normalizer/from-rest.ts +428 -58
  42. package/src/normalizer/types.ts +63 -10
  43. package/src/utils/figma-node.ts +15 -10
@@ -1,9 +1,8 @@
1
- import type { SolidPaint } from "@figma/rest-api-spec";
2
1
  import type {
3
2
  NormalizedHasGeometryTrait,
4
3
  NormalizedInstanceNode,
5
- NormalizedIsLayerTrait,
6
4
  NormalizedSceneNode,
5
+ NormalizedSolidPaint,
7
6
  } from "../normalizer";
8
7
 
9
8
  export function traverseNode(
@@ -12,8 +11,10 @@ export function traverseNode(
12
11
  ) {
13
12
  callback(node);
14
13
 
15
- if ("children" in node) {
16
- node.children.forEach((child) => traverseNode(child, callback));
14
+ if (!("children" in node)) return;
15
+
16
+ for (const child of node.children) {
17
+ traverseNode(child, callback);
17
18
  }
18
19
  }
19
20
 
@@ -56,7 +57,7 @@ export function findAllInstances<T>({ node, key }: { node: NormalizedSceneNode;
56
57
 
57
58
  export function getFirstSolidFill(node: NormalizedHasGeometryTrait) {
58
59
  const fills = node.fills.filter(
59
- (fill): fill is SolidPaint =>
60
+ (fill): fill is NormalizedSolidPaint =>
60
61
  fill.type === "SOLID" && (!("visible" in fill) || fill.visible === true),
61
62
  );
62
63
 
@@ -67,14 +68,16 @@ export function getFirstSolidFill(node: NormalizedHasGeometryTrait) {
67
68
  return fills[0];
68
69
  }
69
70
 
70
- export function getFirstFillVariable(node: NormalizedIsLayerTrait) {
71
- return node.boundVariables?.fills?.[0];
71
+ export function getFirstFillVariable(node: NormalizedHasGeometryTrait) {
72
+ const fill = getFirstSolidFill(node);
73
+
74
+ return fill?.boundVariables?.color;
72
75
  }
73
76
 
74
77
  export function getFirstStroke(node: NormalizedHasGeometryTrait) {
75
78
  const strokes =
76
79
  node.strokes?.filter(
77
- (stroke): stroke is SolidPaint =>
80
+ (stroke): stroke is NormalizedSolidPaint =>
78
81
  stroke.type === "SOLID" && (!("visible" in stroke) || stroke.visible === true),
79
82
  ) ?? [];
80
83
 
@@ -85,6 +88,8 @@ export function getFirstStroke(node: NormalizedHasGeometryTrait) {
85
88
  return strokes[0];
86
89
  }
87
90
 
88
- export function getFirstStrokeVariable(node: NormalizedIsLayerTrait) {
89
- return node.boundVariables?.strokes?.[0];
91
+ export function getFirstStrokeVariable(node: NormalizedHasGeometryTrait) {
92
+ const stroke = getFirstStroke(node);
93
+
94
+ return stroke?.boundVariables?.color;
90
95
  }