@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
|
@@ -1,19 +1,19 @@
|
|
|
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, NormalizedTextNode } from "@/normalizer";
|
|
4
4
|
import { findAll, findAllInstances, findOne } from "@/utils/figma-node";
|
|
5
5
|
import { match } from "ts-pattern";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
7
7
|
import type {
|
|
8
8
|
AppBarLeftProperties,
|
|
9
9
|
AppBarMainProperties,
|
|
10
10
|
AppBarProperties,
|
|
11
11
|
AppBarRightProperties,
|
|
12
|
-
} from "
|
|
12
|
+
} from "@/codegen/component-properties";
|
|
13
13
|
|
|
14
14
|
const APP_BAR_MAIN_KEY = "336b49b26c3933485d87cc460b06c390976ea58e";
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const createAppBarMainHandler = (_ctx: ComponentHandlerDeps) =>
|
|
16
|
+
defineComponentHandler<AppBarMainProperties>(
|
|
17
17
|
APP_BAR_MAIN_KEY,
|
|
18
18
|
({ componentProperties: props }) => {
|
|
19
19
|
const { title, subtitle, layout } = match(props.Type.value)
|
|
@@ -49,8 +49,8 @@ const createAppBarMainTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
const APP_BAR_LEFT_KEY = "e5d2e47052a22395db79f195a0991a570dc1b6c9";
|
|
52
|
-
const
|
|
53
|
-
|
|
52
|
+
const createAppBarLeftHandler = (ctx: ComponentHandlerDeps) =>
|
|
53
|
+
defineComponentHandler<AppBarLeftProperties>(APP_BAR_LEFT_KEY, (node) => {
|
|
54
54
|
const props = node.componentProperties;
|
|
55
55
|
|
|
56
56
|
const children = (() => {
|
|
@@ -65,17 +65,15 @@ const createAppBarLeftTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
65
65
|
(child) => child.type === "INSTANCE" && child.name === "Icon",
|
|
66
66
|
) as NormalizedInstanceNode | null;
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
if (!iconNode) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
69
71
|
|
|
70
72
|
return createElement(
|
|
71
73
|
"AppBarIconButton",
|
|
72
74
|
undefined,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
: undefined,
|
|
76
|
-
iconComponentKey === undefined
|
|
77
|
-
? "아이콘과, aria-label 또는 aria-labelledby를 제공해주세요."
|
|
78
|
-
: "aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
75
|
+
ctx.iconHandler.transform(iconNode),
|
|
76
|
+
"aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
79
77
|
);
|
|
80
78
|
}
|
|
81
79
|
}
|
|
@@ -85,8 +83,8 @@ const createAppBarLeftTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
85
83
|
});
|
|
86
84
|
|
|
87
85
|
const APP_BAR_RIGHT_KEY = "9e157fc2d1f89ffee938a5bc62f4a58064fec44e";
|
|
88
|
-
const
|
|
89
|
-
|
|
86
|
+
const createAppBarRightHandler = (ctx: ComponentHandlerDeps) =>
|
|
87
|
+
defineComponentHandler<AppBarRightProperties>(APP_BAR_RIGHT_KEY, (node) => {
|
|
90
88
|
const props = node.componentProperties;
|
|
91
89
|
|
|
92
90
|
const children = (() => {
|
|
@@ -105,18 +103,12 @@ const createAppBarRightTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
105
103
|
(child) => child.type === "INSTANCE" && child.name === "Icon",
|
|
106
104
|
) as NormalizedInstanceNode[];
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return iconComponentKeys.map((iconComponentKey) =>
|
|
106
|
+
return iconNodes.map((iconNode) =>
|
|
111
107
|
createElement(
|
|
112
108
|
"AppBarIconButton",
|
|
113
109
|
undefined,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
: undefined,
|
|
117
|
-
iconComponentKey === undefined
|
|
118
|
-
? "아이콘과, aria-label 또는 aria-labelledby를 제공해주세요."
|
|
119
|
-
: "aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
110
|
+
ctx.iconHandler.transform(iconNode),
|
|
111
|
+
"aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
120
112
|
),
|
|
121
113
|
);
|
|
122
114
|
}
|
|
@@ -126,12 +118,12 @@ const createAppBarRightTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
126
118
|
return createElement("AppBarRight", undefined, children);
|
|
127
119
|
});
|
|
128
120
|
|
|
129
|
-
export const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const
|
|
121
|
+
export const createAppBarHandler = (ctx: ComponentHandlerDeps) => {
|
|
122
|
+
const appBarMainHandler = createAppBarMainHandler(ctx);
|
|
123
|
+
const appBarLeftHandler = createAppBarLeftHandler(ctx);
|
|
124
|
+
const appBarRightHandler = createAppBarRightHandler(ctx);
|
|
133
125
|
|
|
134
|
-
return
|
|
126
|
+
return defineComponentHandler<AppBarProperties>(metadata.standardNavigation.key, (node) => {
|
|
135
127
|
const props = node.componentProperties;
|
|
136
128
|
|
|
137
129
|
const theme = (() => {
|
|
@@ -153,25 +145,25 @@ export const createAppBarTransformer = (ctx: SeedComponentTransformerDeps) => {
|
|
|
153
145
|
})();
|
|
154
146
|
|
|
155
147
|
const mainNode = findAllInstances<AppBarMainProperties>({
|
|
156
|
-
key:
|
|
148
|
+
key: appBarMainHandler.key,
|
|
157
149
|
node,
|
|
158
150
|
});
|
|
159
151
|
const onlyMainNode = mainNode.length === 1 ? mainNode[0] : undefined;
|
|
160
|
-
const main = onlyMainNode ?
|
|
152
|
+
const main = onlyMainNode ? appBarMainHandler.transform(onlyMainNode) : undefined;
|
|
161
153
|
|
|
162
154
|
const leftNode = findAllInstances<AppBarLeftProperties>({
|
|
163
|
-
key:
|
|
155
|
+
key: appBarLeftHandler.key,
|
|
164
156
|
node,
|
|
165
157
|
});
|
|
166
158
|
const onlyLeftNode = leftNode.length === 1 ? leftNode[0] : undefined;
|
|
167
|
-
const left = onlyLeftNode ?
|
|
159
|
+
const left = onlyLeftNode ? appBarLeftHandler.transform(onlyLeftNode) : undefined;
|
|
168
160
|
|
|
169
161
|
const rightNode = findAllInstances<AppBarRightProperties>({
|
|
170
|
-
key:
|
|
162
|
+
key: appBarRightHandler.key,
|
|
171
163
|
node,
|
|
172
164
|
});
|
|
173
165
|
const onlyRightNode = rightNode.length === 1 ? rightNode[0] : undefined;
|
|
174
|
-
const right = onlyRightNode ?
|
|
166
|
+
const right = onlyRightNode ? appBarRightHandler.transform(onlyRightNode) : undefined;
|
|
175
167
|
|
|
176
168
|
return createElement(
|
|
177
169
|
"AppBar",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
+
import { findAllInstances } from "@/utils/figma-node";
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { AvatarProperties, AvatarStackProperties } from "@/codegen/component-properties";
|
|
6
|
+
import { createAvatarHandler } from "./avatar";
|
|
7
|
+
|
|
8
|
+
export const createAvatarStackHandler = (ctx: ComponentHandlerDeps) => {
|
|
9
|
+
const avatarHandler = createAvatarHandler(ctx);
|
|
10
|
+
|
|
11
|
+
return defineComponentHandler<AvatarStackProperties>(metadata.avatarStack.key, (node) => {
|
|
12
|
+
const avatarNodes = findAllInstances<AvatarProperties>({
|
|
13
|
+
node,
|
|
14
|
+
key: avatarHandler.key,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const { componentProperties: props } = node;
|
|
18
|
+
|
|
19
|
+
const commonProps = {
|
|
20
|
+
size: props.Size.value,
|
|
21
|
+
// TODO: 구현될 예정
|
|
22
|
+
// topItem: camelCase(props["Top Item"].value),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const avatarStackChildren = avatarNodes.map(avatarHandler.transform);
|
|
26
|
+
|
|
27
|
+
return createElement("AvatarStack", commonProps, avatarStackChildren);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
@@ -1,17 +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
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type {
|
|
6
|
+
AvatarProperties,
|
|
7
|
+
IdentityPlaceholderProperties,
|
|
8
|
+
} from "@/codegen/component-properties";
|
|
9
|
+
import { createIdentityPlaceholderHandler } from "./identity-placeholder";
|
|
7
10
|
|
|
8
|
-
export const
|
|
9
|
-
const
|
|
11
|
+
export const createAvatarHandler = (ctx: ComponentHandlerDeps) => {
|
|
12
|
+
const identityPlaceholderHandler = createIdentityPlaceholderHandler(ctx);
|
|
10
13
|
|
|
11
|
-
return
|
|
14
|
+
return defineComponentHandler<AvatarProperties>(metadata.avatar.key, (node) => {
|
|
12
15
|
const [placeholder] = findAllInstances<IdentityPlaceholderProperties>({
|
|
13
16
|
node,
|
|
14
|
-
key:
|
|
17
|
+
key: identityPlaceholderHandler.key,
|
|
15
18
|
});
|
|
16
19
|
const { componentProperties: props } = node;
|
|
17
20
|
|
|
@@ -23,7 +26,7 @@ export const createAvatarTransformer = (ctx: SeedComponentTransformerDeps) => {
|
|
|
23
26
|
src: `https://placehold.co/${props.Size.value}x${props.Size.value}`,
|
|
24
27
|
}),
|
|
25
28
|
...(placeholder && {
|
|
26
|
-
fallback:
|
|
29
|
+
fallback: identityPlaceholderHandler.transform(placeholder),
|
|
27
30
|
}),
|
|
28
31
|
size: props.Size.value,
|
|
29
32
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { BadgeProperties } from "@/codegen/component-properties";
|
|
6
|
+
import { handleSizeProp } from "../size";
|
|
7
|
+
|
|
8
|
+
export const createBadgeHandler = (_ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<BadgeProperties>(metadata.badge.key, ({ componentProperties: props }) => {
|
|
10
|
+
const commonProps = {
|
|
11
|
+
size: handleSizeProp(props.Size.value),
|
|
12
|
+
tone: camelCase(props.Tone.value),
|
|
13
|
+
variant: camelCase(props.Variant.value),
|
|
14
|
+
shape: camelCase(props.Shape.value),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return createElement("Badge", commonProps, props["Label#1584:0"].value);
|
|
18
|
+
});
|
|
@@ -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 type { NormalizedTextNode } from "@/normalizer";
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
|
-
import type {
|
|
6
|
-
import type { CalloutProperties } from "
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
import type { CalloutProperties } from "@/codegen/component-properties";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createCalloutHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<CalloutProperties>(
|
|
10
10
|
metadata.callout.key,
|
|
11
11
|
({ componentProperties: props, children }) => {
|
|
12
12
|
const tag = (() => {
|
|
@@ -78,9 +78,7 @@ export const createCalloutTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
78
78
|
children: linkLabel,
|
|
79
79
|
},
|
|
80
80
|
...(props["Icon#12598:210"].value && {
|
|
81
|
-
prefixIcon:
|
|
82
|
-
ctx.iconService.createIconTagName(props["Icon#12598:210"].componentKey),
|
|
83
|
-
),
|
|
81
|
+
prefixIcon: ctx.iconHandler.transform(props["Icon#12598:210"]),
|
|
84
82
|
}),
|
|
85
83
|
};
|
|
86
84
|
|
|
@@ -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 { CheckboxProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { CheckboxProperties } from "@/codegen/component-properties";
|
|
6
6
|
import { handleSizeProp } from "../size";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createCheckboxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<CheckboxProperties>(
|
|
10
10
|
metadata.checkbox.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const states = props.State.value.split("-");
|
|
@@ -1,13 +1,13 @@
|
|
|
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 { ChipTabsItemProperties, ChipTabsProperties } from "
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
import type { ChipTabsItemProperties, ChipTabsProperties } from "@/codegen/component-properties";
|
|
7
7
|
|
|
8
8
|
const CHIP_TABS_ITEM_KEY = "fa80168b02051fbb0ba032238bd76d840dbe2e15";
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const createChipTabsItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
10
|
+
defineComponentHandler<ChipTabsItemProperties>(
|
|
11
11
|
CHIP_TABS_ITEM_KEY,
|
|
12
12
|
({ componentProperties: props }) => {
|
|
13
13
|
const states = props.State.value.split("-");
|
|
@@ -23,13 +23,13 @@ const createChipTabsItemTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
23
23
|
},
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
export const
|
|
27
|
-
const
|
|
26
|
+
export const createChipTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
27
|
+
const chipTabsItemHandler = createChipTabsItemHandler(ctx);
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return defineComponentHandler<ChipTabsProperties>(metadata.chipTablist.key, (node) => {
|
|
30
30
|
const chipTabsItems = findAllInstances<ChipTabsItemProperties>({
|
|
31
31
|
node,
|
|
32
|
-
key:
|
|
32
|
+
key: chipTabsItemHandler.key,
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
const selectedChipTabsItem = chipTabsItems.find((chipTabsItem) =>
|
|
@@ -39,7 +39,7 @@ export const createChipTabsTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
39
39
|
const chipTabsList = createElement(
|
|
40
40
|
"ChipTabsList",
|
|
41
41
|
undefined,
|
|
42
|
-
chipTabsItems.map(
|
|
42
|
+
chipTabsItems.map(chipTabsItemHandler.transform),
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
const commonProps = {
|
|
@@ -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),
|