@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
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
|
+
import * as sets from "@/entities/data/__generated__/archive/component-sets";
|
|
3
|
+
import * as components from "@/entities/data/__generated__/archive/components";
|
|
4
|
+
import { createLocalSnippetHelper } from "../../../element-factories";
|
|
5
|
+
import type { ComponentHandlerDeps } from "../../deps.interface";
|
|
6
|
+
import {
|
|
7
|
+
createFieldFooterHandler,
|
|
8
|
+
createFieldHeaderHandler,
|
|
9
|
+
FIELD_KEYS,
|
|
10
|
+
type FieldFooterProps,
|
|
11
|
+
type FieldHeaderProps,
|
|
12
|
+
} from "@/codegen/targets/react/component/handlers/archive/field";
|
|
13
|
+
import type {
|
|
14
|
+
FieldHeaderProperties,
|
|
15
|
+
FieldFooterProperties,
|
|
16
|
+
FieldButtonProperties,
|
|
17
|
+
InputButtonProperties,
|
|
18
|
+
InputButtonPrefixProperties,
|
|
19
|
+
InputButtonSuffixProperties,
|
|
20
|
+
ActionButtonGhostProperties,
|
|
21
|
+
GenericFieldButtonProps,
|
|
22
|
+
} from "@/codegen/component-properties.archive";
|
|
23
|
+
import { findAllInstances, findOne } from "@/utils/figma-node";
|
|
24
|
+
import type { NormalizedTextNode } from "@/normalizer";
|
|
25
|
+
|
|
26
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("field-button");
|
|
27
|
+
|
|
28
|
+
const INPUT_BUTTON_KEY = "965bdecb58755af9a08d60cc3c8d2d33b42e15f0";
|
|
29
|
+
const INPUT_BUTTON_PREFIX_KEY = "12b40c736a098298c64ba16de85702b4b460d1f1";
|
|
30
|
+
const INPUT_BUTTON_SUFFIX_KEY = "5dda27af9f4afafa471925c17acf97d81912877a";
|
|
31
|
+
|
|
32
|
+
export const createFieldButtonHandler = (ctx: ComponentHandlerDeps) => {
|
|
33
|
+
const fieldHeaderHandler = createFieldHeaderHandler(ctx);
|
|
34
|
+
const fieldFooterHandler = createFieldFooterHandler(ctx);
|
|
35
|
+
|
|
36
|
+
return defineComponentHandler<FieldButtonProperties>(
|
|
37
|
+
sets.templateCustomPickerField.key,
|
|
38
|
+
(node, traverse) => {
|
|
39
|
+
const props = node.componentProperties;
|
|
40
|
+
|
|
41
|
+
const [inputButton] = findAllInstances<InputButtonProperties>({
|
|
42
|
+
node,
|
|
43
|
+
key: INPUT_BUTTON_KEY,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const [clearButton] = findAllInstances<ActionButtonGhostProperties>({
|
|
47
|
+
node,
|
|
48
|
+
key: sets.actionButtonGhostButton.key,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const [fieldHeader] = findAllInstances<FieldHeaderProperties>({
|
|
52
|
+
node,
|
|
53
|
+
key: FIELD_KEYS.HEADER,
|
|
54
|
+
});
|
|
55
|
+
const [fieldFooter] = findAllInstances<FieldFooterProperties>({
|
|
56
|
+
node,
|
|
57
|
+
key: FIELD_KEYS.FOOTER,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// maxGraphemeCount and required can't be props of FieldButton
|
|
61
|
+
const { required: _required, ...headerProps } =
|
|
62
|
+
props["Show Header#40606:8"].value && fieldHeader
|
|
63
|
+
? (fieldHeaderHandler.transform(fieldHeader, traverse).props as FieldHeaderProps)
|
|
64
|
+
: {};
|
|
65
|
+
const { maxGraphemeCount: _maxGraphemeCount, ...footerProps } =
|
|
66
|
+
props["Show Footer#40606:9"].value && fieldFooter
|
|
67
|
+
? (fieldFooterHandler.transform(fieldFooter, traverse).props as FieldFooterProps)
|
|
68
|
+
: {};
|
|
69
|
+
|
|
70
|
+
const [prefix] = findAllInstances<InputButtonPrefixProperties>({
|
|
71
|
+
node: inputButton,
|
|
72
|
+
key: INPUT_BUTTON_PREFIX_KEY,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const [suffix] = findAllInstances<InputButtonSuffixProperties>({
|
|
76
|
+
node: inputButton,
|
|
77
|
+
key: INPUT_BUTTON_SUFFIX_KEY,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const commonProps = {
|
|
81
|
+
...(inputButton.componentProperties.State.value === "Disabled" && {
|
|
82
|
+
disabled: true,
|
|
83
|
+
}),
|
|
84
|
+
...((inputButton.componentProperties.State.value === "Error" ||
|
|
85
|
+
inputButton.componentProperties.State.value === "Error Pressed") && {
|
|
86
|
+
invalid: true,
|
|
87
|
+
}),
|
|
88
|
+
...(clearButton && {
|
|
89
|
+
showClearButton: true,
|
|
90
|
+
}),
|
|
91
|
+
...(inputButton.componentProperties["Has Prefix#32514:10"].value === true &&
|
|
92
|
+
prefix &&
|
|
93
|
+
prefix.componentProperties.Type.value === "Icon" && {
|
|
94
|
+
prefixIcon: ctx.iconHandler.transform(prefix.componentProperties["Icon#34021:2"]),
|
|
95
|
+
}),
|
|
96
|
+
...(inputButton.componentProperties["Has Suffix#32865:68"].value === true &&
|
|
97
|
+
suffix &&
|
|
98
|
+
suffix.componentProperties["Type (Figma Only)"].value === "Icon" && {
|
|
99
|
+
suffixIcon: ctx.iconHandler.transform(suffix.componentProperties["Icon#37963:0"]),
|
|
100
|
+
}),
|
|
101
|
+
...(inputButton.componentProperties["Has Suffix#32865:68"].value === true &&
|
|
102
|
+
suffix &&
|
|
103
|
+
suffix.componentProperties["Type (Figma Only)"].value === "Text" && {
|
|
104
|
+
suffix: suffix.componentProperties["Suffix Text#34021:4"].value,
|
|
105
|
+
}),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// these can be fragile but better than having 9 different handlers
|
|
109
|
+
const placeholder = findOne(
|
|
110
|
+
node,
|
|
111
|
+
(node) => node.type === "TEXT" && node.name.toLowerCase().includes("placeholder"),
|
|
112
|
+
) as NormalizedTextNode;
|
|
113
|
+
|
|
114
|
+
const value = findOne(
|
|
115
|
+
node,
|
|
116
|
+
(node) => node.type === "TEXT" && node.name.toLowerCase().includes("value"),
|
|
117
|
+
) as NormalizedTextNode;
|
|
118
|
+
|
|
119
|
+
return createLocalSnippetElement(
|
|
120
|
+
"FieldButton",
|
|
121
|
+
{ ...headerProps, ...footerProps, ...commonProps },
|
|
122
|
+
props["Has Value"].value === "True" && value
|
|
123
|
+
? createLocalSnippetElement("FieldButtonValue", undefined, value.characters)
|
|
124
|
+
: placeholder
|
|
125
|
+
? createLocalSnippetElement("FieldButtonPlaceholder", undefined, placeholder.characters)
|
|
126
|
+
: undefined,
|
|
127
|
+
{ comment: "buttonProps를 통해 aria-label을 제공하세요." },
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// TODO: those 4 are basically the same
|
|
134
|
+
|
|
135
|
+
export const createSelectFieldHandler = (ctx: ComponentHandlerDeps) => {
|
|
136
|
+
const fieldButtonHandler = createFieldButtonHandler(ctx);
|
|
137
|
+
|
|
138
|
+
return defineComponentHandler<GenericFieldButtonProps>(
|
|
139
|
+
components.templateSelectField.key,
|
|
140
|
+
(node, traverse) => {
|
|
141
|
+
const [fieldButton] = findAllInstances<FieldButtonProperties>({
|
|
142
|
+
node,
|
|
143
|
+
key: fieldButtonHandler.key,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return fieldButtonHandler.transform(fieldButton, traverse);
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const createDatePickerFieldHandler = (ctx: ComponentHandlerDeps) => {
|
|
152
|
+
const fieldButtonHandler = createFieldButtonHandler(ctx);
|
|
153
|
+
|
|
154
|
+
return defineComponentHandler<GenericFieldButtonProps>(
|
|
155
|
+
components.templateDatePickerField.key,
|
|
156
|
+
(node, traverse) => {
|
|
157
|
+
const [fieldButton] = findAllInstances<FieldButtonProperties>({
|
|
158
|
+
node,
|
|
159
|
+
key: fieldButtonHandler.key,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return fieldButtonHandler.transform(fieldButton, traverse);
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const createTimePickerFieldHandler = (ctx: ComponentHandlerDeps) => {
|
|
168
|
+
const fieldButtonHandler = createFieldButtonHandler(ctx);
|
|
169
|
+
|
|
170
|
+
return defineComponentHandler<GenericFieldButtonProps>(
|
|
171
|
+
components.templateTimePickerField.key,
|
|
172
|
+
(node, traverse) => {
|
|
173
|
+
const [fieldButton] = findAllInstances<FieldButtonProperties>({
|
|
174
|
+
node,
|
|
175
|
+
key: fieldButtonHandler.key,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return fieldButtonHandler.transform(fieldButton, traverse);
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const createAddressFieldHandler = (ctx: ComponentHandlerDeps) => {
|
|
184
|
+
const fieldButtonHandler = createFieldButtonHandler(ctx);
|
|
185
|
+
|
|
186
|
+
return defineComponentHandler<GenericFieldButtonProps>(
|
|
187
|
+
components.templateAddressPickerField.key,
|
|
188
|
+
(node, traverse) => {
|
|
189
|
+
const [fieldButton] = findAllInstances<FieldButtonProperties>({
|
|
190
|
+
node,
|
|
191
|
+
key: fieldButtonHandler.key,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return fieldButtonHandler.transform(fieldButton, traverse);
|
|
195
|
+
},
|
|
196
|
+
);
|
|
197
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FieldCharacterCountProperties,
|
|
3
|
+
FieldFooterProperties,
|
|
4
|
+
FieldHeaderProperties,
|
|
5
|
+
FieldIndicatorProperties,
|
|
6
|
+
} from "@/codegen/component-properties.archive";
|
|
7
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
8
|
+
import { createSeedReactElement } from "../../../element-factories";
|
|
9
|
+
import type { ComponentHandlerDeps } from "../../deps.interface";
|
|
10
|
+
import { match } from "ts-pattern";
|
|
11
|
+
import { findAllInstances } from "@/utils/figma-node";
|
|
12
|
+
import { camelCase } from "change-case";
|
|
13
|
+
|
|
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
|
+
export type FieldHeaderProps = FieldIndicatorProps & {
|
|
25
|
+
label?: string;
|
|
26
|
+
labelWeight?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* NOTE: only gives useful 'props' for field-related components but doesn't give fully functional code.
|
|
31
|
+
*/
|
|
32
|
+
export const createFieldHeaderHandler = (ctx: ComponentHandlerDeps) => {
|
|
33
|
+
const indicatorHandler = createFieldIndicatorHandler(ctx);
|
|
34
|
+
|
|
35
|
+
return defineComponentHandler<FieldHeaderProperties>(FIELD_HEADER_KEY, (node, traverse) => {
|
|
36
|
+
const { componentProperties: props } = node;
|
|
37
|
+
|
|
38
|
+
const [indicator] = findAllInstances<FieldIndicatorProperties>({
|
|
39
|
+
node,
|
|
40
|
+
key: FIELD_INDICATOR_KEY,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// only returns some nice common props for Slider, TextField and more
|
|
44
|
+
return createSeedReactElement("__FieldHeader__", {
|
|
45
|
+
label: props["Label#34796:0"].value,
|
|
46
|
+
labelWeight: camelCase(props.Weight.value),
|
|
47
|
+
...(indicator &&
|
|
48
|
+
(indicatorHandler.transform(indicator, traverse).props as FieldIndicatorProps)),
|
|
49
|
+
} satisfies FieldHeaderProps);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type FieldIndicatorProps = {
|
|
54
|
+
required?: boolean;
|
|
55
|
+
showRequiredIndicator?: boolean;
|
|
56
|
+
indicator?: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* NOTE: only gives useful 'props' for field-related components but doesn't give fully functional code.
|
|
61
|
+
*/
|
|
62
|
+
const createFieldIndicatorHandler = (_ctx: ComponentHandlerDeps) => {
|
|
63
|
+
return defineComponentHandler<FieldIndicatorProperties>(
|
|
64
|
+
FIELD_INDICATOR_KEY,
|
|
65
|
+
({ componentProperties: props }) => {
|
|
66
|
+
const { required, showRequiredIndicator, indicator } = match(props.Type.value)
|
|
67
|
+
.with("Required Mark", () => ({
|
|
68
|
+
required: true,
|
|
69
|
+
showRequiredIndicator: true,
|
|
70
|
+
indicator: undefined,
|
|
71
|
+
}))
|
|
72
|
+
.with("Text", () => ({
|
|
73
|
+
required: undefined,
|
|
74
|
+
showRequiredIndicator: undefined,
|
|
75
|
+
indicator: props["Required Label#40606:3"].value,
|
|
76
|
+
}))
|
|
77
|
+
.exhaustive();
|
|
78
|
+
|
|
79
|
+
// only returns some nice common props for Slider, TextField and more
|
|
80
|
+
return createSeedReactElement("__FieldIndicator__", {
|
|
81
|
+
required,
|
|
82
|
+
showRequiredIndicator,
|
|
83
|
+
indicator,
|
|
84
|
+
} satisfies FieldIndicatorProps);
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type FieldFooterProps = FieldCharacterCountProps & {
|
|
90
|
+
description?: string;
|
|
91
|
+
maxGraphemeCount?: number;
|
|
92
|
+
invalid?: boolean;
|
|
93
|
+
errorMessage?: string;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* NOTE: only gives useful 'props' for field-related components but doesn't give fully functional code.
|
|
98
|
+
*/
|
|
99
|
+
export const createFieldFooterHandler = (ctx: ComponentHandlerDeps) => {
|
|
100
|
+
const characterCountHandler = createFieldCharacterCountHandler(ctx);
|
|
101
|
+
|
|
102
|
+
return defineComponentHandler<FieldFooterProperties>(FIELD_FOOTER_KEY, (node, traverse) => {
|
|
103
|
+
const { componentProperties: props } = node;
|
|
104
|
+
|
|
105
|
+
const { description, maxGraphemeCount } = match(props.Type.value)
|
|
106
|
+
.with("Description", () => ({
|
|
107
|
+
description: props["Text#2770:0"].value,
|
|
108
|
+
maxGraphemeCount: undefined,
|
|
109
|
+
}))
|
|
110
|
+
.with("Description With Character Count", () => ({
|
|
111
|
+
description: props["Text#2770:0"].value,
|
|
112
|
+
maxGraphemeCount: undefined,
|
|
113
|
+
}))
|
|
114
|
+
.with("Character Count", () => {
|
|
115
|
+
const [characterCount] = findAllInstances<FieldCharacterCountProperties>({
|
|
116
|
+
node,
|
|
117
|
+
key: FIELD_CHARACTER_COUNT_KEY,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
description: undefined,
|
|
122
|
+
...(characterCount &&
|
|
123
|
+
(characterCountHandler.transform(characterCount, traverse)
|
|
124
|
+
.props as FieldCharacterCountProps)),
|
|
125
|
+
};
|
|
126
|
+
})
|
|
127
|
+
.exhaustive();
|
|
128
|
+
|
|
129
|
+
const { errorMessage, invalid } = match(props.Error.value === "true")
|
|
130
|
+
.with(true, () => ({
|
|
131
|
+
invalid: true,
|
|
132
|
+
errorMessage: props["Error Text#32821:0"].value,
|
|
133
|
+
}))
|
|
134
|
+
.with(false, () => ({
|
|
135
|
+
invalid: undefined,
|
|
136
|
+
errorMessage: undefined,
|
|
137
|
+
}))
|
|
138
|
+
.exhaustive();
|
|
139
|
+
|
|
140
|
+
// only returns some nice common props for Slider, TextField and more
|
|
141
|
+
return createSeedReactElement("__FieldFooter__", {
|
|
142
|
+
description,
|
|
143
|
+
maxGraphemeCount,
|
|
144
|
+
invalid,
|
|
145
|
+
errorMessage,
|
|
146
|
+
} satisfies FieldFooterProps);
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
type FieldCharacterCountProps = {
|
|
151
|
+
maxGraphemeCount?: number;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* NOTE: only gives useful 'props' for field-related components but doesn't give fully functional code.
|
|
156
|
+
*/
|
|
157
|
+
const createFieldCharacterCountHandler = (_ctx: ComponentHandlerDeps) => {
|
|
158
|
+
return defineComponentHandler<FieldCharacterCountProperties>(
|
|
159
|
+
FIELD_CHARACTER_COUNT_KEY,
|
|
160
|
+
({ componentProperties: props }) => {
|
|
161
|
+
// only returns some nice common props for Slider, TextField and more
|
|
162
|
+
return createSeedReactElement("__FieldCharacterCount__", {
|
|
163
|
+
maxGraphemeCount: Number(props["Max Count#40960:4"].value),
|
|
164
|
+
} satisfies FieldCharacterCountProps);
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FloatingActionButtonButtonItemProperties,
|
|
3
|
+
FloatingActionButtonMenuItemProperties,
|
|
4
|
+
FloatingActionButtonProperties,
|
|
5
|
+
} from "@/codegen/component-properties.archive";
|
|
6
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
7
|
+
import * as metadata from "@/entities/data/__generated__/archive/component-sets";
|
|
8
|
+
import { createLocalSnippetHelper } from "../../../element-factories";
|
|
9
|
+
import type { ComponentHandlerDeps } from "../../deps.interface";
|
|
10
|
+
import { findAllInstances } from "@/utils/figma-node";
|
|
11
|
+
|
|
12
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("floating-action-button");
|
|
13
|
+
|
|
14
|
+
const BUTTON_TYPE_KEY = "8cecc85275115d653579d4c3156567ebf19f7b27";
|
|
15
|
+
const MENU_TYPE_KEY = "400124347392c15473f9cd2d8a6aedb64f3baf36";
|
|
16
|
+
|
|
17
|
+
export const createFloatingActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
18
|
+
defineComponentHandler<FloatingActionButtonProperties>(
|
|
19
|
+
metadata.floatingActionButton.key,
|
|
20
|
+
(node) => {
|
|
21
|
+
const [button] = findAllInstances<FloatingActionButtonButtonItemProperties>({
|
|
22
|
+
node,
|
|
23
|
+
key: BUTTON_TYPE_KEY,
|
|
24
|
+
});
|
|
25
|
+
const [menu] = findAllInstances<FloatingActionButtonMenuItemProperties>({
|
|
26
|
+
node,
|
|
27
|
+
key: MENU_TYPE_KEY,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const commonProps = (() => {
|
|
31
|
+
if (button)
|
|
32
|
+
return {
|
|
33
|
+
icon: ctx.iconHandler.transform(button.componentProperties["Icon#29766:18"]),
|
|
34
|
+
extended: button.componentProperties.Extended.value === "True",
|
|
35
|
+
label: button.componentProperties["Label#29808:0"].value,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (menu)
|
|
39
|
+
return {
|
|
40
|
+
icon: ctx.iconHandler.transform(menu.componentProperties["Icon#29766:0"]),
|
|
41
|
+
extended: menu.componentProperties.Extended.value === "True",
|
|
42
|
+
label: menu.componentProperties["Label#29766:9"].value,
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
|
|
46
|
+
return createLocalSnippetElement("FloatingActionButton", commonProps);
|
|
47
|
+
},
|
|
48
|
+
);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { HelpBubbleProperties } from "@/codegen/component-properties.archive";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
3
|
+
import * as metadata from "@/entities/data/__generated__/archive/component-sets";
|
|
4
|
+
import { createLocalSnippetHelper } from "../../../element-factories";
|
|
5
|
+
import type { ComponentHandlerDeps } from "../../deps.interface";
|
|
6
|
+
|
|
7
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("help-bubble");
|
|
8
|
+
const { createLocalSnippetElement: createLocalSnippetElementTrigger } =
|
|
9
|
+
createLocalSnippetHelper("action-button");
|
|
10
|
+
|
|
11
|
+
export const createHelpBubbleHandler = (_ctx: ComponentHandlerDeps) =>
|
|
12
|
+
defineComponentHandler<HelpBubbleProperties>(
|
|
13
|
+
metadata.helpBubble.key,
|
|
14
|
+
({ componentProperties: props }) => {
|
|
15
|
+
const placement:
|
|
16
|
+
| "top"
|
|
17
|
+
| "right"
|
|
18
|
+
| "bottom"
|
|
19
|
+
| "left"
|
|
20
|
+
| "top-end"
|
|
21
|
+
| "top-start"
|
|
22
|
+
| "right-end"
|
|
23
|
+
| "right-start"
|
|
24
|
+
| "bottom-end"
|
|
25
|
+
| "bottom-start"
|
|
26
|
+
| "left-end"
|
|
27
|
+
| "left-start" = (() => {
|
|
28
|
+
switch (props.Placement.value) {
|
|
29
|
+
case "Bottom-Left":
|
|
30
|
+
return "top-start";
|
|
31
|
+
case "Bottom-Center":
|
|
32
|
+
return "top";
|
|
33
|
+
case "Bottom-Right":
|
|
34
|
+
return "top-end";
|
|
35
|
+
case "Left-Top":
|
|
36
|
+
return "right-start";
|
|
37
|
+
case "Left-Center":
|
|
38
|
+
return "right";
|
|
39
|
+
case "Left-Bottom":
|
|
40
|
+
return "right-end";
|
|
41
|
+
case "Top-Left":
|
|
42
|
+
return "bottom-start";
|
|
43
|
+
case "Top-Center":
|
|
44
|
+
return "bottom";
|
|
45
|
+
case "Top-Right":
|
|
46
|
+
return "bottom-end";
|
|
47
|
+
case "Right-Top":
|
|
48
|
+
return "left-start";
|
|
49
|
+
case "Right-Center":
|
|
50
|
+
return "left";
|
|
51
|
+
case "Right-Bottom":
|
|
52
|
+
return "left-end";
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
|
|
56
|
+
const commonProps = {
|
|
57
|
+
title: props["Title#62535:0"].value,
|
|
58
|
+
...(props["Show Description#62499:0"].value && {
|
|
59
|
+
description: props["Description#62535:98"].value,
|
|
60
|
+
}),
|
|
61
|
+
defaultOpen: true,
|
|
62
|
+
showCloseButton: props["Show Close Button#40538:0"].value,
|
|
63
|
+
placement,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return createLocalSnippetElement(
|
|
67
|
+
"HelpBubbleTrigger",
|
|
68
|
+
commonProps,
|
|
69
|
+
createLocalSnippetElementTrigger("ActionButton", {}, "HelpBubble 열기"),
|
|
70
|
+
{ comment: "필요에 따라 HelpBubbleAnchor로 변경하여 사용하세요." },
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IdentityPlaceholderProperties } from "@/codegen/component-properties.archive";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
3
|
+
import { camelCase } from "change-case";
|
|
4
|
+
import { createLocalSnippetHelper } from "../../../element-factories";
|
|
5
|
+
import type { ComponentHandlerDeps } from "../../deps.interface";
|
|
6
|
+
|
|
7
|
+
const IDENTITY_PLACEHOLDER_KEY = "b3563b6f16ba4cfe4240c9b33eef7edad4c304eb";
|
|
8
|
+
|
|
9
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("identity-placeholder");
|
|
10
|
+
|
|
11
|
+
export const createIdentityPlaceholderHandler = (_ctx: ComponentHandlerDeps) =>
|
|
12
|
+
defineComponentHandler<IdentityPlaceholderProperties>(
|
|
13
|
+
IDENTITY_PLACEHOLDER_KEY,
|
|
14
|
+
({ componentProperties: props }) => {
|
|
15
|
+
const commonProps = {
|
|
16
|
+
identity: camelCase(props.Identity.value),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return createLocalSnippetElement("IdentityPlaceholder", commonProps);
|
|
20
|
+
},
|
|
21
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
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 "./skeleton";
|
|
33
|
+
export * from "./slider";
|
|
34
|
+
export * from "./snackbar";
|
|
35
|
+
export * from "./switch";
|
|
36
|
+
export * from "./switchmark";
|
|
37
|
+
export * from "./tabs";
|
|
38
|
+
export * from "./tag-group";
|
|
39
|
+
export * from "./text-field";
|
|
40
|
+
export * from "./toggle-button";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LegacySelectBoxGroupProperties,
|
|
3
|
+
LegacySelectBoxProperties,
|
|
4
|
+
} from "@/codegen/component-properties.archive";
|
|
5
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
6
|
+
import { findAllInstances } from "@/utils/figma-node";
|
|
7
|
+
import { match } from "ts-pattern";
|
|
8
|
+
import { createLocalSnippetHelper, createSeedReactElement } from "../../../element-factories";
|
|
9
|
+
import type { ComponentHandlerDeps } from "../../deps.interface";
|
|
10
|
+
|
|
11
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("select-box");
|
|
12
|
+
|
|
13
|
+
const LEGACY_SELECT_BOX_KEY = "38722ffeb4c966256a709155e8ddac50c93d7c60";
|
|
14
|
+
const LEGACY_SELECT_BOX_GROUP_KEY = "a3d58bb8540600878742cdcf2608a4b3851667ec";
|
|
15
|
+
|
|
16
|
+
export const createLegacySelectBoxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
17
|
+
defineComponentHandler<LegacySelectBoxProperties>(
|
|
18
|
+
LEGACY_SELECT_BOX_KEY,
|
|
19
|
+
({ componentProperties: props }) => {
|
|
20
|
+
const tag = match(props.Control.value)
|
|
21
|
+
.with("Checkbox", () => "CheckSelectBox")
|
|
22
|
+
.with("Radio", () => "RadioSelectBoxItem")
|
|
23
|
+
.exhaustive();
|
|
24
|
+
|
|
25
|
+
const commonProps = {
|
|
26
|
+
label: props["Label#3635:0"].value,
|
|
27
|
+
...(props["Show Description#3033:0"].value && {
|
|
28
|
+
description: props["Description #3033:5"].value,
|
|
29
|
+
}),
|
|
30
|
+
...(tag === "RadioSelectBoxItem" && {
|
|
31
|
+
value: props["Label#3635:0"].value,
|
|
32
|
+
}),
|
|
33
|
+
...(tag === "CheckSelectBox" &&
|
|
34
|
+
props.Selected.value === "True" && {
|
|
35
|
+
defaultChecked: true,
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return createLocalSnippetElement(tag, commonProps, undefined, {
|
|
40
|
+
comment:
|
|
41
|
+
"이 Figma 컴포넌트는 @seed-design/react@1.2보다 낮은 버전의 SelectBox입니다. 신규 컴포넌트로 교체할 수 있습니다.",
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export const createLegacySelectBoxGroupHandler = (ctx: ComponentHandlerDeps) => {
|
|
47
|
+
const selectBoxHandler = createLegacySelectBoxHandler(ctx);
|
|
48
|
+
|
|
49
|
+
return defineComponentHandler<LegacySelectBoxGroupProperties>(
|
|
50
|
+
LEGACY_SELECT_BOX_GROUP_KEY,
|
|
51
|
+
(node, traverse) => {
|
|
52
|
+
const props = node.componentProperties;
|
|
53
|
+
|
|
54
|
+
const tag = match(props.Control.value)
|
|
55
|
+
.with("Checkbox", () => "CheckSelectBoxGroup")
|
|
56
|
+
.with("Radio", () => "RadioSelectBoxRoot")
|
|
57
|
+
.exhaustive();
|
|
58
|
+
|
|
59
|
+
const selectBoxes = findAllInstances<LegacySelectBoxProperties>({
|
|
60
|
+
node,
|
|
61
|
+
key: selectBoxHandler.key,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const selectedSelectBox = selectBoxes.find(
|
|
65
|
+
(selectBox) => selectBox.componentProperties.Selected.value === "True",
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// traverse the container like it's a frame
|
|
69
|
+
const vStackProps = traverse({ ...node, type: "FRAME" })?.props;
|
|
70
|
+
|
|
71
|
+
const stack = createSeedReactElement(
|
|
72
|
+
"VStack",
|
|
73
|
+
vStackProps,
|
|
74
|
+
selectBoxes.map((box) => selectBoxHandler.transform(box, traverse)),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const commonProps = {
|
|
78
|
+
...(tag === "RadioSelectBoxRoot" && {
|
|
79
|
+
defaultValue: selectedSelectBox?.componentProperties["Label#3635:0"].value,
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return createLocalSnippetElement(tag, commonProps, stack, {
|
|
84
|
+
comment:
|
|
85
|
+
"이 Figma 컴포넌트는 @seed-design/react@1.2보다 낮은 버전의 SelectBox입니다. 신규 컴포넌트로 교체할 수 있습니다.",
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
};
|