@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.
Files changed (118) hide show
  1. package/lib/codegen/index.cjs +12318 -190
  2. package/lib/codegen/index.d.ts.map +1 -1
  3. package/lib/codegen/index.js +12318 -190
  4. package/lib/codegen/targets/react/index.cjs +17676 -3101
  5. package/lib/codegen/targets/react/index.d.ts.map +1 -1
  6. package/lib/codegen/targets/react/index.js +17676 -3101
  7. package/lib/index.cjs +12324 -196
  8. package/lib/index.d.ts.map +1 -1
  9. package/lib/index.js +12324 -196
  10. package/package.json +4 -4
  11. package/src/codegen/component-properties.archive.ts +1019 -0
  12. package/src/codegen/component-properties.ts +219 -893
  13. package/src/codegen/core/infer-layout.test.ts +1 -1
  14. package/src/codegen/index.ts +1 -1
  15. package/src/codegen/targets/react/component/handlers/action-button.ts +69 -66
  16. package/src/codegen/targets/react/component/handlers/alert-dialog.ts +2 -4
  17. package/src/codegen/targets/react/component/handlers/app-bar.ts +90 -87
  18. package/src/codegen/targets/react/component/handlers/archive/action-button.ts +144 -0
  19. package/src/codegen/targets/react/component/handlers/archive/alert-dialog.ts +122 -0
  20. package/src/codegen/targets/react/component/handlers/archive/app-bar.ts +149 -0
  21. package/src/codegen/targets/react/component/handlers/archive/avatar-stack.ts +35 -0
  22. package/src/codegen/targets/react/component/handlers/archive/avatar.ts +55 -0
  23. package/src/codegen/targets/react/component/handlers/archive/badge.ts +18 -0
  24. package/src/codegen/targets/react/component/handlers/archive/bottom-sheet.ts +70 -0
  25. package/src/codegen/targets/react/component/handlers/archive/callout.ts +88 -0
  26. package/src/codegen/targets/react/component/handlers/archive/checkbox.ts +43 -0
  27. package/src/codegen/targets/react/component/handlers/archive/checkmark.ts +29 -0
  28. package/src/codegen/targets/react/component/handlers/archive/chip.ts +90 -0
  29. package/src/codegen/targets/react/component/handlers/archive/contextual-floating-button.ts +52 -0
  30. package/src/codegen/targets/react/component/handlers/archive/divider.ts +25 -0
  31. package/src/codegen/targets/react/component/handlers/archive/field-button.ts +197 -0
  32. package/src/codegen/targets/react/component/handlers/archive/field.ts +167 -0
  33. package/src/codegen/targets/react/component/handlers/archive/floating-action-button.ts +48 -0
  34. package/src/codegen/targets/react/component/handlers/archive/help-bubble.ts +73 -0
  35. package/src/codegen/targets/react/component/handlers/archive/identity-placeholder.ts +21 -0
  36. package/src/codegen/targets/react/component/handlers/archive/index.ts +40 -0
  37. package/src/codegen/targets/react/component/handlers/archive/legacy-select-box.ts +89 -0
  38. package/src/codegen/targets/react/component/handlers/archive/legacy-text-field.ts +198 -0
  39. package/src/codegen/targets/react/component/handlers/archive/list-header.ts +20 -0
  40. package/src/codegen/targets/react/component/handlers/archive/list-item.ts +162 -0
  41. package/src/codegen/targets/react/component/handlers/archive/manner-temp-badge.ts +21 -0
  42. package/src/codegen/targets/react/component/handlers/archive/manner-temp.ts +18 -0
  43. package/src/codegen/targets/react/component/handlers/archive/menu-sheet.ts +108 -0
  44. package/src/codegen/targets/react/component/handlers/archive/page-banner.ts +101 -0
  45. package/src/codegen/targets/react/component/handlers/archive/progress-circle.ts +55 -0
  46. package/src/codegen/targets/react/component/handlers/archive/radio-group.ts +31 -0
  47. package/src/codegen/targets/react/component/handlers/archive/radiomark.ts +27 -0
  48. package/src/codegen/targets/react/component/handlers/archive/reaction-button.ts +37 -0
  49. package/src/codegen/targets/react/component/handlers/archive/result-section.ts +67 -0
  50. package/src/codegen/targets/react/component/handlers/archive/segmented-control.ts +64 -0
  51. package/src/codegen/targets/react/component/handlers/archive/skeleton.ts +26 -0
  52. package/src/codegen/targets/react/component/handlers/archive/slider.ts +114 -0
  53. package/src/codegen/targets/react/component/handlers/archive/snackbar.ts +25 -0
  54. package/src/codegen/targets/react/component/handlers/archive/switch.ts +39 -0
  55. package/src/codegen/targets/react/component/handlers/archive/switchmark.ts +26 -0
  56. package/src/codegen/targets/react/component/handlers/archive/tabs.ts +297 -0
  57. package/src/codegen/targets/react/component/handlers/archive/tag-group.ts +86 -0
  58. package/src/codegen/targets/react/component/handlers/archive/text-field.ts +264 -0
  59. package/src/codegen/targets/react/component/handlers/archive/toggle-button.ts +43 -0
  60. package/src/codegen/targets/react/component/handlers/avatar-stack.ts +5 -2
  61. package/src/codegen/targets/react/component/handlers/avatar.ts +42 -39
  62. package/src/codegen/targets/react/component/handlers/badge.ts +1 -1
  63. package/src/codegen/targets/react/component/handlers/bottom-sheet.ts +56 -51
  64. package/src/codegen/targets/react/component/handlers/callout.ts +1 -1
  65. package/src/codegen/targets/react/component/handlers/checkbox.ts +91 -3
  66. package/src/codegen/targets/react/component/handlers/checkmark.ts +1 -1
  67. package/src/codegen/targets/react/component/handlers/chip.ts +8 -5
  68. package/src/codegen/targets/react/component/handlers/contextual-floating-button.ts +1 -1
  69. package/src/codegen/targets/react/component/handlers/divider.ts +1 -1
  70. package/src/codegen/targets/react/component/handlers/field-button.ts +13 -18
  71. package/src/codegen/targets/react/component/handlers/field.ts +71 -74
  72. package/src/codegen/targets/react/component/handlers/floating-action-button.ts +3 -6
  73. package/src/codegen/targets/react/component/handlers/help-bubble.ts +1 -1
  74. package/src/codegen/targets/react/component/handlers/identity-placeholder.ts +10 -2
  75. package/src/codegen/targets/react/component/handlers/index.ts +41 -0
  76. package/src/codegen/targets/react/component/handlers/legacy-select-box.ts +4 -6
  77. package/src/codegen/targets/react/component/handlers/legacy-text-field.ts +3 -5
  78. package/src/codegen/targets/react/component/handlers/list-header.ts +1 -1
  79. package/src/codegen/targets/react/component/handlers/list-item.ts +24 -23
  80. package/src/codegen/targets/react/component/handlers/manner-temp-badge.ts +1 -1
  81. package/src/codegen/targets/react/component/handlers/manner-temp.ts +1 -1
  82. package/src/codegen/targets/react/component/handlers/menu-sheet.ts +45 -42
  83. package/src/codegen/targets/react/component/handlers/page-banner.ts +77 -72
  84. package/src/codegen/targets/react/component/handlers/progress-circle.ts +1 -1
  85. package/src/codegen/targets/react/component/handlers/radio-group.ts +98 -20
  86. package/src/codegen/targets/react/component/handlers/radiomark.ts +1 -1
  87. package/src/codegen/targets/react/component/handlers/reaction-button.ts +1 -1
  88. package/src/codegen/targets/react/component/handlers/result-section.ts +1 -1
  89. package/src/codegen/targets/react/component/handlers/segmented-control.ts +2 -3
  90. package/src/codegen/targets/react/component/handlers/select-box.ts +333 -0
  91. package/src/codegen/targets/react/component/handlers/skeleton.ts +1 -1
  92. package/src/codegen/targets/react/component/handlers/slider.ts +13 -10
  93. package/src/codegen/targets/react/component/handlers/snackbar.ts +1 -1
  94. package/src/codegen/targets/react/component/handlers/switch.ts +1 -1
  95. package/src/codegen/targets/react/component/handlers/switchmark.ts +1 -1
  96. package/src/codegen/targets/react/component/handlers/tabs.ts +39 -42
  97. package/src/codegen/targets/react/component/handlers/tag-group.ts +46 -42
  98. package/src/codegen/targets/react/component/handlers/text-field.ts +11 -22
  99. package/src/codegen/targets/react/component/handlers/toggle-button.ts +1 -1
  100. package/src/codegen/targets/react/component/index.ts +5 -115
  101. package/src/entities/data/__generated__/archive/component-sets/index.d.ts +2074 -0
  102. package/src/entities/data/__generated__/archive/component-sets/index.mjs +2074 -0
  103. package/src/entities/data/__generated__/archive/components/index.d.ts +116 -0
  104. package/src/entities/data/__generated__/archive/components/index.mjs +116 -0
  105. package/src/entities/data/__generated__/archive/styles/index.d.ts +3 -0
  106. package/src/entities/data/__generated__/archive/styles/index.mjs +429 -0
  107. package/src/entities/data/__generated__/archive/variable-collections/index.d.ts +3 -0
  108. package/src/entities/data/__generated__/archive/variable-collections/index.mjs +501 -0
  109. package/src/entities/data/__generated__/archive/variables/index.d.ts +3 -0
  110. package/src/entities/data/__generated__/archive/variables/index.mjs +7019 -0
  111. package/src/entities/data/__generated__/component-sets/index.d.ts +3439 -1265
  112. package/src/entities/data/__generated__/component-sets/index.mjs +3439 -1265
  113. package/src/entities/data/__generated__/components/index.d.ts +326 -64
  114. package/src/entities/data/__generated__/components/index.mjs +326 -64
  115. package/src/entities/data/__generated__/styles/index.mjs +9 -2
  116. package/src/entities/data/__generated__/variable-collections/index.mjs +150 -173
  117. package/src/entities/data/__generated__/variables/index.mjs +0 -74
  118. 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>(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
- });
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
- FIELD_INDICATOR_KEY,
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>(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
- });
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
- FIELD_CHARACTER_COUNT_KEY,
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.floatingActionButton.key,
16
+ metadata.componentFloatingActionButton.key,
20
17
  (node) => {
21
18
  const [button] = findAllInstances<FloatingActionButtonButtonItemProperties>({
22
19
  node,
23
- key: BUTTON_TYPE_KEY,
20
+ key: metadata.privateComponentItemButtonType.key,
24
21
  });
25
22
  const [menu] = findAllInstances<FloatingActionButtonMenuItemProperties>({
26
23
  node,
27
- key: MENU_TYPE_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.helpBubble.key,
13
+ metadata.componentHelpBubble.key,
14
14
  ({ componentProperties: props }) => {
15
15
  const placement:
16
16
  | "top"
@@ -1,11 +1,19 @@
1
- import type { IdentityPlaceholderProperties } from "@/codegen/component-properties";
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 LEGACY_SELECT_BOX_KEY = "38722ffeb4c966256a709155e8ddac50c93d7c60";
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
- LEGACY_SELECT_BOX_KEY,
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
- LEGACY_SELECT_BOX_GROUP_KEY,
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
- LEGACY_TEXT_FIELD_KEY,
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
- LEGACY_MULTILINE_TEXT_FIELD_KEY,
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.listHeader.key,
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
- checkmark: "f24c9ef42ef08df79483fbae0fa7d9037e566748",
18
- radiomark: "5a77ad37a2291989dfe77c44ddee9aa39e447f90",
19
- icon: "0e4c05f097d3fa2dc0cbfdbf8db2662bcf8439ca",
20
- avatar: "ef0e8bd6c2f92e620acf204bb9a8079ef25a1e5c",
21
- image: "82239325aa1cb65af7c649fc71a8f2b48fb9b9f3",
22
- custom: "81f201fc876e38f016ab7427a6b3da000ee919a2",
23
- } as const;
24
-
25
- const SUFFIX_KEYS = {
26
- checkmark: "abf9810103ae6e6afe8fa253ec5f05d6a7304b38",
27
- radiomark: "0a9464ad270bfd7f56438f62bb0155a25ca146a9",
28
- chevron: "8c52207687ffed15cd5931d71ed9d196b3358a68",
29
- switch: "1e933f75dd6bb4b21c3289b5c3b4402d2c623125",
30
- custom: "3a70bf5bb9856c13893931b7a0df652bcf0be895",
31
- icon: "4cc7e9b84a8388a36cb3898c6c02e6110a3281b9",
32
- chevronWithText: "fe0e25f4fecda59d0a3730ead7c5bc0a66a41e7e",
33
- iconButton: "5636566f6de6f58200dce388f7b1ac9f517b30e1",
34
- actionButton: "3d788f28c785d1c60b937b253c39ce582dbe1ed3",
35
- } as const;
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.listItem.key, (node, traverse) => {
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 Object.values(PREFIX_KEYS)) {
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 Object.values(SUFFIX_KEYS)) {
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.mannerTempBadge.key,
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.mannerTemp.key, ({ children }) => {
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
- MENU_SHEET_ITEM_KEY,
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
- MENU_SHEET_GROUP_KEY,
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>(metadata.menuSheet.key, (node, traverse) => {
66
- const { componentProperties: props } = node;
67
-
68
- const groups = findAllInstances<MenuSheetGroupProperties>({
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
- const contentChildren = groups.map((group) => menuSheetGroupHandler.transform(group, traverse));
68
+ const groups = findAllInstances<MenuSheetGroupProperties>({
69
+ node,
70
+ key: menuSheetGroupHandler.key,
71
+ });
74
72
 
75
- const title = props["Show Header#17043:12"].value
76
- ? props["Title Text#14599:0"].value
77
- : undefined;
73
+ const contentChildren = groups.map((group) =>
74
+ menuSheetGroupHandler.transform(group, traverse),
75
+ );
78
76
 
79
- const description =
80
- props["Show Header#17043:12"].value && props["Show Header Description#32984:0"].value
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
- const { labelAlign } = match(props.Layout.value)
85
- .with("Text with Icon", () => ({ labelAlign: "left" }))
86
- .with("Text Only", () => ({ labelAlign: "center" }))
87
- .exhaustive();
88
-
89
- const content = createLocalSnippetElement(
90
- "MenuSheetContent",
91
- { title, description, labelAlign },
92
- contentChildren,
93
- {
94
- comment: title
95
- ? undefined
96
- : "title 제공하지 않는 경우 aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.",
97
- },
98
- );
99
-
100
- const trigger = createLocalSnippetElement(
101
- "MenuSheetTrigger",
102
- { asChild: true },
103
- createLocalSnippetElementTrigger("ActionButton", {}, "MenuSheet 열기"),
104
- );
105
-
106
- return createLocalSnippetElement("MenuSheet", undefined, [trigger, content]);
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
  };