Advanced Formily Patterns
БесплатноБез исполняемых скриптовНе проверенThis skill should be used when the user asks to "implement dynamic forms", "formily complex forms", "formily conditional fields", "formily nested forms"…
от whinc★ 15 звёзд на GitHubОб этом скилле
Advanced Formily Patterns
This skill provides advanced guidance for implementing complex form scenarios with Formily. Focus on dynamic forms, conditional fields, nested forms, async validation, performance optimization, and sophisticated form patterns in TypeScript.
Dynamic Forms
Conditional Field Visibility
import { createForm, onFieldChange } from '@formily/core'
const form = createForm({
effects() {
// Show/hide fields based on other field values
onFieldChange('userType', ['value'], (field) => {
const userType = field.value
form.setFieldState('companyName', state => {
state.visible = userType === 'business'
if (userType !== 'business') {
state.value = ''
}
})
form.setFieldState('studentId', state => {
state.visible = userType === 'student'
if (userType !== 'student') {
state.value = ''
}
})
})
}
})
Dynamic Field Options
const form = createForm({
effects() {
onFieldChange('country', ['value'], (field) => {
const country = field.value
// Update city options based on selected country
const cityOptions = country === 'us'
? [
{ label: 'New York', value: 'nyc' },
{ label: 'Los Angeles', value: 'la' },
{ label: 'Chicago', value: 'chi' }
]
: country === 'uk'
? [
{ label: 'London', value: 'lon' },
{ label: 'Manchester', value: 'man' },
{ label: 'Birmingham', value: 'bir' }
]
: []
form.setFieldState('city', state => {
state.dataSource = cityOptions
state.value = cityOptions.length > 0 ? cityOptions[0].value : ''
})
})
}
})
Dynamic Form Schema
import { createForm, Form } from '@formily/core'
interface DynamicFormConfig {
fields: Array<{
name: string
type: 'string' | 'number' | 'boolean' | 'array' | 'object'
label: string
required?: boolean
options?: Array<{ label: string; value: any }>
validation?: any[]
}>
}
const createDynamicForm = (config: DynamicFormConfig) => {
const schema = {
type: 'object',
properties: config.fields.reduce((acc, field) => {
acc[field.name] = {
type: field.type,
title: field.label,
required: field.required,
'x-validator': field.validation
}
if (field.type === 'boolean') {
acc[field.name]['x-component'] = 'Checkbox'
} else if (field.options) {
acc[field.name]['x-component'] = 'Select'
acc[field.name]['x-component-props'] = {
options: field.options
}
} else {
acc[field.name]['x-component'] = 'Input'
}
return acc
}, {} as any)
}
return createForm({ schema })
}
Array Field Patterns
Dynamic Array Items
import { createForm, isArrayField } from '@formily/core'
import { ArrayField } from '@formily/react'
const form = createForm({
initialValues: {
contacts: [
{ name: '', phone: '', relationship: '' }
]
}
})
// Add new contact item
const addContact = () => {
form.pushValues('contacts', {
name: '',
phone: '',
relationship: ''
})
}
// Remove contact item
const removeContact = (index: number) => {
form.removeValues(`contacts.${index}`)
}
// Reorder contacts
const moveContact = (fromIndex: number, toIndex: number) => {
const field = form.query('contacts')
if (isArrayField(field)) {
field.move(fromIndex, toIndex)
}
}
Nested Array Objects
interface Contact {
name: string
emails: Array<{
address: string
type: 'work' | 'personal' | 'other'
}>
}
const NestedArrayForm = () => {
const form = createForm<Contact>({
initialValues: {
name: '',
emails: []
}
})
const addEmail = () => {
form.pushValues('emails', {
address: '',
type: 'work'
})
}
return (
<FormProvider form={form}>
<ArrayField name="emails">
{(field) => (
<div>
{field.value?.map((email, index) => (
<div key={index}>
<Field name={`emails.${index}.address`}>
{/** Email input component */}
</Field>
<Field name={`emails.${index}.type`}>
{/** Email type select component */}
</Field>
</div>
))}
<button onClick={addEmail}>Add Email</button>
</div>
)}
</ArrayField>
</FormProvider>
)
}
Async Validation Patterns
Server-Side Validation
import { createForm } from '@formily/core'
const form = createForm({
effects() {
// Async email uniqueness check
onFieldChange('email', ['value'], async (field) => {
if (!field.value) return
field.validating = true
try {
const isUnique = await
Установить Advanced Formily Patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл Advanced Formily Patterns?
This skill should be used when the user asks to "implement dynamic forms", "formily complex forms", "formily conditional fields", "formily nested forms", "formily async validation", "formily performance optimization", or "advanced formily patterns".
Как установить скилл Advanced Formily Patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Advanced Formily Patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic