@seed-design/figma 0.0.21 → 0.0.23
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 +8012 -0
- package/lib/codegen/index.d.ts +1828 -0
- package/lib/codegen/index.js +7983 -0
- package/lib/codegen/targets/react/index.cjs +12198 -0
- package/lib/codegen/targets/react/index.d.ts +267 -0
- package/lib/codegen/targets/react/index.js +12180 -0
- package/lib/index.cjs +79 -2741
- package/lib/index.d.ts +17 -1937
- package/lib/index.js +61 -2715
- package/package.json +12 -2
- package/src/codegen/{targets/react/component/properties.type.ts → component-properties.ts} +43 -43
- package/src/codegen/core/codegen.ts +17 -6
- 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/index.ts +14 -14
- package/src/codegen/core/{props.ts → props-converter.ts} +10 -13
- package/src/codegen/core/{value.ts → value-resolver.ts} +87 -50
- 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 +94 -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 +19 -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 +124 -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 +32 -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/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
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { match } from "ts-pattern";
|
|
4
|
-
import type {
|
|
5
|
-
import type { ControlChipProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { ControlChipProperties } from "@/codegen/component-properties";
|
|
6
6
|
import { handleSizeProp } from "../size";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createControlChipHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<ControlChipProperties>(
|
|
10
10
|
metadata.controlChip.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const states = props.State.value.split("-");
|
|
@@ -16,9 +16,7 @@ export const createControlChipTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
16
16
|
layout: "iconOnly",
|
|
17
17
|
children: [
|
|
18
18
|
createElement("Icon", {
|
|
19
|
-
svg:
|
|
20
|
-
ctx.iconService.createIconTagName(props["Icon#8722:41"].componentKey),
|
|
21
|
-
),
|
|
19
|
+
svg: ctx.iconHandler.transform(props["Icon#8722:41"]),
|
|
22
20
|
}),
|
|
23
21
|
],
|
|
24
22
|
}))
|
|
@@ -26,9 +24,7 @@ export const createControlChipTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
26
24
|
layout: "withText",
|
|
27
25
|
children: [
|
|
28
26
|
createElement("PrefixIcon", {
|
|
29
|
-
svg:
|
|
30
|
-
ctx.iconService.createIconTagName(props["Prefix Icon#8722:0"].componentKey),
|
|
31
|
-
),
|
|
27
|
+
svg: ctx.iconHandler.transform(props["Prefix Icon#8722:0"]),
|
|
32
28
|
}),
|
|
33
29
|
props["Label#7185:0"].value,
|
|
34
30
|
],
|
|
@@ -38,9 +34,7 @@ export const createControlChipTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
38
34
|
children: [
|
|
39
35
|
props["Label#7185:0"].value,
|
|
40
36
|
createElement("SuffixIcon", {
|
|
41
|
-
svg:
|
|
42
|
-
ctx.iconService.createIconTagName(props["Suffix Icon#8722:82"].componentKey),
|
|
43
|
-
),
|
|
37
|
+
svg: ctx.iconHandler.transform(props["Suffix Icon#8722:82"]),
|
|
44
38
|
}),
|
|
45
39
|
],
|
|
46
40
|
}))
|
|
@@ -48,15 +42,11 @@ export const createControlChipTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
48
42
|
layout: "withText",
|
|
49
43
|
children: [
|
|
50
44
|
createElement("PrefixIcon", {
|
|
51
|
-
svg:
|
|
52
|
-
ctx.iconService.createIconTagName(props["Prefix Icon#8722:0"].componentKey),
|
|
53
|
-
),
|
|
45
|
+
svg: ctx.iconHandler.transform(props["Prefix Icon#8722:0"]),
|
|
54
46
|
}),
|
|
55
47
|
props["Label#7185:0"].value,
|
|
56
48
|
createElement("SuffixIcon", {
|
|
57
|
-
svg:
|
|
58
|
-
ctx.iconService.createIconTagName(props["Suffix Icon#8722:82"].componentKey),
|
|
59
|
-
),
|
|
49
|
+
svg: ctx.iconHandler.transform(props["Suffix Icon#8722:82"]),
|
|
60
50
|
}),
|
|
61
51
|
],
|
|
62
52
|
}))
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
|
-
import type {
|
|
6
|
-
import type { ActionButtonProperties, ErrorStateProperties } from "
|
|
7
|
-
import {
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
import type { ActionButtonProperties, ErrorStateProperties } from "@/codegen/component-properties";
|
|
7
|
+
import { createActionButtonHandler } from "./action-button";
|
|
8
8
|
|
|
9
|
-
export const
|
|
10
|
-
const
|
|
9
|
+
export const createErrorStateHandler = (ctx: ComponentHandlerDeps) => {
|
|
10
|
+
const actionButtonHandler = createActionButtonHandler(ctx);
|
|
11
11
|
|
|
12
|
-
return
|
|
12
|
+
return defineComponentHandler<ErrorStateProperties>(metadata.errorState.key, (node) => {
|
|
13
13
|
const props = node.componentProperties;
|
|
14
14
|
|
|
15
15
|
const [actionButtonNode] = findAllInstances<ActionButtonProperties>({
|
|
16
16
|
node,
|
|
17
|
-
key:
|
|
17
|
+
key: actionButtonHandler.key,
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
const commonProps = {
|
|
@@ -25,7 +25,7 @@ export const createErrorStateTransformer = (ctx: SeedComponentTransformerDeps) =
|
|
|
25
25
|
description: props["Description#16237:5"].value,
|
|
26
26
|
...(actionButtonNode && {
|
|
27
27
|
primaryActionProps: {
|
|
28
|
-
children:
|
|
28
|
+
children: actionButtonHandler.transform(actionButtonNode).children[0],
|
|
29
29
|
},
|
|
30
30
|
secondaryActionProps: {
|
|
31
31
|
children: props["Secondary Action Label#17042:0"].value,
|
package/src/codegen/targets/react/component/{transformers → handlers}/extended-action-sheet.ts
RENAMED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
6
|
import type {
|
|
7
7
|
ExtendedActionSheetGroupProperties,
|
|
8
8
|
ExtendedActionSheetItemProperties,
|
|
9
9
|
ExtendedActionSheetProperties,
|
|
10
|
-
} from "
|
|
10
|
+
} from "@/codegen/component-properties";
|
|
11
11
|
|
|
12
12
|
const EXTENDED_ACTION_SHEET_ITEM_KEY = "057083e95466da59051119eec0b41d4ad5a07f8f";
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const createExtendedActionSheetItemHandler = (ctx: ComponentHandlerDeps) =>
|
|
14
|
+
defineComponentHandler<ExtendedActionSheetItemProperties>(
|
|
15
15
|
EXTENDED_ACTION_SHEET_ITEM_KEY,
|
|
16
16
|
({ componentProperties: props }) => {
|
|
17
17
|
const states = props.State.value.split("-");
|
|
@@ -26,9 +26,7 @@ const createExtendedActionSheetItemTransformer = (ctx: SeedComponentTransformerD
|
|
|
26
26
|
return createElement("ExtendedActionSheetItem", commonProps, [
|
|
27
27
|
props["Show Prefix Icon#17043:5"].value
|
|
28
28
|
? createElement("PrefixIcon", {
|
|
29
|
-
svg:
|
|
30
|
-
ctx.iconService.createIconTagName(props["Prefix Icon#55948:0"].componentKey),
|
|
31
|
-
),
|
|
29
|
+
svg: ctx.iconHandler.transform(props["Prefix Icon#55948:0"]),
|
|
32
30
|
})
|
|
33
31
|
: undefined,
|
|
34
32
|
props["Label#55905:8"].value,
|
|
@@ -37,38 +35,38 @@ const createExtendedActionSheetItemTransformer = (ctx: SeedComponentTransformerD
|
|
|
37
35
|
);
|
|
38
36
|
|
|
39
37
|
const EXTENDED_ACTION_SHEET_GROUP_KEY = "2a504a1c6b7810d5e652862dcba2cb7048f9eb16";
|
|
40
|
-
const
|
|
41
|
-
const
|
|
38
|
+
const createExtendedActionSheetGroupHandler = (ctx: ComponentHandlerDeps) => {
|
|
39
|
+
const extendedActionSheetItemHandler = createExtendedActionSheetItemHandler(ctx);
|
|
42
40
|
|
|
43
|
-
return
|
|
41
|
+
return defineComponentHandler<ExtendedActionSheetGroupProperties>(
|
|
44
42
|
EXTENDED_ACTION_SHEET_GROUP_KEY,
|
|
45
43
|
(node) => {
|
|
46
44
|
const items = findAllInstances<ExtendedActionSheetItemProperties>({
|
|
47
45
|
node,
|
|
48
|
-
key:
|
|
46
|
+
key: extendedActionSheetItemHandler.key,
|
|
49
47
|
});
|
|
50
48
|
|
|
51
|
-
const contentChildren = items.map(
|
|
49
|
+
const contentChildren = items.map(extendedActionSheetItemHandler.transform);
|
|
52
50
|
|
|
53
51
|
return createElement("ExtendedActionSheetGroup", undefined, contentChildren);
|
|
54
52
|
},
|
|
55
53
|
);
|
|
56
54
|
};
|
|
57
55
|
|
|
58
|
-
export const
|
|
59
|
-
const
|
|
56
|
+
export const createExtendedActionSheetHandler = (ctx: ComponentHandlerDeps) => {
|
|
57
|
+
const extendedActionSheetGroupHandler = createExtendedActionSheetGroupHandler(ctx);
|
|
60
58
|
|
|
61
|
-
return
|
|
59
|
+
return defineComponentHandler<ExtendedActionSheetProperties>(
|
|
62
60
|
metadata.extendedActionSheet.key,
|
|
63
61
|
(node) => {
|
|
64
62
|
const { componentProperties: props } = node;
|
|
65
63
|
|
|
66
64
|
const groups = findAllInstances<ExtendedActionSheetGroupProperties>({
|
|
67
65
|
node,
|
|
68
|
-
key:
|
|
66
|
+
key: extendedActionSheetGroupHandler.key,
|
|
69
67
|
});
|
|
70
68
|
|
|
71
|
-
const contentChildren = groups.map(
|
|
69
|
+
const contentChildren = groups.map(extendedActionSheetGroupHandler.transform);
|
|
72
70
|
|
|
73
71
|
const title = props["Show Title#17043:12"].value ? props["Title#14599:0"].value : undefined;
|
|
74
72
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
|
-
import type {
|
|
5
|
-
import type { ExtendedFabProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { ExtendedFabProperties } from "@/codegen/component-properties";
|
|
6
6
|
import { handleSizeProp } from "../size";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createExtendedFabHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<ExtendedFabProperties>(
|
|
10
10
|
metadata.extendedFloatingActionButton.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const commonProps = {
|
|
@@ -16,7 +16,7 @@ export const createExtendedFabTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
16
16
|
|
|
17
17
|
return createElement("ExtendedFab", commonProps, [
|
|
18
18
|
createElement("PrefixIcon", {
|
|
19
|
-
svg:
|
|
19
|
+
svg: ctx.iconHandler.transform(props["Icon#28796:0"]),
|
|
20
20
|
}),
|
|
21
21
|
props["Label#28936:0"].value,
|
|
22
22
|
]);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
+
import { createElement } from "@/codegen/core";
|
|
4
|
+
import type { FabProperties } from "@/codegen/component-properties";
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
|
|
7
|
+
export const createFabHandler = (ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<FabProperties>(
|
|
9
|
+
metadata.floatingActionButton.key,
|
|
10
|
+
({ componentProperties: props }) => {
|
|
11
|
+
return createElement(
|
|
12
|
+
"Fab",
|
|
13
|
+
undefined,
|
|
14
|
+
ctx.iconHandler.transform(props["Icon#28796:0"]),
|
|
15
|
+
"aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.",
|
|
16
|
+
);
|
|
17
|
+
},
|
|
18
|
+
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { createElement } from "@/codegen/core";
|
|
4
|
-
import type { HelpBubbleProperties } from "
|
|
5
|
-
import type {
|
|
4
|
+
import type { HelpBubbleProperties } from "@/codegen/component-properties";
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createHelpBubbleHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<HelpBubbleProperties>(
|
|
9
9
|
metadata.helpBubble.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const placement:
|
package/src/codegen/targets/react/component/{transformers → handlers}/identity-placeholder.ts
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import { camelCase } from "change-case";
|
|
3
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
4
4
|
import { createElement } from "@/codegen/core";
|
|
5
|
-
import type { IdentityPlaceholderProperties } from "
|
|
6
|
-
import type {
|
|
5
|
+
import type { IdentityPlaceholderProperties } from "@/codegen/component-properties";
|
|
6
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createIdentityPlaceholderHandler = (_ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<IdentityPlaceholderProperties>(
|
|
10
10
|
metadata.identityPlaceholder.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const commonProps = {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { InlineBannerProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
4
|
import type { NormalizedInstanceNode, NormalizedTextNode } from "@/normalizer";
|
|
4
5
|
import { findOne } from "@/utils/figma-node";
|
|
5
6
|
import { camelCase } from "change-case";
|
|
6
|
-
import type {
|
|
7
|
-
import type { InlineBannerProperties } from "../properties.type";
|
|
7
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
8
8
|
|
|
9
|
-
export const
|
|
10
|
-
|
|
9
|
+
export const createInlineBannerHandler = (ctx: ComponentHandlerDeps) =>
|
|
10
|
+
defineComponentHandler<InlineBannerProperties>(metadata.inlineBanner.key, (node) => {
|
|
11
11
|
const { componentProperties: props } = node;
|
|
12
12
|
|
|
13
13
|
const tag = (() => {
|
|
@@ -58,11 +58,8 @@ export const createInlineBannerTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
58
58
|
(child) => child.type === "INSTANCE" && child.name === "icon",
|
|
59
59
|
) as NormalizedInstanceNode | null;
|
|
60
60
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const prefixIcon = iconComponentKey
|
|
64
|
-
? createElement(ctx.iconService.createIconTagName(iconComponentKey))
|
|
65
|
-
: undefined;
|
|
61
|
+
const showIcon = props["Show Icon#11840:27"] && iconNode;
|
|
62
|
+
const prefixIcon = showIcon ? ctx.iconHandler.transform(iconNode) : undefined;
|
|
66
63
|
|
|
67
64
|
const commonProps = {
|
|
68
65
|
variant: camelCase(props.Variant.value),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { MannerTempBadgeProperties } from "
|
|
3
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
4
|
+
import type { MannerTempBadgeProperties } from "@/codegen/component-properties";
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
|
|
6
|
+
export const createMannerTempBadgeHandler = (_ctx: ComponentHandlerDeps) =>
|
|
7
|
+
defineComponentHandler<MannerTempBadgeProperties>(
|
|
8
8
|
metadata.mannerTempBadge.key,
|
|
9
9
|
({ children }) => {
|
|
10
10
|
const textNode = children.find((child) => child.type === "TEXT");
|
package/src/codegen/targets/react/component/{transformers → handlers}/multiline-text-field.ts
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { MultilineTextFieldProperties } from "
|
|
3
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
4
|
+
import type { MultilineTextFieldProperties } from "@/codegen/component-properties";
|
|
5
5
|
import { handleSizeProp } from "../size";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createMultilineTextFieldHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<MultilineTextFieldProperties>(
|
|
9
9
|
metadata.multilineTextField.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
4
|
import { match } from "ts-pattern";
|
|
5
|
-
import type {
|
|
6
|
-
import type { ProgressCircleProperties } from "
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
import type { ProgressCircleProperties } from "@/codegen/component-properties";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createProgressCircleHandler = (_ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<ProgressCircleProperties>(
|
|
10
10
|
metadata.progressCircle.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const { value, minValue, maxValue } = match(props.Value.value)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactionButtonProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { ReactionButtonProperties } from "../properties.type";
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
5
|
import { handleSizeProp } from "../size";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createReactionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<ReactionButtonProperties>(
|
|
9
9
|
metadata.reactionButton.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const states = props.State.value.split("-");
|
|
@@ -25,7 +25,7 @@ export const createReactionButtonTransformer = (ctx: SeedComponentTransformerDep
|
|
|
25
25
|
|
|
26
26
|
return createElement("ReactionButton", commonProps, [
|
|
27
27
|
createElement("PrefixIcon", {
|
|
28
|
-
svg:
|
|
28
|
+
svg: ctx.iconHandler.transform(props["Icon#12379:0"]),
|
|
29
29
|
}),
|
|
30
30
|
props["Label#6397:0"].value,
|
|
31
31
|
props["Show Count#6397:33"].value
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
5
|
import type {
|
|
6
6
|
SegmentedControlItemProperties,
|
|
7
7
|
SegmentedControlProperties,
|
|
8
|
-
} from "
|
|
8
|
+
} from "@/codegen/component-properties";
|
|
9
9
|
|
|
10
10
|
const SEGMENTED_CONTROL_ITEM_KEY = "9a7ba0d4c041ddbce84ee48881788434fd6bccc8";
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const createSegmentedControlItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
12
|
+
defineComponentHandler<SegmentedControlItemProperties>(
|
|
13
13
|
SEGMENTED_CONTROL_ITEM_KEY,
|
|
14
14
|
({ componentProperties: props }) => {
|
|
15
15
|
const states = props.State.value.split("-");
|
|
@@ -24,22 +24,22 @@ const createSegmentedControlItemTransformer = (_ctx: SeedComponentTransformerDep
|
|
|
24
24
|
},
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
export const
|
|
28
|
-
const
|
|
27
|
+
export const createSegmentedControlHandler = (ctx: ComponentHandlerDeps) => {
|
|
28
|
+
const segmentedControlItemHandler = createSegmentedControlItemHandler(ctx);
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return defineComponentHandler<SegmentedControlProperties>(
|
|
31
31
|
metadata.segmentedControl.key,
|
|
32
32
|
(node) => {
|
|
33
33
|
const segments = findAllInstances<SegmentedControlItemProperties>({
|
|
34
34
|
node,
|
|
35
|
-
key:
|
|
35
|
+
key: segmentedControlItemHandler.key,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
const selectedSegment = segments.find((segment) =>
|
|
39
39
|
segment.componentProperties.State.value.split("-").includes("Selected"),
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const segmentedControlChildren = segments.map(
|
|
42
|
+
const segmentedControlChildren = segments.map(segmentedControlItemHandler.transform);
|
|
43
43
|
|
|
44
44
|
const commonProps = {
|
|
45
45
|
...(selectedSegment && {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
|
-
import type {
|
|
5
|
-
import type { SelectBoxGroupProperties, SelectBoxProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { SelectBoxGroupProperties, SelectBoxProperties } from "@/codegen/component-properties";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createSelectBoxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<SelectBoxProperties>(
|
|
9
9
|
metadata.selectBox.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const tag = (() => {
|
|
@@ -37,10 +37,10 @@ export const createSelectBoxTransformer = (_ctx: SeedComponentTransformerDeps) =
|
|
|
37
37
|
},
|
|
38
38
|
);
|
|
39
39
|
|
|
40
|
-
export const
|
|
41
|
-
const
|
|
40
|
+
export const createSelectBoxGroupHandler = (ctx: ComponentHandlerDeps) => {
|
|
41
|
+
const selectBoxHandler = createSelectBoxHandler(ctx);
|
|
42
42
|
|
|
43
|
-
return
|
|
43
|
+
return defineComponentHandler<SelectBoxGroupProperties>(
|
|
44
44
|
metadata.templateSelectBoxGroup.key,
|
|
45
45
|
(node) => {
|
|
46
46
|
const props = node.componentProperties;
|
|
@@ -56,7 +56,7 @@ export const createSelectBoxGroupTransformer = (ctx: SeedComponentTransformerDep
|
|
|
56
56
|
|
|
57
57
|
const selectBoxes = findAllInstances<SelectBoxProperties>({
|
|
58
58
|
node,
|
|
59
|
-
key:
|
|
59
|
+
key: selectBoxHandler.key,
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
const selectedSelectBox = selectBoxes.find((selectBox) =>
|
|
@@ -66,7 +66,7 @@ export const createSelectBoxGroupTransformer = (ctx: SeedComponentTransformerDep
|
|
|
66
66
|
const stack = createElement(
|
|
67
67
|
"Stack",
|
|
68
68
|
{ gap: "spacingY.componentDefault" },
|
|
69
|
-
selectBoxes.map(
|
|
69
|
+
selectBoxes.map(selectBoxHandler.transform),
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
const commonProps = {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
+
import { camelCase } from "change-case";
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { SkeletonProperties } from "@/codegen/component-properties";
|
|
6
|
+
import { match } from "ts-pattern";
|
|
7
|
+
|
|
8
|
+
export const createSkeletonHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<SkeletonProperties>(metadata.skeleton.key, (node) => {
|
|
10
|
+
const { componentProperties: props, layoutSizingHorizontal, layoutSizingVertical } = node;
|
|
11
|
+
|
|
12
|
+
const commonProps = {
|
|
13
|
+
radius: camelCase(props.Radius.value),
|
|
14
|
+
width: match(layoutSizingHorizontal)
|
|
15
|
+
.with("FIXED", () => ctx.valueResolver.getFormattedValue.width(node))
|
|
16
|
+
.with("FILL", () => "full")
|
|
17
|
+
.otherwise(() => "full"),
|
|
18
|
+
height: match(layoutSizingVertical)
|
|
19
|
+
.with("FIXED", () => ctx.valueResolver.getFormattedValue.height(node))
|
|
20
|
+
.with("FILL", () => "full")
|
|
21
|
+
.otherwise(() => "full"),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return createElement("Skeleton", commonProps);
|
|
25
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
|
-
import type {
|
|
5
|
-
import type { SnackbarProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { SnackbarProperties } from "@/codegen/component-properties";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createSnackbarHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<SnackbarProperties>(
|
|
9
9
|
metadata.snackbar.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const commonProps = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { SwitchProperties } from "
|
|
3
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
4
|
+
import type { SwitchProperties } from "@/codegen/component-properties";
|
|
5
5
|
import { handleSizeProp } from "../size";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createSwitchHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<SwitchProperties>(
|
|
9
9
|
metadata.switch.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const states = props.State.value.split("-");
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import type { NormalizedInstanceNode } from "@/normalizer";
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
6
|
import type {
|
|
7
7
|
TabsFillItemProperties,
|
|
8
8
|
TabsHugItemProperties,
|
|
9
9
|
TabsProperties,
|
|
10
|
-
} from "
|
|
10
|
+
} from "@/codegen/component-properties";
|
|
11
11
|
import { handleSizeProp } from "../size";
|
|
12
12
|
|
|
13
13
|
const TABS_HUG_ITEM_KEY = "c242492543b327ceb84fa9933841512fc62a898c";
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const createTabsHugItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
15
|
+
defineComponentHandler<TabsHugItemProperties>(
|
|
16
16
|
TABS_HUG_ITEM_KEY,
|
|
17
17
|
({ componentProperties: props }) => {
|
|
18
18
|
const states = props.State.value.split("-");
|
|
@@ -32,8 +32,8 @@ const createTabsHugItemTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const TABS_FILL_ITEM_KEY = "7275293344efb40ee9a3f5248ba2659b94a0b305";
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const createTabsFillItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
36
|
+
defineComponentHandler<TabsFillItemProperties>(
|
|
37
37
|
TABS_FILL_ITEM_KEY,
|
|
38
38
|
({ componentProperties: props }) => {
|
|
39
39
|
const states = props.State.value.split("-");
|
|
@@ -52,11 +52,11 @@ const createTabsFillItemTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
52
52
|
},
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
export const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
55
|
+
export const createTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
56
|
+
const tabsHugItemHandler = createTabsHugItemHandler(ctx);
|
|
57
|
+
const tabsFillItemHandler = createTabsFillItemHandler(ctx);
|
|
58
58
|
|
|
59
|
-
return
|
|
59
|
+
return defineComponentHandler<TabsProperties>(metadata.tablist.key, (node) => {
|
|
60
60
|
const { componentProperties: props, children } = node;
|
|
61
61
|
|
|
62
62
|
const mappedItems = children.map(
|
|
@@ -72,13 +72,13 @@ export const createTabsTransformer = (ctx: SeedComponentTransformerDeps) => {
|
|
|
72
72
|
|
|
73
73
|
const componentKey = child.componentSetKey ? child.componentSetKey : child.componentKey;
|
|
74
74
|
|
|
75
|
-
if (componentKey ===
|
|
75
|
+
if (componentKey === tabsHugItemHandler.key)
|
|
76
76
|
return {
|
|
77
77
|
triggerLayout: "hug" as const,
|
|
78
78
|
node: child as NormalizedInstanceNode & { componentProperties: TabsHugItemProperties },
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
if (componentKey ===
|
|
81
|
+
if (componentKey === tabsFillItemHandler.key)
|
|
82
82
|
return {
|
|
83
83
|
triggerLayout: "fill" as const,
|
|
84
84
|
node: child as NormalizedInstanceNode & { componentProperties: TabsFillItemProperties },
|
|
@@ -102,9 +102,9 @@ export const createTabsTransformer = (ctx: SeedComponentTransformerDeps) => {
|
|
|
102
102
|
tabsItems.map(({ triggerLayout, node }) => {
|
|
103
103
|
switch (triggerLayout) {
|
|
104
104
|
case "hug":
|
|
105
|
-
return
|
|
105
|
+
return tabsHugItemHandler.transform(node);
|
|
106
106
|
case "fill":
|
|
107
|
-
return
|
|
107
|
+
return tabsFillItemHandler.transform(node);
|
|
108
108
|
}
|
|
109
109
|
}),
|
|
110
110
|
);
|