@seed-design/figma 1.2.0 → 1.3.2
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 +12318 -190
- package/lib/codegen/index.d.ts.map +1 -1
- package/lib/codegen/index.js +12318 -190
- package/lib/codegen/targets/react/index.cjs +17676 -3101
- package/lib/codegen/targets/react/index.d.ts.map +1 -1
- package/lib/codegen/targets/react/index.js +17676 -3101
- package/lib/index.cjs +12324 -196
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +12324 -196
- package/package.json +4 -4
- package/src/codegen/component-properties.archive.ts +1019 -0
- package/src/codegen/component-properties.ts +219 -893
- package/src/codegen/core/infer-layout.test.ts +1 -1
- package/src/codegen/index.ts +1 -1
- package/src/codegen/targets/react/component/handlers/action-button.ts +69 -66
- package/src/codegen/targets/react/component/handlers/alert-dialog.ts +2 -4
- package/src/codegen/targets/react/component/handlers/app-bar.ts +90 -87
- package/src/codegen/targets/react/component/handlers/archive/action-button.ts +144 -0
- package/src/codegen/targets/react/component/handlers/archive/alert-dialog.ts +122 -0
- package/src/codegen/targets/react/component/handlers/archive/app-bar.ts +149 -0
- package/src/codegen/targets/react/component/handlers/archive/avatar-stack.ts +35 -0
- package/src/codegen/targets/react/component/handlers/archive/avatar.ts +55 -0
- package/src/codegen/targets/react/component/handlers/archive/badge.ts +18 -0
- package/src/codegen/targets/react/component/handlers/archive/bottom-sheet.ts +70 -0
- package/src/codegen/targets/react/component/handlers/archive/callout.ts +88 -0
- package/src/codegen/targets/react/component/handlers/archive/checkbox.ts +43 -0
- package/src/codegen/targets/react/component/handlers/archive/checkmark.ts +29 -0
- package/src/codegen/targets/react/component/handlers/archive/chip.ts +90 -0
- package/src/codegen/targets/react/component/handlers/archive/contextual-floating-button.ts +52 -0
- package/src/codegen/targets/react/component/handlers/archive/divider.ts +25 -0
- package/src/codegen/targets/react/component/handlers/archive/field-button.ts +197 -0
- package/src/codegen/targets/react/component/handlers/archive/field.ts +167 -0
- package/src/codegen/targets/react/component/handlers/archive/floating-action-button.ts +48 -0
- package/src/codegen/targets/react/component/handlers/archive/help-bubble.ts +73 -0
- package/src/codegen/targets/react/component/handlers/archive/identity-placeholder.ts +21 -0
- package/src/codegen/targets/react/component/handlers/archive/index.ts +40 -0
- package/src/codegen/targets/react/component/handlers/archive/legacy-select-box.ts +89 -0
- package/src/codegen/targets/react/component/handlers/archive/legacy-text-field.ts +198 -0
- package/src/codegen/targets/react/component/handlers/archive/list-header.ts +20 -0
- package/src/codegen/targets/react/component/handlers/archive/list-item.ts +162 -0
- package/src/codegen/targets/react/component/handlers/archive/manner-temp-badge.ts +21 -0
- package/src/codegen/targets/react/component/handlers/archive/manner-temp.ts +18 -0
- package/src/codegen/targets/react/component/handlers/archive/menu-sheet.ts +108 -0
- package/src/codegen/targets/react/component/handlers/archive/page-banner.ts +101 -0
- package/src/codegen/targets/react/component/handlers/archive/progress-circle.ts +55 -0
- package/src/codegen/targets/react/component/handlers/archive/radio-group.ts +31 -0
- package/src/codegen/targets/react/component/handlers/archive/radiomark.ts +27 -0
- package/src/codegen/targets/react/component/handlers/archive/reaction-button.ts +37 -0
- package/src/codegen/targets/react/component/handlers/archive/result-section.ts +67 -0
- package/src/codegen/targets/react/component/handlers/archive/segmented-control.ts +64 -0
- package/src/codegen/targets/react/component/handlers/archive/skeleton.ts +26 -0
- package/src/codegen/targets/react/component/handlers/archive/slider.ts +114 -0
- package/src/codegen/targets/react/component/handlers/archive/snackbar.ts +25 -0
- package/src/codegen/targets/react/component/handlers/archive/switch.ts +39 -0
- package/src/codegen/targets/react/component/handlers/archive/switchmark.ts +26 -0
- package/src/codegen/targets/react/component/handlers/archive/tabs.ts +297 -0
- package/src/codegen/targets/react/component/handlers/archive/tag-group.ts +86 -0
- package/src/codegen/targets/react/component/handlers/archive/text-field.ts +264 -0
- package/src/codegen/targets/react/component/handlers/archive/toggle-button.ts +43 -0
- package/src/codegen/targets/react/component/handlers/avatar-stack.ts +5 -2
- package/src/codegen/targets/react/component/handlers/avatar.ts +42 -39
- package/src/codegen/targets/react/component/handlers/badge.ts +1 -1
- package/src/codegen/targets/react/component/handlers/bottom-sheet.ts +56 -51
- package/src/codegen/targets/react/component/handlers/callout.ts +1 -1
- package/src/codegen/targets/react/component/handlers/checkbox.ts +91 -3
- package/src/codegen/targets/react/component/handlers/checkmark.ts +1 -1
- package/src/codegen/targets/react/component/handlers/chip.ts +8 -5
- package/src/codegen/targets/react/component/handlers/contextual-floating-button.ts +1 -1
- package/src/codegen/targets/react/component/handlers/divider.ts +1 -1
- package/src/codegen/targets/react/component/handlers/field-button.ts +13 -18
- package/src/codegen/targets/react/component/handlers/field.ts +71 -74
- package/src/codegen/targets/react/component/handlers/floating-action-button.ts +3 -6
- package/src/codegen/targets/react/component/handlers/help-bubble.ts +1 -1
- package/src/codegen/targets/react/component/handlers/identity-placeholder.ts +10 -2
- package/src/codegen/targets/react/component/handlers/index.ts +41 -0
- package/src/codegen/targets/react/component/handlers/legacy-select-box.ts +4 -6
- package/src/codegen/targets/react/component/handlers/legacy-text-field.ts +3 -5
- package/src/codegen/targets/react/component/handlers/list-header.ts +1 -1
- package/src/codegen/targets/react/component/handlers/list-item.ts +24 -23
- package/src/codegen/targets/react/component/handlers/manner-temp-badge.ts +1 -1
- package/src/codegen/targets/react/component/handlers/manner-temp.ts +1 -1
- package/src/codegen/targets/react/component/handlers/menu-sheet.ts +45 -42
- package/src/codegen/targets/react/component/handlers/page-banner.ts +77 -72
- package/src/codegen/targets/react/component/handlers/progress-circle.ts +1 -1
- package/src/codegen/targets/react/component/handlers/radio-group.ts +98 -20
- package/src/codegen/targets/react/component/handlers/radiomark.ts +1 -1
- package/src/codegen/targets/react/component/handlers/reaction-button.ts +1 -1
- package/src/codegen/targets/react/component/handlers/result-section.ts +1 -1
- package/src/codegen/targets/react/component/handlers/segmented-control.ts +2 -3
- package/src/codegen/targets/react/component/handlers/select-box.ts +333 -0
- package/src/codegen/targets/react/component/handlers/skeleton.ts +1 -1
- package/src/codegen/targets/react/component/handlers/slider.ts +13 -10
- package/src/codegen/targets/react/component/handlers/snackbar.ts +1 -1
- package/src/codegen/targets/react/component/handlers/switch.ts +1 -1
- package/src/codegen/targets/react/component/handlers/switchmark.ts +1 -1
- package/src/codegen/targets/react/component/handlers/tabs.ts +39 -42
- package/src/codegen/targets/react/component/handlers/tag-group.ts +46 -42
- package/src/codegen/targets/react/component/handlers/text-field.ts +11 -22
- package/src/codegen/targets/react/component/handlers/toggle-button.ts +1 -1
- package/src/codegen/targets/react/component/index.ts +5 -115
- package/src/entities/data/__generated__/archive/component-sets/index.d.ts +2074 -0
- package/src/entities/data/__generated__/archive/component-sets/index.mjs +2074 -0
- package/src/entities/data/__generated__/archive/components/index.d.ts +116 -0
- package/src/entities/data/__generated__/archive/components/index.mjs +116 -0
- package/src/entities/data/__generated__/archive/styles/index.d.ts +3 -0
- package/src/entities/data/__generated__/archive/styles/index.mjs +429 -0
- package/src/entities/data/__generated__/archive/variable-collections/index.d.ts +3 -0
- package/src/entities/data/__generated__/archive/variable-collections/index.mjs +501 -0
- package/src/entities/data/__generated__/archive/variables/index.d.ts +3 -0
- package/src/entities/data/__generated__/archive/variables/index.mjs +7019 -0
- package/src/entities/data/__generated__/component-sets/index.d.ts +3439 -1265
- package/src/entities/data/__generated__/component-sets/index.mjs +3439 -1265
- package/src/entities/data/__generated__/components/index.d.ts +326 -64
- package/src/entities/data/__generated__/components/index.mjs +326 -64
- package/src/entities/data/__generated__/styles/index.mjs +9 -2
- package/src/entities/data/__generated__/variable-collections/index.mjs +150 -173
- package/src/entities/data/__generated__/variables/index.mjs +0 -74
- package/src/entities/index.ts +21 -7
|
@@ -5,22 +5,13 @@ import type {
|
|
|
5
5
|
FieldIndicatorProperties,
|
|
6
6
|
} from "@/codegen/component-properties";
|
|
7
7
|
import { defineComponentHandler } from "@/codegen/core";
|
|
8
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
8
9
|
import { createSeedReactElement } from "../../element-factories";
|
|
9
10
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
10
11
|
import { match } from "ts-pattern";
|
|
11
12
|
import { findAllInstances } from "@/utils/figma-node";
|
|
12
13
|
import { camelCase } from "change-case";
|
|
13
14
|
|
|
14
|
-
const FIELD_HEADER_KEY = "84fe2e479c3291177662e41c71af29716e48789b";
|
|
15
|
-
const FIELD_INDICATOR_KEY = "a0a170973212ea0cd952b45a8acb11a92561f402";
|
|
16
|
-
const FIELD_FOOTER_KEY = "ab528f3b51a6dc529bb144de1495b07deef77ffa";
|
|
17
|
-
const FIELD_CHARACTER_COUNT_KEY = "25dd9a96f4bf3b866b8713f6d8deec370eebfa72";
|
|
18
|
-
|
|
19
|
-
export const FIELD_KEYS = {
|
|
20
|
-
HEADER: FIELD_HEADER_KEY,
|
|
21
|
-
FOOTER: FIELD_FOOTER_KEY,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
15
|
export type FieldHeaderProps = FieldIndicatorProps & {
|
|
25
16
|
label?: string;
|
|
26
17
|
labelWeight?: string;
|
|
@@ -32,22 +23,25 @@ export type FieldHeaderProps = FieldIndicatorProps & {
|
|
|
32
23
|
export const createFieldHeaderHandler = (ctx: ComponentHandlerDeps) => {
|
|
33
24
|
const indicatorHandler = createFieldIndicatorHandler(ctx);
|
|
34
25
|
|
|
35
|
-
return defineComponentHandler<FieldHeaderProperties>(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
return defineComponentHandler<FieldHeaderProperties>(
|
|
27
|
+
metadata.componentFieldHeader.key,
|
|
28
|
+
(node, traverse) => {
|
|
29
|
+
const { componentProperties: props } = node;
|
|
30
|
+
|
|
31
|
+
const [indicator] = findAllInstances<FieldIndicatorProperties>({
|
|
32
|
+
node,
|
|
33
|
+
key: indicatorHandler.key,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// only returns some nice common props for Slider, TextField and more
|
|
37
|
+
return createSeedReactElement("__FieldHeader__", {
|
|
38
|
+
label: props["Label#34796:0"].value,
|
|
39
|
+
labelWeight: camelCase(props.Weight.value),
|
|
40
|
+
...(indicator &&
|
|
41
|
+
(indicatorHandler.transform(indicator, traverse).props as FieldIndicatorProps)),
|
|
42
|
+
} satisfies FieldHeaderProps);
|
|
43
|
+
},
|
|
44
|
+
);
|
|
51
45
|
};
|
|
52
46
|
|
|
53
47
|
type FieldIndicatorProps = {
|
|
@@ -61,7 +55,7 @@ type FieldIndicatorProps = {
|
|
|
61
55
|
*/
|
|
62
56
|
const createFieldIndicatorHandler = (_ctx: ComponentHandlerDeps) => {
|
|
63
57
|
return defineComponentHandler<FieldIndicatorProperties>(
|
|
64
|
-
|
|
58
|
+
metadata.privateComponentFieldHeaderIndicator.key,
|
|
65
59
|
({ componentProperties: props }) => {
|
|
66
60
|
const { required, showRequiredIndicator, indicator } = match(props.Type.value)
|
|
67
61
|
.with("Required Mark", () => ({
|
|
@@ -99,52 +93,55 @@ export type FieldFooterProps = FieldCharacterCountProps & {
|
|
|
99
93
|
export const createFieldFooterHandler = (ctx: ComponentHandlerDeps) => {
|
|
100
94
|
const characterCountHandler = createFieldCharacterCountHandler(ctx);
|
|
101
95
|
|
|
102
|
-
return defineComponentHandler<FieldFooterProperties>(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
96
|
+
return defineComponentHandler<FieldFooterProperties>(
|
|
97
|
+
metadata.componentFieldFooter.key,
|
|
98
|
+
(node, traverse) => {
|
|
99
|
+
const { componentProperties: props } = node;
|
|
100
|
+
|
|
101
|
+
const { description, maxGraphemeCount } = match(props.Type.value)
|
|
102
|
+
.with("Description", () => ({
|
|
103
|
+
description: props["Text#2770:0"].value,
|
|
104
|
+
maxGraphemeCount: undefined,
|
|
105
|
+
}))
|
|
106
|
+
.with("Description With Character Count", () => ({
|
|
107
|
+
description: props["Text#2770:0"].value,
|
|
108
|
+
maxGraphemeCount: undefined,
|
|
109
|
+
}))
|
|
110
|
+
.with("Character Count", () => {
|
|
111
|
+
const [characterCount] = findAllInstances<FieldCharacterCountProperties>({
|
|
112
|
+
node,
|
|
113
|
+
key: characterCountHandler.key,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
description: undefined,
|
|
118
|
+
...(characterCount &&
|
|
119
|
+
(characterCountHandler.transform(characterCount, traverse)
|
|
120
|
+
.props as FieldCharacterCountProps)),
|
|
121
|
+
};
|
|
122
|
+
})
|
|
123
|
+
.exhaustive();
|
|
124
|
+
|
|
125
|
+
const { errorMessage, invalid } = match(props.Error.value === "true")
|
|
126
|
+
.with(true, () => ({
|
|
127
|
+
invalid: true,
|
|
128
|
+
errorMessage: props["Error Text#32821:0"].value,
|
|
129
|
+
}))
|
|
130
|
+
.with(false, () => ({
|
|
131
|
+
invalid: undefined,
|
|
132
|
+
errorMessage: undefined,
|
|
133
|
+
}))
|
|
134
|
+
.exhaustive();
|
|
135
|
+
|
|
136
|
+
// only returns some nice common props for Slider, TextField and more
|
|
137
|
+
return createSeedReactElement("__FieldFooter__", {
|
|
138
|
+
description,
|
|
139
|
+
maxGraphemeCount,
|
|
140
|
+
invalid,
|
|
141
|
+
errorMessage,
|
|
142
|
+
} satisfies FieldFooterProps);
|
|
143
|
+
},
|
|
144
|
+
);
|
|
148
145
|
};
|
|
149
146
|
|
|
150
147
|
type FieldCharacterCountProps = {
|
|
@@ -156,7 +153,7 @@ type FieldCharacterCountProps = {
|
|
|
156
153
|
*/
|
|
157
154
|
const createFieldCharacterCountHandler = (_ctx: ComponentHandlerDeps) => {
|
|
158
155
|
return defineComponentHandler<FieldCharacterCountProperties>(
|
|
159
|
-
|
|
156
|
+
metadata.privateComponentFieldFooterCharacterCount.key,
|
|
160
157
|
({ componentProperties: props }) => {
|
|
161
158
|
// only returns some nice common props for Slider, TextField and more
|
|
162
159
|
return createSeedReactElement("__FieldCharacterCount__", {
|
|
@@ -11,20 +11,17 @@ import { findAllInstances } from "@/utils/figma-node";
|
|
|
11
11
|
|
|
12
12
|
const { createLocalSnippetElement } = createLocalSnippetHelper("floating-action-button");
|
|
13
13
|
|
|
14
|
-
const BUTTON_TYPE_KEY = "8cecc85275115d653579d4c3156567ebf19f7b27";
|
|
15
|
-
const MENU_TYPE_KEY = "400124347392c15473f9cd2d8a6aedb64f3baf36";
|
|
16
|
-
|
|
17
14
|
export const createFloatingActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
18
15
|
defineComponentHandler<FloatingActionButtonProperties>(
|
|
19
|
-
metadata.
|
|
16
|
+
metadata.componentFloatingActionButton.key,
|
|
20
17
|
(node) => {
|
|
21
18
|
const [button] = findAllInstances<FloatingActionButtonButtonItemProperties>({
|
|
22
19
|
node,
|
|
23
|
-
key:
|
|
20
|
+
key: metadata.privateComponentItemButtonType.key,
|
|
24
21
|
});
|
|
25
22
|
const [menu] = findAllInstances<FloatingActionButtonMenuItemProperties>({
|
|
26
23
|
node,
|
|
27
|
-
key:
|
|
24
|
+
key: metadata.privateComponentItemMenuType.key,
|
|
28
25
|
});
|
|
29
26
|
|
|
30
27
|
const commonProps = (() => {
|
|
@@ -10,7 +10,7 @@ const { createLocalSnippetElement: createLocalSnippetElementTrigger } =
|
|
|
10
10
|
|
|
11
11
|
export const createHelpBubbleHandler = (_ctx: ComponentHandlerDeps) =>
|
|
12
12
|
defineComponentHandler<HelpBubbleProperties>(
|
|
13
|
-
metadata.
|
|
13
|
+
metadata.componentHelpBubble.key,
|
|
14
14
|
({ componentProperties: props }) => {
|
|
15
15
|
const placement:
|
|
16
16
|
| "top"
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { defineComponentHandler } from "@/codegen/core";
|
|
1
|
+
import { defineComponentHandler, type InferComponentDefinition } from "@/codegen/core";
|
|
3
2
|
import { camelCase } from "change-case";
|
|
4
3
|
import { createLocalSnippetHelper } from "../../element-factories";
|
|
5
4
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
5
|
|
|
6
|
+
// hardcoded since this lives in a different figma file
|
|
7
7
|
const IDENTITY_PLACEHOLDER_KEY = "b3563b6f16ba4cfe4240c9b33eef7edad4c304eb";
|
|
8
8
|
|
|
9
|
+
export type IdentityPlaceholderProperties = InferComponentDefinition<{
|
|
10
|
+
Identity: {
|
|
11
|
+
type: "VARIANT";
|
|
12
|
+
defaultValue: "Person";
|
|
13
|
+
variantOptions: ["Person", "Business"];
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
|
|
9
17
|
const { createLocalSnippetElement } = createLocalSnippetHelper("identity-placeholder");
|
|
10
18
|
|
|
11
19
|
export const createIdentityPlaceholderHandler = (_ctx: ComponentHandlerDeps) =>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export * from "./action-button";
|
|
2
|
+
export * from "./alert-dialog";
|
|
3
|
+
export * from "./app-bar";
|
|
4
|
+
export * from "./avatar";
|
|
5
|
+
export * from "./avatar-stack";
|
|
6
|
+
export * from "./badge";
|
|
7
|
+
export * from "./bottom-sheet";
|
|
8
|
+
export * from "./callout";
|
|
9
|
+
export * from "./checkbox";
|
|
10
|
+
export * from "./checkmark";
|
|
11
|
+
export * from "./chip";
|
|
12
|
+
export * from "./contextual-floating-button";
|
|
13
|
+
export * from "./divider";
|
|
14
|
+
export * from "./field-button";
|
|
15
|
+
export * from "./floating-action-button";
|
|
16
|
+
export * from "./help-bubble";
|
|
17
|
+
export * from "./identity-placeholder";
|
|
18
|
+
export * from "./legacy-select-box";
|
|
19
|
+
export * from "./legacy-text-field";
|
|
20
|
+
export * from "./list-header";
|
|
21
|
+
export * from "./list-item";
|
|
22
|
+
export * from "./manner-temp";
|
|
23
|
+
export * from "./manner-temp-badge";
|
|
24
|
+
export * from "./menu-sheet";
|
|
25
|
+
export * from "./page-banner";
|
|
26
|
+
export * from "./progress-circle";
|
|
27
|
+
export * from "./radio-group";
|
|
28
|
+
export * from "./radiomark";
|
|
29
|
+
export * from "./reaction-button";
|
|
30
|
+
export * from "./result-section";
|
|
31
|
+
export * from "./segmented-control";
|
|
32
|
+
export * from "./select-box";
|
|
33
|
+
export * from "./skeleton";
|
|
34
|
+
export * from "./slider";
|
|
35
|
+
export * from "./snackbar";
|
|
36
|
+
export * from "./switch";
|
|
37
|
+
export * from "./switchmark";
|
|
38
|
+
export * from "./tabs";
|
|
39
|
+
export * from "./tag-group";
|
|
40
|
+
export * from "./text-field";
|
|
41
|
+
export * from "./toggle-button";
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
LegacySelectBoxProperties,
|
|
4
4
|
} from "@/codegen/component-properties";
|
|
5
5
|
import { defineComponentHandler } from "@/codegen/core";
|
|
6
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
6
7
|
import { findAllInstances } from "@/utils/figma-node";
|
|
7
8
|
import { match } from "ts-pattern";
|
|
8
9
|
import { createLocalSnippetHelper, createSeedReactElement } from "../../element-factories";
|
|
@@ -10,12 +11,9 @@ import type { ComponentHandlerDeps } from "../deps.interface";
|
|
|
10
11
|
|
|
11
12
|
const { createLocalSnippetElement } = createLocalSnippetHelper("select-box");
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
const LEGACY_SELECT_BOX_GROUP_KEY = "a3d58bb8540600878742cdcf2608a4b3851667ec";
|
|
15
|
-
|
|
16
|
-
export const createLegacySelectBoxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
14
|
+
const createLegacySelectBoxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
17
15
|
defineComponentHandler<LegacySelectBoxProperties>(
|
|
18
|
-
|
|
16
|
+
metadata.componentDeprecatedSelectBox.key,
|
|
19
17
|
({ componentProperties: props }) => {
|
|
20
18
|
const tag = match(props.Control.value)
|
|
21
19
|
.with("Checkbox", () => "CheckSelectBox")
|
|
@@ -47,7 +45,7 @@ export const createLegacySelectBoxGroupHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
47
45
|
const selectBoxHandler = createLegacySelectBoxHandler(ctx);
|
|
48
46
|
|
|
49
47
|
return defineComponentHandler<LegacySelectBoxGroupProperties>(
|
|
50
|
-
|
|
48
|
+
metadata.componentDeprecatedSelectBoxGroup.key,
|
|
51
49
|
(node, traverse) => {
|
|
52
50
|
const props = node.componentProperties;
|
|
53
51
|
|
|
@@ -3,18 +3,16 @@ import type {
|
|
|
3
3
|
LegacyTextFieldProperties,
|
|
4
4
|
} from "@/codegen/component-properties";
|
|
5
5
|
import { defineComponentHandler } from "@/codegen/core";
|
|
6
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
6
7
|
import { createLocalSnippetHelper } from "../../element-factories";
|
|
7
8
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
8
9
|
import { handleSizeProp } from "../size";
|
|
9
10
|
|
|
10
11
|
const { createLocalSnippetElement } = createLocalSnippetHelper("text-field");
|
|
11
12
|
|
|
12
|
-
const LEGACY_TEXT_FIELD_KEY = "c49873c37a639f0dffdea4efd0eb43760d66c141";
|
|
13
|
-
const LEGACY_MULTILINE_TEXT_FIELD_KEY = "88b2399c930c85f9ce2972163a078bc684b84bbe";
|
|
14
|
-
|
|
15
13
|
export const createLegacyTextFieldHandler = (ctx: ComponentHandlerDeps) =>
|
|
16
14
|
defineComponentHandler<LegacyTextFieldProperties>(
|
|
17
|
-
|
|
15
|
+
metadata.componentDeprecatedTextField.key,
|
|
18
16
|
({ componentProperties: props }) => {
|
|
19
17
|
const {
|
|
20
18
|
Size: { value: size },
|
|
@@ -120,7 +118,7 @@ export const createLegacyTextFieldHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
120
118
|
|
|
121
119
|
export const createLegacyMultilineTextFieldHandler = (_ctx: ComponentHandlerDeps) =>
|
|
122
120
|
defineComponentHandler<LegacyMultilineTextFieldProperties>(
|
|
123
|
-
|
|
121
|
+
metadata.componentDeprecatedMultilineTextField.key,
|
|
124
122
|
({ componentProperties: props }) => {
|
|
125
123
|
const {
|
|
126
124
|
Size: { value: size },
|
|
@@ -9,7 +9,7 @@ const { createLocalSnippetElement } = createLocalSnippetHelper("list-header");
|
|
|
9
9
|
|
|
10
10
|
export const createListHeaderHandler = (_ctx: ComponentHandlerDeps) =>
|
|
11
11
|
defineComponentHandler<ListHeaderProperties>(
|
|
12
|
-
metadata.
|
|
12
|
+
metadata.componentListHeader.key,
|
|
13
13
|
({ componentProperties: props }) => {
|
|
14
14
|
const commonProps = {
|
|
15
15
|
variant: camelCase(props["Variant"].value),
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
} from "@/codegen/component-properties";
|
|
6
6
|
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
7
7
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
8
|
+
import * as components from "@/entities/data/__generated__/components";
|
|
8
9
|
import type { NormalizedTextNode } from "@/normalizer";
|
|
9
10
|
import { findAllInstances, findOne } from "@/utils/figma-node";
|
|
10
11
|
import { createLocalSnippetHelper, createSeedReactElement } from "../../element-factories";
|
|
@@ -13,29 +14,29 @@ import { match } from "ts-pattern";
|
|
|
13
14
|
|
|
14
15
|
const { createLocalSnippetElement } = createLocalSnippetHelper("list");
|
|
15
16
|
|
|
16
|
-
const PREFIX_KEYS =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const SUFFIX_KEYS =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
const PREFIX_KEYS = [
|
|
18
|
+
components.componentListItemPrefixCheckbox.key,
|
|
19
|
+
components.componentListItemPrefixRadiomark.key,
|
|
20
|
+
components.componentListItemPrefixIcon.key,
|
|
21
|
+
components.componentListItemPrefixAvatar.key,
|
|
22
|
+
components.componentListItemPrefixImage.key,
|
|
23
|
+
components.componentListItemPrefixCustom.key,
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const SUFFIX_KEYS = [
|
|
27
|
+
components.componentListItemSuffixCheckbox.key,
|
|
28
|
+
components.componentListItemSuffixRadiomark.key,
|
|
29
|
+
components.componentListItemSuffixChevron.key,
|
|
30
|
+
components.componentListItemSuffixSwitch.key,
|
|
31
|
+
components.componentListItemSuffixCustom.key,
|
|
32
|
+
components.componentListItemSuffixIcon.key,
|
|
33
|
+
components.componentListItemSuffixChevronWithText.key,
|
|
34
|
+
metadata.componentListItemSuffixIconButton.key,
|
|
35
|
+
metadata.componentListItemSuffixActionButton.key,
|
|
36
|
+
];
|
|
36
37
|
|
|
37
38
|
export const createListItemHandler = (ctx: ComponentHandlerDeps) =>
|
|
38
|
-
defineComponentHandler<ListItemProperties>(metadata.
|
|
39
|
+
defineComponentHandler<ListItemProperties>(metadata.componentListItem.key, (node, traverse) => {
|
|
39
40
|
const { componentProperties: props } = node;
|
|
40
41
|
|
|
41
42
|
const { alignItems, title } = match(props.Variants.value)
|
|
@@ -54,7 +55,7 @@ export const createListItemHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
54
55
|
const prefixNode = (() => {
|
|
55
56
|
if (props["Has Prefix#28452:85"].value === false) return null;
|
|
56
57
|
|
|
57
|
-
for (const key of
|
|
58
|
+
for (const key of PREFIX_KEYS) {
|
|
58
59
|
const [found] = findAllInstances<ListItemPrefixIconProperties | {}>({ node, key });
|
|
59
60
|
|
|
60
61
|
if (found) return found;
|
|
@@ -78,7 +79,7 @@ export const createListItemHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
78
79
|
const suffixNode = (() => {
|
|
79
80
|
if (props["Has Suffix#28452:64"].value === false) return null;
|
|
80
81
|
|
|
81
|
-
for (const key of
|
|
82
|
+
for (const key of SUFFIX_KEYS) {
|
|
82
83
|
const [found] = findAllInstances<ListItemSuffixIconProperties | {}>({ node, key });
|
|
83
84
|
|
|
84
85
|
if (found) return found;
|
|
@@ -8,7 +8,7 @@ const { createLocalSnippetElement } = createLocalSnippetHelper("manner-temp-badg
|
|
|
8
8
|
|
|
9
9
|
export const createMannerTempBadgeHandler = (_ctx: ComponentHandlerDeps) =>
|
|
10
10
|
defineComponentHandler<MannerTempBadgeProperties>(
|
|
11
|
-
metadata.
|
|
11
|
+
metadata.componentMannerTempBadge.key,
|
|
12
12
|
({ children }) => {
|
|
13
13
|
const textNode = children.find((child) => child.type === "TEXT");
|
|
14
14
|
|
|
@@ -7,7 +7,7 @@ import type { ComponentHandlerDeps } from "../deps.interface";
|
|
|
7
7
|
const { createLocalSnippetElement } = createLocalSnippetHelper("manner-temp");
|
|
8
8
|
|
|
9
9
|
export const createMannerTempHandler = (_ctx: ComponentHandlerDeps) =>
|
|
10
|
-
defineComponentHandler<MannerTempProperties>(metadata.
|
|
10
|
+
defineComponentHandler<MannerTempProperties>(metadata.componentMannerTemp.key, ({ children }) => {
|
|
11
11
|
const textNode = children.find((child) => child.type === "TEXT");
|
|
12
12
|
|
|
13
13
|
const commonProps = {
|
|
@@ -15,10 +15,9 @@ const { createLocalSnippetElement } = createLocalSnippetHelper("menu-sheet");
|
|
|
15
15
|
const { createLocalSnippetElement: createLocalSnippetElementTrigger } =
|
|
16
16
|
createLocalSnippetHelper("action-button");
|
|
17
17
|
|
|
18
|
-
const MENU_SHEET_ITEM_KEY = "057083e95466da59051119eec0b41d4ad5a07f8f";
|
|
19
18
|
const createMenuSheetItemHandler = (ctx: ComponentHandlerDeps) =>
|
|
20
19
|
defineComponentHandler<MenuSheetItemProperties>(
|
|
21
|
-
|
|
20
|
+
metadata.privateComponentMenuSheetMenuItem.key,
|
|
22
21
|
({ componentProperties: props }) => {
|
|
23
22
|
const states = props.State.value.split("-");
|
|
24
23
|
|
|
@@ -40,12 +39,11 @@ const createMenuSheetItemHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
40
39
|
},
|
|
41
40
|
);
|
|
42
41
|
|
|
43
|
-
const MENU_SHEET_GROUP_KEY = "2a504a1c6b7810d5e652862dcba2cb7048f9eb16";
|
|
44
42
|
const createMenuSheetGroupHandler = (ctx: ComponentHandlerDeps) => {
|
|
45
43
|
const menuSheetItemHandler = createMenuSheetItemHandler(ctx);
|
|
46
44
|
|
|
47
45
|
return defineComponentHandler<MenuSheetGroupProperties>(
|
|
48
|
-
|
|
46
|
+
metadata.privateComponentMenuSheetMenuGroup.key,
|
|
49
47
|
(node, traverse) => {
|
|
50
48
|
const items = findAllInstances<MenuSheetItemProperties>({
|
|
51
49
|
node,
|
|
@@ -62,47 +60,52 @@ const createMenuSheetGroupHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
62
60
|
export const createMenuSheetHandler = (ctx: ComponentHandlerDeps) => {
|
|
63
61
|
const menuSheetGroupHandler = createMenuSheetGroupHandler(ctx);
|
|
64
62
|
|
|
65
|
-
return defineComponentHandler<MenuSheetProperties>(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
node,
|
|
70
|
-
key: menuSheetGroupHandler.key,
|
|
71
|
-
});
|
|
63
|
+
return defineComponentHandler<MenuSheetProperties>(
|
|
64
|
+
metadata.componentMenuSheet.key,
|
|
65
|
+
(node, traverse) => {
|
|
66
|
+
const { componentProperties: props } = node;
|
|
72
67
|
|
|
73
|
-
|
|
68
|
+
const groups = findAllInstances<MenuSheetGroupProperties>({
|
|
69
|
+
node,
|
|
70
|
+
key: menuSheetGroupHandler.key,
|
|
71
|
+
});
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
const contentChildren = groups.map((group) =>
|
|
74
|
+
menuSheetGroupHandler.transform(group, traverse),
|
|
75
|
+
);
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
? props["Description Text#21827:0"].value
|
|
77
|
+
const title = props["Show Header#17043:12"].value
|
|
78
|
+
? props["Title Text#14599:0"].value
|
|
82
79
|
: undefined;
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
81
|
+
const description =
|
|
82
|
+
props["Show Header#17043:12"].value && props["Show Header Description#32984:0"].value
|
|
83
|
+
? props["Description Text#21827:0"].value
|
|
84
|
+
: undefined;
|
|
85
|
+
|
|
86
|
+
const { labelAlign } = match(props.Layout.value)
|
|
87
|
+
.with("Text with Icon", () => ({ labelAlign: "left" }))
|
|
88
|
+
.with("Text Only", () => ({ labelAlign: "center" }))
|
|
89
|
+
.exhaustive();
|
|
90
|
+
|
|
91
|
+
const content = createLocalSnippetElement(
|
|
92
|
+
"MenuSheetContent",
|
|
93
|
+
{ title, description, labelAlign },
|
|
94
|
+
contentChildren,
|
|
95
|
+
{
|
|
96
|
+
comment: title
|
|
97
|
+
? undefined
|
|
98
|
+
: "title을 제공하지 않는 경우 aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.",
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const trigger = createLocalSnippetElement(
|
|
103
|
+
"MenuSheetTrigger",
|
|
104
|
+
{ asChild: true },
|
|
105
|
+
createLocalSnippetElementTrigger("ActionButton", {}, "MenuSheet 열기"),
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return createLocalSnippetElement("MenuSheet", undefined, [trigger, content]);
|
|
109
|
+
},
|
|
110
|
+
);
|
|
108
111
|
};
|