Docyrus

CreateRecordDialog

Bottom-sheet dialog for quick record creation — selectors with dependent clearing, @ /

iOSAndroid
Preview CreateRecordDialog on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-create-record-dialog

Usage

import { CreateRecordDialog } from '@/components/docyrus-native/create-record-dialog';

<CreateRecordDialog
  open={isOpen}
  onOpenChange={setIsOpen}
  headerIcon={<DocyrusIcon icon="fal square-plus" size={16} color="muted" />}
  headerLabel="New Task"
  headerFields={[
    {
      key: 'project',
      label: 'Project',
      options: projects,
      clearsFields: ['milestone']
    },
    { key: 'milestone', label: 'Milestone', options: milestones }
  ]}
  mentionTriggers={[{ trigger: '@', options: users }]}
  aiActions={[{ id: 'summarize', label: 'Summarize', onAction: ({ subject }) => summarize(subject) }]}
  footerToggles={[{ key: 'notify', label: 'Notify assignee', defaultChecked: true }]}
  enableCreateMore
  onSubmit={data => api.create(data)} />

API Reference

CreateRecordDialogProps

PropTypeDefaultDescription
openbooleanfalseControlled open state (the form resets on every open)
onOpenChange(open: boolean) => void—Open state change
childrenReactNode—Trigger — pressing it opens the dialog
headerIconReactNode—Icon before the title
headerLabelstring—Title (after dialogTitle)
headerFieldsSelectorFieldConfig[][]Selectors above the subject
subjectPlaceholderstringui.createRecord.subjectPlaceholderSubject placeholder
descriptionPlaceholderstringui.createRecord.descriptionPlaceholderDescription placeholder
descriptionExpandedbooleanfalseShow the description input immediately
footerFieldsSelectorFieldConfig[][]Selectors below the description
footerTogglesFooterToggleConfig[][]Switch rows
mentionTriggersMentionTriggerConfig[][]@ / # autocomplete in subject + description
onMentionSelect(selection: MentionSelection) => void—Mention picked
aiActionsAiAction[][]AI action chips (onAction({ subject, description }))
enableCreateMorebooleanfalseShow the create-more switch
createMoreResetKeysstring[]['subject', 'description']Keys reset after a create-more submit (field keys allowed)
onSubmit(data: CreateRecordFormData) => void | Promise<void>—Submit handler (required)
isPendingbooleanfalseSubmitting state
saveLabelstringui.createRecord.save (“Save”)Submit label
cancelLabelstringui.createRecord.cancelCancel label
createMoreLabelstringui.createRecord.createMoreCreate-more label
addDescriptionLabelstringui.createRecord.addDescriptionAdd-description label
dialogTitlestringui.createRecord.dialogTitleTitle
classNamestring—Sheet class

SelectorFieldConfig

FieldTypeDescription
keystringField key (in data.fields)
labelstringLabel
placeholderstringEmpty text
iconReactNodeIcon beside the label
optionsSelectorOption[]Options
valuestring | nullControlled value
defaultValuestringInitial value
searchPlaceholderstringSearch placeholder (> 6 options)
emptyTextstringNo-results text
onChange(value: string | null) => voidChange callback
clearsFieldsstring[]Selector keys reset to null when this one changes

SelectorOption

FieldTypeDescription
idstringValue
labelstringLabel
descriptionstringSecondary line (native)
iconReactNodeLeading icon
colorstringDot color (hex / rgb / Tailwind name)

FooterToggleConfig

FieldTypeDescription
keystringToggle key (in data.toggles)
labelstringLabel
defaultCheckedbooleanInitial state
defaultValuebooleanDeprecated alias of defaultChecked

MentionTriggerConfig / MentionOption / MentionSelection

TypeFields
MentionTriggerConfigtrigger, options: MentionOption[], searchPlaceholder?, emptyText?
MentionOptionid, label, description?, icon?
MentionSelectiontrigger, option, field: 'subject' | 'description'

Picking a mention removes the typed @query and adds a removable chip; selections are returned in data.mentions.

AiAction

FieldTypeDescription
idstringKey
labelstringChip label
iconReactNodeChip icon
disabledbooleanDisable the chip
onAction(ctx: { subject; description }) => void | Promise<void>Handler

CreateRecordFormData

FieldTypeDescription
subjectstringTrimmed subject
descriptionstringTrimmed description
fieldsRecord<string, string | null>Selector values
togglesRecord<string, boolean>Toggle values
mentionsMentionSelection[]Picked mentions

Type Exports

TypeDescription
CreateRecordDialogPropsProps
CreateRecordFormDataSubmit payload
SelectorFieldConfig, SelectorOptionSelectors
FooterToggleConfigToggles
MentionTriggerConfig, MentionOption, MentionSelectionMentions
AiActionAI chips

Breaking changes (web-parity release)

  • CreateRecordFormData.mentions added; default save label is “Save” (was “Create”).
  • The form resets when the dialog opens (was: on close).
  • FooterToggleConfig.defaultValue is deprecated in favour of defaultChecked.

On this page