Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let appendToNode;
// inputField ref might not be set in enzyme tests
if (this.inputField) {
this.cal = new flatpickr(this.inputField, {
defaultDate: value,
appendTo: appendToNode,
mode: datePickerType,
allowInput: true,
dateFormat: dateFormat,
locale: l10n[locale],
minDate: minDate,
maxDate: maxDate,
plugins:
datePickerType === 'range'
? [new rangePlugin({ input: this.toInputField })]
: '',
clickOpens: true,
nextArrow: this.rightArrowHTML(),
prevArrow: this.leftArrowHTML(),
onChange: (...args) => {
if (onChange) {
onChange(...args);
}
},
onReady: onHook,
onMonthChange: onHook,
onYearChange: onHook,
onOpen: onHook,
onValueUpdate: onHook,
});
this.addKeyboardEvents(this.cal);
get flatpickrOptions() {
const plugins = [...this.plugins, carbonFlatpickrMonthSelectPlugin];
if (this.range) {
plugins.push(rangePlugin({ input: `#${this.id}-rangeInput`, position: "left"}));
}
return Object.assign({}, this._flatpickrOptions, this.flatpickrBaseOptions, {
mode: this.range ? "range" : "single",
plugins,
dateFormat: this.dateFormat
});
}
initialize() {
const plugins = [];
if (this.data.get('range')) {
plugins.push(new rangePlugin({ input: this.data.get('range') }));
}
this.config = {
locale: document.documentElement.lang,
plugins,
};
}