@d34dman/flowdrop 0.0.22 → 0.0.24
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/dist/components/App.svelte +26 -25
- package/dist/components/ConfigForm.svelte +141 -520
- package/dist/components/ConfigForm.svelte.d.ts +5 -3
- package/dist/components/form/FormArray.svelte +1049 -0
- package/dist/components/form/FormArray.svelte.d.ts +22 -0
- package/dist/components/form/FormCheckboxGroup.svelte +152 -0
- package/dist/components/form/FormCheckboxGroup.svelte.d.ts +15 -0
- package/dist/components/form/FormField.svelte +297 -0
- package/dist/components/form/FormField.svelte.d.ts +18 -0
- package/dist/components/form/FormFieldWrapper.svelte +133 -0
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +18 -0
- package/dist/components/form/FormNumberField.svelte +109 -0
- package/dist/components/form/FormNumberField.svelte.d.ts +23 -0
- package/dist/components/form/FormRangeField.svelte +252 -0
- package/dist/components/form/FormRangeField.svelte.d.ts +21 -0
- package/dist/components/form/FormSelect.svelte +126 -0
- package/dist/components/form/FormSelect.svelte.d.ts +18 -0
- package/dist/components/form/FormTextField.svelte +88 -0
- package/dist/components/form/FormTextField.svelte.d.ts +17 -0
- package/dist/components/form/FormTextarea.svelte +94 -0
- package/dist/components/form/FormTextarea.svelte.d.ts +19 -0
- package/dist/components/form/FormToggle.svelte +123 -0
- package/dist/components/form/FormToggle.svelte.d.ts +17 -0
- package/dist/components/form/index.d.ts +42 -0
- package/dist/components/form/index.js +46 -0
- package/dist/components/form/types.d.ts +224 -0
- package/dist/components/form/types.js +29 -0
- package/dist/components/nodes/GatewayNode.svelte +76 -16
- package/dist/components/nodes/SimpleNode.svelte +41 -5
- package/dist/components/nodes/SimpleNode.svelte.d.ts +2 -1
- package/dist/components/nodes/SquareNode.svelte +41 -5
- package/dist/components/nodes/SquareNode.svelte.d.ts +2 -1
- package/dist/components/nodes/WorkflowNode.svelte +88 -5
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -3
- package/dist/stores/workflowStore.d.ts +15 -0
- package/dist/stores/workflowStore.js +28 -0
- package/dist/types/index.d.ts +176 -1
- package/dist/types/index.js +16 -0
- package/package.json +3 -3
- package/dist/config/demo.d.ts +0 -58
- package/dist/config/demo.js +0 -142
- package/dist/data/samples.d.ts +0 -51
- package/dist/data/samples.js +0 -3245
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
FormTextarea Component
|
|
3
|
+
Multiline text input field for longer string values
|
|
4
|
+
|
|
5
|
+
Features:
|
|
6
|
+
- Resizable textarea with minimum height
|
|
7
|
+
- Focus and hover states
|
|
8
|
+
- Proper ARIA attributes for accessibility
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
interface Props {
|
|
13
|
+
/** Field identifier */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Current value */
|
|
16
|
+
value: string;
|
|
17
|
+
/** Placeholder text */
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
/** Number of visible rows */
|
|
20
|
+
rows?: number;
|
|
21
|
+
/** Whether the field is required */
|
|
22
|
+
required?: boolean;
|
|
23
|
+
/** ARIA description ID */
|
|
24
|
+
ariaDescribedBy?: string;
|
|
25
|
+
/** Callback when value changes */
|
|
26
|
+
onChange: (value: string) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
id,
|
|
31
|
+
value = "",
|
|
32
|
+
placeholder = "",
|
|
33
|
+
rows = 4,
|
|
34
|
+
required = false,
|
|
35
|
+
ariaDescribedBy,
|
|
36
|
+
onChange
|
|
37
|
+
}: Props = $props();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Handle textarea changes
|
|
41
|
+
*/
|
|
42
|
+
function handleInput(event: Event): void {
|
|
43
|
+
const target = event.currentTarget as HTMLTextAreaElement;
|
|
44
|
+
onChange(target.value);
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<textarea
|
|
49
|
+
{id}
|
|
50
|
+
class="form-textarea"
|
|
51
|
+
value={value ?? ""}
|
|
52
|
+
{placeholder}
|
|
53
|
+
{rows}
|
|
54
|
+
aria-describedby={ariaDescribedBy}
|
|
55
|
+
aria-required={required}
|
|
56
|
+
oninput={handleInput}
|
|
57
|
+
></textarea>
|
|
58
|
+
|
|
59
|
+
<style>
|
|
60
|
+
.form-textarea {
|
|
61
|
+
width: 100%;
|
|
62
|
+
padding: 0.625rem 0.875rem;
|
|
63
|
+
border: 1px solid var(--color-ref-gray-200, #e5e7eb);
|
|
64
|
+
border-radius: 0.5rem;
|
|
65
|
+
font-size: 0.875rem;
|
|
66
|
+
font-family: inherit;
|
|
67
|
+
color: var(--color-ref-gray-900, #111827);
|
|
68
|
+
background-color: var(--color-ref-gray-50, #f9fafb);
|
|
69
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
70
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
|
71
|
+
resize: vertical;
|
|
72
|
+
min-height: 5rem;
|
|
73
|
+
line-height: 1.5;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.form-textarea::placeholder {
|
|
77
|
+
color: var(--color-ref-gray-400, #9ca3af);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.form-textarea:hover {
|
|
81
|
+
border-color: var(--color-ref-gray-300, #d1d5db);
|
|
82
|
+
background-color: #ffffff;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.form-textarea:focus {
|
|
86
|
+
outline: none;
|
|
87
|
+
border-color: var(--color-ref-blue-500, #3b82f6);
|
|
88
|
+
background-color: #ffffff;
|
|
89
|
+
box-shadow:
|
|
90
|
+
0 0 0 3px rgba(59, 130, 246, 0.12),
|
|
91
|
+
0 1px 2px rgba(0, 0, 0, 0.04);
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
94
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** Field identifier */
|
|
3
|
+
id: string;
|
|
4
|
+
/** Current value */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Placeholder text */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** Number of visible rows */
|
|
9
|
+
rows?: number;
|
|
10
|
+
/** Whether the field is required */
|
|
11
|
+
required?: boolean;
|
|
12
|
+
/** ARIA description ID */
|
|
13
|
+
ariaDescribedBy?: string;
|
|
14
|
+
/** Callback when value changes */
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const FormTextarea: import("svelte").Component<Props, {}, "">;
|
|
18
|
+
type FormTextarea = ReturnType<typeof FormTextarea>;
|
|
19
|
+
export default FormTextarea;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
FormToggle Component
|
|
3
|
+
Toggle switch for boolean values
|
|
4
|
+
|
|
5
|
+
Features:
|
|
6
|
+
- Smooth toggle animation
|
|
7
|
+
- On/Off labels with state-based coloring
|
|
8
|
+
- Focus-visible states for keyboard navigation
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
interface Props {
|
|
13
|
+
/** Field identifier */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Current value */
|
|
16
|
+
value: boolean;
|
|
17
|
+
/** Label shown when toggle is on */
|
|
18
|
+
onLabel?: string;
|
|
19
|
+
/** Label shown when toggle is off */
|
|
20
|
+
offLabel?: string;
|
|
21
|
+
/** ARIA description ID */
|
|
22
|
+
ariaDescribedBy?: string;
|
|
23
|
+
/** Callback when value changes */
|
|
24
|
+
onChange: (value: boolean) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let {
|
|
28
|
+
id,
|
|
29
|
+
value = false,
|
|
30
|
+
onLabel = "Enabled",
|
|
31
|
+
offLabel = "Disabled",
|
|
32
|
+
ariaDescribedBy,
|
|
33
|
+
onChange
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Handle toggle changes
|
|
38
|
+
*/
|
|
39
|
+
function handleChange(event: Event): void {
|
|
40
|
+
const target = event.currentTarget as HTMLInputElement;
|
|
41
|
+
onChange(target.checked);
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<label class="form-toggle">
|
|
46
|
+
<input
|
|
47
|
+
{id}
|
|
48
|
+
type="checkbox"
|
|
49
|
+
class="form-toggle__input"
|
|
50
|
+
checked={value}
|
|
51
|
+
aria-describedby={ariaDescribedBy}
|
|
52
|
+
onchange={handleChange}
|
|
53
|
+
/>
|
|
54
|
+
<span class="form-toggle__track">
|
|
55
|
+
<span class="form-toggle__thumb"></span>
|
|
56
|
+
</span>
|
|
57
|
+
<span class="form-toggle__label">
|
|
58
|
+
{value ? onLabel : offLabel}
|
|
59
|
+
</span>
|
|
60
|
+
</label>
|
|
61
|
+
|
|
62
|
+
<style>
|
|
63
|
+
.form-toggle {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
gap: 0.75rem;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
padding: 0.5rem 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.form-toggle__input {
|
|
72
|
+
position: absolute;
|
|
73
|
+
opacity: 0;
|
|
74
|
+
width: 0;
|
|
75
|
+
height: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.form-toggle__track {
|
|
79
|
+
position: relative;
|
|
80
|
+
width: 2.75rem;
|
|
81
|
+
height: 1.5rem;
|
|
82
|
+
background-color: var(--color-ref-gray-300, #d1d5db);
|
|
83
|
+
border-radius: 0.75rem;
|
|
84
|
+
transition: background-color 0.2s;
|
|
85
|
+
flex-shrink: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.form-toggle__thumb {
|
|
89
|
+
position: absolute;
|
|
90
|
+
top: 0.125rem;
|
|
91
|
+
left: 0.125rem;
|
|
92
|
+
width: 1.25rem;
|
|
93
|
+
height: 1.25rem;
|
|
94
|
+
background-color: #ffffff;
|
|
95
|
+
border-radius: 50%;
|
|
96
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
|
97
|
+
transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.form-toggle__input:checked + .form-toggle__track {
|
|
101
|
+
background-color: var(--color-ref-blue-500, #3b82f6);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.form-toggle__input:checked + .form-toggle__track .form-toggle__thumb {
|
|
105
|
+
transform: translateX(1.25rem);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.form-toggle__input:focus-visible + .form-toggle__track {
|
|
109
|
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.form-toggle__label {
|
|
113
|
+
font-size: 0.875rem;
|
|
114
|
+
color: var(--color-ref-gray-600, #4b5563);
|
|
115
|
+
font-weight: 500;
|
|
116
|
+
min-width: 4.5rem;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.form-toggle__input:checked ~ .form-toggle__label {
|
|
120
|
+
color: var(--color-ref-blue-600, #2563eb);
|
|
121
|
+
}
|
|
122
|
+
</style>
|
|
123
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** Field identifier */
|
|
3
|
+
id: string;
|
|
4
|
+
/** Current value */
|
|
5
|
+
value: boolean;
|
|
6
|
+
/** Label shown when toggle is on */
|
|
7
|
+
onLabel?: string;
|
|
8
|
+
/** Label shown when toggle is off */
|
|
9
|
+
offLabel?: string;
|
|
10
|
+
/** ARIA description ID */
|
|
11
|
+
ariaDescribedBy?: string;
|
|
12
|
+
/** Callback when value changes */
|
|
13
|
+
onChange: (value: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const FormToggle: import("svelte").Component<Props, {}, "">;
|
|
16
|
+
type FormToggle = ReturnType<typeof FormToggle>;
|
|
17
|
+
export default FormToggle;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form Components Module
|
|
3
|
+
*
|
|
4
|
+
* Modular form components for dynamic form rendering based on JSON Schema.
|
|
5
|
+
* Designed for extensibility to support complex types like arrays and objects.
|
|
6
|
+
*
|
|
7
|
+
* @module form
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```svelte
|
|
11
|
+
* <script>
|
|
12
|
+
* import { FormField } from "./";
|
|
13
|
+
* import type { FieldSchema } from "./";
|
|
14
|
+
*
|
|
15
|
+
* const schema: FieldSchema = {
|
|
16
|
+
* type: "string",
|
|
17
|
+
* title: "Name",
|
|
18
|
+
* description: "Enter your name"
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* let value = $state("");
|
|
22
|
+
* </script>
|
|
23
|
+
*
|
|
24
|
+
* <FormField
|
|
25
|
+
* fieldKey="name"
|
|
26
|
+
* {schema}
|
|
27
|
+
* {value}
|
|
28
|
+
* onChange={(v) => value = v}
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export * from "./types.js";
|
|
33
|
+
export { default as FormField } from "./FormField.svelte";
|
|
34
|
+
export { default as FormFieldWrapper } from "./FormFieldWrapper.svelte";
|
|
35
|
+
export { default as FormTextField } from "./FormTextField.svelte";
|
|
36
|
+
export { default as FormTextarea } from "./FormTextarea.svelte";
|
|
37
|
+
export { default as FormNumberField } from "./FormNumberField.svelte";
|
|
38
|
+
export { default as FormRangeField } from "./FormRangeField.svelte";
|
|
39
|
+
export { default as FormToggle } from "./FormToggle.svelte";
|
|
40
|
+
export { default as FormSelect } from "./FormSelect.svelte";
|
|
41
|
+
export { default as FormCheckboxGroup } from "./FormCheckboxGroup.svelte";
|
|
42
|
+
export { default as FormArray } from "./FormArray.svelte";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form Components Module
|
|
3
|
+
*
|
|
4
|
+
* Modular form components for dynamic form rendering based on JSON Schema.
|
|
5
|
+
* Designed for extensibility to support complex types like arrays and objects.
|
|
6
|
+
*
|
|
7
|
+
* @module form
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```svelte
|
|
11
|
+
* <script>
|
|
12
|
+
* import { FormField } from "./";
|
|
13
|
+
* import type { FieldSchema } from "./";
|
|
14
|
+
*
|
|
15
|
+
* const schema: FieldSchema = {
|
|
16
|
+
* type: "string",
|
|
17
|
+
* title: "Name",
|
|
18
|
+
* description: "Enter your name"
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* let value = $state("");
|
|
22
|
+
* </script>
|
|
23
|
+
*
|
|
24
|
+
* <FormField
|
|
25
|
+
* fieldKey="name"
|
|
26
|
+
* {schema}
|
|
27
|
+
* {value}
|
|
28
|
+
* onChange={(v) => value = v}
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
// Types
|
|
33
|
+
export * from "./types.js";
|
|
34
|
+
// Main factory component
|
|
35
|
+
export { default as FormField } from "./FormField.svelte";
|
|
36
|
+
// Wrapper component
|
|
37
|
+
export { default as FormFieldWrapper } from "./FormFieldWrapper.svelte";
|
|
38
|
+
// Individual field components
|
|
39
|
+
export { default as FormTextField } from "./FormTextField.svelte";
|
|
40
|
+
export { default as FormTextarea } from "./FormTextarea.svelte";
|
|
41
|
+
export { default as FormNumberField } from "./FormNumberField.svelte";
|
|
42
|
+
export { default as FormRangeField } from "./FormRangeField.svelte";
|
|
43
|
+
export { default as FormToggle } from "./FormToggle.svelte";
|
|
44
|
+
export { default as FormSelect } from "./FormSelect.svelte";
|
|
45
|
+
export { default as FormCheckboxGroup } from "./FormCheckboxGroup.svelte";
|
|
46
|
+
export { default as FormArray } from "./FormArray.svelte";
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form Field Types
|
|
3
|
+
* Shared types for form components in the FlowDrop workflow editor
|
|
4
|
+
*
|
|
5
|
+
* These types provide a foundation for dynamic form rendering based on JSON Schema
|
|
6
|
+
* and support extensibility for complex field types like arrays and objects.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Supported field types for form rendering
|
|
10
|
+
* Can be extended to support complex types like 'array' and 'object'
|
|
11
|
+
*/
|
|
12
|
+
export type FieldType = "string" | "number" | "integer" | "boolean" | "select" | "array" | "object";
|
|
13
|
+
/**
|
|
14
|
+
* Field format for specialized rendering
|
|
15
|
+
* - multiline: Renders as textarea
|
|
16
|
+
* - hidden: Field is hidden from UI but included in form submission
|
|
17
|
+
* - range: Renders as range slider for numeric values
|
|
18
|
+
*/
|
|
19
|
+
export type FieldFormat = "multiline" | "hidden" | "range" | string;
|
|
20
|
+
/**
|
|
21
|
+
* Option type for select and checkbox group fields
|
|
22
|
+
*/
|
|
23
|
+
export interface FieldOption {
|
|
24
|
+
/** The value stored when this option is selected */
|
|
25
|
+
value: string;
|
|
26
|
+
/** The display label for this option */
|
|
27
|
+
label: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Base properties shared by all form fields
|
|
31
|
+
*/
|
|
32
|
+
export interface BaseFieldProps {
|
|
33
|
+
/** Unique identifier for the field (used for id and name attributes) */
|
|
34
|
+
id: string;
|
|
35
|
+
/** Current value of the field */
|
|
36
|
+
value: unknown;
|
|
37
|
+
/** Whether the field is required */
|
|
38
|
+
required?: boolean;
|
|
39
|
+
/** Whether the field is disabled */
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/** Placeholder text for input fields */
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
/** ARIA description ID for accessibility */
|
|
44
|
+
ariaDescribedBy?: string;
|
|
45
|
+
/** Callback when the field value changes */
|
|
46
|
+
onChange: (value: unknown) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Properties for text input fields
|
|
50
|
+
*/
|
|
51
|
+
export interface TextFieldProps extends BaseFieldProps {
|
|
52
|
+
value: string;
|
|
53
|
+
onChange: (value: string) => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Properties for multiline text fields (textarea)
|
|
57
|
+
*/
|
|
58
|
+
export interface TextareaFieldProps extends BaseFieldProps {
|
|
59
|
+
value: string;
|
|
60
|
+
/** Number of visible rows */
|
|
61
|
+
rows?: number;
|
|
62
|
+
onChange: (value: string) => void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Properties for number input fields
|
|
66
|
+
*/
|
|
67
|
+
export interface NumberFieldProps extends BaseFieldProps {
|
|
68
|
+
value: number | string;
|
|
69
|
+
/** Minimum allowed value */
|
|
70
|
+
min?: number;
|
|
71
|
+
/** Maximum allowed value */
|
|
72
|
+
max?: number;
|
|
73
|
+
/** Step increment for the input */
|
|
74
|
+
step?: number;
|
|
75
|
+
onChange: (value: number | string) => void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Properties for boolean toggle fields
|
|
79
|
+
*/
|
|
80
|
+
export interface ToggleFieldProps extends BaseFieldProps {
|
|
81
|
+
value: boolean;
|
|
82
|
+
/** Label shown when toggle is on */
|
|
83
|
+
onLabel?: string;
|
|
84
|
+
/** Label shown when toggle is off */
|
|
85
|
+
offLabel?: string;
|
|
86
|
+
onChange: (value: boolean) => void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Properties for range slider fields
|
|
90
|
+
*/
|
|
91
|
+
export interface RangeFieldProps extends BaseFieldProps {
|
|
92
|
+
value: number | string;
|
|
93
|
+
/** Minimum allowed value */
|
|
94
|
+
min?: number;
|
|
95
|
+
/** Maximum allowed value */
|
|
96
|
+
max?: number;
|
|
97
|
+
/** Step increment for the slider */
|
|
98
|
+
step?: number;
|
|
99
|
+
onChange: (value: number) => void;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Properties for select dropdown fields
|
|
103
|
+
*/
|
|
104
|
+
export interface SelectFieldProps extends BaseFieldProps {
|
|
105
|
+
value: string;
|
|
106
|
+
/** Available options for selection */
|
|
107
|
+
options: FieldOption[] | string[];
|
|
108
|
+
onChange: (value: string) => void;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Properties for checkbox group fields (multiple selection)
|
|
112
|
+
*/
|
|
113
|
+
export interface CheckboxGroupFieldProps extends BaseFieldProps {
|
|
114
|
+
value: string[];
|
|
115
|
+
/** Available options for selection */
|
|
116
|
+
options: string[];
|
|
117
|
+
onChange: (value: string[]) => void;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Properties for array fields (dynamic lists)
|
|
121
|
+
*/
|
|
122
|
+
export interface ArrayFieldProps extends BaseFieldProps {
|
|
123
|
+
value: unknown[];
|
|
124
|
+
/** Schema for array items */
|
|
125
|
+
itemSchema: FieldSchema;
|
|
126
|
+
/** Minimum number of items required */
|
|
127
|
+
minItems?: number;
|
|
128
|
+
/** Maximum number of items allowed */
|
|
129
|
+
maxItems?: number;
|
|
130
|
+
/** Label for the add button */
|
|
131
|
+
addLabel?: string;
|
|
132
|
+
onChange: (value: unknown[]) => void;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Field schema definition derived from JSON Schema property
|
|
136
|
+
* Used to determine which field component to render
|
|
137
|
+
*/
|
|
138
|
+
export interface FieldSchema {
|
|
139
|
+
/** The field type from JSON Schema */
|
|
140
|
+
type: FieldType | string;
|
|
141
|
+
/** Display title for the field */
|
|
142
|
+
title?: string;
|
|
143
|
+
/** Description for help text */
|
|
144
|
+
description?: string;
|
|
145
|
+
/** Default value for the field */
|
|
146
|
+
default?: unknown;
|
|
147
|
+
/** Enum values for select/checkbox fields */
|
|
148
|
+
enum?: unknown[];
|
|
149
|
+
/** Whether multiple values can be selected */
|
|
150
|
+
multiple?: boolean;
|
|
151
|
+
/** Format hint for specialized rendering */
|
|
152
|
+
format?: FieldFormat;
|
|
153
|
+
/** Options for select type fields (alternative to enum) */
|
|
154
|
+
options?: FieldOption[];
|
|
155
|
+
/** Placeholder text */
|
|
156
|
+
placeholder?: string;
|
|
157
|
+
/** Minimum value for numbers */
|
|
158
|
+
minimum?: number;
|
|
159
|
+
/** Maximum value for numbers */
|
|
160
|
+
maximum?: number;
|
|
161
|
+
/** Step increment for number/range inputs */
|
|
162
|
+
step?: number;
|
|
163
|
+
/** Minimum length for strings */
|
|
164
|
+
minLength?: number;
|
|
165
|
+
/** Maximum length for strings */
|
|
166
|
+
maxLength?: number;
|
|
167
|
+
/** Validation pattern for strings */
|
|
168
|
+
pattern?: string;
|
|
169
|
+
/** Item schema for array fields */
|
|
170
|
+
items?: FieldSchema;
|
|
171
|
+
/** Minimum number of items for array fields */
|
|
172
|
+
minItems?: number;
|
|
173
|
+
/** Maximum number of items for array fields */
|
|
174
|
+
maxItems?: number;
|
|
175
|
+
/** Property schemas for object fields (future use) */
|
|
176
|
+
properties?: Record<string, FieldSchema>;
|
|
177
|
+
/** Required properties for object fields (future use) */
|
|
178
|
+
required?: string[];
|
|
179
|
+
/** Allow additional properties not defined by the schema */
|
|
180
|
+
[key: string]: unknown;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Props for the FormField factory component
|
|
184
|
+
* Renders the appropriate field component based on schema
|
|
185
|
+
*/
|
|
186
|
+
export interface FormFieldFactoryProps {
|
|
187
|
+
/** Unique key/id for the field */
|
|
188
|
+
fieldKey: string;
|
|
189
|
+
/** Field schema definition */
|
|
190
|
+
schema: FieldSchema;
|
|
191
|
+
/** Current field value */
|
|
192
|
+
value: unknown;
|
|
193
|
+
/** Whether the field is required */
|
|
194
|
+
required?: boolean;
|
|
195
|
+
/** Animation delay index for staggered animations */
|
|
196
|
+
animationIndex?: number;
|
|
197
|
+
/** Callback when the field value changes */
|
|
198
|
+
onChange: (value: unknown) => void;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Props for the FormFieldWrapper component
|
|
202
|
+
* Provides label, description, and layout for field content
|
|
203
|
+
*/
|
|
204
|
+
export interface FormFieldWrapperProps {
|
|
205
|
+
/** Field identifier for label association */
|
|
206
|
+
id: string;
|
|
207
|
+
/** Display label text */
|
|
208
|
+
label: string;
|
|
209
|
+
/** Whether the field is required */
|
|
210
|
+
required?: boolean;
|
|
211
|
+
/** Description/help text for the field */
|
|
212
|
+
description?: string;
|
|
213
|
+
/** Animation delay in milliseconds */
|
|
214
|
+
animationDelay?: number;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Type guard to check if options are FieldOption objects
|
|
218
|
+
*/
|
|
219
|
+
export declare function isFieldOptionArray(options: FieldOption[] | string[]): options is FieldOption[];
|
|
220
|
+
/**
|
|
221
|
+
* Normalize options to FieldOption format
|
|
222
|
+
* Converts string arrays to FieldOption arrays for consistent handling
|
|
223
|
+
*/
|
|
224
|
+
export declare function normalizeOptions(options: FieldOption[] | string[] | unknown[]): FieldOption[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form Field Types
|
|
3
|
+
* Shared types for form components in the FlowDrop workflow editor
|
|
4
|
+
*
|
|
5
|
+
* These types provide a foundation for dynamic form rendering based on JSON Schema
|
|
6
|
+
* and support extensibility for complex field types like arrays and objects.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if options are FieldOption objects
|
|
10
|
+
*/
|
|
11
|
+
export function isFieldOptionArray(options) {
|
|
12
|
+
return options.length > 0 && typeof options[0] === "object" && "value" in options[0];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Normalize options to FieldOption format
|
|
16
|
+
* Converts string arrays to FieldOption arrays for consistent handling
|
|
17
|
+
*/
|
|
18
|
+
export function normalizeOptions(options) {
|
|
19
|
+
if (!options || options.length === 0) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
if (isFieldOptionArray(options)) {
|
|
23
|
+
return options;
|
|
24
|
+
}
|
|
25
|
+
return options.map((opt) => ({
|
|
26
|
+
value: String(opt),
|
|
27
|
+
label: String(opt)
|
|
28
|
+
}));
|
|
29
|
+
}
|