@d34dman/flowdrop 0.0.28 → 0.0.29
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/form/FormFieldLight.svelte +422 -0
- package/dist/components/form/FormFieldLight.svelte.d.ts +18 -0
- package/dist/core/index.d.ts +39 -0
- package/dist/core/index.js +50 -0
- package/dist/display/index.d.ts +29 -0
- package/dist/display/index.js +36 -0
- package/dist/editor/index.d.ts +78 -0
- package/dist/editor/index.js +117 -0
- package/dist/form/code.d.ts +100 -0
- package/dist/form/code.js +153 -0
- package/dist/form/fieldRegistry.d.ts +163 -0
- package/dist/form/fieldRegistry.js +175 -0
- package/dist/form/full.d.ts +53 -0
- package/dist/form/full.js +75 -0
- package/dist/form/index.d.ts +57 -0
- package/dist/form/index.js +68 -0
- package/dist/form/markdown.d.ts +68 -0
- package/dist/form/markdown.js +93 -0
- package/dist/index.d.ts +31 -66
- package/dist/index.js +49 -80
- package/package.json +46 -3
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form Field Component Registry
|
|
3
|
+
*
|
|
4
|
+
* Provides a registry system for form field components that enables:
|
|
5
|
+
* - Tree-shaking: Heavy components (code editor, markdown) are only bundled when registered
|
|
6
|
+
* - Dynamic field types: Users can add custom field renderers
|
|
7
|
+
* - Lazy loading: Components can be registered at runtime
|
|
8
|
+
*
|
|
9
|
+
* @module form/fieldRegistry
|
|
10
|
+
*
|
|
11
|
+
* @example Basic usage with light fields only (no codemirror/easymde):
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { SchemaForm } from "@d34dman/flowdrop/form";
|
|
14
|
+
* // Uses only basic fields - small bundle size
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example Adding code editor support:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { SchemaForm, registerFieldComponent } from "@d34dman/flowdrop/form";
|
|
20
|
+
* import { FormCodeEditor, codeEditorFieldMatcher } from "@d34dman/flowdrop/form/code";
|
|
21
|
+
*
|
|
22
|
+
* registerFieldComponent("code-editor", FormCodeEditor, codeEditorFieldMatcher);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Field component registry
|
|
27
|
+
* Stores registered field components with their matchers
|
|
28
|
+
*/
|
|
29
|
+
const fieldRegistry = new Map();
|
|
30
|
+
/**
|
|
31
|
+
* Ordered list of field type keys by priority (highest first)
|
|
32
|
+
* Cached and invalidated when registry changes
|
|
33
|
+
*/
|
|
34
|
+
let orderedKeys = null;
|
|
35
|
+
/**
|
|
36
|
+
* Register a field component for a specific field type
|
|
37
|
+
*
|
|
38
|
+
* @param type - Unique identifier for this field type
|
|
39
|
+
* @param component - Svelte component to render for matching fields
|
|
40
|
+
* @param matcher - Function to determine if a schema matches this type
|
|
41
|
+
* @param priority - Priority for matching (default: 0, higher = checked first)
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* registerFieldComponent(
|
|
46
|
+
* "code-editor",
|
|
47
|
+
* FormCodeEditor,
|
|
48
|
+
* (schema) => schema.format === "json" || schema.format === "code",
|
|
49
|
+
* 100 // High priority to override default
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function registerFieldComponent(type, component, matcher, priority = 0) {
|
|
54
|
+
fieldRegistry.set(type, { component, matcher, priority });
|
|
55
|
+
orderedKeys = null; // Invalidate cache
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Unregister a field component
|
|
59
|
+
*
|
|
60
|
+
* @param type - The field type to unregister
|
|
61
|
+
* @returns true if the component was registered and removed
|
|
62
|
+
*/
|
|
63
|
+
export function unregisterFieldComponent(type) {
|
|
64
|
+
const removed = fieldRegistry.delete(type);
|
|
65
|
+
if (removed) {
|
|
66
|
+
orderedKeys = null; // Invalidate cache
|
|
67
|
+
}
|
|
68
|
+
return removed;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get all registered field types
|
|
72
|
+
*
|
|
73
|
+
* @returns Array of registered field type identifiers
|
|
74
|
+
*/
|
|
75
|
+
export function getRegisteredFieldTypes() {
|
|
76
|
+
return Array.from(fieldRegistry.keys());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Check if a field type is registered
|
|
80
|
+
*
|
|
81
|
+
* @param type - Field type to check
|
|
82
|
+
* @returns true if the type is registered
|
|
83
|
+
*/
|
|
84
|
+
export function isFieldTypeRegistered(type) {
|
|
85
|
+
return fieldRegistry.has(type);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get ordered keys by priority (cached)
|
|
89
|
+
*/
|
|
90
|
+
function getOrderedKeys() {
|
|
91
|
+
if (orderedKeys === null) {
|
|
92
|
+
orderedKeys = Array.from(fieldRegistry.entries())
|
|
93
|
+
.sort((a, b) => b[1].priority - a[1].priority)
|
|
94
|
+
.map(([key]) => key);
|
|
95
|
+
}
|
|
96
|
+
return orderedKeys;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolve which component should render a given field schema
|
|
100
|
+
* Checks registered matchers in priority order
|
|
101
|
+
*
|
|
102
|
+
* @param schema - The field schema to resolve
|
|
103
|
+
* @returns The matching registration or null if no match
|
|
104
|
+
*/
|
|
105
|
+
export function resolveFieldComponent(schema) {
|
|
106
|
+
const keys = getOrderedKeys();
|
|
107
|
+
for (const key of keys) {
|
|
108
|
+
const registration = fieldRegistry.get(key);
|
|
109
|
+
if (registration && registration.matcher(schema)) {
|
|
110
|
+
return registration;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Clear all registered field components
|
|
117
|
+
* Useful for testing or reset scenarios
|
|
118
|
+
*/
|
|
119
|
+
export function clearFieldRegistry() {
|
|
120
|
+
fieldRegistry.clear();
|
|
121
|
+
orderedKeys = null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the registry size
|
|
125
|
+
* @returns Number of registered field components
|
|
126
|
+
*/
|
|
127
|
+
export function getFieldRegistrySize() {
|
|
128
|
+
return fieldRegistry.size;
|
|
129
|
+
}
|
|
130
|
+
// ============================================================================
|
|
131
|
+
// Built-in Field Matchers (for light fields)
|
|
132
|
+
// These are always available and used by the base FormField component
|
|
133
|
+
// ============================================================================
|
|
134
|
+
/**
|
|
135
|
+
* Matcher for hidden fields (should not render)
|
|
136
|
+
*/
|
|
137
|
+
export const hiddenFieldMatcher = (schema) => schema.format === "hidden";
|
|
138
|
+
/**
|
|
139
|
+
* Matcher for checkbox group fields (enum with multiple)
|
|
140
|
+
*/
|
|
141
|
+
export const checkboxGroupMatcher = (schema) => Boolean(schema.enum && schema.multiple);
|
|
142
|
+
/**
|
|
143
|
+
* Matcher for enum select fields
|
|
144
|
+
*/
|
|
145
|
+
export const enumSelectMatcher = (schema) => Boolean(schema.enum && !schema.multiple);
|
|
146
|
+
/**
|
|
147
|
+
* Matcher for multiline textarea fields
|
|
148
|
+
*/
|
|
149
|
+
export const textareaMatcher = (schema) => schema.type === "string" && schema.format === "multiline";
|
|
150
|
+
/**
|
|
151
|
+
* Matcher for range slider fields
|
|
152
|
+
*/
|
|
153
|
+
export const rangeMatcher = (schema) => (schema.type === "number" || schema.type === "integer") &&
|
|
154
|
+
schema.format === "range";
|
|
155
|
+
/**
|
|
156
|
+
* Matcher for string text fields
|
|
157
|
+
*/
|
|
158
|
+
export const textFieldMatcher = (schema) => schema.type === "string" && !schema.format;
|
|
159
|
+
/**
|
|
160
|
+
* Matcher for number fields
|
|
161
|
+
*/
|
|
162
|
+
export const numberFieldMatcher = (schema) => (schema.type === "number" || schema.type === "integer") &&
|
|
163
|
+
schema.format !== "range";
|
|
164
|
+
/**
|
|
165
|
+
* Matcher for boolean toggle fields
|
|
166
|
+
*/
|
|
167
|
+
export const toggleMatcher = (schema) => schema.type === "boolean";
|
|
168
|
+
/**
|
|
169
|
+
* Matcher for select fields with options
|
|
170
|
+
*/
|
|
171
|
+
export const selectOptionsMatcher = (schema) => schema.type === "select" || Boolean(schema.options);
|
|
172
|
+
/**
|
|
173
|
+
* Matcher for array fields
|
|
174
|
+
*/
|
|
175
|
+
export const arrayMatcher = (schema) => schema.type === "array" && Boolean(schema.items);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop Form Full Module
|
|
3
|
+
*
|
|
4
|
+
* Convenience module that imports and registers all form field types,
|
|
5
|
+
* including heavy editors (CodeMirror, EasyMDE).
|
|
6
|
+
*
|
|
7
|
+
* This is equivalent to importing from the light form module and manually
|
|
8
|
+
* registering all editor types.
|
|
9
|
+
*
|
|
10
|
+
* @module form/full
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Single import that sets up everything
|
|
15
|
+
* import { SchemaForm, initializeAllFieldTypes } from "@d34dman/flowdrop/form/full";
|
|
16
|
+
*
|
|
17
|
+
* // Call once at app startup
|
|
18
|
+
* initializeAllFieldTypes();
|
|
19
|
+
*
|
|
20
|
+
* // Now all field types are available
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export * from "./index.js";
|
|
24
|
+
export { FormCodeEditor, FormTemplateEditor } from "./code.js";
|
|
25
|
+
export { FormMarkdownEditor } from "./markdown.js";
|
|
26
|
+
export { registerCodeEditorField, registerTemplateEditorField, registerAllCodeEditors, isCodeEditorRegistered, isTemplateEditorRegistered, codeEditorFieldMatcher, templateEditorFieldMatcher } from "./code.js";
|
|
27
|
+
export { registerMarkdownEditorField, isMarkdownEditorRegistered, markdownEditorFieldMatcher } from "./markdown.js";
|
|
28
|
+
/**
|
|
29
|
+
* Initialize all form field types including heavy editors
|
|
30
|
+
*
|
|
31
|
+
* Call this once at application startup to enable all field types.
|
|
32
|
+
* This includes:
|
|
33
|
+
* - Code/JSON editor (CodeMirror)
|
|
34
|
+
* - Template editor (CodeMirror with Twig/Liquid syntax)
|
|
35
|
+
* - Markdown editor (EasyMDE)
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { initializeAllFieldTypes } from "@d34dman/flowdrop/form/full";
|
|
40
|
+
*
|
|
41
|
+
* // In your app's entry point
|
|
42
|
+
* initializeAllFieldTypes();
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function initializeAllFieldTypes(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Check if all field types have been initialized
|
|
48
|
+
*/
|
|
49
|
+
export declare function areAllFieldTypesInitialized(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Reset initialization state (useful for testing)
|
|
52
|
+
*/
|
|
53
|
+
export declare function resetFieldTypeInitialization(): void;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop Form Full Module
|
|
3
|
+
*
|
|
4
|
+
* Convenience module that imports and registers all form field types,
|
|
5
|
+
* including heavy editors (CodeMirror, EasyMDE).
|
|
6
|
+
*
|
|
7
|
+
* This is equivalent to importing from the light form module and manually
|
|
8
|
+
* registering all editor types.
|
|
9
|
+
*
|
|
10
|
+
* @module form/full
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Single import that sets up everything
|
|
15
|
+
* import { SchemaForm, initializeAllFieldTypes } from "@d34dman/flowdrop/form/full";
|
|
16
|
+
*
|
|
17
|
+
* // Call once at app startup
|
|
18
|
+
* initializeAllFieldTypes();
|
|
19
|
+
*
|
|
20
|
+
* // Now all field types are available
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
// Re-export everything from the light form module
|
|
24
|
+
export * from "./index.js";
|
|
25
|
+
// Import registration functions
|
|
26
|
+
import { registerCodeEditorField, registerTemplateEditorField } from "./code.js";
|
|
27
|
+
import { registerMarkdownEditorField } from "./markdown.js";
|
|
28
|
+
// Re-export heavy editor components for direct access
|
|
29
|
+
export { FormCodeEditor, FormTemplateEditor } from "./code.js";
|
|
30
|
+
export { FormMarkdownEditor } from "./markdown.js";
|
|
31
|
+
// Re-export registration functions
|
|
32
|
+
export { registerCodeEditorField, registerTemplateEditorField, registerAllCodeEditors, isCodeEditorRegistered, isTemplateEditorRegistered, codeEditorFieldMatcher, templateEditorFieldMatcher } from "./code.js";
|
|
33
|
+
export { registerMarkdownEditorField, isMarkdownEditorRegistered, markdownEditorFieldMatcher } from "./markdown.js";
|
|
34
|
+
/**
|
|
35
|
+
* Track if all field types have been initialized
|
|
36
|
+
*/
|
|
37
|
+
let allFieldTypesInitialized = false;
|
|
38
|
+
/**
|
|
39
|
+
* Initialize all form field types including heavy editors
|
|
40
|
+
*
|
|
41
|
+
* Call this once at application startup to enable all field types.
|
|
42
|
+
* This includes:
|
|
43
|
+
* - Code/JSON editor (CodeMirror)
|
|
44
|
+
* - Template editor (CodeMirror with Twig/Liquid syntax)
|
|
45
|
+
* - Markdown editor (EasyMDE)
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { initializeAllFieldTypes } from "@d34dman/flowdrop/form/full";
|
|
50
|
+
*
|
|
51
|
+
* // In your app's entry point
|
|
52
|
+
* initializeAllFieldTypes();
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export function initializeAllFieldTypes() {
|
|
56
|
+
if (allFieldTypesInitialized) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
registerCodeEditorField();
|
|
60
|
+
registerTemplateEditorField();
|
|
61
|
+
registerMarkdownEditorField();
|
|
62
|
+
allFieldTypesInitialized = true;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if all field types have been initialized
|
|
66
|
+
*/
|
|
67
|
+
export function areAllFieldTypesInitialized() {
|
|
68
|
+
return allFieldTypesInitialized;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Reset initialization state (useful for testing)
|
|
72
|
+
*/
|
|
73
|
+
export function resetFieldTypeInitialization() {
|
|
74
|
+
allFieldTypesInitialized = false;
|
|
75
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop Form Module
|
|
3
|
+
*
|
|
4
|
+
* Provides SchemaForm and form field components for building dynamic forms
|
|
5
|
+
* from JSON Schema definitions. This is the "light" version that includes
|
|
6
|
+
* only basic field types (text, number, select, checkbox, etc.).
|
|
7
|
+
*
|
|
8
|
+
* For code editor support (CodeMirror), import from "@d34dman/flowdrop/form/code"
|
|
9
|
+
* For markdown editor support (EasyMDE), import from "@d34dman/flowdrop/form/markdown"
|
|
10
|
+
*
|
|
11
|
+
* @module form
|
|
12
|
+
*
|
|
13
|
+
* @example Basic usage (small bundle - ~20KB):
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { SchemaForm } from "@d34dman/flowdrop/form";
|
|
16
|
+
*
|
|
17
|
+
* const schema = {
|
|
18
|
+
* type: "object",
|
|
19
|
+
* properties: {
|
|
20
|
+
* name: { type: "string", title: "Name" },
|
|
21
|
+
* age: { type: "number", title: "Age" }
|
|
22
|
+
* }
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example With code editor support (adds ~300KB):
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { SchemaForm } from "@d34dman/flowdrop/form";
|
|
29
|
+
* import { registerCodeEditorField } from "@d34dman/flowdrop/form/code";
|
|
30
|
+
*
|
|
31
|
+
* // Register code editor support before using
|
|
32
|
+
* registerCodeEditorField();
|
|
33
|
+
*
|
|
34
|
+
* const schema = {
|
|
35
|
+
* type: "object",
|
|
36
|
+
* properties: {
|
|
37
|
+
* config: { type: "object", format: "json", title: "Configuration" }
|
|
38
|
+
* }
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export { default as SchemaForm } from "../components/SchemaForm.svelte";
|
|
43
|
+
export { default as FormField } from "../components/form/FormFieldLight.svelte";
|
|
44
|
+
export { default as FormFieldFull } from "../components/form/FormField.svelte";
|
|
45
|
+
export { default as FormFieldWrapper } from "../components/form/FormFieldWrapper.svelte";
|
|
46
|
+
export { default as FormTextField } from "../components/form/FormTextField.svelte";
|
|
47
|
+
export { default as FormTextarea } from "../components/form/FormTextarea.svelte";
|
|
48
|
+
export { default as FormNumberField } from "../components/form/FormNumberField.svelte";
|
|
49
|
+
export { default as FormRangeField } from "../components/form/FormRangeField.svelte";
|
|
50
|
+
export { default as FormToggle } from "../components/form/FormToggle.svelte";
|
|
51
|
+
export { default as FormSelect } from "../components/form/FormSelect.svelte";
|
|
52
|
+
export { default as FormCheckboxGroup } from "../components/form/FormCheckboxGroup.svelte";
|
|
53
|
+
export { default as FormArray } from "../components/form/FormArray.svelte";
|
|
54
|
+
export type { FieldSchema, FieldType, FieldFormat, FieldOption, SchemaFormProps, BaseFieldProps, TextFieldProps, TextareaFieldProps, NumberFieldProps, ToggleFieldProps, RangeFieldProps, SelectFieldProps, CheckboxGroupFieldProps, ArrayFieldProps, FormFieldFactoryProps, FormFieldWrapperProps } from "../components/form/types.js";
|
|
55
|
+
export { isFieldOptionArray, normalizeOptions } from "../components/form/types.js";
|
|
56
|
+
export { registerFieldComponent, unregisterFieldComponent, resolveFieldComponent, getRegisteredFieldTypes, isFieldTypeRegistered, clearFieldRegistry, getFieldRegistrySize, hiddenFieldMatcher, checkboxGroupMatcher, enumSelectMatcher, textareaMatcher, rangeMatcher, textFieldMatcher, numberFieldMatcher, toggleMatcher, selectOptionsMatcher, arrayMatcher } from "./fieldRegistry.js";
|
|
57
|
+
export type { FieldComponentProps, FieldMatcher, FieldComponent, FieldComponentRegistration } from "./fieldRegistry.js";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop Form Module
|
|
3
|
+
*
|
|
4
|
+
* Provides SchemaForm and form field components for building dynamic forms
|
|
5
|
+
* from JSON Schema definitions. This is the "light" version that includes
|
|
6
|
+
* only basic field types (text, number, select, checkbox, etc.).
|
|
7
|
+
*
|
|
8
|
+
* For code editor support (CodeMirror), import from "@d34dman/flowdrop/form/code"
|
|
9
|
+
* For markdown editor support (EasyMDE), import from "@d34dman/flowdrop/form/markdown"
|
|
10
|
+
*
|
|
11
|
+
* @module form
|
|
12
|
+
*
|
|
13
|
+
* @example Basic usage (small bundle - ~20KB):
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { SchemaForm } from "@d34dman/flowdrop/form";
|
|
16
|
+
*
|
|
17
|
+
* const schema = {
|
|
18
|
+
* type: "object",
|
|
19
|
+
* properties: {
|
|
20
|
+
* name: { type: "string", title: "Name" },
|
|
21
|
+
* age: { type: "number", title: "Age" }
|
|
22
|
+
* }
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example With code editor support (adds ~300KB):
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { SchemaForm } from "@d34dman/flowdrop/form";
|
|
29
|
+
* import { registerCodeEditorField } from "@d34dman/flowdrop/form/code";
|
|
30
|
+
*
|
|
31
|
+
* // Register code editor support before using
|
|
32
|
+
* registerCodeEditorField();
|
|
33
|
+
*
|
|
34
|
+
* const schema = {
|
|
35
|
+
* type: "object",
|
|
36
|
+
* properties: {
|
|
37
|
+
* config: { type: "object", format: "json", title: "Configuration" }
|
|
38
|
+
* }
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// Main Components
|
|
44
|
+
// ============================================================================
|
|
45
|
+
export { default as SchemaForm } from "../components/SchemaForm.svelte";
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Form Field Components (Light - no heavy dependencies)
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Use the light version of FormField that uses the registry for heavy editors
|
|
50
|
+
export { default as FormField } from "../components/form/FormFieldLight.svelte";
|
|
51
|
+
// Also export the original (full) version for users who want everything
|
|
52
|
+
export { default as FormFieldFull } from "../components/form/FormField.svelte";
|
|
53
|
+
export { default as FormFieldWrapper } from "../components/form/FormFieldWrapper.svelte";
|
|
54
|
+
export { default as FormTextField } from "../components/form/FormTextField.svelte";
|
|
55
|
+
export { default as FormTextarea } from "../components/form/FormTextarea.svelte";
|
|
56
|
+
export { default as FormNumberField } from "../components/form/FormNumberField.svelte";
|
|
57
|
+
export { default as FormRangeField } from "../components/form/FormRangeField.svelte";
|
|
58
|
+
export { default as FormToggle } from "../components/form/FormToggle.svelte";
|
|
59
|
+
export { default as FormSelect } from "../components/form/FormSelect.svelte";
|
|
60
|
+
export { default as FormCheckboxGroup } from "../components/form/FormCheckboxGroup.svelte";
|
|
61
|
+
export { default as FormArray } from "../components/form/FormArray.svelte";
|
|
62
|
+
export { isFieldOptionArray, normalizeOptions } from "../components/form/types.js";
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// Field Registry (for dynamic field registration)
|
|
65
|
+
// ============================================================================
|
|
66
|
+
export { registerFieldComponent, unregisterFieldComponent, resolveFieldComponent, getRegisteredFieldTypes, isFieldTypeRegistered, clearFieldRegistry, getFieldRegistrySize,
|
|
67
|
+
// Built-in matchers for custom components
|
|
68
|
+
hiddenFieldMatcher, checkboxGroupMatcher, enumSelectMatcher, textareaMatcher, rangeMatcher, textFieldMatcher, numberFieldMatcher, toggleMatcher, selectOptionsMatcher, arrayMatcher } from "./fieldRegistry.js";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop Form Markdown Editor Module
|
|
3
|
+
*
|
|
4
|
+
* Adds EasyMDE-based markdown editor support to SchemaForm.
|
|
5
|
+
* This module bundles EasyMDE dependencies (~200KB).
|
|
6
|
+
*
|
|
7
|
+
* @module form/markdown
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { SchemaForm } from "@d34dman/flowdrop/form";
|
|
12
|
+
* import { registerMarkdownEditorField } from "@d34dman/flowdrop/form/markdown";
|
|
13
|
+
*
|
|
14
|
+
* // Register markdown editor support (call once at app startup)
|
|
15
|
+
* registerMarkdownEditorField();
|
|
16
|
+
*
|
|
17
|
+
* // Now SchemaForm will render markdown editors for format: "markdown"
|
|
18
|
+
* const schema = {
|
|
19
|
+
* type: "object",
|
|
20
|
+
* properties: {
|
|
21
|
+
* content: { type: "string", format: "markdown", title: "Content" }
|
|
22
|
+
* }
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { FieldSchema } from "../components/form/types.js";
|
|
27
|
+
export { default as FormMarkdownEditor } from "../components/form/FormMarkdownEditor.svelte";
|
|
28
|
+
export type { MarkdownEditorFieldProps } from "../components/form/types.js";
|
|
29
|
+
/**
|
|
30
|
+
* Matcher for markdown editor fields
|
|
31
|
+
* Matches: format "markdown"
|
|
32
|
+
*/
|
|
33
|
+
export declare function markdownEditorFieldMatcher(schema: FieldSchema): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Register the markdown editor field component
|
|
36
|
+
*
|
|
37
|
+
* Call this function once at application startup to enable
|
|
38
|
+
* markdown editor fields in SchemaForm. This loads EasyMDE dependencies.
|
|
39
|
+
*
|
|
40
|
+
* @param priority - Priority for field matching (default: 100)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // In your app's entry point:
|
|
45
|
+
* import { registerMarkdownEditorField } from "@d34dman/flowdrop/form/markdown";
|
|
46
|
+
*
|
|
47
|
+
* registerMarkdownEditorField();
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function registerMarkdownEditorField(priority?: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Synchronously register markdown editor field using the imported component
|
|
53
|
+
*
|
|
54
|
+
* Use this when you've already imported the component and want immediate registration.
|
|
55
|
+
*
|
|
56
|
+
* @param priority - Priority for field matching (default: 100)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { registerMarkdownEditorFieldWithComponent, FormMarkdownEditor } from "@d34dman/flowdrop/form/markdown";
|
|
61
|
+
* registerMarkdownEditorFieldWithComponent(FormMarkdownEditor);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function registerMarkdownEditorFieldWithComponent(component: any, priority?: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Check if markdown editor field is registered
|
|
67
|
+
*/
|
|
68
|
+
export declare function isMarkdownEditorRegistered(): boolean;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FlowDrop Form Markdown Editor Module
|
|
3
|
+
*
|
|
4
|
+
* Adds EasyMDE-based markdown editor support to SchemaForm.
|
|
5
|
+
* This module bundles EasyMDE dependencies (~200KB).
|
|
6
|
+
*
|
|
7
|
+
* @module form/markdown
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { SchemaForm } from "@d34dman/flowdrop/form";
|
|
12
|
+
* import { registerMarkdownEditorField } from "@d34dman/flowdrop/form/markdown";
|
|
13
|
+
*
|
|
14
|
+
* // Register markdown editor support (call once at app startup)
|
|
15
|
+
* registerMarkdownEditorField();
|
|
16
|
+
*
|
|
17
|
+
* // Now SchemaForm will render markdown editors for format: "markdown"
|
|
18
|
+
* const schema = {
|
|
19
|
+
* type: "object",
|
|
20
|
+
* properties: {
|
|
21
|
+
* content: { type: "string", format: "markdown", title: "Content" }
|
|
22
|
+
* }
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import { registerFieldComponent } from "./fieldRegistry.js";
|
|
27
|
+
// Re-export the component for direct usage if needed
|
|
28
|
+
export { default as FormMarkdownEditor } from "../components/form/FormMarkdownEditor.svelte";
|
|
29
|
+
/**
|
|
30
|
+
* Matcher for markdown editor fields
|
|
31
|
+
* Matches: format "markdown"
|
|
32
|
+
*/
|
|
33
|
+
export function markdownEditorFieldMatcher(schema) {
|
|
34
|
+
return schema.format === "markdown";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Track if markdown editor is registered
|
|
38
|
+
*/
|
|
39
|
+
let markdownEditorRegistered = false;
|
|
40
|
+
/**
|
|
41
|
+
* Register the markdown editor field component
|
|
42
|
+
*
|
|
43
|
+
* Call this function once at application startup to enable
|
|
44
|
+
* markdown editor fields in SchemaForm. This loads EasyMDE dependencies.
|
|
45
|
+
*
|
|
46
|
+
* @param priority - Priority for field matching (default: 100)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // In your app's entry point:
|
|
51
|
+
* import { registerMarkdownEditorField } from "@d34dman/flowdrop/form/markdown";
|
|
52
|
+
*
|
|
53
|
+
* registerMarkdownEditorField();
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export function registerMarkdownEditorField(priority = 100) {
|
|
57
|
+
if (markdownEditorRegistered) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Dynamic import to ensure proper code splitting
|
|
61
|
+
import("../components/form/FormMarkdownEditor.svelte").then((module) => {
|
|
62
|
+
registerFieldComponent("markdown-editor", module.default, markdownEditorFieldMatcher, priority);
|
|
63
|
+
markdownEditorRegistered = true;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Synchronously register markdown editor field using the imported component
|
|
68
|
+
*
|
|
69
|
+
* Use this when you've already imported the component and want immediate registration.
|
|
70
|
+
*
|
|
71
|
+
* @param priority - Priority for field matching (default: 100)
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { registerMarkdownEditorFieldWithComponent, FormMarkdownEditor } from "@d34dman/flowdrop/form/markdown";
|
|
76
|
+
* registerMarkdownEditorFieldWithComponent(FormMarkdownEditor);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export function registerMarkdownEditorFieldWithComponent(
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
component, priority = 100) {
|
|
82
|
+
if (markdownEditorRegistered) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
registerFieldComponent("markdown-editor", component, markdownEditorFieldMatcher, priority);
|
|
86
|
+
markdownEditorRegistered = true;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Check if markdown editor field is registered
|
|
90
|
+
*/
|
|
91
|
+
export function isMarkdownEditorRegistered() {
|
|
92
|
+
return markdownEditorRegistered;
|
|
93
|
+
}
|