cron-core

Props

NameTypeDefaultDescription

model-value

string

"* * * * *"

the current cron expression

fields

Field[]

[
  { id: 'minute', items: defaultItems(this.locale).minuteItems },
  { id: 'hour', items: defaultItems(this.locale).hourItems },
  { id: 'day', items: defaultItems(this.locale).dayItems },
  { id: 'month', items: defaultItems(this.locale).monthItems },
  { id: 'dayOfWeek', items: defaultItems(this.locale).dayOfWeekItems }
]

each field defines on position of the cron expression

periods

Period[]

[
  { id: 'minute', value: [] },
  { id: 'hour', value: ['minute'] },
  { id: 'day', value: ['hour', 'minute'] },
  { id: 'week', value: ['dayOfWeek', 'hour', 'minute'] },
  { id: 'month', value: ['day', 'dayOfWeek', 'hour', 'minute'] },
  { id: 'year', value: ['month', 'day', 'dayOfWeek', 'hour', 'minute'] }
]

the value porperty of a period determines which fields are visible

locale

string

"en"

custom-locale

Locale

en.jsopen in new window

Types

type Field = {
    id: string,
    items: Array<{
        text: string
        alt: string
        value: string
    }>
}
type Period = {
    id: string,
    value: string[]
}
// strings are nested by periodId -> fieldId -> cronType -> position
// '*' can be used as a wildcard

// cronType = empty | value | range | everyX | *
// position = prefix | text | suffix | *

type Locale = {
    '{periodId}'?: {
        '{position}'?: string // prefix/text/suffix of period selection 
        '{fieldId}'?: {
            '{cronType}'?: {
                '{positon}'?: string // prefix/text/suffix of field
            }
        }
    }
}

Events

NameDescription

update:model-value

emitted when the cron expression changed

error

emitted when the cron expression is invalid

Slots

NameDescriptionSlot Props

default

used to render the cron editor

CronState

Types

type CronState = {
    fields: Array<{
        attrs: { 
            modelValue: Array<number> //array item values
        },
        events: {
            'update:model-value': (arg1: Array<number>) => void
        },
        id: string,
        items: Array<Object> //see type Field
        cron: string,
        selectedStr: string,
        prefix: string,
        suffix: string
    }>,
    period: {
        attrs: { 
            modelValue: string //selected period id
        },
        events: {
            'update:model-value': (periodId: string) => void
        },
        items: Array<Period>,
        prefix: string,
        suffix: string
    },
    error: string
}
Contributors: Andreas Bichinger