-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathbuildFieldInputInstance.ts
More file actions
36 lines (33 loc) · 1.15 KB
/
buildFieldInputInstance.ts
File metadata and controls
36 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { get } from 'es-toolkit/compat';
import type { FieldInputInstance, FieldInputTemplate, FieldValue, StatefulFieldType } from 'features/nodes/types/field';
const FIELD_VALUE_FALLBACK_MAP: Record<StatefulFieldType['name'], FieldValue> = {
EnumField: '',
BoardField: undefined,
BooleanField: false,
ColorField: { r: 0, g: 0, b: 0, a: 1 },
FloatField: 0,
ImageField: undefined,
IntegerField: 0,
ModelIdentifierField: undefined,
SchedulerField: 'dpmpp_3m_k',
StringField: '',
StylePresetField: undefined,
FloatGeneratorField: undefined,
IntegerGeneratorField: undefined,
StringGeneratorField: undefined,
ImageGeneratorField: undefined,
LoRAMetadataField: undefined,
ControlNetMetadataField: undefined,
IPAdapterMetadataField: undefined,
T2IAdapterMetadataField: undefined,
MetadataExtraField: undefined,
};
export const buildFieldInputInstance = (id: string, template: FieldInputTemplate): FieldInputInstance => {
const fieldInstance: FieldInputInstance = {
name: template.name,
label: '',
description: '',
value: template.default ?? get(FIELD_VALUE_FALLBACK_MAP, template.type.name),
};
return fieldInstance;
};