Skip to content

Commit 8debcdd

Browse files
committed
update skill
1 parent e3dc107 commit 8debcdd

File tree

1 file changed

+56
-0
lines changed
  • .claude/skills/generate-frontend-forms

1 file changed

+56
-0
lines changed

.claude/skills/generate-frontend-forms/SKILL.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,62 @@ The form system automatically shows:
491491
- **Checkmark** on success (fades after 2s)
492492
- **Warning icon** on validation error (with tooltip)
493493

494+
### Confirmation Dialogs
495+
496+
For dangerous operations (security settings, permissions), use the `confirm` prop to show a confirmation modal before saving. The `confirm` prop accepts either a string or a function.
497+
498+
```tsx
499+
<AutoSaveField
500+
name="require2FA"
501+
schema={schema}
502+
initialValue={false}
503+
confirm={value =>
504+
value
505+
? 'This will remove all members without 2FA. Continue?'
506+
: 'Are you sure you want to allow members without 2FA?'
507+
}
508+
mutationOptions={{...}}
509+
>
510+
{field => (
511+
<field.Layout.Row label="Require Two-Factor Auth">
512+
<field.Switch checked={field.state.value} onChange={field.handleChange} />
513+
</field.Layout.Row>
514+
)}
515+
</AutoSaveField>
516+
```
517+
518+
**Confirm Config Options:**
519+
520+
| Type | Description |
521+
| -------------------------------- | ------------------------------------------------------------------------------------------- |
522+
| `string` | Always show this message before saving |
523+
| `(value) => string \| undefined` | Function that returns a message based on the new value, or `undefined` to skip confirmation |
524+
525+
> **Note**: Confirmation dialogs always focus the Cancel button for safety, preventing accidental confirmation of dangerous operations.
526+
527+
**Examples:**
528+
529+
```tsx
530+
// ✅ Simple string - always confirm
531+
confirm="Are you sure you want to change this setting?"
532+
533+
// ✅ Only confirm when ENABLING (return undefined to skip)
534+
confirm={value => value ? 'Are you sure you want to enable this?' : undefined}
535+
536+
// ✅ Only confirm when DISABLING
537+
confirm={value => !value ? 'Disabling this removes security protection.' : undefined}
538+
539+
// ✅ Different messages for each direction
540+
confirm={value =>
541+
value
542+
? 'Enable 2FA requirement for all members?'
543+
: 'Allow members without 2FA?'
544+
}
545+
546+
// ✅ For select fields - confirm specific values
547+
confirm={value => value === 'delete' ? 'This will permanently delete all data!' : undefined}
548+
```
549+
494550
---
495551

496552
## Form Submission

0 commit comments

Comments
 (0)