Skip to content

API reference ​

All packages are written in TypeScript and ship their types. This page lists the public exports; the source files have doc comments with more detail.

@schema-form-kit/core ​

Types ​

FormSchema, FieldSchema, FieldType, StepSchema, Option, I18nText, Locale, Condition (FieldCondition, AllCondition, AnyCondition, NotCondition), ComparisonOperator, ValidationRule, FormValues, FormErrors, CustomValidator, CustomValidatorContext, ValidateOptions. See Schema and fields.

Conditions and fields ​

ExportDescription
evaluateCondition(condition, ctx)Evaluates a condition. ctx is { root: values, scope?: item }.
conditionDependencies(condition)Field names a condition reads.
isFieldVisible(field, ctx)Whether visibleWhen holds.
isFieldRequired(field, ctx)Whether required is true or its condition holds.
visibleFields(fields, ctx)The fields that are visible.
effectiveValues(schema, values)Values with hidden answers removed, cascading. Alias: pruneHiddenValues.
buildInitialValues(schema, existing?)Values filled with defaults, keeping existing.
initialItem(fields)A new item for a repeatable group.
findField(schema, name)A top-level field by name.
getSteps(schema)The steps. A form without steps has one implicit step.
fieldsOfStep(schema, step)The fields of a step, in order.
isEmpty(value)undefined, null, blank text or an empty array.

Validation ​

ExportDescription
validateForm(schema, values, options?)Errors for the whole form, keyed by value path.
validateStep(schema, index, values, options?)Errors for one step.
validateFields(fields, values, options?)Lower level; does not remove hidden values first.
hasErrors(errors)Whether there is at least one error.
errorsUnder(errors, path)Errors for a path and everything inside it.
checkSchema(schema)Static problems in a schema, as SchemaIssue[].

Text and paths ​

ExportDescription
t(text, locale?)Resolves an I18nText, falling back to the other locale.
format(template, params)Fills {name} placeholders.
messages, DEFAULT_LOCALEBuilt-in validation messages; the default locale (zh-TW).
getPath, setPathRead and immutably write a dot path such as jobs.0.company.
joinPath, splitPathBuild and split dot paths.

@schema-form-kit/vue ​

ExportDescription
SchemaFormThe form component. See below.
useSchemaForm(options)Headless state. See Customization.
FieldRendererRenders one field with its label and errors; for custom layouts.
TextField, NumberField, …The default field components; also defaultComponents.
useFormContext()Form state for components rendered inside <SchemaForm>.
FieldComponentPropsProps of a field component.
SchemaFormKitOptional plugin: app.use(SchemaFormKit) registers <SchemaForm> globally.

Styles: import '@schema-form-kit/vue/styles.css'.

<SchemaForm> props ​

PropTypeDefault
schemaFormSchemarequired
v-modelFormValues{}
locale'zh-TW' | 'en''zh-TW'
customValidatorsRecord<string, CustomValidator>—
componentsPartial<Record<FieldType, Component>>—
hideHeaderbooleanfalse

Events, slots and exposed methods are listed under Customization.

@schema-form-kit/builder-core ​

Every operation takes a schema and returns a new one; the input is never changed. Fields are addressed by a name path such as experiences.company. Invalid operations throw BuilderError.

ExportDescription
createEmptySchema(id?)A blank form.
addField(schema, fieldOrType, { parent?, index?, stepId? })Adds a field; returns { schema, path }.
removeField, duplicateFieldRemove or copy a field.
moveField(schema, path, toIndex)Reorders within its group.
moveFieldToStep(schema, name, stepId, index?)Moves a top-level field to another step.
updateField(schema, path, patch)Changes properties other than the name and type.
renameField(schema, path, newName)Renames and updates every condition that refers to the field.
changeFieldType(schema, path, type)Changes the type, keeping what still fits.
enableSteps, disableSteps, addStep, updateStep, removeStep, moveStepStep editing.
findReferences(schema, path)Conditions that refer to a field.
palette, createField(type, siblingNames), uniqueNameField templates for a palette.
RULES_BY_TYPE, CHOICE_TYPESWhich rules and options each type supports.
createHistory, commit, undo, redo, canUndo, canRedoUndo/redo history. commit can merge edits with coalesceKey.
importSchema(json), exportSchema(schema)Parse with errors and warnings; pretty-print.
getField, fieldsAt, walkFields, splitFieldPath, parentPath, childPathTree helpers.

@schema-form-kit/builder ​

ExportDescription
FormBuilderThe builder UI. Props: v-model:schema, locale.
useBuilder(schema, options?)Builder state (selection, drag and drop, history) used by the UI.
uiTextThe builder's interface text in each locale.

Styles: import '@schema-form-kit/builder/styles.css'.

Released under the MIT License.