@seed-design/figma 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/codegen/index.cjs +8019 -0
- package/lib/codegen/index.d.ts +1827 -0
- package/lib/codegen/index.js +7989 -0
- package/lib/codegen/targets/react/index.cjs +12205 -0
- package/lib/codegen/targets/react/index.d.ts +270 -0
- package/lib/codegen/targets/react/index.js +12187 -0
- package/lib/index.cjs +86 -2741
- package/lib/index.d.ts +18 -1933
- package/lib/index.js +68 -2715
- package/package.json +18 -9
- package/src/codegen/{targets/react/component/properties.type.ts → component-properties.ts} +43 -43
- package/src/codegen/core/codegen.ts +24 -9
- package/src/codegen/core/{component.ts → component-handler.ts} +3 -3
- package/src/codegen/core/component-type-helper.ts +35 -0
- package/src/codegen/core/context.ts +20 -0
- package/src/codegen/core/index.ts +16 -14
- package/src/codegen/core/infer-layout.test.ts +17 -16
- package/src/codegen/core/infer-layout.ts +1 -1
- package/src/codegen/core/{props.ts → props-converter.ts} +10 -13
- package/src/codegen/core/{value.ts → value-resolver.ts} +90 -52
- package/src/codegen/default-services.ts +44 -0
- package/src/codegen/index.ts +1 -44
- package/src/codegen/targets/figma/frame.ts +8 -8
- package/src/codegen/targets/figma/index.ts +1 -1
- package/src/codegen/targets/figma/pipeline.ts +71 -0
- package/src/codegen/targets/figma/props.ts +59 -70
- package/src/codegen/targets/figma/shape.ts +18 -18
- package/src/codegen/targets/figma/text.ts +6 -6
- package/src/codegen/targets/figma/value-resolver.ts +22 -0
- package/src/codegen/targets/react/component/deps.interface.ts +5 -4
- package/src/codegen/targets/react/component/{transformers → handlers}/action-button.ts +8 -14
- package/src/codegen/targets/react/component/{transformers → handlers}/action-chip.ts +10 -20
- package/src/codegen/targets/react/component/{transformers → handlers}/action-sheet.ts +13 -10
- package/src/codegen/targets/react/component/{transformers → handlers}/app-bar.ts +28 -36
- package/src/codegen/targets/react/component/handlers/avatar-stack.ts +29 -0
- package/src/codegen/targets/react/component/{transformers → handlers}/avatar.ts +12 -9
- package/src/codegen/targets/react/component/handlers/badge.ts +18 -0
- package/src/codegen/targets/react/component/{transformers → handlers}/callout.ts +6 -8
- package/src/codegen/targets/react/component/{transformers → handlers}/checkbox.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/chip-tabs.ts +10 -10
- package/src/codegen/targets/react/component/{transformers → handlers}/control-chip.ts +10 -20
- package/src/codegen/targets/react/component/{transformers → handlers}/error-state.ts +9 -9
- package/src/codegen/targets/react/component/{transformers → handlers}/extended-action-sheet.ts +16 -18
- package/src/codegen/targets/react/component/{transformers → handlers}/extended-fab.ts +6 -6
- package/src/codegen/targets/react/component/handlers/fab.ts +18 -0
- package/src/codegen/targets/react/component/{transformers → handlers}/help-bubble.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/identity-placeholder.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/inline-banner.ts +7 -10
- package/src/codegen/targets/react/component/{transformers → handlers}/manner-temp-badge.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/multiline-text-field.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/progress-circle.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/reaction-button.ts +6 -6
- package/src/codegen/targets/react/component/{transformers → handlers}/segmented-control.ts +10 -10
- package/src/codegen/targets/react/component/{transformers → handlers}/select-box.ts +10 -10
- package/src/codegen/targets/react/component/handlers/skeleton.ts +25 -0
- package/src/codegen/targets/react/component/{transformers → handlers}/snackbar.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/switch.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/tabs.ts +15 -15
- package/src/codegen/targets/react/component/{transformers → handlers}/text-button.ts +7 -13
- package/src/codegen/targets/react/component/{transformers → handlers}/text-field.ts +9 -9
- package/src/codegen/targets/react/component/{transformers → handlers}/toggle-button.ts +7 -11
- package/src/codegen/targets/react/component/index.ts +79 -75
- package/src/codegen/targets/react/frame.ts +8 -8
- package/src/codegen/targets/react/icon.ts +50 -0
- package/src/codegen/targets/react/index.ts +1 -1
- package/src/codegen/targets/react/instance.ts +19 -50
- package/src/codegen/targets/react/pipeline.ts +108 -0
- package/src/codegen/targets/react/props.ts +95 -73
- package/src/codegen/targets/react/shape.ts +5 -5
- package/src/codegen/targets/react/text.ts +6 -6
- package/src/codegen/targets/react/value-resolver.ts +35 -0
- package/src/entities/icon.repository.ts +2 -2
- package/src/entities/icon.service.ts +9 -20
- package/src/entities/style.service.ts +5 -17
- package/src/entities/variable.service.ts +36 -68
- package/src/normalizer/from-plugin.ts +3 -0
- package/src/normalizer/from-rest.ts +6 -0
- package/src/normalizer/types.ts +4 -1
- package/src/utils/figma-variable.ts +39 -3
- package/src/codegen/core/component.types.ts +0 -29
- package/src/codegen/targets/figma/context.ts +0 -139
- package/src/codegen/targets/react/component/transformers/avatar-stack.ts +0 -29
- package/src/codegen/targets/react/component/transformers/badge.ts +0 -21
- package/src/codegen/targets/react/component/transformers/fab.ts +0 -18
- package/src/codegen/targets/react/component/transformers/skeleton.ts +0 -51
- package/src/codegen/targets/react/context.ts +0 -176
- /package/src/codegen/core/{element.ts → element-transformer.ts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { MannerTempBadgeProperties } from "
|
|
3
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
4
|
+
import type { MannerTempBadgeProperties } from "@/codegen/component-properties";
|
|
5
5
|
|
|
6
|
-
export const
|
|
7
|
-
|
|
6
|
+
export const createMannerTempBadgeHandler = (_ctx: ComponentHandlerDeps) =>
|
|
7
|
+
defineComponentHandler<MannerTempBadgeProperties>(
|
|
8
8
|
metadata.mannerTempBadge.key,
|
|
9
9
|
({ children }) => {
|
|
10
10
|
const textNode = children.find((child) => child.type === "TEXT");
|
package/src/codegen/targets/react/component/{transformers → handlers}/multiline-text-field.ts
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { MultilineTextFieldProperties } from "
|
|
3
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
4
|
+
import type { MultilineTextFieldProperties } from "@/codegen/component-properties";
|
|
5
5
|
import { handleSizeProp } from "../size";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createMultilineTextFieldHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<MultilineTextFieldProperties>(
|
|
9
9
|
metadata.multilineTextField.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
4
|
import { match } from "ts-pattern";
|
|
5
|
-
import type {
|
|
6
|
-
import type { ProgressCircleProperties } from "
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
import type { ProgressCircleProperties } from "@/codegen/component-properties";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createProgressCircleHandler = (_ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<ProgressCircleProperties>(
|
|
10
10
|
metadata.progressCircle.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const { value, minValue, maxValue } = match(props.Value.value)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactionButtonProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { ReactionButtonProperties } from "../properties.type";
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
5
|
import { handleSizeProp } from "../size";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createReactionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<ReactionButtonProperties>(
|
|
9
9
|
metadata.reactionButton.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const states = props.State.value.split("-");
|
|
@@ -25,7 +25,7 @@ export const createReactionButtonTransformer = (ctx: SeedComponentTransformerDep
|
|
|
25
25
|
|
|
26
26
|
return createElement("ReactionButton", commonProps, [
|
|
27
27
|
createElement("PrefixIcon", {
|
|
28
|
-
svg:
|
|
28
|
+
svg: ctx.iconHandler.transform(props["Icon#12379:0"]),
|
|
29
29
|
}),
|
|
30
30
|
props["Label#6397:0"].value,
|
|
31
31
|
props["Show Count#6397:33"].value
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
5
|
import type {
|
|
6
6
|
SegmentedControlItemProperties,
|
|
7
7
|
SegmentedControlProperties,
|
|
8
|
-
} from "
|
|
8
|
+
} from "@/codegen/component-properties";
|
|
9
9
|
|
|
10
10
|
const SEGMENTED_CONTROL_ITEM_KEY = "9a7ba0d4c041ddbce84ee48881788434fd6bccc8";
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const createSegmentedControlItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
12
|
+
defineComponentHandler<SegmentedControlItemProperties>(
|
|
13
13
|
SEGMENTED_CONTROL_ITEM_KEY,
|
|
14
14
|
({ componentProperties: props }) => {
|
|
15
15
|
const states = props.State.value.split("-");
|
|
@@ -24,22 +24,22 @@ const createSegmentedControlItemTransformer = (_ctx: SeedComponentTransformerDep
|
|
|
24
24
|
},
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
export const
|
|
28
|
-
const
|
|
27
|
+
export const createSegmentedControlHandler = (ctx: ComponentHandlerDeps) => {
|
|
28
|
+
const segmentedControlItemHandler = createSegmentedControlItemHandler(ctx);
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return defineComponentHandler<SegmentedControlProperties>(
|
|
31
31
|
metadata.segmentedControl.key,
|
|
32
32
|
(node) => {
|
|
33
33
|
const segments = findAllInstances<SegmentedControlItemProperties>({
|
|
34
34
|
node,
|
|
35
|
-
key:
|
|
35
|
+
key: segmentedControlItemHandler.key,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
const selectedSegment = segments.find((segment) =>
|
|
39
39
|
segment.componentProperties.State.value.split("-").includes("Selected"),
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const segmentedControlChildren = segments.map(
|
|
42
|
+
const segmentedControlChildren = segments.map(segmentedControlItemHandler.transform);
|
|
43
43
|
|
|
44
44
|
const commonProps = {
|
|
45
45
|
...(selectedSegment && {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
|
-
import type {
|
|
5
|
-
import type { SelectBoxGroupProperties, SelectBoxProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { SelectBoxGroupProperties, SelectBoxProperties } from "@/codegen/component-properties";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createSelectBoxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<SelectBoxProperties>(
|
|
9
9
|
metadata.selectBox.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const tag = (() => {
|
|
@@ -37,10 +37,10 @@ export const createSelectBoxTransformer = (_ctx: SeedComponentTransformerDeps) =
|
|
|
37
37
|
},
|
|
38
38
|
);
|
|
39
39
|
|
|
40
|
-
export const
|
|
41
|
-
const
|
|
40
|
+
export const createSelectBoxGroupHandler = (ctx: ComponentHandlerDeps) => {
|
|
41
|
+
const selectBoxHandler = createSelectBoxHandler(ctx);
|
|
42
42
|
|
|
43
|
-
return
|
|
43
|
+
return defineComponentHandler<SelectBoxGroupProperties>(
|
|
44
44
|
metadata.templateSelectBoxGroup.key,
|
|
45
45
|
(node) => {
|
|
46
46
|
const props = node.componentProperties;
|
|
@@ -56,7 +56,7 @@ export const createSelectBoxGroupTransformer = (ctx: SeedComponentTransformerDep
|
|
|
56
56
|
|
|
57
57
|
const selectBoxes = findAllInstances<SelectBoxProperties>({
|
|
58
58
|
node,
|
|
59
|
-
key:
|
|
59
|
+
key: selectBoxHandler.key,
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
const selectedSelectBox = selectBoxes.find((selectBox) =>
|
|
@@ -66,7 +66,7 @@ export const createSelectBoxGroupTransformer = (ctx: SeedComponentTransformerDep
|
|
|
66
66
|
const stack = createElement(
|
|
67
67
|
"Stack",
|
|
68
68
|
{ gap: "spacingY.componentDefault" },
|
|
69
|
-
selectBoxes.map(
|
|
69
|
+
selectBoxes.map(selectBoxHandler.transform),
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
const commonProps = {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
+
import { camelCase } from "change-case";
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { SkeletonProperties } from "@/codegen/component-properties";
|
|
6
|
+
import { match } from "ts-pattern";
|
|
7
|
+
|
|
8
|
+
export const createSkeletonHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<SkeletonProperties>(metadata.skeleton.key, (node) => {
|
|
10
|
+
const { componentProperties: props, layoutSizingHorizontal, layoutSizingVertical } = node;
|
|
11
|
+
|
|
12
|
+
const commonProps = {
|
|
13
|
+
radius: camelCase(props.Radius.value),
|
|
14
|
+
width: match(layoutSizingHorizontal)
|
|
15
|
+
.with("FIXED", () => ctx.valueResolver.getFormattedValue.width(node))
|
|
16
|
+
.with("FILL", () => "full")
|
|
17
|
+
.otherwise(() => "full"),
|
|
18
|
+
height: match(layoutSizingVertical)
|
|
19
|
+
.with("FIXED", () => ctx.valueResolver.getFormattedValue.height(node))
|
|
20
|
+
.with("FILL", () => "full")
|
|
21
|
+
.otherwise(() => "full"),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return createElement("Skeleton", commonProps);
|
|
25
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
|
-
import type {
|
|
5
|
-
import type { SnackbarProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { SnackbarProperties } from "@/codegen/component-properties";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createSnackbarHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<SnackbarProperties>(
|
|
9
9
|
metadata.snackbar.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const commonProps = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { SwitchProperties } from "
|
|
3
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
4
|
+
import type { SwitchProperties } from "@/codegen/component-properties";
|
|
5
5
|
import { handleSizeProp } from "../size";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createSwitchHandler = (_ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<SwitchProperties>(
|
|
9
9
|
metadata.switch.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const states = props.State.value.split("-");
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import type { NormalizedInstanceNode } from "@/normalizer";
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
6
|
import type {
|
|
7
7
|
TabsFillItemProperties,
|
|
8
8
|
TabsHugItemProperties,
|
|
9
9
|
TabsProperties,
|
|
10
|
-
} from "
|
|
10
|
+
} from "@/codegen/component-properties";
|
|
11
11
|
import { handleSizeProp } from "../size";
|
|
12
12
|
|
|
13
13
|
const TABS_HUG_ITEM_KEY = "c242492543b327ceb84fa9933841512fc62a898c";
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const createTabsHugItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
15
|
+
defineComponentHandler<TabsHugItemProperties>(
|
|
16
16
|
TABS_HUG_ITEM_KEY,
|
|
17
17
|
({ componentProperties: props }) => {
|
|
18
18
|
const states = props.State.value.split("-");
|
|
@@ -32,8 +32,8 @@ const createTabsHugItemTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const TABS_FILL_ITEM_KEY = "7275293344efb40ee9a3f5248ba2659b94a0b305";
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const createTabsFillItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
36
|
+
defineComponentHandler<TabsFillItemProperties>(
|
|
37
37
|
TABS_FILL_ITEM_KEY,
|
|
38
38
|
({ componentProperties: props }) => {
|
|
39
39
|
const states = props.State.value.split("-");
|
|
@@ -52,11 +52,11 @@ const createTabsFillItemTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
52
52
|
},
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
export const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
55
|
+
export const createTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
56
|
+
const tabsHugItemHandler = createTabsHugItemHandler(ctx);
|
|
57
|
+
const tabsFillItemHandler = createTabsFillItemHandler(ctx);
|
|
58
58
|
|
|
59
|
-
return
|
|
59
|
+
return defineComponentHandler<TabsProperties>(metadata.tablist.key, (node) => {
|
|
60
60
|
const { componentProperties: props, children } = node;
|
|
61
61
|
|
|
62
62
|
const mappedItems = children.map(
|
|
@@ -72,13 +72,13 @@ export const createTabsTransformer = (ctx: SeedComponentTransformerDeps) => {
|
|
|
72
72
|
|
|
73
73
|
const componentKey = child.componentSetKey ? child.componentSetKey : child.componentKey;
|
|
74
74
|
|
|
75
|
-
if (componentKey ===
|
|
75
|
+
if (componentKey === tabsHugItemHandler.key)
|
|
76
76
|
return {
|
|
77
77
|
triggerLayout: "hug" as const,
|
|
78
78
|
node: child as NormalizedInstanceNode & { componentProperties: TabsHugItemProperties },
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
if (componentKey ===
|
|
81
|
+
if (componentKey === tabsFillItemHandler.key)
|
|
82
82
|
return {
|
|
83
83
|
triggerLayout: "fill" as const,
|
|
84
84
|
node: child as NormalizedInstanceNode & { componentProperties: TabsFillItemProperties },
|
|
@@ -102,9 +102,9 @@ export const createTabsTransformer = (ctx: SeedComponentTransformerDeps) => {
|
|
|
102
102
|
tabsItems.map(({ triggerLayout, node }) => {
|
|
103
103
|
switch (triggerLayout) {
|
|
104
104
|
case "hug":
|
|
105
|
-
return
|
|
105
|
+
return tabsHugItemHandler.transform(node);
|
|
106
106
|
case "fill":
|
|
107
|
-
return
|
|
107
|
+
return tabsFillItemHandler.transform(node);
|
|
108
108
|
}
|
|
109
109
|
}),
|
|
110
110
|
);
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TextButtonProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
4
|
import type { NormalizedInstanceNode } from "@/normalizer";
|
|
4
5
|
import { findOne } from "@/utils/figma-node";
|
|
5
6
|
import { camelCase } from "change-case";
|
|
6
7
|
import { match } from "ts-pattern";
|
|
7
|
-
import type {
|
|
8
|
-
import type { TextButtonProperties } from "../properties.type";
|
|
8
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
9
9
|
import { handleSizeProp } from "../size";
|
|
10
10
|
|
|
11
|
-
export const
|
|
12
|
-
|
|
11
|
+
export const createTextButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
12
|
+
defineComponentHandler<TextButtonProperties>(metadata.textButton.key, (node) => {
|
|
13
13
|
const { componentProperties: props } = node;
|
|
14
14
|
|
|
15
15
|
const states = props.State.value.split("-");
|
|
16
16
|
|
|
17
17
|
const { prefixIcon, suffixIcon, children } = match(props.Layout.value)
|
|
18
18
|
.with("Icon First", () => ({
|
|
19
|
-
prefixIcon:
|
|
20
|
-
ctx.iconService.createIconTagName(props["Prefix Icon#7561:0"].componentKey),
|
|
21
|
-
),
|
|
19
|
+
prefixIcon: ctx.iconHandler.transform(props["Prefix Icon#7561:0"]),
|
|
22
20
|
suffixIcon: undefined,
|
|
23
21
|
children: props["Label#6148:0"].value,
|
|
24
22
|
}))
|
|
@@ -28,13 +26,9 @@ export const createTextButtonTransformer = (ctx: SeedComponentTransformerDeps) =
|
|
|
28
26
|
(node) => node.type === "INSTANCE" && node.name === "Suffix Icon",
|
|
29
27
|
) as NormalizedInstanceNode | null;
|
|
30
28
|
|
|
31
|
-
const suffixIconComponentKey = suffixIconNode?.componentKey;
|
|
32
|
-
|
|
33
29
|
return {
|
|
34
30
|
prefixIcon: undefined,
|
|
35
|
-
suffixIcon:
|
|
36
|
-
? createElement(ctx.iconService.createIconTagName(suffixIconComponentKey))
|
|
37
|
-
: undefined,
|
|
31
|
+
suffixIcon: suffixIconNode ? ctx.iconHandler.transform(suffixIconNode) : undefined,
|
|
38
32
|
children: props["Label#6148:0"].value,
|
|
39
33
|
};
|
|
40
34
|
})
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type {
|
|
4
|
-
import type { TextFieldProperties } from "
|
|
3
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
4
|
+
import type { TextFieldProperties } from "@/codegen/component-properties";
|
|
5
5
|
import { handleSizeProp } from "../size";
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
7
|
+
export const createTextFieldHandler = (ctx: ComponentHandlerDeps) =>
|
|
8
|
+
defineComponentHandler<TextFieldProperties>(
|
|
9
9
|
metadata.textField.key,
|
|
10
10
|
({ componentProperties: props }) => {
|
|
11
11
|
const {
|
|
@@ -18,14 +18,14 @@ export const createTextFieldTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
18
18
|
"Indicator#15327:249": { value: indicator },
|
|
19
19
|
"Show Prefix#958:125": { value: showPrefix },
|
|
20
20
|
"Show Prefix Icon#1267:50": { value: showPrefixIcon },
|
|
21
|
-
"Prefix Icon#1267:25":
|
|
21
|
+
"Prefix Icon#1267:25": prefixIcon,
|
|
22
22
|
"Show Prefix Text#1267:0": { value: showPrefixText },
|
|
23
23
|
"Prefix Text#15327:101": { value: prefix },
|
|
24
24
|
"Placeholder#958:0": { value: placeholder },
|
|
25
25
|
"Filled Text#1304:0": { value: defaultValue },
|
|
26
26
|
"Show Suffix#958:100": { value: showSuffix },
|
|
27
27
|
"Show Suffix Icon#1267:75": { value: showSuffixIcon },
|
|
28
|
-
"Suffix Icon #1267:100":
|
|
28
|
+
"Suffix Icon #1267:100": suffixIcon,
|
|
29
29
|
"Show Suffix Text#1267:125": { value: showSuffixText },
|
|
30
30
|
"Suffix Text#15327:138": { value: suffix },
|
|
31
31
|
"Show Footer#958:25": { value: showFooter },
|
|
@@ -51,7 +51,7 @@ export const createTextFieldTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
51
51
|
// input affixes
|
|
52
52
|
...(showPrefix &&
|
|
53
53
|
showPrefixIcon && {
|
|
54
|
-
prefixIcon:
|
|
54
|
+
prefixIcon: ctx.iconHandler.transform(prefixIcon),
|
|
55
55
|
}),
|
|
56
56
|
...(showPrefix &&
|
|
57
57
|
showPrefixText && {
|
|
@@ -59,7 +59,7 @@ export const createTextFieldTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
59
59
|
}),
|
|
60
60
|
...(showSuffix &&
|
|
61
61
|
showSuffixIcon && {
|
|
62
|
-
suffixIcon:
|
|
62
|
+
suffixIcon: ctx.iconHandler.transform(suffixIcon),
|
|
63
63
|
}),
|
|
64
64
|
...(showSuffix &&
|
|
65
65
|
showSuffixText && {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
|
-
import type {
|
|
5
|
-
import type { ToggleButtonProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { ToggleButtonProperties } from "@/codegen/component-properties";
|
|
6
6
|
import { handleSizeProp } from "../size";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createToggleButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<ToggleButtonProperties>(
|
|
10
10
|
metadata.toggleButton.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const states = props.State.value.split("-");
|
|
@@ -28,17 +28,13 @@ export const createToggleButtonTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
28
28
|
return createElement("ToggleButton", commonProps, [
|
|
29
29
|
props["Show Prefix Icon#6122:392"].value
|
|
30
30
|
? createElement("PrefixIcon", {
|
|
31
|
-
svg:
|
|
32
|
-
ctx.iconService.createIconTagName(props["Prefix Icon#6122:98"].componentKey),
|
|
33
|
-
),
|
|
31
|
+
svg: ctx.iconHandler.transform(props["Prefix Icon#6122:98"]),
|
|
34
32
|
})
|
|
35
33
|
: undefined,
|
|
36
34
|
props["Label#6122:49"].value,
|
|
37
35
|
props["Show Suffix Icon#6122:147"].value
|
|
38
36
|
? createElement("SuffixIcon", {
|
|
39
|
-
svg:
|
|
40
|
-
ctx.iconService.createIconTagName(props["Suffix Icon#6122:343"].componentKey),
|
|
41
|
-
),
|
|
37
|
+
svg: ctx.iconHandler.transform(props["Suffix Icon#6122:343"]),
|
|
42
38
|
})
|
|
43
39
|
: undefined,
|
|
44
40
|
]);
|
|
@@ -1,77 +1,81 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from "./
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import { createTextFieldTransformer } from "./transformers/text-field";
|
|
36
|
-
import { createToggleButtonTransformer } from "./transformers/toggle-button";
|
|
1
|
+
import type { ComponentHandler } from "@/codegen/core";
|
|
2
|
+
import type { NormalizedInstanceNode } from "@/normalizer";
|
|
3
|
+
import type { ComponentHandlerDeps } from "./deps.interface";
|
|
4
|
+
import { createActionButtonHandler } from "./handlers/action-button";
|
|
5
|
+
import { createActionChipHandler } from "./handlers/action-chip";
|
|
6
|
+
import { createActionSheetHandler } from "./handlers/action-sheet";
|
|
7
|
+
import { createAppBarHandler } from "./handlers/app-bar";
|
|
8
|
+
import { createAvatarHandler } from "./handlers/avatar";
|
|
9
|
+
import { createAvatarStackHandler } from "./handlers/avatar-stack";
|
|
10
|
+
import { createBadgeHandler } from "./handlers/badge";
|
|
11
|
+
import { createCalloutHandler } from "./handlers/callout";
|
|
12
|
+
import { createCheckboxHandler } from "./handlers/checkbox";
|
|
13
|
+
import { createChipTabsHandler } from "./handlers/chip-tabs";
|
|
14
|
+
import { createControlChipHandler } from "./handlers/control-chip";
|
|
15
|
+
import { createErrorStateHandler } from "./handlers/error-state";
|
|
16
|
+
import { createExtendedActionSheetHandler } from "./handlers/extended-action-sheet";
|
|
17
|
+
import { createExtendedFabHandler } from "./handlers/extended-fab";
|
|
18
|
+
import { createFabHandler } from "./handlers/fab";
|
|
19
|
+
import { createHelpBubbleHandler } from "./handlers/help-bubble";
|
|
20
|
+
import { createIdentityPlaceholderHandler } from "./handlers/identity-placeholder";
|
|
21
|
+
import { createInlineBannerHandler } from "./handlers/inline-banner";
|
|
22
|
+
import { createMannerTempBadgeHandler } from "./handlers/manner-temp-badge";
|
|
23
|
+
import { createMultilineTextFieldHandler } from "./handlers/multiline-text-field";
|
|
24
|
+
import { createProgressCircleHandler } from "./handlers/progress-circle";
|
|
25
|
+
import { createReactionButtonHandler } from "./handlers/reaction-button";
|
|
26
|
+
import { createSegmentedControlHandler } from "./handlers/segmented-control";
|
|
27
|
+
import { createSelectBoxGroupHandler, createSelectBoxHandler } from "./handlers/select-box";
|
|
28
|
+
import { createSkeletonHandler } from "./handlers/skeleton";
|
|
29
|
+
import { createSnackbarHandler } from "./handlers/snackbar";
|
|
30
|
+
import { createSwitchHandler } from "./handlers/switch";
|
|
31
|
+
import { createTabsHandler } from "./handlers/tabs";
|
|
32
|
+
import { createTextButtonHandler } from "./handlers/text-button";
|
|
33
|
+
import { createTextFieldHandler } from "./handlers/text-field";
|
|
34
|
+
import { createToggleButtonHandler } from "./handlers/toggle-button";
|
|
37
35
|
|
|
38
|
-
export type {
|
|
39
|
-
export type
|
|
36
|
+
export type { ComponentHandlerDeps };
|
|
37
|
+
export type UnboundComponentHandler<T extends NormalizedInstanceNode["componentProperties"]> = (
|
|
38
|
+
deps: ComponentHandlerDeps,
|
|
39
|
+
) => ComponentHandler<T>;
|
|
40
40
|
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
41
|
+
export function bindComponentHandler<T extends NormalizedInstanceNode["componentProperties"]>(
|
|
42
|
+
unbound: UnboundComponentHandler<T>,
|
|
43
|
+
deps: ComponentHandlerDeps,
|
|
44
|
+
): ComponentHandler<T> {
|
|
45
|
+
return unbound(deps);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const unboundSeedComponentHandlers: Array<UnboundComponentHandler<any>> = [
|
|
49
|
+
createActionButtonHandler,
|
|
50
|
+
createActionChipHandler,
|
|
51
|
+
createActionSheetHandler,
|
|
52
|
+
createAppBarHandler,
|
|
53
|
+
createAvatarHandler,
|
|
54
|
+
createAvatarStackHandler,
|
|
55
|
+
createBadgeHandler,
|
|
56
|
+
createCalloutHandler,
|
|
57
|
+
createCheckboxHandler,
|
|
58
|
+
createChipTabsHandler,
|
|
59
|
+
createControlChipHandler,
|
|
60
|
+
createErrorStateHandler,
|
|
61
|
+
createExtendedActionSheetHandler,
|
|
62
|
+
createExtendedFabHandler,
|
|
63
|
+
createFabHandler,
|
|
64
|
+
createHelpBubbleHandler,
|
|
65
|
+
createIdentityPlaceholderHandler,
|
|
66
|
+
createInlineBannerHandler,
|
|
67
|
+
createMannerTempBadgeHandler,
|
|
68
|
+
createMultilineTextFieldHandler,
|
|
69
|
+
createProgressCircleHandler,
|
|
70
|
+
createReactionButtonHandler,
|
|
71
|
+
createSegmentedControlHandler,
|
|
72
|
+
createSelectBoxGroupHandler,
|
|
73
|
+
createSelectBoxHandler,
|
|
74
|
+
createSkeletonHandler,
|
|
75
|
+
createSnackbarHandler,
|
|
76
|
+
createSwitchHandler,
|
|
77
|
+
createTabsHandler,
|
|
78
|
+
createTextButtonHandler,
|
|
79
|
+
createTextFieldHandler,
|
|
80
|
+
createToggleButtonHandler,
|
|
81
|
+
];
|