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