@seed-design/figma 0.0.21 → 0.0.22

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 (82) hide show
  1. package/lib/codegen/index.cjs +8019 -0
  2. package/lib/codegen/index.d.ts +1827 -0
  3. package/lib/codegen/index.js +7989 -0
  4. package/lib/codegen/targets/react/index.cjs +12205 -0
  5. package/lib/codegen/targets/react/index.d.ts +270 -0
  6. package/lib/codegen/targets/react/index.js +12187 -0
  7. package/lib/index.cjs +79 -2741
  8. package/lib/index.d.ts +17 -1937
  9. package/lib/index.js +61 -2715
  10. package/package.json +11 -1
  11. package/src/codegen/{targets/react/component/properties.type.ts → component-properties.ts} +43 -43
  12. package/src/codegen/core/codegen.ts +23 -8
  13. package/src/codegen/core/{component.ts → component-handler.ts} +3 -3
  14. package/src/codegen/core/component-type-helper.ts +35 -0
  15. package/src/codegen/core/context.ts +20 -0
  16. package/src/codegen/core/index.ts +16 -14
  17. package/src/codegen/core/{props.ts → props-converter.ts} +10 -13
  18. package/src/codegen/core/{value.ts → value-resolver.ts} +90 -52
  19. package/src/codegen/default-services.ts +44 -0
  20. package/src/codegen/index.ts +1 -44
  21. package/src/codegen/targets/figma/frame.ts +8 -8
  22. package/src/codegen/targets/figma/index.ts +1 -1
  23. package/src/codegen/targets/figma/pipeline.ts +71 -0
  24. package/src/codegen/targets/figma/props.ts +59 -70
  25. package/src/codegen/targets/figma/shape.ts +18 -18
  26. package/src/codegen/targets/figma/text.ts +6 -6
  27. package/src/codegen/targets/figma/value-resolver.ts +22 -0
  28. package/src/codegen/targets/react/component/deps.interface.ts +5 -4
  29. package/src/codegen/targets/react/component/{transformers → handlers}/action-button.ts +8 -14
  30. package/src/codegen/targets/react/component/{transformers → handlers}/action-chip.ts +10 -20
  31. package/src/codegen/targets/react/component/{transformers → handlers}/action-sheet.ts +13 -10
  32. package/src/codegen/targets/react/component/{transformers → handlers}/app-bar.ts +28 -36
  33. package/src/codegen/targets/react/component/handlers/avatar-stack.ts +29 -0
  34. package/src/codegen/targets/react/component/{transformers → handlers}/avatar.ts +12 -9
  35. package/src/codegen/targets/react/component/handlers/badge.ts +18 -0
  36. package/src/codegen/targets/react/component/{transformers → handlers}/callout.ts +6 -8
  37. package/src/codegen/targets/react/component/{transformers → handlers}/checkbox.ts +5 -5
  38. package/src/codegen/targets/react/component/{transformers → handlers}/chip-tabs.ts +10 -10
  39. package/src/codegen/targets/react/component/{transformers → handlers}/control-chip.ts +10 -20
  40. package/src/codegen/targets/react/component/{transformers → handlers}/error-state.ts +9 -9
  41. package/src/codegen/targets/react/component/{transformers → handlers}/extended-action-sheet.ts +16 -18
  42. package/src/codegen/targets/react/component/{transformers → handlers}/extended-fab.ts +6 -6
  43. package/src/codegen/targets/react/component/handlers/fab.ts +18 -0
  44. package/src/codegen/targets/react/component/{transformers → handlers}/help-bubble.ts +5 -5
  45. package/src/codegen/targets/react/component/{transformers → handlers}/identity-placeholder.ts +5 -5
  46. package/src/codegen/targets/react/component/{transformers → handlers}/inline-banner.ts +7 -10
  47. package/src/codegen/targets/react/component/{transformers → handlers}/manner-temp-badge.ts +5 -5
  48. package/src/codegen/targets/react/component/{transformers → handlers}/multiline-text-field.ts +5 -5
  49. package/src/codegen/targets/react/component/{transformers → handlers}/progress-circle.ts +5 -5
  50. package/src/codegen/targets/react/component/{transformers → handlers}/reaction-button.ts +6 -6
  51. package/src/codegen/targets/react/component/{transformers → handlers}/segmented-control.ts +10 -10
  52. package/src/codegen/targets/react/component/{transformers → handlers}/select-box.ts +10 -10
  53. package/src/codegen/targets/react/component/handlers/skeleton.ts +25 -0
  54. package/src/codegen/targets/react/component/{transformers → handlers}/snackbar.ts +5 -5
  55. package/src/codegen/targets/react/component/{transformers → handlers}/switch.ts +5 -5
  56. package/src/codegen/targets/react/component/{transformers → handlers}/tabs.ts +15 -15
  57. package/src/codegen/targets/react/component/{transformers → handlers}/text-button.ts +7 -13
  58. package/src/codegen/targets/react/component/{transformers → handlers}/text-field.ts +9 -9
  59. package/src/codegen/targets/react/component/{transformers → handlers}/toggle-button.ts +7 -11
  60. package/src/codegen/targets/react/component/index.ts +79 -75
  61. package/src/codegen/targets/react/frame.ts +8 -8
  62. package/src/codegen/targets/react/icon.ts +50 -0
  63. package/src/codegen/targets/react/index.ts +1 -1
  64. package/src/codegen/targets/react/instance.ts +19 -50
  65. package/src/codegen/targets/react/pipeline.ts +108 -0
  66. package/src/codegen/targets/react/props.ts +95 -73
  67. package/src/codegen/targets/react/shape.ts +5 -5
  68. package/src/codegen/targets/react/text.ts +6 -6
  69. package/src/codegen/targets/react/value-resolver.ts +35 -0
  70. package/src/entities/icon.repository.ts +2 -2
  71. package/src/entities/icon.service.ts +9 -20
  72. package/src/entities/style.service.ts +5 -17
  73. package/src/entities/variable.service.ts +36 -68
  74. package/src/utils/figma-variable.ts +39 -3
  75. package/src/codegen/core/component.types.ts +0 -29
  76. package/src/codegen/targets/figma/context.ts +0 -139
  77. package/src/codegen/targets/react/component/transformers/avatar-stack.ts +0 -29
  78. package/src/codegen/targets/react/component/transformers/badge.ts +0 -21
  79. package/src/codegen/targets/react/component/transformers/fab.ts +0 -18
  80. package/src/codegen/targets/react/component/transformers/skeleton.ts +0 -51
  81. package/src/codegen/targets/react/context.ts +0 -176
  82. /package/src/codegen/core/{element.ts → element-transformer.ts} +0 -0
package/lib/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import { match } from 'ts-pattern';
2
- import { camelCase, pascalCase } from 'change-case';
1
+ export * from './codegen/index.js';
3
2
 
4
3
  function createRestNormalizer(ctx) {
5
4
  function normalizeNodes(nodes) {
@@ -457,628 +456,9 @@ function createPluginNormalizer() {
457
456
  return normalizeNode;
458
457
  }
459
458
 
460
- function ensureArray(maybeArray) {
461
- if (Array.isArray(maybeArray)) {
462
- return maybeArray;
463
- }
464
- return [
465
- maybeArray
466
- ];
467
- }
468
- function exists(value) {
469
- return value != null;
470
- }
471
- function compactObject(obj) {
472
- return Object.fromEntries(Object.entries(obj).filter(([, value])=>value != null));
473
- }
474
- function objectEntries(obj) {
475
- return Object.entries(obj);
476
- }
477
- /**
478
- * camelCase but preserve underscore between numbers.
479
- * temporary workaround to avoid x1_5 -> x15
480
- * @example "color-1_5" -> "color1_5"
481
- */ function camelCasePreserveUnderscoreBetweenNumbers(input) {
482
- return camelCase(input, {
483
- mergeAmbiguousCharacters: false
484
- }).replaceAll(/(\D)_(\d)/g, "$1$2").replaceAll(/(\d)_(\D)/g, "$1$2");
485
- }
486
-
487
- function createElement(tag, props = {}, children, comment) {
488
- return {
489
- __IS_JSX_ELEMENT_NODE: true,
490
- tag,
491
- props,
492
- children: ensureArray(children).filter(exists),
493
- comment
494
- };
495
- }
496
- function cloneElement(element, props = {}, children) {
497
- return {
498
- ...element,
499
- props: {
500
- ...element.props,
501
- ...props
502
- },
503
- children: children ? ensureArray(children).filter(exists) : element.children
504
- };
505
- }
506
- function appendSource(element, source) {
507
- return {
508
- ...element,
509
- source
510
- };
511
- }
512
- function isElement(node) {
513
- return typeof node === "object" && node != null && "__IS_JSX_ELEMENT_NODE" in node && node.__IS_JSX_ELEMENT_NODE === true;
514
- }
515
- function stringifyElement(element, options = {}) {
516
- function recursive(node, depth) {
517
- if (typeof node === "string") {
518
- return node;
519
- }
520
- const { tag, props, children, comment } = node;
521
- const propEntries = Object.entries(options.printSource ? {
522
- ...props,
523
- "data-figma-node-id": node.source
524
- } : props);
525
- const propFragments = propEntries.map(([key, value])=>{
526
- if (typeof value === "string") {
527
- if (value.includes("\n")) {
528
- return `${key}={\"${value.replace("\n", "\\n")}\"}`;
529
- }
530
- return `${key}="${value}"`;
531
- }
532
- if (typeof value === "number") {
533
- return `${key}={${value}}`;
534
- }
535
- if (typeof value === "boolean") {
536
- return `${key}={${value}}`;
537
- }
538
- if (isElement(value)) {
539
- return `${key}={${recursive(value, depth + 1)}}`;
540
- }
541
- if (typeof value === "object") {
542
- return `${key}={${JSON.stringify(value)}}`;
543
- }
544
- if (typeof value === "undefined") {
545
- return undefined;
546
- }
547
- }).filter(exists);
548
- const oneLiner = propFragments.join(" ");
549
- const propsString = propEntries.length === 0 ? "" : ` ${oneLiner.length < 80 ? oneLiner : `\n${" ".repeat(depth + 1)}${propFragments.join(`\n${" ".repeat(depth + 1)}`)}\n${" ".repeat(depth)}`}`;
550
- if (children == null || children.length === 0) {
551
- return `<${tag}${propsString} />${comment ? `{/* ${comment} */}` : ""}`;
552
- }
553
- const result = [
554
- `<${tag}${propsString}>`,
555
- ...ensureArray(children).filter(exists).map((child)=>recursive(child, depth + 1)).map((str)=>" ".repeat(depth + 1) + str),
556
- `${" ".repeat(depth)}</${tag}>${comment ? `{/* ${comment} */}` : ""}`
557
- ].join("\n");
558
- return result;
559
- }
560
- return recursive(element, 0);
561
- }
562
-
563
- // --- Helper Functions ---
564
- function getCollectiveBoundingBox(nodes) {
565
- if (nodes.length === 0) {
566
- return null;
567
- }
568
- let minX = Number.POSITIVE_INFINITY;
569
- let minY = Number.POSITIVE_INFINITY;
570
- let maxX = Number.NEGATIVE_INFINITY;
571
- let maxY = Number.NEGATIVE_INFINITY;
572
- nodes.forEach((node)=>{
573
- const box = node.absoluteBoundingBox;
574
- minX = Math.min(minX, box.x);
575
- minY = Math.min(minY, box.y);
576
- maxX = Math.max(maxX, box.x + box.width);
577
- maxY = Math.max(maxY, box.y + box.height);
578
- });
579
- return {
580
- x: minX,
581
- y: minY,
582
- width: maxX - minX,
583
- height: maxY - minY
584
- };
585
- }
586
- function calculateMean(arr) {
587
- if (arr.length === 0) return 0;
588
- return arr.reduce((sum, val)=>sum + val, 0) / arr.length;
589
- }
590
- function calculateVariance(arr) {
591
- if (arr.length < 2) return 0;
592
- const mean = calculateMean(arr);
593
- return arr.reduce((sum, val)=>sum + (val - mean) ** 2, 0) / arr.length;
594
- }
595
- function calculateMedian(arr) {
596
- if (arr.length === 0) return 0;
597
- const sortedArr = [
598
- ...arr
599
- ].sort((a, b)=>a - b);
600
- const mid = Math.floor(sortedArr.length / 2);
601
- if (sortedArr.length % 2 === 0) {
602
- return (sortedArr[mid - 1] + sortedArr[mid]) / 2;
603
- }
604
- return sortedArr[mid];
605
- }
606
- // Tolerance for floating point comparisons and alignment checks
607
- const EPSILON = 1; // 1 pixel tolerance
608
- // --- Main Inference Function ---
609
- function inferLayout(parentNode) {
610
- if (parentNode.layoutMode !== "NONE") {
611
- return {
612
- properties: {},
613
- childProperties: {}
614
- };
615
- }
616
- const children = parentNode.children || [];
617
- const parentBox = parentNode.absoluteBoundingBox;
618
- const result = {
619
- layoutMode: "NONE"
620
- };
621
- if (children.length === 0) {
622
- return {
623
- properties: result,
624
- childProperties: {}
625
- }; // Cannot infer layout for no children
626
- }
627
- if (children.length === 1) {
628
- // Default for single child: Horizontal, Hug contents, No spacing, Calculate padding
629
- result.layoutMode = "HORIZONTAL";
630
- result.primaryAxisSizingMode = "AUTO";
631
- result.counterAxisSizingMode = "AUTO";
632
- result.itemSpacing = 0;
633
- result.primaryAxisAlignItems = "MIN"; // Doesn't matter for one item
634
- result.counterAxisAlignItems = "MIN"; // Doesn't matter for one item
635
- const childBox = children[0].absoluteBoundingBox;
636
- result.paddingLeft = Math.max(0, childBox.x - parentBox.x);
637
- result.paddingRight = Math.max(0, parentBox.x + parentBox.width - (childBox.x + childBox.width));
638
- result.paddingTop = Math.max(0, childBox.y - parentBox.y);
639
- result.paddingBottom = Math.max(0, parentBox.y + parentBox.height - (childBox.y + childBox.height));
640
- return {
641
- properties: result,
642
- childProperties: {}
643
- };
644
- }
645
- // --- 1. Determine Layout Direction ---
646
- const sortedByX = [
647
- ...children
648
- ].sort((a, b)=>a.absoluteBoundingBox.x - b.absoluteBoundingBox.x);
649
- const sortedByY = [
650
- ...children
651
- ].sort((a, b)=>a.absoluteBoundingBox.y - b.absoluteBoundingBox.y);
652
- const horizontalGaps = [];
653
- for(let i = 0; i < sortedByX.length - 1; i++){
654
- const current = sortedByX[i].absoluteBoundingBox;
655
- const next = sortedByX[i + 1].absoluteBoundingBox;
656
- // Ensure items don't significantly overlap vertically for horizontal check
657
- if (Math.max(current.y, next.y) < Math.min(current.y + current.height, next.y + next.height)) {
658
- horizontalGaps.push(next.x - (current.x + current.width));
659
- }
660
- }
661
- const verticalGaps = [];
662
- for(let i = 0; i < sortedByY.length - 1; i++){
663
- const current = sortedByY[i].absoluteBoundingBox;
664
- const next = sortedByY[i + 1].absoluteBoundingBox;
665
- // Ensure items don't significantly overlap horizontally for vertical check
666
- if (Math.max(current.x, next.x) < Math.min(current.x + current.width, next.x + next.width)) {
667
- verticalGaps.push(next.y - (current.y + current.height));
668
- }
669
- }
670
- // Heuristic: Prefer axis with more non-negative gaps and lower variance
671
- const hVariance = calculateVariance(horizontalGaps.filter((g)=>g >= -1));
672
- const vVariance = calculateVariance(verticalGaps.filter((g)=>g >= -1));
673
- const hCount = horizontalGaps.filter((g)=>g >= -1).length;
674
- const vCount = verticalGaps.filter((g)=>g >= -1).length;
675
- let primaryAxisSortedNodes = sortedByX; // Default guess
676
- // Basic variance check (lower is better). Add slight bias for horizontal if equal.
677
- if (vCount > 0 && (hCount === 0 || vVariance < hVariance - EPSILON && vCount >= hCount || vVariance <= hVariance && vCount > hCount)) {
678
- result.layoutMode = "VERTICAL";
679
- primaryAxisSortedNodes = sortedByY;
680
- } else if (hCount > 0) {
681
- result.layoutMode = "HORIZONTAL";
682
- primaryAxisSortedNodes = sortedByX;
683
- } else {
684
- // Ambiguous case based on gaps, fall back to bounding box aspect ratio
685
- const collectiveBox = getCollectiveBoundingBox(children);
686
- if (collectiveBox) {
687
- if (collectiveBox.height > collectiveBox.width) {
688
- result.layoutMode = "VERTICAL";
689
- primaryAxisSortedNodes = sortedByY;
690
- } else {
691
- result.layoutMode = "HORIZONTAL";
692
- primaryAxisSortedNodes = sortedByX;
693
- }
694
- } else {
695
- // Still nothing? Default to Horizontal
696
- result.layoutMode = "HORIZONTAL";
697
- primaryAxisSortedNodes = sortedByX;
698
- }
699
- }
700
- const primaryGaps = result.layoutMode === "HORIZONTAL" ? horizontalGaps : verticalGaps;
701
- const validGaps = primaryGaps.filter((g)=>g >= -1); // Allow slight overlap
702
- // --- 2. Calculate Spacing & Primary Alignment ---
703
- let isSpaceBetween = false;
704
- const collectiveBox = getCollectiveBoundingBox(children);
705
- if (collectiveBox && children.length >= 2) {
706
- // Check for Space Between potential
707
- const first = primaryAxisSortedNodes[0].absoluteBoundingBox;
708
- const last = primaryAxisSortedNodes[primaryAxisSortedNodes.length - 1].absoluteBoundingBox;
709
- let firstStart;
710
- let lastEnd;
711
- let parentSize;
712
- if (result.layoutMode === "HORIZONTAL") {
713
- firstStart = first.x;
714
- lastEnd = last.x + last.width;
715
- parentSize = parentBox.width;
716
- } else {
717
- firstStart = first.y;
718
- lastEnd = last.y + last.height;
719
- parentSize = parentBox.height;
720
- }
721
- const contentSpan = lastEnd - firstStart;
722
- // Heuristic for Space Between: Content spans most of the parent & average gap is large
723
- const averageGap = calculateMean(validGaps);
724
- // Example threshold: Content fills > 85% AND average gap is > 20% of average item size? Or just large?
725
- if (contentSpan > parentSize * 0.8 && validGaps.length > 0 && averageGap > 10) {
726
- // Additional check: are first/last items close to parent edges (considering padding)?
727
- const startPadding = result.layoutMode === "HORIZONTAL" ? first.x - parentBox.x : first.y - parentBox.y;
728
- const endPadding = result.layoutMode === "HORIZONTAL" ? parentBox.x + parentBox.width - (last.x + last.width) : parentBox.y + parentBox.height - (last.y + last.height);
729
- // If start/end items are reasonably close to edges (e.g., < 2 * average gap?)
730
- if (Math.abs(startPadding) < Math.max(20, averageGap * 1.5) && Math.abs(endPadding) < Math.max(20, averageGap * 1.5)) {
731
- isSpaceBetween = true;
732
- }
733
- }
734
- }
735
- if (isSpaceBetween) {
736
- result.primaryAxisAlignItems = "SPACE_BETWEEN";
737
- result.itemSpacing = 0; // Spacing is implicit
738
- result.primaryAxisSizingMode = "FIXED"; // Usually fixed when using space between
739
- } else {
740
- result.primaryAxisAlignItems = "MIN"; // Default to MIN for packed, could refine later
741
- if (validGaps.length > 0) {
742
- // Use median spacing for robustness against outliers
743
- result.itemSpacing = calculateMedian(validGaps);
744
- // Clamp negative spacing if it's very small (likely float error)
745
- if (result.itemSpacing < 0 && result.itemSpacing > -1) {
746
- result.itemSpacing = 0;
747
- }
748
- } else {
749
- result.itemSpacing = 0; // No valid gaps found
750
- }
751
- result.primaryAxisSizingMode = "AUTO"; // Default to hug content for packed
752
- }
753
- // --- 3. Calculate Padding ---
754
- if (collectiveBox) {
755
- result.paddingLeft = Math.max(0, collectiveBox.x - parentBox.x);
756
- result.paddingRight = Math.max(0, parentBox.x + parentBox.width - (collectiveBox.x + collectiveBox.width));
757
- result.paddingTop = Math.max(0, collectiveBox.y - parentBox.y);
758
- result.paddingBottom = Math.max(0, parentBox.y + parentBox.height - (collectiveBox.y + collectiveBox.height));
759
- } else {
760
- result.paddingLeft = 0;
761
- result.paddingRight = 0;
762
- result.paddingTop = 0;
763
- result.paddingBottom = 0;
764
- }
765
- // --- 4. Determine Counter Axis Alignment ---
766
- const counterCoordsMin = [];
767
- const counterCoordsCenter = [];
768
- const counterCoordsMax = [];
769
- if (result.layoutMode === "HORIZONTAL") {
770
- // Check vertical alignment (Y)
771
- children.forEach((node)=>{
772
- const box = node.absoluteBoundingBox;
773
- counterCoordsMin.push(box.y);
774
- counterCoordsCenter.push(box.y + box.height / 2);
775
- counterCoordsMax.push(box.y + box.height);
776
- });
777
- } else {
778
- // VERTICAL layout
779
- // Check horizontal alignment (X)
780
- children.forEach((node)=>{
781
- const box = node.absoluteBoundingBox;
782
- counterCoordsMin.push(box.x);
783
- counterCoordsCenter.push(box.x + box.width / 2);
784
- counterCoordsMax.push(box.x + box.width);
785
- });
786
- }
787
- const minVariance = calculateVariance(counterCoordsMin);
788
- const centerVariance = calculateVariance(counterCoordsCenter);
789
- const maxVariance = calculateVariance(counterCoordsMax);
790
- const alignmentTolerance = EPSILON * EPSILON * 4; // Allow slightly more variance for alignment match
791
- if (minVariance <= centerVariance && minVariance <= maxVariance && minVariance < alignmentTolerance) {
792
- result.counterAxisAlignItems = "MIN";
793
- } else if (centerVariance <= minVariance && centerVariance <= maxVariance && centerVariance < alignmentTolerance) {
794
- result.counterAxisAlignItems = "CENTER";
795
- } else if (maxVariance <= minVariance && maxVariance <= centerVariance && maxVariance < alignmentTolerance) {
796
- result.counterAxisAlignItems = "MAX";
797
- } else {
798
- // Default if variances are high or similar
799
- result.counterAxisAlignItems = "CENTER";
800
- }
801
- // --- 5. Determine Counter Axis Sizing Mode ---
802
- // Default to AUTO unless children perfectly fill the parent counter dimension
803
- result.counterAxisSizingMode = "AUTO";
804
- if (collectiveBox) {
805
- let collectiveCounterSize;
806
- let parentCounterSize;
807
- if (result.layoutMode === "HORIZONTAL") {
808
- collectiveCounterSize = collectiveBox.height;
809
- parentCounterSize = parentBox.height - (result.paddingTop ?? 0) - (result.paddingBottom ?? 0);
810
- } else {
811
- collectiveCounterSize = collectiveBox.width;
812
- parentCounterSize = parentBox.width - (result.paddingLeft ?? 0) - (result.paddingRight ?? 0);
813
- }
814
- // If collective size is very close to parent size on counter axis
815
- if (Math.abs(collectiveCounterSize - parentCounterSize) < EPSILON) {
816
- result.counterAxisSizingMode = "FIXED";
817
- }
818
- }
819
- // 6. Infer layoutAlign for each child
820
- const childProperties = {};
821
- const availableWidth = parentBox.width - (result.paddingLeft ?? 0) - (result.paddingRight ?? 0);
822
- const availableHeight = parentBox.height - (result.paddingTop ?? 0) - (result.paddingBottom ?? 0);
823
- children.forEach((child)=>{
824
- const childBox = child.absoluteBoundingBox;
825
- let inferredChildAlign = undefined;
826
- // Check STRETCH
827
- if (result.layoutMode === "HORIZONTAL") {
828
- // Counter: Vertical
829
- if (Math.abs(childBox.height - availableHeight) < EPSILON && availableHeight > 0) {
830
- inferredChildAlign = "STRETCH";
831
- }
832
- } else {
833
- // Counter: Horizontal
834
- if (Math.abs(childBox.width - availableWidth) < EPSILON && availableWidth > 0) {
835
- inferredChildAlign = "STRETCH";
836
- }
837
- }
838
- if (inferredChildAlign) {
839
- childProperties[child.id] = {
840
- layoutAlign: inferredChildAlign
841
- };
842
- }
843
- });
844
- return {
845
- properties: result,
846
- childProperties
847
- };
848
- }
849
- function applyInferredLayout(parentNode, result) {
850
- const { properties, childProperties } = result;
851
- if (properties.layoutMode === "NONE") {
852
- return parentNode;
853
- }
854
- return {
855
- ...parentNode,
856
- ...properties,
857
- children: parentNode.children.map((child)=>{
858
- const props = childProperties[child.id];
859
- if (props) {
860
- return {
861
- ...child,
862
- ...props
863
- };
864
- }
865
- return child;
866
- })
867
- };
868
- }
869
-
870
- function createCodegenTransformer({ frameTransformer, textTransformer, rectangleTransformer, instanceTransformer, vectorTransformer, booleanOperationTransformer, shouldInferAutoLayout }) {
871
- function traverse(node) {
872
- if ("visible" in node && !node.visible) {
873
- return;
874
- }
875
- const result = match(node).with({
876
- type: "FRAME"
877
- }, (node)=>shouldInferAutoLayout ? frameTransformer(applyInferredLayout(node, inferLayout(node)), traverse) : frameTransformer(node, traverse)).with({
878
- type: "TEXT"
879
- }, (node)=>textTransformer(node, traverse)).with({
880
- type: "RECTANGLE"
881
- }, (node)=>rectangleTransformer(node, traverse)).with({
882
- type: "COMPONENT"
883
- }, (node)=>frameTransformer(node, traverse)) // NOTE: Treat component node as Frame for now
884
- .with({
885
- type: "INSTANCE"
886
- }, (node)=>instanceTransformer(node, traverse)).with({
887
- type: "VECTOR"
888
- }, (node)=>vectorTransformer(node, traverse)).with({
889
- type: "BOOLEAN_OPERATION"
890
- }, (node)=>booleanOperationTransformer(node, traverse)).with({
891
- type: "UNHANDLED"
892
- }, ()=>createElement("UnhandledFigmaNode")).exhaustive();
893
- if (result) {
894
- return appendSource(result, node.id);
895
- }
896
- return;
897
- }
898
- return (node)=>traverse(node);
899
- }
900
-
901
- function defineComponentTransformer(key, transform) {
902
- return {
903
- key,
904
- transform
905
- };
906
- }
907
-
908
- function defineElementTransformer(transformer) {
909
- return transformer;
910
- }
911
-
912
- function definePropsTransformer(transformer) {
913
- return transformer;
914
- }
915
- function createPropsTransformer({ handlers, shorthands, defaults }) {
916
- return definePropsTransformer((node)=>{
917
- const result = {};
918
- for (const [prop, handler] of objectEntries(handlers)){
919
- const value = handler(node);
920
- if (value !== undefined && (!defaults || value !== defaults[prop])) {
921
- result[prop] = value;
922
- }
923
- }
924
- if (shorthands) {
925
- for (const [shorthand, props] of objectEntries(shorthands)){
926
- const values = props.map((prop)=>result[prop]);
927
- const allDefined = values.every((value)=>value !== undefined);
928
- const allEqual = allDefined && values.every((value)=>value === values[0]);
929
- if (allEqual && values[0] !== undefined) {
930
- result[shorthand] = values[0];
931
- for (const prop of props){
932
- delete result[prop];
933
- }
934
- }
935
- }
936
- }
937
- return result;
938
- });
939
- }
940
-
941
- function traverseNode(node, callback) {
942
- if ("children" in node) {
943
- node.children.forEach((child)=>traverseNode(child, callback));
944
- } else {
945
- callback(node);
946
- }
947
- }
948
- function findOne(node, callback) {
949
- let result;
950
- traverseNode(node, (n)=>{
951
- if (callback(n)) {
952
- result = n;
953
- }
954
- });
955
- return result;
956
- }
957
- function findAll(node, callback) {
958
- const result = [];
959
- traverseNode(node, (n)=>{
960
- if (callback(n)) {
961
- result.push(n);
962
- }
963
- });
964
- return result;
965
- }
966
- function findAllInstances({ node, key }) {
967
- return findAll(node, (n)=>n.type === "INSTANCE" && (n.componentKey === key || n.componentSetKey === key));
968
- }
969
- function getFirstSolidFill(node) {
970
- const fills = node.fills.filter((fill)=>fill.type === "SOLID" && (!("visible" in fill) || fill.visible === true));
971
- if (fills.length === 0) {
972
- return undefined;
973
- }
974
- return fills[0];
975
- }
976
- function getFirstFillVariable(node) {
977
- return node.boundVariables?.fills?.[0];
978
- }
979
- function getFirstStroke(node) {
980
- const strokes = node.strokes?.filter((stroke)=>stroke.type === "SOLID" && (!("visible" in stroke) || stroke.visible === true)) ?? [];
981
- if (strokes.length === 0) {
982
- return undefined;
983
- }
984
- return strokes[0];
985
- }
986
- function getFirstStrokeVariable(node) {
987
- return node.boundVariables?.strokes?.[0];
988
- }
989
-
990
- function createValueTransformer({ variableService, formatters, shouldInferVariableName }) {
991
- function processColor(key, value, scope) {
992
- if (key) {
993
- return variableService.getVariableName(key);
994
- }
995
- if (value) {
996
- if (shouldInferVariableName) {
997
- return variableService.inferVariableName(value, scope) ?? formatters.color(value);
998
- }
999
- return formatters.color(value);
1000
- }
1001
- return undefined;
1002
- }
1003
- function processDimension(key, value, scope) {
1004
- if (key) {
1005
- return variableService.getVariableName(key);
1006
- }
1007
- if (value) {
1008
- if (shouldInferVariableName) {
1009
- return variableService.inferVariableName(value, scope) ?? formatters.dimension(value);
1010
- }
1011
- return formatters.dimension(value);
1012
- }
1013
- return undefined;
1014
- }
1015
- function processFontDimension(key, value, scope) {
1016
- if (key) {
1017
- return variableService.getVariableName(key);
1018
- }
1019
- if (value) {
1020
- if (shouldInferVariableName) {
1021
- return variableService.inferVariableName(value, scope) ?? formatters.fontDimension(value);
1022
- }
1023
- return formatters.fontDimension(value);
1024
- }
1025
- return undefined;
1026
- }
1027
- function processFontWeight(key, value) {
1028
- if (key) {
1029
- return variableService.getVariableName(key);
1030
- }
1031
- if (value) {
1032
- if (shouldInferVariableName) {
1033
- const fontWeightToString = {
1034
- 100: "thin",
1035
- 200: "extra-light",
1036
- 300: "light",
1037
- 400: "regular",
1038
- 500: "medium",
1039
- 600: "semi-bold",
1040
- 700: "bold",
1041
- 800: "extra-bold",
1042
- 900: "black"
1043
- };
1044
- return variableService.inferVariableName(value, "FONT_WEIGHT") ?? variableService.inferVariableName(fontWeightToString[value], "FONT_STYLE") ?? formatters.fontWeight(value);
1045
- }
1046
- return formatters.fontWeight(value);
1047
- }
1048
- return undefined;
1049
- }
1050
- const getFormattedValue = {
1051
- width: (node)=>processDimension(node.boundVariables?.size?.x?.id, node.absoluteBoundingBox?.width, "WIDTH_HEIGHT"),
1052
- height: (node)=>processDimension(node.boundVariables?.size?.y?.id, node.absoluteBoundingBox?.height, "WIDTH_HEIGHT"),
1053
- minWidth: (node)=>processDimension(node.boundVariables?.minWidth?.id, node.minWidth, "WIDTH_HEIGHT"),
1054
- minHeight: (node)=>processDimension(node.boundVariables?.minHeight?.id, node.minHeight, "WIDTH_HEIGHT"),
1055
- maxWidth: (node)=>processDimension(node.boundVariables?.maxWidth?.id, node.maxWidth, "WIDTH_HEIGHT"),
1056
- maxHeight: (node)=>processDimension(node.boundVariables?.maxHeight?.id, node.maxHeight, "WIDTH_HEIGHT"),
1057
- paddingLeft: (node)=>processDimension(node.boundVariables?.paddingLeft?.id, node.paddingLeft, "GAP"),
1058
- paddingRight: (node)=>processDimension(node.boundVariables?.paddingRight?.id, node.paddingRight, "GAP"),
1059
- paddingTop: (node)=>processDimension(node.boundVariables?.paddingTop?.id, node.paddingTop, "GAP"),
1060
- paddingBottom: (node)=>processDimension(node.boundVariables?.paddingBottom?.id, node.paddingBottom, "GAP"),
1061
- itemSpacing: (node)=>processDimension(node.boundVariables?.itemSpacing?.id, node.itemSpacing, "GAP"),
1062
- frameFill: (node)=>processColor(getFirstFillVariable(node)?.id, getFirstSolidFill(node)?.color, "FRAME_FILL"),
1063
- shapeFill: (node)=>processColor(getFirstFillVariable(node)?.id, getFirstSolidFill(node)?.color, "SHAPE_FILL"),
1064
- textFill: (node)=>processColor(getFirstFillVariable(node)?.id, getFirstSolidFill(node)?.color, "TEXT_FILL"),
1065
- stroke: (node)=>processColor(getFirstStrokeVariable(node)?.id, getFirstStroke(node)?.color, "STROKE_COLOR"),
1066
- topLeftRadius: (node)=>processDimension(node.boundVariables?.topLeftRadius?.id, node.rectangleCornerRadii?.[0] ?? node.cornerRadius, "CORNER_RADIUS"),
1067
- topRightRadius: (node)=>processDimension(node.boundVariables?.topRightRadius?.id, node.rectangleCornerRadii?.[1] ?? node.cornerRadius, "CORNER_RADIUS"),
1068
- bottomLeftRadius: (node)=>processDimension(node.boundVariables?.bottomLeftRadius?.id, node.rectangleCornerRadii?.[2] ?? node.cornerRadius, "CORNER_RADIUS"),
1069
- bottomRightRadius: (node)=>processDimension(node.boundVariables?.bottomRightRadius?.id, node.rectangleCornerRadii?.[3] ?? node.cornerRadius, "CORNER_RADIUS"),
1070
- fontSize: (node)=>processFontDimension(node.boundVariables?.fontSize?.[0]?.id, node.style.fontSize, "FONT_SIZE"),
1071
- fontWeight: (node)=>processFontWeight(node.boundVariables?.fontWeight?.[0]?.id, node.style.fontWeight),
1072
- lineHeight: (node)=>processFontDimension(node.boundVariables?.lineHeight?.[0]?.id, node.style.lineHeightPx, "LINE_HEIGHT")
1073
- };
1074
- return {
1075
- getFormattedValue
1076
- };
1077
- }
1078
-
1079
459
  function createStaticIconRepository(iconRecord) {
1080
460
  return {
1081
- getIconData: (key)=>iconRecord[key]
461
+ getOne: (key)=>iconRecord[key]
1082
462
  };
1083
463
  }
1084
464
 
@@ -10795,79 +10175,78 @@ function createStaticVariableRepository({ variables, variableCollections }) {
10795
10175
  }
10796
10176
 
10797
10177
  function createIconService({ iconRepository }) {
10798
- function isIconComponent(componentKey) {
10799
- return iconRepository.getIconData(componentKey) !== undefined;
10178
+ function isAvailable(componentKey) {
10179
+ return iconRepository.getOne(componentKey) !== undefined;
10800
10180
  }
10801
- function createIconTagName(key) {
10802
- if (!key) {
10803
- return "UnknownIcon";
10804
- }
10805
- const iconData = iconRepository.getIconData(key);
10806
- if (!iconData) {
10807
- return "UnknownIcon";
10808
- }
10809
- const { name, weight } = iconData;
10810
- return pascalCase(`${name}${weight ? weight : ""}`);
10181
+ function getOne(componentKey) {
10182
+ return iconRepository.getOne(componentKey);
10811
10183
  }
10812
10184
  return {
10813
- isIconComponent,
10814
- createIconTagName
10185
+ isAvailable,
10186
+ getOne
10815
10187
  };
10816
10188
  }
10817
10189
 
10818
10190
  // TODO: inferStyleName 추가해야 함, rest api에서 style value가 제공되지 않고 있어 보류
10819
- function createStyleService({ styleRepository, styleNameTransformer }) {
10820
- function getFigmaStyleName(id) {
10191
+ function createStyleService({ styleRepository }) {
10192
+ function getName(id) {
10821
10193
  const style = styleRepository.findOneByKey(id);
10822
10194
  if (!style) {
10823
10195
  return undefined;
10824
10196
  }
10825
10197
  return style.name;
10826
10198
  }
10827
- function getFigmaStyleSlug(id) {
10828
- const name = getFigmaStyleName(id);
10199
+ function getSlug(id) {
10200
+ const name = getName(id);
10829
10201
  if (!name) {
10830
10202
  return undefined;
10831
10203
  }
10832
10204
  return name.split("/");
10833
10205
  }
10834
- function getStyleName(id) {
10835
- const slug = getFigmaStyleSlug(id);
10836
- if (!slug) {
10837
- return undefined;
10838
- }
10839
- return styleNameTransformer({
10840
- slug
10841
- });
10842
- }
10843
10206
  return {
10844
- getStyleName
10207
+ getSlug
10845
10208
  };
10846
10209
  }
10847
10210
 
10848
- function isVariableAlias(value) {
10849
- return typeof value === "object" && value !== null && "type" in value && value.type === "VARIABLE_ALIAS";
10850
- }
10851
10211
  // boundVariable.id is formatted as "VariableID:{key}/{localId}", we have to extract the key
10852
10212
  function sanitizeVariableId(id) {
10853
10213
  return id.replace("VariableID:", "").split("/")[0];
10854
10214
  }
10215
+ function isVariableAlias(value) {
10216
+ return typeof value === "object" && value !== null && "type" in value && value.type === "VARIABLE_ALIAS";
10217
+ }
10218
+ function isIdenticalVariableValue(value1, value2) {
10219
+ if (typeof value1 !== typeof value2) {
10220
+ return false;
10221
+ }
10222
+ if (typeof value1 === "string" || typeof value1 === "number" || typeof value1 === "boolean") {
10223
+ return value1 === value2;
10224
+ }
10225
+ return value1.r === value2.r && value1.g === value2.g && value1.b === value2.b && value1.a === value2.a;
10226
+ }
10227
+ function isInsideScope(variable, scope) {
10228
+ if (variable.scopes.includes("ALL_SCOPES")) {
10229
+ return true;
10230
+ }
10231
+ if (variable.scopes.includes("ALL_FILLS")) {
10232
+ if (scope === "FRAME_FILL" || scope === "SHAPE_FILL" || scope === "TEXT_FILL") {
10233
+ return true;
10234
+ }
10235
+ }
10236
+ return variable.scopes.includes(scope);
10237
+ }
10855
10238
 
10856
- function createVariableService({ variableRepository, variableNameTransformer, inferCompareFunction }) {
10239
+ function createVariableService({ variableRepository, inferCompareFunction }) {
10857
10240
  const variables = variableRepository.getVariableList();
10858
10241
  // private
10859
- function getFigmaVariableName(key) {
10242
+ function getName(key) {
10860
10243
  const sanitizedId = sanitizeVariableId(key);
10861
10244
  const variable = variableRepository.findVariableByKey(sanitizedId);
10862
10245
  if (!variable) {
10863
- return "UNKNOWN_VARIABLE";
10246
+ return undefined;
10864
10247
  }
10865
10248
  return variable.name;
10866
10249
  }
10867
- function getFigmaVariableSlug(key) {
10868
- const name = getFigmaVariableName(key);
10869
- return name.split("/");
10870
- }
10871
10250
  function getDefaultModeId(variable) {
10872
10251
  const variableCollection = variableRepository.findVariableCollectionById(variable.variableCollectionId);
10873
10252
  if (!variableCollection) {
@@ -10876,57 +10255,38 @@ function createVariableService({ variableRepository, variableNameTransformer, in
10876
10255
  }
10877
10256
  return variableCollection.defaultModeId;
10878
10257
  }
10879
- function resolveVariableValue(id, mode) {
10880
- const variable = variableRepository.findVariableById(id);
10881
- if (!variable) {
10882
- throw new Error(`Variable not found: ${id}`);
10258
+ // public
10259
+ function getSlug(key) {
10260
+ const name = getName(key);
10261
+ if (!name) {
10262
+ return undefined;
10883
10263
  }
10264
+ return name.split("/");
10265
+ }
10266
+ function resolveValue(variable, mode) {
10884
10267
  const value = variable.valuesByMode[mode];
10885
10268
  if (value === undefined) {
10886
- throw new Error(`Variable value not found: ${id} ${mode}`);
10269
+ throw new Error(`Variable value not found: ${variable.id} ${mode}`);
10887
10270
  }
10888
10271
  if (isVariableAlias(value)) {
10889
- return resolveVariableValue(value.id, mode);
10890
- }
10891
- return value;
10892
- }
10893
- function isIdenticalVariableValue(value1, value2) {
10894
- if (typeof value1 !== typeof value2) {
10895
- return false;
10896
- }
10897
- if (typeof value1 === "string" || typeof value1 === "number" || typeof value1 === "boolean") {
10898
- return value1 === value2;
10899
- }
10900
- return value1.r === value2.r && value1.g === value2.g && value1.b === value2.b && value1.a === value2.a;
10901
- }
10902
- function isInsideScope(variable, scope) {
10903
- if (variable.scopes.includes("ALL_SCOPES")) {
10904
- return true;
10905
- }
10906
- if (variable.scopes.includes("ALL_FILLS")) {
10907
- if (scope === "FRAME_FILL" || scope === "SHAPE_FILL" || scope === "TEXT_FILL") {
10908
- return true;
10272
+ const resolvedVariable = variableRepository.findVariableById(value.id);
10273
+ if (!resolvedVariable) {
10274
+ throw new Error(`Variable not found: ${value.id}`);
10909
10275
  }
10276
+ return resolveValue(resolvedVariable, mode);
10910
10277
  }
10911
- return variable.scopes.includes(scope);
10912
- }
10913
- // public
10914
- function getVariableName(key) {
10915
- const slug = getFigmaVariableSlug(key);
10916
- return variableNameTransformer({
10917
- slug
10918
- });
10278
+ return value;
10919
10279
  }
10920
- function inferVariableName(value, scope) {
10280
+ function infer(value, scope) {
10921
10281
  // NOTE: We assume that the variable is in the default mode or value is equal between all modes for simplicity.
10922
- const inferredVariables = variables.filter((variable)=>isInsideScope(variable, scope) && isIdenticalVariableValue(resolveVariableValue(variable.id, getDefaultModeId(variable)), value));
10923
- const inferredVariableNames = inferredVariables.map((variable)=>getVariableName(variable.key));
10924
- const sortedVariableNames = inferredVariableNames.sort(inferCompareFunction);
10925
- return sortedVariableNames[0];
10282
+ const inferredVariables = variables.filter((variable)=>isInsideScope(variable, scope) && isIdenticalVariableValue(resolveValue(variable, getDefaultModeId(variable)), value));
10283
+ const sortedVariables = inferredVariables.sort(inferCompareFunction);
10284
+ return sortedVariables[0];
10926
10285
  }
10927
10286
  return {
10928
- getVariableName,
10929
- inferVariableName
10287
+ getSlug,
10288
+ resolveValue,
10289
+ infer
10930
10290
  };
10931
10291
  }
10932
10292
 
@@ -10947,2018 +10307,4 @@ function getFigmaColorVariableNames(scopes) {
10947
10307
  return variables.filter((variable)=>scopes.includes(variable.name.split("/")[0])).map((variable)=>variable.name);
10948
10308
  }
10949
10309
 
10950
- function toCssPixel(value) {
10951
- return `${value}px`;
10952
- }
10953
- function toCssRgba(color) {
10954
- if (color.a === 1) {
10955
- return `rgb(${Math.round(color.r * 255)}, ${Math.round(color.g * 255)}, ${Math.round(color.b * 255)})`;
10956
- }
10957
- return `rgba(${Math.round(color.r * 255)}, ${Math.round(color.g * 255)}, ${Math.round(color.b * 255)}, ${color.a})`;
10958
- }
10959
-
10960
- function createFrameTransformer$1({ propsTransformers }) {
10961
- return defineElementTransformer((node, traverse)=>{
10962
- const children = node.children;
10963
- const props = {
10964
- ...propsTransformers.radius(node, traverse),
10965
- ...propsTransformers.containerLayout(node, traverse),
10966
- ...propsTransformers.selfLayout(node, traverse),
10967
- ...propsTransformers.frameFill(node, traverse),
10968
- ...propsTransformers.stroke(node, traverse)
10969
- };
10970
- return createElement("Frame", props, children.map((child)=>traverse(child)));
10971
- });
10972
- }
10973
-
10974
- function createInstanceTransformer$1({ frameTransformer }) {
10975
- const transform = defineElementTransformer((node, traverse)=>{
10976
- return frameTransformer(node, traverse);
10977
- });
10978
- return transform;
10979
- }
10980
-
10981
- function createContainerLayoutPropsTransformer$1(valueTransformer) {
10982
- return createPropsTransformer({
10983
- handlers: {
10984
- layoutMode: ({ layoutMode })=>layoutMode ?? "NONE",
10985
- primaryAxisAlignItems: ({ primaryAxisAlignItems })=>primaryAxisAlignItems,
10986
- counterAxisAlignItems: ({ counterAxisAlignItems })=>counterAxisAlignItems,
10987
- layoutWrap: ({ layoutWrap })=>layoutWrap,
10988
- itemSpacing: ({ itemSpacing })=>itemSpacing,
10989
- paddingTop: (node)=>valueTransformer.getFormattedValue.paddingTop(node),
10990
- paddingBottom: (node)=>valueTransformer.getFormattedValue.paddingBottom(node),
10991
- paddingLeft: (node)=>valueTransformer.getFormattedValue.paddingLeft(node),
10992
- paddingRight: (node)=>valueTransformer.getFormattedValue.paddingRight(node)
10993
- },
10994
- shorthands: {
10995
- horizontalPadding: [
10996
- "paddingLeft",
10997
- "paddingRight"
10998
- ],
10999
- verticalPadding: [
11000
- "paddingTop",
11001
- "paddingBottom"
11002
- ]
11003
- },
11004
- defaults: {}
11005
- });
11006
- }
11007
- function createSelfLayoutPropsTransformer$1(valueTransformer) {
11008
- return createPropsTransformer({
11009
- handlers: {
11010
- layoutGrow: ({ layoutGrow })=>layoutGrow,
11011
- layoutAlign: ({ layoutAlign })=>layoutAlign,
11012
- layoutSizingVertical: ({ layoutSizingVertical })=>layoutSizingVertical,
11013
- layoutSizingHorizontal: ({ layoutSizingHorizontal })=>layoutSizingHorizontal,
11014
- width: (node)=>valueTransformer.getFormattedValue.width(node),
11015
- height: (node)=>valueTransformer.getFormattedValue.height(node),
11016
- minWidth: (node)=>valueTransformer.getFormattedValue.minWidth(node),
11017
- minHeight: (node)=>valueTransformer.getFormattedValue.minHeight(node),
11018
- maxWidth: (node)=>valueTransformer.getFormattedValue.maxWidth(node),
11019
- maxHeight: (node)=>valueTransformer.getFormattedValue.maxHeight(node)
11020
- },
11021
- defaults: {}
11022
- });
11023
- }
11024
- function createRadiusPropsTransformer$1(valueTransformer) {
11025
- return createPropsTransformer({
11026
- handlers: {
11027
- topLeftRadius: (node)=>valueTransformer.getFormattedValue.topLeftRadius(node),
11028
- topRightRadius: (node)=>valueTransformer.getFormattedValue.topRightRadius(node),
11029
- bottomLeftRadius: (node)=>valueTransformer.getFormattedValue.bottomLeftRadius(node),
11030
- bottomRightRadius: (node)=>valueTransformer.getFormattedValue.bottomRightRadius(node)
11031
- },
11032
- shorthands: {
11033
- cornerRadius: [
11034
- "topLeftRadius",
11035
- "topRightRadius",
11036
- "bottomLeftRadius",
11037
- "bottomRightRadius"
11038
- ]
11039
- },
11040
- defaults: {
11041
- cornerRadius: 0,
11042
- topLeftRadius: 0,
11043
- topRightRadius: 0,
11044
- bottomLeftRadius: 0,
11045
- bottomRightRadius: 0
11046
- }
11047
- });
11048
- }
11049
- function createFrameFillPropsTransformer$1(valueTransformer) {
11050
- return definePropsTransformer((node)=>{
11051
- const fill = valueTransformer.getFormattedValue.frameFill(node);
11052
- return {
11053
- fill
11054
- };
11055
- });
11056
- }
11057
- function createShapeFillPropsTransformer$1(valueTransformer) {
11058
- return definePropsTransformer((node)=>{
11059
- const fill = valueTransformer.getFormattedValue.shapeFill(node);
11060
- return {
11061
- fill
11062
- };
11063
- });
11064
- }
11065
- function createTextFillPropsTransformer$1(valueTransformer) {
11066
- return definePropsTransformer((node)=>{
11067
- const fill = valueTransformer.getFormattedValue.textFill(node);
11068
- return {
11069
- fill
11070
- };
11071
- });
11072
- }
11073
- function createStrokePropsTransformer$1(valueTransformer) {
11074
- return definePropsTransformer((node)=>{
11075
- const stroke = valueTransformer.getFormattedValue.stroke(node);
11076
- const strokeWeight = node.strokeWeight;
11077
- return {
11078
- stroke,
11079
- strokeWeight
11080
- };
11081
- });
11082
- }
11083
- function createTypeStylePropsTransformer$1({ valueTransformer, styleService }) {
11084
- return definePropsTransformer((node)=>{
11085
- const styleName = node.textStyleKey ? styleService.getStyleName(node.textStyleKey) : undefined;
11086
- const maxLines = node.style.textTruncation === "ENDING" ? node.style.maxLines ?? undefined : undefined;
11087
- if (styleName) {
11088
- return {
11089
- textStyle: styleName,
11090
- maxLines
11091
- };
11092
- }
11093
- return {
11094
- fontSize: valueTransformer.getFormattedValue.fontSize(node),
11095
- fontWeight: valueTransformer.getFormattedValue.fontWeight(node),
11096
- lineHeight: valueTransformer.getFormattedValue.lineHeight(node),
11097
- maxLines
11098
- };
11099
- });
11100
- }
11101
-
11102
- function createRectangleTransformer$1({ propsTransformers }) {
11103
- return defineElementTransformer((node, traverse)=>{
11104
- return createElement("Rectangle", {
11105
- ...propsTransformers.selfLayout(node, traverse)
11106
- });
11107
- });
11108
- }
11109
- function createVectorTransformer$1({ propsTransformers }) {
11110
- return defineElementTransformer((node, traverse)=>{
11111
- return createElement("Vector", {
11112
- ...propsTransformers.selfLayout(node, traverse),
11113
- ...propsTransformers.radius(node, traverse),
11114
- ...propsTransformers.stroke(node, traverse),
11115
- ...propsTransformers.shapeFill(node, traverse)
11116
- }, [], "Vector Node Placeholder");
11117
- });
11118
- }
11119
- function createBooleanOperationTransformer$1({ propsTransformers }) {
11120
- return defineElementTransformer((node, traverse)=>{
11121
- return createElement("BooleanOperation", {
11122
- ...propsTransformers.selfLayout(node, traverse),
11123
- ...propsTransformers.radius(node, traverse),
11124
- ...propsTransformers.stroke(node, traverse),
11125
- ...propsTransformers.shapeFill(node, traverse)
11126
- }, node.children.map(traverse));
11127
- });
11128
- }
11129
-
11130
- function createTextTransformer$1({ propsTransformers }) {
11131
- return defineElementTransformer((node, traverse)=>{
11132
- const hasMultipleFills = node.fills.length > 1;
11133
- const fillProps = propsTransformers.textFill(node, traverse);
11134
- const typeStyleProps = propsTransformers.typeStyle(node, traverse);
11135
- const props = compactObject({
11136
- ...typeStyleProps,
11137
- ...fillProps
11138
- });
11139
- return createElement("Text", props, node.characters, hasMultipleFills ? "Multiple fills in Text node encountered, only the first fill is used." : "");
11140
- });
11141
- }
11142
-
11143
- const styleService$1 = createStyleService({
11144
- styleRepository,
11145
- styleNameTransformer: ({ slug })=>slug[slug.length - 1]
11146
- });
11147
- const variableService$1 = createVariableService({
11148
- variableRepository,
11149
- variableNameTransformer: ({ slug })=>slug.filter((s)=>s !== "dimension").map((s)=>s.replaceAll(",", "_")).join("/"),
11150
- inferCompareFunction: (name1, name2)=>{
11151
- const scoreFn = (name)=>{
11152
- let score = 0;
11153
- if (name.includes("bg")) {
11154
- score += 100;
11155
- }
11156
- if (name.includes("fg")) {
11157
- score += 100;
11158
- }
11159
- if (name.includes("stroke")) {
11160
- score += 100;
11161
- }
11162
- if (name.includes("spacing-x")) {
11163
- score -= 100;
11164
- }
11165
- if (name.includes("spacing-y")) {
11166
- score -= 100;
11167
- }
11168
- if (name.endsWith("pressed")) {
11169
- score -= 100;
11170
- }
11171
- return score;
11172
- };
11173
- return scoreFn(name2) - scoreFn(name1);
11174
- }
11175
- });
11176
- function createContext$1(options) {
11177
- const { shouldInferVariableName, shouldInferAutoLayout } = options;
11178
- const valueTransformer = createValueTransformer({
11179
- variableService: variableService$1,
11180
- formatters: {
11181
- color: (value)=>toCssRgba(value),
11182
- dimension: (value)=>value,
11183
- fontDimension: (value)=>value,
11184
- fontWeight: (value)=>value
11185
- },
11186
- shouldInferVariableName
11187
- });
11188
- const containerLayoutPropsTransformer = createContainerLayoutPropsTransformer$1(valueTransformer);
11189
- const selfLayoutPropsTransformer = createSelfLayoutPropsTransformer$1(valueTransformer);
11190
- const frameFillPropsTransformer = createFrameFillPropsTransformer$1(valueTransformer);
11191
- const shapeFillPropsTransformer = createShapeFillPropsTransformer$1(valueTransformer);
11192
- const textFillPropsTransformer = createTextFillPropsTransformer$1(valueTransformer);
11193
- const radiusPropsTransformer = createRadiusPropsTransformer$1(valueTransformer);
11194
- const strokePropsTransformer = createStrokePropsTransformer$1(valueTransformer);
11195
- const typeStylePropsTransformer = createTypeStylePropsTransformer$1({
11196
- valueTransformer,
11197
- styleService: styleService$1
11198
- });
11199
- const propsTransformers = {
11200
- containerLayout: containerLayoutPropsTransformer,
11201
- selfLayout: selfLayoutPropsTransformer,
11202
- frameFill: frameFillPropsTransformer,
11203
- shapeFill: shapeFillPropsTransformer,
11204
- textFill: textFillPropsTransformer,
11205
- radius: radiusPropsTransformer,
11206
- stroke: strokePropsTransformer,
11207
- typeStyle: typeStylePropsTransformer
11208
- };
11209
- const frameTransformer = createFrameTransformer$1({
11210
- propsTransformers
11211
- });
11212
- const instanceTransformer = createInstanceTransformer$1({
11213
- frameTransformer
11214
- });
11215
- const textTransformer = createTextTransformer$1({
11216
- propsTransformers
11217
- });
11218
- const rectangleTransformer = createRectangleTransformer$1({
11219
- propsTransformers
11220
- });
11221
- const vectorTransformer = createVectorTransformer$1({
11222
- propsTransformers
11223
- });
11224
- const booleanOperationTransformer = createBooleanOperationTransformer$1({
11225
- propsTransformers
11226
- });
11227
- const codegenTransformer = createCodegenTransformer({
11228
- frameTransformer,
11229
- textTransformer,
11230
- rectangleTransformer,
11231
- instanceTransformer,
11232
- vectorTransformer,
11233
- booleanOperationTransformer,
11234
- shouldInferAutoLayout
11235
- });
11236
- return codegenTransformer;
11237
- }
11238
-
11239
- var index$1 = {
11240
- __proto__: null,
11241
- createBooleanOperationTransformer: createBooleanOperationTransformer$1,
11242
- createContainerLayoutPropsTransformer: createContainerLayoutPropsTransformer$1,
11243
- createContext: createContext$1,
11244
- createFrameFillPropsTransformer: createFrameFillPropsTransformer$1,
11245
- createFrameTransformer: createFrameTransformer$1,
11246
- createInstanceTransformer: createInstanceTransformer$1,
11247
- createRadiusPropsTransformer: createRadiusPropsTransformer$1,
11248
- createRectangleTransformer: createRectangleTransformer$1,
11249
- createSelfLayoutPropsTransformer: createSelfLayoutPropsTransformer$1,
11250
- createShapeFillPropsTransformer: createShapeFillPropsTransformer$1,
11251
- createStrokePropsTransformer: createStrokePropsTransformer$1,
11252
- createTextFillPropsTransformer: createTextFillPropsTransformer$1,
11253
- createTextTransformer: createTextTransformer$1,
11254
- createTypeStylePropsTransformer: createTypeStylePropsTransformer$1,
11255
- createVectorTransformer: createVectorTransformer$1
11256
- };
11257
-
11258
- function createContainerLayoutPropsTransformer(valueTransformer) {
11259
- return createPropsTransformer({
11260
- handlers: {
11261
- direction: ({ layoutMode })=>match(layoutMode).with("HORIZONTAL", ()=>"row").with("VERTICAL", ()=>"column").with("NONE", ()=>undefined).with(undefined, ()=>undefined).exhaustive(),
11262
- justify: ({ primaryAxisAlignItems })=>match(primaryAxisAlignItems).with("MIN", ()=>"flex-start").with("CENTER", ()=>"center").with("MAX", ()=>"flex-end").with("SPACE_BETWEEN", ()=>"space-between").with(undefined, ()=>undefined).exhaustive(),
11263
- align: ({ counterAxisAlignItems, children })=>{
11264
- const isStretch = children.every((child)=>{
11265
- if (!("layoutAlign" in child)) {
11266
- return false;
11267
- }
11268
- return child.layoutAlign === "STRETCH";
11269
- });
11270
- if (isStretch) {
11271
- return "stretch";
11272
- }
11273
- return match(counterAxisAlignItems).with("MIN", ()=>"flex-start").with("CENTER", ()=>"center").with("MAX", ()=>"flex-end").with("BASELINE", ()=>"baseline").with(undefined, ()=>undefined).exhaustive();
11274
- },
11275
- wrap: ({ layoutWrap })=>match(layoutWrap).with("WRAP", ()=>true).with("NO_WRAP", ()=>"nowrap").with(undefined, ()=>undefined).exhaustive(),
11276
- gap: (node)=>{
11277
- if (node.children.length <= 1) {
11278
- return undefined;
11279
- }
11280
- if (node.primaryAxisAlignItems === "SPACE_BETWEEN") {
11281
- return undefined;
11282
- }
11283
- return valueTransformer.getFormattedValue.itemSpacing(node);
11284
- },
11285
- pt: (node)=>valueTransformer.getFormattedValue.paddingTop(node),
11286
- pb: (node)=>valueTransformer.getFormattedValue.paddingBottom(node),
11287
- pl: (node)=>valueTransformer.getFormattedValue.paddingLeft(node),
11288
- pr: (node)=>valueTransformer.getFormattedValue.paddingRight(node)
11289
- },
11290
- shorthands: {
11291
- p: [
11292
- "pt",
11293
- "pb",
11294
- "pl",
11295
- "pr"
11296
- ],
11297
- px: [
11298
- "pl",
11299
- "pr"
11300
- ],
11301
- py: [
11302
- "pt",
11303
- "pb"
11304
- ]
11305
- },
11306
- defaults: {
11307
- justify: "flex-start",
11308
- align: "stretch",
11309
- wrap: "nowrap",
11310
- gap: 0,
11311
- p: 0,
11312
- px: 0,
11313
- py: 0,
11314
- pb: 0,
11315
- pl: 0,
11316
- pr: 0,
11317
- pt: 0
11318
- }
11319
- });
11320
- }
11321
- function createSelfLayoutPropsTransformer(valueTransformer) {
11322
- return createPropsTransformer({
11323
- handlers: {
11324
- grow: ({ layoutGrow })=>layoutGrow === 1 ? true : layoutGrow,
11325
- alignSelf: ({ layoutAlign })=>match(layoutAlign).with("STRETCH", ()=>"stretch").with("INHERIT", ()=>undefined).with("MIN", ()=>undefined) // Deprecated in Figma
11326
- .with("CENTER", ()=>undefined) // Deprecated in Figma
11327
- .with("MAX", ()=>undefined) // Deprecated in Figma
11328
- .with(undefined, ()=>undefined).exhaustive(),
11329
- height: (node)=>node.layoutSizingVertical === "FIXED" ? valueTransformer.getFormattedValue.height(node) : undefined,
11330
- width: (node)=>node.layoutSizingHorizontal === "FIXED" ? valueTransformer.getFormattedValue.width(node) : undefined,
11331
- minHeight: (node)=>node.layoutSizingVertical === "HUG" ? valueTransformer.getFormattedValue.minHeight(node) : undefined,
11332
- maxHeight: (node)=>node.layoutSizingVertical === "HUG" ? valueTransformer.getFormattedValue.maxHeight(node) : undefined,
11333
- minWidth: (node)=>node.layoutSizingHorizontal === "HUG" ? valueTransformer.getFormattedValue.minWidth(node) : undefined,
11334
- maxWidth: (node)=>node.layoutSizingHorizontal === "HUG" ? valueTransformer.getFormattedValue.maxWidth(node) : undefined
11335
- },
11336
- defaults: {
11337
- grow: 0
11338
- }
11339
- });
11340
- }
11341
- function createIconSelfLayoutPropsTransformer(valueTransformer) {
11342
- return createPropsTransformer({
11343
- handlers: {
11344
- size: (node)=>valueTransformer.getFormattedValue.width(node)
11345
- }
11346
- });
11347
- }
11348
- function createRadiusPropsTransformer(valueTransformer) {
11349
- return createPropsTransformer({
11350
- handlers: {
11351
- borderTopLeftRadius: (node)=>valueTransformer.getFormattedValue.topLeftRadius(node),
11352
- borderTopRightRadius: (node)=>valueTransformer.getFormattedValue.topRightRadius(node),
11353
- borderBottomLeftRadius: (node)=>valueTransformer.getFormattedValue.bottomLeftRadius(node),
11354
- borderBottomRightRadius: (node)=>valueTransformer.getFormattedValue.bottomRightRadius(node)
11355
- },
11356
- shorthands: {
11357
- borderRadius: [
11358
- "borderTopLeftRadius",
11359
- "borderTopRightRadius",
11360
- "borderBottomLeftRadius",
11361
- "borderBottomRightRadius"
11362
- ]
11363
- },
11364
- defaults: {
11365
- borderRadius: 0,
11366
- borderTopLeftRadius: 0,
11367
- borderTopRightRadius: 0,
11368
- borderBottomLeftRadius: 0,
11369
- borderBottomRightRadius: 0
11370
- }
11371
- });
11372
- }
11373
- function createTypeStylePropsTransformer({ valueTransformer, styleService }) {
11374
- return definePropsTransformer((node)=>{
11375
- const styleName = node.textStyleKey ? styleService.getStyleName(node.textStyleKey) : undefined;
11376
- const maxLines = node.style.textTruncation === "ENDING" ? node.style.maxLines ?? undefined : undefined;
11377
- if (styleName) {
11378
- return {
11379
- textStyle: styleName,
11380
- maxLines
11381
- };
11382
- }
11383
- return {
11384
- fontSize: valueTransformer.getFormattedValue.fontSize(node),
11385
- fontWeight: valueTransformer.getFormattedValue.fontWeight(node),
11386
- lineHeight: valueTransformer.getFormattedValue.lineHeight(node),
11387
- maxLines
11388
- };
11389
- });
11390
- }
11391
- function createFrameFillPropsTransformer(valueTransformer) {
11392
- return definePropsTransformer((node)=>{
11393
- const bg = valueTransformer.getFormattedValue.frameFill(node);
11394
- return {
11395
- bg
11396
- };
11397
- });
11398
- }
11399
- function createShapeFillPropsTransformer(valueTransformer) {
11400
- return definePropsTransformer((node)=>{
11401
- const color = valueTransformer.getFormattedValue.shapeFill(node);
11402
- return {
11403
- color
11404
- };
11405
- });
11406
- }
11407
- function createTextFillPropsTransformer(valueTransformer) {
11408
- return definePropsTransformer((node)=>{
11409
- const color = valueTransformer.getFormattedValue.textFill(node);
11410
- return {
11411
- color
11412
- };
11413
- });
11414
- }
11415
- function createStrokePropsTransformer(valueTransformer) {
11416
- return definePropsTransformer((node)=>{
11417
- const borderColor = valueTransformer.getFormattedValue.stroke(node);
11418
- const borderWidth = borderColor ? node.strokeWeight : undefined;
11419
- return {
11420
- borderColor,
11421
- borderWidth
11422
- };
11423
- });
11424
- }
11425
-
11426
- function createRectangleTransformer({ propsTransformers }) {
11427
- return defineElementTransformer((node, traverse)=>{
11428
- return createElement("Box", {
11429
- ...propsTransformers.selfLayout(node, traverse),
11430
- background: "palette.gray200"
11431
- }, undefined, "Rectangle Node Placeholder");
11432
- });
11433
- }
11434
- function createVectorTransformer() {
11435
- return defineElementTransformer(()=>{
11436
- return createElement("svg", {}, [], "Vector Node Placeholder");
11437
- });
11438
- }
11439
- function createBooleanOperationTransformer() {
11440
- return defineElementTransformer(()=>{
11441
- return createElement("svg", {}, [], "Boolean Operation Node Placeholder");
11442
- });
11443
- }
11444
-
11445
- function createFrameTransformer({ propsTransformers }) {
11446
- function inferLayoutComponent(props, isFlex) {
11447
- if (!isFlex) {
11448
- return "Box";
11449
- }
11450
- if (props.direction === "column") {
11451
- return "VStack";
11452
- }
11453
- return "HStack";
11454
- }
11455
- return defineElementTransformer((node, traverse)=>{
11456
- const children = node.children;
11457
- const transformedChildren = children.map(traverse);
11458
- const isFlex = node.layoutMode === "HORIZONTAL" || node.layoutMode === "VERTICAL";
11459
- const props = {
11460
- ...propsTransformers.radius(node, traverse),
11461
- ...isFlex ? propsTransformers.containerLayout(node, traverse) : {},
11462
- ...propsTransformers.selfLayout(node, traverse),
11463
- ...propsTransformers.frameFill(node, traverse),
11464
- ...propsTransformers.stroke(node, traverse)
11465
- };
11466
- const isStretch = props.align === undefined || props.align === "stretch";
11467
- const processedChildren = isStretch ? transformedChildren.map((child)=>child ? cloneElement(child, {
11468
- alignSelf: undefined
11469
- }) : child) : transformedChildren;
11470
- const layoutComponent = inferLayoutComponent(props, isFlex);
11471
- if (layoutComponent === "VStack") {
11472
- const { direction, ...rest } = props;
11473
- return createElement("VStack", rest, processedChildren);
11474
- }
11475
- if (layoutComponent === "HStack") {
11476
- const { direction, ...rest } = props;
11477
- return createElement("HStack", rest, processedChildren);
11478
- }
11479
- if (layoutComponent === "Box") {
11480
- return createElement("Box", props, processedChildren);
11481
- }
11482
- });
11483
- }
11484
-
11485
- function createInstanceTransformer({ iconService, ignoredComponentKeys, propsTransformers, componentTransformers, frameTransformer }) {
11486
- const transformIconColorProps = definePropsTransformer((node, traverse)=>{
11487
- if (node.children.length === 0) {
11488
- throw new Error("Node has no children");
11489
- }
11490
- const vectors = node.children.filter((child)=>child.type === "VECTOR" || child.type === "BOOLEAN_OPERATION");
11491
- const colorProps = vectors.map((vector)=>propsTransformers.shapeFill(vector, traverse));
11492
- const fills = new Set(colorProps.map((props)=>props.color).filter((color)=>color !== undefined));
11493
- // If there are more than 1 color, colors are likely pre-defined in the icon component; we should ignore the color prop.
11494
- if (fills.size > 1) {
11495
- return {};
11496
- }
11497
- return {
11498
- color: fills.values().next().value
11499
- };
11500
- });
11501
- const transform = defineElementTransformer((node, traverse)=>{
11502
- const { componentKey, componentSetKey } = node;
11503
- if (ignoredComponentKeys?.has(componentKey)) {
11504
- return undefined;
11505
- }
11506
- if (iconService?.isIconComponent(componentKey)) {
11507
- const tagName = iconService.createIconTagName(componentKey);
11508
- const props = {
11509
- ...propsTransformers.iconSelfLayout(node, traverse),
11510
- ...transformIconColorProps(node, traverse)
11511
- };
11512
- return createElement("Icon", {
11513
- svg: createElement(tagName),
11514
- ...props
11515
- });
11516
- }
11517
- const componentTransformer = componentSetKey ? componentTransformers[componentSetKey] : componentTransformers[componentKey];
11518
- if (componentTransformer) {
11519
- return componentTransformer.transform(node);
11520
- }
11521
- return frameTransformer(node, traverse);
11522
- });
11523
- return transform;
11524
- }
11525
-
11526
- function createTextTransformer({ propsTransformers }) {
11527
- return defineElementTransformer((node, traverse)=>{
11528
- const hasMultipleFills = node.fills.length > 1;
11529
- const fillProps = propsTransformers.textFill(node, traverse);
11530
- const typeStyleProps = propsTransformers.typeStyle(node, traverse);
11531
- const props = compactObject({
11532
- ...typeStyleProps,
11533
- ...fillProps
11534
- });
11535
- return createElement("Text", props, node.characters.replace(/\n/g, "<br />"), hasMultipleFills ? "Multiple fills in Text node encountered, only the first fill is used." : "");
11536
- });
11537
- }
11538
-
11539
- const metadata$v = {
11540
- "key": "a3d58bb8540600878742cdcf2608a4b3851667ec"};
11541
-
11542
- const metadata$u = {
11543
- "key": "450ede9d0bf42fc6ef14345c77e6e407d6d5ee89"};
11544
-
11545
- const metadata$t = {
11546
- "key": "3d21594ef116e94a9465d507447b858aea062575"};
11547
-
11548
- const metadata$s = {
11549
- "key": "7c29b70b7e71618e1894c26f61f336de2730d76e"};
11550
-
11551
- const metadata$r = {
11552
- "key": "d71644aeba2e29deda366798fdfe35977166d120"};
11553
-
11554
- const metadata$q = {
11555
- "key": "019467fdad2192abb48699dcfb79e344df04b799"};
11556
-
11557
- const metadata$p = {
11558
- "key": "04609a35d47a1a0ef4904b3c25f79451892a85a1"};
11559
-
11560
- const metadata$o = {
11561
- "key": "ec46d38baac3c367c4a5ffa47a2110d51ba0a4fe"};
11562
-
11563
- const metadata$n = {
11564
- "key": "94a2f6957a86f8ae3b8c7ca200dfcd5e29f6075b"};
11565
-
11566
- const metadata$m = {
11567
- "key": "d098159beacf7713e9116f0ef38d8a20f64ec84f"};
11568
-
11569
- const metadata$l = {
11570
- "key": "5780d56fc2f9bc4bbd6bc3db93949d8a8b7b7563"};
11571
-
11572
- const metadata$k = {
11573
- "key": "39b4ecd0b5b4d35f4dc5791765ca04aa062a5172"};
11574
-
11575
- const metadata$j = {
11576
- "key": "cd4cf8a850bf3de87b79080b36b421a649bf3fcb"};
11577
-
11578
- const metadata$i = {
11579
- "key": "032f3fddaad0aa3fa5a7f680768c1f5d02fb463f"};
11580
-
11581
- const metadata$h = {
11582
- "key": "1974b94703032585bb9e20bd54743e01094b965c"};
11583
-
11584
- const metadata$g = {
11585
- "key": "804b327c091278a40d5891939eaed90bb2889659"};
11586
-
11587
- const metadata$f = {
11588
- "key": "808206c07408aa1056ec85a55925e9844e9265c2"};
11589
-
11590
- const metadata$e = {
11591
- "key": "ce587d0f21754af05240cb32a4880227cb0ea1e1"};
11592
-
11593
- const metadata$d = {
11594
- "key": "ac5331cec7a2c75b671df5b85ef247dfd820dd2f"};
11595
-
11596
- const metadata$c = {
11597
- "key": "88b2399c930c85f9ce2972163a078bc684b84bbe"};
11598
-
11599
- const metadata$b = {
11600
- "key": "6e6779a372cab2485a0e25529bc4dbc9932a7346"};
11601
-
11602
- const metadata$a = {
11603
- "key": "ec43e4e881f7048e95601f8b58c01a0905a174e0"};
11604
-
11605
- const metadata$9 = {
11606
- "key": "3ad7133ba52755867f42f9232375f75639e00d58"};
11607
-
11608
- const metadata$8 = {
11609
- "key": "38722ffeb4c966256a709155e8ddac50c93d7c60"};
11610
-
11611
- const metadata$7 = {
11612
- "key": "ef22c3288722fbfa64a5ab73df397ade88f8e05a"};
11613
-
11614
- const metadata$6 = {
11615
- "key": "81b17fb8c7d731a19cf8d36a8605559d41414eca"};
11616
-
11617
- const metadata$5 = {
11618
- "key": "c07bfe331cf214375fce9ad47cb6fdb459d1fb1b"};
11619
-
11620
- const metadata$4 = {
11621
- "key": "80ce5a33b5ab713ab3bd2449472e2fb13d78c7f3"};
11622
-
11623
- const metadata$3 = {
11624
- "key": "ffe33411fb8796f7a95d3637b90150007f0dd954"};
11625
-
11626
- const metadata$2 = {
11627
- "key": "601f788792916250e33d04bd3165dee1404342df"};
11628
-
11629
- const metadata$1 = {
11630
- "key": "c49873c37a639f0dffdea4efd0eb43760d66c141"};
11631
-
11632
- const metadata = {
11633
- "key": "1d240ee5fd7a56879713e69cbea1b6f006f0ea22"};
11634
-
11635
- // TODO: move this file to relevant directory
11636
- function handleSizeProp(size) {
11637
- switch(size){
11638
- case "XSmall":
11639
- return "xsmall";
11640
- case "Small":
11641
- return "small";
11642
- case "Medium":
11643
- return "medium";
11644
- case "Large":
11645
- return "large";
11646
- case "XLarge":
11647
- return "xlarge";
11648
- default:
11649
- return camelCase(size);
11650
- }
11651
- }
11652
-
11653
- const createActionButtonTransformer = (ctx)=>defineComponentTransformer(metadata$u.key, ({ componentProperties: props })=>{
11654
- const states = props.State.value.split("-");
11655
- const { layout, children } = match(props.Layout.value).with("Icon Only", ()=>({
11656
- layout: "iconOnly",
11657
- children: [
11658
- createElement("Icon", {
11659
- svg: createElement(ctx.iconService.createIconTagName(props["Icon#7574:0"].componentKey))
11660
- })
11661
- ]
11662
- })).with("Icon First", ()=>({
11663
- layout: "withText",
11664
- children: [
11665
- createElement("PrefixIcon", {
11666
- svg: createElement(ctx.iconService.createIconTagName(props["Prefix Icon#5987:305"].componentKey))
11667
- }),
11668
- props["Label#5987:61"].value
11669
- ]
11670
- })).with("Icon Last", ()=>({
11671
- layout: "withText",
11672
- children: [
11673
- props["Label#5987:61"].value,
11674
- createElement("SuffixIcon", {
11675
- svg: createElement(ctx.iconService.createIconTagName(props["Suffix Icon#5987:244"].componentKey))
11676
- })
11677
- ]
11678
- })).with("Text Only", ()=>({
11679
- layout: "withText",
11680
- children: props["Label#5987:61"].value
11681
- })).exhaustive();
11682
- const commonProps = {
11683
- ...states.includes("Disabled") && {
11684
- disabled: true
11685
- },
11686
- ...states.includes("Loading") && {
11687
- loading: true
11688
- },
11689
- size: handleSizeProp(props.Size.value),
11690
- variant: camelCase(props.Variant.value),
11691
- layout
11692
- };
11693
- return createElement("ActionButton", commonProps, children);
11694
- });
11695
-
11696
- const createActionChipTransformer = (ctx)=>defineComponentTransformer(metadata$t.key, ({ componentProperties: props })=>{
11697
- const states = props.State.value.split("-");
11698
- const { layout, children } = match(props.Layout.value).with("Icon Only", ()=>({
11699
- layout: "iconOnly",
11700
- children: [
11701
- createElement("Icon", {
11702
- svg: createElement(ctx.iconService.createIconTagName(props["Icon#8714:0"].componentKey))
11703
- })
11704
- ]
11705
- })).with("Icon First", ()=>({
11706
- layout: "withText",
11707
- children: [
11708
- createElement("PrefixIcon", {
11709
- svg: createElement(ctx.iconService.createIconTagName(props["Prefix Icon#8711:0"].componentKey))
11710
- }),
11711
- props["Label#7185:0"].value
11712
- ]
11713
- })).with("Icon Last", ()=>({
11714
- layout: "withText",
11715
- children: [
11716
- props["Label#7185:0"].value,
11717
- createElement("SuffixIcon", {
11718
- svg: createElement(ctx.iconService.createIconTagName(props["Suffix Icon#8711:3"].componentKey))
11719
- })
11720
- ]
11721
- })).with("Icon Both", ()=>({
11722
- layout: "withText",
11723
- children: [
11724
- createElement("PrefixIcon", {
11725
- svg: createElement(ctx.iconService.createIconTagName(props["Prefix Icon#8711:0"].componentKey))
11726
- }),
11727
- props["Label#7185:0"].value,
11728
- createElement("SuffixIcon", {
11729
- svg: createElement(ctx.iconService.createIconTagName(props["Suffix Icon#8711:3"].componentKey))
11730
- })
11731
- ]
11732
- })).with("Text Only", ()=>({
11733
- layout: "withText",
11734
- children: props["Label#7185:0"].value
11735
- })).exhaustive();
11736
- const commonProps = {
11737
- size: handleSizeProp(props.Size.value),
11738
- layout,
11739
- ...states.includes("Disabled") && {
11740
- disabled: true
11741
- },
11742
- ...props["Show Count#7185:42"].value && {
11743
- count: Number(props["Count#7185:21"].value)
11744
- }
11745
- };
11746
- return createElement("ActionChip", commonProps, children);
11747
- });
11748
-
11749
- const ACTION_SHEET_ITEM_KEY = "c3cafd3a3fdcd45fecb6971019d88eaf39a2e381";
11750
- const createActionSheetItemTransformer = (_ctx)=>defineComponentTransformer(ACTION_SHEET_ITEM_KEY, ({ componentProperties: props })=>{
11751
- const states = props.State.value.split("-");
11752
- const commonProps = {
11753
- label: props["Label#15420:4"].value,
11754
- tone: camelCase(props.Tone.value),
11755
- ...states.includes("Disabled") && {
11756
- disabled: true
11757
- }
11758
- };
11759
- return createElement("ActionSheetItem", commonProps);
11760
- });
11761
- const createActionSheetTransformer = (ctx)=>{
11762
- const actionSheetItemTransformer = createActionSheetItemTransformer();
11763
- return defineComponentTransformer(metadata$s.key, (node)=>{
11764
- const { componentProperties: props } = node;
11765
- const contentProps = match(props.Header.value).with("None", ()=>({
11766
- title: undefined,
11767
- description: undefined
11768
- })).with("Title Only", ()=>({
11769
- title: props["Title#15641:37"].value,
11770
- description: undefined
11771
- })).with("Description Only", ()=>({
11772
- title: undefined,
11773
- description: props["Description#15641:70"].value
11774
- })).with("Title With Description", ()=>({
11775
- title: props["Title#15641:37"].value,
11776
- description: props["Description#15641:70"].value
11777
- })).exhaustive();
11778
- const items = findAllInstances({
11779
- node,
11780
- key: actionSheetItemTransformer.key
11781
- });
11782
- const contentChildren = items.map(actionSheetItemTransformer.transform);
11783
- const content = createElement("ActionSheetContent", contentProps, contentChildren, contentProps.title ? "" : "title을 제공하지 않는 경우 aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.");
11784
- const trigger = createElement("ActionSheetTrigger", {
11785
- asChild: true
11786
- }, createElement("ActionButton", undefined, "열기", "ActionSheet을 여는 요소를 제공해주세요."));
11787
- return createElement("ActionSheet", undefined, [
11788
- trigger,
11789
- content
11790
- ]);
11791
- });
11792
- };
11793
-
11794
- const APP_BAR_MAIN_KEY = "336b49b26c3933485d87cc460b06c390976ea58e";
11795
- const createAppBarMainTransformer = (_ctx)=>defineComponentTransformer(APP_BAR_MAIN_KEY, ({ componentProperties: props })=>{
11796
- const { title, subtitle, layout } = match(props.Type.value).with("Title", ()=>({
11797
- title: props["Title#16944:0"].value,
11798
- subtitle: undefined,
11799
- layout: undefined
11800
- })).with("Title-Subtitle", ()=>({
11801
- title: props["Title#16944:0"].value,
11802
- subtitle: props["Subtitle#16958:9"].value,
11803
- layout: "withSubtitle"
11804
- })).otherwise(()=>({
11805
- title: undefined,
11806
- subtitle: undefined,
11807
- layout: undefined
11808
- }));
11809
- const commonProps = {
11810
- title,
11811
- subtitle,
11812
- layout
11813
- };
11814
- return createElement("AppBarMain", commonProps, undefined, title === undefined ? "Title을 제공해주세요." : undefined);
11815
- });
11816
- const APP_BAR_LEFT_KEY = "e5d2e47052a22395db79f195a0991a570dc1b6c9";
11817
- const createAppBarLeftTransformer = (ctx)=>defineComponentTransformer(APP_BAR_LEFT_KEY, (node)=>{
11818
- const props = node.componentProperties;
11819
- const children = (()=>{
11820
- switch(props.Action.value){
11821
- case "Back":
11822
- return createElement("AppBarBackButton", undefined);
11823
- case "Close":
11824
- return createElement("AppBarCloseButton", undefined);
11825
- case "Other":
11826
- {
11827
- const iconNode = findOne(node, (child)=>child.type === "INSTANCE" && child.name === "Icon");
11828
- const iconComponentKey = iconNode?.componentKey ?? undefined;
11829
- return createElement("AppBarIconButton", undefined, iconComponentKey ? createElement(ctx.iconService.createIconTagName(iconComponentKey)) : undefined, iconComponentKey === undefined ? "아이콘과, aria-label 또는 aria-labelledby를 제공해주세요." : "aria-label 또는 aria-labelledby를 제공해주세요.");
11830
- }
11831
- }
11832
- })();
11833
- return createElement("AppBarLeft", undefined, children);
11834
- });
11835
- const APP_BAR_RIGHT_KEY = "9e157fc2d1f89ffee938a5bc62f4a58064fec44e";
11836
- const createAppBarRightTransformer = (ctx)=>defineComponentTransformer(APP_BAR_RIGHT_KEY, (node)=>{
11837
- const props = node.componentProperties;
11838
- const children = (()=>{
11839
- switch(props.Type.value){
11840
- case "1 Text":
11841
- {
11842
- const textNode = findOne(node, (child)=>child.type === "TEXT");
11843
- return textNode?.characters;
11844
- }
11845
- default:
11846
- {
11847
- const iconNodes = findAll(node, (child)=>child.type === "INSTANCE" && child.name === "Icon");
11848
- const iconComponentKeys = iconNodes.map((iconNode)=>iconNode.componentKey);
11849
- return iconComponentKeys.map((iconComponentKey)=>createElement("AppBarIconButton", undefined, iconComponentKey ? createElement(ctx.iconService.createIconTagName(iconComponentKey)) : undefined, iconComponentKey === undefined ? "아이콘과, aria-label 또는 aria-labelledby를 제공해주세요." : "aria-label 또는 aria-labelledby를 제공해주세요."));
11850
- }
11851
- }
11852
- })();
11853
- return createElement("AppBarRight", undefined, children);
11854
- });
11855
- const createAppBarTransformer = (ctx)=>{
11856
- const appBarMainTransformer = createAppBarMainTransformer();
11857
- const appBarLeftTransformer = createAppBarLeftTransformer(ctx);
11858
- const appBarRightTransformer = createAppBarRightTransformer(ctx);
11859
- return defineComponentTransformer(metadata$5.key, (node)=>{
11860
- const props = node.componentProperties;
11861
- const theme = (()=>{
11862
- switch(props.OS.value){
11863
- case "Android":
11864
- return "android";
11865
- case "iOS":
11866
- return "cupertino";
11867
- }
11868
- })();
11869
- const tone = (()=>{
11870
- switch(props.Variant.value){
11871
- case "Layer Default":
11872
- return "layer";
11873
- case "Transparent":
11874
- return "transparent";
11875
- }
11876
- })();
11877
- const mainNode = findAllInstances({
11878
- key: appBarMainTransformer.key,
11879
- node
11880
- });
11881
- const onlyMainNode = mainNode.length === 1 ? mainNode[0] : undefined;
11882
- const main = onlyMainNode ? appBarMainTransformer.transform(onlyMainNode) : undefined;
11883
- const leftNode = findAllInstances({
11884
- key: appBarLeftTransformer.key,
11885
- node
11886
- });
11887
- const onlyLeftNode = leftNode.length === 1 ? leftNode[0] : undefined;
11888
- const left = onlyLeftNode ? appBarLeftTransformer.transform(onlyLeftNode) : undefined;
11889
- const rightNode = findAllInstances({
11890
- key: appBarRightTransformer.key,
11891
- node
11892
- });
11893
- const onlyRightNode = rightNode.length === 1 ? rightNode[0] : undefined;
11894
- const right = onlyRightNode ? appBarRightTransformer.transform(onlyRightNode) : undefined;
11895
- return createElement("AppBar", {
11896
- theme,
11897
- tone
11898
- }, [
11899
- left,
11900
- main,
11901
- right
11902
- ].filter(Boolean), tone === "transparent" ? `<AppScreen layerOffsetTop="none">으로 상단 패딩을 제거할 수 있습니다.` : undefined);
11903
- });
11904
- };
11905
-
11906
- const createIdentityPlaceholderTransformer = (_ctx)=>defineComponentTransformer(metadata$f.key, ({ componentProperties: props })=>{
11907
- const commonProps = {
11908
- identity: camelCase(props.Identity.value)
11909
- };
11910
- return createElement("IdentityPlaceholder", commonProps);
11911
- });
11912
-
11913
- const createAvatarTransformer = (ctx)=>{
11914
- const identityPlaceholderTransformer = createIdentityPlaceholderTransformer();
11915
- return defineComponentTransformer(metadata$r.key, (node)=>{
11916
- const [placeholder] = findAllInstances({
11917
- node,
11918
- key: identityPlaceholderTransformer.key
11919
- });
11920
- const { componentProperties: props } = node;
11921
- const avatarHasSrc = props["Show Image#71850:57"].value;
11922
- const commonProps = {
11923
- ...avatarHasSrc && {
11924
- // Placeholder
11925
- src: `https://placehold.co/${props.Size.value}x${props.Size.value}`
11926
- },
11927
- ...placeholder && {
11928
- fallback: identityPlaceholderTransformer.transform(placeholder)
11929
- },
11930
- size: props.Size.value
11931
- };
11932
- return createElement("Avatar", commonProps, props["Show Badge#1398:26"].value ? createElement("AvatarBadge", {}) : undefined, avatarHasSrc ? "alt 텍스트를 제공해야 합니다." : undefined);
11933
- });
11934
- };
11935
-
11936
- const createAvatarStackTransformer = (ctx)=>{
11937
- const avatarTransformer = createAvatarTransformer();
11938
- return defineComponentTransformer(metadata$q.key, (node)=>{
11939
- const avatarNodes = findAllInstances({
11940
- node,
11941
- key: avatarTransformer.key
11942
- });
11943
- const { componentProperties: props } = node;
11944
- const commonProps = {
11945
- size: props.Size.value
11946
- };
11947
- const avatarStackChildren = avatarNodes.map(avatarTransformer.transform);
11948
- return createElement("AvatarStack", commonProps, avatarStackChildren);
11949
- });
11950
- };
11951
-
11952
- const createBadgeTransformer = (_ctx)=>defineComponentTransformer(metadata$p.key, ({ componentProperties: props })=>{
11953
- const commonProps = {
11954
- size: handleSizeProp(props.Size.value),
11955
- tone: camelCase(props.Tone.value),
11956
- variant: camelCase(props.Variant.value),
11957
- shape: camelCase(props.Shape.value)
11958
- };
11959
- return createElement("Badge", commonProps, props["Label#1584:0"].value);
11960
- });
11961
-
11962
- const createCalloutTransformer = (ctx)=>defineComponentTransformer(metadata$o.key, ({ componentProperties: props, children })=>{
11963
- const tag = (()=>{
11964
- switch(props.Interaction.value){
11965
- case "Default":
11966
- return "Callout";
11967
- case "Actionable":
11968
- return "ActionableCallout";
11969
- case "Dismissible":
11970
- return "DismissibleCallout";
11971
- default:
11972
- return "Callout";
11973
- }
11974
- })();
11975
- const textNode = children.find((child)=>child.type === "TEXT");
11976
- if (!textNode) {
11977
- return createElement(tag, undefined, undefined, "내용을 제공해주세요.");
11978
- }
11979
- const slices = textNode.segments;
11980
- let title;
11981
- let description;
11982
- let linkLabel;
11983
- switch(slices.length){
11984
- case 1:
11985
- {
11986
- description = slices[0]?.characters.trim();
11987
- break;
11988
- }
11989
- case 2:
11990
- {
11991
- const firstSlice = slices[0];
11992
- const secondSlice = slices[1];
11993
- if (firstSlice?.style.fontWeight === 700) {
11994
- title = firstSlice?.characters.trim();
11995
- description = secondSlice?.characters.trim();
11996
- break;
11997
- }
11998
- description = firstSlice?.characters.trim();
11999
- if (tag !== "ActionableCallout") {
12000
- linkLabel = secondSlice?.characters.trim();
12001
- }
12002
- break;
12003
- }
12004
- case 3:
12005
- {
12006
- title = slices[0]?.characters.trim();
12007
- description = slices[1]?.characters.trim();
12008
- if (tag !== "ActionableCallout") {
12009
- linkLabel = slices[2]?.characters.trim();
12010
- }
12011
- break;
12012
- }
12013
- }
12014
- const commonProps = {
12015
- tone: camelCase(props.Tone.value),
12016
- title,
12017
- description,
12018
- linkProps: {
12019
- children: linkLabel
12020
- },
12021
- ...props["Icon#12598:210"].value && {
12022
- prefixIcon: createElement(ctx.iconService.createIconTagName(props["Icon#12598:210"].componentKey))
12023
- }
12024
- };
12025
- return createElement(tag, commonProps);
12026
- });
12027
-
12028
- const createCheckboxTransformer = (_ctx)=>defineComponentTransformer(metadata$n.key, ({ componentProperties: props })=>{
12029
- const states = props.State.value.split("-");
12030
- const commonProps = {
12031
- label: props["Label#49990:0"].value,
12032
- weight: camelCase(props.Weight.value),
12033
- variant: camelCase(props.Shape.value),
12034
- size: handleSizeProp(props.Size.value),
12035
- ...states.includes("Selected") && {
12036
- defaultChecked: true
12037
- },
12038
- ...states.includes("Indeterminate") && {
12039
- defaultChecked: true,
12040
- indeterminate: true
12041
- },
12042
- ...states.includes("Disabled") && {
12043
- disabled: true
12044
- }
12045
- };
12046
- return createElement("Checkbox", commonProps);
12047
- });
12048
-
12049
- const CHIP_TABS_ITEM_KEY = "fa80168b02051fbb0ba032238bd76d840dbe2e15";
12050
- const createChipTabsItemTransformer = (_ctx)=>defineComponentTransformer(CHIP_TABS_ITEM_KEY, ({ componentProperties: props })=>{
12051
- const states = props.State.value.split("-");
12052
- const commonProps = {
12053
- value: props["Label#8876:0"].value,
12054
- ...states.includes("Disabled") && {
12055
- disabled: true
12056
- }
12057
- };
12058
- return createElement("ChipTabsTrigger", commonProps, props["Label#8876:0"].value);
12059
- });
12060
- const createChipTabsTransformer = (ctx)=>{
12061
- const chipTabsItemTransformer = createChipTabsItemTransformer();
12062
- return defineComponentTransformer(metadata$m.key, (node)=>{
12063
- const chipTabsItems = findAllInstances({
12064
- node,
12065
- key: chipTabsItemTransformer.key
12066
- });
12067
- const selectedChipTabsItem = chipTabsItems.find((chipTabsItem)=>chipTabsItem.componentProperties.State.value.split("-").includes("Selected"));
12068
- const chipTabsList = createElement("ChipTabsList", undefined, chipTabsItems.map(chipTabsItemTransformer.transform));
12069
- const commonProps = {
12070
- variant: camelCase(node.componentProperties.Variant.value),
12071
- ...selectedChipTabsItem && {
12072
- defaultValue: selectedChipTabsItem.componentProperties["Label#8876:0"].value
12073
- }
12074
- };
12075
- return createElement("ChipTabs", commonProps, chipTabsList);
12076
- });
12077
- };
12078
-
12079
- const createControlChipTransformer = (ctx)=>defineComponentTransformer(metadata$l.key, ({ componentProperties: props })=>{
12080
- const states = props.State.value.split("-");
12081
- const { layout, children } = match(props.Layout.value).with("Icon Only", ()=>({
12082
- layout: "iconOnly",
12083
- children: [
12084
- createElement("Icon", {
12085
- svg: createElement(ctx.iconService.createIconTagName(props["Icon#8722:41"].componentKey))
12086
- })
12087
- ]
12088
- })).with("Icon First", ()=>({
12089
- layout: "withText",
12090
- children: [
12091
- createElement("PrefixIcon", {
12092
- svg: createElement(ctx.iconService.createIconTagName(props["Prefix Icon#8722:0"].componentKey))
12093
- }),
12094
- props["Label#7185:0"].value
12095
- ]
12096
- })).with("Icon Last", ()=>({
12097
- layout: "withText",
12098
- children: [
12099
- props["Label#7185:0"].value,
12100
- createElement("SuffixIcon", {
12101
- svg: createElement(ctx.iconService.createIconTagName(props["Suffix Icon#8722:82"].componentKey))
12102
- })
12103
- ]
12104
- })).with("Icon Both", ()=>({
12105
- layout: "withText",
12106
- children: [
12107
- createElement("PrefixIcon", {
12108
- svg: createElement(ctx.iconService.createIconTagName(props["Prefix Icon#8722:0"].componentKey))
12109
- }),
12110
- props["Label#7185:0"].value,
12111
- createElement("SuffixIcon", {
12112
- svg: createElement(ctx.iconService.createIconTagName(props["Suffix Icon#8722:82"].componentKey))
12113
- })
12114
- ]
12115
- })).with("Text Only", ()=>({
12116
- layout: "withText",
12117
- children: props["Label#7185:0"].value
12118
- })).exhaustive();
12119
- const commonProps = {
12120
- size: handleSizeProp(props.Size.value),
12121
- layout,
12122
- ...states.includes("Selected") && {
12123
- defaultChecked: true
12124
- },
12125
- ...states.includes("Disabled") && {
12126
- disabled: true
12127
- },
12128
- ...props["Show Count#7185:42"].value && {
12129
- count: Number(props["Count#7185:21"].value)
12130
- }
12131
- };
12132
- return createElement("ControlChip.Toggle", commonProps, children);
12133
- });
12134
-
12135
- const createErrorStateTransformer = (ctx)=>{
12136
- const actionButtonTransformer = createActionButtonTransformer(ctx);
12137
- return defineComponentTransformer(metadata$k.key, (node)=>{
12138
- const props = node.componentProperties;
12139
- const [actionButtonNode] = findAllInstances({
12140
- node,
12141
- key: actionButtonTransformer.key
12142
- });
12143
- const commonProps = {
12144
- variant: camelCase(props.Variant.value),
12145
- ...props.Layout.value === "With Title" && {
12146
- title: props["Title#16237:0"].value
12147
- },
12148
- description: props["Description#16237:5"].value,
12149
- ...actionButtonNode && {
12150
- primaryActionProps: {
12151
- children: actionButtonTransformer.transform(actionButtonNode).children[0]
12152
- },
12153
- secondaryActionProps: {
12154
- children: props["Secondary Action Label#17042:0"].value
12155
- }
12156
- }
12157
- };
12158
- return createElement("ErrorState", commonProps);
12159
- });
12160
- };
12161
-
12162
- const EXTENDED_ACTION_SHEET_ITEM_KEY = "057083e95466da59051119eec0b41d4ad5a07f8f";
12163
- const createExtendedActionSheetItemTransformer = (ctx)=>defineComponentTransformer(EXTENDED_ACTION_SHEET_ITEM_KEY, ({ componentProperties: props })=>{
12164
- const states = props.State.value.split("-");
12165
- const commonProps = {
12166
- tone: camelCase(props.Tone.value),
12167
- ...states.includes("Disabled") && {
12168
- disabled: true
12169
- }
12170
- };
12171
- return createElement("ExtendedActionSheetItem", commonProps, [
12172
- props["Show Prefix Icon#17043:5"].value ? createElement("PrefixIcon", {
12173
- svg: createElement(ctx.iconService.createIconTagName(props["Prefix Icon#55948:0"].componentKey))
12174
- }) : undefined,
12175
- props["Label#55905:8"].value
12176
- ]);
12177
- });
12178
- const EXTENDED_ACTION_SHEET_GROUP_KEY = "2a504a1c6b7810d5e652862dcba2cb7048f9eb16";
12179
- const createExtendedActionSheetGroupTransformer = (ctx)=>{
12180
- const extendedActionSheetItemTransformer = createExtendedActionSheetItemTransformer(ctx);
12181
- return defineComponentTransformer(EXTENDED_ACTION_SHEET_GROUP_KEY, (node)=>{
12182
- const items = findAllInstances({
12183
- node,
12184
- key: extendedActionSheetItemTransformer.key
12185
- });
12186
- const contentChildren = items.map(extendedActionSheetItemTransformer.transform);
12187
- return createElement("ExtendedActionSheetGroup", undefined, contentChildren);
12188
- });
12189
- };
12190
- const createExtendedActionSheetTransformer = (ctx)=>{
12191
- const extendedActionSheetGroupTransformer = createExtendedActionSheetGroupTransformer(ctx);
12192
- return defineComponentTransformer(metadata$j.key, (node)=>{
12193
- const { componentProperties: props } = node;
12194
- const groups = findAllInstances({
12195
- node,
12196
- key: extendedActionSheetGroupTransformer.key
12197
- });
12198
- const contentChildren = groups.map(extendedActionSheetGroupTransformer.transform);
12199
- const title = props["Show Title#17043:12"].value ? props["Title#14599:0"].value : undefined;
12200
- const content = createElement("ExtendedActionSheetContent", {
12201
- title
12202
- }, contentChildren, title ? undefined : "title을 제공하지 않는 경우 aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.");
12203
- const trigger = createElement("ExtendedActionSheetTrigger", {
12204
- asChild: true
12205
- }, createElement("ActionButton", undefined, "열기", "ExtendedActionSheet을 여는 요소를 제공해주세요."));
12206
- return createElement("ExtendedActionSheet", undefined, [
12207
- trigger,
12208
- content
12209
- ]);
12210
- });
12211
- };
12212
-
12213
- const createExtendedFabTransformer = (ctx)=>defineComponentTransformer(metadata$i.key, ({ componentProperties: props })=>{
12214
- const commonProps = {
12215
- size: handleSizeProp(props.Size.value),
12216
- variant: camelCase(props.Variant.value)
12217
- };
12218
- return createElement("ExtendedFab", commonProps, [
12219
- createElement("PrefixIcon", {
12220
- svg: createElement(ctx.iconService.createIconTagName(props["Icon#28796:0"].componentKey))
12221
- }),
12222
- props["Label#28936:0"].value
12223
- ]);
12224
- });
12225
-
12226
- const createFabTransformer = (ctx)=>defineComponentTransformer(metadata$h.key, ({ componentProperties: props })=>{
12227
- return createElement("Fab", undefined, createElement(ctx.iconService.createIconTagName(props["Icon#28796:0"].componentKey)), "aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.");
12228
- });
12229
-
12230
- const createHelpBubbleTransformer = (_ctx)=>defineComponentTransformer(metadata$g.key, ({ componentProperties: props })=>{
12231
- const placement = (()=>{
12232
- switch(props.Placement.value){
12233
- case "Bottom-Left":
12234
- return "top-start";
12235
- case "Bottom-Center":
12236
- return "top";
12237
- case "Bottom-Right":
12238
- return "top-end";
12239
- case "Left-Top":
12240
- return "right-start";
12241
- case "Left-Center":
12242
- return "right";
12243
- case "Left-Bottom":
12244
- return "right-end";
12245
- case "Top-Left":
12246
- return "bottom-start";
12247
- case "Top-Center":
12248
- return "bottom";
12249
- case "Top-Right":
12250
- return "bottom-end";
12251
- case "Right-Top":
12252
- return "left-start";
12253
- case "Right-Center":
12254
- return "left";
12255
- case "Right-Bottom":
12256
- return "left-end";
12257
- }
12258
- })();
12259
- const commonProps = {
12260
- title: props["Title#62535:0"].value,
12261
- ...props["Show Description#62499:0"].value && {
12262
- description: props["Description#62535:98"].value
12263
- },
12264
- showCloseButton: props["Show Close Button"].value === "True",
12265
- defaultOpen: true,
12266
- placement
12267
- };
12268
- return createElement("HelpBubbleTrigger", commonProps, createElement("ActionButton", undefined, "열기", "HelpBubble을 여는 요소를 제공해주세요."));
12269
- });
12270
-
12271
- const createInlineBannerTransformer = (ctx)=>defineComponentTransformer(metadata$e.key, (node)=>{
12272
- const { componentProperties: props } = node;
12273
- const tag = (()=>{
12274
- switch(props.Interaction.value){
12275
- case "Default":
12276
- return "InlineBanner";
12277
- case "Actionable":
12278
- return "ActionableInlineBanner";
12279
- case "Dismissible":
12280
- return "DismissibleInlineBanner";
12281
- case "Link":
12282
- return "InlineBanner";
12283
- default:
12284
- return "InlineBanner";
12285
- }
12286
- })();
12287
- const textNode = findOne(node, (child)=>child.type === "TEXT" && child.name === "Label");
12288
- if (!textNode) {
12289
- return createElement(tag, undefined, undefined, "내용을 제공해주세요.");
12290
- }
12291
- const slices = textNode.segments;
12292
- let title;
12293
- let description;
12294
- switch(slices.length){
12295
- case 1:
12296
- {
12297
- description = slices[0]?.characters.trim();
12298
- break;
12299
- }
12300
- case 2:
12301
- {
12302
- title = slices[0]?.characters.trim();
12303
- description = slices[1]?.characters.trim();
12304
- break;
12305
- }
12306
- }
12307
- const iconNode = findOne(node, (child)=>child.type === "INSTANCE" && child.name === "icon");
12308
- const iconComponentKey = props["Show Icon#11840:27"] && iconNode ? iconNode.componentKey : undefined;
12309
- const prefixIcon = iconComponentKey ? createElement(ctx.iconService.createIconTagName(iconComponentKey)) : undefined;
12310
- const commonProps = {
12311
- variant: camelCase(props.Variant.value),
12312
- title,
12313
- description,
12314
- ...props.Interaction.value === "Link" && {
12315
- linkProps: {
12316
- children: props["Link Label#1547:81"].value
12317
- }
12318
- },
12319
- prefixIcon
12320
- };
12321
- return createElement(tag, commonProps);
12322
- });
12323
-
12324
- const createMannerTempBadgeTransformer = (_ctx)=>defineComponentTransformer(metadata$d.key, ({ children })=>{
12325
- const textNode = children.find((child)=>child.type === "TEXT");
12326
- const commonProps = {
12327
- temperature: Number(textNode?.characters.replace(/[^\d.-]/g, "") ?? "-1")
12328
- };
12329
- return createElement("MannerTempBadge", commonProps);
12330
- });
12331
-
12332
- const createMultilineTextFieldTransformer = (_ctx)=>defineComponentTransformer(metadata$c.key, ({ componentProperties: props })=>{
12333
- const { Size: { value: size }, State: { value: state }, Filled: { value: filled }, "Show Header#870:0": { value: showHeader }, "Label#15327:323": { value: label }, "Show Indicator#1259:0": { value: showIndicator }, "Indicator#15327:286": { value: indicator }, "Placeholder#958:0": { value: placeholder }, "Filled Text#1304:0": { value: defaultValue }, "Show Footer#958:25": { value: showFooter }, "Show Description#958:50": { value: showDescription }, "Description#15327:212": { value: description }, "Show Character count#958:75": { value: showCharacterCount }, "Character Count#15327:360": { value: _characterCount }, "Max Character Count#15327:175": { value: maxCharacterCount } } = props;
12334
- const states = state.split("-");
12335
- const commonProps = {
12336
- size: handleSizeProp(size),
12337
- // header
12338
- ...showHeader && {
12339
- label
12340
- },
12341
- ...showHeader && showIndicator && {
12342
- indicator
12343
- },
12344
- // input
12345
- ...filled === "True" && {
12346
- defaultValue
12347
- },
12348
- ...states.includes("Invalid") && {
12349
- invalid: true
12350
- },
12351
- ...states.includes("Disabled") && {
12352
- disabled: true
12353
- },
12354
- ...states.includes("Read Only") && {
12355
- readOnly: true
12356
- },
12357
- // footer
12358
- ...showFooter && showDescription && states.includes("Invalid") && {
12359
- // invalid인 경우 description을 error로 사용
12360
- errorMessage: description
12361
- },
12362
- ...showFooter && showDescription && !states.includes("Invalid") && {
12363
- // invalid가 아닌 경우 description을 description으로 사용
12364
- description
12365
- },
12366
- ...showFooter && showCharacterCount && {
12367
- maxGraphemeCount: Number(maxCharacterCount)
12368
- }
12369
- };
12370
- const inputProps = {
12371
- placeholder
12372
- };
12373
- const TextFieldChildren = createElement("TextFieldTextarea", inputProps);
12374
- return createElement("TextField", commonProps, TextFieldChildren);
12375
- });
12376
-
12377
- const createProgressCircleTransformer = (_ctx)=>defineComponentTransformer(metadata$b.key, ({ componentProperties: props })=>{
12378
- const { value, minValue, maxValue } = match(props.Value.value).with("Indeterminate", ()=>({
12379
- value: undefined,
12380
- minValue: undefined,
12381
- maxValue: undefined
12382
- })).with("0%", ()=>({
12383
- value: 0,
12384
- minValue: 0,
12385
- maxValue: 100
12386
- })).with("25%", ()=>({
12387
- value: 25,
12388
- minValue: 0,
12389
- maxValue: 100
12390
- })).with("75%", ()=>({
12391
- value: 75,
12392
- minValue: 0,
12393
- maxValue: 100
12394
- })).with("100%", ()=>({
12395
- value: 100,
12396
- minValue: 0,
12397
- maxValue: 100
12398
- })).exhaustive();
12399
- const commonProps = {
12400
- value,
12401
- minValue,
12402
- maxValue,
12403
- size: props.Size.value,
12404
- tone: camelCase(props.Tone.value)
12405
- };
12406
- return createElement("ProgressCircle", commonProps);
12407
- });
12408
-
12409
- const createReactionButtonTransformer = (ctx)=>defineComponentTransformer(metadata$a.key, ({ componentProperties: props })=>{
12410
- const states = props.State.value.split("-");
12411
- const commonProps = {
12412
- size: handleSizeProp(props.Size.value),
12413
- ...states.includes("Loading") && {
12414
- loading: true
12415
- },
12416
- ...states.includes("Disabled") && {
12417
- disabled: true
12418
- },
12419
- ...states.includes("Selected") && {
12420
- defaultPressed: true
12421
- }
12422
- };
12423
- return createElement("ReactionButton", commonProps, [
12424
- createElement("PrefixIcon", {
12425
- svg: createElement(ctx.iconService.createIconTagName(props["Icon#12379:0"].componentKey))
12426
- }),
12427
- props["Label#6397:0"].value,
12428
- props["Show Count#6397:33"].value ? createElement("Count", {}, props["Count#15816:0"].value) : undefined
12429
- ]);
12430
- });
12431
-
12432
- const SEGMENTED_CONTROL_ITEM_KEY = "9a7ba0d4c041ddbce84ee48881788434fd6bccc8";
12433
- const createSegmentedControlItemTransformer = (_ctx)=>defineComponentTransformer(SEGMENTED_CONTROL_ITEM_KEY, ({ componentProperties: props })=>{
12434
- const states = props.State.value.split("-");
12435
- const commonProps = {
12436
- value: props["Label#11366:15"].value,
12437
- ...states.includes("Disabled") && {
12438
- disabled: true
12439
- }
12440
- };
12441
- return createElement("SegmentedControlItem", commonProps, props["Label#11366:15"].value);
12442
- });
12443
- const createSegmentedControlTransformer = (ctx)=>{
12444
- const segmentedControlItemTransformer = createSegmentedControlItemTransformer();
12445
- return defineComponentTransformer(metadata$9.key, (node)=>{
12446
- const segments = findAllInstances({
12447
- node,
12448
- key: segmentedControlItemTransformer.key
12449
- });
12450
- const selectedSegment = segments.find((segment)=>segment.componentProperties.State.value.split("-").includes("Selected"));
12451
- const segmentedControlChildren = segments.map(segmentedControlItemTransformer.transform);
12452
- const commonProps = {
12453
- ...selectedSegment && {
12454
- defaultValue: selectedSegment.componentProperties["Label#11366:15"].value
12455
- }
12456
- };
12457
- return createElement("SegmentedControl", commonProps, segmentedControlChildren, "aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.");
12458
- });
12459
- };
12460
-
12461
- const createSelectBoxTransformer = (_ctx)=>defineComponentTransformer(metadata$8.key, ({ componentProperties: props })=>{
12462
- const tag = (()=>{
12463
- switch(props.Control.value){
12464
- case "Checkbox":
12465
- return "CheckSelectBox";
12466
- case "Radio":
12467
- return "RadioSelectBox";
12468
- }
12469
- })();
12470
- const states = props.State.value.split("-");
12471
- const commonProps = {
12472
- label: props["Label#3635:0"].value,
12473
- ...props["Show Description#3033:0"].value && {
12474
- description: props["Description #3033:5"].value
12475
- },
12476
- ...tag === "RadioSelectBox" && {
12477
- value: props["Label#3635:0"].value
12478
- },
12479
- ...tag === "CheckSelectBox" && states.includes("Selected") && {
12480
- defaultChecked: true
12481
- }
12482
- };
12483
- return createElement(tag, commonProps);
12484
- });
12485
- const createSelectBoxGroupTransformer = (ctx)=>{
12486
- const selectBoxTransformer = createSelectBoxTransformer();
12487
- return defineComponentTransformer(metadata$v.key, (node)=>{
12488
- const props = node.componentProperties;
12489
- const tag = (()=>{
12490
- switch(props.Control.value){
12491
- case "Checkbox":
12492
- return "CheckSelectBoxGroup";
12493
- case "Radio":
12494
- return "RadioSelectBoxGroup";
12495
- }
12496
- })();
12497
- const selectBoxes = findAllInstances({
12498
- node,
12499
- key: selectBoxTransformer.key
12500
- });
12501
- const selectedSelectBox = selectBoxes.find((selectBox)=>selectBox.componentProperties.State.value.split("-").includes("Selected"));
12502
- const stack = createElement("Stack", {
12503
- gap: "spacingY.componentDefault"
12504
- }, selectBoxes.map(selectBoxTransformer.transform));
12505
- const commonProps = {
12506
- ...tag === "RadioSelectBoxGroup" && {
12507
- defaultValue: selectedSelectBox?.componentProperties["Label#3635:0"].value
12508
- }
12509
- };
12510
- return createElement(tag, commonProps, stack);
12511
- });
12512
- };
12513
-
12514
- const createSkeletonTransformer = (ctx)=>defineComponentTransformer(metadata$7.key, ({ componentProperties: props, absoluteBoundingBox, layoutSizingHorizontal, layoutSizingVertical, boundVariables })=>{
12515
- const commonProps = {
12516
- radius: camelCase(props.Radius.value),
12517
- width: (()=>{
12518
- switch(layoutSizingHorizontal){
12519
- case "FIXED":
12520
- {
12521
- const variableId = boundVariables?.size?.x?.id;
12522
- if (variableId) return ctx.variableService.getVariableName(variableId);
12523
- return `${absoluteBoundingBox?.width}px`;
12524
- }
12525
- case "FILL":
12526
- return "full";
12527
- default:
12528
- return "full";
12529
- }
12530
- })(),
12531
- height: (()=>{
12532
- switch(layoutSizingVertical){
12533
- case "FIXED":
12534
- {
12535
- const variableId = boundVariables?.size?.y?.id;
12536
- if (variableId) return ctx.variableService.getVariableName(variableId);
12537
- return `${absoluteBoundingBox?.height}px`;
12538
- }
12539
- case "FILL":
12540
- return "full";
12541
- default:
12542
- return "full";
12543
- }
12544
- })()
12545
- };
12546
- return createElement("Skeleton", commonProps);
12547
- });
12548
-
12549
- const createSnackbarTransformer = (_ctx)=>defineComponentTransformer(metadata$6.key, ({ componentProperties: props })=>{
12550
- const commonProps = {
12551
- message: props["Message#1528:4"].value,
12552
- variant: camelCase(props.Variant.value),
12553
- ...props["Show Action Button#1528:0"].value && {
12554
- actionLabel: props["Action Button Label#1528:8"].value
12555
- }
12556
- };
12557
- // TODO: adapter.create({ render })
12558
- return createElement("Snackbar", commonProps);
12559
- });
12560
-
12561
- const createSwitchTransformer = (_ctx)=>defineComponentTransformer(metadata$4.key, ({ componentProperties: props })=>{
12562
- const states = props.State.value.split("-");
12563
- const size = handleSizeProp(props.Size.value);
12564
- const commonProps = {
12565
- size,
12566
- ...size === "small" && {
12567
- label: props["Label#15191:2"].value
12568
- },
12569
- ...states.includes("Selected") && {
12570
- defaultChecked: true
12571
- },
12572
- ...states.includes("Disabled") && {
12573
- disabled: true
12574
- }
12575
- };
12576
- return createElement("Switch", commonProps);
12577
- });
12578
-
12579
- const TABS_HUG_ITEM_KEY = "c242492543b327ceb84fa9933841512fc62a898c";
12580
- const createTabsHugItemTransformer = (_ctx)=>defineComponentTransformer(TABS_HUG_ITEM_KEY, ({ componentProperties: props })=>{
12581
- const states = props.State.value.split("-");
12582
- const commonProps = {
12583
- value: props["Label#4478:2"].value,
12584
- ...props.Notification.value === "True" && {
12585
- alert: true
12586
- },
12587
- ...states.includes("Disabled") && {
12588
- disabled: true
12589
- }
12590
- };
12591
- return createElement("TabsTrigger", commonProps, props["Label#4478:2"].value);
12592
- });
12593
- const TABS_FILL_ITEM_KEY = "7275293344efb40ee9a3f5248ba2659b94a0b305";
12594
- const createTabsFillItemTransformer = (_ctx)=>defineComponentTransformer(TABS_FILL_ITEM_KEY, ({ componentProperties: props })=>{
12595
- const states = props.State.value.split("-");
12596
- const commonProps = {
12597
- value: props["Label#4478:2"].value,
12598
- ...props.Notification.value === "True" && {
12599
- alert: true
12600
- },
12601
- ...states.includes("Disabled") && {
12602
- disabled: true
12603
- }
12604
- };
12605
- return createElement("TabsTrigger", commonProps, props["Label#4478:2"].value);
12606
- });
12607
- const createTabsTransformer = (ctx)=>{
12608
- const tabsHugItemTransformer = createTabsHugItemTransformer();
12609
- const tabsFillItemTransformer = createTabsFillItemTransformer();
12610
- return defineComponentTransformer(metadata$3.key, (node)=>{
12611
- const { componentProperties: props, children } = node;
12612
- const mappedItems = children.map((child)=>{
12613
- if (child.type !== "INSTANCE") return null;
12614
- const componentKey = child.componentSetKey ? child.componentSetKey : child.componentKey;
12615
- if (componentKey === tabsHugItemTransformer.key) return {
12616
- triggerLayout: "hug",
12617
- node: child
12618
- };
12619
- if (componentKey === tabsFillItemTransformer.key) return {
12620
- triggerLayout: "fill",
12621
- node: child
12622
- };
12623
- return null;
12624
- });
12625
- const tabsItems = mappedItems.filter((item)=>item !== null);
12626
- const selectedTabsItem = tabsItems.find(({ node: { componentProperties } })=>componentProperties.State.value.split("-").includes("Selected"))?.node;
12627
- const tabTriggerList = createElement("TabsList", undefined, tabsItems.map(({ triggerLayout, node })=>{
12628
- switch(triggerLayout){
12629
- case "hug":
12630
- return tabsHugItemTransformer.transform(node);
12631
- case "fill":
12632
- return tabsFillItemTransformer.transform(node);
12633
- }
12634
- }));
12635
- const tabContents = tabsItems.map(({ node })=>{
12636
- const value = node.componentProperties["Label#4478:2"].value;
12637
- return createElement("TabsContent", {
12638
- value
12639
- }, "{/* TODO: 컨텐츠 추가 */}");
12640
- });
12641
- const commonProps = {
12642
- triggerLayout: camelCase(props.Layout.value),
12643
- size: handleSizeProp(props.Size.value),
12644
- ...selectedTabsItem && {
12645
- defaultValue: selectedTabsItem.componentProperties["Label#4478:2"].value
12646
- }
12647
- };
12648
- return createElement("TabsRoot", commonProps, [
12649
- tabTriggerList,
12650
- ...tabContents
12651
- ]);
12652
- });
12653
- };
12654
-
12655
- const createTextButtonTransformer = (ctx)=>defineComponentTransformer(metadata$2.key, (node)=>{
12656
- const { componentProperties: props } = node;
12657
- const states = props.State.value.split("-");
12658
- const { prefixIcon, suffixIcon, children } = match(props.Layout.value).with("Icon First", ()=>({
12659
- prefixIcon: createElement(ctx.iconService.createIconTagName(props["Prefix Icon#7561:0"].componentKey)),
12660
- suffixIcon: undefined,
12661
- children: props["Label#6148:0"].value
12662
- })).with("Icon Last", ()=>{
12663
- const suffixIconNode = findOne(node, (node)=>node.type === "INSTANCE" && node.name === "Suffix Icon");
12664
- const suffixIconComponentKey = suffixIconNode?.componentKey;
12665
- return {
12666
- prefixIcon: undefined,
12667
- suffixIcon: suffixIconComponentKey ? createElement(ctx.iconService.createIconTagName(suffixIconComponentKey)) : undefined,
12668
- children: props["Label#6148:0"].value
12669
- };
12670
- }).exhaustive();
12671
- const commonProps = {
12672
- tone: camelCase(props.Tone.value),
12673
- size: handleSizeProp(props.Size.value),
12674
- prefixIcon,
12675
- suffixIcon,
12676
- ...states.includes("Disabled") && {
12677
- disabled: true
12678
- }
12679
- };
12680
- return createElement("TextButton", commonProps, children);
12681
- });
12682
-
12683
- const createTextFieldTransformer = (ctx)=>defineComponentTransformer(metadata$1.key, ({ componentProperties: props })=>{
12684
- const { Size: { value: size }, State: { value: state }, Filled: { value: filled }, "Show Header#870:0": { value: showHeader }, "Label#14964:0": { value: label }, "Show Indicator#1259:0": { value: showIndicator }, "Indicator#15327:249": { value: indicator }, "Show Prefix#958:125": { value: showPrefix }, "Show Prefix Icon#1267:50": { value: showPrefixIcon }, "Prefix Icon#1267:25": { componentKey: prefixIcon }, "Show Prefix Text#1267:0": { value: showPrefixText }, "Prefix Text#15327:101": { value: prefix }, "Placeholder#958:0": { value: placeholder }, "Filled Text#1304:0": { value: defaultValue }, "Show Suffix#958:100": { value: showSuffix }, "Show Suffix Icon#1267:75": { value: showSuffixIcon }, "Suffix Icon #1267:100": { componentKey: suffixIcon }, "Show Suffix Text#1267:125": { value: showSuffixText }, "Suffix Text#15327:138": { value: suffix }, "Show Footer#958:25": { value: showFooter }, "Show Description#958:50": { value: showDescription }, "Description#12626:5": { value: description }, "Show Character Count#958:75": { value: showCharacterCount }, "Character Count#15327:64": { value: _characterCount }, "Max Character Count#15327:27": { value: maxCharacterCount } } = props;
12685
- const states = state.split("-");
12686
- const commonProps = {
12687
- size: handleSizeProp(size),
12688
- // header
12689
- ...showHeader && {
12690
- label
12691
- },
12692
- ...showHeader && showIndicator && {
12693
- indicator
12694
- },
12695
- // input affixes
12696
- ...showPrefix && showPrefixIcon && {
12697
- prefixIcon: createElement(ctx.iconService.createIconTagName(prefixIcon))
12698
- },
12699
- ...showPrefix && showPrefixText && {
12700
- prefix
12701
- },
12702
- ...showSuffix && showSuffixIcon && {
12703
- suffixIcon: createElement(ctx.iconService.createIconTagName(suffixIcon))
12704
- },
12705
- ...showSuffix && showSuffixText && {
12706
- suffix
12707
- },
12708
- // input
12709
- ...filled === "True" && {
12710
- defaultValue
12711
- },
12712
- ...states.includes("Invalid") && {
12713
- invalid: true
12714
- },
12715
- ...states.includes("Disabled") && {
12716
- disabled: true
12717
- },
12718
- ...states.includes("Read Only") && {
12719
- readOnly: true
12720
- },
12721
- // footer
12722
- ...showFooter && showDescription && states.includes("Invalid") && {
12723
- // invalid인 경우 description을 error로 사용
12724
- errorMessage: description
12725
- },
12726
- ...showFooter && showDescription && !states.includes("Invalid") && {
12727
- // invalid가 아닌 경우 description을 description으로 사용
12728
- description
12729
- },
12730
- ...showFooter && showCharacterCount && {
12731
- maxGraphemeCount: Number(maxCharacterCount)
12732
- }
12733
- };
12734
- const inputProps = {
12735
- placeholder
12736
- };
12737
- const TextFieldChildren = createElement("TextFieldInput", inputProps);
12738
- return createElement("TextField", commonProps, TextFieldChildren);
12739
- });
12740
-
12741
- const createToggleButtonTransformer = (ctx)=>defineComponentTransformer(metadata.key, ({ componentProperties: props })=>{
12742
- const states = props.State.value.split("-");
12743
- const commonProps = {
12744
- variant: camelCase(props.Variant.value),
12745
- size: handleSizeProp(props.Size.value),
12746
- ...states.includes("Selected") && {
12747
- defaultPressed: true
12748
- },
12749
- ...states.includes("Disabled") && {
12750
- disabled: true
12751
- },
12752
- ...states.includes("Loading") && {
12753
- loading: true
12754
- }
12755
- };
12756
- return createElement("ToggleButton", commonProps, [
12757
- props["Show Prefix Icon#6122:392"].value ? createElement("PrefixIcon", {
12758
- svg: createElement(ctx.iconService.createIconTagName(props["Prefix Icon#6122:98"].componentKey))
12759
- }) : undefined,
12760
- props["Label#6122:49"].value,
12761
- props["Show Suffix Icon#6122:147"].value ? createElement("SuffixIcon", {
12762
- svg: createElement(ctx.iconService.createIconTagName(props["Suffix Icon#6122:343"].componentKey))
12763
- }) : undefined
12764
- ]);
12765
- });
12766
-
12767
- const createSeedComponentTransformers = (ctx)=>Object.fromEntries([
12768
- createActionButtonTransformer(ctx),
12769
- createActionChipTransformer(ctx),
12770
- createActionSheetTransformer(),
12771
- createAppBarTransformer(ctx),
12772
- createAvatarTransformer(),
12773
- createAvatarStackTransformer(),
12774
- createBadgeTransformer(),
12775
- createCalloutTransformer(ctx),
12776
- createCheckboxTransformer(),
12777
- createChipTabsTransformer(),
12778
- createControlChipTransformer(ctx),
12779
- createErrorStateTransformer(ctx),
12780
- createExtendedActionSheetTransformer(ctx),
12781
- createExtendedFabTransformer(ctx),
12782
- createFabTransformer(ctx),
12783
- createHelpBubbleTransformer(),
12784
- createIdentityPlaceholderTransformer(),
12785
- createInlineBannerTransformer(ctx),
12786
- createMannerTempBadgeTransformer(),
12787
- createMultilineTextFieldTransformer(),
12788
- createProgressCircleTransformer(),
12789
- createReactionButtonTransformer(ctx),
12790
- createSegmentedControlTransformer(),
12791
- createSelectBoxGroupTransformer(),
12792
- createSelectBoxTransformer(),
12793
- createSkeletonTransformer(ctx),
12794
- createSnackbarTransformer(),
12795
- createSwitchTransformer(),
12796
- createTabsTransformer(),
12797
- createTextButtonTransformer(ctx),
12798
- createTextFieldTransformer(ctx),
12799
- createToggleButtonTransformer(ctx)
12800
- ].map((x)=>[
12801
- x.key,
12802
- x
12803
- ]));
12804
-
12805
- const IGNORED_COMPONENT_KEYS = new Set([
12806
- "1acdc7247c83a73a0504d6fad86d08783938cb1a",
12807
- "b38b719b61cdf1a24458d7a7888bee74b7649084"
12808
- ]);
12809
- const styleService = createStyleService({
12810
- styleRepository,
12811
- styleNameTransformer: ({ slug })=>camelCase(slug[slug.length - 1], {
12812
- mergeAmbiguousCharacters: true
12813
- })
12814
- });
12815
- const variableService = createVariableService({
12816
- variableRepository,
12817
- variableNameTransformer: ({ slug })=>slug.filter((s)=>!(s === "dimension" || s === "radius" || s === "font-size" || s === "font-weight" || s === "line-height")).map((s)=>s.replaceAll(",", "_")).map(camelCasePreserveUnderscoreBetweenNumbers).join("."),
12818
- inferCompareFunction: (name1, name2)=>{
12819
- const scoreFn = (name)=>{
12820
- let score = 0;
12821
- if (name.includes("bg")) {
12822
- score += 100;
12823
- }
12824
- if (name.includes("fg")) {
12825
- score += 100;
12826
- }
12827
- if (name.includes("stroke")) {
12828
- score += 100;
12829
- }
12830
- if (name.includes("spacing-x")) {
12831
- score -= 100;
12832
- }
12833
- if (name.includes("spacing-y")) {
12834
- score -= 100;
12835
- }
12836
- if (name.endsWith("pressed")) {
12837
- score -= 100;
12838
- }
12839
- return score;
12840
- };
12841
- return scoreFn(name2) - scoreFn(name1);
12842
- }
12843
- });
12844
- const iconService = createIconService({
12845
- iconRepository
12846
- });
12847
- // TODO: implement figma component service
12848
- const componentTransformers = createSeedComponentTransformers({
12849
- iconService,
12850
- variableService
12851
- });
12852
- function createContext(options) {
12853
- const { ignoredComponentKeys = IGNORED_COMPONENT_KEYS, shouldInferVariableName, shouldInferAutoLayout } = options;
12854
- const valueTransformer = createValueTransformer({
12855
- variableService,
12856
- formatters: {
12857
- color: (value)=>toCssRgba(value),
12858
- dimension: (value)=>toCssPixel(value),
12859
- fontDimension: (value)=>toCssPixel(value),
12860
- fontWeight: (value)=>value
12861
- },
12862
- shouldInferVariableName
12863
- });
12864
- const containerLayoutPropsTransformer = createContainerLayoutPropsTransformer(valueTransformer);
12865
- const selfLayoutPropsTransformer = createSelfLayoutPropsTransformer(valueTransformer);
12866
- const iconSelfLayoutPropsTransformer = createIconSelfLayoutPropsTransformer(valueTransformer);
12867
- const frameFillPropsTransformer = createFrameFillPropsTransformer(valueTransformer);
12868
- const shapeFillPropsTransformer = createShapeFillPropsTransformer(valueTransformer);
12869
- const textFillPropsTransformer = createTextFillPropsTransformer(valueTransformer);
12870
- const radiusPropsTransformer = createRadiusPropsTransformer(valueTransformer);
12871
- const strokePropsTransformer = createStrokePropsTransformer(valueTransformer);
12872
- const typeStylePropsTransformer = createTypeStylePropsTransformer({
12873
- valueTransformer,
12874
- styleService
12875
- });
12876
- const propsTransformers = {
12877
- containerLayout: containerLayoutPropsTransformer,
12878
- selfLayout: selfLayoutPropsTransformer,
12879
- iconSelfLayout: iconSelfLayoutPropsTransformer,
12880
- frameFill: frameFillPropsTransformer,
12881
- shapeFill: shapeFillPropsTransformer,
12882
- textFill: textFillPropsTransformer,
12883
- radius: radiusPropsTransformer,
12884
- stroke: strokePropsTransformer,
12885
- typeStyle: typeStylePropsTransformer
12886
- };
12887
- const frameTransformer = createFrameTransformer({
12888
- propsTransformers
12889
- });
12890
- const instanceTransformer = createInstanceTransformer({
12891
- iconService,
12892
- ignoredComponentKeys,
12893
- propsTransformers,
12894
- componentTransformers,
12895
- frameTransformer
12896
- });
12897
- const textTransformer = createTextTransformer({
12898
- propsTransformers
12899
- });
12900
- const rectangleTransformer = createRectangleTransformer({
12901
- propsTransformers
12902
- });
12903
- const vectorTransformer = createVectorTransformer();
12904
- const booleanOperationTransformer = createBooleanOperationTransformer();
12905
- const codegenTransformer = createCodegenTransformer({
12906
- frameTransformer,
12907
- textTransformer,
12908
- rectangleTransformer,
12909
- instanceTransformer,
12910
- vectorTransformer,
12911
- booleanOperationTransformer,
12912
- shouldInferAutoLayout
12913
- });
12914
- return codegenTransformer;
12915
- }
12916
-
12917
- var index = {
12918
- __proto__: null,
12919
- createBooleanOperationTransformer: createBooleanOperationTransformer,
12920
- createContainerLayoutPropsTransformer: createContainerLayoutPropsTransformer,
12921
- createContext: createContext,
12922
- createFrameFillPropsTransformer: createFrameFillPropsTransformer,
12923
- createFrameTransformer: createFrameTransformer,
12924
- createIconSelfLayoutPropsTransformer: createIconSelfLayoutPropsTransformer,
12925
- createInstanceTransformer: createInstanceTransformer,
12926
- createRadiusPropsTransformer: createRadiusPropsTransformer,
12927
- createRectangleTransformer: createRectangleTransformer,
12928
- createSeedComponentTransformers: createSeedComponentTransformers,
12929
- createSelfLayoutPropsTransformer: createSelfLayoutPropsTransformer,
12930
- createShapeFillPropsTransformer: createShapeFillPropsTransformer,
12931
- createStrokePropsTransformer: createStrokePropsTransformer,
12932
- createTextFillPropsTransformer: createTextFillPropsTransformer,
12933
- createTextTransformer: createTextTransformer,
12934
- createTypeStylePropsTransformer: createTypeStylePropsTransformer,
12935
- createVectorTransformer: createVectorTransformer
12936
- };
12937
-
12938
- function generateJsxTree(node, options = {}) {
12939
- const { shouldInferVariableName = true, shouldInferAutoLayout = true } = options;
12940
- const codegen = createContext({
12941
- shouldInferVariableName,
12942
- shouldInferAutoLayout
12943
- });
12944
- return codegen(node);
12945
- }
12946
- function generateCode(node, options = {}) {
12947
- const result = generateJsxTree(node, options);
12948
- return result ? stringifyElement(result, {
12949
- printSource: options.shouldPrintSource
12950
- }) : undefined;
12951
- }
12952
- function generateFigmaSummary(node, options = {}) {
12953
- const { shouldInferVariableName = false, shouldPrintSource = false, shouldInferAutoLayout = false } = options;
12954
- const codegen = createContext$1({
12955
- shouldInferVariableName,
12956
- shouldInferAutoLayout
12957
- });
12958
- const result = codegen(node);
12959
- return result ? stringifyElement(result, {
12960
- printSource: shouldPrintSource
12961
- }) : undefined;
12962
- }
12963
-
12964
- export { cloneElement, createCodegenTransformer, createElement, createIconService, createPluginNormalizer, createPropsTransformer, createRestNormalizer, createStaticIconRepository, createStaticStyleRepository, createStaticVariableRepository, createStyleService, createValueTransformer, createVariableService, defineComponentTransformer, defineElementTransformer, definePropsTransformer, index$1 as figma, generateCode, generateFigmaSummary, generateJsxTree, getFigmaColorVariableNames, getFigmaStyleKey, getFigmaVariableKey, iconRepository, inferLayout, index as react, styleRepository, variableRepository };
10310
+ export { createIconService, createPluginNormalizer, createRestNormalizer, createStaticIconRepository, createStaticStyleRepository, createStaticVariableRepository, createStyleService, createVariableService, getFigmaColorVariableNames, getFigmaStyleKey, getFigmaVariableKey, iconRepository, styleRepository, variableRepository };