@seed-design/figma 0.0.0-alpha-20260324091316
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 +23543 -0
- package/lib/codegen/index.d.ts +2957 -0
- package/lib/codegen/index.d.ts.map +1 -0
- package/lib/codegen/index.js +23514 -0
- package/lib/codegen/targets/react/index.cjs +31980 -0
- package/lib/codegen/targets/react/index.d.ts +308 -0
- package/lib/codegen/targets/react/index.d.ts.map +1 -0
- package/lib/codegen/targets/react/index.js +31961 -0
- package/lib/index.cjs +26905 -0
- package/lib/index.d.ts +221 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +26884 -0
- package/package.json +56 -0
- package/src/codegen/component-properties.archive.ts +1019 -0
- package/src/codegen/component-properties.ts +369 -0
- package/src/codegen/core/codegen.ts +112 -0
- package/src/codegen/core/component-handler.ts +23 -0
- package/src/codegen/core/component-type-helper.ts +35 -0
- package/src/codegen/core/element-transformer.ts +13 -0
- package/src/codegen/core/index.ts +19 -0
- package/src/codegen/core/infer-layout.test.ts +286 -0
- package/src/codegen/core/infer-layout.ts +416 -0
- package/src/codegen/core/jsx.ts +174 -0
- package/src/codegen/core/props-converter.ts +78 -0
- package/src/codegen/core/value-resolver.ts +381 -0
- package/src/codegen/default-services.ts +44 -0
- package/src/codegen/index.ts +3 -0
- package/src/codegen/skip-components.ts +7 -0
- package/src/codegen/targets/figma/frame.ts +38 -0
- package/src/codegen/targets/figma/index.ts +6 -0
- package/src/codegen/targets/figma/instance.ts +36 -0
- package/src/codegen/targets/figma/pipeline.ts +106 -0
- package/src/codegen/targets/figma/props.ts +262 -0
- package/src/codegen/targets/figma/shape.ts +65 -0
- package/src/codegen/targets/figma/text.ts +30 -0
- package/src/codegen/targets/figma/value-resolver.ts +75 -0
- package/src/codegen/targets/index.ts +2 -0
- package/src/codegen/targets/react/component/deps.interface.ts +7 -0
- package/src/codegen/targets/react/component/handlers/action-button.ts +149 -0
- package/src/codegen/targets/react/component/handlers/alert-dialog.ts +120 -0
- package/src/codegen/targets/react/component/handlers/app-bar.ts +169 -0
- 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 +38 -0
- package/src/codegen/targets/react/component/handlers/avatar.ts +58 -0
- package/src/codegen/targets/react/component/handlers/badge.ts +18 -0
- package/src/codegen/targets/react/component/handlers/bottom-sheet.ts +74 -0
- package/src/codegen/targets/react/component/handlers/callout.ts +88 -0
- package/src/codegen/targets/react/component/handlers/checkbox.ts +129 -0
- package/src/codegen/targets/react/component/handlers/checkmark.ts +29 -0
- package/src/codegen/targets/react/component/handlers/chip.ts +93 -0
- package/src/codegen/targets/react/component/handlers/content-placeholder.ts +20 -0
- package/src/codegen/targets/react/component/handlers/contextual-floating-button.ts +52 -0
- package/src/codegen/targets/react/component/handlers/divider.ts +25 -0
- package/src/codegen/targets/react/component/handlers/field-button.ts +192 -0
- package/src/codegen/targets/react/component/handlers/field.ts +164 -0
- package/src/codegen/targets/react/component/handlers/floating-action-button.ts +45 -0
- package/src/codegen/targets/react/component/handlers/help-bubble.ts +73 -0
- package/src/codegen/targets/react/component/handlers/identity-placeholder.ts +20 -0
- package/src/codegen/targets/react/component/handlers/image-frame.ts +147 -0
- package/src/codegen/targets/react/component/handlers/index.ts +43 -0
- package/src/codegen/targets/react/component/handlers/legacy-select-box.ts +87 -0
- package/src/codegen/targets/react/component/handlers/legacy-text-field.ts +196 -0
- package/src/codegen/targets/react/component/handlers/list-header.ts +20 -0
- package/src/codegen/targets/react/component/handlers/list-item.ts +163 -0
- package/src/codegen/targets/react/component/handlers/manner-temp-badge.ts +21 -0
- package/src/codegen/targets/react/component/handlers/manner-temp.ts +18 -0
- package/src/codegen/targets/react/component/handlers/menu-sheet.ts +111 -0
- package/src/codegen/targets/react/component/handlers/page-banner.ts +106 -0
- package/src/codegen/targets/react/component/handlers/progress-circle.ts +55 -0
- package/src/codegen/targets/react/component/handlers/radio-group.ts +109 -0
- package/src/codegen/targets/react/component/handlers/radiomark.ts +27 -0
- package/src/codegen/targets/react/component/handlers/reaction-button.ts +37 -0
- package/src/codegen/targets/react/component/handlers/result-section.ts +67 -0
- package/src/codegen/targets/react/component/handlers/segmented-control.ts +63 -0
- package/src/codegen/targets/react/component/handlers/select-box.ts +333 -0
- package/src/codegen/targets/react/component/handlers/skeleton.ts +26 -0
- package/src/codegen/targets/react/component/handlers/slider.ts +117 -0
- package/src/codegen/targets/react/component/handlers/snackbar.ts +25 -0
- package/src/codegen/targets/react/component/handlers/switch.ts +35 -0
- package/src/codegen/targets/react/component/handlers/switchmark.ts +26 -0
- package/src/codegen/targets/react/component/handlers/tabs.ts +298 -0
- package/src/codegen/targets/react/component/handlers/tag-group.ts +90 -0
- package/src/codegen/targets/react/component/handlers/text-field.ts +253 -0
- package/src/codegen/targets/react/component/handlers/toggle-button.ts +43 -0
- package/src/codegen/targets/react/component/index.ts +24 -0
- package/src/codegen/targets/react/component/size.ts +22 -0
- package/src/codegen/targets/react/element-factories.ts +59 -0
- package/src/codegen/targets/react/frame.ts +96 -0
- package/src/codegen/targets/react/icon.ts +55 -0
- package/src/codegen/targets/react/index.ts +7 -0
- package/src/codegen/targets/react/instance.ts +82 -0
- package/src/codegen/targets/react/pipeline.ts +133 -0
- package/src/codegen/targets/react/props.ts +417 -0
- package/src/codegen/targets/react/shape.ts +47 -0
- package/src/codegen/targets/react/text.ts +31 -0
- package/src/codegen/targets/react/value-resolver.ts +93 -0
- package/src/entities/component.interface.ts +7 -0
- package/src/entities/component.repository.ts +16 -0
- 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 +4325 -0
- package/src/entities/data/__generated__/component-sets/index.mjs +4325 -0
- package/src/entities/data/__generated__/components/index.d.ts +378 -0
- package/src/entities/data/__generated__/components/index.mjs +378 -0
- package/src/entities/data/__generated__/icons/index.d.ts +3 -0
- package/src/entities/data/__generated__/icons/index.mjs +3476 -0
- package/src/entities/data/__generated__/styles/index.d.ts +3 -0
- package/src/entities/data/__generated__/styles/index.mjs +436 -0
- package/src/entities/data/__generated__/variable-collections/index.d.ts +3 -0
- package/src/entities/data/__generated__/variable-collections/index.mjs +479 -0
- package/src/entities/data/__generated__/variables/index.d.ts +3 -0
- package/src/entities/data/__generated__/variables/index.mjs +6969 -0
- package/src/entities/icon.interface.ts +5 -0
- package/src/entities/icon.repository.ts +11 -0
- package/src/entities/icon.service.ts +26 -0
- package/src/entities/index.ts +60 -0
- package/src/entities/style.interface.ts +5 -0
- package/src/entities/style.repository.ts +27 -0
- package/src/entities/style.service.ts +36 -0
- package/src/entities/variable.interface.ts +18 -0
- package/src/entities/variable.repository.ts +57 -0
- package/src/entities/variable.service.ts +101 -0
- package/src/index.ts +3 -0
- package/src/normalizer/from-plugin.ts +602 -0
- package/src/normalizer/from-rest.ts +577 -0
- package/src/normalizer/index.ts +3 -0
- package/src/normalizer/types.ts +208 -0
- package/src/utils/common.ts +38 -0
- package/src/utils/css.ts +19 -0
- package/src/utils/figma-gradient.ts +72 -0
- package/src/utils/figma-node.ts +95 -0
- package/src/utils/figma-variable.ts +49 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import type { InferComponentDefinition } from "@/codegen/core";
|
|
2
|
+
import type * as sets from "@/entities/data/__generated__/component-sets";
|
|
3
|
+
import type * as components from "@/entities/data/__generated__/components";
|
|
4
|
+
|
|
5
|
+
export type ActionButtonProperties = InferComponentDefinition<
|
|
6
|
+
typeof sets.componentActionButton.componentPropertyDefinitions
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
export type ActionButtonGhostProperties = InferComponentDefinition<
|
|
10
|
+
typeof sets.componentActionButtonGhostButton.componentPropertyDefinitions
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
export type AlertDialogProperties = InferComponentDefinition<
|
|
14
|
+
typeof sets.componentAlertDialog.componentPropertyDefinitions
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
export type AlertDialogFooterProperties = InferComponentDefinition<
|
|
18
|
+
typeof sets.privateComponentAlertDialogActions.componentPropertyDefinitions
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export type AvatarProperties = InferComponentDefinition<
|
|
22
|
+
typeof sets.componentAvatar.componentPropertyDefinitions
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export type AvatarStackProperties = InferComponentDefinition<
|
|
26
|
+
typeof sets.componentAvatarStack.componentPropertyDefinitions
|
|
27
|
+
>;
|
|
28
|
+
|
|
29
|
+
export type BadgeProperties = InferComponentDefinition<
|
|
30
|
+
typeof sets.componentBadge.componentPropertyDefinitions
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
export type BottomSheetProperties = InferComponentDefinition<
|
|
34
|
+
typeof sets.componentBottomSheet.componentPropertyDefinitions
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
export type CalloutProperties = InferComponentDefinition<
|
|
38
|
+
typeof sets.componentCallout.componentPropertyDefinitions
|
|
39
|
+
>;
|
|
40
|
+
|
|
41
|
+
export type CheckboxProperties = InferComponentDefinition<
|
|
42
|
+
typeof sets.componentCheckbox.componentPropertyDefinitions
|
|
43
|
+
>;
|
|
44
|
+
|
|
45
|
+
export type CheckboxGroupFieldProperties = InferComponentDefinition<
|
|
46
|
+
typeof sets.templateCheckboxField.componentPropertyDefinitions
|
|
47
|
+
>;
|
|
48
|
+
|
|
49
|
+
export type CheckmarkProperties = InferComponentDefinition<
|
|
50
|
+
typeof sets.componentCheckmark.componentPropertyDefinitions
|
|
51
|
+
>;
|
|
52
|
+
|
|
53
|
+
export type ChipProperties = InferComponentDefinition<
|
|
54
|
+
typeof sets.componentChip.componentPropertyDefinitions
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
export type ChipIconSuffixProperties = InferComponentDefinition<
|
|
58
|
+
typeof components.componentChipSuffixIcon.componentPropertyDefinitions
|
|
59
|
+
>;
|
|
60
|
+
|
|
61
|
+
export type ContentPlaceholderProperties = InferComponentDefinition<
|
|
62
|
+
typeof sets.privateComponentContentPlaceholder.componentPropertyDefinitions
|
|
63
|
+
>;
|
|
64
|
+
|
|
65
|
+
export type ContextualFloatingButtonProperties = InferComponentDefinition<
|
|
66
|
+
typeof sets.componentContextualFloatingButton.componentPropertyDefinitions
|
|
67
|
+
>;
|
|
68
|
+
|
|
69
|
+
export type DividerProperties = InferComponentDefinition<
|
|
70
|
+
typeof sets.componentDivider.componentPropertyDefinitions
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
export type FieldHeaderProperties = InferComponentDefinition<
|
|
74
|
+
typeof sets.componentFieldHeader.componentPropertyDefinitions
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
export type FieldIndicatorProperties = InferComponentDefinition<
|
|
78
|
+
typeof sets.privateComponentFieldHeaderIndicator.componentPropertyDefinitions
|
|
79
|
+
>;
|
|
80
|
+
|
|
81
|
+
export type FieldFooterProperties = InferComponentDefinition<
|
|
82
|
+
typeof sets.componentFieldFooter.componentPropertyDefinitions
|
|
83
|
+
>;
|
|
84
|
+
|
|
85
|
+
export type FieldCharacterCountProperties = InferComponentDefinition<
|
|
86
|
+
typeof sets.privateComponentFieldFooterCharacterCount.componentPropertyDefinitions
|
|
87
|
+
>;
|
|
88
|
+
|
|
89
|
+
export type MenuSheetProperties = InferComponentDefinition<
|
|
90
|
+
typeof sets.componentMenuSheet.componentPropertyDefinitions
|
|
91
|
+
>;
|
|
92
|
+
|
|
93
|
+
export type MenuSheetGroupProperties = InferComponentDefinition<
|
|
94
|
+
typeof sets.privateComponentMenuSheetMenuGroup.componentPropertyDefinitions
|
|
95
|
+
>;
|
|
96
|
+
|
|
97
|
+
export type MenuSheetItemProperties = InferComponentDefinition<
|
|
98
|
+
typeof sets.privateComponentMenuSheetMenuItem.componentPropertyDefinitions
|
|
99
|
+
>;
|
|
100
|
+
|
|
101
|
+
export type FloatingActionButtonProperties = InferComponentDefinition<
|
|
102
|
+
typeof sets.componentFloatingActionButton.componentPropertyDefinitions
|
|
103
|
+
>;
|
|
104
|
+
|
|
105
|
+
export type FloatingActionButtonButtonItemProperties = InferComponentDefinition<
|
|
106
|
+
typeof sets.privateComponentItemButtonType.componentPropertyDefinitions
|
|
107
|
+
>;
|
|
108
|
+
|
|
109
|
+
export type FloatingActionButtonMenuItemProperties = InferComponentDefinition<
|
|
110
|
+
typeof sets.privateComponentItemMenuType.componentPropertyDefinitions
|
|
111
|
+
>;
|
|
112
|
+
|
|
113
|
+
export type HelpBubbleProperties = InferComponentDefinition<
|
|
114
|
+
typeof sets.componentHelpBubble.componentPropertyDefinitions
|
|
115
|
+
>;
|
|
116
|
+
|
|
117
|
+
export type IdentityPlaceholderProperties = InferComponentDefinition<
|
|
118
|
+
typeof sets.privateComponentIdentityPlaceholder.componentPropertyDefinitions
|
|
119
|
+
>;
|
|
120
|
+
|
|
121
|
+
export type ImageFrameProperties = InferComponentDefinition<
|
|
122
|
+
typeof sets.componentImageFrame.componentPropertyDefinitions
|
|
123
|
+
>;
|
|
124
|
+
|
|
125
|
+
export type ImageFrameIconProperties = InferComponentDefinition<
|
|
126
|
+
typeof components.componentImageFrameIcon.componentPropertyDefinitions
|
|
127
|
+
>;
|
|
128
|
+
|
|
129
|
+
export type ImageFrameOverlayIndicatorProperties = InferComponentDefinition<
|
|
130
|
+
typeof components.componentImageFrameOverlayIndicator.componentPropertyDefinitions
|
|
131
|
+
>;
|
|
132
|
+
|
|
133
|
+
export type ImageFrameReactionButtonProperties = InferComponentDefinition<
|
|
134
|
+
typeof sets.componentImageFrameReactionButton.componentPropertyDefinitions
|
|
135
|
+
>;
|
|
136
|
+
|
|
137
|
+
export type PageBannerProperties = InferComponentDefinition<
|
|
138
|
+
typeof sets.componentPageBanner.componentPropertyDefinitions
|
|
139
|
+
>;
|
|
140
|
+
|
|
141
|
+
export type PageBannerButtonProperties = InferComponentDefinition<
|
|
142
|
+
typeof components.componentPageBannerSuffixAction.componentPropertyDefinitions
|
|
143
|
+
>;
|
|
144
|
+
|
|
145
|
+
export type ListHeaderProperties = InferComponentDefinition<
|
|
146
|
+
typeof sets.componentListHeader.componentPropertyDefinitions
|
|
147
|
+
>;
|
|
148
|
+
|
|
149
|
+
export type ListItemProperties = InferComponentDefinition<
|
|
150
|
+
typeof sets.componentListItem.componentPropertyDefinitions
|
|
151
|
+
>;
|
|
152
|
+
|
|
153
|
+
export type ListItemPrefixIconProperties = InferComponentDefinition<
|
|
154
|
+
typeof components.componentListItemPrefixIcon.componentPropertyDefinitions
|
|
155
|
+
>;
|
|
156
|
+
|
|
157
|
+
export type ListItemSuffixIconProperties = InferComponentDefinition<
|
|
158
|
+
typeof components.componentListItemSuffixIcon.componentPropertyDefinitions
|
|
159
|
+
>;
|
|
160
|
+
|
|
161
|
+
export type MannerTempProperties = InferComponentDefinition<
|
|
162
|
+
typeof sets.componentMannerTemp.componentPropertyDefinitions
|
|
163
|
+
>;
|
|
164
|
+
|
|
165
|
+
export type MannerTempBadgeProperties = InferComponentDefinition<
|
|
166
|
+
typeof sets.componentMannerTempBadge.componentPropertyDefinitions
|
|
167
|
+
>;
|
|
168
|
+
|
|
169
|
+
export type ProgressCircleProperties = InferComponentDefinition<
|
|
170
|
+
typeof sets.componentProgressCircle.componentPropertyDefinitions
|
|
171
|
+
>;
|
|
172
|
+
|
|
173
|
+
export type RadioProperties = InferComponentDefinition<
|
|
174
|
+
typeof sets.componentRadio.componentPropertyDefinitions
|
|
175
|
+
>;
|
|
176
|
+
|
|
177
|
+
export type RadioGroupFieldProperties = InferComponentDefinition<
|
|
178
|
+
typeof sets.templateRadioField.componentPropertyDefinitions
|
|
179
|
+
>;
|
|
180
|
+
|
|
181
|
+
export type RadiomarkProperties = InferComponentDefinition<
|
|
182
|
+
typeof sets.componentRadiomark.componentPropertyDefinitions
|
|
183
|
+
>;
|
|
184
|
+
|
|
185
|
+
export type ReactionButtonProperties = InferComponentDefinition<
|
|
186
|
+
typeof sets.componentReactionButton.componentPropertyDefinitions
|
|
187
|
+
>;
|
|
188
|
+
|
|
189
|
+
export type ResultSectionProperties = InferComponentDefinition<
|
|
190
|
+
typeof sets.componentResultSection.componentPropertyDefinitions
|
|
191
|
+
>;
|
|
192
|
+
|
|
193
|
+
export type SegmentedControlProperties = InferComponentDefinition<
|
|
194
|
+
typeof sets.componentSegmentedControl.componentPropertyDefinitions
|
|
195
|
+
>;
|
|
196
|
+
|
|
197
|
+
export type SegmentedControlItemProperties = InferComponentDefinition<
|
|
198
|
+
typeof sets.privateComponentSegmentedControlItem.componentPropertyDefinitions
|
|
199
|
+
>;
|
|
200
|
+
|
|
201
|
+
export type SelectBoxGroupFieldProperties = InferComponentDefinition<
|
|
202
|
+
typeof sets.templateSelectBoxField.componentPropertyDefinitions
|
|
203
|
+
>;
|
|
204
|
+
|
|
205
|
+
export type SelectBoxGroupProperties = InferComponentDefinition<
|
|
206
|
+
typeof sets.componentSelectBoxGroup.componentPropertyDefinitions
|
|
207
|
+
>;
|
|
208
|
+
|
|
209
|
+
export type SelectBoxHorizontalProperties = InferComponentDefinition<
|
|
210
|
+
typeof sets.componentSelectBoxItemHorizontal.componentPropertyDefinitions
|
|
211
|
+
>;
|
|
212
|
+
|
|
213
|
+
export type SelectBoxVerticalProperties = InferComponentDefinition<
|
|
214
|
+
typeof sets.componentSelectBoxItemVertical.componentPropertyDefinitions
|
|
215
|
+
>;
|
|
216
|
+
|
|
217
|
+
export type SelectBoxPrefixIconProperties = InferComponentDefinition<
|
|
218
|
+
typeof components.componentSelectBoxItemPrefixIcon.componentPropertyDefinitions
|
|
219
|
+
>;
|
|
220
|
+
|
|
221
|
+
export type SkeletonProperties = InferComponentDefinition<
|
|
222
|
+
typeof sets.componentSkeleton.componentPropertyDefinitions
|
|
223
|
+
>;
|
|
224
|
+
|
|
225
|
+
export type SliderProperties = InferComponentDefinition<
|
|
226
|
+
typeof sets.componentSlider.componentPropertyDefinitions
|
|
227
|
+
>;
|
|
228
|
+
|
|
229
|
+
export type SliderTicksProperties = InferComponentDefinition<
|
|
230
|
+
typeof sets.privateComponentSliderItemTickMark.componentPropertyDefinitions
|
|
231
|
+
>;
|
|
232
|
+
|
|
233
|
+
export type SliderFieldProperties = InferComponentDefinition<
|
|
234
|
+
typeof sets.templateSliderField.componentPropertyDefinitions
|
|
235
|
+
>;
|
|
236
|
+
|
|
237
|
+
export type SnackbarProperties = InferComponentDefinition<
|
|
238
|
+
typeof sets.componentSnackbar.componentPropertyDefinitions
|
|
239
|
+
>;
|
|
240
|
+
|
|
241
|
+
export type SwitchProperties = InferComponentDefinition<
|
|
242
|
+
typeof sets.componentSwitch.componentPropertyDefinitions
|
|
243
|
+
>;
|
|
244
|
+
|
|
245
|
+
export type SwitchmarkProperties = InferComponentDefinition<
|
|
246
|
+
typeof sets.componentSwitchmark.componentPropertyDefinitions
|
|
247
|
+
>;
|
|
248
|
+
|
|
249
|
+
export type ToggleButtonProperties = InferComponentDefinition<
|
|
250
|
+
typeof sets.componentToggleButton.componentPropertyDefinitions
|
|
251
|
+
>;
|
|
252
|
+
|
|
253
|
+
export type AppBarProperties = InferComponentDefinition<
|
|
254
|
+
typeof sets.componentTopNavigation.componentPropertyDefinitions
|
|
255
|
+
>;
|
|
256
|
+
|
|
257
|
+
export type AppBarMainProperties = InferComponentDefinition<
|
|
258
|
+
typeof sets.privateComponentTopNavigationTitle.componentPropertyDefinitions
|
|
259
|
+
>;
|
|
260
|
+
|
|
261
|
+
export type AppBarLeftIconButtonProperties = InferComponentDefinition<
|
|
262
|
+
typeof components.privateComponentTopNavigationLeftIconButton.componentPropertyDefinitions
|
|
263
|
+
>;
|
|
264
|
+
|
|
265
|
+
export type AppBarRightIconButtonProperties = InferComponentDefinition<
|
|
266
|
+
typeof sets.privateComponentTopNavigationRightIconButton.componentPropertyDefinitions
|
|
267
|
+
>;
|
|
268
|
+
|
|
269
|
+
export type TabsProperties = InferComponentDefinition<
|
|
270
|
+
typeof sets.componentTabs.componentPropertyDefinitions
|
|
271
|
+
>;
|
|
272
|
+
|
|
273
|
+
export type TabsLineWrapperProperties = InferComponentDefinition<
|
|
274
|
+
typeof sets.privateComponentTabsLine.componentPropertyDefinitions
|
|
275
|
+
>;
|
|
276
|
+
|
|
277
|
+
export type TabsLineTriggerHugProperties = InferComponentDefinition<
|
|
278
|
+
typeof sets.privateComponentTabItemLineHug.componentPropertyDefinitions
|
|
279
|
+
>;
|
|
280
|
+
|
|
281
|
+
export type TabsLineTriggerFillProperties = InferComponentDefinition<
|
|
282
|
+
typeof sets.privateComponentTabItemLineFill.componentPropertyDefinitions
|
|
283
|
+
>;
|
|
284
|
+
|
|
285
|
+
export type TabsChipWrapperProperties = InferComponentDefinition<
|
|
286
|
+
typeof sets.privateComponentTabsChip.componentPropertyDefinitions
|
|
287
|
+
>;
|
|
288
|
+
|
|
289
|
+
export type ChipTabsTriggerProperties = InferComponentDefinition<
|
|
290
|
+
typeof sets.privateComponentTabItemChip.componentPropertyDefinitions
|
|
291
|
+
>;
|
|
292
|
+
|
|
293
|
+
export type TagGroupProperties = InferComponentDefinition<
|
|
294
|
+
typeof sets.componentTagGroup.componentPropertyDefinitions
|
|
295
|
+
>;
|
|
296
|
+
|
|
297
|
+
export type TagGroupItemProperties = InferComponentDefinition<
|
|
298
|
+
typeof sets.privateComponentItemTag.componentPropertyDefinitions
|
|
299
|
+
>;
|
|
300
|
+
|
|
301
|
+
export type TextInputFieldProperties = InferComponentDefinition<
|
|
302
|
+
typeof sets.templateTextField.componentPropertyDefinitions
|
|
303
|
+
>;
|
|
304
|
+
|
|
305
|
+
export type TextInputOutlineProperties = InferComponentDefinition<
|
|
306
|
+
typeof sets.componentTextInput.componentPropertyDefinitions
|
|
307
|
+
>;
|
|
308
|
+
|
|
309
|
+
export type TextInputOutlinePrefixProperties = InferComponentDefinition<
|
|
310
|
+
typeof sets.privateComponentTextInputPrefix.componentPropertyDefinitions
|
|
311
|
+
>;
|
|
312
|
+
|
|
313
|
+
export type TextInputOutlineSuffixProperties = InferComponentDefinition<
|
|
314
|
+
typeof sets.privateComponentTextInputSuffix.componentPropertyDefinitions
|
|
315
|
+
>;
|
|
316
|
+
|
|
317
|
+
export type TextInputUnderlinePrefixProperties = InferComponentDefinition<
|
|
318
|
+
typeof sets.privateComponentUnderlineTextInputPrefix.componentPropertyDefinitions
|
|
319
|
+
>;
|
|
320
|
+
|
|
321
|
+
export type TextInputUnderlineSuffixProperties = InferComponentDefinition<
|
|
322
|
+
typeof sets.privateComponentUnderlineTextInputSuffix.componentPropertyDefinitions
|
|
323
|
+
>;
|
|
324
|
+
|
|
325
|
+
export type TextInputUnderlineProperties = InferComponentDefinition<
|
|
326
|
+
typeof sets.componentUnderlineTextInput.componentPropertyDefinitions
|
|
327
|
+
>;
|
|
328
|
+
|
|
329
|
+
export type TextareaFieldProperties = InferComponentDefinition<
|
|
330
|
+
typeof sets.templateTextareaField.componentPropertyDefinitions
|
|
331
|
+
>;
|
|
332
|
+
|
|
333
|
+
export type TextareaProperties = InferComponentDefinition<
|
|
334
|
+
typeof sets.componentTextarea.componentPropertyDefinitions
|
|
335
|
+
>;
|
|
336
|
+
|
|
337
|
+
export type FieldButtonProperties = InferComponentDefinition<
|
|
338
|
+
typeof sets.templateFieldButton.componentPropertyDefinitions
|
|
339
|
+
>;
|
|
340
|
+
|
|
341
|
+
export type InputButtonProperties = InferComponentDefinition<
|
|
342
|
+
typeof sets.componentInputButton.componentPropertyDefinitions
|
|
343
|
+
>;
|
|
344
|
+
|
|
345
|
+
export type InputButtonPrefixProperties = InferComponentDefinition<
|
|
346
|
+
typeof sets.privateComponentInputButtonPrefix.componentPropertyDefinitions
|
|
347
|
+
>;
|
|
348
|
+
|
|
349
|
+
export type InputButtonSuffixProperties = InferComponentDefinition<
|
|
350
|
+
typeof sets.privateComponentInputButtonSuffix.componentPropertyDefinitions
|
|
351
|
+
>;
|
|
352
|
+
|
|
353
|
+
export type GenericFieldButtonProps = InferComponentDefinition<{}>;
|
|
354
|
+
|
|
355
|
+
export type LegacyTextFieldProperties = InferComponentDefinition<
|
|
356
|
+
typeof sets.componentDeprecatedTextField.componentPropertyDefinitions
|
|
357
|
+
>;
|
|
358
|
+
|
|
359
|
+
export type LegacyMultilineTextFieldProperties = InferComponentDefinition<
|
|
360
|
+
typeof sets.componentDeprecatedMultilineTextField.componentPropertyDefinitions
|
|
361
|
+
>;
|
|
362
|
+
|
|
363
|
+
export type LegacySelectBoxProperties = InferComponentDefinition<
|
|
364
|
+
typeof sets.componentDeprecatedSelectBox.componentPropertyDefinitions
|
|
365
|
+
>;
|
|
366
|
+
|
|
367
|
+
export type LegacySelectBoxGroupProperties = InferComponentDefinition<
|
|
368
|
+
typeof sets.componentDeprecatedSelectBoxGroup.componentPropertyDefinitions
|
|
369
|
+
>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
NormalizedBooleanOperationNode,
|
|
3
|
+
NormalizedComponentNode,
|
|
4
|
+
NormalizedFrameNode,
|
|
5
|
+
NormalizedInstanceNode,
|
|
6
|
+
NormalizedRectangleNode,
|
|
7
|
+
NormalizedSceneNode,
|
|
8
|
+
NormalizedTextNode,
|
|
9
|
+
NormalizedVectorNode,
|
|
10
|
+
} from "@/normalizer";
|
|
11
|
+
import { match } from "ts-pattern";
|
|
12
|
+
import { appendSource, createElement, stringifyElement, type ElementNode } from "../core/jsx";
|
|
13
|
+
import type { ElementTransformer } from "./element-transformer";
|
|
14
|
+
import { applyInferredLayout, inferLayout } from "./infer-layout";
|
|
15
|
+
import { pascalCase } from "change-case";
|
|
16
|
+
|
|
17
|
+
export interface CodeGeneratorDeps {
|
|
18
|
+
frameTransformer: ElementTransformer<
|
|
19
|
+
NormalizedFrameNode | NormalizedComponentNode | NormalizedInstanceNode
|
|
20
|
+
>;
|
|
21
|
+
textTransformer: ElementTransformer<NormalizedTextNode>;
|
|
22
|
+
rectangleTransformer: ElementTransformer<NormalizedRectangleNode>;
|
|
23
|
+
instanceTransformer: ElementTransformer<NormalizedInstanceNode>;
|
|
24
|
+
vectorTransformer: ElementTransformer<NormalizedVectorNode>;
|
|
25
|
+
booleanOperationTransformer: ElementTransformer<NormalizedBooleanOperationNode>;
|
|
26
|
+
shouldInferAutoLayout: boolean;
|
|
27
|
+
skipComponentKeys?: Set<string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CodeGenerator {
|
|
31
|
+
generateJsxTree: (node: NormalizedSceneNode) => ElementNode | undefined;
|
|
32
|
+
generateCode: (
|
|
33
|
+
node: NormalizedSceneNode,
|
|
34
|
+
options: { shouldPrintSource: boolean },
|
|
35
|
+
) => { imports: string; jsx: string } | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createCodeGenerator({
|
|
39
|
+
frameTransformer,
|
|
40
|
+
textTransformer,
|
|
41
|
+
rectangleTransformer,
|
|
42
|
+
instanceTransformer,
|
|
43
|
+
vectorTransformer,
|
|
44
|
+
booleanOperationTransformer,
|
|
45
|
+
shouldInferAutoLayout,
|
|
46
|
+
skipComponentKeys,
|
|
47
|
+
}: CodeGeneratorDeps): CodeGenerator {
|
|
48
|
+
function isSkippedInstance(node: NormalizedSceneNode): boolean {
|
|
49
|
+
if (!skipComponentKeys || skipComponentKeys.size === 0) return false;
|
|
50
|
+
if (node.type !== "INSTANCE") return false;
|
|
51
|
+
|
|
52
|
+
const { componentKey, componentSetKey } = node;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
skipComponentKeys.has(componentKey) ||
|
|
56
|
+
(!!componentSetKey && skipComponentKeys.has(componentSetKey))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function traverse(node: NormalizedSceneNode): ElementNode | undefined {
|
|
61
|
+
if ("visible" in node && !node.visible) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (isSkippedInstance(node)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const result = match(node)
|
|
70
|
+
.with({ type: "FRAME" }, (node) =>
|
|
71
|
+
shouldInferAutoLayout
|
|
72
|
+
? frameTransformer(applyInferredLayout(node, inferLayout(node)), traverse)
|
|
73
|
+
: frameTransformer(node, traverse),
|
|
74
|
+
)
|
|
75
|
+
.with({ type: "TEXT" }, (node) => textTransformer(node, traverse))
|
|
76
|
+
.with({ type: "RECTANGLE" }, (node) => rectangleTransformer(node, traverse))
|
|
77
|
+
.with({ type: "COMPONENT" }, (node) => frameTransformer(node, traverse)) // NOTE: Treat component node as Frame for now
|
|
78
|
+
.with({ type: "INSTANCE" }, (node) => instanceTransformer(node, traverse))
|
|
79
|
+
.with({ type: "VECTOR" }, (node) => vectorTransformer(node, traverse))
|
|
80
|
+
.with({ type: "BOOLEAN_OPERATION" }, (node) => booleanOperationTransformer(node, traverse))
|
|
81
|
+
.with({ type: "UNHANDLED" }, (node) =>
|
|
82
|
+
createElement(`Unhandled${pascalCase(node.original.type)}Node`),
|
|
83
|
+
)
|
|
84
|
+
.exhaustive();
|
|
85
|
+
|
|
86
|
+
if (result) {
|
|
87
|
+
return appendSource(result, node.id);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function generateJsxTree(node: NormalizedSceneNode) {
|
|
94
|
+
return traverse(node);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function generateCode(node: NormalizedSceneNode, options: { shouldPrintSource: boolean }) {
|
|
98
|
+
if (isSkippedInstance(node)) {
|
|
99
|
+
return { imports: "", jsx: "// This component is intentionally excluded from codegen" };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const jsxTree = generateJsxTree(node);
|
|
103
|
+
|
|
104
|
+
if (!jsxTree) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return stringifyElement(jsxTree, { printSource: options.shouldPrintSource });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return { generateJsxTree, generateCode };
|
|
112
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NormalizedInstanceNode, NormalizedSceneNode } from "@/normalizer";
|
|
2
|
+
import type { ElementNode } from "./jsx";
|
|
3
|
+
|
|
4
|
+
export interface ComponentHandler<
|
|
5
|
+
T extends
|
|
6
|
+
NormalizedInstanceNode["componentProperties"] = NormalizedInstanceNode["componentProperties"],
|
|
7
|
+
> {
|
|
8
|
+
key: string;
|
|
9
|
+
transform: (
|
|
10
|
+
node: Omit<NormalizedInstanceNode, "componentProperties"> & { componentProperties: T },
|
|
11
|
+
traverse: (node: NormalizedSceneNode) => ElementNode | undefined,
|
|
12
|
+
) => ElementNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function defineComponentHandler<T extends NormalizedInstanceNode["componentProperties"]>(
|
|
16
|
+
key: string,
|
|
17
|
+
transform: (
|
|
18
|
+
node: Omit<NormalizedInstanceNode, "componentProperties"> & { componentProperties: T },
|
|
19
|
+
traverse: (node: NormalizedSceneNode) => ElementNode | undefined,
|
|
20
|
+
) => ElementNode,
|
|
21
|
+
): ComponentHandler<T> {
|
|
22
|
+
return { key, transform };
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ComponentPropertyType, InstanceSwapPreferredValue } from "@figma/rest-api-spec";
|
|
2
|
+
|
|
3
|
+
export interface ComponentPropertyDefinition {
|
|
4
|
+
type: ComponentPropertyType;
|
|
5
|
+
preferredValues?: InstanceSwapPreferredValue[];
|
|
6
|
+
variantOptions?: string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type InferComponentPropertyType<T extends ComponentPropertyDefinition> =
|
|
10
|
+
T["type"] extends "TEXT"
|
|
11
|
+
? string
|
|
12
|
+
: T["type"] extends "BOOLEAN"
|
|
13
|
+
? boolean
|
|
14
|
+
: T["type"] extends "INSTANCE_SWAP"
|
|
15
|
+
? string
|
|
16
|
+
: T["type"] extends "VARIANT"
|
|
17
|
+
? T["variantOptions"] extends string[]
|
|
18
|
+
? T["variantOptions"][number]
|
|
19
|
+
: never
|
|
20
|
+
: never;
|
|
21
|
+
|
|
22
|
+
export type InferComponentDefinition<T extends Record<string, ComponentPropertyDefinition>> = {
|
|
23
|
+
[K in keyof T]: {
|
|
24
|
+
type: T[K]["type"];
|
|
25
|
+
value: InferComponentPropertyType<T[K]>;
|
|
26
|
+
readonly boundVariables?: {
|
|
27
|
+
[field in VariableBindableComponentPropertyField]?: VariableAlias;
|
|
28
|
+
};
|
|
29
|
+
} & (T[K]["type"] extends "INSTANCE_SWAP"
|
|
30
|
+
? {
|
|
31
|
+
componentKey: string;
|
|
32
|
+
preferredValues: InstanceSwapPreferredValue[];
|
|
33
|
+
}
|
|
34
|
+
: {});
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NormalizedSceneNode } from "@/normalizer";
|
|
2
|
+
import type { ElementNode } from "./jsx";
|
|
3
|
+
|
|
4
|
+
export type ElementTransformer<T extends NormalizedSceneNode> = (
|
|
5
|
+
node: T,
|
|
6
|
+
traverse: (node: NormalizedSceneNode) => ElementNode | undefined,
|
|
7
|
+
) => ElementNode | undefined;
|
|
8
|
+
|
|
9
|
+
export function defineElementTransformer<T extends NormalizedSceneNode>(
|
|
10
|
+
transformer: ElementTransformer<T>,
|
|
11
|
+
) {
|
|
12
|
+
return transformer;
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type { CodeGeneratorDeps } from "./codegen";
|
|
2
|
+
export type { ComponentHandler } from "./component-handler";
|
|
3
|
+
export type {
|
|
4
|
+
ComponentPropertyDefinition,
|
|
5
|
+
InferComponentDefinition,
|
|
6
|
+
InferComponentPropertyType,
|
|
7
|
+
} from "./component-type-helper";
|
|
8
|
+
export type { ElementTransformer } from "./element-transformer";
|
|
9
|
+
export type { ElementNode } from "./jsx";
|
|
10
|
+
export type { PropsConverter } from "./props-converter";
|
|
11
|
+
export type { ValueResolver } from "./value-resolver";
|
|
12
|
+
|
|
13
|
+
export { createCodeGenerator } from "./codegen";
|
|
14
|
+
export { defineComponentHandler } from "./component-handler";
|
|
15
|
+
export { defineElementTransformer } from "./element-transformer";
|
|
16
|
+
export { inferLayout } from "./infer-layout";
|
|
17
|
+
export { cloneElement, createElement } from "./jsx";
|
|
18
|
+
export { createPropsConverter, definePropsConverter } from "./props-converter";
|
|
19
|
+
export { createValueResolver } from "./value-resolver";
|