@vue-js-cron/core
Version:
A renderless Vue.js cron editor.
309 lines • 8.84 kB
TypeScript
import type { Localization } from '../locale/types';
import { type ExtractPropTypes, type PropType, type SetupContext } from 'vue';
import { type CronFormat, type Field, type Period } from '../types';
import { type UseCronSegmentReturn } from './cron-segment';
export interface CronOptions {
initialValue?: string;
initialPeriod?: string;
locale?: string;
fields?: Field[];
periods?: Period[];
customLocale?: Localization;
format?: CronFormat;
}
export interface CronContext {
segmentMap: Map<string, UseCronSegmentReturn>;
}
export declare class DefaultCronOptions {
locale: string;
format: CronFormat;
initialValue(fields: Field[]): string;
fields(format: CronFormat, locale: string): Field[];
periods(format: CronFormat): Period[];
}
export declare function findFirstPeriod(periods: Period[], cron: string, fields: Field[]): Period | undefined;
export declare function useCron(options: CronOptions): {
cron: import("vue").Ref<string>;
error: import("vue").Ref<string>;
segments: {
id: string;
items: import("../types").FieldItem[];
cron: import("vue").Ref<string>;
selected: import("vue").Ref<number[]>;
error: import("vue").Ref<string>;
select: (evt: number[]) => void;
text: import("vue").Ref<string>;
prefix: import("vue").Ref<string>;
suffix: import("vue").Ref<string>;
}[];
selected: import("vue").ComputedRef<{
id: string;
items: import("../types").FieldItem[];
cron: import("vue").Ref<string>;
selected: import("vue").Ref<number[]>;
error: import("vue").Ref<string>;
select: (evt: number[]) => void;
text: import("vue").Ref<string>;
prefix: import("vue").Ref<string>;
suffix: import("vue").Ref<string>;
}[]>;
period: {
select: (periodId: string) => void;
selected: import("vue").Ref<{
id: string;
value: string[];
text?: string | undefined;
} | {
text: any;
id: string;
value: string[];
}>;
items: {
text: any;
id: string;
value: string[];
}[];
prefix: import("vue").Ref<string>;
suffix: import("vue").Ref<string>;
};
};
/**
* @interface
*/
export type UseCronReturn = ReturnType<typeof useCron>;
export declare function setupCron(props: CronCoreProps, { emit }: SetupContext<['update:model-value', 'update:period', 'error']>): UseCronReturn;
export declare const cronCoreProps: () => {
/**
* The value of the cron expression
*
* @defaultValue crontab: `* * * * *`, quartz: `* * * * * *`
*/
modelValue: {
type: StringConstructor;
};
/**
* The id of a period to select
*
* @defaultValue last entry of `CronCoreProps.periods`
*/
period: {
type: StringConstructor;
};
/**
* The format of the cron expression, either crontab or quartz
*
* @defaultValue `crontab`
*/
format: {
type: PropType<CronFormat>;
};
/**
* The locale of the component, such as `en`, `de`, etc.
*
* @defaultValue `en`
*/
locale: {
type: StringConstructor;
};
/** The segments of the cron expression, such as second, minute, hour, etc. */
fields: {
type: PropType<Field[]>;
};
/** The periods to select, e.g. Every month, day, etc. */
periods: {
type: PropType<Period[]>;
};
/** The custom locale object, used to override values of the current {@link Localization} */
customLocale: {
type: PropType<Localization>;
};
/** Number of columns in the dropdown,
* e.g. the possible values of minute (0-59) will be displayed in a grid with 5 columns
*
* @defaultValue
* ```
* {
* second: 5,
* minute: 5,
* hour: 4,
* day: 4,
* }
* ```
*/
cols: {
type: PropType<Record<string, number>>;
default: () => {
second: number;
minute: number;
hour: number;
day: number;
};
};
/** Disable the cron editor */
disabled: {
type: BooleanConstructor;
default: boolean;
};
};
/**
* Properties of {@link CronCore}.
* These properties are shared across all cron components
*
* @interface
*/
export type CronCoreProps = Partial<ExtractPropTypes<ReturnType<typeof cronCoreProps>>>;
export declare const CronCore: import("vue").DefineComponent<{
/**
* The value of the cron expression
*
* @defaultValue crontab: `* * * * *`, quartz: `* * * * * *`
*/
modelValue: {
type: StringConstructor;
};
/**
* The id of a period to select
*
* @defaultValue last entry of `CronCoreProps.periods`
*/
period: {
type: StringConstructor;
};
/**
* The format of the cron expression, either crontab or quartz
*
* @defaultValue `crontab`
*/
format: {
type: PropType<CronFormat>;
};
/**
* The locale of the component, such as `en`, `de`, etc.
*
* @defaultValue `en`
*/
locale: {
type: StringConstructor;
};
/** The segments of the cron expression, such as second, minute, hour, etc. */
fields: {
type: PropType<Field[]>;
};
/** The periods to select, e.g. Every month, day, etc. */
periods: {
type: PropType<Period[]>;
};
/** The custom locale object, used to override values of the current {@link Localization} */
customLocale: {
type: PropType<Localization>;
};
/** Number of columns in the dropdown,
* e.g. the possible values of minute (0-59) will be displayed in a grid with 5 columns
*
* @defaultValue
* ```
* {
* second: 5,
* minute: 5,
* hour: 4,
* day: 4,
* }
* ```
*/
cols: {
type: PropType<Record<string, number>>;
default: () => {
second: number;
minute: number;
hour: number;
day: number;
};
};
/** Disable the cron editor */
disabled: {
type: BooleanConstructor;
default: boolean;
};
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
[key: string]: any;
}>[] | undefined, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:model-value" | "update:period" | "error")[], "update:model-value" | "update:period" | "error", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
/**
* The value of the cron expression
*
* @defaultValue crontab: `* * * * *`, quartz: `* * * * * *`
*/
modelValue: {
type: StringConstructor;
};
/**
* The id of a period to select
*
* @defaultValue last entry of `CronCoreProps.periods`
*/
period: {
type: StringConstructor;
};
/**
* The format of the cron expression, either crontab or quartz
*
* @defaultValue `crontab`
*/
format: {
type: PropType<CronFormat>;
};
/**
* The locale of the component, such as `en`, `de`, etc.
*
* @defaultValue `en`
*/
locale: {
type: StringConstructor;
};
/** The segments of the cron expression, such as second, minute, hour, etc. */
fields: {
type: PropType<Field[]>;
};
/** The periods to select, e.g. Every month, day, etc. */
periods: {
type: PropType<Period[]>;
};
/** The custom locale object, used to override values of the current {@link Localization} */
customLocale: {
type: PropType<Localization>;
};
/** Number of columns in the dropdown,
* e.g. the possible values of minute (0-59) will be displayed in a grid with 5 columns
*
* @defaultValue
* ```
* {
* second: 5,
* minute: 5,
* hour: 4,
* day: 4,
* }
* ```
*/
cols: {
type: PropType<Record<string, number>>;
default: () => {
second: number;
minute: number;
hour: number;
day: number;
};
};
/** Disable the cron editor */
disabled: {
type: BooleanConstructor;
default: boolean;
};
}>> & {
"onUpdate:model-value"?: ((...args: any[]) => any) | undefined;
"onUpdate:period"?: ((...args: any[]) => any) | undefined;
onError?: ((...args: any[]) => any) | undefined;
}, {
cols: Record<string, number>;
disabled: boolean;
}, {}>;
//# sourceMappingURL=cron-core.d.ts.map