# CronCore - Component

# Props

NameTypeDefaultDescription

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', text: 'Minute', value: [] },
    { id: 'hour', text: 'Hour', value: ['minute'] },
    { id: 'day', text: 'Day', value: ['hour', 'minute'] },
    { id: 'week', text: 'Week', value: ['dayOfWeek', 'hour', 'minute'] },
    { id: 'month', text: 'Month', value: ['day', 'dayOfWeek', 'hour', 'minute'] },
    { id: 'year', text: '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.js (opens new window)

# Types

type Field = {
    id: string,
    items: Array<{
        text: string
        alt: string
        value: string
    }>
}
type Period = {
    id: string,
    text: string,
    value: string[]
}
type Locale = {
    periodPrefix: string,
    periodSuffix: string
    eachPeriod: {
        eachField: {
            empty: string,
            value: string,
            range: string,
            everyX: string,
            prefix: string,
            suffix: string,
        },
        '{{fieldId}}Field': {
            empty: string,
            value: string,
            range: string,
            everyX: string,
            prefix: string,
            suffix: string,
        }
    }
    '{{periodId}}Period': {
        eachField: {
            empty: string,
            value: string,
            range: string,
            everyX: string,
            prefix: string,
            suffix: string,
        },
        '{{fieldId}}Field': {
            empty: string,
            value: string,
            range: string,
            everyX: string,
            prefix: string,
            suffix: string,
        }
    }
}

# Events

NameDescription

input

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: { 
            value: Array<number> //array item values
        },
        events: {
            input: (arg1: Array<number>) => void
        },
        id: string,
        items: Array<Object> //see type Field
        cron: string,
        selectedStr: string,
        prefix: string,
        suffix: string
    }>,
    period: {
        attrs: { 
            value: string //selected period id
        },
        events: {
            input: (periodId: string) => void
        },
        items: Array<Period>,
        prefix: string,
        suffix: string
    },
    error: string
}