handsontable
Version:
Handsontable is a JavaScript Data Grid available for React, Angular and Vue.
26 lines (25 loc) • 893 B
JavaScript
import * as C from "../../../../i18n/constants.mjs";
import { registerCondition } from "../../conditionRegisterer.mjs";
import { parseToLocalDate } from "../../../../helpers/dateTime.mjs";
export const CONDITION_NAME = 'intl_date_before';
/**
* @param {object} dataRow The object which holds and describes the single cell value.
* @param {Array} inputValues An array of values to compare with.
* @param {*} inputValues."0" Maximum date of a range.
* @returns {boolean}
*/
export function condition(dataRow, _ref) {
let [value] = _ref;
const dataDate = parseToLocalDate(dataRow.value);
const inputDate = parseToLocalDate(value);
if (dataDate === null || inputDate === null) {
return false;
}
return dataDate <= inputDate;
}
registerCondition(CONDITION_NAME, condition, {
name: C.FILTERS_CONDITIONS_BEFORE,
inputsCount: 1,
showOperators: true,
inputType: 'date'
});