@seed-design/figma 0.2.1 → 0.2.4

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 (47) hide show
  1. package/lib/codegen/index.cjs +294 -62
  2. package/lib/codegen/index.d.ts +460 -68
  3. package/lib/codegen/index.d.ts.map +1 -1
  4. package/lib/codegen/index.js +294 -62
  5. package/lib/codegen/targets/react/index.cjs +856 -242
  6. package/lib/codegen/targets/react/index.d.ts.map +1 -1
  7. package/lib/codegen/targets/react/index.js +856 -242
  8. package/lib/index.cjs +285 -60
  9. package/lib/index.js +285 -60
  10. package/package.json +2 -2
  11. package/src/codegen/component-properties.ts +82 -6
  12. package/src/codegen/core/jsx.ts +14 -2
  13. package/src/codegen/targets/react/component/handlers/checkbox.ts +7 -0
  14. package/src/codegen/targets/react/component/handlers/checkmark.ts +29 -0
  15. package/src/codegen/targets/react/component/handlers/chip.ts +5 -2
  16. package/src/codegen/targets/react/component/handlers/divider.ts +8 -2
  17. package/src/codegen/targets/react/component/handlers/help-bubble.ts +2 -0
  18. package/src/codegen/targets/react/component/handlers/list-item.ts +155 -0
  19. package/src/codegen/targets/react/component/handlers/radio-group.ts +31 -0
  20. package/src/codegen/targets/react/component/handlers/radio-mark.ts +27 -0
  21. package/src/codegen/targets/react/component/handlers/switch.ts +7 -0
  22. package/src/codegen/targets/react/component/handlers/tabs.ts +288 -5
  23. package/src/codegen/targets/react/component/index.ts +12 -2
  24. package/src/entities/data/__generated__/component-sets/checkbox.d.ts +9 -2
  25. package/src/entities/data/__generated__/component-sets/checkbox.mjs +9 -2
  26. package/src/entities/data/__generated__/component-sets/checkmark.d.ts +13 -6
  27. package/src/entities/data/__generated__/component-sets/checkmark.mjs +13 -6
  28. package/src/entities/data/__generated__/component-sets/divider.d.ts +2 -2
  29. package/src/entities/data/__generated__/component-sets/divider.mjs +2 -2
  30. package/src/entities/data/__generated__/component-sets/help-bubble.d.ts +3 -0
  31. package/src/entities/data/__generated__/component-sets/help-bubble.mjs +3 -0
  32. package/src/entities/data/__generated__/component-sets/index.d.ts +2 -0
  33. package/src/entities/data/__generated__/component-sets/index.mjs +2 -0
  34. package/src/entities/data/__generated__/component-sets/list-header.d.ts +24 -0
  35. package/src/entities/data/__generated__/component-sets/list-header.mjs +24 -0
  36. package/src/entities/data/__generated__/component-sets/list-item.d.ts +152 -0
  37. package/src/entities/data/__generated__/component-sets/list-item.mjs +152 -0
  38. package/src/entities/data/__generated__/component-sets/radio-mark.d.ts +7 -0
  39. package/src/entities/data/__generated__/component-sets/radio-mark.mjs +7 -0
  40. package/src/entities/data/__generated__/component-sets/radio.d.ts +14 -0
  41. package/src/entities/data/__generated__/component-sets/radio.mjs +14 -0
  42. package/src/entities/data/__generated__/component-sets/switch.d.ts +10 -3
  43. package/src/entities/data/__generated__/component-sets/switch.mjs +10 -3
  44. package/src/entities/data/__generated__/component-sets/tabs.d.ts +1 -1
  45. package/src/entities/data/__generated__/component-sets/tabs.mjs +1 -1
  46. package/src/entities/data/__generated__/component-sets/inline-banner.d.ts +0 -40
  47. package/src/entities/data/__generated__/component-sets/inline-banner.mjs +0 -40
@@ -107,6 +107,10 @@ export type CheckboxProperties = InferComponentDefinition<
107
107
  typeof metadata.checkbox.componentPropertyDefinitions
108
108
  >;
109
109
 
110
+ export type CheckmarkProperties = InferComponentDefinition<
111
+ typeof metadata.checkmark.componentPropertyDefinitions
112
+ >;
113
+
110
114
  export type ChipProperties = InferComponentDefinition<
111
115
  typeof metadata.chip.componentPropertyDefinitions
112
116
  >;
@@ -250,6 +254,30 @@ export type PageBannerButtonProperties = InferComponentDefinition<{
250
254
  };
251
255
  }>;
252
256
 
257
+ export type ListHeaderProperties = InferComponentDefinition<
258
+ typeof metadata.listHeader.componentPropertyDefinitions
259
+ >;
260
+
261
+ export type ListItemProperties = InferComponentDefinition<
262
+ typeof metadata.listItem.componentPropertyDefinitions
263
+ >;
264
+
265
+ export type ListItemPrefixIconProperties = InferComponentDefinition<{
266
+ "Icon#28452:111": {
267
+ type: "INSTANCE_SWAP";
268
+ defaultValue: "34885:102336";
269
+ preferredValues: [{ type: "COMPONENT_SET"; key: "1449adc3a216979ac3e6a4a99183a9e9790b220c" }];
270
+ };
271
+ }>;
272
+
273
+ export type ListItemSuffixIconProperties = InferComponentDefinition<{
274
+ "Icon#28347:9": {
275
+ type: "INSTANCE_SWAP";
276
+ defaultValue: "26621:23412";
277
+ preferredValues: [];
278
+ };
279
+ }>;
280
+
253
281
  export type MannerTempProperties = InferComponentDefinition<
254
282
  typeof metadata.mannerTemp.componentPropertyDefinitions
255
283
  >;
@@ -266,6 +294,14 @@ export type ProgressCircleProperties = InferComponentDefinition<
266
294
  typeof metadata.progressCircle.componentPropertyDefinitions
267
295
  >;
268
296
 
297
+ export type RadioProperties = InferComponentDefinition<
298
+ typeof metadata.radio.componentPropertyDefinitions
299
+ >;
300
+
301
+ export type RadioMarkProperties = InferComponentDefinition<
302
+ typeof metadata.radioMark.componentPropertyDefinitions
303
+ >;
304
+
269
305
  export type ReactionButtonProperties = InferComponentDefinition<
270
306
  typeof metadata.reactionButton.componentPropertyDefinitions
271
307
  >;
@@ -414,7 +450,24 @@ export type AppBarRightIconButtonProperties = InferComponentDefinition<{
414
450
  };
415
451
  }>;
416
452
 
417
- export type TabsUnderlineHugItemProperties = InferComponentDefinition<{
453
+ export type TabsProperties = InferComponentDefinition<
454
+ typeof metadata.tabs.componentPropertyDefinitions
455
+ >;
456
+
457
+ export type TabsLineWrapperProperties = InferComponentDefinition<{
458
+ Size: {
459
+ type: "VARIANT";
460
+ defaultValue: "Medium";
461
+ variantOptions: ["Medium", "Small"];
462
+ };
463
+ Layout: {
464
+ type: "VARIANT";
465
+ defaultValue: "Fill";
466
+ variantOptions: ["Hug", "Fill"];
467
+ };
468
+ }>;
469
+
470
+ export type TabsLineTriggerHugProperties = InferComponentDefinition<{
418
471
  "Label#4478:2": {
419
472
  type: "TEXT";
420
473
  defaultValue: "라벨";
@@ -426,7 +479,7 @@ export type TabsUnderlineHugItemProperties = InferComponentDefinition<{
426
479
  Size: {
427
480
  type: "VARIANT";
428
481
  defaultValue: "Small";
429
- variantOptions: ["Small", "Medium"];
482
+ variantOptions: ["Medium", "Small"];
430
483
  };
431
484
  State: {
432
485
  type: "VARIANT";
@@ -435,19 +488,19 @@ export type TabsUnderlineHugItemProperties = InferComponentDefinition<{
435
488
  };
436
489
  }>;
437
490
 
438
- export type TabsUnderlineFillItemProperties = InferComponentDefinition<{
491
+ export type TabsLineTriggerFillProperties = InferComponentDefinition<{
439
492
  "Label#4478:2": {
440
493
  type: "TEXT";
441
494
  defaultValue: "라벨";
442
495
  };
443
- "Has Notification#32892:0": {
496
+ "Has Notification#32904:13": {
444
497
  type: "BOOLEAN";
445
498
  defaultValue: false;
446
499
  };
447
500
  Size: {
448
501
  type: "VARIANT";
449
502
  defaultValue: "Small";
450
- variantOptions: ["Small", "Medium"];
503
+ variantOptions: ["Medium", "Small"];
451
504
  };
452
505
  State: {
453
506
  type: "VARIANT";
@@ -456,7 +509,7 @@ export type TabsUnderlineFillItemProperties = InferComponentDefinition<{
456
509
  };
457
510
  }>;
458
511
 
459
- export type TabsChipItemProperties = InferComponentDefinition<{
512
+ export type TabsChipWrapperProperties = InferComponentDefinition<{
460
513
  Size: {
461
514
  type: "VARIANT";
462
515
  defaultValue: "Large";
@@ -468,3 +521,26 @@ export type TabsChipItemProperties = InferComponentDefinition<{
468
521
  variantOptions: ["Solid", "Outline"];
469
522
  };
470
523
  }>;
524
+
525
+ export type ChipTabsTriggerProperties = InferComponentDefinition<{
526
+ "\bSize": {
527
+ type: "VARIANT";
528
+ defaultValue: "Medium";
529
+ variantOptions: ["Medium", "Large"];
530
+ };
531
+ Variant: {
532
+ type: "VARIANT";
533
+ defaultValue: "Solid";
534
+ variantOptions: ["Outline", "Solid"];
535
+ };
536
+ State: {
537
+ type: "VARIANT";
538
+ defaultValue: "Selected";
539
+ variantOptions: ["Enabled", "Selected", "Disabled"];
540
+ };
541
+ "Has Notification": {
542
+ type: "VARIANT";
543
+ defaultValue: "False";
544
+ variantOptions: ["False", "True"];
545
+ };
546
+ }>;
@@ -90,7 +90,7 @@ export function stringifyElement(element: ElementNode, options: { printSource?:
90
90
  .map(([key, value]) => {
91
91
  if (typeof value === "string") {
92
92
  if (value.includes("\n")) {
93
- return `${key}={\"${value.replace("\n", "\\n")}\"}`;
93
+ return `${key}={"${value.replaceAll("\n", "\\n")}"}`;
94
94
  }
95
95
 
96
96
  return `${key}="${value}"`;
@@ -107,7 +107,17 @@ export function stringifyElement(element: ElementNode, options: { printSource?:
107
107
  }
108
108
 
109
109
  if (isElement(value)) {
110
- return `${key}={${recursive(value, depth + 1)}}`;
110
+ const elementStr = recursive(value, depth + 1);
111
+
112
+ const commentMatch = elementStr.match(/\{\/\* (.+?)\*\/\}$/);
113
+
114
+ if (commentMatch) {
115
+ const elementWithoutComment = elementStr.replace(/\{\/\* .+? \*\/\}$/, "");
116
+
117
+ return `${key}={${elementWithoutComment}}/* ${commentMatch[1]} */`;
118
+ }
119
+
120
+ return `${key}={${elementStr}}`;
111
121
  }
112
122
 
113
123
  if (typeof value === "object") {
@@ -117,6 +127,8 @@ export function stringifyElement(element: ElementNode, options: { printSource?:
117
127
  if (typeof value === "undefined") {
118
128
  return undefined;
119
129
  }
130
+
131
+ return undefined;
120
132
  })
121
133
  .filter(exists);
122
134
 
@@ -5,6 +5,7 @@ import { camelCase } from "change-case";
5
5
  import { createLocalSnippetHelper } from "../../element-factories";
6
6
  import type { ComponentHandlerDeps } from "../deps.interface";
7
7
  import { handleSizeProp } from "../size";
8
+ import { match } from "ts-pattern";
8
9
 
9
10
  const { createLocalSnippetElement } = createLocalSnippetHelper("checkbox");
10
11
 
@@ -12,9 +13,15 @@ export const createCheckboxHandler = (_ctx: ComponentHandlerDeps) =>
12
13
  defineComponentHandler<CheckboxProperties>(
13
14
  metadata.checkbox.key,
14
15
  ({ componentProperties: props }) => {
16
+ const tone = match(props.Tone.value)
17
+ .with("Neutral", () => "neutral")
18
+ .with("🚫[Deprecated]Brand", () => "brand")
19
+ .exhaustive();
20
+
15
21
  const commonProps = {
16
22
  label: props["Label#49990:0"].value,
17
23
  weight: camelCase(props.Weight.value),
24
+ tone,
18
25
  variant: camelCase(props.Shape.value),
19
26
  size: handleSizeProp(props.Size.value),
20
27
  ...(props.Selected.value === "True" && {
@@ -0,0 +1,29 @@
1
+ import type { CheckmarkProperties } from "@/codegen/component-properties";
2
+ import { defineComponentHandler } from "@/codegen/core";
3
+ import * as metadata from "@/entities/data/__generated__/component-sets";
4
+ import { camelCase } from "change-case";
5
+ import { createLocalSnippetHelper } from "../../element-factories";
6
+ import type { ComponentHandlerDeps } from "../deps.interface";
7
+ import { handleSizeProp } from "../size";
8
+ import { match } from "ts-pattern";
9
+
10
+ const { createLocalSnippetElement } = createLocalSnippetHelper("checkbox");
11
+
12
+ export const createCheckmarkHandler = (_ctx: ComponentHandlerDeps) =>
13
+ defineComponentHandler<CheckmarkProperties>(
14
+ metadata.checkmark.key,
15
+ ({ componentProperties: props }) => {
16
+ const tone = match(props.Tone.value)
17
+ .with("Neutral", () => "neutral")
18
+ .with("🚫[Deprecated]Brand", () => "brand")
19
+ .exhaustive();
20
+
21
+ const commonProps = {
22
+ tone,
23
+ variant: camelCase(props.Shape.value),
24
+ size: handleSizeProp(props.Size.value),
25
+ };
26
+
27
+ return createLocalSnippetElement("Checkmark", commonProps);
28
+ },
29
+ );
@@ -72,16 +72,19 @@ export const createChipHandler = (ctx: ComponentHandlerDeps) => {
72
72
  variant: camelCase(props.Variant.value),
73
73
  size: handleSizeProp(props.Size.value),
74
74
  layout: props["Label#7185:0"].value ? "withText" : "iconOnly",
75
+ ...(props.Selected.value === "True" && {
76
+ defaultChecked: true,
77
+ }),
75
78
  ...(props.State.value === "Disabled" && {
76
79
  disabled: true,
77
80
  }),
78
81
  };
79
82
 
80
83
  return createLocalSnippetElement(
81
- "Chip.Button",
84
+ "Chip.Toggle",
82
85
  commonProps,
83
86
  [prefix, label, suffixIcon ? iconSuffixHandler.transform(suffixIcon, traverse) : undefined],
84
- { comment: "목적에 따라 Chip.Toggle, Chip.RadioItem 등으로 바꿔 사용하세요." },
87
+ { comment: "목적에 따라 Chip.Button, Chip.RadioItem 등으로 바꿔 사용하세요." },
85
88
  );
86
89
  });
87
90
  };
@@ -4,16 +4,22 @@ import * as metadata from "@/entities/data/__generated__/component-sets";
4
4
  import { match } from "ts-pattern";
5
5
  import { createSeedReactElement } from "../../element-factories";
6
6
  import type { ComponentHandlerDeps } from "../deps.interface";
7
+ import { camelCase } from "change-case";
7
8
 
8
9
  export const createDividerHandler = (_ctx: ComponentHandlerDeps) =>
9
10
  defineComponentHandler<DividerProperties>(
10
11
  metadata.divider.key,
11
12
  ({ componentProperties: props }) => {
12
13
  const { color } = match(props.Tone.value)
13
- .with("Neutral", () => ({ color: "stroke.neutral" }))
14
14
  .with("Neutral Muted", () => ({ color: "stroke.neutralMuted" }))
15
+ .with("Neutral Subtle", () => ({ color: "stroke.neutralSubtle" }))
15
16
  .exhaustive();
16
17
 
17
- return createSeedReactElement("Divider", { color });
18
+ const commonProps = {
19
+ color,
20
+ orientation: camelCase(props.Orientation.value),
21
+ };
22
+
23
+ return createSeedReactElement("Divider", commonProps, undefined);
18
24
  },
19
25
  );
@@ -59,6 +59,7 @@ export const createHelpBubbleHandler = (_ctx: ComponentHandlerDeps) =>
59
59
  description: props["Description#62535:98"].value,
60
60
  }),
61
61
  defaultOpen: true,
62
+ showCloseButton: props["Show Close Button#40538:0"].value,
62
63
  placement,
63
64
  };
64
65
 
@@ -66,6 +67,7 @@ export const createHelpBubbleHandler = (_ctx: ComponentHandlerDeps) =>
66
67
  "HelpBubbleTrigger",
67
68
  commonProps,
68
69
  createLocalSnippetElementTrigger("ActionButton", {}, "HelpBubble 열기"),
70
+ { comment: "필요에 따라 HelpBubbleAnchor로 변경하여 사용하세요." },
69
71
  );
70
72
  },
71
73
  );
@@ -0,0 +1,155 @@
1
+ import type {
2
+ ListItemSuffixIconProperties,
3
+ ListItemPrefixIconProperties,
4
+ ListItemProperties,
5
+ } from "@/codegen/component-properties";
6
+ import { createElement, defineComponentHandler } from "@/codegen/core";
7
+ import * as metadata from "@/entities/data/__generated__/component-sets";
8
+ import type { NormalizedTextNode } from "@/normalizer";
9
+ import { findAllInstances, findOne } from "@/utils/figma-node";
10
+ import { createLocalSnippetHelper, createSeedReactElement } from "../../element-factories";
11
+ import type { ComponentHandlerDeps } from "../deps.interface";
12
+ import { match } from "ts-pattern";
13
+
14
+ const { createLocalSnippetElement } = createLocalSnippetHelper("list");
15
+
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;
36
+
37
+ export const createListItemHandler = (ctx: ComponentHandlerDeps) =>
38
+ defineComponentHandler<ListItemProperties>(metadata.listItem.key, (node, traverse) => {
39
+ const { componentProperties: props } = node;
40
+
41
+ const { alignItems, title } = match(props.Variants.value)
42
+ .with("Single Line", () => ({ alignItems: undefined, title: props["Title#28452:21"].value }))
43
+ .with("Multi Line", () => ({
44
+ alignItems: "flex-start",
45
+ title: props["Title #28487:0"].value,
46
+ }))
47
+ .exhaustive();
48
+
49
+ const detailNode = findOne(
50
+ node,
51
+ (node) => node.type === "TEXT" && node.name === "Sub Text",
52
+ ) as NormalizedTextNode | null;
53
+
54
+ const prefixNode = (() => {
55
+ if (props["Has Prefix#28452:85"].value === false) return null;
56
+
57
+ for (const key of Object.values(PREFIX_KEYS)) {
58
+ const [found] = findAllInstances<ListItemPrefixIconProperties | {}>({ node, key });
59
+
60
+ if (found) return found;
61
+ }
62
+
63
+ return null;
64
+ })();
65
+
66
+ const prefix = (() => {
67
+ if (!prefixNode) return undefined;
68
+
69
+ if ("Icon#28452:111" in prefixNode.componentProperties) {
70
+ return createSeedReactElement("Icon", {
71
+ svg: ctx.iconHandler.transform(prefixNode.componentProperties["Icon#28452:111"]),
72
+ });
73
+ }
74
+
75
+ return traverse(prefixNode.children[0]);
76
+ })();
77
+
78
+ const suffixNode = (() => {
79
+ if (props["Has Suffix#28452:64"].value === false) return null;
80
+
81
+ for (const key of Object.values(SUFFIX_KEYS)) {
82
+ const [found] = findAllInstances<ListItemSuffixIconProperties | {}>({ node, key });
83
+
84
+ if (found) return found;
85
+ }
86
+
87
+ return null;
88
+ })();
89
+
90
+ const suffix = (() => {
91
+ if (!suffixNode) return undefined;
92
+
93
+ if ("Icon#28347:9" in suffixNode.componentProperties) {
94
+ return createSeedReactElement("Icon", {
95
+ svg: ctx.iconHandler.transform(suffixNode.componentProperties["Icon#28347:9"]),
96
+ });
97
+ }
98
+
99
+ return traverse(suffixNode.children[0]);
100
+ })();
101
+
102
+ const disabled = props.State.value === "Disabled";
103
+
104
+ const tag = (() => {
105
+ if (prefix?.tag === "Checkmark" || suffix?.tag === "Checkmark") {
106
+ return "ListCheckItem";
107
+ }
108
+
109
+ if (prefix?.tag === "RadioMark" || suffix?.tag === "RadioMark") {
110
+ return "ListRadioItem";
111
+ }
112
+
113
+ // checkmark/radioMark 없는데 disabled인 경우 Button으로 추측
114
+ if (disabled) {
115
+ return "ListButtonItem";
116
+ }
117
+
118
+ return "ListItem";
119
+ })();
120
+
121
+ const commonProps = {
122
+ ...(tag === "ListRadioItem" && {
123
+ value: title,
124
+ }),
125
+ alignItems,
126
+ title,
127
+ ...(props["Has Detail#28469:1"].value &&
128
+ detailNode && {
129
+ detail: detailNode.characters,
130
+ }),
131
+ ...(prefix && { prefix }),
132
+ ...(suffix && { suffix }),
133
+ ...(disabled &&
134
+ (tag === "ListButtonItem" || tag === "ListCheckItem" || tag === "ListRadioItem") && {
135
+ disabled: true,
136
+ }),
137
+ ...(props.State.value === "Highlighted" && {
138
+ highlighted: true,
139
+ }),
140
+ };
141
+
142
+ const comment = match(tag)
143
+ .with("ListItem", () => "목적에 따라 ListButtonItem이나 ListLinkItem으로 바꿔 사용하세요.")
144
+ .with("ListCheckItem", () => `<List as="fieldset">과 함께 사용하세요.`)
145
+ .with("ListRadioItem", () => "<RadioGroup.Root>와 함께 사용하세요.")
146
+ .otherwise(() => undefined);
147
+
148
+ const list = createLocalSnippetElement(tag, commonProps, undefined, { comment });
149
+
150
+ if (props["Divider#28441:0"].value) {
151
+ return createElement("", {}, [list, createLocalSnippetElement("ListDivider")]);
152
+ }
153
+
154
+ return list;
155
+ });
@@ -0,0 +1,31 @@
1
+ import type { RadioProperties } from "@/codegen/component-properties";
2
+ import { defineComponentHandler } from "@/codegen/core";
3
+ import * as metadata from "@/entities/data/__generated__/component-sets";
4
+ import { createLocalSnippetHelper } from "../../element-factories";
5
+ import type { ComponentHandlerDeps } from "../deps.interface";
6
+ import { handleSizeProp } from "../size";
7
+ import { camelCase } from "change-case";
8
+ import { match } from "ts-pattern";
9
+
10
+ const { createLocalSnippetElement } = createLocalSnippetHelper("radio-group");
11
+
12
+ export const createRadioGroupItemHandler = (_ctx: ComponentHandlerDeps) =>
13
+ defineComponentHandler<RadioProperties>(metadata.radio.key, ({ componentProperties: props }) => {
14
+ const tone = match(props.Tone.value)
15
+ .with("Neutral", () => "neutral")
16
+ .with("🚫[Deprecated]Brand", () => "brand")
17
+ .exhaustive();
18
+
19
+ const commonProps = {
20
+ ...(props.State.value === "Disabled" && {
21
+ disabled: true,
22
+ }),
23
+ label: props["Label#49990:171"].value,
24
+ value: props["Label#49990:171"].value,
25
+ size: handleSizeProp(props.Size.value),
26
+ tone,
27
+ weight: camelCase(props.Weight.value),
28
+ };
29
+
30
+ return createLocalSnippetElement("RadioGroupItem", commonProps);
31
+ });
@@ -0,0 +1,27 @@
1
+ import type { RadioMarkProperties } from "@/codegen/component-properties";
2
+ import { defineComponentHandler } from "@/codegen/core";
3
+ import * as metadata from "@/entities/data/__generated__/component-sets";
4
+ import { createLocalSnippetHelper } from "../../element-factories";
5
+ import type { ComponentHandlerDeps } from "../deps.interface";
6
+ import { handleSizeProp } from "../size";
7
+ import { match } from "ts-pattern";
8
+
9
+ const { createLocalSnippetElement } = createLocalSnippetHelper("radio-group");
10
+
11
+ export const createRadioMarkHandler = (_ctx: ComponentHandlerDeps) =>
12
+ defineComponentHandler<RadioMarkProperties>(
13
+ metadata.radioMark.key,
14
+ ({ componentProperties: props }) => {
15
+ const tone = match(props.Tone.value)
16
+ .with("Neutral", () => "neutral")
17
+ .with("🚫[Deprecated]Brand", () => "brand")
18
+ .exhaustive();
19
+
20
+ const commonProps = {
21
+ tone,
22
+ size: handleSizeProp(props.Size.value),
23
+ };
24
+
25
+ return createLocalSnippetElement("RadioMark", commonProps);
26
+ },
27
+ );
@@ -3,6 +3,7 @@ import { defineComponentHandler } from "@/codegen/core";
3
3
  import * as metadata from "@/entities/data/__generated__/component-sets";
4
4
  import { createLocalSnippetHelper } from "../../element-factories";
5
5
  import type { ComponentHandlerDeps } from "../deps.interface";
6
+ import { match } from "ts-pattern";
6
7
 
7
8
  const { createLocalSnippetElement } = createLocalSnippetHelper("switch");
8
9
 
@@ -10,7 +11,13 @@ export const createSwitchHandler = (_ctx: ComponentHandlerDeps) =>
10
11
  defineComponentHandler<SwitchProperties>(
11
12
  metadata.switch.key,
12
13
  ({ componentProperties: props }) => {
14
+ const tone = match(props.Tone.value)
15
+ .with("Neutral", () => "neutral")
16
+ .with("🚫[Deprecated] Brand", () => "brand")
17
+ .exhaustive();
18
+
13
19
  const commonProps = {
20
+ tone,
14
21
  size: props.Size.value,
15
22
  label: props["Label#36578:0"].value,
16
23
  ...(props.Selected.value === "True" && {