UNPKG

handsontable

Version:

Handsontable is a JavaScript Data Grid available for React, Angular and Vue.

31 lines (29 loc) 1.74 kB
"use strict"; exports.__esModule = true; exports.condition = condition; var _moment = _interopRequireDefault(require("moment")); var C = _interopRequireWildcard(require("../../../../i18n/constants")); var _conditionRegisterer = require("../../conditionRegisterer"); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const CONDITION_NAME = exports.CONDITION_NAME = '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} */ function condition(dataRow, _ref) { let [value] = _ref; const date = (0, _moment.default)(dataRow.value, dataRow.meta.dateFormat); const inputDate = (0, _moment.default)(value, dataRow.meta.dateFormat); if (!date.isValid() || !inputDate.isValid()) { return false; } return date.diff(inputDate) <= 0; } (0, _conditionRegisterer.registerCondition)(CONDITION_NAME, condition, { name: C.FILTERS_CONDITIONS_BEFORE, inputsCount: 1, showOperators: true });