@seed-design/figma 1.1.19 → 1.2.1

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 (117) hide show
  1. package/lib/codegen/index.cjs +12280 -190
  2. package/lib/codegen/index.d.ts +9 -1
  3. package/lib/codegen/index.d.ts.map +1 -1
  4. package/lib/codegen/index.js +12280 -190
  5. package/lib/codegen/targets/react/index.cjs +17286 -3116
  6. package/lib/codegen/targets/react/index.d.ts.map +1 -1
  7. package/lib/codegen/targets/react/index.js +17286 -3116
  8. package/lib/index.cjs +12286 -196
  9. package/lib/index.d.ts.map +1 -1
  10. package/lib/index.js +12286 -196
  11. package/package.json +4 -4
  12. package/src/codegen/component-properties.archive.ts +1019 -0
  13. package/src/codegen/component-properties.ts +191 -885
  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 +41 -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 +41 -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 -49
  64. package/src/codegen/targets/react/component/handlers/callout.ts +1 -1
  65. package/src/codegen/targets/react/component/handlers/checkbox.ts +1 -1
  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 +18 -16
  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 +3 -5
  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 +22 -21
  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 +59 -54
  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 +1 -1
  86. package/src/codegen/targets/react/component/handlers/radiomark.ts +2 -2
  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/skeleton.ts +1 -1
  91. package/src/codegen/targets/react/component/handlers/slider.ts +11 -8
  92. package/src/codegen/targets/react/component/handlers/snackbar.ts +1 -1
  93. package/src/codegen/targets/react/component/handlers/switch.ts +2 -2
  94. package/src/codegen/targets/react/component/handlers/switchmark.ts +2 -2
  95. package/src/codegen/targets/react/component/handlers/tabs.ts +39 -42
  96. package/src/codegen/targets/react/component/handlers/tag-group.ts +57 -59
  97. package/src/codegen/targets/react/component/handlers/text-field.ts +11 -22
  98. package/src/codegen/targets/react/component/handlers/toggle-button.ts +1 -1
  99. package/src/codegen/targets/react/component/index.ts +5 -115
  100. package/src/entities/data/__generated__/archive/component-sets/index.d.ts +2074 -0
  101. package/src/entities/data/__generated__/archive/component-sets/index.mjs +2074 -0
  102. package/src/entities/data/__generated__/archive/components/index.d.ts +116 -0
  103. package/src/entities/data/__generated__/archive/components/index.mjs +116 -0
  104. package/src/entities/data/__generated__/archive/styles/index.d.ts +3 -0
  105. package/src/entities/data/__generated__/archive/styles/index.mjs +429 -0
  106. package/src/entities/data/__generated__/archive/variable-collections/index.d.ts +3 -0
  107. package/src/entities/data/__generated__/archive/variable-collections/index.mjs +501 -0
  108. package/src/entities/data/__generated__/archive/variables/index.d.ts +3 -0
  109. package/src/entities/data/__generated__/archive/variables/index.mjs +7019 -0
  110. package/src/entities/data/__generated__/component-sets/index.d.ts +3442 -1306
  111. package/src/entities/data/__generated__/component-sets/index.mjs +3442 -1306
  112. package/src/entities/data/__generated__/components/index.d.ts +87 -85
  113. package/src/entities/data/__generated__/components/index.mjs +87 -85
  114. package/src/entities/data/__generated__/styles/index.mjs +9 -2
  115. package/src/entities/data/__generated__/variable-collections/index.mjs +150 -173
  116. package/src/entities/data/__generated__/variables/index.mjs +0 -74
  117. package/src/entities/index.ts +21 -7
@@ -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";
15
+ export * from "./field-button";
16
+ export * from "./floating-action-button";
17
+ export * from "./help-bubble";
18
+ export * from "./identity-placeholder";
19
+ export * from "./legacy-select-box";
20
+ export * from "./legacy-text-field";
21
+ export * from "./list-header";
22
+ export * from "./list-item";
23
+ export * from "./manner-temp";
24
+ export * from "./manner-temp-badge";
25
+ export * from "./menu-sheet";
26
+ export * from "./page-banner";
27
+ export * from "./progress-circle";
28
+ export * from "./radio-group";
29
+ export * from "./radiomark";
30
+ export * from "./reaction-button";
31
+ export * from "./result-section";
32
+ export * from "./segmented-control";
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
14
  export 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";
@@ -14,28 +15,28 @@ import { match } from "ts-pattern";
14
15
  const { createLocalSnippetElement } = createLocalSnippetHelper("list");
15
16
 
16
17
  const PREFIX_KEYS = {
17
- checkmark: "f24c9ef42ef08df79483fbae0fa7d9037e566748",
18
- radioMark: "5a77ad37a2291989dfe77c44ddee9aa39e447f90",
19
- icon: "0e4c05f097d3fa2dc0cbfdbf8db2662bcf8439ca",
20
- avatar: "ef0e8bd6c2f92e620acf204bb9a8079ef25a1e5c",
21
- image: "82239325aa1cb65af7c649fc71a8f2b48fb9b9f3",
22
- custom: "81f201fc876e38f016ab7427a6b3da000ee919a2",
23
- } as const;
18
+ checkmark: "563275de82ea1282cece0c35c0cd8d1625bc3a9d",
19
+ radiomark: "51f7c0917ebc559d81e63d0639cb632a792f40de",
20
+ icon: components.componentListItemPrefixIcon.key,
21
+ avatar: "27e33754113178be97e07195528c4ea020b3d3b7",
22
+ image: "d06216ff143a960844799c0b8f9212628f78c69d",
23
+ custom: "b8059f5e0f85e0745fc61ff70f04571177c2cdfc",
24
+ };
24
25
 
25
26
  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;
27
+ checkmark: "385ba8d607029e15e0d38ab415f783016488b185",
28
+ radiomark: "09871d64c5c30407da586fb34425c2e83e147c81",
29
+ chevron: components.componentListItemSuffixChevron.key,
30
+ switch: "0c26bd64e117e168b06eea69be903e4be762a728",
31
+ custom: "26b86c9f8965d38aa5a1181a5cdc89fa487988d1",
32
+ icon: components.componentListItemSuffixIcon.key,
33
+ chevronWithText: components.componentListItemSuffixChevronWithText.key,
34
+ iconButton: metadata.componentListItemSuffixIconButton.key,
35
+ actionButton: 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)
@@ -102,7 +103,7 @@ export const createListItemHandler = (ctx: ComponentHandlerDeps) =>
102
103
  const disabled = props.State.value === "Disabled";
103
104
 
104
105
  const tag = (() => {
105
- if (suffix?.tag === "SwitchMark") {
106
+ if (suffix?.tag === "Switchmark") {
106
107
  return "ListSwitchItem";
107
108
  }
108
109
 
@@ -110,11 +111,11 @@ export const createListItemHandler = (ctx: ComponentHandlerDeps) =>
110
111
  return "ListCheckItem";
111
112
  }
112
113
 
113
- if (prefix?.tag === "RadioMark" || suffix?.tag === "RadioMark") {
114
+ if (prefix?.tag === "Radiomark" || suffix?.tag === "Radiomark") {
114
115
  return "ListRadioItem";
115
116
  }
116
117
 
117
- // checkmark/radioMark 없는데 disabled인 경우 Button으로 추측
118
+ // checkmark/radiomark 없는데 disabled인 경우 Button으로 추측
118
119
  if (disabled) {
119
120
  return "ListButtonItem";
120
121
  }
@@ -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 = {
@@ -7,7 +7,7 @@ import { defineComponentHandler } from "@/codegen/core";
7
7
  import * as metadata from "@/entities/data/__generated__/component-sets";
8
8
  import { findAllInstances } from "@/utils/figma-node";
9
9
  import { camelCase } from "change-case";
10
- import { createLocalSnippetHelper, createSeedReactElement } from "../../element-factories";
10
+ import { createLocalSnippetHelper } from "../../element-factories";
11
11
  import type { ComponentHandlerDeps } from "../deps.interface";
12
12
  import { match } from "ts-pattern";
13
13
 
@@ -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
 
@@ -27,25 +26,24 @@ const createMenuSheetItemHandler = (ctx: ComponentHandlerDeps) =>
27
26
  ...(states.includes("Disabled") && {
28
27
  disabled: true,
29
28
  }),
29
+ ...(props["Show Prefix Icon#17043:5"].value && {
30
+ prefixIcon: ctx.iconHandler.transform(props["Prefix Icon#55948:0"]),
31
+ }),
32
+ label: props["Label#55905:8"].value,
33
+ ...(props["Show Item Description#51411:19"].value && {
34
+ description: props["Sub Text#51411:0"].value,
35
+ }),
30
36
  };
31
37
 
32
- return createLocalSnippetElement("MenuSheetItem", commonProps, [
33
- props["Show Prefix Icon#17043:5"].value
34
- ? createSeedReactElement("PrefixIcon", {
35
- svg: ctx.iconHandler.transform(props["Prefix Icon#55948:0"]),
36
- })
37
- : undefined,
38
- props["Label#55905:8"].value,
39
- ]);
38
+ return createLocalSnippetElement("MenuSheetItem", commonProps);
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,45 +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
- });
72
-
73
- const contentChildren = groups.map((group) => menuSheetGroupHandler.transform(group, traverse));
74
-
75
- const title = props["Show Header#17043:12"].value
76
- ? props["Title Text#14599:0"].value
77
- : undefined;
78
-
79
- // TODO: React 구현체에 description 추가 이후
80
- // const description = props["Description Text#21827:0"].value;
81
-
82
- const { labelAlign } = match(props.Layout.value)
83
- .with("Text with Icon", () => ({ labelAlign: "left" }))
84
- .with("Text Only", () => ({ labelAlign: "center" }))
85
- .exhaustive();
86
-
87
- const content = createLocalSnippetElement(
88
- "MenuSheetContent",
89
- { title, labelAlign },
90
- contentChildren,
91
- {
92
- comment: title
93
- ? undefined
94
- : "title을 제공하지 않는 경우 aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.",
95
- },
96
- );
97
-
98
- const trigger = createLocalSnippetElement(
99
- "MenuSheetTrigger",
100
- { asChild: true },
101
- createLocalSnippetElementTrigger("ActionButton", {}, "MenuSheet 열기"),
102
- );
103
-
104
- return createLocalSnippetElement("MenuSheet", undefined, [trigger, content]);
105
- });
63
+ return defineComponentHandler<MenuSheetProperties>(
64
+ metadata.componentMenuSheet.key,
65
+ (node, traverse) => {
66
+ const { componentProperties: props } = node;
67
+
68
+ const groups = findAllInstances<MenuSheetGroupProperties>({
69
+ node,
70
+ key: menuSheetGroupHandler.key,
71
+ });
72
+
73
+ const contentChildren = groups.map((group) =>
74
+ menuSheetGroupHandler.transform(group, traverse),
75
+ );
76
+
77
+ const title = props["Show Header#17043:12"].value
78
+ ? props["Title Text#14599:0"].value
79
+ : undefined;
80
+
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
+ );
106
111
  };
@@ -4,6 +4,7 @@ import type {
4
4
  } from "@/codegen/component-properties";
5
5
  import { createElement, defineComponentHandler } from "@/codegen/core";
6
6
  import * as metadata from "@/entities/data/__generated__/component-sets";
7
+ import * as components from "@/entities/data/__generated__/components";
7
8
  import type { NormalizedInstanceNode, NormalizedTextNode } from "@/normalizer";
8
9
  import { findAllInstances, findOne } from "@/utils/figma-node";
9
10
  import { camelCase } from "change-case";
@@ -13,89 +14,93 @@ import { match } from "ts-pattern";
13
14
 
14
15
  const { createLocalSnippetElement } = createLocalSnippetHelper("page-banner");
15
16
 
16
- const SUFFIX_BUTTON_KEY = "7dce4e1242761ccd8e5da42278fc2d870918039c";
17
-
18
17
  const createPageBannerButtonHandler = (_ctx: ComponentHandlerDeps) =>
19
- defineComponentHandler<PageBannerButtonProperties>(SUFFIX_BUTTON_KEY, (node) => {
20
- return createElement(
21
- "PageBannerButton",
22
- undefined,
23
- node.componentProperties["Label#39890:0"].value,
24
- );
25
- });
18
+ defineComponentHandler<PageBannerButtonProperties>(
19
+ components.componentPageBannerSuffixAction.key,
20
+ (node) => {
21
+ return createElement(
22
+ "PageBannerButton",
23
+ undefined,
24
+ node.componentProperties["Label#39890:0"].value,
25
+ );
26
+ },
27
+ );
26
28
 
27
29
  export const createPageBannerHandler = (ctx: ComponentHandlerDeps) => {
28
30
  const buttonHandler = createPageBannerButtonHandler(ctx);
29
31
 
30
- return defineComponentHandler<PageBannerProperties>(metadata.pageBanner.key, (node, traverse) => {
31
- const { componentProperties: props } = node;
32
-
33
- const { tag, suffix } = match(props.Interaction.value)
34
- .with("Actionable", () => ({ tag: "ActionablePageBanner", suffix: undefined }))
35
- .with("Dismissible", () => ({ tag: "DismissiblePageBanner", suffix: undefined }))
36
- .with("Display", () => ({ tag: "PageBanner", suffix: undefined }))
37
- .with("Display (With Action)", () => {
38
- const [buttonNode] = findAllInstances<PageBannerButtonProperties>({
39
- node,
40
- key: SUFFIX_BUTTON_KEY,
32
+ return defineComponentHandler<PageBannerProperties>(
33
+ metadata.componentPageBanner.key,
34
+ (node, traverse) => {
35
+ const { componentProperties: props } = node;
36
+
37
+ const { tag, suffix } = match(props.Interaction.value)
38
+ .with("Actionable", () => ({ tag: "ActionablePageBanner", suffix: undefined }))
39
+ .with("Dismissible", () => ({ tag: "DismissiblePageBanner", suffix: undefined }))
40
+ .with("Display", () => ({ tag: "PageBanner", suffix: undefined }))
41
+ .with("Display (With Action)", () => {
42
+ const [buttonNode] = findAllInstances<PageBannerButtonProperties>({
43
+ node,
44
+ key: components.componentPageBannerSuffixAction.key,
45
+ });
46
+ const suffix = buttonNode ? buttonHandler.transform(buttonNode, traverse) : undefined;
47
+
48
+ return { tag: "PageBanner", suffix };
49
+ })
50
+ .with("Actionable (Custom)", () => ({
51
+ tag: "PageBanner",
52
+ suffix: createElement("div", undefined, "Custom Content"),
53
+ }))
54
+ .exhaustive();
55
+
56
+ const textNode = findOne(
57
+ node,
58
+ (child) => child.type === "TEXT" && child.name === "Text",
59
+ ) as NormalizedTextNode | null;
60
+
61
+ if (!textNode) {
62
+ return createLocalSnippetElement(tag, undefined, undefined, {
63
+ comment: "내용을 제공해주세요.",
41
64
  });
42
- const suffix = buttonNode ? buttonHandler.transform(buttonNode, traverse) : undefined;
43
-
44
- return { tag: "PageBanner", suffix };
45
- })
46
- .with("Actionable (Custom)", () => ({
47
- tag: "PageBanner",
48
- suffix: createElement("div", undefined, "Custom Content"),
49
- }))
50
- .exhaustive();
51
-
52
- const textNode = findOne(
53
- node,
54
- (child) => child.type === "TEXT" && child.name === "Text",
55
- ) as NormalizedTextNode | null;
65
+ }
56
66
 
57
- if (!textNode) {
58
- return createLocalSnippetElement(tag, undefined, undefined, {
59
- comment: "내용을 제공해주세요.",
60
- });
61
- }
67
+ const slices = textNode.segments;
62
68
 
63
- const slices = textNode.segments;
69
+ let title: string | undefined;
70
+ let description: string | undefined;
64
71
 
65
- let title: string | undefined;
66
- let description: string | undefined;
72
+ switch (slices.length) {
73
+ case 1: {
74
+ description = slices[0]?.characters.trim();
67
75
 
68
- switch (slices.length) {
69
- case 1: {
70
- description = slices[0]?.characters.trim();
76
+ break;
77
+ }
78
+ case 2: {
79
+ title = slices[0]?.characters.trim();
80
+ description = slices[1]?.characters.trim();
71
81
 
72
- break;
82
+ break;
83
+ }
73
84
  }
74
- case 2: {
75
- title = slices[0]?.characters.trim();
76
- description = slices[1]?.characters.trim();
77
85
 
78
- break;
79
- }
80
- }
81
-
82
- const iconNode = findOne(
83
- node,
84
- (child) => child.type === "INSTANCE" && child.name === "icon",
85
- ) as NormalizedInstanceNode | null;
86
-
87
- const showPrefixIcon = props["Show Prefix Icon#11840:27"].value && iconNode;
88
- const prefixIcon = showPrefixIcon ? ctx.iconHandler.transform(iconNode) : undefined;
89
-
90
- const commonProps = {
91
- title,
92
- description,
93
- prefixIcon,
94
- tone: camelCase(props.Tone.value),
95
- variant: camelCase(props.Variant.value),
96
- ...(suffix && { suffix }),
97
- };
98
-
99
- return createLocalSnippetElement(tag, commonProps);
100
- });
86
+ const iconNode = findOne(
87
+ node,
88
+ (child) => child.type === "INSTANCE" && child.name === "icon",
89
+ ) as NormalizedInstanceNode | null;
90
+
91
+ const showPrefixIcon = props["Show Prefix Icon#11840:27"].value && iconNode;
92
+ const prefixIcon = showPrefixIcon ? ctx.iconHandler.transform(iconNode) : undefined;
93
+
94
+ const commonProps = {
95
+ title,
96
+ description,
97
+ prefixIcon,
98
+ tone: camelCase(props.Tone.value),
99
+ variant: camelCase(props.Variant.value),
100
+ ...(suffix && { suffix }),
101
+ };
102
+
103
+ return createLocalSnippetElement(tag, commonProps);
104
+ },
105
+ );
101
106
  };
@@ -10,7 +10,7 @@ const { createLocalSnippetElement } = createLocalSnippetHelper("progress-circle"
10
10
 
11
11
  export const createProgressCircleHandler = (_ctx: ComponentHandlerDeps) =>
12
12
  defineComponentHandler<ProgressCircleProperties>(
13
- metadata.progressCircle.key,
13
+ metadata.componentProgressCircle.key,
14
14
  ({ componentProperties: props }) => {
15
15
  const { value, minValue, maxValue } = match(props.Value.value)
16
16
  .with("Indeterminate", () => ({
@@ -10,7 +10,7 @@ import { match } from "ts-pattern";
10
10
  const { createLocalSnippetElement } = createLocalSnippetHelper("radio-group");
11
11
 
12
12
  export const createRadioGroupItemHandler = (_ctx: ComponentHandlerDeps) =>
13
- defineComponentHandler<RadioProperties>(metadata.radio.key, ({ componentProperties: props }) => {
13
+ defineComponentHandler<RadioProperties>(metadata.componentRadio.key, ({ componentProperties: props }) => {
14
14
  const tone = match(props.Tone.value)
15
15
  .with("Neutral", () => "neutral")
16
16
  .with("🚫[Deprecated]Brand", () => "brand")
@@ -10,7 +10,7 @@ const { createLocalSnippetElement } = createLocalSnippetHelper("radio-group");
10
10
 
11
11
  export const createRadiomarkHandler = (_ctx: ComponentHandlerDeps) =>
12
12
  defineComponentHandler<RadiomarkProperties>(
13
- metadata.radiomark.key,
13
+ metadata.componentRadiomark.key,
14
14
  ({ componentProperties: props }) => {
15
15
  const tone = match(props.Tone.value)
16
16
  .with("Neutral", () => "neutral")
@@ -22,6 +22,6 @@ export const createRadiomarkHandler = (_ctx: ComponentHandlerDeps) =>
22
22
  size: handleSizeProp(props.Size.value),
23
23
  };
24
24
 
25
- return createLocalSnippetElement("RadioMark", commonProps);
25
+ return createLocalSnippetElement("Radiomark", commonProps);
26
26
  },
27
27
  );
@@ -9,7 +9,7 @@ const { createLocalSnippetElement } = createLocalSnippetHelper("reaction-button"
9
9
 
10
10
  export const createReactionButtonHandler = (ctx: ComponentHandlerDeps) =>
11
11
  defineComponentHandler<ReactionButtonProperties>(
12
- metadata.reactionButton.key,
12
+ metadata.componentReactionButton.key,
13
13
  ({ componentProperties: props }) => {
14
14
  const commonProps = {
15
15
  size: handleSizeProp(props.Size.value),